#undef BUFSECTORS
}
-static 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);
-}
-
#define PRF_HYPHEN 1u
static int parse_range(const char *p, unsigned f,
secaddr *start_out, secaddr *end_out)
(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;
* fractional.
*/
+extern int read_line(FILE *fp, struct buf *b);
+ /* Read a line from FP, appending it to the buffer B, leaving the
+ * string in B null-terminated (as if by `buf_putz'). Return 0 on
+ * success, or -1 if nothing was read (not even an empty line) before
+ * we encountered end-of-file or a read error.
+ */
+
extern void carefully_write(int fd, const void *buf, size_t sz);
/* Write SZ bytes to file descriptor FD, starting at BUF. Report a
* fatal error if this fails. Correctly handles short writes and