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

# 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 } rpmtdFlags;
    00017
    00022 struct rpmtd_s {
    00023     rpmTag tag;         /* rpm tag of this data entry*/
    00024     rpmTagType type;    /* data type */
    00025     rpm_count_t count;  /* number of entries */
    00026     rpm_data_t data;    /* pointer to actual data */
    00027     rpmtdFlags flags;   /* flags on memory allocation etc */
    00028     int ix;             /* iteration index */
    00029 };
    00030
    00035 rpmtd rpmtdNew(void);
    00036
    00042 rpmtd rpmtdFree(rpmtd td);
    00043
    00049 void rpmtdReset(rpmtd td);
    00050
    00056 void rpmtdFreeData(rpmtd td);
    00057
    00063 rpm_count_t rpmtdCount(rpmtd td);
    00064
    00070 rpmTag rpmtdTag(rpmtd td);
    00071
    00077 rpmTagType rpmtdType(rpmtd td);
    00078
    00084 int rpmtdGetIndex(rpmtd td);
    00085
    00094 int rpmtdSetIndex(rpmtd td, int index);
    00095
    00101 int rpmtdInit(rpmtd td);
    00102
    00108 int rpmtdNext(rpmtd td);
    00109
    00115 uint32_t *rpmtdNextUint32(rpmtd td);
    00116
    00122 uint64_t *rpmtdNextUint64(rpmtd td);
    00123
    00129 const char *rpmtdNextString(rpmtd td);
    00130
    00139 char *rpmtdGetChar(rpmtd td);
    00140
    00149 uint16_t * rpmtdGetUint16(rpmtd td);
    00150
    00159 uint32_t * rpmtdGetUint32(rpmtd td);
    00160
    00169 uint64_t * rpmtdGetUint64(rpmtd td);
    00170
    00179 const char * rpmtdGetString(rpmtd td);
    00180
    00181 typedef enum rpmtdFormats_e {
    00182     RPMTD_FORMAT_STRING         = 0,    /* plain string (any type) */
    00183     RPMTD_FORMAT_ARMOR          = 1,    /* ascii armor format (bin types) */
    00184     RPMTD_FORMAT_BASE64         = 2,    /* base64 encoding (bin types) */
    00185     RPMTD_FORMAT_PGPSIG         = 3,    /* pgp/gpg signature (bin types) */
    00186     RPMTD_FORMAT_DEPFLAGS       = 4,    /* dependency flags (int32 types) */
    00187     RPMTD_FORMAT_FFLAGS         = 5,    /* file flags (int32 types) */
    00188     RPMTD_FORMAT_PERMS          = 6,    /* permission string (int32 types) */
    00189     RPMTD_FORMAT_TRIGGERTYPE    = 7,    /* trigger types */
    00190     RPMTD_FORMAT_XML            = 8,    /* xml format (any type) */
    00191     RPMTD_FORMAT_OCTAL          = 9,    /* octal format (int32 types) */
    00192     RPMTD_FORMAT_HEX            = 10,   /* hex format (int32 types) */
    00193     RPMTD_FORMAT_DATE           = 11,   /* date format (int32 types) */
    00194     RPMTD_FORMAT_DAY            = 12,   /* day format (int32 types) */
    00195     RPMTD_FORMAT_SHESCAPE       = 13,   /* shell escaped (any type) */
    00196     RPMTD_FORMAT_ARRAYSIZE      = 14,   /* size of contained array (any type) */
    00197 } rpmtdFormats;
    00198
    00210 char *rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg);
    00211
    00220 int rpmtdSetTag(rpmtd td, rpmTag tag);
    00221
    00233 int rpmtdFromUint8(rpmtd td, rpmTag tag, uint8_t *data, rpm_count_t count);
    00234
    00245 int rpmtdFromUint16(rpmtd td, rpmTag tag, uint16_t *data, rpm_count_t count);
    00246
    00257 int rpmtdFromUint32(rpmtd td, rpmTag tag, uint32_t *data, rpm_count_t count);
    00258
    00269 int rpmtdFromUint64(rpmtd td, rpmTag tag, uint64_t *data, rpm_count_t count);
    00270
    00279 int rpmtdFromString(rpmtd td, rpmTag tag, const char *data);
    00280
    00291 int rpmtdFromStringArray(rpmtd td, rpmTag tag, const char **data, rpm_count_t count);
    00292
    00302 int rpmtdFromArgv(rpmtd td, rpmTag tag, ARGV_t argv);
    00303
    00313 int rpmtdFromArgi(rpmtd td, rpmTag tag, ARGI_t argi);
    00314
    00315 /* \ingroup rpmtd
    00316  * Perform deep copy of container.
    00317  * Create a modifiable copy of tag data container (on string arrays each
    00318  * string is separately allocated)
    00319  * @todo                Only string arrays types are supported currently
    00320  * @param td            Container to copy
    00321  * @return              New container or NULL on error
    00322  */
    00323 rpmtd rpmtdDup(rpmtd td);
    00324
    00325 #ifdef __cplusplus
    00326 }
    00327 #endif
    00328
    00329 #endif /* _RPMTD_H */