c0c79a3f09914f35651895ffc111883455b7f62dtz#!/usr/perl5/bin/perl -w
c0c79a3f09914f35651895ffc111883455b7f62dtz#
c0c79a3f09914f35651895ffc111883455b7f62dtz# CDDL HEADER START
c0c79a3f09914f35651895ffc111883455b7f62dtz#
c0c79a3f09914f35651895ffc111883455b7f62dtz# The contents of this file are subject to the terms of the
c0c79a3f09914f35651895ffc111883455b7f62dtz# Common Development and Distribution License (the "License").
c0c79a3f09914f35651895ffc111883455b7f62dtz# You may not use this file except in compliance with the License.
c0c79a3f09914f35651895ffc111883455b7f62dtz#
c0c79a3f09914f35651895ffc111883455b7f62dtz# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c0c79a3f09914f35651895ffc111883455b7f62dtz# or http://www.opensolaris.org/os/licensing.
c0c79a3f09914f35651895ffc111883455b7f62dtz# See the License for the specific language governing permissions
c0c79a3f09914f35651895ffc111883455b7f62dtz# and limitations under the License.
c0c79a3f09914f35651895ffc111883455b7f62dtz#
c0c79a3f09914f35651895ffc111883455b7f62dtz# When distributing Covered Code, include this CDDL HEADER in each
c0c79a3f09914f35651895ffc111883455b7f62dtz# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c0c79a3f09914f35651895ffc111883455b7f62dtz# If applicable, add the following below this CDDL HEADER, with the
c0c79a3f09914f35651895ffc111883455b7f62dtz# fields enclosed by brackets "[]" replaced with your own identifying
c0c79a3f09914f35651895ffc111883455b7f62dtz# information: Portions Copyright [yyyy] [name of copyright owner]
c0c79a3f09914f35651895ffc111883455b7f62dtz#
c0c79a3f09914f35651895ffc111883455b7f62dtz# CDDL HEADER END
c0c79a3f09914f35651895ffc111883455b7f62dtz#
c0c79a3f09914f35651895ffc111883455b7f62dtz#
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
c0c79a3f09914f35651895ffc111883455b7f62dtz#
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz# auditxml_jni [-d] <xml input file>
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz# auditxml takes the audit record description (.xml file) and
c0c79a3f09914f35651895ffc111883455b7f62dtz# generates the files needed for the Java
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzuse auditxml;
c0c79a3f09914f35651895ffc111883455b7f62dtzuse Getopt::Std;
c0c79a3f09914f35651895ffc111883455b7f62dtzuse vars qw($opt_d);
c0c79a3f09914f35651895ffc111883455b7f62dtzuse strict;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzour $debug = 0; # normal use is to set via the file being parsed.
c0c79a3f09914f35651895ffc111883455b7f62dtz # <debug set="on"/> or <debug set="off"/> or <debug/>
c0c79a3f09914f35651895ffc111883455b7f62dtz # if the set attribute is omitted, debug state is toggled
c0c79a3f09914f35651895ffc111883455b7f62dtz # Override with appDebug, but toggle won't do what you
c0c79a3f09914f35651895ffc111883455b7f62dtz # want.
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $appDebug = 0; # used after return from "new auditxml";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $genNotice = "
c0c79a3f09914f35651895ffc111883455b7f62dtzDO NOT EDIT. This file is auto generated by the Solaris Audit
c0c79a3f09914f35651895ffc111883455b7f62dtzsystem from adt.xml.
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzSee http://opensolaris.org/os/project/audit/
c0c79a3f09914f35651895ffc111883455b7f62dtz";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz# trim leading/trailing newlines
c0c79a3f09914f35651895ffc111883455b7f62dtz$genNotice =~ s/^\n//s;
c0c79a3f09914f35651895ffc111883455b7f62dtz$genNotice =~ s/\n$//s;
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $prog = $0; $prog =~ s|.*/||g;
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $usage = "usage: $prog [-d] file.xml\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzgetopts('d');
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz$appDebug = $opt_d;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $uniLabel = "adr";
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $xlateUniLabelInc = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzdie $usage if ($#ARGV < 0);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz# where everything comes from and where it goes:
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $templatePath = './';
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $javaPath = $templatePath;
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $bsmBuildPath = "../libbsm";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $jniBuildPath = "$javaPath";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $buildPathJ = "$jniBuildPath/com/sun/audit";
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $buildPathJNI = "$jniBuildPath/common";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $auditEventJ = "$buildPathJ/AuditEvent.java";
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $jniC = "$buildPathJNI/adt_jni_event.c";
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $mapFile = "$jniBuildPath/common/mapfile-vers";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $doc = new auditxml ($ARGV[0]); # input XML file
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz$debug = $appDebug;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzmy %jniEventTable = ();
c0c79a3f09914f35651895ffc111883455b7f62dtzmy %externalIdNo = ();
c0c79a3f09914f35651895ffc111883455b7f62dtzmy %msg_list = ();
c0c79a3f09914f35651895ffc111883455b7f62dtzmy %eventCode = ();
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzreadAuditEventFile("$bsmBuildPath/audit_event.txt");
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $event;
c0c79a3f09914f35651895ffc111883455b7f62dtzwhile ($event = $doc->getNextEvent()) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $eventId = $event->getId();
c0c79a3f09914f35651895ffc111883455b7f62dtz my $idNo = $event->getIdNo();
c0c79a3f09914f35651895ffc111883455b7f62dtz $externalIdNo{$eventId} = $idNo;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $super;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $omit = $event->getOmit();
c0c79a3f09914f35651895ffc111883455b7f62dtz my $eventType = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($super = $event->getSuperClass()) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $event = $super;
c0c79a3f09914f35651895ffc111883455b7f62dtz $eventType = 'instance';
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz $eventType = $event->getType();
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz # c file table for translation
c0c79a3f09914f35651895ffc111883455b7f62dtz generateTableC($event, $eventId, $eventType, undef, $omit);
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzwhile (my $textList = $doc->getNextMsgId()) {
c0c79a3f09914f35651895ffc111883455b7f62dtz generateMsgLists($textList); # enum -> text mappings
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzprintJavaFiles($jniC, $auditEventJ, $buildPathJ, $mapFile);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzexit 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzsub printJavaFiles {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $jniFile = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $javaFile = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $subclassPath = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $mapFile = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz # warning: time_t is equated to jlong since there is no
c0c79a3f09914f35651895ffc111883455b7f62dtz # way to use sys/types.h in Java code.
c0c79a3f09914f35651895ffc111883455b7f62dtz # java long is C long long, 64 bits.
c0c79a3f09914f35651895ffc111883455b7f62dtz # java int is 32 bits.
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my %java_jni = ('ADT_DATE' => ['long', 'jlong'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_UINT' => ['int', 'jint'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_INT' => ['int', 'jint'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_INT32' => ['int', 'jint'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_UID' => ['int', 'jint'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_GID' => ['int', 'jint'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_UIDSTAR' => ['int[]', 'jintArray'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_GIDSTAR' => ['int[]', 'jintArray'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_CHAR' => ['String', 'jchar'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_CHARSTAR' => ['String', 'jstring'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_CHAR2STAR' => ['String[]', 'jstring'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_MSG' => ['int', 'jint'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_PID' => ['int', 'jint'],
c0c79a3f09914f35651895ffc111883455b7f62dtz# ADT_PRIVSTAR omitted -- not implemented and the audit records that
c0c79a3f09914f35651895ffc111883455b7f62dtz# use it must be coded to emit no java. We'll cross that bridge
c0c79a3f09914f35651895ffc111883455b7f62dtz# when someone in Java land needs to generate a priv token.
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_LONG' => ['int', 'jint'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_TERMIDSTAR' => ['String', 'jstring'], # hostname -> termid
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_ULONG' => ['int', 'jint'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_UINT16' => ['int', 'jint'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_UINT32' => ['int', 'jint'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_UINT32STAR' => ['int[]', 'jintArray'],
c0c79a3f09914f35651895ffc111883455b7f62dtz# ADT_UINT32ARRAY omitted; no Java implementation yet
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_UINT64' => ['long', 'jlong'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ADT_UINT64STAR' => ['long[]', 'jlongArray']
c0c79a3f09914f35651895ffc111883455b7f62dtz );
c0c79a3f09914f35651895ffc111883455b7f62dtz my $noMemory = 'gettext("Out of memory")';
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz # open output files
c0c79a3f09914f35651895ffc111883455b7f62dtz open (Cfile, ">$jniFile") or
c0c79a3f09914f35651895ffc111883455b7f62dtz die "can't open output file ($jniFile): $!\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz open (Jfile, ">$javaFile") or
c0c79a3f09914f35651895ffc111883455b7f62dtz die "can't open output file ($javaFile): $!\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz open (MapFile, ">$mapFile") or
c0c79a3f09914f35651895ffc111883455b7f62dtz die "can't open output file ($mapFile): $!\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz # write headers
c0c79a3f09914f35651895ffc111883455b7f62dtz my $notice = $genNotice;
c0c79a3f09914f35651895ffc111883455b7f62dtz $notice =~ s/\n/\n * /gs;
c0c79a3f09914f35651895ffc111883455b7f62dtz $notice =~ s/\s+\n/\n/gs;
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz/*
c0c79a3f09914f35651895ffc111883455b7f62dtz * $notice
c0c79a3f09914f35651895ffc111883455b7f62dtz */
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz#include "../../libbsm/common/adt_xlate.h"
c0c79a3f09914f35651895ffc111883455b7f62dtz#include <jni.h>
c0c79a3f09914f35651895ffc111883455b7f62dtz#include "../com/sun/audit/AuditSession.h" /* javah output */
c0c79a3f09914f35651895ffc111883455b7f62dtz#include "adt_jni.h"
c0c79a3f09914f35651895ffc111883455b7f62dtz#include <stdlib.h>
c0c79a3f09914f35651895ffc111883455b7f62dtz#include <string.h>
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzstatic char *except_class = "java/lang/Exception";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz print Jfile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz/*
c0c79a3f09914f35651895ffc111883455b7f62dtz * $notice
c0c79a3f09914f35651895ffc111883455b7f62dtz */
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzpackage com.sun.audit;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzpublic class AuditEvent {
c0c79a3f09914f35651895ffc111883455b7f62dtz protected AuditSession sh; // associated session object
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz public AuditEvent(AuditSession auSession)
c0c79a3f09914f35651895ffc111883455b7f62dtz throws Error
c0c79a3f09914f35651895ffc111883455b7f62dtz {
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz sh = auSession;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
0bd81b6f8fb7804214192b87b0aa3f03fcf87c45gww // Manifest values: keep them in sync with generated <bsm/adt_event.h>.
0bd81b6f8fb7804214192b87b0aa3f03fcf87c45gww // It is generated by \$SRC/lib/libbsm/auditxml
0bd81b6f8fb7804214192b87b0aa3f03fcf87c45gww
0bd81b6f8fb7804214192b87b0aa3f03fcf87c45gww public static final int ADT_SUCCESS = 0; // generated
0bd81b6f8fb7804214192b87b0aa3f03fcf87c45gww public static final int ADT_FAILURE = -1; // generated
0bd81b6f8fb7804214192b87b0aa3f03fcf87c45gww
c0c79a3f09914f35651895ffc111883455b7f62dtz // See the subclasses of AuditEvent for mapping message codes
c0c79a3f09914f35651895ffc111883455b7f62dtz // to events
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $notice_map = $genNotice;
c0c79a3f09914f35651895ffc111883455b7f62dtz $notice_map =~ s/\n/\n# /gs;
c0c79a3f09914f35651895ffc111883455b7f62dtz $notice_map =~ s/\s+\n/\n/gs;
c0c79a3f09914f35651895ffc111883455b7f62dtz print MapFile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz#
c0c79a3f09914f35651895ffc111883455b7f62dtz# $notice_map
c0c79a3f09914f35651895ffc111883455b7f62dtz#
c0c79a3f09914f35651895ffc111883455b7f62dtz
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami\$mapfile_version 2
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali BahramiSYMBOL_VERSION SUNWprivate_1.1 {
c0c79a3f09914f35651895ffc111883455b7f62dtz global:
c0c79a3f09914f35651895ffc111883455b7f62dtz c2j_pointer;
c0c79a3f09914f35651895ffc111883455b7f62dtz j2c_pointer;
c0c79a3f09914f35651895ffc111883455b7f62dtz Java_com_sun_audit_AuditSession_bsmAuditOn;
c0c79a3f09914f35651895ffc111883455b7f62dtz Java_com_sun_audit_AuditSession_startSession;
c0c79a3f09914f35651895ffc111883455b7f62dtz Java_com_sun_audit_AuditSession_endSession;
c0c79a3f09914f35651895ffc111883455b7f62dtz Java_com_sun_audit_AuditSession_dupSession;
c0c79a3f09914f35651895ffc111883455b7f62dtz Java_com_sun_audit_AuditSession_getSessionId;
c0c79a3f09914f35651895ffc111883455b7f62dtz Java_com_sun_audit_AuditSession_exportSessionData;
57b598f5829606393ded70b44d927a5a004392b8tz Java_com_sun_audit_AuditSession_sessionAttr;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz# One subclass of AuditEvent per audit record...
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz # generate java final int classes to line up with string/enums
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach my $listName (sort keys %msg_list) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $shortName = uc $listName;
c0c79a3f09914f35651895ffc111883455b7f62dtz $shortName =~ s/_TEXT//;
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($listRef, $headref) = @{$msg_list{$listName}};
c0c79a3f09914f35651895ffc111883455b7f62dtz my @listValue = @$listRef;
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($header, $enumValue, $public, $deprecated) = @$headref;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $listValue;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print Jfile "\n\t// adt_$listName" . "\n\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz print Jfile "\tpublic static final int ADT_$shortName",
c0c79a3f09914f35651895ffc111883455b7f62dtz " = $enumValue;\n" if $enumValue;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz next unless ($#listValue >= 0);
c0c79a3f09914f35651895ffc111883455b7f62dtz print Jfile "\t// Deprecated message list\n" if $deprecated;
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach $listValue (@listValue) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($id, $text) = split(/\s*::\s*/, $listValue);
c0c79a3f09914f35651895ffc111883455b7f62dtz print Jfile "\t// $text\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz print Jfile "\tpublic static final int ADT_$shortName";
c0c79a3f09914f35651895ffc111883455b7f62dtz print Jfile "_$id = $enumValue;\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz $enumValue++;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz # generate event creation and access functions and event
c0c79a3f09914f35651895ffc111883455b7f62dtz # generation for both Java and JNI
c0c79a3f09914f35651895ffc111883455b7f62dtz # com.sun.audit.AuditEvent_xxx.java
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach my $eventId (sort keys %jniEventTable) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($ref1, $eventType, $allowedIds, $header) = @{$jniEventTable{$eventId}};
c0c79a3f09914f35651895ffc111883455b7f62dtz $eventCode{$eventId} = -1 if ($eventType eq 'generic');
c0c79a3f09914f35651895ffc111883455b7f62dtz my @entries = @$ref1;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $entries = $#entries;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $root = $eventId;
c0c79a3f09914f35651895ffc111883455b7f62dtz $root =~ s/AUE_//;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $javaPutEvent = 'putEvent';
c0c79a3f09914f35651895ffc111883455b7f62dtz my $putMethod = "_$root";
c0c79a3f09914f35651895ffc111883455b7f62dtz $putMethod =~ s/_/_1/g;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $jniPutEvent = "Java_com_sun_audit_AuditEvent$putMethod" . "_$javaPutEvent";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz # the subclass file template isn't used; it may be needed to get
c0c79a3f09914f35651895ffc111883455b7f62dtz # the right file header stuff in place. The subclassPath is
c0c79a3f09914f35651895ffc111883455b7f62dtz # the directory that contains 'em.
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $validSfile = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz unless (open(Sfile, ">$subclassPath/AuditEvent_$root.java")) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "can't open class file AuditEvent_$root.java: $!\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz $validSfile = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($eventCode{"AUE_$root"}) {
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($validSfile) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print Sfile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz/*
c0c79a3f09914f35651895ffc111883455b7f62dtz * $notice
c0c79a3f09914f35651895ffc111883455b7f62dtz */
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzpackage com.sun.audit;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz// audit event: $eventId = $eventCode{"AUE_$root"}
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzpublic class AuditEvent_$root extends AuditEvent {
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "no event code for $eventId. Is audit_event current?\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz my $nativeParameterList = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz my $jniParameterList = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz my $specParameterList = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz my $jniStorageList = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz my $needCleanupTarget = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $jniFreeList = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $haveStringDef = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $haveCDef = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $haveLengthDef = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $haveStringArrayDef = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $cntTermidDef = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $jniDefine;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $needLocaleDefined = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $jniADTalloc;
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined $header && ($header > 0) ) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniDefine = "union union_of_events *event;\n" .
c0c79a3f09914f35651895ffc111883455b7f62dtz "\tadt_session_data_t *session;\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniADTalloc = '(union union_of_events *)adt_alloc_event';
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniDefine = "adt_event_data_t *event;\n" .
c0c79a3f09914f35651895ffc111883455b7f62dtz "\tadt_session_data_t *session;\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniADTalloc = 'adt_alloc_event';
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz my $ref2;
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach $ref2 (@entries) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($id, $type) = @$ref2;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $jniRoot = $root . $id;
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniRoot =~ s/_/_1/g; # escape unicode "_"
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $p_event;
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined $header && ($header > 0) ) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $p_event = "event->d$header.adt_$root.$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz $p_event = "event->adt_$root.$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($type eq 'ADT_UINT32STAR') { # int array
c0c79a3f09914f35651895ffc111883455b7f62dtz $needLocaleDefined = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniStorageList .= <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz /* $id */
c0c79a3f09914f35651895ffc111883455b7f62dtz length = (*env)->GetArrayLength(env, $id);
c0c79a3f09914f35651895ffc111883455b7f62dtz $p_event =
c0c79a3f09914f35651895ffc111883455b7f62dtz (int *)malloc(length * sizeof (int));
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($p_event == NULL) {
c0c79a3f09914f35651895ffc111883455b7f62dtz locale = I18N_SETUP;
c0c79a3f09914f35651895ffc111883455b7f62dtz local_throw(env, except_class,
c0c79a3f09914f35651895ffc111883455b7f62dtz $noMemory);
c0c79a3f09914f35651895ffc111883455b7f62dtz (void) setlocale(LC_MESSAGES, locale);
c0c79a3f09914f35651895ffc111883455b7f62dtz goto cleanup;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz (*env)->GetIntArrayRegion(env, $id, 0, length,
c0c79a3f09914f35651895ffc111883455b7f62dtz (int *)$p_event);
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniFreeList .= "\n\tif ($p_event != NULL)\n" .
c0c79a3f09914f35651895ffc111883455b7f62dtz "\t\tfree($p_event);\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz unless ($haveLengthDef) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $haveLengthDef = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniDefine .= "\tint\t\t\tlength;\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $nativeParameterList .= ",\n\t int[]\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniParameterList .= ",\n jintArray\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $specParameterList .= ", jintArray";
c0c79a3f09914f35651895ffc111883455b7f62dtz $needCleanupTarget = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif (($type eq 'ADT_UIDSTAR') ||
c0c79a3f09914f35651895ffc111883455b7f62dtz ($type eq 'ADT_GIDSTAR')) { # gid_t array
c0c79a3f09914f35651895ffc111883455b7f62dtz my $cType = 'uid_t';
c0c79a3f09914f35651895ffc111883455b7f62dtz $cType = 'gid_t' if ($type eq 'ADT_GIDSTAR');
c0c79a3f09914f35651895ffc111883455b7f62dtz $needLocaleDefined = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniStorageList .= <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz /* $id */
c0c79a3f09914f35651895ffc111883455b7f62dtz length = (*env)->GetArrayLength(env, $id);
c0c79a3f09914f35651895ffc111883455b7f62dtz $p_event =
c0c79a3f09914f35651895ffc111883455b7f62dtz ($cType *)malloc(length * sizeof ($cType));
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($p_event == NULL) {
c0c79a3f09914f35651895ffc111883455b7f62dtz locale = I18N_SETUP;
c0c79a3f09914f35651895ffc111883455b7f62dtz local_throw(env, except_class,
c0c79a3f09914f35651895ffc111883455b7f62dtz $noMemory);
c0c79a3f09914f35651895ffc111883455b7f62dtz (void) setlocale(LC_MESSAGES, locale);
c0c79a3f09914f35651895ffc111883455b7f62dtz goto cleanup;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz (*env)->GetIntArrayRegion(env, $id, 0, length,
c0c79a3f09914f35651895ffc111883455b7f62dtz (int *)$p_event);
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniFreeList .=
c0c79a3f09914f35651895ffc111883455b7f62dtz "\n\tif ($p_event != NULL)\n" .
c0c79a3f09914f35651895ffc111883455b7f62dtz "\t\tfree($p_event);\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz unless ($haveLengthDef) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $haveLengthDef = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniDefine .= "\tint\t\t\tlength;\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $nativeParameterList .= ",\n\t int[]\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniParameterList .= ",\n jintArray\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $specParameterList .= ", jintArray";
c0c79a3f09914f35651895ffc111883455b7f62dtz $needCleanupTarget = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($type eq 'ADT_UINT64STAR') { # long array
c0c79a3f09914f35651895ffc111883455b7f62dtz $needLocaleDefined = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniStorageList .= <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz /* $id */
c0c79a3f09914f35651895ffc111883455b7f62dtz length = (*env)->GetArrayLength(env, $id);
c0c79a3f09914f35651895ffc111883455b7f62dtz $p_event =
c0c79a3f09914f35651895ffc111883455b7f62dtz (long *)malloc(length * sizeof (long long));
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($p_event == NULL) {
c0c79a3f09914f35651895ffc111883455b7f62dtz locale = I18N_SETUP;
c0c79a3f09914f35651895ffc111883455b7f62dtz local_throw(env, except_class,
c0c79a3f09914f35651895ffc111883455b7f62dtz $noMemory);
c0c79a3f09914f35651895ffc111883455b7f62dtz (void) setlocale(LC_MESSAGES, locale);
c0c79a3f09914f35651895ffc111883455b7f62dtz goto cleanup;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz (*env)->GetLongArrayRegion(env, $id, 0, length,
c0c79a3f09914f35651895ffc111883455b7f62dtz $p_event);
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniFreeList .= "\n\tif ($p_event != NULL)\n" .
c0c79a3f09914f35651895ffc111883455b7f62dtz "\t\tfree($p_event);\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz unless ($haveLengthDef) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $haveLengthDef = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniDefine .= "\tint\t\t\tlength;\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $nativeParameterList .= ",\n\t long[]\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniParameterList .= ",\n jlongArray\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $specParameterList .= ", jlongArray";
c0c79a3f09914f35651895ffc111883455b7f62dtz $needCleanupTarget = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($type eq 'ADT_CHAR') { # string in Java, char in C
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniStorageList .= <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz /* $id */
c0c79a3f09914f35651895ffc111883455b7f62dtz c = (char *)(*env)->GetStringUTFChars(env, $id, NULL);
c0c79a3f09914f35651895ffc111883455b7f62dtz if (c == NULL)
c0c79a3f09914f35651895ffc111883455b7f62dtz goto cleanup; /* exception thrown */
c0c79a3f09914f35651895ffc111883455b7f62dtz $p_event = *c;
c0c79a3f09914f35651895ffc111883455b7f62dtz (*env)->ReleaseStringUTFChars(env, $id, c);
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz # no need to free anything
c0c79a3f09914f35651895ffc111883455b7f62dtz unless ($haveCDef) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $haveCDef = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniDefine .= "\tchar\t\t\t*c\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $nativeParameterList .= ",\n\t String\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniParameterList .= ",\n jstring\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $specParameterList .= ", jstring";
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($type eq 'ADT_CHARSTAR') {
c0c79a3f09914f35651895ffc111883455b7f62dtz $needLocaleDefined = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniStorageList .= <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz /* $id */
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($id != NULL) {
c0c79a3f09914f35651895ffc111883455b7f62dtz string = (char *)(*env)->GetStringUTFChars(
c0c79a3f09914f35651895ffc111883455b7f62dtz env, $id, NULL);
c0c79a3f09914f35651895ffc111883455b7f62dtz if (string == NULL)
c0c79a3f09914f35651895ffc111883455b7f62dtz goto cleanup; /* exception thrown */
c0c79a3f09914f35651895ffc111883455b7f62dtz $p_event = strdup(string);
c0c79a3f09914f35651895ffc111883455b7f62dtz (*env)->ReleaseStringUTFChars(env, $id, string);
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($p_event == NULL) {
c0c79a3f09914f35651895ffc111883455b7f62dtz locale = I18N_SETUP;
c0c79a3f09914f35651895ffc111883455b7f62dtz local_throw(env, except_class,
c0c79a3f09914f35651895ffc111883455b7f62dtz $noMemory);
c0c79a3f09914f35651895ffc111883455b7f62dtz (void) setlocale(LC_MESSAGES, locale);
c0c79a3f09914f35651895ffc111883455b7f62dtz goto cleanup;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniFreeList .= "\n\tif ($p_event != NULL)\n" .
c0c79a3f09914f35651895ffc111883455b7f62dtz "\t\tfree($p_event);\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz unless ($haveStringDef) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $haveStringDef = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniDefine .= "\tchar\t\t\t*string;\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $nativeParameterList .= ",\n\t String\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniParameterList .= ",\n jstring\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $specParameterList .= ", jstring";
c0c79a3f09914f35651895ffc111883455b7f62dtz $needCleanupTarget = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($type eq 'ADT_CHAR2STAR') { # array of string
c0c79a3f09914f35651895ffc111883455b7f62dtz $needLocaleDefined = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniStorageList .= <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz /* $id */
c0c79a3f09914f35651895ffc111883455b7f62dtz length = (*env)->GetArrayLength(env, $id);
c0c79a3f09914f35651895ffc111883455b7f62dtz $p_event = (char **)malloc(length
c0c79a3f09914f35651895ffc111883455b7f62dtz * sizeof (char *));
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($p_event == NULL) {
c0c79a3f09914f35651895ffc111883455b7f62dtz locale = I18N_SETUP;
c0c79a3f09914f35651895ffc111883455b7f62dtz local_throw(env, except_class,
c0c79a3f09914f35651895ffc111883455b7f62dtz $noMemory);
c0c79a3f09914f35651895ffc111883455b7f62dtz (void) setlocale(LC_MESSAGES, locale);
c0c79a3f09914f35651895ffc111883455b7f62dtz goto cleanup;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz p = $p_event;
c0c79a3f09914f35651895ffc111883455b7f62dtz for (i = 0; i < length; i++) {
c0c79a3f09914f35651895ffc111883455b7f62dtz jString = (*env)->GetObjectArrayElement(env, $id, i);
c0c79a3f09914f35651895ffc111883455b7f62dtz string = (char *)(*env)->GetStringUTFChars(
c0c79a3f09914f35651895ffc111883455b7f62dtz env, jString, NULL);
c0c79a3f09914f35651895ffc111883455b7f62dtz if (string == NULL)
c0c79a3f09914f35651895ffc111883455b7f62dtz goto cleanup; /* exception thrown */
c0c79a3f09914f35651895ffc111883455b7f62dtz *p = strdup(string);
c0c79a3f09914f35651895ffc111883455b7f62dtz (*env)->ReleaseStringUTFChars(env, jString, string);
c0c79a3f09914f35651895ffc111883455b7f62dtz if (*p == NULL) {
c0c79a3f09914f35651895ffc111883455b7f62dtz locale = I18N_SETUP;
c0c79a3f09914f35651895ffc111883455b7f62dtz local_throw(env, except_class,
c0c79a3f09914f35651895ffc111883455b7f62dtz $noMemory);
c0c79a3f09914f35651895ffc111883455b7f62dtz (void) setlocale(LC_MESSAGES, locale);
c0c79a3f09914f35651895ffc111883455b7f62dtz while (p >= $p_event)
c0c79a3f09914f35651895ffc111883455b7f62dtz free(*p--);
c0c79a3f09914f35651895ffc111883455b7f62dtz goto cleanup;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz p++;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniFreeList .=
c0c79a3f09914f35651895ffc111883455b7f62dtz "\n\tif ($p_event != NULL)\n" .
c0c79a3f09914f35651895ffc111883455b7f62dtz "\t\tfree($p_event);\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz unless ($haveStringArrayDef) {
c0c79a3f09914f35651895ffc111883455b7f62dtz unless ($haveStringDef) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $haveStringDef = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniDefine .= <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz char *string;
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz unless ($haveLengthDef) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $haveLengthDef = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniDefine .= <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz int length;
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $haveStringArrayDef = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniDefine .= <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz int i;
c0c79a3f09914f35651895ffc111883455b7f62dtz char **p;
c0c79a3f09914f35651895ffc111883455b7f62dtz jstring jString;
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $nativeParameterList .= ",\n\t String[]\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniParameterList .= ",\n jstring\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $specParameterList .= ", jstring";
c0c79a3f09914f35651895ffc111883455b7f62dtz $needCleanupTarget = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($type eq 'ADT_TERMIDSTAR') {
c0c79a3f09914f35651895ffc111883455b7f62dtz $needLocaleDefined = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniStorageList .= <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz /* $id */
c0c79a3f09914f35651895ffc111883455b7f62dtz hostname$cntTermidDef = (char *)(*env)->GetStringUTFChars(env, $id, NULL);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz if (adt_load_hostname((const char *)hostname$cntTermidDef, &termid$cntTermidDef)) {
c0c79a3f09914f35651895ffc111883455b7f62dtz local_throw(env, except_class,
c0c79a3f09914f35651895ffc111883455b7f62dtz gettext("hostname lookup failed"));
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $p_event = termid$cntTermidDef;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz (*env)->ReleaseStringUTFChars(env, $id, hostname$cntTermidDef);
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniFreeList .= "\n\tif (hostname$cntTermidDef != NULL)\n" .
c0c79a3f09914f35651895ffc111883455b7f62dtz "\t\tfree(hostname$cntTermidDef);\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniFreeList .= "\n\tif (termid$cntTermidDef != NULL)\n" .
c0c79a3f09914f35651895ffc111883455b7f62dtz "\t\tfree(termid$cntTermidDef);\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniDefine .= "\tchar\t\t\t*hostname$cntTermidDef;\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniDefine .= "\tadt_termid_t\t\t*termid$cntTermidDef;\n"; #djdj
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz $cntTermidDef++;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($nativeParameter, $jniParameter) = @{$java_jni{$type}};
c0c79a3f09914f35651895ffc111883455b7f62dtz $nativeParameterList .= ",\n\t $nativeParameter\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniParameterList .= ",\n $jniParameter\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $specParameterList .= ", $jniParameter";
c0c79a3f09914f35651895ffc111883455b7f62dtz $needCleanupTarget = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz } else { # all others are primitive types
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniStorageList .= "\n\t$p_event = $id;\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($nativeParameter, $jniParameter) = @{$java_jni{$type}};
c0c79a3f09914f35651895ffc111883455b7f62dtz $nativeParameter = "$nativeParameter\t"
c0c79a3f09914f35651895ffc111883455b7f62dtz if length $nativeParameter < 4; # why?
c0c79a3f09914f35651895ffc111883455b7f62dtz $nativeParameterList .= ",\n\t $nativeParameter\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniParameterList .= ",\n $jniParameter\t$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz $specParameterList .= ", $jniParameter";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($needLocaleDefined) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniDefine .= <<EOF
c0c79a3f09914f35651895ffc111883455b7f62dtz char *locale;
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz my $genericOverride = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz my $idParameter = $eventId;
c0c79a3f09914f35651895ffc111883455b7f62dtz $idParameter =~ s/AUE_/ADT_/;
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($eventType eq 'generic') {
c0c79a3f09914f35651895ffc111883455b7f62dtz $genericOverride = ', jint eventId';
c0c79a3f09914f35651895ffc111883455b7f62dtz $idParameter = 'eventId';
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniFreeList = "\tcleanup:\n" . $jniFreeList if $needCleanupTarget;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile qq{/* ARGSUSED */
c0c79a3f09914f35651895ffc111883455b7f62dtzJNIEXPORT void JNICALL
c0c79a3f09914f35651895ffc111883455b7f62dtz$jniPutEvent(
c0c79a3f09914f35651895ffc111883455b7f62dtz JNIEnv *env,
c0c79a3f09914f35651895ffc111883455b7f62dtz jobject self,
c0c79a3f09914f35651895ffc111883455b7f62dtz jbyteArray jsession$genericOverride,
c0c79a3f09914f35651895ffc111883455b7f62dtz jint status,
c0c79a3f09914f35651895ffc111883455b7f62dtz jint ret_val$jniParameterList)
c0c79a3f09914f35651895ffc111883455b7f62dtz{
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniDefine
c0c79a3f09914f35651895ffc111883455b7f62dtz (void) j2c_pointer(env, jsession, (char **)&session);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz event = $jniADTalloc(session, $idParameter);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz$jniStorageList
c0c79a3f09914f35651895ffc111883455b7f62dtz (void) adt_put_event((adt_event_data_t *)event, status, ret_val);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz$jniFreeList
c0c79a3f09914f35651895ffc111883455b7f62dtz adt_free_event((adt_event_data_t *)event);
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtz};
c0c79a3f09914f35651895ffc111883455b7f62dtz print MapFile qq{
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniPutEvent; };
c0c79a3f09914f35651895ffc111883455b7f62dtz my $overrideParameter = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($eventType eq 'generic') {
c0c79a3f09914f35651895ffc111883455b7f62dtz $overrideParameter = 'int eventId,';
c0c79a3f09914f35651895ffc111883455b7f62dtz my @allowed = @$allowedIds;
c0c79a3f09914f35651895ffc111883455b7f62dtz if (@allowed) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $i;
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($validSfile) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print Sfile "\t// Allowed values for eventId in putEvent:\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz for ($i = 0; $i <= $#allowed; $i++) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $idNo = $externalIdNo{$allowed[$i]};
c0c79a3f09914f35651895ffc111883455b7f62dtz $allowed[$i] =~ s/AUE_/ADT_/;
c0c79a3f09914f35651895ffc111883455b7f62dtz print Sfile "\tstatic final int $allowed[$i] = ",
c0c79a3f09914f35651895ffc111883455b7f62dtz "$idNo;\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz print Sfile "\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "Generic event with no allowed instances: $eventId\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($validSfile) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print Sfile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz private native void $javaPutEvent(byte[]session, $overrideParameter
c0c79a3f09914f35651895ffc111883455b7f62dtz int status, int ret_val$nativeParameterList);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz public AuditEvent_$root(AuditSession session)
c0c79a3f09914f35651895ffc111883455b7f62dtz throws Exception
c0c79a3f09914f35651895ffc111883455b7f62dtz {
c0c79a3f09914f35651895ffc111883455b7f62dtz super(session);
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz my $javaParameterList = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach $ref2 (@entries) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($id, $type, $format, $jComment, $required) = @$ref2;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz # generate java native method prototypes
c0c79a3f09914f35651895ffc111883455b7f62dtz # and the corresponding C method implementation
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $javaMethodName = "$id";
c0c79a3f09914f35651895ffc111883455b7f62dtz my $javaStorageName = $javaMethodName . '_val';
c0c79a3f09914f35651895ffc111883455b7f62dtz my $jniMethodName = $root . $id;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $storage;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $enumUsage = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz my $jParam = @{$java_jni{$type}}[0];
c0c79a3f09914f35651895ffc111883455b7f62dtz my $comment = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($required) {
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($format ne 'NULL') {
c0c79a3f09914f35651895ffc111883455b7f62dtz $comment = "\t// (required) formatted: $format";
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz $comment = "\t// required";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($format ne 'NULL') {
c0c79a3f09914f35651895ffc111883455b7f62dtz $comment = "\t// (optional) formatted: $format";
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz $comment = "\t// optional";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz if (($type eq 'ADT_UINT32STAR') ||
c0c79a3f09914f35651895ffc111883455b7f62dtz ($type eq 'ADT_UIDSTAR') ||
c0c79a3f09914f35651895ffc111883455b7f62dtz ($type eq 'ADT_GIDSTAR')) { # int array
c0c79a3f09914f35651895ffc111883455b7f62dtz $storage = "int[] $javaStorageName" . ($required ?
c0c79a3f09914f35651895ffc111883455b7f62dtz ' = {}' : '');
c0c79a3f09914f35651895ffc111883455b7f62dtz $javaParameterList .= ",\n\t\t\t $javaStorageName";
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($type eq 'ADT_UINT64STAR') { # long array
c0c79a3f09914f35651895ffc111883455b7f62dtz $storage = "long[] $javaStorageName" . ($required ?
c0c79a3f09914f35651895ffc111883455b7f62dtz ' = {}' : '');
c0c79a3f09914f35651895ffc111883455b7f62dtz $javaParameterList .= ",\n\t\t\t $javaStorageName";
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif (($type eq 'ADT_CHARSTAR') ||
c0c79a3f09914f35651895ffc111883455b7f62dtz ($type eq 'ADT_CHAR')) { # string
c0c79a3f09914f35651895ffc111883455b7f62dtz $storage = "String $javaStorageName" . ($required ?
c0c79a3f09914f35651895ffc111883455b7f62dtz ' = ""' : '');
c0c79a3f09914f35651895ffc111883455b7f62dtz $javaParameterList .= ",\n\t\t\t $javaStorageName";
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($type eq 'ADT_CHAR2STAR') { # array of string
c0c79a3f09914f35651895ffc111883455b7f62dtz $storage = "String[] $javaStorageName" . ($required ?
c0c79a3f09914f35651895ffc111883455b7f62dtz ' = {}' : '');
c0c79a3f09914f35651895ffc111883455b7f62dtz $javaParameterList .= ",\n\t\t\t $javaStorageName";
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($type eq 'ADT_TERMIDSTAR') { # array of string
c0c79a3f09914f35651895ffc111883455b7f62dtz $storage = "String $javaStorageName" . ($required ?
c0c79a3f09914f35651895ffc111883455b7f62dtz ' = ""' : '');
c0c79a3f09914f35651895ffc111883455b7f62dtz $javaParameterList .= ",\n\t\t\t $javaStorageName";
c0c79a3f09914f35651895ffc111883455b7f62dtz } else { # all others are primitive types
c0c79a3f09914f35651895ffc111883455b7f62dtz $storage = "$jParam $javaStorageName = 0";
c0c79a3f09914f35651895ffc111883455b7f62dtz $javaParameterList .= ",\n\t\t\t $javaStorageName";
c0c79a3f09914f35651895ffc111883455b7f62dtz $enumUsage = "\n\t// See $jComment in AuditEvent.java for valid values"
c0c79a3f09914f35651895ffc111883455b7f62dtz if $jComment;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz print Sfile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz$enumUsage
c0c79a3f09914f35651895ffc111883455b7f62dtz private $storage;$comment
c0c79a3f09914f35651895ffc111883455b7f62dtz public void $javaMethodName($jParam setTo)
c0c79a3f09914f35651895ffc111883455b7f62dtz {
c0c79a3f09914f35651895ffc111883455b7f62dtz $javaStorageName = setTo;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz } # end foreach (@entries)
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($eventType eq 'generic') {
c0c79a3f09914f35651895ffc111883455b7f62dtz print Sfile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz public void putEvent(int status, int ret_val, int eventId)
c0c79a3f09914f35651895ffc111883455b7f62dtz {
c0c79a3f09914f35651895ffc111883455b7f62dtz byte[] session = super.sh.getSession();
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz if ((super.sh.AuditIsOn) && (super.sh.ValidSession))
c0c79a3f09914f35651895ffc111883455b7f62dtz $javaPutEvent(session, eventId,
c0c79a3f09914f35651895ffc111883455b7f62dtz status, ret_val$javaParameterList);
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz print Sfile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz public void putEvent(int status, int ret_val)
c0c79a3f09914f35651895ffc111883455b7f62dtz {
c0c79a3f09914f35651895ffc111883455b7f62dtz byte[] session = super.sh.getSession();
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz if ((super.sh.AuditIsOn) && (super.sh.ValidSession))
c0c79a3f09914f35651895ffc111883455b7f62dtz $javaPutEvent(session, status, ret_val$javaParameterList);
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz close Sfile;
c0c79a3f09914f35651895ffc111883455b7f62dtz } # end if ($validSfile);
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz # write trailers
c0c79a3f09914f35651895ffc111883455b7f62dtz print Jfile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz print MapFile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz local:
c0c79a3f09914f35651895ffc111883455b7f62dtz *;
c0c79a3f09914f35651895ffc111883455b7f62dtz};
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz close Cfile;
c0c79a3f09914f35651895ffc111883455b7f62dtz close Jfile;
c0c79a3f09914f35651895ffc111883455b7f62dtz close MapFile;
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzsub generateTableC {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $event = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $eventId = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $eventType = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $eventHeader = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $omit = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my %tokenType = (
c0c79a3f09914f35651895ffc111883455b7f62dtz 'acl' => 'AUT_ACL',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'arbitrary' => 'AUT_ARBITRARY',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'arg' => 'AUT_ARG',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'attr' => 'AUT_ATTR',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'command' => 'AUT_CMD',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'command_1' => 'ADT_CMD_ALT', # dummy token id
c0c79a3f09914f35651895ffc111883455b7f62dtz 'date' => 'AUT_TEXT',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'exec_args' => 'AUT_EXEC_ARGS',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'exec_env' => 'AUT_EXEC_ENV',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'exit' => 'AUT_EXIT',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'file' => 'AUT_FILE',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'fmri' => 'AUT_FMRI',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'groups' => 'AUT_GROUPS',
c0c79a3f09914f35651895ffc111883455b7f62dtz # 'header' => 'AUT_HEADER', # not used
c0c79a3f09914f35651895ffc111883455b7f62dtz 'in_addr' => 'AUT_IN_ADDR',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ipc' => 'AUT_IPC',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ipc_perm' => 'AUT_IPC_PERM',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'iport' => 'AUT_IPORT',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'label' => 'AUT_LABEL',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'newgroups' => 'AUT_NEWGROUPS',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'opaque' => 'AUT_OPAQUE',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'path' => 'AUT_PATH',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'path_list' => '-AUT_PATH', # dummy token id
c0c79a3f09914f35651895ffc111883455b7f62dtz 'process' => 'AUT_PROCESS',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'priv_effective' => 'ADT_AUT_PRIV_E', # dummy token id
c0c79a3f09914f35651895ffc111883455b7f62dtz 'priv_limit' => 'ADT_AUT_PRIV_L', # dummy token id
c0c79a3f09914f35651895ffc111883455b7f62dtz 'priv_inherit' => 'ADT_AUT_PRIV_I', # dummy token id
c0c79a3f09914f35651895ffc111883455b7f62dtz 'return' => 'AUT_RETURN',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'seq' => 'AUT_SEQ',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'socket' => 'AUT_SOCKET',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'socket-inet' => 'AUT_SOCKET_INET',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'subject' => 'AUT_SUBJECT',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'text' => 'AUT_TEXT',
047f6e6f42a3d50d3e38a05c00bf7dd3fafac726gww 'tid' => 'AUT_TID',
c0c79a3f09914f35651895ffc111883455b7f62dtz # 'trailer' => 'AUT_TRAILER', # not used
c0c79a3f09914f35651895ffc111883455b7f62dtz 'uauth' => 'AUT_UAUTH',
047f6e6f42a3d50d3e38a05c00bf7dd3fafac726gww 'user' => 'AUT_USER',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'zonename' => 'AUT_ZONENAME'
c0c79a3f09914f35651895ffc111883455b7f62dtz );
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my @xlateEntryList = ();
c0c79a3f09914f35651895ffc111883455b7f62dtz my @jniEntryList = ();
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $external = $event->getExternal();
c0c79a3f09914f35651895ffc111883455b7f62dtz my $internal = $event->getInternal();
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz unless ($external) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "No external object captured for event $eventId\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz return;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz unless ($internal) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "No internal object captured for event $eventId\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz return;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz my @entryRef = $internal->getEntries();
c0c79a3f09914f35651895ffc111883455b7f62dtz my $entryRef;
c0c79a3f09914f35651895ffc111883455b7f62dtz my @tokenOrder = ();
c0c79a3f09914f35651895ffc111883455b7f62dtz my $firstTokenIndex = 0; # djdj not used yet, djdj BUG!
c0c79a3f09914f35651895ffc111883455b7f62dtz # needs to be used by translate table
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($internal->isReorder()) { # prescan the entry list to get the token order
c0c79a3f09914f35651895ffc111883455b7f62dtz my @inputOrder;
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach $entryRef (@entryRef) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($intEntry, $entry) = @$entryRef;
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@inputOrder, $intEntry->getAttr('order'));
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $i; # walk down the inputOrder list once
c0c79a3f09914f35651895ffc111883455b7f62dtz my $k = 1; # discover next in line
c0c79a3f09914f35651895ffc111883455b7f62dtz my $l = 0; # who should point to next in line
c0c79a3f09914f35651895ffc111883455b7f62dtz for ($i = 0; $i <= $#inputOrder; $i++) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $j;
c0c79a3f09914f35651895ffc111883455b7f62dtz for ($j = 0; $j <= $#inputOrder; $j++) {
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($k == $inputOrder[$j]) {
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($k == 1) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $firstTokenIndex = $j;
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz $tokenOrder[$l] = "&(selfReference[$j])";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $l = $j;
c0c79a3f09914f35651895ffc111883455b7f62dtz last;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $k++;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $tokenOrder[$l] = 'NULL';
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz else { # default order -- input order same as output
c0c79a3f09914f35651895ffc111883455b7f62dtz my $i;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $j;
c0c79a3f09914f35651895ffc111883455b7f62dtz for ($i = 0; $i < $#entryRef; $i++) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $j = $i + 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz $tokenOrder[$i] = "&(selfReference[$j])";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $tokenOrder[$#entryRef] = 'NULL';
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $sequence = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach $entryRef (@entryRef) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($intEntry, $entry) = @$entryRef;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $entryId = $entry->getAttr('id');
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($extEntry, $unusedEntry, $tokenId) =
c0c79a3f09914f35651895ffc111883455b7f62dtz $external->getEntry($entryId);
c0c79a3f09914f35651895ffc111883455b7f62dtz my $opt = $extEntry->getAttr('opt');
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($opt eq 'none') {
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined ($doc->getToken($tokenId))) {
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined ($tokenType{$tokenId})) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $tokenId = $tokenType{$tokenId};
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz else {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "token id $tokenId not implemented\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz else {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "token = $tokenId is undefined\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz $tokenId = 'error';
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($xlate, $jni) =
c0c79a3f09914f35651895ffc111883455b7f62dtz formatTableEntry ('', $tokenId, $eventId, '', 0, 0, $tokenOrder[$sequence],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'NULL', '');
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@xlateEntryList, $xlate);
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@jniEntryList, @$jni);
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz else {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $dataType = $extEntry->getAttr('type');
c0c79a3f09914f35651895ffc111883455b7f62dtz $dataType =~ s/\s+//g; # remove blanks (char * => char*)
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $enumGroup = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($dataType =~ /^msg/i) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $enumGroup = $dataType;
c0c79a3f09914f35651895ffc111883455b7f62dtz $enumGroup =~ s/^msg\s*//i;
c0c79a3f09914f35651895ffc111883455b7f62dtz $enumGroup = 'adt_' . $enumGroup;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz my $required = ($opt eq 'required') ? 1 : 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $tsol = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $tokenId = $intEntry->getAttr('token');
c0c79a3f09914f35651895ffc111883455b7f62dtz my $token;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $tokenName;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $tokenFormat = $intEntry->getAttr('format');
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined ($tokenFormat)) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $tokenFormat = "\"$tokenFormat\"";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz else {
c0c79a3f09914f35651895ffc111883455b7f62dtz $tokenFormat = 'NULL';
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined ($token = $doc->getToken($tokenId))) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $tsol = (lc $token->getUsage() eq 'tsol') ? 1 : 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined ($tokenType{$tokenId})) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $tokenName = $tokenType{$tokenId};
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz else {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "token id $tokenId not implemented\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz else {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR
c0c79a3f09914f35651895ffc111883455b7f62dtz "$tokenId is an unimplemented token ($entryId in $eventId)\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz $tokenName = 'AUT_TEXT';
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($xlate, $jni) =
c0c79a3f09914f35651895ffc111883455b7f62dtz formatTableEntry($entryId, $tokenName, $eventId, $dataType, $required,
c0c79a3f09914f35651895ffc111883455b7f62dtz $tsol, $tokenOrder[$sequence], $tokenFormat,
c0c79a3f09914f35651895ffc111883455b7f62dtz $enumGroup, (uc $omit eq 'JNI'));
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@xlateEntryList, $xlate);
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@jniEntryList, @$jni);
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $sequence++;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $jniEventTable{$eventId} = [\@jniEntryList, $eventType,
c0c79a3f09914f35651895ffc111883455b7f62dtz $external->getAllowedTypes(), $eventHeader]
c0c79a3f09914f35651895ffc111883455b7f62dtz unless (uc $omit eq 'JNI') || ($omit eq 'always');
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzsub formatTableEntry {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($id, $token, $eventId, $type, $required, $tsol, $sequence, $format, $enumGroup,
c0c79a3f09914f35651895ffc111883455b7f62dtz $omitJNI) = @_;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz # does this map belong in the xml source? (at least the defaults?)
c0c79a3f09914f35651895ffc111883455b7f62dtz # fill in the default value only if it is other than zero.
c0c79a3f09914f35651895ffc111883455b7f62dtz # base type adt name, default value
c0c79a3f09914f35651895ffc111883455b7f62dtz my %entryDef = ( 'au_asid_t' => ['ADT_UINT32', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'uint_t' => ['ADT_UINT32', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'int' => ['ADT_INT', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'int32_t' => ['ADT_INT32', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'uid_t' => ['ADT_UID', 'AU_NOAUDITID'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'gid_t' => ['ADT_GID', 'AU_NOAUDITID'],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'uid_t*' => ['ADT_UIDSTAR', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'gid_t*' => ['ADT_GIDSTAR', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'char' => ['ADT_CHAR', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'char*' => ['ADT_CHARSTAR', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'char**' => ['ADT_CHAR2STAR', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'long' => ['ADT_LONG', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'pid_t' => ['ADT_PID', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'priv_set_t*' => ['ADT_PRIVSTAR', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'ulong_t' => ['ADT_ULONG', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'uint16_t', => ['ADT_UINT16', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'uint32_t' => ['ADT_UINT32', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'uint32_t*' => ['ADT_UINT32STAR', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'uint32_t[]' => ['ADT_UINT32ARRAY', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'uint64_t' => ['ADT_UINT64', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'uint64_t*' => ['ADT_UINT64STAR', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz 'm_label_t*' => ['ADT_MLABELSTAR', ''],
c0c79a3f09914f35651895ffc111883455b7f62dtz );
c0c79a3f09914f35651895ffc111883455b7f62dtz my $xlateLabel = $uniLabel.$xlateUniLabelInc;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $xlateLabelInc = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $xlateLine = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz my @jniLine = ();
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz # the list handling should be a simple loop with a loop of one
c0c79a3f09914f35651895ffc111883455b7f62dtz # falling out naturally.
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz unless ($type =~ /,/) { # if list, then generate sequence of entries
c0c79a3f09914f35651895ffc111883455b7f62dtz my $dataType;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $dataSize;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $xlateLabelRef = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $arraySize = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz $arraySize = $1 if ($type =~ s/\[(\d+)\]/[]/);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $entryType = ${$entryDef{$type}}[0];
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my @xlateType = (); # for adt_xlate.c
c0c79a3f09914f35651895ffc111883455b7f62dtz my $typeCount = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($entryType) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $dataType = $entryType;
c0c79a3f09914f35651895ffc111883455b7f62dtz $type =~ s/([^*]+)\s*(\*+)/$1 $2/;
c0c79a3f09914f35651895ffc111883455b7f62dtz $type =~ s/\[\]//;
c0c79a3f09914f35651895ffc111883455b7f62dtz $dataSize = "sizeof ($type)";
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($arraySize) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $dataSize = "$arraySize * " . $dataSize;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLine = "{{$dataType, $dataSize}}";
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@jniLine, [$id, $dataType, $format, $enumGroup, $required]);
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($type eq '') {
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLabelRef = 'NULL';
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($type =~ /^msg/i) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $type =~ s/^msg//i;
c0c79a3f09914f35651895ffc111883455b7f62dtz $dataType = 'ADT_MSG';
c0c79a3f09914f35651895ffc111883455b7f62dtz my $dataEnum = 'ADT_LIST_' . uc $type;
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLine = "{{$dataType, $dataEnum}}";
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@jniLine, [$id, $dataType, $format, $enumGroup, $required]);
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($type =~ /time_t/i) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $dataType = 'ADT_DATE';
c0c79a3f09914f35651895ffc111883455b7f62dtz $dataSize = "sizeof (time_t)";
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLine = "{{$dataType, $dataSize}}";
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@jniLine, [$id, $dataType, $format, $enumGroup, $required]);
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($type =~ /termid/i) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $dataType = 'ADT_TERMIDSTAR';
c0c79a3f09914f35651895ffc111883455b7f62dtz $dataSize = "sizeof (au_tid_addr_t *)";
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLine = "{{$dataType, $dataSize}}";
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@jniLine, [$id, $dataType, $format, $enumGroup, $required]);
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($omitJNI) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLabelRef = 'NULL';
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "$type is not an implemented data type\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLabelRef = 'NULL';
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLabelRef = '&' . $xlateLabel . '[0]'
c0c79a3f09914f35651895ffc111883455b7f62dtz unless $xlateLabelRef eq 'NULL';
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz # "EOL" is where a comma should go unless end of list
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLine = "{$token,\t1,\t$xlateLabelRef,\t$sequence,\n" .
c0c79a3f09914f35651895ffc111883455b7f62dtz "\t\t0,\t$required,\t$tsol,\t$format}EOL";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz } else { # is a list
c0c79a3f09914f35651895ffc111883455b7f62dtz my @type = split(/,/, $type);
c0c79a3f09914f35651895ffc111883455b7f62dtz my @arraySize = ();
c0c79a3f09914f35651895ffc111883455b7f62dtz my @id = split(/,/, $id);
c0c79a3f09914f35651895ffc111883455b7f62dtz my @jniId = @id;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $dataType;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $typeCount = ($#type + 1);
c0c79a3f09914f35651895ffc111883455b7f62dtz my @xlateType = ();
c0c79a3f09914f35651895ffc111883455b7f62dtz my @default = ();
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach my $dtype (@type) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $jniId = shift @jniId;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $id = shift @id;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $arraySize = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz $arraySize = $1 if ($dtype =~ s/\[(\d+)\]/[]/);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $entryType = ${$entryDef{$dtype}}[0];
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($entryType) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $type = $dtype;
c0c79a3f09914f35651895ffc111883455b7f62dtz $type =~ s/([^*]+)\s*(\*+)/$1 $2/;
c0c79a3f09914f35651895ffc111883455b7f62dtz $type =~ s/\[\]//;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $sizeString = "sizeof";
c0c79a3f09914f35651895ffc111883455b7f62dtz $sizeString = "$arraySize * " . $sizeString if $arraySize;
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@xlateType, "\{$entryType, $sizeString ($type)\}");
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@jniLine, [$jniId, $entryType, $format, $enumGroup, $required]);
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($type =~ /^msg/i) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $type =~ s/^msg//i;
c0c79a3f09914f35651895ffc111883455b7f62dtz $dataType = 'ADT_MSG';
c0c79a3f09914f35651895ffc111883455b7f62dtz my $dataEnum = 'ADT_LIST_' . uc $type;
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@xlateType, "\{$dataType, $dataEnum\}};");
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@jniLine, [$jniId, $dataType, $format, $enumGroup, $required]);
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($type =~ /time_t/i) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $dataType = 'ADT_DATE';
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@xlateType, "\{$entryType, sizeof ($type)\}");
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@jniLine, [$jniId, $entryType, $format, $enumGroup, $required]);
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($type =~ /termid/i) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $dataType = 'ADT_TERMIDSTAR';
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@xlateType, "\{$dataType, sizeof (au_tid_addr_t *)\}");
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@jniLine, [$jniId, $dataType, $format, $enumGroup, $required]);
c0c79a3f09914f35651895ffc111883455b7f62dtz } elsif ($omitJNI) {
c0c79a3f09914f35651895ffc111883455b7f62dtz # nothing to do.
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "$dtype is not an implemented data type\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz if (${$entryDef{$dtype}}[1]) {
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@default, $id, ${$entryDef{$dtype}}[1]);
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz my $xlateArray = "\[$typeCount\] =\t{" . join(",\n\t\t\t\t", @xlateType) . "};";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLine =
c0c79a3f09914f35651895ffc111883455b7f62dtz "{$token,\t$typeCount,\t&$xlateLabel\[0\],\t$sequence,\n" .
c0c79a3f09914f35651895ffc111883455b7f62dtz "\t\t0,\t$required,\t$tsol,\t$format}EOL";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateUniLabelInc++ if $xlateLabelInc;
c0c79a3f09914f35651895ffc111883455b7f62dtz return ($xlateLine, \@jniLine);
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzsub generateMsgLists {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $textList = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $textName = $textList->getId();
c0c79a3f09914f35651895ffc111883455b7f62dtz my $header = $textList->getHeader();
c0c79a3f09914f35651895ffc111883455b7f62dtz my $start = $textList->getMsgStart();
c0c79a3f09914f35651895ffc111883455b7f62dtz my $public = $textList->getMsgPublic();
c0c79a3f09914f35651895ffc111883455b7f62dtz my $deprecated = $textList->getDeprecated();
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print "$textName starts at $start\n" if $debug;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $entry;
c0c79a3f09914f35651895ffc111883455b7f62dtz my @entry;
c0c79a3f09914f35651895ffc111883455b7f62dtz while ($entry = $textList->getNextMsg()) {
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($debug) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($id, $text) = split(/\s*::\s*/, $entry);
c0c79a3f09914f35651895ffc111883455b7f62dtz print " $id = $text\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz unshift (@entry, $entry);
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $msg_list{$textName} =
c0c79a3f09914f35651895ffc111883455b7f62dtz [\@entry, [$header, $start, $public, $deprecated]];
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtzsub readAuditEventFile {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $eventListFile = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz open(Event, $eventListFile)
c0c79a3f09914f35651895ffc111883455b7f62dtz or die "can't open $eventListFile: $!\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz while(<Event>) {
c0c79a3f09914f35651895ffc111883455b7f62dtz next if /^\s*#/;
c0c79a3f09914f35651895ffc111883455b7f62dtz next if /^\s*$/;
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($value, $name) = split(/\s*:\s*/);
c0c79a3f09914f35651895ffc111883455b7f62dtz next if $value < 6000;
c0c79a3f09914f35651895ffc111883455b7f62dtz $eventCode{$name} = $value;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz close Event;
c0c79a3f09914f35651895ffc111883455b7f62dtz}