00001 #ifndef H_HEADER
00002 #define H_HEADER
00003
00080
00081
00082 #include "rpmio.h"
00083
00084 #ifdef __cplusplus
00085 extern "C" {
00086 #endif
00087
00088
00089 typedef long long int int_64;
00090 typedef int int_32;
00091 typedef short int int_16;
00092 typedef char int_8;
00093
00094
00095 typedef unsigned long long int uint_64;
00096 typedef unsigned int uint_32;
00097 typedef unsigned short uint_16;
00098 typedef unsigned char uint_8;
00099
00102 typedef const char * errmsg_t;
00103
00106 typedef struct headerToken_s * Header;
00107
00111 enum rpmTagType_e {
00112 RPM_NULL_TYPE = 0,
00113 RPM_CHAR_TYPE = 1,
00114 RPM_INT8_TYPE = 2,
00115 RPM_INT16_TYPE = 3,
00116 RPM_INT32_TYPE = 4,
00117 RPM_INT64_TYPE = 5,
00118 RPM_STRING_TYPE = 6,
00119 RPM_BIN_TYPE = 7,
00120 RPM_STRING_ARRAY_TYPE = 8,
00121 RPM_I18NSTRING_TYPE = 9,
00122 RPM_ASN1_TYPE = 10,
00123 RPM_OPENPGP_TYPE = 11,
00124 RPM_MASK_TYPE = 0x0000ffff
00125 };
00126 #define RPM_MIN_TYPE 0
00127 #define RPM_MAX_TYPE 11
00128
00129 #define RPM_UINT8_TYPE RPM_INT8_TYPE
00130 #define RPM_UINT16_TYPE RPM_INT16_TYPE
00131 #define RPM_UINT32_TYPE RPM_INT32_TYPE
00132 #define RPM_UINT64_TYPE RPM_INT64_TYPE
00133
00136 typedef enum rpmTagType_e rpmTagType;
00137
00140 typedef union rpmDataType_u rpmTagData;
00141
00144 typedef int_32 rpmTagCount;
00145
00148 typedef struct _HE_s * HE_t;
00149
00152
00153 typedef union rpmDataType_u hRET_t;
00154 #if !defined(SWIG)
00155 union rpmDataType_u {
00156 void * ptr;
00157 int_8 * i8p;
00158 int_32 * i32p;
00159 int_16 * i16p;
00160 int_64 * i64p;
00161 const char * str;
00162 unsigned char * blob;
00163 const char ** argv;
00164 uint_8 * ui8p;
00165 uint_16 * ui16p;
00166 uint_32 * ui32p;
00167 uint_64 * ui64p;
00168 HE_t * he;
00169 };
00170 #endif
00171
00172
00175 typedef int_32 * hTAG_t;
00176 #ifdef NOTYET
00177 typedef rpmTagType * hTYP_t;
00178 typedef rpmTagData * hPTR_t;
00179 typedef rpmTagCount * hCNT_t;
00180 #else
00181 typedef int_32 * hTYP_t;
00182 typedef const void * hPTR_t;
00183 typedef int_32 * hCNT_t;
00184 #endif
00185
00188
00189 #if !defined(SWIG)
00190 struct _HE_s {
00191 int_32 tag;
00192 rpmTagType t;
00193
00194 rpmTagData p;
00195 rpmTagCount c;
00196 int ix;
00197 unsigned int freeData : 1;
00198 unsigned int avail : 1;
00199 unsigned int append : 1;
00200 };
00201 typedef struct _HE_s HE_s;
00202 #endif
00203
00204
00207 typedef struct headerIterator_s * HeaderIterator;
00208
00212 typedef struct headerTagTableEntry_s * headerTagTableEntry;
00213 #if !defined(SWIG)
00214 struct headerTagTableEntry_s {
00215
00216 const char * name;
00217 int val;
00218 int type;
00219 };
00220 #endif
00221
00224 typedef struct headerTagIndices_s * headerTagIndices;
00225 #if !defined(SWIG)
00226 struct headerTagIndices_s {
00227 int (*loadIndex) (headerTagTableEntry ** ipp, int * np,
00228 int (*cmp) (const void * avp, const void * bvp))
00229 ;
00230
00231 headerTagTableEntry * byName;
00232 int byNameSize;
00233 int (*byNameCmp) (const void * avp, const void * bvp)
00234 ;
00235 int (*tagValue) (const char * name)
00236 ;
00237
00238 headerTagTableEntry * byValue;
00239 int byValueSize;
00240 int (*byValueCmp) (const void * avp, const void * bvp)
00241 ;
00242 const char * (*tagName) (int value)
00243 ;
00244 int (*tagType) (int value)
00245 ;
00246 };
00247 #endif
00248
00251 enum headerSprintfExtensionType {
00252 HEADER_EXT_LAST = 0,
00253 HEADER_EXT_FORMAT,
00254 HEADER_EXT_MORE,
00255 HEADER_EXT_TAG
00256 };
00257
00264 typedef char * (*headerTagFormatFunction) (HE_t he, const char ** av)
00265 ;
00266
00275 typedef int (*headerTagTagFunction) (Header h, HE_t he)
00276 ;
00277
00281 typedef struct headerSprintfExtension_s * headerSprintfExtension;
00282 #if !defined(SWIG)
00283 struct headerSprintfExtension_s {
00284 enum headerSprintfExtensionType type;
00285
00286 const char * name;
00287 union {
00288
00289 void * generic;
00290 headerTagFormatFunction fmtFunction;
00291 headerTagTagFunction tagFunction;
00292 struct headerSprintfExtension_s * more;
00293 } u;
00294 };
00295 #endif
00296
00300
00301
00302 extern const struct headerSprintfExtension_s headerDefaultFormats[];
00303
00304
00308 enum hMagic {
00309 HEADER_MAGIC_NO = 0,
00310 HEADER_MAGIC_YES = 1
00311 };
00312
00321
00322 typedef enum rpmSubTagType_e {
00323 RPM_REGION_TYPE = -10,
00324 RPM_BIN_ARRAY_TYPE = -11,
00327 RPM_XREF_TYPE = -12
00330 } rpmSubTagType;
00331
00332
00336
00337 typedef enum rpmTagReturnType_e {
00338 RPM_ANY_RETURN_TYPE = 0,
00339 RPM_SCALAR_RETURN_TYPE = 0x00010000,
00340 RPM_ARRAY_RETURN_TYPE = 0x00020000,
00341 RPM_MAPPING_RETURN_TYPE = 0x00040000,
00342 RPM_MASK_RETURN_TYPE = 0xffff0000
00343 } rpmTagReturnType;
00344
00345
00350 #define HEADER_IMAGE 61
00351 #define HEADER_SIGNATURES 62
00352 #define HEADER_IMMUTABLE 63
00353 #define HEADER_REGIONS 64
00354 #define HEADER_I18NTABLE 100
00355 #define HEADER_SIGBASE 256
00356 #define HEADER_TAGBASE 1000
00357
00365 typedef
00366 void * (*HFD_t) ( const void * data, rpmTagType type)
00367 ;
00368
00383 typedef int (*HGE_t) (Header h, int_32 tag,
00384 rpmTagType * type,
00385 void * p,
00386 int_32 * c)
00387 ;
00388
00404 typedef int (*HAE_t) (Header h, int_32 tag, rpmTagType type,
00405 const void * p, int_32 c)
00406 ;
00407
00419 typedef int (*HME_t) (Header h, int_32 tag, rpmTagType type,
00420 const void * p, int_32 c)
00421 ;
00422
00433 typedef int (*HRE_t) (Header h, int_32 tag)
00434 ;
00435
00440 typedef
00441 Header (*HDRnew) (void)
00442 ;
00443
00449 typedef
00450 Header (*HDRfree) ( Header h)
00451 ;
00452
00458 typedef
00459 Header (*HDRlink) (Header h)
00460 ;
00461
00467 typedef
00468 Header (*HDRunlink) ( Header h)
00469 ;
00470
00476 typedef
00477 void (*HDRsort) (Header h)
00478 ;
00479
00485 typedef
00486 void (*HDRunsort) (Header h)
00487 ;
00488
00495 typedef
00496 unsigned int (*HDRsizeof) ( Header h, enum hMagic magicp)
00497 ;
00498
00504 typedef
00505 void * (*HDRunload) (Header h)
00506 ;
00507
00515 typedef
00516 Header (*HDRreload) ( Header h, int tag)
00517 ;
00518
00524 typedef
00525 Header (*HDRcopy) (Header h)
00526 ;
00527
00533 typedef
00534 Header (*HDRload) ( void * uh)
00535 ;
00536
00542 typedef
00543 Header (*HDRcopyload) (const void * uh)
00544 ;
00545
00552 typedef
00553 Header (*HDRread) (void * _fd, enum hMagic magicp)
00554 ;
00555
00563 typedef
00564 int (*HDRwrite) (void * _fd, Header h, enum hMagic magicp)
00565
00566 ;
00567
00574 typedef
00575 int (*HDRisentry) (Header h, int_32 tag)
00576 ;
00577
00585 typedef
00586 void * (*HDRfreetag) (Header h,
00587 const void * data, rpmTagType type)
00588 ;
00589
00600 typedef
00601 int (*HDRext) (Header h, int_32 tag,
00602 hTYP_t type,
00603 hRET_t * p,
00604 hCNT_t c)
00605 ;
00606
00620 typedef
00621 int (*HDRget) (Header h, int_32 tag,
00622 hTYP_t type,
00623 void * p,
00624 hCNT_t c)
00625 ;
00626
00639 typedef
00640 int (*HDRgetmin) (Header h, int_32 tag,
00641 hTYP_t type,
00642 void * p,
00643 hCNT_t c)
00644 ;
00645
00660 typedef
00661 int (*HDRadd) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00662 ;
00663
00678 typedef
00679 int (*HDRappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00680 ;
00681
00692 typedef
00693 int (*HDRaddorappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00694 ;
00695
00716 typedef
00717 int (*HDRaddi18n) (Header h, int_32 tag, const char * string,
00718 const char * lang)
00719 ;
00720
00731 typedef
00732 int (*HDRmodify) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00733 ;
00734
00744 typedef
00745 int (*HDRremove) (Header h, int_32 tag)
00746 ;
00747
00759 typedef
00760 char * (*HDRsprintf) (Header h, const char * fmt,
00761 const struct headerTagTableEntry_s * tags,
00762 const struct headerSprintfExtension_s * exts,
00763 errmsg_t * errmsg)
00764 ;
00765
00772 typedef
00773 void (*HDRcopytags) (Header headerFrom, Header headerTo, hTAG_t tagstocopy)
00774 ;
00775
00781 typedef
00782 HeaderIterator (*HDRfreeiter) ( HeaderIterator hi)
00783 ;
00784
00790 typedef
00791 HeaderIterator (*HDRinititer) (Header h)
00792 ;
00793
00803 typedef
00804 int (*HDRnextiter) (HeaderIterator hi,
00805 hTAG_t tag,
00806 hTYP_t type,
00807 hPTR_t * p,
00808 hCNT_t c)
00809 ;
00810
00818 typedef
00819 int (*HDRgetmagic)( Header h, unsigned char **magicp, size_t *nmagicp)
00820 ;
00821
00829 typedef
00830 int (*HDRsetmagic)( Header h, unsigned char * magic, size_t nmagic)
00831 ;
00832
00838 typedef
00839 const char * (*HDRgetorigin) ( Header h)
00840 ;
00841
00848 typedef
00849 int (*HDRsetorigin) ( Header h, const char * origin)
00850 ;
00851
00857 typedef
00858 int (*HDRgetinstance) ( Header h)
00859 ;
00860
00867 typedef
00868 int (*HDRsetinstance) ( Header h, int instance)
00869 ;
00870
00877 typedef
00878 void * (*HDRgetstats) (Header h, int opx)
00879 ;
00880
00884 typedef struct HV_s * HV_t;
00885 #if !defined(SWIG)
00886 struct HV_s {
00887 HDRlink hdrlink;
00888 HDRunlink hdrunlink;
00889 HDRfree hdrfree;
00890 HDRnew hdrnew;
00891 HDRsort hdrsort;
00892 HDRunsort hdrunsort;
00893 HDRsizeof hdrsizeof;
00894 HDRunload hdrunload;
00895 HDRreload hdrreload;
00896 HDRcopy hdrcopy;
00897 HDRload hdrload;
00898 HDRcopyload hdrcopyload;
00899 HDRread hdrread;
00900 HDRwrite hdrwrite;
00901 HDRisentry hdrisentry;
00902 HDRfreetag hdrfreetag;
00903 HDRget hdrget;
00904 HDRgetmin hdrgetmin;
00905 HDRadd hdradd;
00906 HDRappend hdrappend;
00907 HDRaddorappend hdraddorappend;
00908 HDRaddi18n hdraddi18n;
00909 HDRmodify hdrmodify;
00910 HDRremove hdrremove;
00911 HDRsprintf hdrsprintf;
00912 HDRcopytags hdrcopytags;
00913 HDRfreeiter hdrfreeiter;
00914 HDRinititer hdrinititer;
00915 HDRnextiter hdrnextiter;
00916 HDRgetorigin hdrgetorigin;
00917 HDRsetorigin hdrsetorigin;
00918 HDRgetinstance hdrgetinstance;
00919 HDRsetinstance hdrsetinstance;
00920
00921 void * hdrvecs;
00922
00923 void * hdrdata;
00924 int hdrversion;
00925 };
00926 #endif
00927
00928 #if !defined(SWIG)
00929
00938 static inline
00939 void * headerFreeData( const void * data, rpmTagType type)
00940
00941 {
00942 if (data) {
00943
00944 if (type == -1 ||
00945 type == RPM_STRING_ARRAY_TYPE ||
00946 type == RPM_I18NSTRING_TYPE ||
00947 type == RPM_BIN_TYPE)
00948 free((void *)data);
00949
00950 }
00951 return NULL;
00952 }
00953 #endif
00954
00955 #if !defined(__HEADER_PROTOTYPES__)
00956 #include "hdrinline.h"
00957 #endif
00958
00964 int headerMacrosLoad(Header h)
00965
00966 ;
00967
00973 int headerMacrosUnload(Header h)
00974
00975 ;
00976
00985 int headerNVR(Header h,
00986 const char ** np,
00987 const char ** vp,
00988 const char ** rp)
00989 ;
00990
01001 int headerNEVRA(Header h,
01002 const char ** np,
01003 const char ** ep,
01004 const char ** vp,
01005 const char ** rp,
01006 const char ** ap)
01007 ;
01008
01015
01016 char * hGetNEVR(Header h, const char ** np )
01017 ;
01018
01025
01026 char * hGetNEVRA(Header h, const char ** np )
01027 ;
01028
01034 uint_32 hGetColor(Header h)
01035 ;
01036
01037 #ifdef __cplusplus
01038 }
01039 #endif
01040
01041 #endif