xref: /csrg-svn/usr.sbin/accton/accton.c (revision 61772)
134916Sbostic /*
2*61772Sbostic  * Copyright (c) 1988, 1993
3*61772Sbostic  *	The Regents of the University of California.  All rights reserved.
434916Sbostic  *
542790Sbostic  * %sccs.include.redist.c%
634916Sbostic  */
734916Sbostic 
834916Sbostic #ifndef lint
9*61772Sbostic static char copyright[] =
10*61772Sbostic "@(#) Copyright (c) 1988, 1993\n\
11*61772Sbostic 	The Regents of the University of California.  All rights reserved.\n";
1234916Sbostic #endif /* not lint */
1334916Sbostic 
1434916Sbostic #ifndef lint
15*61772Sbostic static char sccsid[] = "@(#)accton.c	8.1 (Berkeley) 06/06/93";
1634916Sbostic #endif /* not lint */
1734916Sbostic 
1851963Sbostic #include <sys/types.h>
1951963Sbostic #include <errno.h>
2051963Sbostic #include <unistd.h>
2151963Sbostic #include <stdlib.h>
2234916Sbostic #include <stdio.h>
2351963Sbostic #include <string.h>
2434916Sbostic 
2551963Sbostic void usage __P((void));
2651963Sbostic 
2751963Sbostic int
main(argc,argv)28948Sbill main(argc, argv)
2934916Sbostic 	int argc;
3051963Sbostic 	char *argv[];
31948Sbill {
3251963Sbostic 	int ch;
3351963Sbostic 
3451963Sbostic 	while ((ch = getopt(argc, argv, "")) != EOF)
3551963Sbostic 		switch(ch) {
3651963Sbostic 		case '?':
3751963Sbostic 		default:
3851963Sbostic 			usage();
3951963Sbostic 		}
4051963Sbostic 	argc -= optind;
4151963Sbostic 	argv += optind;
4251963Sbostic 
4351963Sbostic 	switch(argc) {
4451964Sbostic 	case 0:
4551963Sbostic 		if (acct(NULL)) {
4651963Sbostic 			(void)fprintf(stderr,
4751963Sbostic 			    "accton: %s\n", strerror(errno));
4851963Sbostic 			exit(1);
4951963Sbostic 		}
5051963Sbostic 		break;
5151964Sbostic 	case 1:
5251964Sbostic 		if (acct(*argv)) {
5351963Sbostic 			(void)fprintf(stderr,
5451963Sbostic 			    "accton: %s: %s\n", *argv, strerror(errno));
5551963Sbostic 			exit(1);
5651963Sbostic 		}
5751963Sbostic 		break;
5851963Sbostic 	default:
5951963Sbostic 		usage();
6034916Sbostic 	}
61948Sbill 	exit(0);
62948Sbill }
6351963Sbostic 
6451963Sbostic void
usage()6551963Sbostic usage()
6651963Sbostic {
6751963Sbostic 	(void)fprintf(stderr, "usage: accton [file]\n");
6851963Sbostic 	exit(1);
6951963Sbostic }
70