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#
047f6e6f42a3d50d3e38a05c00bf7dd3fafac726gww# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
c0c79a3f09914f35651895ffc111883455b7f62dtz# Use is subject to license terms.
c0c79a3f09914f35651895ffc111883455b7f62dtz#
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz# auditxml takes the audit record description (.xml file) and
c0c79a3f09914f35651895ffc111883455b7f62dtz# generates the files needed for the C audit api.
c0c79a3f09914f35651895ffc111883455b7f62dtz
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwmy $prog = $0; $prog =~ s|.*/||g;
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwmy $usage = <<EOF;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwUsage: $prog [options] <xml-input-file>
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwOptions:
0ad2061eab39cb8631cb8f2e91ce483699f50425gww -d Enable debug output
0ad2061eab39cb8631cb8f2e91ce483699f50425gww -e pfx Internal event prefix (default: AUE)
0ad2061eab39cb8631cb8f2e91ce483699f50425gww -i pfx Interface prefix (default: adt)
0ad2061eab39cb8631cb8f2e91ce483699f50425gww External event prefix is uppercase version of this string.
0ad2061eab39cb8631cb8f2e91ce483699f50425gww -o dir Output directory (default: current dir)
0ad2061eab39cb8631cb8f2e91ce483699f50425gww
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwEOF
0ad2061eab39cb8631cb8f2e91ce483699f50425gww
c0c79a3f09914f35651895ffc111883455b7f62dtzuse auditxml;
c0c79a3f09914f35651895ffc111883455b7f62dtzuse Getopt::Std;
c0c79a3f09914f35651895ffc111883455b7f62dtzuse strict;
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
0ad2061eab39cb8631cb8f2e91ce483699f50425gww# Process command-line options
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwour ($opt_d, $opt_e, $opt_i, $opt_o);
81d662ee1fa70e2f91e1d6fa52d3621146c10d61Richard PALO$opt_e = "";
81d662ee1fa70e2f91e1d6fa52d3621146c10d61Richard PALO$opt_i = "";
81d662ee1fa70e2f91e1d6fa52d3621146c10d61Richard PALO$opt_o = "";
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwif (!getopts('de:i:o:') || $#ARGV != 0) {
0ad2061eab39cb8631cb8f2e91ce483699f50425gww die $usage;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww}
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwmy $outdir = $opt_o || ".";
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwmy $pfx_adt = lc($opt_i) || "adt";
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwmy $pfx_ADT = uc($pfx_adt);
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwmy $pfx_AUE = uc($opt_e) || "AUE";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz$appDebug = $opt_d;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $uniLabel = "adr";
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $xlateUniLabelInc = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz# where everything comes from and where it goes:
c0c79a3f09914f35651895ffc111883455b7f62dtz
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwmy $xlateFile = "$outdir/${pfx_adt}_xlate.c";
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwmy $headerFile = "$outdir/${pfx_adt}_event_N.h";
c0c79a3f09914f35651895ffc111883455b7f62dtz
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwmy $filename = $ARGV[0]; # input XML file
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwmy $doc = new auditxml ($filename);
0ad2061eab39cb8631cb8f2e91ce483699f50425gww$filename =~ s|.*/||g;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz$debug = $appDebug;
c0c79a3f09914f35651895ffc111883455b7f62dtz
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwmy $genNotice = "
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwDO NOT EDIT. This file is auto generated by the Solaris Audit
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwsystem from $filename.
0ad2061eab39cb8631cb8f2e91ce483699f50425gww
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwSee http://opensolaris.org/os/project/audit/
0ad2061eab39cb8631cb8f2e91ce483699f50425gww";
0ad2061eab39cb8631cb8f2e91ce483699f50425gww
0ad2061eab39cb8631cb8f2e91ce483699f50425gww# trim leading/trailing newlines
0ad2061eab39cb8631cb8f2e91ce483699f50425gww$genNotice =~ s/^\n//s;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww$genNotice =~ s/\n$//s;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww
c0c79a3f09914f35651895ffc111883455b7f62dtzmy %xlateEventTable = ();
c0c79a3f09914f35651895ffc111883455b7f62dtzmy @xlateTypeList = ();
c0c79a3f09914f35651895ffc111883455b7f62dtzmy %xlateTypeList = ();
c0c79a3f09914f35651895ffc111883455b7f62dtzmy %eventAPI = ();
c0c79a3f09914f35651895ffc111883455b7f62dtzmy %eventExtra = ();
c0c79a3f09914f35651895ffc111883455b7f62dtzmy %headers = ();
c0c79a3f09914f35651895ffc111883455b7f62dtzmy %externalIdNo = ();
c0c79a3f09914f35651895ffc111883455b7f62dtzmy @outputState = ();
c0c79a3f09914f35651895ffc111883455b7f62dtzmy %nameTranslation = ();
c0c79a3f09914f35651895ffc111883455b7f62dtzmy @xlateDefaults = ();
c0c79a3f09914f35651895ffc111883455b7f62dtzmy %xlateDefault = ();
c0c79a3f09914f35651895ffc111883455b7f62dtzmy %msg_list = ();
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $event;
c0c79a3f09914f35651895ffc111883455b7f62dtzwhile ($event = $doc->getNextEvent()) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $eventId = $event->getId();
c0c79a3f09914f35651895ffc111883455b7f62dtz my $eventHeader = $event->getHeader();
c0c79a3f09914f35651895ffc111883455b7f62dtz my $idNo = $event->getIdNo();
c0c79a3f09914f35651895ffc111883455b7f62dtz $externalIdNo{$eventId} = $idNo;
c0c79a3f09914f35651895ffc111883455b7f62dtz addHeader($eventHeader) if defined ($eventHeader);
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 # header file for API use
c0c79a3f09914f35651895ffc111883455b7f62dtz generateAPIFile($event, $eventId, $eventType, $eventHeader, $idNo)
c0c79a3f09914f35651895ffc111883455b7f62dtz unless $omit eq 'always';
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz # c file table for translation
c0c79a3f09914f35651895ffc111883455b7f62dtz generateTableC($event, $eventId, $eventType, $eventHeader, $omit);
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzmy $textList;
c0c79a3f09914f35651895ffc111883455b7f62dtzwhile ($textList = $doc->getNextMsgId()) {
c0c79a3f09914f35651895ffc111883455b7f62dtz generateMsgLists($textList); # enum -> text mappings
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzprintTableC($xlateFile);
c0c79a3f09914f35651895ffc111883455b7f62dtzprintAPIFile($headerFile, $doc);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzexit 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzsub printTableC {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $file = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz unless (open(Cfile, ">$file")) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "can't open output file ($file): $!\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz return;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
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 <bsm/libbsm.h>
c0c79a3f09914f35651895ffc111883455b7f62dtz#include <adt_xlate.h>
c0c79a3f09914f35651895ffc111883455b7f62dtz#include <libintl.h>
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "#ifndef _PRAUDIT\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "/* Internal data type definitions */\n\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz my $extDef;
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach $extDef (@xlateTypeList) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "static $extDef\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz @xlateTypeList = ();
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "\n/* External event structure to internal event structure */\n\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my @pointers = ();
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach my $eventId (sort keys %xlateEventTable) {
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($xlateEventTable{$eventId}) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($ref1, $eventType, $firstToken, $eventHeader) =
c0c79a3f09914f35651895ffc111883455b7f62dtz @{$xlateEventTable{$eventId}};
c0c79a3f09914f35651895ffc111883455b7f62dtz my @entries = @$ref1;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $entry;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $entries = $#entries;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $count = $entries + 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $externalName = $nameTranslation{$eventId};
c0c79a3f09914f35651895ffc111883455b7f62dtz my $externalRoot = $externalName;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $externalRoot =~ s/${pfx_AUE}_//;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $structName = "XX_$externalRoot";
c0c79a3f09914f35651895ffc111883455b7f62dtz my $root = $eventId;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $root =~ s/${pfx_AUE}_//;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $externalId = $eventId;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $externalId =~ s/${pfx_AUE}_/${pfx_ADT}_/;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz unless ($eventType eq 'generic') {
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "static struct entry $structName\[$count\] = {\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach $entry (@entries) {
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($entries--) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $entry =~ s/EOL/,/;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz else {
c0c79a3f09914f35651895ffc111883455b7f62dtz $entry =~ s/EOL//;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $entry =~ s/selfReference/$structName/;
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "\t$entry\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "};\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "static struct translation X_$externalRoot = {\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@pointers, "X_$externalRoot");
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "\t0,\n"; # tx_offsetsCalculated = 0
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "\t$externalId,\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "\t$externalName,\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "\t$count,\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "\t&XX_$externalRoot\[$firstToken\],\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "\t&XX_$externalRoot\[0\]\n};\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "expected entry for $eventId but none found\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $count = $#pointers + 2;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww print Cfile "adt_translation_t *${pfx_adt}_xlate_table[$count] = {\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $firstEvent = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach my $eventId (@pointers) {
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($firstEvent) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $firstEvent = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz else {
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile ",\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "\t&$eventId";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile ",\n\tNULL\n};\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz
0ad2061eab39cb8631cb8f2e91ce483699f50425gww # generate the Event preload() function
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzvoid
0ad2061eab39cb8631cb8f2e91ce483699f50425gww${pfx_adt}_preload(au_event_t event_id, adt_event_data_t *event_data)
c0c79a3f09914f35651895ffc111883455b7f62dtz{
c0c79a3f09914f35651895ffc111883455b7f62dtz switch (event_id) {
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach my $id (@xlateDefaults) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $adtID = $id;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $adtID =~ s/${pfx_AUE}/${pfx_ADT}/;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz case $adtID:
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz my @preloads = @{$xlateDefault{$id}};
c0c79a3f09914f35651895ffc111883455b7f62dtz while (@preloads) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $fieldName = shift @preloads;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $default = shift @preloads;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $id =~ s/${pfx_AUE}_/${pfx_adt}_/;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile <<EOF;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww event_data->$id.$fieldName = $default;
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz break;
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz default:
c0c79a3f09914f35651895ffc111883455b7f62dtz break;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtz#endif
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
0ad2061eab39cb8631cb8f2e91ce483699f50425gww
0ad2061eab39cb8631cb8f2e91ce483699f50425gww print Cfile "/* message lists */\n\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz my $listName;
c0c79a3f09914f35651895ffc111883455b7f62dtz my @listName;
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach $listName (sort keys %msg_list) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($listRef, $headref) = @{$msg_list{$listName}};
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($header, $start, $public, $deprecated) = @$headref;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my @listValue = @$listRef;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $listValue;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $listLength = $#listValue + 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz $listName = 'NULL' if ($#listValue < 0);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@listName, [$listName, $listLength - 1, $start, $public]);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz next if ($#listValue < 0);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "/* Deprecated message list */\n" if ($deprecated);
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "static char *msg_$listName\[$listLength] = {\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $ffirst = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach $listValue (@listValue) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile ",\n" unless $ffirst;
c0c79a3f09914f35651895ffc111883455b7f62dtz $ffirst = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($id, $text) = split(/\s*::\s*/, $listValue);
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($text) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "\t\"$text\"";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz else {
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "\tNULL";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz print Cfile "\n};\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
0ad2061eab39cb8631cb8f2e91ce483699f50425gww
0ad2061eab39cb8631cb8f2e91ce483699f50425gww if ($#listName >= 0) {
0ad2061eab39cb8631cb8f2e91ce483699f50425gww print Cfile "\nstruct msg_text ${pfx_adt}_msg_text[", $#listName + 1,
0ad2061eab39cb8631cb8f2e91ce483699f50425gww "] = {\n";
0ad2061eab39cb8631cb8f2e91ce483699f50425gww my $ffirst = 1;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww foreach $listName (@listName) {
0ad2061eab39cb8631cb8f2e91ce483699f50425gww my ($name, $max, $start) = @$listName;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $start = -$start if $start;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww print Cfile ",\n" unless $ffirst;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $ffirst = 0;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $name = "msg_$name" if ($name ne 'NULL');
0ad2061eab39cb8631cb8f2e91ce483699f50425gww print Cfile "\t{0, $max, $name, $start}";
0ad2061eab39cb8631cb8f2e91ce483699f50425gww }
0ad2061eab39cb8631cb8f2e91ce483699f50425gww print Cfile "\n};\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz close Cfile;
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzsub printAPIFile {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $file = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $xmlDoc = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my @Hfile;
c0c79a3f09914f35651895ffc111883455b7f62dtz @Hfile = openHeaderFiles($file);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $notice = $genNotice;
c0c79a3f09914f35651895ffc111883455b7f62dtz $notice =~ s/\n/\n * /gs;
c0c79a3f09914f35651895ffc111883455b7f62dtz $notice =~ s/\s+\n/\n/gs;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach my $header (keys %headers) {
c0c79a3f09914f35651895ffc111883455b7f62dtz next unless $Hfile[$header];
c0c79a3f09914f35651895ffc111883455b7f62dtz *Hfile = $Hfile[$header];
c0c79a3f09914f35651895ffc111883455b7f62dtz my $include = "adt.h";
0ad2061eab39cb8631cb8f2e91ce483699f50425gww my $adt_event_n = "_${pfx_ADT}_EVENT_H";
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($header > 0) {
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $include = "${pfx_adt}_event.h";
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $adt_event_n = "_${pfx_ADT}_EVENT_".$header."_H";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz print Hfile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz/*
c0c79a3f09914f35651895ffc111883455b7f62dtz * $notice
c0c79a3f09914f35651895ffc111883455b7f62dtz */
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz#ifndef $adt_event_n
c0c79a3f09914f35651895ffc111883455b7f62dtz#define $adt_event_n
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz#include <bsm/$include>
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz#ifdef __cplusplus
c0c79a3f09914f35651895ffc111883455b7f62dtzextern "C" {
c0c79a3f09914f35651895ffc111883455b7f62dtz#endif
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz/*
c0c79a3f09914f35651895ffc111883455b7f62dtz * adt_put_event() status values. Positive values are for kernel-generated
c0c79a3f09914f35651895ffc111883455b7f62dtz * failure, -1 for user-space. For ADT_SUCCESS, the adt_put_event() return_val
c0c79a3f09914f35651895ffc111883455b7f62dtz * is not used; the convention is to set it to ADT_SUCCESS.
c0c79a3f09914f35651895ffc111883455b7f62dtz */
c0c79a3f09914f35651895ffc111883455b7f62dtz#define ADT_SUCCESS 0
c0c79a3f09914f35651895ffc111883455b7f62dtz#define ADT_FAILURE -1
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach my $listName (sort keys %msg_list) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $shortName = uc $listName;
c0c79a3f09914f35651895ffc111883455b7f62dtz $shortName =~ s/_TEXT//;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($listRef, $headref) = @{$msg_list{$listName}};
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($header, $start, $public, $deprecated) = @$headref;
c0c79a3f09914f35651895ffc111883455b7f62dtz next unless $Hfile[$header];
c0c79a3f09914f35651895ffc111883455b7f62dtz *Hfile = $Hfile[$header];
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print Hfile "/* Deprecated message list */\n" if $deprecated;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww print Hfile "#define\t${pfx_ADT}_$shortName\t$start\n" if $start;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my @listValue = @$listRef;
c0c79a3f09914f35651895ffc111883455b7f62dtz next unless ($#listValue >= 0);
0ad2061eab39cb8631cb8f2e91ce483699f50425gww print Hfile "enum\t${pfx_adt}_$listName", " {\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $listValue;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $i = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $j = $#listValue;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $comma = ',';
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach $listValue (@listValue) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($id, $text) = split(/\s*::\s*/, $listValue);
c0c79a3f09914f35651895ffc111883455b7f62dtz $comma = '' if $i++ == $j;
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($start) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $start = " = $start$comma";
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz $start = "$comma\t";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $text = "(no token will be generated)" unless $text;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww my $line = "\t${pfx_ADT}_$shortName"."_$id$start\t/* ";
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz # ensure whole line does not exceed 80 chars
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz my $eline = $line.$text;
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz #expand tabs
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz 1 while $eline =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e;
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz if ((length($eline) > 77) && ($line =~ /\t\t/)) {
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz # 77 = 80 - length(" */")
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz # strip off double tab so that comment can be longer
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz $line =~ s/\t\t/\t/;
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz # shorten eline; don't mind where the spaces are removed, it is
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz # only $eline length which matters
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz $eline =~ s/ {8}//;
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz }
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz if (length($eline) > 77) { # 80 - length(" */")
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz # here we use negative length in substr to leave off from the
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz # right side; 74 = 77 - length("...")
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz $line .= substr($text, 0, 74 - length($eline));
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz # strip off part of last word (already cut)
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz $line =~ s/\s(\S+)$/ /;
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz $line .= "...";
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz } else {
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz $line .= $text;
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz }
6a3b10db10504576d94f22ea0d7aaf12b96b0bbetz print Hfile "$line */\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz $start = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz print Hfile "};\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
0ad2061eab39cb8631cb8f2e91ce483699f50425gww # generate defines for external event names
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach my $eventId (sort keys %eventAPI) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($header, $idNo) = @{$eventExtra{$eventId}};
c0c79a3f09914f35651895ffc111883455b7f62dtz unless (defined ($header)) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "missing header selection for $eventId\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz next;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz *Hfile = $Hfile[$header];
c0c79a3f09914f35651895ffc111883455b7f62dtz next unless $Hfile[$header];
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $l = length($eventId) + 8; # label plus preceding #define\t
c0c79a3f09914f35651895ffc111883455b7f62dtz $l = 5 - int(($l + 8)/8);
c0c79a3f09914f35651895ffc111883455b7f62dtz $l = 1 if $l < 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $tab = "\t" x $l;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "missing id number for $eventId\n" unless $idNo;
c0c79a3f09914f35651895ffc111883455b7f62dtz
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $eventId =~ s/${pfx_AUE}_/${pfx_ADT}_/;
c0c79a3f09914f35651895ffc111883455b7f62dtz print Hfile "#define\t$eventId$tab$idNo\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz # generate per-event structures
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach my $eventId (sort keys %eventAPI) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($header, $idNo) = @{$eventExtra{$eventId}};
c0c79a3f09914f35651895ffc111883455b7f62dtz my $dataId = $eventId;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $dataId =~ s/^${pfx_AUE}_/${pfx_adt}_/;
c0c79a3f09914f35651895ffc111883455b7f62dtz unless(defined ($header)) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "$eventId is missing the header assignment\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz next;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz *Hfile = $Hfile[$header];
c0c79a3f09914f35651895ffc111883455b7f62dtz next unless $Hfile[$header];
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $externalId = $eventId;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $externalId =~ s/${pfx_AUE}_/${pfx_ADT}_/;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print Hfile "\nstruct $dataId {\t/* $externalId */\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my @entries = @{$eventAPI{$eventId}};
c0c79a3f09914f35651895ffc111883455b7f62dtz my $entry;
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($#entries < 0) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print Hfile "\tint\tdummy;\t/* not used */\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach $entry (@entries) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $entry =~ s/termid/adt_termid_t/;
c0c79a3f09914f35651895ffc111883455b7f62dtz print Hfile "\t$entry\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz print Hfile "};\n";
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $eventId =~ s/^${pfx_AUE}_/${pfx_adt}_/;
c0c79a3f09914f35651895ffc111883455b7f62dtz print Hfile "typedef struct $dataId $eventId","_t;\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach my $header (sort keys %headers) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $outputState[$header] = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach my $eventId (sort keys %eventAPI) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($header, $idNo) = @{$eventExtra{$eventId}};
c0c79a3f09914f35651895ffc111883455b7f62dtz unless(defined ($header)) {
c0c79a3f09914f35651895ffc111883455b7f62dtz # don't print duplicate error message
c0c79a3f09914f35651895ffc111883455b7f62dtz next;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz *Hfile = $Hfile[$header];
c0c79a3f09914f35651895ffc111883455b7f62dtz next unless $Hfile[$header];
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($outputState[$header] == 0) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $outputState[$header] = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $suffix = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz $suffix = "_$header" if $header;
c0c79a3f09914f35651895ffc111883455b7f62dtz print Hfile "\nunion adt_event_data$suffix {\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz my $elementName = $eventId;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $elementName =~ s/^${pfx_AUE}_/${pfx_adt}_/;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $eventId =~ s/^${pfx_AUE}_/${pfx_adt}_/;
c0c79a3f09914f35651895ffc111883455b7f62dtz $elementName =~ s/_t$//;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz print Hfile "\t\t$eventId","_t\t$elementName;\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach my $header (sort keys %headers) {
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($outputState[$header]) {
c0c79a3f09914f35651895ffc111883455b7f62dtz *Hfile = $Hfile[$header];
c0c79a3f09914f35651895ffc111883455b7f62dtz next unless $Hfile[$header];
c0c79a3f09914f35651895ffc111883455b7f62dtz print Hfile "};\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach my $header (keys %headers) {
c0c79a3f09914f35651895ffc111883455b7f62dtz next unless $Hfile[$header];
c0c79a3f09914f35651895ffc111883455b7f62dtz *Hfile = $Hfile[$header];
0ad2061eab39cb8631cb8f2e91ce483699f50425gww my $adt_event_n = "_${pfx_ADT}_EVENT_H";
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($header > 0) {
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $adt_event_n = "_${pfx_ADT}_EVENT_".$header."_H";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz print Hfile <<EOF;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz
0ad2061eab39cb8631cb8f2e91ce483699f50425gww#ifndef ${pfx_ADT}_PRIVATE
0ad2061eab39cb8631cb8f2e91ce483699f50425gww#define ${pfx_ADT}_PRIVATE
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz/*
c0c79a3f09914f35651895ffc111883455b7f62dtz * These interfaces are project private and will change without
0ad2061eab39cb8631cb8f2e91ce483699f50425gww * notice as needed for the Solaris Audit project.
c0c79a3f09914f35651895ffc111883455b7f62dtz */
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzextern void adt_get_auid(const adt_session_data_t *, au_id_t *);
c0c79a3f09914f35651895ffc111883455b7f62dtzextern void adt_set_auid(const adt_session_data_t *, const au_id_t);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzextern void adt_get_mask(const adt_session_data_t *, au_mask_t *);
c0c79a3f09914f35651895ffc111883455b7f62dtzextern void adt_set_mask(const adt_session_data_t *, const au_mask_t *);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzextern void adt_get_termid(const adt_session_data_t *, au_tid_addr_t *);
c0c79a3f09914f35651895ffc111883455b7f62dtzextern void adt_set_termid(const adt_session_data_t *,
c0c79a3f09914f35651895ffc111883455b7f62dtz const au_tid_addr_t *);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzextern void adt_get_asid(const adt_session_data_t *, au_asid_t *);
c0c79a3f09914f35651895ffc111883455b7f62dtzextern void adt_set_asid(const adt_session_data_t *, const au_asid_t);
85e8d33eda72d79b047f9f6d1d38e71c94352fdbgwwextern au_asid_t adt_get_unique_id(au_id_t);
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwextern void adt_load_table(const adt_session_data_t *, adt_translation_t **,
0ad2061eab39cb8631cb8f2e91ce483699f50425gww void (*preload)(au_event_t, adt_event_data_t *));
0ad2061eab39cb8631cb8f2e91ce483699f50425gww
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwextern void ${pfx_adt}_preload(au_event_t, adt_event_data_t *);
0ad2061eab39cb8631cb8f2e91ce483699f50425gww
0ad2061eab39cb8631cb8f2e91ce483699f50425gwwextern adt_translation_t *${pfx_adt}_xlate_table[];
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz#endif
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz#ifdef __cplusplus
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtz#endif
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz#endif /* $adt_event_n */
c0c79a3f09914f35651895ffc111883455b7f62dtzEOF
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz closeHeaderFiles(@Hfile);
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 = (
f72effdea24d97a107b04e4b041cf5081dae0ee9gww #
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # tokenTypes are the ones that are actually defined
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # for use in adt.xml audit records
f72effdea24d97a107b04e4b041cf5081dae0ee9gww #
f72effdea24d97a107b04e4b041cf5081dae0ee9gww
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'acl' => 'AUT_ACL', # not defined
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'arbitrary' => 'AUT_ARBITRARY', # not defined
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'arg' => 'AUT_ARG', # not defined
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'attr' => 'AUT_ATTR',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'command' => 'AUT_CMD',
3cccda98b87857542deb064ace0cec9c785dbeb9Jan Friedel 'command_alt' => 'ADT_CMD_ALT', # dummy token id
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'date' => 'AUT_TEXT', # not used
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'exec_args' => 'AUT_EXEC_ARGS', # not defined
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'exec_env' => 'AUT_EXEC_ENV', # not defined
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'exit' => 'AUT_EXIT', # not defined
c0c79a3f09914f35651895ffc111883455b7f62dtz 'fmri' => 'AUT_FMRI',
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'groups' => 'AUT_GROUPS', # not defined
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'header' => 'AUT_HEADER', # not defined
f72effdea24d97a107b04e4b041cf5081dae0ee9gww 'in_peer' => 'ADT_IN_PEER', # dummy token id
11bc41c8d344c50e04ea4015552fe4efbf0cdfc4gww 'in_remote' => 'ADT_IN_REMOTE', # dummy token id
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'ipc' => 'AUT_IPC', # not defined
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'ipc_perm' => 'AUT_IPC_PERM', # not defined
11bc41c8d344c50e04ea4015552fe4efbf0cdfc4gww 'iport' => 'AUT_IPORT',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'label' => 'AUT_LABEL',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'newgroups' => 'AUT_NEWGROUPS',
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'opaque' => 'AUT_OPAQUE', # not defined
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',
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe 'secflags' => 'AUT_SECFLAGS',
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'seq' => 'AUT_SEQ', # not defined
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'socket' => 'AUT_SOCKET', # not defined
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'socket-inet' => 'AUT_SOCKET_INET',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'subject' => 'AUT_SUBJECT',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'text' => 'AUT_TEXT',
047f6e6f42a3d50d3e38a05c00bf7dd3fafac726gww 'tid' => 'AUT_TID',
f72effdea24d97a107b04e4b041cf5081dae0ee9gww # 'trailer' => 'AUT_TRAILER', # not defined
c0c79a3f09914f35651895ffc111883455b7f62dtz 'uauth' => 'AUT_UAUTH',
047f6e6f42a3d50d3e38a05c00bf7dd3fafac726gww 'user' => 'AUT_USER',
c0c79a3f09914f35651895ffc111883455b7f62dtz 'zonename' => 'AUT_ZONENAME'
c0c79a3f09914f35651895ffc111883455b7f62dtz );
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my @xlateEntryList = ();
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 if ($eventType) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $nameTranslation{$eventId} = $eventId;
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz $nameTranslation{$eventId} = $external->getInternalName();
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) =
5114d1ad03211a84d5722382609b1c7f8552e216gww formatTableEntry ('', $tokenId, $eventId, '', 0, 0,
81d662ee1fa70e2f91e1d6fa52d3621146c10d61Richard PALO $tokenOrder[$sequence], 'NULL', '', $omit);
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@xlateEntryList, $xlate);
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;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $enumGroup = "${pfx_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,
5114d1ad03211a84d5722382609b1c7f8552e216gww $enumGroup, $omit);
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@xlateEntryList, $xlate);
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $sequence++;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateEventTable{$eventId} = [\@xlateEntryList, $eventType, $firstTokenIndex,
c0c79a3f09914f35651895ffc111883455b7f62dtz $eventHeader];
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzsub formatTableEntry {
5114d1ad03211a84d5722382609b1c7f8552e216gww my ($id, $token, $eventId, $type, $required, $tsol, $sequence, $format,
5114d1ad03211a84d5722382609b1c7f8552e216gww $enumGroup, $omitEntry) = @_;
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', ''],
69987563713261563f769bf902be7fd10691efc4sabdar 'fd_t' => ['ADT_FD', '-1'],
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]);
5114d1ad03211a84d5722382609b1c7f8552e216gww } elsif (uc $omitEntry eq 'JNI') {
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLabelRef = 'NULL';
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "$type is not an implemented data type\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLabelRef = 'NULL';
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($xlateLine && !($xlateTypeList{$xlateLine})) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateTypeList{$xlateLine} = $xlateLabel;
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@xlateTypeList, "datadef\t$xlateLabel\[1\] =\t$xlateLine;");
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLabelInc = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLabel = $xlateTypeList{$xlateLine};
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
5114d1ad03211a84d5722382609b1c7f8552e216gww if (uc $omitEntry ne 'ALWAYS' && ${$entryDef{$type}}[1]) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my @list = ();
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($xlateDefault{$eventId}) {
c0c79a3f09914f35651895ffc111883455b7f62dtz @list = @{$xlateDefault{$eventId}};
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@xlateDefaults, $eventId);
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@list, $id, ${$entryDef{$type}}[1]);
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateDefault{$eventId} = \@list;
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]);
5114d1ad03211a84d5722382609b1c7f8552e216gww } elsif (uc $omitEntry eq 'JNI') {
c0c79a3f09914f35651895ffc111883455b7f62dtz # nothing to do.
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "$dtype is not an implemented data type\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
5114d1ad03211a84d5722382609b1c7f8552e216gww if (uc $omitEntry ne 'ALWAYS' && ${$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 unless ($xlateTypeList{$xlateArray}) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateTypeList{$xlateArray} = $xlateLabel;
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateArray = "datadef\t$xlateLabel" . $xlateArray;
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@xlateTypeList, $xlateArray);
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLabelInc = 1;
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLabel = $xlateTypeList{$xlateArray};
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateLine =
c0c79a3f09914f35651895ffc111883455b7f62dtz "{$token,\t$typeCount,\t&$xlateLabel\[0\],\t$sequence,\n" .
c0c79a3f09914f35651895ffc111883455b7f62dtz "\t\t0,\t$required,\t$tsol,\t$format}EOL";
c0c79a3f09914f35651895ffc111883455b7f62dtz if (@default) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my @list = ();
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($xlateDefault{$eventId}) {
c0c79a3f09914f35651895ffc111883455b7f62dtz @list = @{$xlateDefault{$eventId}};
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@xlateDefaults, $eventId);
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@list, @default);
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateDefault{$eventId} = \@list;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $xlateUniLabelInc++ if $xlateLabelInc;
c0c79a3f09914f35651895ffc111883455b7f62dtz return ($xlateLine, \@jniLine);
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzsub generateAPIFile {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $event = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $eventId = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $eventType = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $eventHeader = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $idNo = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my @entryList = ();
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $external = $event->getExternal();
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($eventType && $debug) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "event $eventId is of type $eventType\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz return unless $external;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($extEntry, $entry, $tokenId, $format);
c0c79a3f09914f35651895ffc111883455b7f62dtz while (($extEntry, $entry, $tokenId, $format) = $external->getNextEntry()) {
c0c79a3f09914f35651895ffc111883455b7f62dtz last unless $entry;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $entryId = $entry->getAttr('id');
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz unless (defined $entryId) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "undefined entry id for external $eventId\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz next;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz my $option = $extEntry->getAttr('opt');
c0c79a3f09914f35651895ffc111883455b7f62dtz next if ($option eq 'none');
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined (my $token = $doc->getToken($tokenId))) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $option = 'Trusted Solaris only'
c0c79a3f09914f35651895ffc111883455b7f62dtz if (lc $token->getUsage() eq 'tsol') ? 1 : 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $option .= " (format: $format)" if $format;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $dataType = $extEntry->getAttr('type');
c0c79a3f09914f35651895ffc111883455b7f62dtz unless (defined $dataType) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "no type defined for external tag for $eventId\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz $dataType = "error";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $comment = $entry->getContent();
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz if (($dataType =~ /,/) || ($entryId =~ /,/)) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my @type = split(/\s*,\s*/, $dataType);
c0c79a3f09914f35651895ffc111883455b7f62dtz my @id = split(/\s*,\s*/, $entryId);
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($#type != $#id) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR
c0c79a3f09914f35651895ffc111883455b7f62dtz "number of data types ($dataType) does not match number of ids ($entryId)",
c0c79a3f09914f35651895ffc111883455b7f62dtz " for event $eventId\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($#type < $#id) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $#id = $#type;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz else {
c0c79a3f09914f35651895ffc111883455b7f62dtz $#type = $#id;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $i;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $line = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz $line = "/* $comment */\n\t" if defined $comment;
c0c79a3f09914f35651895ffc111883455b7f62dtz for ($i = 0; $i <= $#type; $i++) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($primitive, $dereference) =
c0c79a3f09914f35651895ffc111883455b7f62dtz ($type[$i] =~ /([^\*]+)\s*(\**)/);
c0c79a3f09914f35651895ffc111883455b7f62dtz $id[$i] .= $1 if ($primitive =~ s/(\[\d+\])//);
c0c79a3f09914f35651895ffc111883455b7f62dtz $line .= "$primitive\t$dereference$id[$i];\t/* $option */";
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@entryList, $line);
c0c79a3f09914f35651895ffc111883455b7f62dtz $line = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz else {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $line = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz $line = "/* $comment */\n\t" if defined $comment;
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($dataType =~ /^msg/i) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $dataType =~ s/^msg\s*//i;
0ad2061eab39cb8631cb8f2e91ce483699f50425gww $line .= "enum ${pfx_adt}_$dataType" . "\t$entryId;\t/* $option */";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz elsif ($dataType =~ /time_t/i) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $line .= "time_t\t$entryId;\t/* $option */";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz else {
c0c79a3f09914f35651895ffc111883455b7f62dtz my ($primitive, $dereference) =
c0c79a3f09914f35651895ffc111883455b7f62dtz ($dataType =~ /([^\*]+)\s*(\**)/);
c0c79a3f09914f35651895ffc111883455b7f62dtz $entryId .= $1 if ($primitive =~ s/(\[\d+\])//);
c0c79a3f09914f35651895ffc111883455b7f62dtz $line .= "$primitive\t$dereference$entryId;\t/* $option */";
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz push (@entryList, $line);
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz $eventExtra{$eventId} = [$eventHeader, $idNo];
c0c79a3f09914f35651895ffc111883455b7f62dtz $eventAPI{$eventId} = \@entryList;
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 addHeader($header);
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}
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzsub addHeader {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $header_index = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz die "invalid adt_event_N.h index: $header_index\n"
c0c79a3f09914f35651895ffc111883455b7f62dtz unless ($header_index =~ /^\d+$/);
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz $headers{$header_index} = $header_index;
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz# $header = 0 is a special case; it is for adt_event.h
c0c79a3f09914f35651895ffc111883455b7f62dtz# $header > 0 creates adt_event_N.h, where N = $header
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzsub openHeaderFiles {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $outfile = shift; # path to an adt_event_N.h file
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $header;
c0c79a3f09914f35651895ffc111883455b7f62dtz my @Hfile = (); # potentially sparse array of file handles
c0c79a3f09914f35651895ffc111883455b7f62dtz my @HfileName = (); # parallel array to Hfile, file name (not path)
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach $header (sort keys %headers) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $file = $outfile;
c0c79a3f09914f35651895ffc111883455b7f62dtz if ($header > 0) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $file =~ s/_N/_$header/;
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz $file =~ s/_N//;
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz unless (open($Hfile[$header], ">$file")) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "can't open output ($file): $!\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz $HfileName[$header] = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz $Hfile[$header] = '';
c0c79a3f09914f35651895ffc111883455b7f62dtz } else {
c0c79a3f09914f35651895ffc111883455b7f62dtz my @tmp = split(/\//, $file);
c0c79a3f09914f35651895ffc111883455b7f62dtz $HfileName[$header] = $tmp[$#tmp];
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz return (@Hfile);
c0c79a3f09914f35651895ffc111883455b7f62dtz}
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtzsub closeHeaderFiles {
c0c79a3f09914f35651895ffc111883455b7f62dtz my @Hfile = @_;
c0c79a3f09914f35651895ffc111883455b7f62dtz
c0c79a3f09914f35651895ffc111883455b7f62dtz my $header;
c0c79a3f09914f35651895ffc111883455b7f62dtz foreach $header (sort keys %headers) {
c0c79a3f09914f35651895ffc111883455b7f62dtz close $Hfile[$header] if $Hfile[$header];
c0c79a3f09914f35651895ffc111883455b7f62dtz }
c0c79a3f09914f35651895ffc111883455b7f62dtz}