accton.c revision 331722
1331722Seadler/* 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 * 4. Neither the name of the University nor the names of its contributors 141553Srgrimes * may be used to endorse or promote products derived from this software 151553Srgrimes * without specific prior written permission. 161553Srgrimes * 171553Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181553Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191553Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201553Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211553Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221553Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231553Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241553Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251553Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261553Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271553Srgrimes * SUCH DAMAGE. 281553Srgrimes */ 291553Srgrimes 30114601Sobrien#if 0 311553Srgrimes#ifndef lint 3228996Scharnierstatic const char copyright[] = 331553Srgrimes"@(#) Copyright (c) 1988, 1993\n\ 341553Srgrimes The Regents of the University of California. All rights reserved.\n"; 351553Srgrimes#endif /* not lint */ 361553Srgrimes 371553Srgrimes#ifndef lint 381553Srgrimesstatic char sccsid[] = "@(#)accton.c 8.1 (Berkeley) 6/6/93"; 39114601Sobrien#endif /* not lint */ 4028996Scharnier#endif 41114601Sobrien#include <sys/cdefs.h> 42114601Sobrien__FBSDID("$FreeBSD: stable/11/usr.sbin/accton/accton.c 331722 2018-03-29 02:50:57Z eadler $"); 431553Srgrimes 441553Srgrimes#include <sys/types.h> 4528996Scharnier#include <err.h> 4628996Scharnier#include <stdio.h> 471553Srgrimes#include <stdlib.h> 481553Srgrimes#include <string.h> 4928996Scharnier#include <unistd.h> 501553Srgrimes 5199833Salfredstatic void usage(void); 521553Srgrimes 531553Srgrimesint 5499833Salfredmain(int argc, char *argv[]) 551553Srgrimes{ 561553Srgrimes int ch; 571553Srgrimes 5824428Simp while ((ch = getopt(argc, argv, "")) != -1) 591553Srgrimes switch(ch) { 601553Srgrimes case '?': 611553Srgrimes default: 621553Srgrimes usage(); 631553Srgrimes } 641553Srgrimes argc -= optind; 651553Srgrimes argv += optind; 661553Srgrimes 671553Srgrimes switch(argc) { 688857Srgrimes case 0: 6928996Scharnier if (acct(NULL)) 7028996Scharnier err(1, NULL); 711553Srgrimes break; 721553Srgrimes case 1: 7328996Scharnier if (acct(*argv)) 7428996Scharnier err(1, "%s", *argv); 751553Srgrimes break; 761553Srgrimes default: 771553Srgrimes usage(); 781553Srgrimes } 791553Srgrimes exit(0); 801553Srgrimes} 811553Srgrimes 8228996Scharnierstatic void 83201387Sedusage(void) 841553Srgrimes{ 851553Srgrimes (void)fprintf(stderr, "usage: accton [file]\n"); 861553Srgrimes exit(1); 871553Srgrimes} 88