aboutsummaryrefslogtreecommitdiff
path: root/coreutils/tail.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-07-14 06:49:52 +0000
committerEric Andersen <andersen@codepoet.org>2000-07-14 06:49:52 +0000
commitfad04fdd12604a46eff62875343515c33e1863c6 (patch)
tree7b840eb074878c454141ce76ba7328f4a8621f1b /coreutils/tail.c
parentb870af09ae1892ab84dd089529675cc2df533e71 (diff)
downloadbusybox-w32-fad04fdd12604a46eff62875343515c33e1863c6.tar.gz
busybox-w32-fad04fdd12604a46eff62875343515c33e1863c6.tar.bz2
busybox-w32-fad04fdd12604a46eff62875343515c33e1863c6.zip
More cleanups.
-Erik
Diffstat (limited to 'coreutils/tail.c')
-rw-r--r--coreutils/tail.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/coreutils/tail.c b/coreutils/tail.c
index 601f0873d..9232356eb 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -104,7 +104,7 @@ static void write_header(const char *filename)
104 Return 0 if successful, 1 if an error occurred. */ 104 Return 0 if successful, 1 if an error occurred. */
105 105
106static int 106static int
107file_lines(const char *filename, int fd, long int n_lines, off_t pos) 107file_lines(int fd, long int n_lines, off_t pos)
108{ 108{
109 char buffer[BUFSIZ]; 109 char buffer[BUFSIZ];
110 int bytes_read; 110 int bytes_read;
@@ -164,7 +164,7 @@ file_lines(const char *filename, int fd, long int n_lines, off_t pos)
164 Buffer the text as a linked list of LBUFFERs, adding them as needed. 164 Buffer the text as a linked list of LBUFFERs, adding them as needed.
165 Return 0 if successful, 1 if an error occured. */ 165 Return 0 if successful, 1 if an error occured. */
166 166
167static int pipe_lines(const char *filename, int fd, long int n_lines) 167static int pipe_lines(int fd, long int n_lines)
168{ 168{
169 struct linebuffer { 169 struct linebuffer {
170 int nbytes, nlines; 170 int nbytes, nlines;
@@ -266,7 +266,7 @@ static int pipe_lines(const char *filename, int fd, long int n_lines)
266 If `forever' is nonzero, keep reading from the end of the file 266 If `forever' is nonzero, keep reading from the end of the file
267 until killed. Return the number of bytes read from the file. */ 267 until killed. Return the number of bytes read from the file. */
268 268
269static long dump_remainder(const char *filename, int fd) 269static long dump_remainder(int fd)
270{ 270{
271 char buffer[BUFSIZ]; 271 char buffer[BUFSIZ];
272 int bytes_read; 272 int bytes_read;
@@ -312,11 +312,11 @@ static int tail_lines(const char *filename, int fd, long int n_lines)
312 if (S_ISREG(stats.st_mode) 312 if (S_ISREG(stats.st_mode)
313 && lseek(fd, (off_t) 0, SEEK_CUR) == (off_t) 0) { 313 && lseek(fd, (off_t) 0, SEEK_CUR) == (off_t) 0) {
314 length = lseek(fd, (off_t) 0, SEEK_END); 314 length = lseek(fd, (off_t) 0, SEEK_END);
315 if (length != 0 && file_lines(filename, fd, n_lines, length)) 315 if (length != 0 && file_lines(fd, n_lines, length))
316 return 1; 316 return 1;
317 dump_remainder(filename, fd); 317 dump_remainder(fd);
318 } else 318 } else
319 return pipe_lines(filename, fd, n_lines); 319 return pipe_lines(fd, n_lines);
320 320
321 return 0; 321 return 0;
322} 322}
@@ -616,7 +616,7 @@ file_lines(const char *filename, int fd, long int n_lines, off_t pos)
616 Buffer the text as a linked list of LBUFFERs, adding them as needed. 616 Buffer the text as a linked list of LBUFFERs, adding them as needed.
617 Return 0 if successful, 1 if an error occured. */ 617 Return 0 if successful, 1 if an error occured. */
618 618
619static int pipe_lines(const char *filename, int fd, long int n_lines) 619static int pipe_lines(int fd, long int n_lines)
620{ 620{
621 struct linebuffer { 621 struct linebuffer {
622 int nbytes, nlines; 622 int nbytes, nlines;
@@ -850,7 +850,7 @@ static int start_lines(const char *filename, int fd, long int n_lines)
850 If `forever' is nonzero, keep reading from the end of the file 850 If `forever' is nonzero, keep reading from the end of the file
851 until killed. Return the number of bytes read from the file. */ 851 until killed. Return the number of bytes read from the file. */
852 852
853static long dump_remainder(const char *filename, int fd) 853static long dump_remainder(int fd)
854{ 854{
855 char buffer[BUFSIZ]; 855 char buffer[BUFSIZ];
856 int bytes_read; 856 int bytes_read;
@@ -925,7 +925,7 @@ static void tail_forever(char **names, int nfiles)
925 write_header(names[i], NULL); 925 write_header(names[i], NULL);
926 last = i; 926 last = i;
927 } 927 }
928 file_sizes[i] += dump_remainder(names[i], file_descs[i]); 928 file_sizes[i] += dump_remainder(file_descs[i]);
929 } 929 }
930 930
931 /* If none of the files changed size, sleep. */ 931 /* If none of the files changed size, sleep. */
@@ -955,7 +955,7 @@ static int tail_bytes(const char *filename, int fd, off_t n_bytes)
955 lseek(fd, n_bytes, SEEK_CUR); 955 lseek(fd, n_bytes, SEEK_CUR);
956 else if (start_bytes(filename, fd, n_bytes)) 956 else if (start_bytes(filename, fd, n_bytes))
957 return 1; 957 return 1;
958 dump_remainder(filename, fd); 958 dump_remainder(fd);
959 } else { 959 } else {
960 if (S_ISREG(stats.st_mode)) { 960 if (S_ISREG(stats.st_mode)) {
961 off_t current_pos, end_pos; 961 off_t current_pos, end_pos;
@@ -1021,9 +1021,9 @@ static int tail_lines(const char *filename, int fd, long int n_lines)
1021 length = lseek(fd, (off_t) 0, SEEK_END); 1021 length = lseek(fd, (off_t) 0, SEEK_END);
1022 if (length != 0 && file_lines(filename, fd, n_lines, length)) 1022 if (length != 0 && file_lines(filename, fd, n_lines, length))
1023 return 1; 1023 return 1;
1024 dump_remainder(filename, fd); 1024 dump_remainder(fd);
1025 } else 1025 } else
1026 return pipe_lines(filename, fd, n_lines); 1026 return pipe_lines(fd, n_lines);
1027 } 1027 }
1028 return 0; 1028 return 0;
1029} 1029}