rpm  4.9.1.3
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 };
00018 
00019 typedef rpmFlags rpmtdFlags;
00020 
00025 struct rpmtd_s {
00026     rpm_tag_t tag;      /* rpm tag of this data entry*/
00027     rpm_tagtype_t type; /* data type */
00028     rpm_count_t count;  /* number of entries */
00029     rpm_data_t data;    /* pointer to actual data */
00030     rpmtdFlags flags;   /* flags on memory allocation etc */
00031     int ix;             /* iteration index */
00032 };
00033 
00038 rpmtd rpmtdNew(void);
00039 
00045 rpmtd rpmtdFree(rpmtd td);
00046  
00052 void rpmtdReset(rpmtd td);
00053 
00059 void rpmtdFreeData(rpmtd td);
00060 
00066 rpm_count_t rpmtdCount(rpmtd td);
00067 
00073 rpmTagVal rpmtdTag(rpmtd td);
00074 
00080 rpmTagType rpmtdType(rpmtd td);
00081 
00087 rpmTagClass rpmtdClass(rpmtd td);
00088 
00094 int rpmtdGetIndex(rpmtd td);
00095 
00104 int rpmtdSetIndex(rpmtd td, int index);
00105 
00111 int rpmtdInit(rpmtd td);
00112 
00118 int rpmtdNext(rpmtd td);
00119 
00125 uint32_t *rpmtdNextUint32(rpmtd td);
00126 
00132 uint64_t *rpmtdNextUint64(rpmtd td);
00133 
00139 const char *rpmtdNextString(rpmtd td);
00140 
00149 char *rpmtdGetChar(rpmtd td);
00150 
00159 uint16_t * rpmtdGetUint16(rpmtd td);
00160 
00169 uint32_t * rpmtdGetUint32(rpmtd td);
00170 
00179 uint64_t * rpmtdGetUint64(rpmtd td);
00180 
00189 const char * rpmtdGetString(rpmtd td);
00190 
00200 uint64_t rpmtdGetNumber(rpmtd td);
00201 
00202 typedef enum rpmtdFormats_e {
00203     RPMTD_FORMAT_STRING         = 0,    /* plain string (any type) */
00204     RPMTD_FORMAT_ARMOR          = 1,    /* ascii armor format (bin types) */
00205     RPMTD_FORMAT_BASE64         = 2,    /* base64 encoding (bin types) */
00206     RPMTD_FORMAT_PGPSIG         = 3,    /* pgp/gpg signature (bin types) */
00207     RPMTD_FORMAT_DEPFLAGS       = 4,    /* dependency flags (int types) */
00208     RPMTD_FORMAT_FFLAGS         = 5,    /* file flags (int types) */
00209     RPMTD_FORMAT_PERMS          = 6,    /* permission string (int types) */
00210     RPMTD_FORMAT_TRIGGERTYPE    = 7,    /* trigger types (int types) */
00211     RPMTD_FORMAT_XML            = 8,    /* xml format (any type) */
00212     RPMTD_FORMAT_OCTAL          = 9,    /* octal format (int types) */
00213     RPMTD_FORMAT_HEX            = 10,   /* hex format (int types) */
00214     RPMTD_FORMAT_DATE           = 11,   /* date format (int types) */
00215     RPMTD_FORMAT_DAY            = 12,   /* day format (int types) */
00216     RPMTD_FORMAT_SHESCAPE       = 13,   /* shell escaped (any type) */
00217     RPMTD_FORMAT_ARRAYSIZE      = 14,   /* size of contained array (any type) */
00218     RPMTD_FORMAT_DEPTYPE        = 15,   /* dependency types (int types) */
00219     RPMTD_FORMAT_FSTATE         = 16,   /* file states (int types) */
00220     RPMTD_FORMAT_VFLAGS         = 17,   /* file verify flags (int types) */
00221     RPMTD_FORMAT_EXPAND         = 18,   /* macro expansion (string types) */
00222     RPMTD_FORMAT_FSTATUS        = 19,   /* file verify status (int types) */
00223 } rpmtdFormats;
00224 
00236 char *rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg);
00237 
00246 int rpmtdSetTag(rpmtd td, rpmTagVal tag);
00247 
00259 int rpmtdFromUint8(rpmtd td, rpmTagVal tag, uint8_t *data, rpm_count_t count);
00260 
00271 int rpmtdFromUint16(rpmtd td, rpmTagVal tag, uint16_t *data, rpm_count_t count);
00272 
00283 int rpmtdFromUint32(rpmtd td, rpmTagVal tag, uint32_t *data, rpm_count_t count);
00284 
00295 int rpmtdFromUint64(rpmtd td, rpmTagVal tag, uint64_t *data, rpm_count_t count);
00296 
00305 int rpmtdFromString(rpmtd td, rpmTagVal tag, const char *data);
00306 
00317 int rpmtdFromStringArray(rpmtd td, rpmTagVal tag, const char **data, rpm_count_t count);
00318 
00328 int rpmtdFromArgv(rpmtd td, rpmTagVal tag, ARGV_t argv);
00329 
00339 int rpmtdFromArgi(rpmtd td, rpmTagVal tag, ARGI_t argi);
00340 
00341 /* \ingroup rpmtd
00342  * Perform deep copy of container.
00343  * Create a modifiable copy of tag data container (on string arrays each
00344  * string is separately allocated)
00345  * @todo                Only string arrays types are supported currently
00346  * @param td            Container to copy
00347  * @return              New container or NULL on error
00348  */
00349 rpmtd rpmtdDup(rpmtd td);
00350 
00351 #ifdef __cplusplus
00352 }
00353 #endif
00354 
00355 #endif /* _RPMTD_H */