1*dccf569eSjoerg /* $NetBSD: accton.c,v 1.12 2011/08/29 20:38:54 joerg Exp $ */
22488f833Smikel
3cf982846Scgd /*
42488f833Smikel * Copyright (c) 1988, 1993
52488f833Smikel * The Regents of the University of California. All rights reserved.
6cf982846Scgd *
7cf982846Scgd * Redistribution and use in source and binary forms, with or without
8cf982846Scgd * modification, are permitted provided that the following conditions
9cf982846Scgd * are met:
10cf982846Scgd * 1. Redistributions of source code must retain the above copyright
11cf982846Scgd * notice, this list of conditions and the following disclaimer.
12cf982846Scgd * 2. Redistributions in binary form must reproduce the above copyright
13cf982846Scgd * notice, this list of conditions and the following disclaimer in the
14cf982846Scgd * documentation and/or other materials provided with the distribution.
15326b2259Sagc * 3. Neither the name of the University nor the names of its contributors
16cf982846Scgd * may be used to endorse or promote products derived from this software
17cf982846Scgd * without specific prior written permission.
18cf982846Scgd *
19cf982846Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20cf982846Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21cf982846Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22cf982846Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23cf982846Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24cf982846Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25cf982846Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26cf982846Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27cf982846Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28cf982846Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29cf982846Scgd * SUCH DAMAGE.
30cf982846Scgd */
31cf982846Scgd
3295dff5caSlukem #include <sys/cdefs.h>
33cf982846Scgd #ifndef lint
349c194566Slukem __COPYRIGHT("@(#) Copyright (c) 1988, 1993\
359c194566Slukem The Regents of the University of California. All rights reserved.");
36cf982846Scgd #endif /* not lint */
37cf982846Scgd
38cf982846Scgd #ifndef lint
3995dff5caSlukem #if 0
4095dff5caSlukem static char sccsid[] = "@(#)accton.c 8.1 (Berkeley) 6/6/93";
4195dff5caSlukem #else
42*dccf569eSjoerg __RCSID("$NetBSD: accton.c,v 1.12 2011/08/29 20:38:54 joerg Exp $");
4395dff5caSlukem #endif
44cf982846Scgd #endif /* not lint */
45cf982846Scgd
462488f833Smikel #include <sys/types.h>
478ff96fa4Slukem #include <err.h>
482488f833Smikel #include <errno.h>
492488f833Smikel #include <unistd.h>
502488f833Smikel #include <stdlib.h>
51cf982846Scgd #include <stdio.h>
522488f833Smikel #include <string.h>
53cf982846Scgd
54*dccf569eSjoerg __dead static void usage(void);
552488f833Smikel
562488f833Smikel int
main(int argc,char ** argv)5705b0c4c2Sxtraeme main(int argc, char **argv)
58cf982846Scgd {
592488f833Smikel int ch;
602488f833Smikel
612488f833Smikel while ((ch = getopt(argc, argv, "")) != -1)
622488f833Smikel switch(ch) {
632488f833Smikel case '?':
642488f833Smikel default:
652488f833Smikel usage();
662488f833Smikel }
672488f833Smikel argc -= optind;
682488f833Smikel argv += optind;
692488f833Smikel
702488f833Smikel switch(argc) {
712488f833Smikel case 0:
728ff96fa4Slukem if (acct(NULL))
738ff96fa4Slukem err(1, "acct");
742488f833Smikel break;
752488f833Smikel case 1:
768ff96fa4Slukem if (acct(*argv))
778ff96fa4Slukem err(1, "acct `%s'", *argv);
782488f833Smikel break;
792488f833Smikel default:
802488f833Smikel usage();
812488f833Smikel }
82cf982846Scgd exit(0);
83cf982846Scgd }
842488f833Smikel
85*dccf569eSjoerg static void
usage(void)8605b0c4c2Sxtraeme usage(void)
872488f833Smikel {
888ff96fa4Slukem
8925bdbb66Scgd (void)fprintf(stderr, "usage: %s [file]\n", getprogname());
902488f833Smikel exit(1);
912488f833Smikel }
92