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 */
};
rpmtd rpmtdNew(void);
rpmtd rpmtdFree(rpmtd td);
void rpmtdReset(rpmtd td);
void rpmtdFreeData(rpmtd td);
rpm_count_t rpmtdCount(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 */