2 # Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
6 # Object.pm contains perl code for exacct object manipulation.
13 package Sun
::Solaris
::Exacct
::Object
;
17 XSLoader
::load
(__PACKAGE__
, $VERSION);
19 our (@EXPORT_OK, %EXPORT_TAGS, @_Constants);
20 @EXPORT_OK = @_Constants;
21 %EXPORT_TAGS = (CONSTANTS
=> \
@_Constants, ALL
=> \
@EXPORT_OK);
23 use base
qw(Exporter);
24 use Sun
::Solaris
::Exacct
::Catalog
qw(:CONSTANTS);
31 # Dump an exacct object to the specified filehandle, or STDOUT by default.
36 my ($class, $obj, $fh, $indent) = @_;
39 my $istr = ' ' x
$indent;
41 # Check for undef values.
42 if (! defined($obj)) {
43 print $fh ($istr, "UNDEFINED_VALUE\n");
48 my @cat = $obj->catalog()->value();
49 if ($obj->type() == &EO_ITEM
) {
50 printf $fh ("%sITEM\n%s Catalog = %s|%s|%s\n",
53 my $val = $obj->value();
55 # Recursively dump nested objects.
57 $class->dump($val, $fh, $indent);
59 # Just print out items.
61 $val = unpack('H*', $val) if ($cat[0] == &EXT_RAW
);
62 printf $fh ("%s Value = %s\n", $istr, $val);
67 printf $fh ("%sGROUP\n%s Catalog = %s|%s|%s\n",
70 foreach my $val ($obj->value()) {
71 $class->dump($val, $fh, $indent);
73 printf $fh ("%sENDGROUP\n", $istr);
78 # Item subclass - establish inheritance.
80 package Sun
::Solaris
::Exacct
::Object
::Item
;
81 use base
qw(Sun::Solaris::Exacct::Object);
84 # Group subclass - establish inheritance.
86 package Sun
::Solaris
::Exacct
::Object
::Group
;
87 use base
qw(Sun::Solaris::Exacct::Object);
90 # Tied array used for holding a group's items.
92 package Sun
::Solaris
::Exacct
::Object
::_Array
;
96 # Check the passed list of arguments are derived from ::Object
103 if (! UNIVERSAL
::isa
($i, 'Sun::Solaris::Exacct::Object'));
106 local $Carp::CarpLevel
= 2;
107 croak
('"', join('", "', @duff), @duff == 1 ?
'" is' : '" are',
108 ' not of type Sun::Solaris::Exacct::Object');
113 # Tied hash access methods
117 return(bless([], $_[0]));
122 return(scalar(@
{$_[0]}));
127 $#{$_[0]} = $_[1] - 1;
133 return($_[0]->[$_[1]] = copy_xs_ea_objects
($_[2]));
138 return($_[0]->[$_[1]]);
148 return(pop(@
{$_[0]}));
155 push(@
$a, copy_xs_ea_objects
(@_));
160 return(shift(@
{$_[0]}));
167 return(unshift(@
$a, copy_xs_ea_objects
(@_)));
172 return(exists($_[0]->[$_[1]]));
177 return(delete($_[0]->[$_[1]]));
187 my $sz = scalar(@
$a);
188 my $off = @_ ?
shift(@_) : 0;
189 $off += $sz if $off < 0;
190 my $len = @_ ?
shift : $sz - $off;
192 return(splice(@
$a, $off, $len, copy_xs_ea_objects
(@_)));