Print this page
5516 perl problems in libbsm/auditxml
Reviewed by: Richard Lowe <richlowe@richlowe.net>


  36         -e pfx  Internal event prefix (default: AUE)
  37         -i pfx  Interface prefix (default: adt)
  38                 External event prefix is uppercase version of this string.
  39         -o dir  Output directory (default: current dir)
  40 
  41 EOF
  42 
  43 use auditxml;
  44 use Getopt::Std;
  45 use strict;
  46 
  47 our $debug = 0; # normal use is to set via the file being parsed.
  48                # <debug set="on"/> or <debug set="off"/> or <debug/>
  49                # if the set attribute is omitted, debug state is toggled
  50                # Override with appDebug, but toggle won't do what you
  51                # want.
  52 my $appDebug = 0; # used after return from "new auditxml";
  53 
  54 # Process command-line options
  55 our ($opt_d, $opt_e, $opt_i, $opt_o);



  56 if (!getopts('de:i:o:') || $#ARGV != 0) {
  57     die $usage;
  58 }
  59 my $outdir = $opt_o || ".";
  60 my $pfx_adt = lc($opt_i) || "adt";
  61 my $pfx_ADT = uc($pfx_adt);
  62 my $pfx_AUE = uc($opt_e) || "AUE";
  63 
  64 $appDebug = $opt_d;
  65 
  66 my $uniLabel = "adr";
  67 my $xlateUniLabelInc = 0;
  68 
  69 
  70 # where everything comes from and where it goes:
  71 
  72 my $xlateFile = "$outdir/${pfx_adt}_xlate.c";
  73 my $headerFile = "$outdir/${pfx_adt}_event_N.h";
  74 
  75 my $filename = $ARGV[0];  # input XML file


 690 
 691       my ($extEntry, $unusedEntry, $tokenId) =
 692         $external->getEntry($entryId);
 693       my $opt = $extEntry->getAttr('opt');
 694 
 695       if ($opt eq 'none') {
 696         if (defined ($doc->getToken($tokenId))) {
 697           if (defined ($tokenType{$tokenId})) {
 698             $tokenId = $tokenType{$tokenId};
 699           }
 700           else {
 701             print STDERR "token id $tokenId not implemented\n";
 702           }
 703         }
 704         else {
 705           print STDERR "token = $tokenId is undefined\n";
 706           $tokenId = 'error';
 707         }
 708         my ($xlate, $jni) =
 709           formatTableEntry ('', $tokenId, $eventId, '', 0, 0,
 710                             $tokenOrder[$sequence], 'NULL', $omit);
 711         push (@xlateEntryList, $xlate);
 712       }
 713       else {
 714         my $dataType = $extEntry->getAttr('type');
 715         $dataType =~ s/\s+//g;   # remove blanks (char * => char*)
 716 
 717         my $enumGroup = '';
 718         if ($dataType =~ /^msg/i) {
 719             $enumGroup = $dataType;
 720             $enumGroup =~ s/^msg\s*//i;
 721             $enumGroup = "${pfx_adt}_" . $enumGroup;
 722         }
 723         my $required = ($opt eq 'required') ? 1 : 0;
 724         my $tsol = 0;
 725         my $tokenId = $intEntry->getAttr('token');
 726         my $token;
 727         my $tokenName;
 728         my $tokenFormat = $intEntry->getAttr('format');
 729         if (defined ($tokenFormat)) {
 730           $tokenFormat = "\"$tokenFormat\"";




  36         -e pfx  Internal event prefix (default: AUE)
  37         -i pfx  Interface prefix (default: adt)
  38                 External event prefix is uppercase version of this string.
  39         -o dir  Output directory (default: current dir)
  40 
  41 EOF
  42 
  43 use auditxml;
  44 use Getopt::Std;
  45 use strict;
  46 
  47 our $debug = 0; # normal use is to set via the file being parsed.
  48                # <debug set="on"/> or <debug set="off"/> or <debug/>
  49                # if the set attribute is omitted, debug state is toggled
  50                # Override with appDebug, but toggle won't do what you
  51                # want.
  52 my $appDebug = 0; # used after return from "new auditxml";
  53 
  54 # Process command-line options
  55 our ($opt_d, $opt_e, $opt_i, $opt_o);
  56 $opt_e = "";
  57 $opt_i = "";
  58 $opt_o = "";
  59 if (!getopts('de:i:o:') || $#ARGV != 0) {
  60     die $usage;
  61 }
  62 my $outdir = $opt_o || ".";
  63 my $pfx_adt = lc($opt_i) || "adt";
  64 my $pfx_ADT = uc($pfx_adt);
  65 my $pfx_AUE = uc($opt_e) || "AUE";
  66 
  67 $appDebug = $opt_d;
  68 
  69 my $uniLabel = "adr";
  70 my $xlateUniLabelInc = 0;
  71 
  72 
  73 # where everything comes from and where it goes:
  74 
  75 my $xlateFile = "$outdir/${pfx_adt}_xlate.c";
  76 my $headerFile = "$outdir/${pfx_adt}_event_N.h";
  77 
  78 my $filename = $ARGV[0];  # input XML file


 693 
 694       my ($extEntry, $unusedEntry, $tokenId) =
 695         $external->getEntry($entryId);
 696       my $opt = $extEntry->getAttr('opt');
 697 
 698       if ($opt eq 'none') {
 699         if (defined ($doc->getToken($tokenId))) {
 700           if (defined ($tokenType{$tokenId})) {
 701             $tokenId = $tokenType{$tokenId};
 702           }
 703           else {
 704             print STDERR "token id $tokenId not implemented\n";
 705           }
 706         }
 707         else {
 708           print STDERR "token = $tokenId is undefined\n";
 709           $tokenId = 'error';
 710         }
 711         my ($xlate, $jni) =
 712           formatTableEntry ('', $tokenId, $eventId, '', 0, 0,
 713                             $tokenOrder[$sequence], 'NULL', '', $omit);
 714         push (@xlateEntryList, $xlate);
 715       }
 716       else {
 717         my $dataType = $extEntry->getAttr('type');
 718         $dataType =~ s/\s+//g;   # remove blanks (char * => char*)
 719 
 720         my $enumGroup = '';
 721         if ($dataType =~ /^msg/i) {
 722             $enumGroup = $dataType;
 723             $enumGroup =~ s/^msg\s*//i;
 724             $enumGroup = "${pfx_adt}_" . $enumGroup;
 725         }
 726         my $required = ($opt eq 'required') ? 1 : 0;
 727         my $tsol = 0;
 728         my $tokenId = $intEntry->getAttr('token');
 729         my $token;
 730         my $tokenName;
 731         my $tokenFormat = $intEntry->getAttr('format');
 732         if (defined ($tokenFormat)) {
 733           $tokenFormat = "\"$tokenFormat\"";