MCPcopy Create free account
hub / github.com/NetHack/NetHack / rsrc_dlb_fgets

Function rsrc_dlb_fgets

outdated/sys/mac/macfile.c:426–456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424}
425
426char *
427rsrc_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
458int
459rsrc_dlb_fgetc(dlb *dp)

Callers

nothing calls this directly

Calls 1

IsHandleFileFunction · 0.85

Tested by

no test coverage detected