1ea_pack_object(3EExXtAeCnCdTe)d Accounting File Access Library Feuan_cptaicokn_sobject(3EXACCT)
2
3
4
6 ea_pack_object, ea_unpack_object, ea_get_creator, ea_get_hostname,
7 ea_next_object, ea_previous_object, ea_get_object, ea_write_object,
8 ea_copy_object, ea_copy_object_tree, ea_get_object_tree - construct,
9 read, and write extended accounting records
10
12 cc [ flag... ] file... -lexacct [ library... ]
13 #include <exacct.h>
14
15 size_t ea_pack_object(ea_object_t *obj, void *buf,
16 size_t bufsize);
17
18
19 ea_object_type_t ea_unpack_object(ea_object_t **objp, int flag,
20 void *buf, size_t bufsize);
21
22
23 const char *ea_get_creator(ea_file_t *ef);
24
25
26 const char *ea_get_hostname(ea_file_t *ef);
27
28
29 ea_object_type_t ea_next_object(ea_file_t *ef, ea_object_t *obj);
30
31
32 ea_object_type_t ea_previous_object(ea_file_t *ef,
33 ea_object_t *obj);
34
35
36 ea_object_type_t ea_get_object(ea_file_t *ef, ea_object_t *obj);
37
38
39 int ea_write_object(ea_file_t *ef, ea_object_t *obj);
40
41
42 ea_object_type_t *ea_copy_object(const ea_object_t *src);
43
44
45 ea_object_type_t *ea_copy_object_tree(const ea_object_t *src);
46
47
48 ea_object_type_t *ea_get_object_tree(ea_file_t *ef,
49 uint32_tnobj);
50
51
53 The ea_pack_object() function converts exacct objects from their in-
54 memory representation to their file representation. It is passed an
55 object pointer that points to the top of an exacct object hierarchy
56 representing one or more exacct records. It returns the size of the
57 buffer required to contain the packed buffer representing the object
58 hierarchy. To obtain the correct size of the required buffer, the buf
59 and bufsize parameters can be set to NULL and 0 respectively, and the
60 required buffer size will be returned. The resulting packed record can
61 be passed to putacct(2) or to ea_set_item(3EXACCT) when constructing an
62 object of type EXT_EXACCT_OBJECT.
63
64
65 The ea_unpack_object() function reverses the packing process performed
66 by ea_pack_object(). A packed buffer passed to ea_unpack_object() is
67 unpacked into the original hierarchy of objects. If the unpack opera‐
68 tion fails (for example, due to a corrupted or incomplete buffer), it
69 returns EO_ERROR; otherwise, the object type of the first object in the
70 hierarchy is returned. If ea_unpack_object() is invoked with flag
71 equal to EUP_ALLOC, it allocates memory for the variable-length data in
72 the included objects. Otherwise, with flag equal to EUP_NOALLOC, it
73 sets the variable length data pointers within the unpacked object
74 structures to point within the buffer indicated by buf. In both cases,
75 ea_unpack_object() allocates all the necessary exacct objects to repre‐
76 sent the unpacked record. The resulting object hierarchy can be freed
77 using ea_free_object(3EXACCT) with the same flag value.
78
79
80 The ea_get_creator() function returns a pointer to a string represent‐
81 ing the recorded creator of the exacct file. The ea_get_hostname()
82 function returns a pointer to a string representing the recorded host‐
83 name on which the exacct file was created. These functions will return
84 NULL if their respective field was not recorded in the exacct file
85 header.
86
87
88 The ea_next_object() function reads the basic fields (eo_catalog and
89 eo_type) into the ea_object_t indicated by obj from the exacct file
90 referred to by ef and rewinds to the head of the record. If the read
91 object is corrupted, ea_next_object() returns EO_ERROR and records the
92 extended accounting error code, accessible with ea_error(3EXACCT). If
93 end-of-file is reached, EO_ERROR is returned and the extended account‐
94 ing error code is set to EXR_EOF.
95
96
97 The ea_previous_object() function skips back one object in the file and
98 reads its basic fields (eo_catalog and eo_type) into the indicated
99 ea_object_t. If the read object is corrupted, ea_previous_object()
100 returns EO_ERROR and records the extended accounting error code, acces‐
101 sible with ea_error(3EXACCT). If end-of-file is reached, EO_ERROR is
102 returned and the extended accounting error code is set to EXR_EOF.
103
104
105 The ea_get_object() function reads the value fields into the
106 ea_object_t indicated by obj, allocating memory as necessary, and
107 advances to the head of the next record. Once a record group object is
108 retrieved using ea_get_object(), subsequent calls to ea_get_object()
109 and ea_next_object() will track through the objects within the record
110 group, and on reaching the end of the group, will return the next
111 object at the same level as the group from the file. If the read object
112 is corrupted, ea_get_object() returns EO_ERROR and records the extended
113 accounting error code, accessible with ea_error(3EXACCT). If end-of-
114 file is reached, EO_ERROR is returned and the extended accounting error
115 code is set to EXR_EOF.
116
117
118