X-Git-Url: https://git.distorted.org.uk/~mdw/dvdrip/blobdiff_plain/c62cd11a8bcfdacd01498ee08da82b2afa4b2f25..844bf71b76ddf9f73cab289066b195691559bc6b:/lib.c diff --git a/lib.c b/lib.c index 320f04d..2147228 100644 --- a/lib.c +++ b/lib.c @@ -137,6 +137,19 @@ double tvdiff(const struct timeval *tv_lo, const struct timeval *tv_hi) (tv_hi->tv_usec - tv_lo->tv_usec)/1.0e6); } +int read_line(FILE *fp, struct buf *b) +{ + int ch; + + ch = getc(fp); + if (ch == EOF) + return (-1); + else if (ch != '\n') + do { buf_putc(b, ch); ch = getc(fp); } while (ch != EOF && ch != '\n'); + buf_putz(b); + return (0); +} + void carefully_write(int fd, const void *buf, size_t sz) { const unsigned char *p = buf;