1Exacct(3PERL) Perl Library Functions Exacct(3PERL)
2
3
4
6 Exacct - exacct system calls and error handling
7
9 use Sun::Solaris::Exacct qw(:EXACCT_ALL);
10 my $ea_rec = getacct(P_PID, $$);
11
12
14 This module provides access to the ea_error(3EXACCT) function and for
15 all the extended accounting system calls. Constants from the various
16 libexacct(3LIB) header files are also provided.
17
18 Constants
19 The P_PID, P_TASKID, P_PROJID and all the EW_*, EP_*, EXR_* macros are
20 provided as Perl constants.
21
22 Functions
23 getacct($idtype, $id)
24
25 The $idtype parameter must be either P_TASKID or P_PID and $id must
26 be a corresponding task or process ID. This function returns an
27 object of type Sun::Solaris::Exacct::Object, representing the
28 unpacked accounting buffer returned by the underlying getacct(2)
29 system call. In the event of error, undef is returned.
30
31
32 putacct($idtype, $id, $record)
33
34 The $idtype parameter must be either P_TASKID or P_PID and $id must
35 be a corresponding task or process ID. If $record is of type
36 Sun::Solaris::Exacct::Object, it is converted to the corresponding
37 packed libexacct object and passed to the putacct(2) system call.
38 If $record is not of type Sun::Solaris::Exacct::Object it is con‐
39 verted to a string using the normal Perl conversion rules and
40 stored as a raw buffer. For predictable and endian-independent
41 results, any raw buffers should be constructed using the Perl
42 pack() function. This function returns true on success and false on
43 failure.
44
45
46 wracct($idtype, $id, $flags)
47
48 The $idtype parameter must be either P_TASKID or P_PID and $id must
49 be a corresponding task or process ID. The $flags parameter must be
50 either EW_INTERVAL or EW_PARTIAL. The parameters are passed
51 directly to the underlying wracct(2) system call. This function
52 returns true on success and false on failure.
53
54
55 ea_error()
56
57 This function provides access to the ea_error(3EXACCT) function. It
58 returns a double-typed scalar that becomes one of the EXR_* con‐
59 stants. In a string context it becomes a descriptive error message.
60 This is the exacct equivalent to the $!(errno) Perl variable.
61
62
63 ea_error_str()
64
65 This function returns a double-typed scalar that in a numeric con‐
66 text will be one of the EXR_* constants as returned by ea_error. In
67 a string context it describes the value returned by ea_error. If
68 ea_error returns EXR_SYSCALL_FAIL, the string value returned is the
69 value returned by strerror(3C). This function is provided as a con‐
70 venience so that repeated blocks of code like the following can be
71 avoided:
72
73 if (ea_error() == EXR_SYSCALL_FAIL) {
74 print("error: $!\n");
75 } else {
76 print("error: ", ea_error(), "\n");
77 }
78
79
80
81 ea_register_catalog($cat_pfx, $catalog_id, $export, @idlist)
82
83 This convenience function is a wrapper around the
84 Sun::Solaris::Exacct::Catalog->register() method.
85
86
87 ea_new_catalog($integer)
88 ea_new_catalog($cat_obj)
89 ea_new_catalog($type, $catalog, $id)
90
91 These convenience functions are wrappers around the
92 Sun::Solaris::Exacct::Catalog->new() method. See Exacct::Cata‐
93 log(3PERL).
94
95
96 ea_new_file($name, $oflags, creator => $creator, aflags => $aflags,
97 mode => $mode)
98
99 This convenience function is a wrapper around the
100 Sun::Solaris::Exacct::File->new() method. See Exacct::File(3PERL).
101
102
103 ea_new_item($catalog, $value)
104
105 This convenience function is a wrapper around the
106 Sun::Solaris::Exacct::Object::Item->new() method. See
107 Exacct::Object::Item(3PERL).
108
109
110 ea_new_group($catalog, @objects)
111
112 This convenience function is a wrapper around the
113 Sun::Solaris::Exacct::Object::Group->new() method. See
114 Exacct::Object::Group(3PERL).
115
116
117 ea_dump_object($object, $filehandle)
118
119 This convenience function is a wrapper around the
120 Sun::Solaris::Exacct::Object->dump() method. See
121 Exacct::Object(3PERL).
122
123
124 Class methods
125 None.
126
127 Object methods
128 None.
129
130 Exports
131 By default nothing is exported from this module. The following tags can
132 be used to selectively import constants and functions defined in this
133 module:
134
135 :SYSCALLS getacct(), putacct(), and wracct()
136
137
138 :LIBCALLS ea_error() and ea_error_str()
139
140
141 :CONSTANTS P_PID, P_TASKID, P_PROJID, EW_*, EP_*, and EXR_*
142
143
144 :SHORTHAND ea_register_catalog(), ea_new_catalog(),
145 ea_new_file(), ea_new_item(), and ea_new_group()
146
147
148 :ALL :SYSCALLS, :LIBCALLS, :CONSTANTS, and :SHORTHAND
149
150
151 :EXACCT_CONSTANTS :CONSTANTS, plus the :CONSTANTS tags for
152 Sun::Solaris::Catalog, Sun::Solaris::File, and
153 Sun::Solaris::Object
154
155
156 :EXACCT_ALL :ALL, plus the :ALL tags for Sun::Solaris::Cata‐
157 log, Sun::Solaris::File, and Sun::Solaris::Object
158
159
161 See attributes(5) for descriptions of the following attributes:
162
163
164
165
166 ┌─────────────────────────────┬─────────────────────────────┐
167 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
168 ├─────────────────────────────┼─────────────────────────────┤
169 │Availability │SUNWpl5u │
170 ├─────────────────────────────┼─────────────────────────────┤
171 │Interface Stability │Evolving │
172 └─────────────────────────────┴─────────────────────────────┘
173
175 getacct(2), putacct(2), wracct(2), ea_error(3EXACCT), Exacct::Cata‐
176 log(3PERL), Exacct::File(3PERL), Exacct::Object(3PERL),
177 Exacct::Object::Group(3PERL), Exacct::Object::Item(3PERL), libex‐
178 acct(3LIB), attributes(5)
179
181 The modules described in the section 3PERL manual pages make extensive
182 use of the Perl "double-typed scalar" facility. This facility allows a
183 scalar value to behave either as an integer or as a string, depending
184 upon context. It is the same behavior as exhibited by the $! Perl vari‐
185 able (errno). It is useful because it avoids the need to map from an
186 integer value to the corresponding string to display a value. Some
187 examples are provided below:
188
189 # Assume $obj is a Sun::Solaris::Item
190 my $type = $obj->type();
191
192 # Print "2 EO_ITEM"
193 printf("%d %s\n", $type, $type);
194
195 # Behave as an integer, $i == 2
196 my $i = 0 + $type;
197
198 # Behave as a string, $s = "abc EO_ITEM xyx"
199 my $s = "abc $type xyz";
200
201
202
203 Wherever a function or method is documented as returning a double-typed
204 scalar, the returned value exhibits this type of behavior.
205
206
207
208SunOS 5.11 1 Dec 2002 Exacct(3PERL)