Perl Library Functions Exacct::File(3PERL)
NAME
Exacct::File - exacct file manipulation
SYNOPSIS
use Sun::Solaris::Exacct::File qw(:ALL);
my $ea_file = Sun::Solaris::Exacct::File->new($myfile, &O_RDONLY);
my $ea_obj = $ea_file->get();
DESCRIPTION
This module provides access to the libexacct(3LIB) functionsthat manipulate accounting files. The interface is object-
oriented and allows the creation and reading of libexacct files. The C library calls wrapped by this module areea_open(3EXACCT), ea_close(3EXACCT),
ea_next_object(3EXACCT), ea_previous_object(3EXACCT),
ea_write_object(3EXACCT), ea_get_object(3EXACCT),
ea_get_creator(3EXACCT), and ea_get_hostname(3EXACCT). The
file read and write methods all operate on Sun::Solaris::Exacct::Object objects and perform all thenecessary memory management, packing, unpacking, and struc-
ture conversions that are required. ConstantsEO_HEAD, EO_TAIL, EO_NO_VALID_HDR, EO_POSN_MSK, and
EO_VALIDATE_MSK. Other constants needed by the new() method
below are in the standard Perl Fcntl module. Functions None. Class methodsnew($name, $oflags, creator => $creator,
This method opens a libexacct file as specified by themandatory parameters $name and $oflags, and returns a
Sun::Solaris::Exacct::File object, or undef if an error
occurs. The parameters $creator, $aflags, and $mode are
optional and are passed as (name => value) pairs. Theonly valid values for $oflags are the combinations of
O_RDONLY, O_WRONLY, O_RDWR, and O_CREAT described below.
The $creator parameter is a string describing the crea-
tor of the file. If it is required (for instance, when writing to a file) but absent, it is set to the stringrepresentation of the caller's UID. The $aflags parame-
ter describes the required positioning in the file forO_RDONLY access: either EO_HEAD or EO_TAIL are allowed.
If absent, EO_HEAD is assumed. The $mode parameter is
the file creation mode and is ignored unless O_CREAT is
specified in $oflags. If $mode is unspecified, the file
creation mode is set to 0666 (octal). If an errorSunOS 5.11 Last change: 1 Dec 2002 1
Perl Library Functions Exacct::File(3PERL)
occurs, it can be retrieved with theSun::Solaris::Exacct::ea_error() function. See
Exacct(3PERL).$oflags $aflags Action
O_RDONLY Absent or EO_HEAD Open for reading at the start of the
file.O_RDONLY EO_TAIL Open for reading at the end of the file.
O_WRONLY Ignored File must exist, open for writing at the
end of the file.O_WRONLY | O_CREAT Ignored Create file if it does not exist, other-
wise truncate and open for writing.O_RDWR Ignored File must exist, open for
reading/writing, positioned at the end of the file.O_RDWR | O_CREAT Ignored Create file if it does not exist, other-
wise truncate and open for reading/writing. Object methods There is no explicit close() method for aSun::Solaris::Exacct::File. The file is closed when the file
handle object is undefined or reassigned. creator() This method returns a string containing the creator of the file or undef if the file does not contain the information. hostname() This method returns a string containing the hostname on which the file was created, or undef if the file does not contain the information. next() This method reads the header information of the next record in the file. In a scalar context the value of thetype field is returned as a dual-typed scalar that will
be one of EO_ITEM, EO_GROUP, or EO_NONE. In a list con-
text it returns a two-element list containing the values
of the type and catalog fields. The type element is adual-typed scalar. The catalog element is blessed into
the Sun::Solaris::Exacct::Catalog class. If an errorSunOS 5.11 Last change: 1 Dec 2002 2
Perl Library Functions Exacct::File(3PERL)
occurs, undef or (undef, undef) is returned depending upon context. The status can be accessed with theSun::Solaris::Exacct::ea_error() function.See
Exacct(3PERL). previous() This method reads the header information of the previous record in the file. In a scalar context it returns thetype field. In a list context it returns the two-element
list containing the values of the type and catalog fields, in the same manner as the next() method. Error are also returned in the same manner as the next() method. get() This method reads in the libexacct record at the current position in the file and returns a Sun::Solaris::Exacct::Object containing the unpacked data from the file. This object can then be further manipulated using its methods. In case of error undef is returned and the error status is made available withthe Sun::Solaris::Exacct::ea_error() function. After
this operation, the position in the file is set to the start of the next record in the file.write(@ea_obj)
This method converts the passed list of Sun::Solaris::Exacct::Objects into libexacct file format and appends them to the libexacct file, which must be open for writing. This method returns true if successfuland false otherwise. On failure the error can be exam-
ined with the Sun::Solaris::Exacct::ea_error() function.
ExportsBy default nothing is exported from this module. The follow-
ing tags can be used to selectively import constants defined in this module: :CONSTANTSEO_HEAD, EO_TAIL, EO_NO_VALID_HDR, EO_POSN_MSK, and
EO_VALIDATE_MSK
SunOS 5.11 Last change: 1 Dec 2002 3
Perl Library Functions Exacct::File(3PERL)
:ALL :CONSTANTS, Fcntl(:DEFAULT).ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:____________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| Availability | SUNWpl5u ||_____________________________|_____________________________|
| Interface Stability | Committed ||_____________________________|_____________________________|
SEE ALSO
ea_close(3EXACCT), ea_get_creator(3EXACCT),
ea_get_hostname(3EXACCT), ea_get_object(3EXACCT),
ea_next_object(3EXACCT), ea_open(3EXACCT),
ea_previous_object(3EXACCT), ea_write_object(3EXACCT),
Exacct(3PERL), Exacct::Catalog(3PERL), Exacct::Object(3PERL), Exacct::Object::Group(3PERL), Exacct::Object::Item(3PERL), libexacct(3LIB), attributes(5)SunOS 5.11 Last change: 1 Dec 2002 4