1Exacct::File(3PERL)         Perl Library Functions         Exacct::File(3PERL)
2
3
4

NAME

6       Exacct::File - exacct file manipulation
7

SYNOPSIS

9       use Sun::Solaris::Exacct::File qw(:ALL);
10       my $ea_file = Sun::Solaris::Exacct::File->new($myfile, &O_RDONLY);
11       my $ea_obj = $ea_file->get();
12
13

DESCRIPTION

15       This  module  provides  access  to  the  libexacct(3LIB) functions that
16       manipulate accounting  files.  The  interface  is  object-oriented  and
17       allows the creation and reading of libexacct files. The C library calls
18       wrapped  by  this  module  are   ea_open(3EXACCT),   ea_close(3EXACCT),
19       ea_next_object(3EXACCT),                   ea_previous_object(3EXACCT),
20       ea_write_object(3EXACCT),      ea_get_object(3EXACCT),      ea_get_cre‐
21       ator(3EXACCT),  and  ea_get_hostname(3EXACCT).  The file read and write
22       methods all operate on Sun::Solaris::Exacct::Object objects and perform
23       all  the necessary memory management, packing, unpacking, and structure
24       conversions that are required.
25
26   Constants
27       EO_HEAD, EO_TAIL, EO_NO_VALID_HDR,  EO_POSN_MSK,  and  EO_VALIDATE_MSK.
28       Other  constants  needed  by the new() method below are in the standard
29       Perl Fcntl module.
30
31   Functions
32       None.
33
34   Class methods
35       new($name, $oflags, creator => $creator,
36
37           This method opens a libexacct file as specified  by  the  mandatory
38           parameters     $name     and     $oflags,     and     returns     a
39           Sun::Solaris::Exacct::File object, or undef if an error occurs. The
40           parameters $creator, $aflags, and $mode are optional and are passed
41           as (name => value) pairs. The only valid values for $oflags are the
42           combinations  of  O_RDONLY, O_WRONLY, O_RDWR, and O_CREAT described
43           below.
44
45           The $creator parameter is a string describing the  creator  of  the
46           file.  If it is required (for instance, when writing to a file) but
47           absent, it is set to the string representation of the caller's UID.
48           The  $aflags  parameter  describes  the required positioning in the
49           file for O_RDONLY access: either EO_HEAD or  EO_TAIL  are  allowed.
50           If  absent,  EO_HEAD  is  assumed.  The $mode parameter is the file
51           creation mode  and  is  ignored  unless  O_CREAT  is  specified  in
52           $oflags.  If $mode is unspecified, the file creation mode is set to
53           0666 (octal). If an error occurs, it  can  be  retrieved  with  the
54           Sun::Solaris::Exacct::ea_error() function. See Exacct(3PERL).
55
56
57
58
59                $oflags               $aflags                          Action
60           O_RDONLY             Absent or EO_HEAD     Open  for  reading  at  the start of the
61                                                      file.
62           O_RDONLY             EO_TAIL               Open for reading at the end of the file.
63           O_WRONLY             Ignored               File must exist, open for writing at the
64                                                      end of the file.
65
66
67           O_WRONLY | O_CREAT   Ignored               Create file if it does not exist, other‐
68                                                      wise truncate and open for writing.
69           O_RDWR               Ignored               File must exist, open for  reading/writ‐
70                                                      ing, positioned at the end of the file.
71           O_RDWR | O_CREAT     Ignored               Create file if it does not exist, other‐
72                                                      wise truncate and open for reading/writ‐
73                                                      ing.
74
75
76
77   Object methods
78       There  is  no explicit close() method for a Sun::Solaris::Exacct::File.
79       The file is closed when the file handle object is  undefined  or  reas‐
80       signed.
81
82       creator()
83
84           This  method returns a string containing the creator of the file or
85           undef if the file does not contain the information.
86
87
88       hostname()
89
90           This method returns a string containing the hostname on  which  the
91           file  was created, or undef if the file does not contain the infor‐
92           mation.
93
94
95       next()
96
97           This method reads the header information of the next record in  the
98           file.  In  a scalar context the value of the type field is returned
99           as a dual-typed scalar that will be one of  EO_ITEM,  EO_GROUP,  or
100           EO_NONE. In a list context it returns a two-element list containing
101           the values of the type and catalog fields. The type  element  is  a
102           dual-typed   scalar.  The  catalog  element  is  blessed  into  the
103           Sun::Solaris::Exacct::Catalog class. If an error occurs,  undef  or
104           (undef,  undef)  is returned depending upon context. The status can
105           be accessed with the Sun::Solaris::Exacct::ea_error()  function.See
106           Exacct(3PERL).
107
108
109       previous()
110
111           This  method reads the header information of the previous record in
112           the file. In a scalar context it returns the type field. In a  list
113           context  it  returns  the two-element list containing the values of
114           the type and catalog fields, in  the  same  manner  as  the  next()
115           method.  Error  are  also returned in the same manner as the next()
116           method.
117
118
119       get()
120
121           This method reads in the libexacct record at the  current  position
122           in  the  file and returns a Sun::Solaris::Exacct::Object containing
123           the unpacked data from the file.  This object can then  be  further
124           manipulated  using its methods.  In case of error undef is returned
125           and   the   error   status   is    made    available    with    the
126           Sun::Solaris::Exacct::ea_error()  function.   After this operation,
127           the position in the file is set to the start of the next record  in
128           the file.
129
130
131       write(@ea_obj)
132
133           This      method      converts      the      passed     list     of
134           Sun::Solaris::Exacct::Objects  into  libexacct  file   format   and
135           appends them to the libexacct file, which must be open for writing.
136           This method returns true if successful  and  false  otherwise.   On
137           failure     the     error     can     be    examined    with    the
138           Sun::Solaris::Exacct::ea_error() function.
139
140
141   Exports
142       By default nothing is exported from this module. The following tags can
143       be used to selectively import constants defined in this module:
144
145       :CONSTANTS
146
147           EO_HEAD, EO_TAIL, EO_NO_VALID_HDR, EO_POSN_MSK, and EO_VALIDATE_MSK
148
149
150       :ALL
151
152           :CONSTANTS, Fcntl(:DEFAULT).
153
154

ATTRIBUTES

156       See attributes(5) for descriptions of the following attributes:
157
158
159
160
161       ┌─────────────────────────────┬─────────────────────────────┐
162       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
163       ├─────────────────────────────┼─────────────────────────────┤
164       │Availability                 │SUNWpl5u                     │
165       ├─────────────────────────────┼─────────────────────────────┤
166       │Interface Stability          │Evolving                     │
167       └─────────────────────────────┴─────────────────────────────┘
168

SEE ALSO

170       ea_close(3EXACCT),  ea_get_creator(3EXACCT),  ea_get_hostname(3EXACCT),
171       ea_get_object(3EXACCT),   ea_next_object(3EXACCT),    ea_open(3EXACCT),
172       ea_previous_object(3EXACCT),  ea_write_object(3EXACCT),  Exacct(3PERL),
173       Exacct::Catalog(3PERL),                          Exacct::Object(3PERL),
174       Exacct::Object::Group(3PERL),    Exacct::Object::Item(3PERL),    libex‐
175       acct(3LIB), attributes(5)
176
177
178
179SunOS 5.11                        1 Dec 2002               Exacct::File(3PERL)
Impressum