#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#
use xmlHandlers;
package externalEvent;
1;
sub new {
my $pkg = shift;
my $id = shift;
my $obj = shift;
# separate kids into classes and create hash of entries and an
# array of includes
my %entry = ();
my @entry = ();
my @allowed_types = ();
my @include = ();
my $internalName = '';
my $kid;
if ($class eq 'entry') {
my $tokenId = 'undefined';
my $format = '';
if (defined $internal) {
}
my $comment;
if (defined $commentKid) {
}
if (defined ($external)) {
}
else {
print STDERR "no external attributes defined for $id/$kidId\n";
}
} # handle event id translation...
elsif ($class eq 'altname') {
unless (defined $internalName) {
print STDERR "missing id for internal name of $id\n";
$internalName = 'error';
}
}
elsif ($class eq 'allowed_types') {
}
}
return bless {'id' => $id,
'internalName' => $internalName,
'allowed_types' => \@allowed_types,
'entry' => \%entry,
'entryList' => \@entry,
'entryListCopy' => \@entryCopy,
'include' => \@include,
}
# return id
sub getExternalName {
my $pkg = shift;
return $pkg->{'id'};
}
# return internal name if it exists, else id
sub getInternalName {
$pkg = shift;
if ($pkg->{'internalName'}) {
return $pkg->{'internalName'};
}
else {
return $pkg->{'id'};
}
}
# getNextEntry reads from 'entryList' destructively
# but resets when the list after the list is emptied
sub getNextEntry {
my $pkg = shift;
unless (@{$pkg->{'entryList'}}) {
return undef;
}
}
# getEntryIds returns list of all ids from entryList
sub getEntryIds {
my $pkg = shift;
return (@{$pkg->{'entryList'}});
}
# getEntry returns a selected entry for the current event
sub getEntry {
my $pkg = shift;
my $id = shift; #entry id
return @$array;
}
# getNextInclude reads from 'include' destructively
sub getNextInclude {
my $pkg = shift;
return shift @{$pkg->{'include'}};
}
# getIncludes returns list of 'include'
sub getIncludes {
my $pkg = shift;
return @{$pkg->{'include'}};
}
# return a reference to the list of event id's allowed for
# this generic event
sub getAllowedTypes {
my $pkg = shift;
return $pkg->{'allowed_types'};
}
package internalEvent;
1;
sub new {
my $pkg = shift;
my $id = shift;
my $obj = shift;
my @entry = ();
my $reorder = 0;
}
my $kid;
if ($class eq 'entry') {
if (defined ($internal)) {
}
else {
print STDERR "no internal attributes defined for $id\n";
}
}
}
return bless {'id' => $id,
'reorder' => $reorder,
'entry' => \@entry,
}
# getEntries returns a list of all entry references
sub getEntries {
my $pkg = shift;
return undef unless @{$pkg->{'entry'}};
return @{$pkg->{'entry'}};
}
sub isReorder {
my $pkg = shift;
return $pkg->{'reorder'};
}
sub getId {
my $pkg = shift;
return $pkg->{'id'};
}
package eventDef;
%uniqueId = ();
1;
sub new {
my $pkg = shift;
my $id = shift;
my $obj = shift;
my $super = shift;
my $omit;
my $type;
my $header;
my $idNo;
my $javaToo;
my $title = '';
my @program = ();
my @see = ();
my @note = ();
print STDERR "$uniqueId{$idNo} and $id have the same id ($idNo)\n";
}
else {
}
return bless {'id' => $id,
'header' => $header,
'idNo' => $idNo,
'omit' => $omit,
'super' => $super,
'type' => $type,
'title' => $title,
'program' => \@program,
'see' => \@see,
'note' => \@note,
'external' => 0,
}
# putDef is called at the end of an <event></event> block, so
# it sees a completed object.
sub putDef {
my $pkg = shift;
my $obj = shift; # ref to xmlHandlers event object
my $context = shift;
if ($context eq 'internal') {
return undef;
} elsif ($context eq 'external') {
return $ref->{'internalName'};
}
}
sub getId {
my $pkg = shift;
return $pkg->{'id'};
}
sub getHeader {
my $pkg = shift;
return $pkg->{'header'};
}
sub getIdNo {
my $pkg = shift;
return $pkg->{'idNo'};
}
sub getSuperClass {
my $pkg = shift;
return $pkg->{'super'};
}
sub getOmit {
my $pkg = shift;
return $pkg->{'omit'};
}
sub getType {
my $pkg = shift;
return $pkg->{'type'};
}
sub getTitle {
return shift->{'title'};
}
sub getProgram {
return shift->{'program'};
}
sub getSee {
return shift->{'see'};
}
sub getNote {
return shift->{'note'};
}
sub getInternal {
my $pkg = shift;
return $pkg->{'internal'};
}
sub getExternal {
my $pkg = shift;
return $pkg->{'external'};
}
# this isn't fully implemented; just a skeleton
package tokenDef;
1;
sub new {
my $pkg = shift;
my $obj = shift;
my $id = shift;
return bless {'id' => $id,
'usage' => $usage
}, $pkg;
}
sub getId {
my $pkg = shift;
return $pkg->{'id'};
}
sub getUsage {
my $pkg = shift;
return $pkg->{'usage'};
}
package messageList;
1;
sub new {
my $pkg = shift;
my $obj = shift;
my $id = shift;
my $header = shift;
my $start = shift;
my $public = shift;
my $deprecated = shift;
my @msg = ();
my $kid;
if ($class eq 'msg') {
if (defined ($msgId)) {
}
else {
print STDERR "missing id for $class <msg>\n";
}
}
else {
print STDERR "invalid tag in <msg_list> block: $class\n";
}
}
return bless {'id' => $id,
'header' => $header,
'msg' => \@msg,
'start' => $start,
'public' => $public,
'deprecated' => $deprecated
}, $pkg;
}
sub getId {
my $pkg = shift;
return $pkg->{'id'};
}
sub getMsgStart {
my $pkg = shift;
return $pkg->{'start'};
}
sub getDeprecated {
my $pkg = shift;
return $pkg->{'deprecated'};
}
sub getMsgPublic {
my $pkg = shift;
return $pkg->{'public'};
}
sub getHeader {
my $pkg = shift;
return $pkg->{'header'};
}
# destructive read of @msg...
sub getNextMsg {
my $pkg = shift;
return undef unless @msg;
return $text;
}
# returns all msgs
sub getMsgs {
my $pkg = shift;
return @{$pkg->{'msg'}};
}
package noteList;
1;
sub new {
my $pkg = shift;
my $obj = shift;
my $id = shift;
my %notes = ();
my $kid;
if ($class eq 'note') {
if (defined ($note_id)) {
}
else {
print STDERR "missing id for $class <note>\n";
}
}
else {
print STDERR "invalid tag in <note_list> block: $class\n";
}
}
return bless {'id' => $id,
'notes' => \%notes,
}, $pkg;
}
sub getId {
my $pkg = shift;
return $pkg->{'id'};
}
sub getNotes {
my $pkg = shift;
return %{$pkg->{'notes'}};
}
package auditxml;
# These aren't internal state because the callback functions don't
# have the object handle.
@debug = (); # stack for nesting debug state
%event = (); # event name => $objRef
@event = (); # event id
%token = (); # token name => $objRef
@token = (); # token id
%note_list = (); # noteList string list id to obj
%msg_list = (); # messageList string list id to obj
@msg_list = (); # id list
%service = (); # valid service names
%externalToInternal = (); # map external event name to internal event name
1;
sub new {
my $pkg = shift;
my $file = shift; # xml file to be parsed
# do not use register() for debug because register generates extra
# debug information
return bless {'xmlObj' => $xml,
'firstToken' => 1,
}
# local function -- register both the auditxml function and the
# xmlHandler callback
sub register {
my $localName = shift;
my $startFunction = shift;
my $endFunction = shift;
if ($startFunction) {
}
if ($endFunction) {
}
}
sub completed {
my $obj = shift;
my $callbackSource = shift;
my $attribute;
foreach $attribute (keys %attributes) {
print "*** $attribute = $attributes{$attribute}\n";
}
print "*** content = $content\n" if defined $content;
}
if ($callbackSource eq 'start') {
}
elsif ($callbackSource eq 'end') {
}
else {
print STDERR "no auditxml function defined for $class\n";
}
}
# getNextEvent reads from @event destructively. 'firstEvent' could
# be used to make a copy from which to read.
sub getNextEvent {
my $pkg = shift;
return undef unless (@event);
if ($pkg->{'firstEvent'}) {
}
}
# returns all event ids
sub getEventIds {
my $pkg = shift;
return @event;
}
# returns event for id
sub getEvent {
my $pkg = shift;
my $id = shift;
}
sub getToken {
my $pkg = shift;
my $id = shift;
}
# getNextToken reads from @token destructively. 'firstToken' could
# be used to make a copy from which to read.
sub getNextToken {
my $pkg = shift;
return undef unless (@token);
if ($pkg->{'firstToken'}) {
}
}
# return token Ids
sub getTokenIds {
my $pkg = shift;
return @token;
}
# getNextMsgId reads from @msg_list destructively.
sub getNextMsgId {
my $pkg = shift;
return undef unless (@msg_list);
}
sub getMsgIds {
my $pkg = shift;
return @msg_list;
}
sub getMsg {
my $pkg = shift;
my $id = shift;
}
sub external {
}
sub internal {
}
sub eventStart {
my $obj = shift;
unless ($id) {
print STDERR "eventStart can't get a valid id\n";
return;
}
my $super;
} else {
$super = 0;
}
} else {
print STDERR "duplicate event id: $id\n";
}
}
sub eventEnd {
my $obj = shift;
unless (defined $id) {
print STDERR "event element is missing required id attribute\n";
return;
}
if ($class eq 'title') {
} elsif ($class eq 'note') {
if (defined $note_list_id && defined $note_id &&
defined $note_list{$note_list_id}) {
if (defined $note_hash_ref{$note_id}) {
if ($note_pos eq 'pre') {
$content = "$note_hash_ref{$note_id} $content";
} else {
$content = "$content $note_hash_ref{$note_id}";
}
}
}
} else {
}
}
}
# class method
#sub getInternalName {
# my $name = shift;
#
# return $externalToInternal{$name};
#}
sub entry {
}
#sub include {
# my $obj = shift;
#
# my $id = $obj->getAttr('id');
#
# if (defined $id) {
# print "include = $id\n" if $main::debug;
# }
# else {
# print STDERR "include element is missing required id attribute\n";
# $main::errExit = 3;
# }
#}
sub token {
my $obj = shift;
if (defined $id) {
}
else {
print STDERR "token element is missing required id attribute\n";
}
}
sub msg_list {
my $obj = shift;
if (defined $id) {
$public, $deprecated);
}
else {
print STDERR
"msg_list element is missing required id attribute\n";
}
}
sub msg {
# my $obj = shift;
}
sub note_list {
my $obj = shift;
if (defined $id) {
print STDERR "note_list \'$id\' already defined\n";
return;
}
}
else {
print STDERR
"note_list element is missing required id attribute\n";
}
}
# Service name was dropped during PSARC review
sub service {
my $obj = shift;
}
elsif (defined $name) {
print STDERR "service $name is missing an id number\n";
}
elsif (defined $id) {
print STDERR "service name missing for id = $id\n";
}
else {
print STDERR "missing both name and id for a service entry\n";
}
}
#sub getServices {
#
# return %service;
#}
# <debug set="on"> or <debug set="off"> or <debug>
# if the set attribute is omitted, debug state is toggled
# debugStart / debugEnd are used to insure debug state is
# scoped to the block between <debug> and </debug>
sub debugStart {
my $obj = shift;
if (defined $state) {
}
else {
}
}
}
sub debugEnd {
my $obj = shift;
}
}