diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-12-18 20:48:34 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-12-18 20:48:34 +0000 |
commit | 7ce1cd82f78fc062293ec0d0f49ea17ba7c095db (patch) | |
tree | 02d3782f113ea45eeb7753bf37a514063ab3252a | |
parent | f08da0e1a8bec8b1b9597f5adf2f2355f9b82613 (diff) |
merge freebsd version of accton
-rw-r--r-- | usr.sbin/accton/accton.c | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/usr.sbin/accton/accton.c b/usr.sbin/accton/accton.c index 231e5141956..f269fa4dcee 100644 --- a/usr.sbin/accton/accton.c +++ b/usr.sbin/accton/accton.c @@ -39,24 +39,52 @@ char copyright[] = #ifndef lint /* from: static char sccsid[] = "@(#)accton.c 4.3 (Berkeley) 6/1/90"; */ -static char *rcsid = "$Id: accton.c,v 1.3 1997/07/04 20:32:13 todd Exp $"; +static char *rcsid = "$Id: accton.c,v 1.4 1998/12/18 20:48:33 deraadt Exp $"; #endif /* not lint */ +#include <sys/types.h> +#include <err.h> #include <stdio.h> #include <unistd.h> +#include <stdlib.h> +#include <string.h> + +static void usage __P((void)); + +void +usage() +{ + fputs("usage: accton [file]\n", stderr); + exit(1); +} int main(argc, argv) int argc; char **argv; { - if (argc > 2) { - fputs("usage: accton [file]\n", stderr); - exit(1); - } - if (acct(argc == 2 ? argv[1] : (char *)NULL)) { - perror("accton"); - exit(1); + int ch; + + while ((ch = getopt(argc, argv, "")) != -1) + switch(ch) { + case '?': + default: + usage(); + } + argc -= optind; + argv += optind; + + switch(argc) { + case 0: + if (acct(NULL)) + err(1, NULL); + break; + case 1: + if (acct(*argv)) + err(1, "%s", *argv); + break; + default: + usage(); } exit(0); } |