accton.c revision 28996
1161475Sdelphij/*
260786Sps * Copyright (c) 1988, 1993
360786Sps *	The Regents of the University of California.  All rights reserved.
460786Sps *
5170256Sdelphij * Redistribution and use in source and binary forms, with or without
660786Sps * modification, are permitted provided that the following conditions
760786Sps * are met:
8170256Sdelphij * 1. Redistributions of source code must retain the above copyright
9170256Sdelphij *    notice, this list of conditions and the following disclaimer.
10170256Sdelphij * 2. Redistributions in binary form must reproduce the above copyright
11170256Sdelphij *    notice, this list of conditions and the following disclaimer in the
12170256Sdelphij *    documentation and/or other materials provided with the distribution.
13170256Sdelphij * 3. All advertising materials mentioning features or use of this software
14170256Sdelphij *    must display the following acknowledgement:
15170256Sdelphij *	This product includes software developed by the University of
16170256Sdelphij *	California, Berkeley and its contributors.
17170256Sdelphij * 4. Neither the name of the University nor the names of its contributors
18161475Sdelphij *    may be used to endorse or promote products derived from this software
19161475Sdelphij *    without specific prior written permission.
2060786Sps *
2160786Sps * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22170256Sdelphij * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23170256Sdelphij * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24170256Sdelphij * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25161475Sdelphij * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26170256Sdelphij * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27161475Sdelphij * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28161475Sdelphij * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29161475Sdelphij * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30161475Sdelphij * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3160786Sps * SUCH DAMAGE.
32170256Sdelphij */
33161475Sdelphij
34161475Sdelphij#ifndef lint
3560786Spsstatic const char copyright[] =
3660786Sps"@(#) Copyright (c) 1988, 1993\n\
37170256Sdelphij	The Regents of the University of California.  All rights reserved.\n";
38161475Sdelphij#endif /* not lint */
39161475Sdelphij
40161475Sdelphij#ifndef lint
4160786Sps#if 0
42161475Sdelphijstatic char sccsid[] = "@(#)accton.c	8.1 (Berkeley) 6/6/93";
43161475Sdelphij#endif
4460786Spsstatic const char rcsid[] =
4560786Sps	"$Id$";
46161475Sdelphij#endif /* not lint */
47161475Sdelphij
48161475Sdelphij#include <sys/types.h>
49161475Sdelphij#include <err.h>
5060786Sps#include <stdio.h>
51161475Sdelphij#include <stdlib.h>
52161475Sdelphij#include <string.h>
5360786Sps#include <unistd.h>
5460786Sps
55161475Sdelphijstatic void usage __P((void));
56161475Sdelphij
5760786Spsint
5860786Spsmain(argc, argv)
59161475Sdelphij	int argc;
60161475Sdelphij	char *argv[];
6160786Sps{
6260786Sps	int ch;
63161475Sdelphij
64161475Sdelphij	while ((ch = getopt(argc, argv, "")) != -1)
65161475Sdelphij		switch(ch) {
6660786Sps		case '?':
6760786Sps		default:
68161475Sdelphij			usage();
69161475Sdelphij		}
70161475Sdelphij	argc -= optind;
7160786Sps	argv += optind;
72161475Sdelphij
73161475Sdelphij	switch(argc) {
7460786Sps	case 0:
7560786Sps		if (acct(NULL))
76161475Sdelphij			err(1, NULL);
77161475Sdelphij		break;
78161475Sdelphij	case 1:
7960786Sps		if (acct(*argv))
8060786Sps			err(1, "%s", *argv);
81161475Sdelphij		break;
82161475Sdelphij	default:
83161475Sdelphij		usage();
8460786Sps	}
8560786Sps	exit(0);
86161475Sdelphij}
87161475Sdelphij
88161475Sdelphijstatic void
89161475Sdelphijusage()
9089019Sps{
9160786Sps	(void)fprintf(stderr, "usage: accton [file]\n");
9260786Sps	exit(1);
93161475Sdelphij}
94161475Sdelphij