| 424 | } |
| 425 | |
| 426 | char * |
| 427 | rsrc_dlb_fgets(char *buf, int len, dlb *dp) |
| 428 | { |
| 429 | HandleFile *hfp = IsHandleFile(dp->fd); |
| 430 | char *p; |
| 431 | int bytesLeft, n = 0; |
| 432 | |
| 433 | if (hfp && hfp->mark < hfp->size) { |
| 434 | bytesLeft = hfp->size - hfp->mark; |
| 435 | if (bytesLeft < len) |
| 436 | len = bytesLeft; |
| 437 | |
| 438 | HLock(hfp->data); |
| 439 | for (n = 0, p = *hfp->data + hfp->mark; n < len; n++, p++) { |
| 440 | buf[n] = *p; |
| 441 | if (*p == '\r') |
| 442 | buf[n] = '\n'; |
| 443 | if (buf[n] == '\n') { |
| 444 | n++; /* we want the return in the buffer */ |
| 445 | break; |
| 446 | } |
| 447 | } |
| 448 | HUnlock(hfp->data); |
| 449 | |
| 450 | hfp->mark += n; |
| 451 | if (n != 0) |
| 452 | buf[n] = '\0'; /* null terminate result */ |
| 453 | } |
| 454 | |
| 455 | return n ? buf : NULL; |
| 456 | } |
| 457 | |
| 458 | int |
| 459 | rsrc_dlb_fgetc(dlb *dp) |
nothing calls this directly
no test coverage detected