main.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <libintl.h>
#include <locale.h>
#include "utils.h"
#include "aconf.h"
#include "res.h"
static const char USAGE[] = "\
Usage:\n\
acctadm [ {process | task | flow} ]\n\
acctadm -u\n\
acctadm -r [ {process | task | flow} ]\n\
acctadm -x|-E|-D {process | task | flow}\n\
acctadm -f filename {process | task | flow}\n\
acctadm -e resources -d resources {process | task | flow}\n";
static const char OPTS[] = "ruxf:e:d:ED";
static const char PATH_CONFIG[] = "/etc/acctadm.conf";
static void
usage()
{
}
int
{
int c; /* options character */
int type = 0; /* type of accounting */
int modified = 0; /* have we modified the /etc/acctadm.conf? */
int Eflg = 0;
int Dflg = 0;
int rflg = 0;
int uflg = 0;
int xflg = 0;
int optcnt = 0;
int state;
(void) textdomain(TEXT_DOMAIN);
(void) setprogname(argv[0]);
switch (c) {
case 'd':
break;
case 'e':
break;
case 'D':
Dflg = 1;
optcnt++;
break;
case 'E':
Eflg = 1;
optcnt++;
break;
case 'f':
optcnt++;
break;
case 'r':
rflg = 1;
optcnt++;
break;
case 'u':
uflg = 1;
optcnt++;
break;
case 'x':
xflg = 1;
optcnt++;
break;
case '?':
default:
usage();
}
}
usage();
} else {
}
}
}
else {
typestr);
usage();
}
} else
/*
* check for invalid options
*/
if (optcnt > 1)
usage();
usage();
!typestr) {
usage();
}
geteuid() != 0)
"accounting configuration\n"));
if (rflg) {
return (E_SUCCESS);
}
/*
* If no arguments has been passed then just print out the current
* state, save it in the configuration file and exit.
*/
aconf_init(&ac);
return (E_SUCCESS);
}
if (uflg) {
return (E_ERROR);
modified++;
}
if (xflg) {
/*
* Turn off the specified accounting and close its file
*/
modified++;
}
/*
*/
}
if (disabled)
if (enabled)
}
}
modified++;
}
if (file) {
/*
* Open new accounting file
*/
modified++;
}
if (Dflg) {
/*
* Disable accounting
*/
modified++;
}
if (Eflg) {
/*
* Enable accounting
*/
modified++;
}
if (modified) {
/*
* If we're modifying the configuration, then write out
* the new configuration file
*/
return (E_ERROR);
aconf_init(&ac);
return (E_ERROR);
}
return (E_SUCCESS);
}