aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/fifolog
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2008-05-14 23:29:02 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2008-05-14 23:29:02 +0000
commit22d0b5dc8b8fbd7be4f61aa2b251f20885130da1 (patch)
tree6fc5fe5a0aa379e0bf5fbecc0ffb1a81062511e9 /usr.sbin/fifolog
parent5fea260f19780714ad63cc41dc1395eaf2c4baaa (diff)
downloadsrc-22d0b5dc8b8fbd7be4f61aa2b251f20885130da1.tar.gz
src-22d0b5dc8b8fbd7be4f61aa2b251f20885130da1.zip
Populate usage()
Submitted by: Jaakko Heinonen <jh@saunalahti.fi>
Notes
Notes: svn path=/head/; revision=179000
Diffstat (limited to 'usr.sbin/fifolog')
-rw-r--r--usr.sbin/fifolog/fifolog_create/fifolog_create.c14
-rw-r--r--usr.sbin/fifolog/fifolog_reader/fifolog_reader.c11
-rw-r--r--usr.sbin/fifolog/fifolog_writer/fifolog_writer.c17
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 2b9376579681..5e91db1276bd 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 b469a3cc23da..7178082a8702 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 469d2845eda0..fd107115711f 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);