rpm 4.10.90

- 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 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     RPMTD_INVALID       = (1 << 4),     /* invalid data (in header) */
    00018 };
    00019
    00020 typedef rpmFlags rpmtdFlags;
    00021
    00026 struct rpmtd_s {
    00027     rpm_tag_t tag;      /* rpm tag of this data entry*/
    00028     rpm_tagtype_t type; /* data type */
    00029     rpm_count_t count;  /* number of entries */
    00030     rpm_data_t data;    /* pointer to actual data */
    00031     rpmtdFlags flags;   /* flags on memory allocation etc */
    00032     int ix;             /* iteration index */
    00033 };
    00034
    00039 rpmtd rpmtdNew(void);
    00040
    00046 rpmtd rpmtdFree(rpmtd td);
    00047
    00053 void rpmtdReset(rpmtd td);
    00054
    00060 void rpmtdFreeData(rpmtd td);
    00061
    00067 rpm_count_t rpmtdCount(rpmtd td);
    00068
    00074 rpmTagVal rpmtdTag(rpmtd td);
    00075
    00081 rpmTagType rpmtdType(rpmtd td);
    00082
    00088 rpmTagClass rpmtdClass(rpmtd td);
    00089
    00095 rpmtdFlags rpmtdGetFlags(rpmtd td);
    00096
    00102 int rpmtdGetIndex(rpmtd td);
    00103
    00112 int rpmtdSetIndex(rpmtd td, int index);
    00113
    00119 int rpmtdInit(rpmtd td);
    00120
    00126 int rpmtdNext(rpmtd td);
    00127
    00133 uint32_t *rpmtdNextUint32(rpmtd td);
    00134
    00140 uint64_t *rpmtdNextUint64(rpmtd td);
    00141
    00147 const char *rpmtdNextString(rpmtd td);
    00148
    00157 char *rpmtdGetChar(rpmtd td);
    00158
    00167 uint16_t * rpmtdGetUint16(rpmtd td);
    00168
    00177 uint32_t * rpmtdGetUint32(rpmtd td);
    00178
    00187 uint64_t * rpmtdGetUint64(rpmtd td);
    00188
    00197 const char * rpmtdGetString(rpmtd td);
    00198
    00208 uint64_t rpmtdGetNumber(rpmtd td);
    00209
    00210 typedef enum rpmtdFormats_e {
    00211     RPMTD_FORMAT_STRING         = 0,    /* plain string (any type) */
    00212     RPMTD_FORMAT_ARMOR          = 1,    /* ascii armor format (bin types) */
    00213     RPMTD_FORMAT_BASE64         = 2,    /* base64 encoding (bin types) */
    00214     RPMTD_FORMAT_PGPSIG         = 3,    /* pgp/gpg signature (bin types) */
    00215     RPMTD_FORMAT_DEPFLAGS       = 4,    /* dependency flags (int types) */
    00216     RPMTD_FORMAT_FFLAGS         = 5,    /* file flags (int types) */
    00217     RPMTD_FORMAT_PERMS          = 6,    /* permission string (int types) */
    00218     RPMTD_FORMAT_TRIGGERTYPE    = 7,    /* trigger types (int types) */
    00219     RPMTD_FORMAT_XML            = 8,    /* xml format (any type) */
    00220     RPMTD_FORMAT_OCTAL          = 9,    /* octal format (int types) */
    00221     RPMTD_FORMAT_HEX            = 10,   /* hex format (int types) */
    00222     RPMTD_FORMAT_DATE           = 11,   /* date format (int types) */
    00223     RPMTD_FORMAT_DAY            = 12,   /* day format (int types) */
    00224     RPMTD_FORMAT_SHESCAPE       = 13,   /* shell escaped (any type) */
    00225     RPMTD_FORMAT_ARRAYSIZE      = 14,   /* size of contained array (any type) */
    00226     RPMTD_FORMAT_DEPTYPE        = 15,   /* dependency types (int types) */
    00227     RPMTD_FORMAT_FSTATE         = 16,   /* file states (int types) */
    00228     RPMTD_FORMAT_VFLAGS         = 17,   /* file verify flags (int types) */
    00229     RPMTD_FORMAT_EXPAND         = 18,   /* macro expansion (string types) */
    00230     RPMTD_FORMAT_FSTATUS        = 19,   /* file verify status (int types) */
    00231 } rpmtdFormats;
    00232
    00244 char *rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg);
    00245
    00254 int rpmtdSetTag(rpmtd td, rpmTagVal tag);
    00255
    00267 int rpmtdFromUint8(rpmtd td, rpmTagVal tag, uint8_t *data, rpm_count_t count);
    00268
    00279 int rpmtdFromUint16(rpmtd td, rpmTagVal tag, uint16_t *data, rpm_count_t count);
    00280
    00291 int rpmtdFromUint32(rpmtd td, rpmTagVal tag, uint32_t *data, rpm_count_t count);
    00292
    00303 int rpmtdFromUint64(rpmtd td, rpmTagVal tag, uint64_t *data, rpm_count_t count);
    00304
    00313 int rpmtdFromString(rpmtd td, rpmTagVal tag, const char *data);
    00314
    00325 int rpmtdFromStringArray(rpmtd td, rpmTagVal tag, const char **data, rpm_count_t count);
    00326
    00336 int rpmtdFromArgv(rpmtd td, rpmTagVal tag, ARGV_t argv);
    00337
    00347 int rpmtdFromArgi(rpmtd td, rpmTagVal tag, ARGI_t argi);
    00348
    00349 /* \ingroup rpmtd
    00350  * Perform deep copy of container.
    00351  * Create a modifiable copy of tag data container (on string arrays each
    00352  * string is separately allocated)
    00353  * @todo                Only string arrays types are supported currently
    00354  * @param td            Container to copy
    00355  * @return              New container or NULL on error
    00356  */
    00357 rpmtd rpmtdDup(rpmtd td);
    00358
    00359 /* \ingroup rpmtd
    00360  * Push string array container contents to a string pool, return string ids.
    00361  * @param td            Tag data container
    00362  * @param pool          String pool
    00363  * @return              Array of string id's (malloced)
    00364  */
    00365 rpmsid * rpmtdToPool(rpmtd td, rpmstrPool pool);
    00366
    00367 #ifdef __cplusplus
    00368 }
    00369 #endif
    00370
    00371 #endif /* _RPMTD_H */