diff options
author | phk <phk@FreeBSD.org> | 2008-05-14 23:29:02 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2008-05-14 23:29:02 +0000 |
commit | b6c607e98bed397a6ce4d11cdbc438e22bb3c0cb (patch) | |
tree | 6fc5fe5a0aa379e0bf5fbecc0ffb1a81062511e9 /usr.sbin/fifolog | |
parent | aee2bbc2886f13a2df8f93770a615656c3929ff8 (diff) | |
download | FreeBSD-src-b6c607e98bed397a6ce4d11cdbc438e22bb3c0cb.zip FreeBSD-src-b6c607e98bed397a6ce4d11cdbc438e22bb3c0cb.tar.gz |
Populate usage()
Submitted by: Jaakko Heinonen <jh@saunalahti.fi>
Diffstat (limited to 'usr.sbin/fifolog')
-rw-r--r-- | usr.sbin/fifolog/fifolog_create/fifolog_create.c | 14 | ||||
-rw-r--r-- | usr.sbin/fifolog/fifolog_reader/fifolog_reader.c | 11 | ||||
-rw-r--r-- | usr.sbin/fifolog/fifolog_writer/fifolog_writer.c | 17 |
3 files changed, 30 insertions, 12 deletions
diff --git a/usr.sbin/fifolog/fifolog_create/fifolog_create.c b/usr.sbin/fifolog/fifolog_create/fifolog_create.c index 2b93765..5e91db1 100644 --- a/usr.sbin/fifolog/fifolog_create/fifolog_create.c +++ b/usr.sbin/fifolog/fifolog_create/fifolog_create.c @@ -27,6 +27,8 @@ */ #include <stdio.h> +#include <stdlib.h> +#include <sysexits.h> #include <unistd.h> #include <err.h> #include <libutil.h> @@ -36,6 +38,14 @@ #define DEF_RECSIZE 512 #define DEF_RECCNT (24 * 60 * 60) +static void +usage(void) +{ + fprintf(stderr, "Usage: fifolog_create [-l record-size] " + "[-r record-count] [-s size] file\n"); + exit(EX_USAGE); +} + int main(int argc, char * const *argv) { @@ -63,13 +73,13 @@ main(int argc, char * const *argv) err(1, "Couldn't parse -s argument"); break; default: - errx(1, "Usage"); + usage(); } } argc -= optind; argv += optind; if (argc != 1) - errx(1, "Usage"); + usage(); if (size != 0 && reccnt != 0 && recsize != 0) { /* N N N */ if (size != reccnt * recsize) diff --git a/usr.sbin/fifolog/fifolog_reader/fifolog_reader.c b/usr.sbin/fifolog/fifolog_reader/fifolog_reader.c index b469a3c..7178082 100644 --- a/usr.sbin/fifolog/fifolog_reader/fifolog_reader.c +++ b/usr.sbin/fifolog/fifolog_reader/fifolog_reader.c @@ -33,6 +33,7 @@ #include <time.h> #include <string.h> #include <stdlib.h> +#include <sysexits.h> #include <regex.h> #include "libfifolog.h" @@ -87,7 +88,7 @@ Usage(void) "\t-t # format timestamps as %%Y%%m%%d%%H%%M%%S\n" "\t-T <timestamp format>\n" ); - exit (2); + exit (EX_USAGE); } int @@ -96,9 +97,6 @@ main(int argc, char * const *argv) int ch, i; off_t o; struct fifolog_reader *fl; - const char *progname; - - progname=argv[0]; time(&opt_E); opt_o = "-"; @@ -149,13 +147,14 @@ main(int argc, char * const *argv) } } + if (argv[0] == NULL) + Usage(); + fprintf(stderr, "From\t%jd %s", (intmax_t)opt_B, ctime(&opt_B)); fprintf(stderr, "To\t%jd %s", (intmax_t)opt_E, ctime(&opt_E)); if (opt_B >= opt_E) errx(1, "Begin time not before End time"); - if (argv[0] == NULL) - errx(1, "Usage: %s [options] fifolog", progname); fl = fifolog_reader_open(argv[0]); if (!strcmp(opt_o, "-")) diff --git a/usr.sbin/fifolog/fifolog_writer/fifolog_writer.c b/usr.sbin/fifolog/fifolog_writer/fifolog_writer.c index 469d284..fd10711 100644 --- a/usr.sbin/fifolog/fifolog_writer/fifolog_writer.c +++ b/usr.sbin/fifolog/fifolog_writer/fifolog_writer.c @@ -28,6 +28,7 @@ #include <stdio.h> #include <stdlib.h> +#include <sysexits.h> #include <err.h> #include <unistd.h> #include <ctype.h> @@ -38,6 +39,14 @@ #include "libfifolog.h" +static void +usage(void) +{ + fprintf(stderr, "fifolog_writer [-w write-rate] [-s sync-rate] " + "[-z compression] file\n"); + exit(EX_USAGE); +} + int main(int argc, char * const *argv) { @@ -62,19 +71,19 @@ main(int argc, char * const *argv) z_opt = strtoul(optarg, NULL, 0); break; default: - errx(1, "Usage"); + usage(); } } argc -= optind; argv += optind; if (argc != 1) - errx(1, "Usage"); + usage(); if (z_opt > 9) - errx(1, "Usage"); + usage(); if (w_opt > s_opt) - errx(1, "Usage"); + usage(); f = fifolog_write_new(); assert(f != NULL); |