From e9b9fc223b3686850483d5155c041efae3100c74 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 11 Jul 2006 23:31:09 +0200 Subject: * Update usage() * Use constant for program name --- inotail.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'inotail.c') diff --git a/inotail.c b/inotail.c index 52f91ae..a852b52 100644 --- a/inotail.c +++ b/inotail.c @@ -37,6 +37,7 @@ #include "inotail.h" +#define PROGRAM_NAME "inotail" #define VERSION "0.1" #define BUFFER_SIZE 4096 @@ -44,10 +45,16 @@ /* Print header with filename before tailing the file? */ static char verbose = 0; -static void usage(void) +static void usage(int status) { - fprintf(stderr, "usage: simpletail [-f] [-n ] \n"); - exit(EXIT_FAILURE); + fprintf(stderr, "Usage: %s [OPTION]... [FILE]...\n\n", PROGRAM_NAME); + fprintf(stderr, " -c N output the last N bytes\n"); + fprintf(stderr, " -f output as the file grows (that's were %s differs from pure tail)\n", PROGRAM_NAME); + fprintf(stderr, " -n N output the last N lines (default: %d)\n", DEFAULT_N_LINES); + fprintf(stderr, " -v always output headers giving file names\n"); + fprintf(stderr, " -V Show %s version\n", PROGRAM_NAME); + + exit(status); } static void write_header(const char *filename) @@ -254,9 +261,6 @@ int main(int argc, char **argv) char **filenames; struct file_struct *files; - if (argc < 2) - usage(); - for (opt = 1; (opt < argc) && (argv[opt][0] == '-'); opt++) { switch (argv[opt][1]) { case 'c': @@ -277,12 +281,12 @@ int main(int argc, char **argv) verbose = 1; break; case 'V': - fprintf(stderr, "inotail %s\n", VERSION); + fprintf(stderr, "%s %s\n", PROGRAM_NAME, VERSION); return 0; case 'h': - default: - usage(); - break; + usage(EXIT_SUCCESS); + default: + usage(EXIT_FAILURE); } } @@ -292,8 +296,8 @@ int main(int argc, char **argv) filenames = argv + opt; } else { /* For now, reading from stdin will be implemented later (tm) */ - usage(); - return -1; + /* XXX: This is not like GNU tail behaves! */ + usage(EXIT_FAILURE); } files = malloc(n_files * sizeof(struct file_struct)); -- cgit v1.2.3-54-g00ecf href='/cgit.cgi/linux/net-next.git/diff/Documentation/media?h=nds-private-remove&id=bd0b560a75bcebdcb48d82ed81f6b77c12771107&id2=2144fff7df8e76654fa72b0a9d2324ce2e0c8a5c'>diff
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/media')