rpm 4.15.1

rpmtd.h
Go to the documentation of this file.
1 #ifndef _RPMTD_H
2 #define _RPMTD_H
3
10 #include <rpm/rpmtypes.h>
11 #include <rpm/argv.h>
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 enum rpmtdFlags_e {
18 RPMTD_NONE = 0,
19 RPMTD_ALLOCED = (1 << 0), /* was memory allocated? */
20 RPMTD_PTR_ALLOCED = (1 << 1), /* were array pointers allocated? */
21 RPMTD_IMMUTABLE = (1 << 2), /* header data or modifiable? */
22 RPMTD_ARGV = (1 << 3), /* string array is NULL-terminated? */
23 RPMTD_INVALID = (1 << 4), /* invalid data (in header) */
24 };
25
26 typedef rpmFlags rpmtdFlags;
27
32 struct rpmtd_s {
33 rpm_tag_t tag; /* rpm tag of this data entry*/
34 rpm_tagtype_t type; /* data type */
35 rpm_count_t count; /* number of entries */
36 rpm_data_t data; /* pointer to actual data */
37 rpmtdFlags flags; /* flags on memory allocation etc */
38 int ix; /* iteration index */
39 rpm_count_t size; /* size of data (only works for RPMTD_IMMUTABLE atm) */
40 };
41
46 rpmtd rpmtdNew(void);
47
53 rpmtd rpmtdFree(rpmtd td);
54
60 void rpmtdReset(rpmtd td);
61
67 void rpmtdFreeData(rpmtd td);
68
74 rpm_count_t rpmtdCount(rpmtd td);
75
82 rpm_count_t rpmtdSize(rpmtd td);
83
89 rpmTagVal rpmtdTag(rpmtd td);
90
96 rpmTagType rpmtdType(rpmtd td);
97
103 rpmTagClass rpmtdClass(rpmtd td);
104
110 rpmtdFlags rpmtdGetFlags(rpmtd td);
111
117 int rpmtdGetIndex(rpmtd td);
118
127 int rpmtdSetIndex(rpmtd td, int index);
128
134 int rpmtdInit(rpmtd td);
135
141 int rpmtdNext(rpmtd td);
142
148 uint32_t *rpmtdNextUint32(rpmtd td);
149
155 uint64_t *rpmtdNextUint64(rpmtd td);
156
162 const char *rpmtdNextString(rpmtd td);
163
172 char *rpmtdGetChar(rpmtd td);
173
182 uint16_t * rpmtdGetUint16(rpmtd td);
183
192 uint32_t * rpmtdGetUint32(rpmtd td);
193
202 uint64_t * rpmtdGetUint64(rpmtd td);
203
212 const char * rpmtdGetString(rpmtd td);
213
223 uint64_t rpmtdGetNumber(rpmtd td);
224
225 typedef enum rpmtdFormats_e {
226 RPMTD_FORMAT_STRING = 0, /* plain string (any type) */
227 RPMTD_FORMAT_ARMOR = 1, /* ascii armor format (bin types) */
228 RPMTD_FORMAT_BASE64 = 2, /* base64 encoding (bin types) */
229 RPMTD_FORMAT_PGPSIG = 3, /* pgp/gpg signature (bin types) */
230 RPMTD_FORMAT_DEPFLAGS = 4, /* dependency flags (int types) */
231 RPMTD_FORMAT_FFLAGS = 5, /* file flags (int types) */
232 RPMTD_FORMAT_PERMS = 6, /* permission string (int types) */
233 RPMTD_FORMAT_TRIGGERTYPE = 7, /* trigger types (int types) */
234 RPMTD_FORMAT_XML = 8, /* xml format (any type) */
235 RPMTD_FORMAT_OCTAL = 9, /* octal format (int types) */
236 RPMTD_FORMAT_HEX = 10, /* hex format (int types) */
237 RPMTD_FORMAT_DATE = 11, /* date format (int types) */
238 RPMTD_FORMAT_DAY = 12, /* day format (int types) */
239 RPMTD_FORMAT_SHESCAPE = 13, /* shell escaped (any type) */
240 RPMTD_FORMAT_ARRAYSIZE = 14, /* size of contained array (any type) */
241 RPMTD_FORMAT_DEPTYPE = 15, /* dependency types (int types) */
242 RPMTD_FORMAT_FSTATE = 16, /* file states (int types) */
243 RPMTD_FORMAT_VFLAGS = 17, /* file verify flags (int types) */
244 RPMTD_FORMAT_EXPAND = 18, /* macro expansion (string types) */
245 RPMTD_FORMAT_FSTATUS = 19, /* file verify status (int types) */
246 RPMTD_FORMAT_HUMANSI = 20, /* human readable value, K = 1000 (int types) */
247 RPMTD_FORMAT_HUMANIEC = 21, /* human readable value, K = 1024 (int types) */
248 } rpmtdFormats;
249
261 char *rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg);
262
271 int rpmtdSetTag(rpmtd td, rpmTagVal tag);
272
284 int rpmtdFromUint8(rpmtd td, rpmTagVal tag, uint8_t *data, rpm_count_t count);
285
296 int rpmtdFromUint16(rpmtd td, rpmTagVal tag, uint16_t *data, rpm_count_t count);
297
308 int rpmtdFromUint32(rpmtd td, rpmTagVal tag, uint32_t *data, rpm_count_t count);
309
320 int rpmtdFromUint64(rpmtd td, rpmTagVal tag, uint64_t *data, rpm_count_t count);
321
330 int rpmtdFromString(rpmtd td, rpmTagVal tag, const char *data);
331
342 int rpmtdFromStringArray(rpmtd td, rpmTagVal tag, const char **data, rpm_count_t count);
343
353 int rpmtdFromArgv(rpmtd td, rpmTagVal tag, ARGV_t argv);
354
364 int rpmtdFromArgi(rpmtd td, rpmTagVal tag, ARGI_t argi);
365
366 /* \ingroup rpmtd
367 * Perform deep copy of container.
368 * Create a modifiable copy of tag data container (on string arrays each
369 * string is separately allocated)
370 * @todo Only string arrays types are supported currently
371 * @param td Container to copy
372 * @return New container or NULL on error
373 */
374 rpmtd rpmtdDup(rpmtd td);
375
376 /* \ingroup rpmtd
377 * Push string array container contents to a string pool, return string ids.
378 * @param td Tag data container
379 * @param pool String pool
380 * @return Array of string id's (malloced)
381 */
382 rpmsid * rpmtdToPool(rpmtd td, rpmstrPool pool);
383
384 #ifdef __cplusplus
385 }
386 #endif
387
388 #endif /* _RPMTD_H */
rpmtd_s::tag
rpm_tag_t tag
Definition: rpmtd.h:33
rpmFlags
uint32_t rpmFlags
Definition: rpmtypes.h:42
rpm_count_t
uint32_t rpm_count_t
Definition: rpmtypes.h:29
RPMTD_FORMAT_FFLAGS
@ RPMTD_FORMAT_FFLAGS
Definition: rpmtd.h:231
rpm_tagtype_t
uint32_t rpm_tagtype_t
Definition: rpmtypes.h:28
rpmtdFlags
rpmFlags rpmtdFlags
Definition: rpmtd.h:26
RPMTD_FORMAT_PERMS
@ RPMTD_FORMAT_PERMS
Definition: rpmtd.h:232
rpmtdFormat
char * rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg)
RPMTD_IMMUTABLE
@ RPMTD_IMMUTABLE
Definition: rpmtd.h:21
rpmtdFromArgi
int rpmtdFromArgi(rpmtd td, rpmTagVal tag, ARGI_t argi)
RPMTD_FORMAT_FSTATUS
@ RPMTD_FORMAT_FSTATUS
Definition: rpmtd.h:245
rpmtdReset
void rpmtdReset(rpmtd td)
rpmtdGetNumber
uint64_t rpmtdGetNumber(rpmtd td)
rpmtdFromUint16
int rpmtdFromUint16(rpmtd td, rpmTagVal tag, uint16_t *data, rpm_count_t count)
rpmtdFromStringArray
int rpmtdFromStringArray(rpmtd td, rpmTagVal tag, const char **data, rpm_count_t count)
rpmtdTag
rpmTagVal rpmtdTag(rpmtd td)
rpmtdGetFlags
rpmtdFlags rpmtdGetFlags(rpmtd td)
RPMTD_FORMAT_ARRAYSIZE
@ RPMTD_FORMAT_ARRAYSIZE
Definition: rpmtd.h:240
rpmtdInit
int rpmtdInit(rpmtd td)
RPMTD_FORMAT_HUMANSI
@ RPMTD_FORMAT_HUMANSI
Definition: rpmtd.h:246
rpmstrPool
struct rpmstrPool_s * rpmstrPool
Definition: rpmtypes.h:83
RPMTD_FORMAT_DAY
@ RPMTD_FORMAT_DAY
Definition: rpmtd.h:238
RPMTD_ARGV
@ RPMTD_ARGV
Definition: rpmtd.h:22
rpmtd_s::flags
rpmtdFlags flags
Definition: rpmtd.h:37
RPMTD_FORMAT_SHESCAPE
@ RPMTD_FORMAT_SHESCAPE
Definition: rpmtd.h:239
ARGI_s
Definition: argv.h:21
rpmTagClass
enum rpmTagClass_e rpmTagClass
RPMTD_FORMAT_TRIGGERTYPE
@ RPMTD_FORMAT_TRIGGERTYPE
Definition: rpmtd.h:233
RPMTD_FORMAT_BASE64
@ RPMTD_FORMAT_BASE64
Definition: rpmtd.h:228
rpmtdFromUint64
int rpmtdFromUint64(rpmtd td, rpmTagVal tag, uint64_t *data, rpm_count_t count)
rpmtdFromString
int rpmtdFromString(rpmtd td, rpmTagVal tag, const char *data)
RPMTD_FORMAT_VFLAGS
@ RPMTD_FORMAT_VFLAGS
Definition: rpmtd.h:243
RPMTD_FORMAT_HEX
@ RPMTD_FORMAT_HEX
Definition: rpmtd.h:236
RPMTD_FORMAT_OCTAL
@ RPMTD_FORMAT_OCTAL
Definition: rpmtd.h:235
rpmtdSetIndex
int rpmtdSetIndex(rpmtd td, int index)
rpmsid
uint32_t rpmsid
Definition: rpmtypes.h:82
rpmtdGetUint64
uint64_t * rpmtdGetUint64(rpmtd td)
rpmtdGetUint16
uint16_t * rpmtdGetUint16(rpmtd td)
rpmtdGetIndex
int rpmtdGetIndex(rpmtd td)
RPMTD_FORMAT_DEPFLAGS
@ RPMTD_FORMAT_DEPFLAGS
Definition: rpmtd.h:230
rpmtd_s::ix
int ix
Definition: rpmtd.h:38
rpmtdSize
rpm_count_t rpmtdSize(rpmtd td)
ARGV_t
char ** ARGV_t
Definition: argv.h:17
RPMTD_PTR_ALLOCED
@ RPMTD_PTR_ALLOCED
Definition: rpmtd.h:20
rpmtdCount
rpm_count_t rpmtdCount(rpmtd td)
rpmtdFromUint8
int rpmtdFromUint8(rpmtd td, rpmTagVal tag, uint8_t *data, rpm_count_t count)
RPMTD_FORMAT_ARMOR
@ RPMTD_FORMAT_ARMOR
Definition: rpmtd.h:227
RPMTD_FORMAT_DATE
@ RPMTD_FORMAT_DATE
Definition: rpmtd.h:237
RPMTD_FORMAT_HUMANIEC
@ RPMTD_FORMAT_HUMANIEC
Definition: rpmtd.h:247
rpmtd_s::size
rpm_count_t size
Definition: rpmtd.h:39
rpmtdType
rpmTagType rpmtdType(rpmtd td)
rpmtdClass
rpmTagClass rpmtdClass(rpmtd td)
rpmtdGetChar
char * rpmtdGetChar(rpmtd td)
rpmtdNext
int rpmtdNext(rpmtd td)
rpm_tag_t
int32_t rpm_tag_t
Definition: rpmtypes.h:27
rpmtdFromUint32
int rpmtdFromUint32(rpmtd td, rpmTagVal tag, uint32_t *data, rpm_count_t count)
rpmtdFromArgv
int rpmtdFromArgv(rpmtd td, rpmTagVal tag, ARGV_t argv)
rpmtdNextUint32
uint32_t * rpmtdNextUint32(rpmtd td)
rpmtdFormats
enum rpmtdFormats_e rpmtdFormats
rpm_data_t
void * rpm_data_t
Definition: rpmtypes.h:33
rpmtd_s::type
rpm_tagtype_t type
Definition: rpmtd.h:34
rpmtd_s
Definition: rpmtd.h:32
RPMTD_FORMAT_FSTATE
@ RPMTD_FORMAT_FSTATE
Definition: rpmtd.h:242
rpmtdNextUint64
uint64_t * rpmtdNextUint64(rpmtd td)
rpmtdGetString
const char * rpmtdGetString(rpmtd td)
rpmtdNextString
const char * rpmtdNextString(rpmtd td)
rpmtdFreeData
void rpmtdFreeData(rpmtd td)
rpmTagVal
rpm_tag_t rpmTagVal
Definition: rpmtypes.h:30
rpmtdDup
rpmtd rpmtdDup(rpmtd td)
rpmtdToPool
rpmsid * rpmtdToPool(rpmtd td, rpmstrPool pool)
rpmtdFlags_e
rpmtdFlags_e
Definition: rpmtd.h:17
rpmtd_s::data
rpm_data_t data
Definition: rpmtd.h:36
RPMTD_NONE
@ RPMTD_NONE
Definition: rpmtd.h:18
rpmtdFormats_e
rpmtdFormats_e
Definition: rpmtd.h:225
RPMTD_ALLOCED
@ RPMTD_ALLOCED
Definition: rpmtd.h:19
rpmTagType
enum rpmTagType_e rpmTagType
RPMTD_FORMAT_STRING
@ RPMTD_FORMAT_STRING
Definition: rpmtd.h:226
RPMTD_FORMAT_EXPAND
@ RPMTD_FORMAT_EXPAND
Definition: rpmtd.h:244
RPMTD_FORMAT_DEPTYPE
@ RPMTD_FORMAT_DEPTYPE
Definition: rpmtd.h:241
rpmtdSetTag
int rpmtdSetTag(rpmtd td, rpmTagVal tag)
rpmtdGetUint32
uint32_t * rpmtdGetUint32(rpmtd td)
RPMTD_FORMAT_XML
@ RPMTD_FORMAT_XML
Definition: rpmtd.h:234
RPMTD_INVALID
@ RPMTD_INVALID
Definition: rpmtd.h:23
rpmtdFree
rpmtd rpmtdFree(rpmtd td)
rpmtd_s::count
rpm_count_t count
Definition: rpmtd.h:35
rpmtdNew
rpmtd rpmtdNew(void)
RPMTD_FORMAT_PGPSIG
@ RPMTD_FORMAT_PGPSIG
Definition: rpmtd.h:229