/* vi: set sw=4 ts=4: */
#include "internal.h"
+
/* This file contains _two_ implementations of tail. One is
* a bit more full featured, but costs 6k. The other (i.e. the
* SIMPLE_TAIL one) is less capable, but is good enough for about
#define XWRITE(fd, buffer, n_bytes) \
do { \
if (n_bytes > 0 && fwrite ((buffer), 1, (n_bytes), stdout) == 0) \
- error("write error"); \
+ errorMsg("write error"); \
} while (0)
/* Number of items to tail. */
lseek(fd, pos, SEEK_SET);
bytes_read = fullRead(fd, buffer, bytes_read);
if (bytes_read == -1)
- error("read error");
+ errorMsg("read error");
/* Count the incomplete line on files that don't end with a newline. */
if (bytes_read && buffer[bytes_read - 1] != '\n')
}
while ((bytes_read = fullRead(fd, buffer, BUFSIZ)) > 0);
if (bytes_read == -1)
- error("read error");
+ errorMsg("read error");
return 0;
}
}
}
if (tmp->nbytes == -1)
- error("read error");
+ errorMsg("read error");
free((char *) tmp);
total += bytes_read;
}
if (bytes_read == -1)
- error("read error");
+ errorMsg("read error");
if (forever) {
fflush(stdout);
sleep(1);
write_header(filename);
if (fstat(fd, &stats))
- error("fstat error");
+ errorMsg("fstat error");
/* Use file_lines only if FD refers to a regular file with
its file pointer positioned at beginning of file. */
/* Not standard input. */
fd = open(filename, O_RDONLY);
if (fd == -1)
- error("open error");
+ fatalError("open error");
errors = tail_lines(filename, fd, (long) n_units);
close(fd);