/*
* 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 1992 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <string.h>
#include <auevents.h>
#define OK 0
#define COMMON 0
/* GLOBALS */
static int length;
static int pos = 0;
struct list {
short count;
short off;
};
struct exception {
short type;
short exception;
};
static int stringcopy(char *, char *, int);
/*
* getauditflagschar() - convert bit flag to character string
*
* input: masks->as_success - audit on success
* masks->as_failure - audit on failure
* verbose - string format. 0 if short name; 1 if long name;
*
* output: auditstring - resultant audit string
*
* returns: 0 - entry read ok
* -1 - error
*/
int
{
int i, j, k, mask_num;
/*
* initialize input buffer
*/
/*
* initialize lists struct
*/
for (i=0;i<MAXEVENT+1;i++)
}
/*
* initialize exception lists
*/
for (i = 0; i < 2; i++) {
}
for (i = 0; i < 3; i++)
except_list[i] = 0;
/*
* set length global
*/
pos = 0;
/*
* find turned-on events - if on, store index of event
* in one of the three event lists, common, success, failure.
*/
for ( i = 0; i < MAXEVENT; i++) {
/*
* check for events in common
*/
0) &&
/*
* check for success events
*/
else {
except_list[SUCCESS]++;
}
/*
* check for failure events
*/
else {
except_list[FAILURE]++;
}
} else {
except_list[COMMON]++;
}
}
/*
* check for all set or all-1 set - output all and common exceptions.
* the all or common state is exclusive; only one of the
* three, (+-)all, allowed
*/
/*
* no exceptions
*/
/*
* one exception
*/
if (except_list[i] == 1) {
}
}
}
/*
* two exceptions
*/
if (except_list[i] == 1) {
}
}
} else if (except_list[COMMON] == 0) {
if (except_list[i] == 1) {
}
}
}
}
} else {
/*
* check for +all or -all
*/
list = i;
else
}
}
}
}
/*
* output all and exceptions
*/
if (list != -1) {
retstat = -1;
}
retstat = -1;
}
if (retstat == 0) {
if (length) {
if
retstat = -1;
} else
retstat = -1;
}
if (retstat == 0) {
/*
* output exceptions
*/
retstat = -1;
retstat = -1;
}
retstat = -1;
}
if ((stringcopy(auditstring,
retstat = -1;
} else if (retstat == 0) {
if ((stringcopy(auditstring,
retstat = -1;
}
}
}
} /* end of " all " processing */
/*
* process common events if no "all" was output
*/
/*
* output common events first
*/
if (length == 1) {
if ((stringcopy(auditstring,
retstat = -1;
} else if ((stringcopy(auditstring,
retstat = -1;
}
/*
* remove common events from individual lists
*/
if (retstat == 0) {
}
}
}
}
}
/*
* start processing individual event flags in success
* and failure lists
*/
if(list != i) {
retstat = -1;
if (length == 1 &&
retstat == 0) {
if ((stringcopy(auditstring,
retstat = -1;
} else if (retstat == 0) {
if ((stringcopy(auditstring,
retstat = -1;
}
}
}
}
}
}
retstat = -1;
return (retstat);
}
static int
int flag) /* if set, output comma after event */
{
int retstat = 0;
/*
* check size
*/
retstat = -1;
} else if (flag != 2) {
if(flag) {
}
} else {
/*
* add null terminator only
*/
if (pos)
}
return (retstat);
}
/*
* getauditflagsbin() - converts character string to success and
* failure bit masks
*
* input: auditstring - audit string
* cnt - number of elements in the masks array
*
* output: masks->as_success - audit on success
* masks->as_failure - audit on failure
*
* returns: 0 - ok
* -1 - error - string contains characters which do
* not match event flag names
*/
int
{
/*
* process character string
*/
do {
gotone = 0;
/*
* read through string storing chars. until a comma
*/
*ptr++ = *auditstring++;
else if (*auditstring == ' ')
*auditstring++;
else {
if (*auditstring == '\0' ||
*auditstring == '\n') {
done = 1;
done = 2;
}
gotone = 1;
}
}
/*
* process audit state
*/
if(!done) auditstring++;
*ptr++ = '\0';
gotone = 0;
succ_event = ON;
fail_event = ON;
tryagain = 1;
invert = 0;
/*
* get flags
*/
do {
switch (*ptr++) {
case '^':
invert = 1;
succ_event = OFF;
fail_event = OFF;
break;
case '+':
if (invert)
fail_event = OK;
else {
succ_event = ON;
fail_event = OK;
}
break;
case '-':
if (invert)
succ_event = OK;
else {
fail_event = ON;
succ_event = OK;
}
break;
default:
tryagain = 0;
ptr--;
break;
}
} while(tryagain);
/* add audit state to mask */
if (succ_event == ON)
else if (succ_event == OFF)
if (fail_event == ON)
else if (fail_event == OFF)
gotone = 1;
}
}
if(!gotone) {
retstat = -1;
done = 1;
}
}
} while (!done);
return (retstat);
}