Populate usage()

Submitted by:   Jaakko Heinonen <jh@saunalahti.fi>
This commit is contained in:
Poul-Henning Kamp 2008-05-14 23:29:02 +00:00
parent 5fea260f19
commit 22d0b5dc8b
3 changed files with 30 additions and 12 deletions

View File

@ -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)

View File

@ -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, "-"))

View File

@ -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);