From b50204eabab7a2f5f21f12e5668f7c8d954aa84a Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 11 Jun 2007 20:08:11 +0200 Subject: inotail.c/.h: Clean up a bit --- inotail.c | 9 --------- inotail.h | 12 ++++++++++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/inotail.c b/inotail.c index 480e60f..e98a881 100644 --- a/inotail.c +++ b/inotail.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -40,7 +39,6 @@ #include "inotail.h" #define PROGRAM_NAME "inotail" -#define BUFFER_SIZE 4096 /* inotify event buffer length for one file */ #define INOTIFY_BUFLEN (4 * sizeof(struct inotify_event)) @@ -233,12 +231,6 @@ static off_t bytes_to_offset(struct file_struct *f, unsigned long n_bytes) /* For now more or less a copy of pipe_lines() from coreutils tail */ static ssize_t tail_pipe_lines(struct file_struct *f, unsigned long n_lines) { - struct line_buf { - char buf[BUFFER_SIZE]; - size_t n_lines; - size_t n_bytes; - struct line_buf *next; - }; struct line_buf *first, *last, *tmp; ssize_t rc; unsigned long total_lines = 0; @@ -314,7 +306,6 @@ static ssize_t tail_pipe_lines(struct file_struct *f, unsigned long n_lines) size_t j; for (j = total_lines - n_lines; j; --j) { p = memchr(p, '\n', tmp->buf + tmp->n_bytes - p); - assert(p); ++p; } } diff --git a/inotail.h b/inotail.h index 836c1de..8e0f30a 100644 --- a/inotail.h +++ b/inotail.h @@ -7,8 +7,8 @@ #ifndef _INOTAIL_H #define _INOTAIL_H -/* Number of items to tail. */ -#define DEFAULT_N_LINES 10 +#define BUFFER_SIZE 4096 +#define DEFAULT_N_LINES 10 /* Number of items to tail. */ /* tail modes */ enum { M_LINES, M_BYTES }; @@ -22,6 +22,14 @@ struct file_struct { int i_watch; /* Inotify watch associated with file_struct */ }; +/* struct for linked list of buffers/lines in tail_pipe_lines */ +struct line_buf { + char buf[BUFFER_SIZE]; + size_t n_lines; + size_t n_bytes; + struct line_buf *next; +}; + #define IS_PIPELIKE(mode) \ (S_ISFIFO(mode) || S_ISSOCK(mode)) -- cgit v1.2.3-54-g00ecf