auditxml revision c0c79a3f09914f35651895ffc111883455b7f62d
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#!/usr/perl5/bin/perl -w
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# CDDL HEADER START
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# The contents of this file are subject to the terms of the
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# Common Development and Distribution License (the "License").
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# You may not use this file except in compliance with the License.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# or http://www.opensolaris.org/os/licensing.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# See the License for the specific language governing permissions
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# and limitations under the License.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# When distributing Covered Code, include this CDDL HEADER in each
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# If applicable, add the following below this CDDL HEADER, with the
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# fields enclosed by brackets "[]" replaced with your own identifying
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# information: Portions Copyright [yyyy] [name of copyright owner]
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# CDDL HEADER END
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# Use is subject to license terms.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# ident "%Z%%M% %I% %E% SMI"
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# auditxml [-d] <xml input file>
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# auditxml takes the audit record description (.xml file) and
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# generates the files needed for the C audit api.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncuse auditxml;
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncuse Getopt::Std;
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncuse vars qw($opt_d);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncuse strict;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncour $debug = 0; # normal use is to set via the file being parsed.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # <debug set="on"/> or <debug set="off"/> or <debug/>
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # if the set attribute is omitted, debug state is toggled
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # Override with appDebug, but toggle won't do what you
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # want.
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy $appDebug = 0; # used after return from "new auditxml";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy $genNotice = "
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncDO NOT EDIT. This file is auto generated by the Solaris Audit
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncsystem from adt.xml.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncSee http://opensolaris.org/os/project/audit/
a180a41bba1d50822df23fff0099e90b86638b89vboxsync";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# trim leading/trailing newlines
a180a41bba1d50822df23fff0099e90b86638b89vboxsync$genNotice =~ s/^\n//s;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync$genNotice =~ s/\n$//s;
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy $prog = $0; $prog =~ s|.*/||g;
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy $usage = "usage: $prog [-d] file.xml\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncgetopts('d');
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync$appDebug = $opt_d;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy $uniLabel = "adr";
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy $xlateUniLabelInc = 0;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncdie $usage if ($#ARGV < 0);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# where everything comes from and where it goes:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy $bsmBuildPath = "./common";
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy $xlateFile = "$bsmBuildPath/adt_xlate.c";
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy $headerFile = "$bsmBuildPath/adt_event_N.h";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy $doc = new auditxml ($ARGV[0]); # input XML file
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync$debug = $appDebug;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy %xlateEventTable = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy @xlateTypeList = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy %xlateTypeList = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy %eventAPI = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy %eventExtra = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy %headers = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy %externalIdNo = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy @outputState = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy %nameTranslation = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy @xlateDefaults = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy %xlateDefault = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy %msg_list = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy $event;
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncwhile ($event = $doc->getNextEvent()) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $eventId = $event->getId();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $eventHeader = $event->getHeader();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $idNo = $event->getIdNo();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $externalIdNo{$eventId} = $idNo;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync addHeader($eventHeader) if defined ($eventHeader);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $super;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $omit = $event->getOmit();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $eventType = '';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($super = $event->getSuperClass()) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $event = $super;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $eventType = 'instance';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $eventType = $event->getType();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # header file for API use
a180a41bba1d50822df23fff0099e90b86638b89vboxsync generateAPIFile($event, $eventId, $eventType, $eventHeader, $idNo)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless $omit eq 'always';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # c file table for translation
a180a41bba1d50822df23fff0099e90b86638b89vboxsync generateTableC($event, $eventId, $eventType, $eventHeader, $omit);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy $textList;
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncwhile ($textList = $doc->getNextMsgId()) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync generateMsgLists($textList); # enum -> text mappings
a180a41bba1d50822df23fff0099e90b86638b89vboxsync}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncprintTableC($xlateFile);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncprintAPIFile($headerFile, $doc);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncexit 0;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncsub printTableC {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $file = shift;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless (open(Cfile, ">$file")) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "can't open output file ($file): $!\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $notice = $genNotice;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $notice =~ s/\n/\n * /gs;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $notice =~ s/\s+\n/\n/gs;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile <<EOF;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/*
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * $notice
a180a41bba1d50822df23fff0099e90b86638b89vboxsync */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#include <bsm/libbsm.h>
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#include <adt_xlate.h>
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#include <libintl.h>
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncEOF
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "#ifndef _PRAUDIT\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "/* Internal data type definitions */\n\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $extDef;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach $extDef (@xlateTypeList) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "static $extDef\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync @xlateTypeList = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\n/* External event structure to internal event structure */\n\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @pointers = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach my $eventId (sort keys %xlateEventTable) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($xlateEventTable{$eventId}) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($ref1, $eventType, $firstToken, $eventHeader) =
a180a41bba1d50822df23fff0099e90b86638b89vboxsync @{$xlateEventTable{$eventId}};
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @entries = @$ref1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $entry;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $entries = $#entries;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $count = $entries + 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $externalName = $nameTranslation{$eventId};
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $externalRoot = $externalName;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $externalRoot =~ s/AUE_//;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $structName = "XX_$externalRoot";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $root = $eventId;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $root =~ s/AUE_//;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $externalId = $eventId;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $externalId =~ s/AUE_/ADT_/;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless ($eventType eq 'generic') {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "static struct entry $structName\[$count\] = {\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach $entry (@entries) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($entries--) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $entry =~ s/EOL/,/;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $entry =~ s/EOL//;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $entry =~ s/selfReference/$structName/;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\t$entry\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "};\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "static struct translation X_$externalRoot = {\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@pointers, "X_$externalRoot");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\t0,\n"; # tx_offsetsCalculated = 0
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\t$externalId,\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\t$externalName,\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\t$count,\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\t&XX_$externalRoot\[$firstToken\],\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\t&XX_$externalRoot\[0\]\n};\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "expected entry for $eventId but none found\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $count = $#pointers + 2;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "struct translation *xlate_table[$count] = {\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $firstEvent = 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach my $eventId (@pointers) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($firstEvent) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $firstEvent = 0;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile ",\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\t&$eventId";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile ",\n\tNULL\n};\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # generate the adt_preload() function
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile <<EOF;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncvoid
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncadt_preload(au_event_t event_id, adt_event_data_t *event_data)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync{
a180a41bba1d50822df23fff0099e90b86638b89vboxsync switch (event_id) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncEOF
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach my $id (@xlateDefaults) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $adtID = $id;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $adtID =~ s/AUE/ADT/;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile <<EOF;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync case $adtID:
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncEOF
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @preloads = @{$xlateDefault{$id}};
a180a41bba1d50822df23fff0099e90b86638b89vboxsync while (@preloads) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $fieldName = shift @preloads;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $default = shift @preloads;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $lcid = lc $id;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $lcid =~ s/aue_/adt_/;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile <<EOF;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync event_data->$lcid.$fieldName = $default;
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncEOF
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile <<EOF;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync break;
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncEOF
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile <<EOF;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync default:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync break;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#endif
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* message lists */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncEOF
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $listName;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @listName;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach $listName (sort keys %msg_list) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($listRef, $headref) = @{$msg_list{$listName}};
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($header, $start, $public, $deprecated) = @$headref;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @listValue = @$listRef;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $listValue;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $listLength = $#listValue + 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $listName = 'NULL' if ($#listValue < 0);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@listName, [$listName, $listLength - 1, $start, $public]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync next if ($#listValue < 0);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "/* Deprecated message list */\n" if ($deprecated);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "static char *msg_$listName\[$listLength] = {\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $ffirst = 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach $listValue (@listValue) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile ",\n" unless $ffirst;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $ffirst = 0;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($id, $text) = split(/\s*::\s*/, $listValue);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($text) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\t\"$text\"";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\tNULL";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\n};\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\nstruct msg_text adt_msg_text[", $#listName + 1,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "] = {\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $ffirst = 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach $listName (@listName) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($name, $max, $start) = @$listName;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $start = -$start if $start;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile ",\n" unless $ffirst;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $ffirst = 0;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $name = "msg_$name" if ($name ne 'NULL');
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\t{0, $max, $name, $start}";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\n};\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync close Cfile;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncsub printAPIFile {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $file = shift;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $xmlDoc = shift;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @Hfile;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync @Hfile = openHeaderFiles($file);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $notice = $genNotice;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $notice =~ s/\n/\n * /gs;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $notice =~ s/\s+\n/\n/gs;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach my $header (keys %headers) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync next unless $Hfile[$header];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync *Hfile = $Hfile[$header];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $include = "adt.h";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $adt_event_n = "_ADT_EVENT_H";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($header > 0) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $include = "adt_event.h";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $adt_event_n = "_ADT_EVENT_".$header."_H";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile <<EOF;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/*
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * $notice
a180a41bba1d50822df23fff0099e90b86638b89vboxsync */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#ifndef $adt_event_n
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define $adt_event_n
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#include <bsm/$include>
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#ifdef __cplusplus
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern "C" {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#endif
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/*
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * adt_put_event() status values. Positive values are for kernel-generated
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * failure, -1 for user-space. For ADT_SUCCESS, the adt_put_event() return_val
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * is not used; the convention is to set it to ADT_SUCCESS.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define ADT_SUCCESS 0
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define ADT_FAILURE -1
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncEOF
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach my $listName (sort keys %msg_list) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $shortName = uc $listName;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $shortName =~ s/_TEXT//;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($listRef, $headref) = @{$msg_list{$listName}};
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($header, $start, $public, $deprecated) = @$headref;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync next unless $Hfile[$header];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync *Hfile = $Hfile[$header];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "/* Deprecated message list */\n" if $deprecated;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "#define\tADT_$shortName\t$start\n" if $start;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @listValue = @$listRef;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync next unless ($#listValue >= 0);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "enum\tadt_$listName", " {\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $listValue;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $i = 0;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $j = $#listValue;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $comma = ',';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach $listValue (@listValue) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($id, $text) = split(/\s*::\s*/, $listValue);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $comma = '' if $i++ == $j;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($start) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $start = " = $start$comma";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $start = "$comma\t";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $text = "(no token will be generated)" unless $text;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "\tADT_$shortName", "_$id$start\t/* $text */\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $start = '';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "};\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # generate defines for ADT_* external event names
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach my $eventId (sort keys %eventAPI) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($header, $idNo) = @{$eventExtra{$eventId}};
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless (defined ($header)) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "missing header selection for $eventId\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync next;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync *Hfile = $Hfile[$header];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync next unless $Hfile[$header];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $l = length($eventId) + 8; # label plus preceding #define\t
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $l = 5 - int(($l + 8)/8);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $l = 1 if $l < 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $tab = "\t" x $l;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "missing id number for $eventId\n" unless $idNo;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $eventId =~ s/AUE_/ADT_/;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "#define\t$eventId$tab$idNo\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # generate per-event structures
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach my $eventId (sort keys %eventAPI) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($header, $idNo) = @{$eventExtra{$eventId}};
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $dataId = $eventId;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataId =~ s/^AUE_/adt_/;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless(defined ($header)) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "$eventId is missing the header assignment\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync next;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync *Hfile = $Hfile[$header];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync next unless $Hfile[$header];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $externalId = $eventId;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $externalId =~ s/AUE_/ADT_/;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "\nstruct $dataId {\t/* $externalId */\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @entries = @{$eventAPI{$eventId}};
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $entry;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($#entries < 0) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "\tint\tdummy;\t/* not used */\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach $entry (@entries) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $entry =~ s/termid/adt_termid_t/;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "\t$entry\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "};\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $eventId =~ s/^AUE_/adt_/;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "typedef struct $dataId $eventId","_t;\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach my $header (sort keys %headers) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $outputState[$header] = 0;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach my $eventId (sort keys %eventAPI) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($header, $idNo) = @{$eventExtra{$eventId}};
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless(defined ($header)) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # don't print duplicate error message
a180a41bba1d50822df23fff0099e90b86638b89vboxsync next;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync *Hfile = $Hfile[$header];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync next unless $Hfile[$header];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($outputState[$header] == 0) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $outputState[$header] = 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $suffix = '';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $suffix = "_$header" if $header;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "\nunion adt_event_data$suffix {\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $elementName = $eventId;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $elementName =~ s/^AUE_/adt_/;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $eventId =~ s/^AUE_/adt_/;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $elementName =~ s/_t$//;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "\t\t$eventId","_t\t$elementName;\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach my $header (sort keys %headers) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($outputState[$header]) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync *Hfile = $Hfile[$header];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync next unless $Hfile[$header];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "};\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach my $header (keys %headers) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync next unless $Hfile[$header];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync *Hfile = $Hfile[$header];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $adt_event_n = "_ADT_EVENT_H";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($header > 0) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $adt_event_n = "_ADT_EVENT_".$header."_H";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile <<EOF;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#ifndef ADT_PRIVATE
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define ADT_PRIVATE
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/*
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * These interfaces are project private and will change without
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * notice as needed for the BSM API project.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_get_auid(const adt_session_data_t *, au_id_t *);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_set_auid(const adt_session_data_t *, const au_id_t);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_get_mask(const adt_session_data_t *, au_mask_t *);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_set_mask(const adt_session_data_t *, const au_mask_t *);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_get_termid(const adt_session_data_t *, au_tid_addr_t *);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_set_termid(const adt_session_data_t *,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync const au_tid_addr_t *);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_get_asid(const adt_session_data_t *, au_asid_t *);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_set_asid(const adt_session_data_t *, const au_asid_t);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#endif
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#ifdef __cplusplus
a180a41bba1d50822df23fff0099e90b86638b89vboxsync}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#endif
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#endif /* $adt_event_n */
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncEOF
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync closeHeaderFiles(@Hfile);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncsub generateTableC {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $event = shift;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $eventId = shift;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $eventType = shift;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $eventHeader = shift;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $omit = shift;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my %tokenType = (
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'acl' => 'AUT_ACL',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'arbitrary' => 'AUT_ARBITRARY',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'arg' => 'AUT_ARG',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'attr' => 'AUT_ATTR',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'command' => 'AUT_CMD',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'command_1' => 'ADT_CMD_ALT', # dummy token id
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'date' => 'AUT_TEXT',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'exec_args' => 'AUT_EXEC_ARGS',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'exec_env' => 'AUT_EXEC_ENV',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'exit' => 'AUT_EXIT',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'file' => 'AUT_FILE',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'fmri' => 'AUT_FMRI',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'groups' => 'AUT_GROUPS',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # 'header' => 'AUT_HEADER', # not used
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'in_addr' => 'AUT_IN_ADDR',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'tid' => 'AUT_TID',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'ipc' => 'AUT_IPC',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'ipc_perm' => 'AUT_IPC_PERM',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'iport' => 'AUT_IPORT',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'label' => 'AUT_LABEL',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'newgroups' => 'AUT_NEWGROUPS',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'opaque' => 'AUT_OPAQUE',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'path' => 'AUT_PATH',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'path_list' => '-AUT_PATH', # dummy token id
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'process' => 'AUT_PROCESS',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'priv_effective' => 'ADT_AUT_PRIV_E', # dummy token id
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'priv_limit' => 'ADT_AUT_PRIV_L', # dummy token id
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'priv_inherit' => 'ADT_AUT_PRIV_I', # dummy token id
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'return' => 'AUT_RETURN',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'seq' => 'AUT_SEQ',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'socket' => 'AUT_SOCKET',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'socket-inet' => 'AUT_SOCKET_INET',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'subject' => 'AUT_SUBJECT',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'text' => 'AUT_TEXT',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # 'trailer' => 'AUT_TRAILER', # not used
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'uauth' => 'AUT_UAUTH',
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'zonename' => 'AUT_ZONENAME'
a180a41bba1d50822df23fff0099e90b86638b89vboxsync );
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @xlateEntryList = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $external = $event->getExternal();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $internal = $event->getInternal();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless ($external) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "No external object captured for event $eventId\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($eventType) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $nameTranslation{$eventId} = $eventId;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $nameTranslation{$eventId} = $external->getInternalName();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless ($internal) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "No internal object captured for event $eventId\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @entryRef = $internal->getEntries();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $entryRef;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @tokenOrder = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $firstTokenIndex = 0; # djdj not used yet, djdj BUG!
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # needs to be used by translate table
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($internal->isReorder()) { # prescan the entry list to get the token order
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @inputOrder;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach $entryRef (@entryRef) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($intEntry, $entry) = @$entryRef;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@inputOrder, $intEntry->getAttr('order'));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $i; # walk down the inputOrder list once
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $k = 1; # discover next in line
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $l = 0; # who should point to next in line
a180a41bba1d50822df23fff0099e90b86638b89vboxsync for ($i = 0; $i <= $#inputOrder; $i++) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $j;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync for ($j = 0; $j <= $#inputOrder; $j++) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($k == $inputOrder[$j]) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($k == 1) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $firstTokenIndex = $j;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $tokenOrder[$l] = "&(selfReference[$j])";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $l = $j;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync last;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $k++;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $tokenOrder[$l] = 'NULL';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync else { # default order -- input order same as output
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $i;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $j;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync for ($i = 0; $i < $#entryRef; $i++) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $j = $i + 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $tokenOrder[$i] = "&(selfReference[$j])";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $tokenOrder[$#entryRef] = 'NULL';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $sequence = 0;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach $entryRef (@entryRef) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($intEntry, $entry) = @$entryRef;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $entryId = $entry->getAttr('id');
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($extEntry, $unusedEntry, $tokenId) =
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $external->getEntry($entryId);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $opt = $extEntry->getAttr('opt');
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($opt eq 'none') {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (defined ($doc->getToken($tokenId))) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (defined ($tokenType{$tokenId})) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $tokenId = $tokenType{$tokenId};
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "token id $tokenId not implemented\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "token = $tokenId is undefined\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $tokenId = 'error';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($xlate, $jni) =
a180a41bba1d50822df23fff0099e90b86638b89vboxsync formatTableEntry ('', $tokenId, $eventId, '', 0, 0, $tokenOrder[$sequence],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'NULL', '');
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync push (@xlateEntryList, $xlate);
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync }
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $dataType = $extEntry->getAttr('type');
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataType =~ s/\s+//g; # remove blanks (char * => char*)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $enumGroup = '';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($dataType =~ /^msg/i) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $enumGroup = $dataType;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $enumGroup =~ s/^msg\s*//i;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $enumGroup = 'adt_' . $enumGroup;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $required = ($opt eq 'required') ? 1 : 0;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $tsol = 0;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $tokenId = $intEntry->getAttr('token');
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $token;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $tokenName;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $tokenFormat = $intEntry->getAttr('format');
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (defined ($tokenFormat)) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $tokenFormat = "\"$tokenFormat\"";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $tokenFormat = 'NULL';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (defined ($token = $doc->getToken($tokenId))) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $tsol = (lc $token->getUsage() eq 'tsol') ? 1 : 0;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (defined ($tokenType{$tokenId})) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $tokenName = $tokenType{$tokenId};
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "token id $tokenId not implemented\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "$tokenId is an unimplemented token ($entryId in $eventId)\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $tokenName = 'AUT_TEXT';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($xlate, $jni) =
a180a41bba1d50822df23fff0099e90b86638b89vboxsync formatTableEntry($entryId, $tokenName, $eventId, $dataType, $required,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $tsol, $tokenOrder[$sequence], $tokenFormat,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $enumGroup, (uc $omit eq 'JNI'));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@xlateEntryList, $xlate);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $sequence++;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateEventTable{$eventId} = [\@xlateEntryList, $eventType, $firstTokenIndex,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $eventHeader];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncsub formatTableEntry {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($id, $token, $eventId, $type, $required, $tsol, $sequence, $format, $enumGroup,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $omitJNI) = @_;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # does this map belong in the xml source? (at least the defaults?)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # fill in the default value only if it is other than zero.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # base type adt name, default value
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my %entryDef = ( 'au_asid_t' => ['ADT_UINT32', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'uint_t' => ['ADT_UINT32', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'int' => ['ADT_INT', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'int32_t' => ['ADT_INT32', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'uid_t' => ['ADT_UID', 'AU_NOAUDITID'],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'gid_t' => ['ADT_GID', 'AU_NOAUDITID'],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'uid_t*' => ['ADT_UIDSTAR', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'gid_t*' => ['ADT_GIDSTAR', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'char' => ['ADT_CHAR', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'char*' => ['ADT_CHARSTAR', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'char**' => ['ADT_CHAR2STAR', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'long' => ['ADT_LONG', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'pid_t' => ['ADT_PID', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'priv_set_t*' => ['ADT_PRIVSTAR', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'ulong_t' => ['ADT_ULONG', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'uint16_t', => ['ADT_UINT16', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'uint32_t' => ['ADT_UINT32', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'uint32_t*' => ['ADT_UINT32STAR', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'uint32_t[]' => ['ADT_UINT32ARRAY', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'uint64_t' => ['ADT_UINT64', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'uint64_t*' => ['ADT_UINT64STAR', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'm_label_t*' => ['ADT_MLABELSTAR', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync );
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $xlateLabel = $uniLabel.$xlateUniLabelInc;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $xlateLabelInc = 0;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $xlateLine = '';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @jniLine = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # the list handling should be a simple loop with a loop of one
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # falling out naturally.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless ($type =~ /,/) { # if list, then generate sequence of entries
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync my $dataType;
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync my $dataSize;
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync my $xlateLabelRef = '';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $arraySize = '';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $arraySize = $1 if ($type =~ s/\[(\d+)\]/[]/);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $entryType = ${$entryDef{$type}}[0];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @xlateType = (); # for adt_xlate.c
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $typeCount = 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($entryType) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataType = $entryType;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $type =~ s/([^*]+)\s*(\*+)/$1 $2/;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $type =~ s/\[\]//;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataSize = "sizeof ($type)";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($arraySize) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataSize = "$arraySize * " . $dataSize;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateLine = "{{$dataType, $dataSize}}";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$id, $dataType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } elsif ($type eq '') {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateLabelRef = 'NULL';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } elsif ($type =~ /^msg/i) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $type =~ s/^msg//i;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataType = 'ADT_MSG';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $dataEnum = 'ADT_LIST_' . uc $type;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateLine = "{{$dataType, $dataEnum}}";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$id, $dataType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } elsif ($type =~ /time_t/i) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataType = 'ADT_DATE';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataSize = "sizeof (time_t)";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateLine = "{{$dataType, $dataSize}}";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$id, $dataType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } elsif ($type =~ /termid/i) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataType = 'ADT_TERMIDSTAR';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataSize = "sizeof (au_tid_addr_t *)";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateLine = "{{$dataType, $dataSize}}";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$id, $dataType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } elsif ($omitJNI) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateLabelRef = 'NULL';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "$type is not an implemented data type\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateLabelRef = 'NULL';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($xlateLine && !($xlateTypeList{$xlateLine})) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateTypeList{$xlateLine} = $xlateLabel;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@xlateTypeList, "datadef\t$xlateLabel\[1\] =\t$xlateLine;");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateLabelInc = 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateLabel = $xlateTypeList{$xlateLine};
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateLabelRef = '&' . $xlateLabel . '[0]'
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless $xlateLabelRef eq 'NULL';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # "EOL" is where a comma should go unless end of list
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateLine = "{$token,\t1,\t$xlateLabelRef,\t$sequence,\n" .
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "\t\t0,\t$required,\t$tsol,\t$format}EOL";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (${$entryDef{$type}}[1]) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @list = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($xlateDefault{$eventId}) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync @list = @{$xlateDefault{$eventId}};
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@xlateDefaults, $eventId);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@list, $id, ${$entryDef{$type}}[1]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateDefault{$eventId} = \@list;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else { # is a list
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @type = split(/,/, $type);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @arraySize = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @id = split(/,/, $id);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @jniId = @id;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $dataType;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $typeCount = ($#type + 1);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @xlateType = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @default = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach my $dtype (@type) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $jniId = shift @jniId;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $id = shift @id;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $arraySize = '';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $arraySize = $1 if ($dtype =~ s/\[(\d+)\]/[]/);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $entryType = ${$entryDef{$dtype}}[0];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($entryType) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $type = $dtype;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $type =~ s/([^*]+)\s*(\*+)/$1 $2/;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $type =~ s/\[\]//;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $sizeString = "sizeof";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $sizeString = "$arraySize * " . $sizeString if $arraySize;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@xlateType, "\{$entryType, $sizeString ($type)\}");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$jniId, $entryType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } elsif ($type =~ /^msg/i) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $type =~ s/^msg//i;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataType = 'ADT_MSG';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $dataEnum = 'ADT_LIST_' . uc $type;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@xlateType, "\{$dataType, $dataEnum\}};");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$jniId, $dataType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } elsif ($type =~ /time_t/i) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataType = 'ADT_DATE';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@xlateType, "\{$entryType, sizeof ($type)\}");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$jniId, $entryType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } elsif ($type =~ /termid/i) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataType = 'ADT_TERMIDSTAR';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@xlateType, "\{$dataType, sizeof (au_tid_addr_t *)\}");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$jniId, $dataType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } elsif ($omitJNI) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # nothing to do.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "$dtype is not an implemented data type\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (${$entryDef{$dtype}}[1]) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@default, $id, ${$entryDef{$dtype}}[1]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $xlateArray = "\[$typeCount\] =\t{" . join(",\n\t\t\t\t", @xlateType) . "};";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless ($xlateTypeList{$xlateArray}) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateTypeList{$xlateArray} = $xlateLabel;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateArray = "datadef\t$xlateLabel" . $xlateArray;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@xlateTypeList, $xlateArray);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateLabelInc = 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateLabel = $xlateTypeList{$xlateArray};
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateLine =
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "{$token,\t$typeCount,\t&$xlateLabel\[0\],\t$sequence,\n" .
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "\t\t0,\t$required,\t$tsol,\t$format}EOL";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (@default) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @list = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($xlateDefault{$eventId}) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync @list = @{$xlateDefault{$eventId}};
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@xlateDefaults, $eventId);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@list, @default);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateDefault{$eventId} = \@list;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateUniLabelInc++ if $xlateLabelInc;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return ($xlateLine, \@jniLine);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncsub generateAPIFile {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $event = shift;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $eventId = shift;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $eventType = shift;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $eventHeader = shift;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $idNo = shift;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @entryList = ();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $external = $event->getExternal();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($eventType && $debug) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "event $eventId is of type $eventType\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return unless $external;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($extEntry, $entry, $tokenId, $format);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync while (($extEntry, $entry, $tokenId, $format) = $external->getNextEntry()) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync last unless $entry;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $entryId = $entry->getAttr('id');
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless (defined $entryId) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "undefined entry id for external $eventId\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync next;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $option = $extEntry->getAttr('opt');
a180a41bba1d50822df23fff0099e90b86638b89vboxsync next if ($option eq 'none');
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (defined (my $token = $doc->getToken($tokenId))) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $option = 'Trusted Solaris only'
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (lc $token->getUsage() eq 'tsol') ? 1 : 0;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $option .= " (format: $format)" if $format;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $dataType = $extEntry->getAttr('type');
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless (defined $dataType) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "no type defined for external tag for $eventId\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataType = "error";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $comment = $entry->getContent();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (($dataType =~ /,/) || ($entryId =~ /,/)) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @type = split(/\s*,\s*/, $dataType);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @id = split(/\s*,\s*/, $entryId);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($#type != $#id) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "number of data types ($dataType) does not match number of ids ($entryId)",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync " for event $eventId\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($#type < $#id) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $#id = $#type;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $#type = $#id;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $i;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $line = '';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $line = "/* $comment */\n\t" if defined $comment;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync for ($i = 0; $i <= $#type; $i++) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($primitive, $dereference) =
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ($type[$i] =~ /([^\*]+)\s*(\**)/);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $id[$i] .= $1 if ($primitive =~ s/(\[\d+\])//);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $line .= "$primitive\t$dereference$id[$i];\t/* $option */";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@entryList, $line);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $line = '';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $line = '';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $line = "/* $comment */\n\t" if defined $comment;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($dataType =~ /^msg/i) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataType =~ s/^msg\s*//i;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $line .= "enum adt_$dataType" . "\t$entryId;\t/* $option */";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync elsif ($dataType =~ /time_t/i) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $line .= "time_t\t$entryId;\t/* $option */";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($primitive, $dereference) =
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ($dataType =~ /([^\*]+)\s*(\**)/);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $entryId .= $1 if ($primitive =~ s/(\[\d+\])//);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $line .= "$primitive\t$dereference$entryId;\t/* $option */";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@entryList, $line);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $eventExtra{$eventId} = [$eventHeader, $idNo];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $eventAPI{$eventId} = \@entryList;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncsub generateMsgLists {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $textList = shift;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $textName = $textList->getId();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $header = $textList->getHeader();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $start = $textList->getMsgStart();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $public = $textList->getMsgPublic();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $deprecated = $textList->getDeprecated();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync addHeader($header);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print "$textName starts at $start\n" if $debug;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $entry;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @entry;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync while ($entry = $textList->getNextMsg()) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($debug) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($id, $text) = split(/\s*::\s*/, $entry);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print " $id = $text\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unshift (@entry, $entry);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $msg_list{$textName} =
a180a41bba1d50822df23fff0099e90b86638b89vboxsync [\@entry, [$header, $start, $public, $deprecated]];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncsub addHeader {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $header_index = shift;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync die "invalid adt_event_N.h index: $header_index\n"
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless ($header_index =~ /^\d+$/);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $headers{$header_index} = $header_index;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# $header = 0 is a special case; it is for adt_event.h
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# $header > 0 creates adt_event_N.h, where N = $header
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncsub openHeaderFiles {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $outfile = shift; # path to an adt_event_N.h file
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $header;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @Hfile = (); # potentially sparse array of file handles
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @HfileName = (); # parallel array to Hfile, file name (not path)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach $header (sort keys %headers) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $file = $outfile;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($header > 0) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $file =~ s/_N/_$header/;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $file =~ s/_N//;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless (open($Hfile[$header], ">$file")) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "can't open output ($file): $!\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $HfileName[$header] = '';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $Hfile[$header] = '';
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @tmp = split(/\//, $file);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $HfileName[$header] = $tmp[$#tmp];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return (@Hfile);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncsub closeHeaderFiles {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @Hfile = @_;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $header;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync foreach $header (sort keys %headers) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync close $Hfile[$header] if $Hfile[$header];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync