- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# rpmtd.h

Go to the documentation of this file.

    00001 #ifndef _RPMTD_H
    00002 #define _RPMTD_H
    00003
    00004 #include <rpm/rpmtypes.h>
    00005 #include <rpm/argv.h>
    00006
    00007 #ifdef __cplusplus
    00008 extern "C" {
    00009 #endif
    00010
    00011 typedef enum rpmtdFlags_e {
    00012     RPMTD_NONE          = 0,
    00013     RPMTD_ALLOCED       = (1 << 0),     /* was memory allocated? */
    00014     RPMTD_PTR_ALLOCED   = (1 << 1),     /* were array pointers allocated? */
    00015     RPMTD_IMMUTABLE     = (1 << 2),     /* header data or modifiable? */
    00016     RPMTD_ARGV          = (1 << 3),     /* string array is NULL-terminated? */
    00017 } rpmtdFlags;
    00018
    00023 struct rpmtd_s {
    00024     rpmTag tag;         /* rpm tag of this data entry*/
    00025     rpmTagType type;    /* data type */
    00026     rpm_count_t count;  /* number of entries */
    00027     rpm_data_t data;    /* pointer to actual data */
    00028     rpmtdFlags flags;   /* flags on memory allocation etc */
    00029     int ix;             /* iteration index */
    00030 };
    00031
    00036 rpmtd rpmtdNew(void);
    00037
    00043 rpmtd rpmtdFree(rpmtd td);
    00044
    00050 void rpmtdReset(rpmtd td);
    00051
    00057 void rpmtdFreeData(rpmtd td);
    00058
    00064 rpm_count_t rpmtdCount(rpmtd td);
    00065
    00071 rpmTag rpmtdTag(rpmtd td);
    00072
    00078 rpmTagType rpmtdType(rpmtd td);
    00079
    00085 rpmTagClass rpmtdClass(rpmtd td);
    00086
    00092 int rpmtdGetIndex(rpmtd td);
    00093
    00102 int rpmtdSetIndex(rpmtd td, int index);
    00103
    00109 int rpmtdInit(rpmtd td);
    00110
    00116 int rpmtdNext(rpmtd td);
    00117
    00123 uint32_t *rpmtdNextUint32(rpmtd td);
    00124
    00130 uint64_t *rpmtdNextUint64(rpmtd td);
    00131
    00137 const char *rpmtdNextString(rpmtd td);
    00138
    00147 char *rpmtdGetChar(rpmtd td);
    00148
    00157 uint16_t * rpmtdGetUint16(rpmtd td);
    00158
    00167 uint32_t * rpmtdGetUint32(rpmtd td);
    00168
    00177 uint64_t * rpmtdGetUint64(rpmtd td);
    00178
    00187 const char * rpmtdGetString(rpmtd td);
    00188
    00198 uint64_t rpmtdGetNumber(rpmtd td);
    00199
    00200 typedef enum rpmtdFormats_e {
    00201     RPMTD_FORMAT_STRING         = 0,    /* plain string (any type) */
    00202     RPMTD_FORMAT_ARMOR          = 1,    /* ascii armor format (bin types) */
    00203     RPMTD_FORMAT_BASE64         = 2,    /* base64 encoding (bin types) */
    00204     RPMTD_FORMAT_PGPSIG         = 3,    /* pgp/gpg signature (bin types) */
    00205     RPMTD_FORMAT_DEPFLAGS       = 4,    /* dependency flags (int32 types) */
    00206     RPMTD_FORMAT_FFLAGS         = 5,    /* file flags (int32 types) */
    00207     RPMTD_FORMAT_PERMS          = 6,    /* permission string (int32 types) */
    00208     RPMTD_FORMAT_TRIGGERTYPE    = 7,    /* trigger types */
    00209     RPMTD_FORMAT_XML            = 8,    /* xml format (any type) */
    00210     RPMTD_FORMAT_OCTAL          = 9,    /* octal format (int32 types) */
    00211     RPMTD_FORMAT_HEX            = 10,   /* hex format (int32 types) */
    00212     RPMTD_FORMAT_DATE           = 11,   /* date format (int32 types) */
    00213     RPMTD_FORMAT_DAY            = 12,   /* day format (int32 types) */
    00214     RPMTD_FORMAT_SHESCAPE       = 13,   /* shell escaped (any type) */
    00215     RPMTD_FORMAT_ARRAYSIZE      = 14,   /* size of contained array (any type) */
    00216     RPMTD_FORMAT_DEPTYPE        = 15,   /* dependency types (int32 types) */
    00217 } rpmtdFormats;
    00218
    00230 char *rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg);
    00231
    00240 int rpmtdSetTag(rpmtd td, rpmTag tag);
    00241
    00253 int rpmtdFromUint8(rpmtd td, rpmTag tag, uint8_t *data, rpm_count_t count);
    00254
    00265 int rpmtdFromUint16(rpmtd td, rpmTag tag, uint16_t *data, rpm_count_t count);
    00266
    00277 int rpmtdFromUint32(rpmtd td, rpmTag tag, uint32_t *data, rpm_count_t count);
    00278
    00289 int rpmtdFromUint64(rpmtd td, rpmTag tag, uint64_t *data, rpm_count_t count);
    00290
    00299 int rpmtdFromString(rpmtd td, rpmTag tag, const char *data);
    00300
    00311 int rpmtdFromStringArray(rpmtd td, rpmTag tag, const char **data, rpm_count_t count);
    00312
    00322 int rpmtdFromArgv(rpmtd td, rpmTag tag, ARGV_t argv);
    00323
    00333 int rpmtdFromArgi(rpmtd td, rpmTag tag, ARGI_t argi);
    00334
    00335 /* \ingroup rpmtd
    00336  * Perform deep copy of container.
    00337  * Create a modifiable copy of tag data container (on string arrays each
    00338  * string is separately allocated)
    00339  * @todo                Only string arrays types are supported currently
    00340  * @param td            Container to copy
    00341  * @return              New container or NULL on error
    00342  */
    00343 rpmtd rpmtdDup(rpmtd td);
    00344
    00345 #ifdef __cplusplus
    00346 }
    00347 #endif
    00348
    00349 #endif /* _RPMTD_H */