rpmtd.h
Go to the documentation of this file.
#ifndef _RPMTD_H
#define _RPMTD_H
#include <rpm/rpmtypes.h>
#include <rpm/argv.h>
#ifdef __cplusplus
extern "C" {
#endif
enum rpmtdFlags_e {
RPMTD_NONE = 0,
RPMTD_ALLOCED = (1 << 0), /* was memory allocated? */
RPMTD_PTR_ALLOCED = (1 << 1), /* were array pointers allocated? */
RPMTD_IMMUTABLE = (1 << 2), /* header data or modifiable? */
RPMTD_ARGV = (1 << 3), /* string array is NULL-terminated? */
RPMTD_INVALID = (1 << 4), /* invalid data (in header) */
};
typedef rpmFlags rpmtdFlags;
struct rpmtd_s {
rpm_tag_t tag; /* rpm tag of this data entry*/
rpm_tagtype_t type; /* data type */
rpm_count_t count; /* number of entries */
rpm_data_t data; /* pointer to actual data */
rpmtdFlags flags; /* flags on memory allocation etc */
int ix; /* iteration index */
rpm_count_t size; /* size of data (only works for RPMTD_IMMUTABLE atm) */
};
rpmtd rpmtdNew(void);
rpmtd rpmtdFree(rpmtd td);
void rpmtdReset(rpmtd td);
void rpmtdFreeData(rpmtd td);
rpm_count_t rpmtdCount(rpmtd td);
rpm_count_t rpmtdSize(rpmtd td);
rpmTagVal rpmtdTag(rpmtd td);
rpmTagType rpmtdType(rpmtd td);
rpmTagClass rpmtdClass(rpmtd td);
rpmtdFlags rpmtdGetFlags(rpmtd td);
int rpmtdGetIndex(rpmtd td);
int rpmtdSetIndex(rpmtd td, int index);
int rpmtdInit(rpmtd td);
int rpmtdNext(rpmtd td);
uint32_t *rpmtdNextUint32(rpmtd td);
uint64_t *rpmtdNextUint64(rpmtd td);
const char *rpmtdNextString(rpmtd td);
char *rpmtdGetChar(rpmtd td);
uint16_t * rpmtdGetUint16(rpmtd td);
uint32_t * rpmtdGetUint32(rpmtd td);
uint64_t * rpmtdGetUint64(rpmtd td);
const char * rpmtdGetString(rpmtd td);
uint64_t rpmtdGetNumber(rpmtd td);
typedef enum rpmtdFormats_e {
RPMTD_FORMAT_STRING = 0, /* plain string (any type) */
RPMTD_FORMAT_ARMOR = 1, /* ascii armor format (bin types) */
RPMTD_FORMAT_BASE64 = 2, /* base64 encoding (bin types) */
RPMTD_FORMAT_PGPSIG = 3, /* pgp/gpg signature (bin types) */
RPMTD_FORMAT_DEPFLAGS = 4, /* dependency flags (int types) */
RPMTD_FORMAT_FFLAGS = 5, /* file flags (int types) */
RPMTD_FORMAT_PERMS = 6, /* permission string (int types) */
RPMTD_FORMAT_TRIGGERTYPE = 7, /* trigger types (int types) */
RPMTD_FORMAT_XML = 8, /* xml format (any type) */
RPMTD_FORMAT_OCTAL = 9, /* octal format (int types) */
RPMTD_FORMAT_HEX = 10, /* hex format (int types) */
RPMTD_FORMAT_DATE = 11, /* date format (int types) */
RPMTD_FORMAT_DAY = 12, /* day format (int types) */
RPMTD_FORMAT_SHESCAPE = 13, /* shell escaped (any type) */
RPMTD_FORMAT_ARRAYSIZE = 14, /* size of contained array (any type) */
RPMTD_FORMAT_DEPTYPE = 15, /* dependency types (int types) */
RPMTD_FORMAT_FSTATE = 16, /* file states (int types) */
RPMTD_FORMAT_VFLAGS = 17, /* file verify flags (int types) */
RPMTD_FORMAT_EXPAND = 18, /* macro expansion (string types) */
RPMTD_FORMAT_FSTATUS = 19, /* file verify status (int types) */
} rpmtdFormats;
char *rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg);
int rpmtdSetTag(rpmtd td, rpmTagVal tag);
int rpmtdFromUint8(rpmtd td, rpmTagVal tag, uint8_t *data, rpm_count_t count);
int rpmtdFromUint16(rpmtd td, rpmTagVal tag, uint16_t *data, rpm_count_t count);
int rpmtdFromUint32(rpmtd td, rpmTagVal tag, uint32_t *data, rpm_count_t count);
int rpmtdFromUint64(rpmtd td, rpmTagVal tag, uint64_t *data, rpm_count_t count);
int rpmtdFromString(rpmtd td, rpmTagVal tag, const char *data);
int rpmtdFromStringArray(rpmtd td, rpmTagVal tag, const char **data, rpm_count_t count);
int rpmtdFromArgv(rpmtd td, rpmTagVal tag, ARGV_t argv);
int rpmtdFromArgi(rpmtd td, rpmTagVal tag, ARGI_t argi);
/* \ingroup rpmtd
* Perform deep copy of container.
* Create a modifiable copy of tag data container (on string arrays each
* string is separately allocated)
* @todo Only string arrays types are supported currently
* @param td Container to copy
* @return New container or NULL on error
*/
rpmtd rpmtdDup(rpmtd td);
/* \ingroup rpmtd
* Push string array container contents to a string pool, return string ids.
* @param td Tag data container
* @param pool String pool
* @return Array of string id's (malloced)
*/
rpmsid * rpmtdToPool(rpmtd td, rpmstrPool pool);
#ifdef __cplusplus
}
#endif
#endif /* _RPMTD_H */
rpmtdFromArgv
int rpmtdFromArgv(rpmtd td, rpmTagVal tag, ARGV_t argv)
Construct tag container from ARGV_t array.
RPMTD_FORMAT_PGPSIG
Definition: rpmtd.h:223
rpmtdNextUint64
uint64_t * rpmtdNextUint64(rpmtd td)
Iterate over uint64_t type tag data container.
RPMTD_FORMAT_VFLAGS
Definition: rpmtd.h:237
rpmtdGetUint16
uint16_t * rpmtdGetUint16(rpmtd td)
Return uint16_t data from tag container.
RPMTD_FORMAT_OCTAL
Definition: rpmtd.h:229
ARGV_t
char ** ARGV_t
Definition: argv.h:15
RPMTD_ALLOCED
Definition: rpmtd.h:13
rpm_count_t
uint32_t rpm_count_t
Definition: rpmtypes.h:29
rpmtdToPool
rpmsid * rpmtdToPool(rpmtd td, rpmstrPool pool)
rpmtdGetChar
char * rpmtdGetChar(rpmtd td)
Return char data from tag container.
rpmtd_s::count
rpm_count_t count
Definition: rpmtd.h:29
rpmtdGetIndex
int rpmtdGetIndex(rpmtd td)
Retrieve current iteration index of the container.
rpmtdNext
int rpmtdNext(rpmtd td)
Iterate over tag data container.
rpmtd_s::size
rpm_count_t size
Definition: rpmtd.h:33
rpmtdFlags
rpmFlags rpmtdFlags
Definition: rpmtd.h:20
rpmtdFormats
enum rpmtdFormats_e rpmtdFormats
RPMTD_FORMAT_SHESCAPE
Definition: rpmtd.h:233
rpm_tagtype_t
uint32_t rpm_tagtype_t
Definition: rpmtypes.h:28
RPMTD_FORMAT_ARRAYSIZE
Definition: rpmtd.h:234
rpmtdGetNumber
uint64_t rpmtdGetNumber(rpmtd td)
Return numeric value from tag container.
rpmtdInit
int rpmtdInit(rpmtd td)
Initialize tag container for iteration.
rpmtdGetUint64
uint64_t * rpmtdGetUint64(rpmtd td)
Return uint64_t data from tag container.
RPMTD_INVALID
Definition: rpmtd.h:17
RPMTD_FORMAT_DAY
Definition: rpmtd.h:232
rpm_tag_t
int32_t rpm_tag_t
Definition: rpmtypes.h:27
RPMTD_FORMAT_TRIGGERTYPE
Definition: rpmtd.h:227
rpmtdClass
rpmTagClass rpmtdClass(rpmtd td)
Retrieve class of the container.
rpmtd_s::type
rpm_tagtype_t type
Definition: rpmtd.h:28
RPMTD_FORMAT_DATE
Definition: rpmtd.h:231
rpmtdNew
rpmtd rpmtdNew(void)
Create new tag data container.
rpmtdFromArgi
int rpmtdFromArgi(rpmtd td, rpmTagVal tag, ARGI_t argi)
Construct tag container from ARGI_t array.
rpmTagVal
rpm_tag_t rpmTagVal
Definition: rpmtypes.h:30
RPMTD_FORMAT_STRING
Definition: rpmtd.h:220
rpmtdFromString
int rpmtdFromString(rpmtd td, rpmTagVal tag, const char *data)
Construct tag container from a string.
rpmtd_s::flags
rpmtdFlags flags
Definition: rpmtd.h:31
RPMTD_FORMAT_FSTATUS
Definition: rpmtd.h:239
RPMTD_IMMUTABLE
Definition: rpmtd.h:15
rpm_data_t
void * rpm_data_t
Definition: rpmtypes.h:33
rpmtdTag
rpmTagVal rpmtdTag(rpmtd td)
Retrieve tag of the container.
rpmtdFromUint16
int rpmtdFromUint16(rpmtd td, rpmTagVal tag, uint16_t *data, rpm_count_t count)
Construct tag container from uint16_t pointer.
rpmstrPool
struct rpmstrPool_s * rpmstrPool
Definition: rpmtypes.h:83
rpmsid
uint32_t rpmsid
Definition: rpmtypes.h:82
rpmtd_s::ix
int ix
Definition: rpmtd.h:32
RPMTD_NONE
Definition: rpmtd.h:12
rpmtdType
rpmTagType rpmtdType(rpmtd td)
Retrieve type of the container.
rpmtdFromUint8
int rpmtdFromUint8(rpmtd td, rpmTagVal tag, uint8_t *data, rpm_count_t count)
Construct tag container from uint8_t pointer.
rpmTagType
enum rpmTagType_e rpmTagType
The basic types of data in tags from headers.
RPMTD_FORMAT_HEX
Definition: rpmtd.h:230
RPMTD_FORMAT_DEPTYPE
Definition: rpmtd.h:235
rpmtdFormats_e
rpmtdFormats_e
Definition: rpmtd.h:219
rpmtdSize
rpm_count_t rpmtdSize(rpmtd td)
Retrieve container data size (eg required for allocation).
RPMTD_PTR_ALLOCED
Definition: rpmtd.h:14
RPMTD_FORMAT_DEPFLAGS
Definition: rpmtd.h:224
rpmtd_s::data
rpm_data_t data
Definition: rpmtd.h:30
RPMTD_FORMAT_FFLAGS
Definition: rpmtd.h:225
rpmtdFromUint32
int rpmtdFromUint32(rpmtd td, rpmTagVal tag, uint32_t *data, rpm_count_t count)
Construct tag container from uint32_t pointer.
RPMTD_ARGV
Definition: rpmtd.h:16
rpmtdCount
rpm_count_t rpmtdCount(rpmtd td)
Retrieve array size of the container.
rpmtd_s::tag
rpm_tag_t tag
Definition: rpmtd.h:27
rpmFlags
uint32_t rpmFlags
Definition: rpmtypes.h:42
RPMTD_FORMAT_BASE64
Definition: rpmtd.h:222
rpmtdGetUint32
uint32_t * rpmtdGetUint32(rpmtd td)
Return uint32_t data from tag container.
rpmtdNextUint32
uint32_t * rpmtdNextUint32(rpmtd td)
Iterate over uint32_t type tag data container.
rpmtdReset
void rpmtdReset(rpmtd td)
(Re-)initialize tag data container.
RPMTD_FORMAT_ARMOR
Definition: rpmtd.h:221
rpmtdFree
rpmtd rpmtdFree(rpmtd td)
Destroy tag data container.
rpmtdDup
rpmtd rpmtdDup(rpmtd td)
RPMTD_FORMAT_FSTATE
Definition: rpmtd.h:236
rpmtdGetString
const char * rpmtdGetString(rpmtd td)
Return string data from tag container.
rpmTagClass
enum rpmTagClass_e rpmTagClass
The classes of data in tags from headers.
RPMTD_FORMAT_XML
Definition: rpmtd.h:228
rpmtdFlags_e
rpmtdFlags_e
Definition: rpmtd.h:11
RPMTD_FORMAT_EXPAND
Definition: rpmtd.h:238
rpmtd_s
Container for rpm tag data (from headers or extensions).
Definition: rpmtd.h:26
RPMTD_FORMAT_PERMS
Definition: rpmtd.h:226
rpmtdNextString
const char * rpmtdNextString(rpmtd td)
Iterate over string / string array type tag data container.
rpmtdSetIndex
int rpmtdSetIndex(rpmtd td, int index)
Set iteration index of the container.
rpmtdFormat
char * rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg)
Format data from tag container to string presentation of given format.
rpmtdFromStringArray
int rpmtdFromStringArray(rpmtd td, rpmTagVal tag, const char **data, rpm_count_t count)
Construct tag container from a string array.
rpmtdSetTag
int rpmtdSetTag(rpmtd td, rpmTagVal tag)
Set container tag and type.
rpmtdFromUint64
int rpmtdFromUint64(rpmtd td, rpmTagVal tag, uint64_t *data, rpm_count_t count)
Construct tag container from uint64_t pointer.
ARGI_s
Definition: argv.h:19
rpmtdGetFlags
rpmtdFlags rpmtdGetFlags(rpmtd td)
Retrieve flags of the container (allocation details etc)
rpmtdFreeData
void rpmtdFreeData(rpmtd td)
Free contained data.