xref: /original-bsd/usr.sbin/accton/accton.c (revision c3e32dec)
1 /*
2  * Copyright (c) 1988, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char copyright[] =
10 "@(#) Copyright (c) 1988, 1993\n\
11 	The Regents of the University of California.  All rights reserved.\n";
12 #endif /* not lint */
13 
14 #ifndef lint
15 static char sccsid[] = "@(#)accton.c	8.1 (Berkeley) 06/06/93";
16 #endif /* not lint */
17 
18 #include <sys/types.h>
19 #include <errno.h>
20 #include <unistd.h>
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <string.h>
24 
25 void usage __P((void));
26 
27 int
28 main(argc, argv)
29 	int argc;
30 	char *argv[];
31 {
32 	int ch;
33 
34 	while ((ch = getopt(argc, argv, "")) != EOF)
35 		switch(ch) {
36 		case '?':
37 		default:
38 			usage();
39 		}
40 	argc -= optind;
41 	argv += optind;
42 
43 	switch(argc) {
44 	case 0:
45 		if (acct(NULL)) {
46 			(void)fprintf(stderr,
47 			    "accton: %s\n", strerror(errno));
48 			exit(1);
49 		}
50 		break;
51 	case 1:
52 		if (acct(*argv)) {
53 			(void)fprintf(stderr,
54 			    "accton: %s: %s\n", *argv, strerror(errno));
55 			exit(1);
56 		}
57 		break;
58 	default:
59 		usage();
60 	}
61 	exit(0);
62 }
63 
64 void
65 usage()
66 {
67 	(void)fprintf(stderr, "usage: accton [file]\n");
68 	exit(1);
69 }
70