rpm  4.8.1
rpmtd.h
Go to the documentation of this file.
1 #ifndef _RPMTD_H
2 #define _RPMTD_H
3 
4 #include <rpm/rpmtypes.h>
5 #include <rpm/argv.h>
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 typedef enum rpmtdFlags_e {
13  RPMTD_ALLOCED = (1 << 0), /* was memory allocated? */
14  RPMTD_PTR_ALLOCED = (1 << 1), /* were array pointers allocated? */
15  RPMTD_IMMUTABLE = (1 << 2), /* header data or modifiable? */
16  RPMTD_ARGV = (1 << 3), /* string array is NULL-terminated? */
17 } rpmtdFlags;
18 
23 struct rpmtd_s {
24  rpmTag tag; /* rpm tag of this data entry*/
25  rpmTagType type; /* data type */
26  rpm_count_t count; /* number of entries */
27  rpm_data_t data; /* pointer to actual data */
28  rpmtdFlags flags; /* flags on memory allocation etc */
29  int ix; /* iteration index */
30 };
31 
36 rpmtd rpmtdNew(void);
37 
44 
50 void rpmtdReset(rpmtd td);
51 
57 void rpmtdFreeData(rpmtd td);
58 
65 
72 
79 
86 
92 int rpmtdGetIndex(rpmtd td);
93 
102 int rpmtdSetIndex(rpmtd td, int index);
103 
109 int rpmtdInit(rpmtd td);
110 
116 int rpmtdNext(rpmtd td);
117 
123 uint32_t *rpmtdNextUint32(rpmtd td);
124 
130 uint64_t *rpmtdNextUint64(rpmtd td);
131 
137 const char *rpmtdNextString(rpmtd td);
138 
147 char *rpmtdGetChar(rpmtd td);
148 
157 uint16_t * rpmtdGetUint16(rpmtd td);
158 
167 uint32_t * rpmtdGetUint32(rpmtd td);
168 
177 uint64_t * rpmtdGetUint64(rpmtd td);
178 
187 const char * rpmtdGetString(rpmtd td);
188 
198 uint64_t rpmtdGetNumber(rpmtd td);
199 
200 typedef enum rpmtdFormats_e {
201  RPMTD_FORMAT_STRING = 0, /* plain string (any type) */
202  RPMTD_FORMAT_ARMOR = 1, /* ascii armor format (bin types) */
203  RPMTD_FORMAT_BASE64 = 2, /* base64 encoding (bin types) */
204  RPMTD_FORMAT_PGPSIG = 3, /* pgp/gpg signature (bin types) */
205  RPMTD_FORMAT_DEPFLAGS = 4, /* dependency flags (int types) */
206  RPMTD_FORMAT_FFLAGS = 5, /* file flags (int types) */
207  RPMTD_FORMAT_PERMS = 6, /* permission string (int types) */
208  RPMTD_FORMAT_TRIGGERTYPE = 7, /* trigger types (int types) */
209  RPMTD_FORMAT_XML = 8, /* xml format (any type) */
210  RPMTD_FORMAT_OCTAL = 9, /* octal format (int types) */
211  RPMTD_FORMAT_HEX = 10, /* hex format (int types) */
212  RPMTD_FORMAT_DATE = 11, /* date format (int types) */
213  RPMTD_FORMAT_DAY = 12, /* day format (int types) */
214  RPMTD_FORMAT_SHESCAPE = 13, /* shell escaped (any type) */
215  RPMTD_FORMAT_ARRAYSIZE = 14, /* size of contained array (any type) */
216  RPMTD_FORMAT_DEPTYPE = 15, /* dependency types (int types) */
217  RPMTD_FORMAT_FSTATE = 16, /* file states (int types) */
218  RPMTD_FORMAT_VFLAGS = 17, /* file verify flags (int types) */
219 } rpmtdFormats;
220 
232 char *rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg);
233 
242 int rpmtdSetTag(rpmtd td, rpmTag tag);
243 
255 int rpmtdFromUint8(rpmtd td, rpmTag tag, uint8_t *data, rpm_count_t count);
256 
267 int rpmtdFromUint16(rpmtd td, rpmTag tag, uint16_t *data, rpm_count_t count);
268 
279 int rpmtdFromUint32(rpmtd td, rpmTag tag, uint32_t *data, rpm_count_t count);
280 
291 int rpmtdFromUint64(rpmtd td, rpmTag tag, uint64_t *data, rpm_count_t count);
292 
301 int rpmtdFromString(rpmtd td, rpmTag tag, const char *data);
302 
313 int rpmtdFromStringArray(rpmtd td, rpmTag tag, const char **data, rpm_count_t count);
314 
324 int rpmtdFromArgv(rpmtd td, rpmTag tag, ARGV_t argv);
325 
335 int rpmtdFromArgi(rpmtd td, rpmTag tag, ARGI_t argi);
336 
337 /* \ingroup rpmtd
338  * Perform deep copy of container.
339  * Create a modifiable copy of tag data container (on string arrays each
340  * string is separately allocated)
341  * @todo Only string arrays types are supported currently
342  * @param td Container to copy
343  * @return New container or NULL on error
344  */
345 rpmtd rpmtdDup(rpmtd td);
346 
347 #ifdef __cplusplus
348 }
349 #endif
350 
351 #endif /* _RPMTD_H */
uint64_t * rpmtdNextUint64(rpmtd td)
Iterate over uint64_t type tag data container.
uint16_t * rpmtdGetUint16(rpmtd td)
Return uint16_t data from tag container.
int rpmtdFromUint16(rpmtd td, rpmTag tag, uint16_t *data, rpm_count_t count)
Construct tag container from uint16_t pointer.
int rpmtdFromStringArray(rpmtd td, rpmTag tag, const char **data, rpm_count_t count)
Construct tag container from a string array.
char ** ARGV_t
Definition: argv.h:14
uint32_t rpm_count_t
Definition: rpmtypes.h:29
char * rpmtdGetChar(rpmtd td)
Return char data from tag container.
rpm_count_t count
Definition: rpmtd.h:26
int rpmtdGetIndex(rpmtd td)
Retrieve current iteration index of the container.
int rpmtdNext(rpmtd td)
Iterate over tag data container.
enum rpmTag_e rpmTag
Tags identify data in package headers.
enum rpmtdFormats_e rpmtdFormats
uint64_t rpmtdGetNumber(rpmtd td)
Return numeric value from tag container.
int rpmtdInit(rpmtd td)
Initialize tag container for iteration.
uint64_t * rpmtdGetUint64(rpmtd td)
Return uint64_t data from tag container.
int rpmtdSetTag(rpmtd td, rpmTag tag)
Set container tag and type.
rpmTagClass rpmtdClass(rpmtd td)
Retrieve class of the container.
rpmtd rpmtdNew(void)
Create new tag data container.
rpmtdFlags flags
Definition: rpmtd.h:28
void * rpm_data_t
Definition: rpmtypes.h:31
int ix
Definition: rpmtd.h:29
int rpmtdFromUint32(rpmtd td, rpmTag tag, uint32_t *data, rpm_count_t count)
Construct tag container from uint32_t pointer.
rpmTagType rpmtdType(rpmtd td)
Retrieve type of the container.
enum rpmTagType_e rpmTagType
The basic types of data in tags from headers.
int rpmtdFromArgi(rpmtd td, rpmTag tag, ARGI_t argi)
Construct tag container from ARGI_t array.
rpmtdFormats_e
Definition: rpmtd.h:200
rpm_data_t data
Definition: rpmtd.h:27
int rpmtdFromArgv(rpmtd td, rpmTag tag, ARGV_t argv)
Construct tag container from ARGV_t array.
enum rpmtdFlags_e rpmtdFlags
int rpmtdFromUint64(rpmtd td, rpmTag tag, uint64_t *data, rpm_count_t count)
Construct tag container from uint64_t pointer.
rpm_count_t rpmtdCount(rpmtd td)
Retrieve array size of the container.
rpmTag rpmtdTag(rpmtd td)
Retrieve tag of the container.
uint32_t * rpmtdGetUint32(rpmtd td)
Return uint32_t data from tag container.
uint32_t * rpmtdNextUint32(rpmtd td)
Iterate over uint32_t type tag data container.
void rpmtdReset(rpmtd td)
(Re-)initialize tag data container.
int rpmtdFromUint8(rpmtd td, rpmTag tag, uint8_t *data, rpm_count_t count)
Construct tag container from uint8_t pointer.
rpmtd rpmtdFree(rpmtd td)
Destroy tag data container.
int rpmtdFromString(rpmtd td, rpmTag tag, const char *data)
Construct tag container from a string.
rpmtd rpmtdDup(rpmtd td)
const char * rpmtdGetString(rpmtd td)
Return string data from tag container.
enum rpmTagClass_e rpmTagClass
The classes of data in tags from headers.
rpmtdFlags_e
Definition: rpmtd.h:11
Container for rpm tag data (from headers or extensions).
Definition: rpmtd.h:23
const char * rpmtdNextString(rpmtd td)
Iterate over string / string array type tag data container.
int rpmtdSetIndex(rpmtd td, int index)
Set iteration index of the container.
char * rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg)
Format data from tag container to string presentation of given format.
rpmTag tag
Definition: rpmtd.h:24
Definition: argv.h:18
void rpmtdFreeData(rpmtd td)
Free contained data.
rpmTagType type
Definition: rpmtd.h:25