accton.c revision 1553
11553Srgrimes/*
21553Srgrimes * Copyright (c) 1988, 1993
31553Srgrimes *	The Regents of the University of California.  All rights reserved.
41553Srgrimes *
51553Srgrimes * Redistribution and use in source and binary forms, with or without
61553Srgrimes * modification, are permitted provided that the following conditions
71553Srgrimes * are met:
81553Srgrimes * 1. Redistributions of source code must retain the above copyright
91553Srgrimes *    notice, this list of conditions and the following disclaimer.
101553Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111553Srgrimes *    notice, this list of conditions and the following disclaimer in the
121553Srgrimes *    documentation and/or other materials provided with the distribution.
131553Srgrimes * 3. All advertising materials mentioning features or use of this software
141553Srgrimes *    must display the following acknowledgement:
151553Srgrimes *	This product includes software developed by the University of
161553Srgrimes *	California, Berkeley and its contributors.
171553Srgrimes * 4. Neither the name of the University nor the names of its contributors
181553Srgrimes *    may be used to endorse or promote products derived from this software
191553Srgrimes *    without specific prior written permission.
201553Srgrimes *
211553Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221553Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231553Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241553Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251553Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261553Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271553Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281553Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291553Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301553Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311553Srgrimes * SUCH DAMAGE.
321553Srgrimes */
331553Srgrimes
341553Srgrimes#ifndef lint
351553Srgrimesstatic char copyright[] =
361553Srgrimes"@(#) Copyright (c) 1988, 1993\n\
371553Srgrimes	The Regents of the University of California.  All rights reserved.\n";
381553Srgrimes#endif /* not lint */
391553Srgrimes
401553Srgrimes#ifndef lint
411553Srgrimesstatic char sccsid[] = "@(#)accton.c	8.1 (Berkeley) 6/6/93";
421553Srgrimes#endif /* not lint */
431553Srgrimes
441553Srgrimes#include <sys/types.h>
451553Srgrimes#include <errno.h>
461553Srgrimes#include <unistd.h>
471553Srgrimes#include <stdlib.h>
481553Srgrimes#include <stdio.h>
491553Srgrimes#include <string.h>
501553Srgrimes
511553Srgrimesvoid usage __P((void));
521553Srgrimes
531553Srgrimesint
541553Srgrimesmain(argc, argv)
551553Srgrimes	int argc;
561553Srgrimes	char *argv[];
571553Srgrimes{
581553Srgrimes	int ch;
591553Srgrimes
601553Srgrimes	while ((ch = getopt(argc, argv, "")) != EOF)
611553Srgrimes		switch(ch) {
621553Srgrimes		case '?':
631553Srgrimes		default:
641553Srgrimes			usage();
651553Srgrimes		}
661553Srgrimes	argc -= optind;
671553Srgrimes	argv += optind;
681553Srgrimes
691553Srgrimes	switch(argc) {
701553Srgrimes	case 0:
711553Srgrimes		if (acct(NULL)) {
721553Srgrimes			(void)fprintf(stderr,
731553Srgrimes			    "accton: %s\n", strerror(errno));
741553Srgrimes			exit(1);
751553Srgrimes		}
761553Srgrimes		break;
771553Srgrimes	case 1:
781553Srgrimes		if (acct(*argv)) {
791553Srgrimes			(void)fprintf(stderr,
801553Srgrimes			    "accton: %s: %s\n", *argv, strerror(errno));
811553Srgrimes			exit(1);
821553Srgrimes		}
831553Srgrimes		break;
841553Srgrimes	default:
851553Srgrimes		usage();
861553Srgrimes	}
871553Srgrimes	exit(0);
881553Srgrimes}
891553Srgrimes
901553Srgrimesvoid
911553Srgrimesusage()
921553Srgrimes{
931553Srgrimes	(void)fprintf(stderr, "usage: accton [file]\n");
941553Srgrimes	exit(1);
951553Srgrimes}
96