auditxml revision 85e8d33eda72d79b047f9f6d1d38e71c94352fdb
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner# CDDL HEADER START
6741d19ec5be2e76369d84bd705bde8767972e00aurium# The contents of this file are subject to the terms of the
6741d19ec5be2e76369d84bd705bde8767972e00aurium# Common Development and Distribution License (the "License").
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner# You may not use this file except in compliance with the License.
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico# See the License for the specific language governing permissions
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico# and limitations under the License.
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico# When distributing Covered Code, include this CDDL HEADER in each
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner# If applicable, add the following below this CDDL HEADER, with the
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner# fields enclosed by brackets "[]" replaced with your own identifying
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner# information: Portions Copyright [yyyy] [name of copyright owner]
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner# CDDL HEADER END
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner# Use is subject to license terms.
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner# auditxml takes the audit record description (.xml file) and
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner# generates the files needed for the C audit api.
e866cf6004410b86765759ca47d88ae2052306bfJazzyNicoUsage: $prog [options] <xml-input-file>
6741d19ec5be2e76369d84bd705bde8767972e00aurium -d Enable debug output
6741d19ec5be2e76369d84bd705bde8767972e00aurium -e pfx Internal event prefix (default: AUE)
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico -i pfx Interface prefix (default: adt)
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico External event prefix is uppercase version of this string.
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico -o dir Output directory (default: current dir)
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpennerour $debug = 0; # normal use is to set via the file being parsed.
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner # <debug set="on"/> or <debug set="off"/> or <debug/>
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner # if the set attribute is omitted, debug state is toggled
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner # Override with appDebug, but toggle won't do what you
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpennermy $appDebug = 0; # used after return from "new auditxml";
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner# Process command-line options
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner# where everything comes from and where it goes:
03f0cd31db1136c686a9b7e279766cc171dfae5aauriumDO NOT EDIT. This file is auto generated by the Solaris Audit
03f0cd31db1136c686a9b7e279766cc171dfae5aaurium# trim leading/trailing newlines
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner addHeader($eventHeader) if defined ($eventHeader);
6741d19ec5be2e76369d84bd705bde8767972e00aurium generateAPIFile($event, $eventId, $eventType, $eventHeader, $idNo)
e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246alvinpenner generateTableC($event, $eventId, $eventType, $eventHeader, $omit);
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico $notice =~ s/\n/\n * /gs;
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico $notice =~ s/\s+\n/\n/gs;
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico#include <bsm/libbsm.h>
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico#include <adt_xlate.h>
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico#include <libintl.h>
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico print Cfile "/* Internal data type definitions */\n\n";
03f0cd31db1136c686a9b7e279766cc171dfae5aaurium print Cfile "\n/* External event structure to internal event structure */\n\n";
6741d19ec5be2e76369d84bd705bde8767972e00aurium print Cfile "static struct entry $structName\[$count\] = {\n";
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico print Cfile "static struct translation X_$externalRoot = {\n";
6741d19ec5be2e76369d84bd705bde8767972e00aurium print STDERR "expected entry for $eventId but none found\n";
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico print Cfile "adt_translation_t *${pfx_adt}_xlate_table[$count] = {\n";
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico${pfx_adt}_preload(au_event_t event_id, adt_event_data_t *event_data)
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico switch (event_id) {
6741d19ec5be2e76369d84bd705bde8767972e00aurium case $adtID:
6741d19ec5be2e76369d84bd705bde8767972e00aurium $id =~ s/${pfx_AUE}_/${pfx_adt}_/;
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico event_data->$id.$fieldName = $default;
d04fdb8e3c74ab565590728d96c52b5f3bbedf98aurium my ($header, $start, $public, $deprecated) = @$headref;
6741d19ec5be2e76369d84bd705bde8767972e00aurium push (@listName, [$listName, $listLength - 1, $start, $public]);
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico print Cfile "/* Deprecated message list */\n" if ($deprecated);
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico print Cfile "static char *msg_$listName\[$listLength] = {\n";
6741d19ec5be2e76369d84bd705bde8767972e00aurium print Cfile "\nstruct msg_text ${pfx_adt}_msg_text[", $#listName + 1,
6741d19ec5be2e76369d84bd705bde8767972e00aurium my $file = shift;
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico $notice =~ s/\n/\n * /gs;
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico $notice =~ s/\s+\n/\n/gs;
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico#ifndef $adt_event_n
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico#define $adt_event_n
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico#include <bsm/$include>
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico#ifdef __cplusplus
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico * adt_put_event() status values. Positive values are for kernel-generated
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico * failure, -1 for user-space. For ADT_SUCCESS, the adt_put_event() return_val
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico * is not used; the convention is to set it to ADT_SUCCESS.
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico#define ADT_SUCCESS 0
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico#define ADT_FAILURE -1
6741d19ec5be2e76369d84bd705bde8767972e00aurium my ($header, $start, $public, $deprecated) = @$headref;
e866cf6004410b86765759ca47d88ae2052306bfJazzyNico print Hfile "/* Deprecated message list */\n" if $deprecated;
6741d19ec5be2e76369d84bd705bde8767972e00aurium print Hfile "#define\t${pfx_ADT}_$shortName\t$start\n" if $start;
$line =~ s/\t\t/\t/;
$eline =~ s/ {8}//;
my $externalId = $eventId;
$externalId =~ s/${pfx_AUE}_/${pfx_ADT}_/;
my $entry;
$entry =~ s/termid/adt_termid_t/;
$outputState[$header] = 0;
$outputState[$header] = 1;
my $elementName = $eventId;
$elementName =~ s/^${pfx_AUE}_/${pfx_adt}_/;
$elementName =~ s/_t$//;
my $event = shift;
my $eventId = shift;
my $eventType = shift;
my $eventHeader = shift;
my $omit = shift;
my $entryRef;
my @inputOrder;
$firstTokenIndex = $j;
last;
my $sequence = 0;
$enumGroup =~ s/^msg\s*//i;
my $tsol = 0;
my $token;
my $tokenName;
print STDERR
$sequence++;
my $xlateLabelInc = 0;
my $dataType;
my $dataSize;
my $entryType = ${$entryDef{$type}}[0];
my $typeCount = 1;
$type =~ s/\[\]//;
$xlateLabelInc = 1;
@list = @{$xlateDefault{$eventId}};
$xlateDefault{$eventId} = \@list;
my $dataType;
my $entryType = ${$entryDef{$dtype}}[0];
$type =~ s/\[\]//;
$xlateLabelInc = 1;
@list = @{$xlateDefault{$eventId}};
$xlateDefault{$eventId} = \@list;
my $event = shift;
my $eventId = shift;
my $eventType = shift;
my $eventHeader = shift;
my $idNo = shift;
print STDERR
$#id = $#type;
$#type = $#id;
$eventExtra{$eventId} = [$eventHeader, $idNo];
my $textList = shift;
my $entry;
my @entry;
[\@entry, [$header, $start, $public, $deprecated]];
my $header_index = shift;
# $header = 0 is a special case; it is for adt_event.h
# $header > 0 creates adt_event_N.h, where N = $header
my $header;
$HfileName[$header] = $tmp[$#tmp];
my @Hfile = @_;
my $header;