rpm  4.13.0
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 
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  RPMTD_INVALID = (1 << 4), /* invalid data (in header) */
18 };
19 
21 
26 struct rpmtd_s {
27  rpm_tag_t tag; /* rpm tag of this data entry*/
28  rpm_tagtype_t type; /* data type */
29  rpm_count_t count; /* number of entries */
30  rpm_data_t data; /* pointer to actual data */
31  rpmtdFlags flags; /* flags on memory allocation etc */
32  int ix; /* iteration index */
33  rpm_count_t size; /* size of data (only works for RPMTD_IMMUTABLE atm) */
34 };
35 
40 rpmtd rpmtdNew(void);
41 
48 
54 void rpmtdReset(rpmtd td);
55 
61 void rpmtdFreeData(rpmtd td);
62 
69 
77 
84 
91 
98 
104 rpmtdFlags rpmtdGetFlags(rpmtd td);
105 
111 int rpmtdGetIndex(rpmtd td);
112 
121 int rpmtdSetIndex(rpmtd td, int index);
122 
128 int rpmtdInit(rpmtd td);
129 
135 int rpmtdNext(rpmtd td);
136 
142 uint32_t *rpmtdNextUint32(rpmtd td);
143 
149 uint64_t *rpmtdNextUint64(rpmtd td);
150 
156 const char *rpmtdNextString(rpmtd td);
157 
166 char *rpmtdGetChar(rpmtd td);
167 
176 uint16_t * rpmtdGetUint16(rpmtd td);
177 
186 uint32_t * rpmtdGetUint32(rpmtd td);
187 
196 uint64_t * rpmtdGetUint64(rpmtd td);
197 
206 const char * rpmtdGetString(rpmtd td);
207 
217 uint64_t rpmtdGetNumber(rpmtd td);
218 
219 typedef enum rpmtdFormats_e {
220  RPMTD_FORMAT_STRING = 0, /* plain string (any type) */
221  RPMTD_FORMAT_ARMOR = 1, /* ascii armor format (bin types) */
222  RPMTD_FORMAT_BASE64 = 2, /* base64 encoding (bin types) */
223  RPMTD_FORMAT_PGPSIG = 3, /* pgp/gpg signature (bin types) */
224  RPMTD_FORMAT_DEPFLAGS = 4, /* dependency flags (int types) */
225  RPMTD_FORMAT_FFLAGS = 5, /* file flags (int types) */
226  RPMTD_FORMAT_PERMS = 6, /* permission string (int types) */
227  RPMTD_FORMAT_TRIGGERTYPE = 7, /* trigger types (int types) */
228  RPMTD_FORMAT_XML = 8, /* xml format (any type) */
229  RPMTD_FORMAT_OCTAL = 9, /* octal format (int types) */
230  RPMTD_FORMAT_HEX = 10, /* hex format (int types) */
231  RPMTD_FORMAT_DATE = 11, /* date format (int types) */
232  RPMTD_FORMAT_DAY = 12, /* day format (int types) */
233  RPMTD_FORMAT_SHESCAPE = 13, /* shell escaped (any type) */
234  RPMTD_FORMAT_ARRAYSIZE = 14, /* size of contained array (any type) */
235  RPMTD_FORMAT_DEPTYPE = 15, /* dependency types (int types) */
236  RPMTD_FORMAT_FSTATE = 16, /* file states (int types) */
237  RPMTD_FORMAT_VFLAGS = 17, /* file verify flags (int types) */
238  RPMTD_FORMAT_EXPAND = 18, /* macro expansion (string types) */
239  RPMTD_FORMAT_FSTATUS = 19, /* file verify status (int types) */
240 } rpmtdFormats;
241 
253 char *rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg);
254 
263 int rpmtdSetTag(rpmtd td, rpmTagVal tag);
264 
277 
289 
301 
313 
322 int rpmtdFromString(rpmtd td, rpmTagVal tag, const char *data);
323 
335 
345 int rpmtdFromArgv(rpmtd td, rpmTagVal tag, ARGV_t argv);
346 
356 int rpmtdFromArgi(rpmtd td, rpmTagVal tag, ARGI_t argi);
357 
358 /* \ingroup rpmtd
359  * Perform deep copy of container.
360  * Create a modifiable copy of tag data container (on string arrays each
361  * string is separately allocated)
362  * @todo Only string arrays types are supported currently
363  * @param td Container to copy
364  * @return New container or NULL on error
365  */
366 rpmtd rpmtdDup(rpmtd td);
367 
368 /* \ingroup rpmtd
369  * Push string array container contents to a string pool, return string ids.
370  * @param td Tag data container
371  * @param pool String pool
372  * @return Array of string id's (malloced)
373  */
374 rpmsid * rpmtdToPool(rpmtd td, rpmstrPool pool);
375 
376 #ifdef __cplusplus
377 }
378 #endif
379 
380 #endif /* _RPMTD_H */
int rpmtdFromArgv(rpmtd td, rpmTagVal tag, ARGV_t argv)
Construct tag container from ARGV_t array.
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.
char ** ARGV_t
Definition: argv.h:15
uint32_t rpm_count_t
Definition: rpmtypes.h:29
rpmsid * rpmtdToPool(rpmtd td, rpmstrPool pool)
char * rpmtdGetChar(rpmtd td)
Return char data from tag container.
rpm_count_t count
Definition: rpmtd.h:29
int rpmtdGetIndex(rpmtd td)
Retrieve current iteration index of the container.
int rpmtdNext(rpmtd td)
Iterate over tag data container.
rpm_count_t size
Definition: rpmtd.h:33
rpmFlags rpmtdFlags
Definition: rpmtd.h:20
enum rpmtdFormats_e rpmtdFormats
uint32_t rpm_tagtype_t
Definition: rpmtypes.h:28
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.
int32_t rpm_tag_t
Definition: rpmtypes.h:27
rpmTagClass rpmtdClass(rpmtd td)
Retrieve class of the container.
rpm_tagtype_t type
Definition: rpmtd.h:28
rpmtd rpmtdNew(void)
Create new tag data container.
int rpmtdFromArgi(rpmtd td, rpmTagVal tag, ARGI_t argi)
Construct tag container from ARGI_t array.
rpm_tag_t rpmTagVal
Definition: rpmtypes.h:30
int rpmtdFromString(rpmtd td, rpmTagVal tag, const char *data)
Construct tag container from a string.
rpmtdFlags flags
Definition: rpmtd.h:31
void * rpm_data_t
Definition: rpmtypes.h:33
rpmTagVal rpmtdTag(rpmtd td)
Retrieve tag of the container.
int rpmtdFromUint16(rpmtd td, rpmTagVal tag, uint16_t *data, rpm_count_t count)
Construct tag container from uint16_t pointer.
struct rpmstrPool_s * rpmstrPool
Definition: rpmtypes.h:83
uint32_t rpmsid
Definition: rpmtypes.h:82
int ix
Definition: rpmtd.h:32
rpmTagType rpmtdType(rpmtd td)
Retrieve type of the container.
int rpmtdFromUint8(rpmtd td, rpmTagVal tag, uint8_t *data, rpm_count_t count)
Construct tag container from uint8_t pointer.
enum rpmTagType_e rpmTagType
The basic types of data in tags from headers.
rpmtdFormats_e
Definition: rpmtd.h:219
rpm_count_t rpmtdSize(rpmtd td)
Retrieve container data size (eg required for allocation).
rpm_data_t data
Definition: rpmtd.h:30
int rpmtdFromUint32(rpmtd td, rpmTagVal tag, uint32_t *data, rpm_count_t count)
Construct tag container from uint32_t pointer.
rpm_count_t rpmtdCount(rpmtd td)
Retrieve array size of the container.
rpm_tag_t tag
Definition: rpmtd.h:27
uint32_t rpmFlags
Definition: rpmtypes.h:42
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.
rpmtd rpmtdFree(rpmtd td)
Destroy tag data container.
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:26
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.
int rpmtdFromStringArray(rpmtd td, rpmTagVal tag, const char **data, rpm_count_t count)
Construct tag container from a string array.
int rpmtdSetTag(rpmtd td, rpmTagVal tag)
Set container tag and type.
int rpmtdFromUint64(rpmtd td, rpmTagVal tag, uint64_t *data, rpm_count_t count)
Construct tag container from uint64_t pointer.
Definition: argv.h:19
rpmtdFlags rpmtdGetFlags(rpmtd td)
Retrieve flags of the container (allocation details etc)
void rpmtdFreeData(rpmtd td)
Free contained data.