00001 #ifndef H_HEADER
00002 #define H_HEADER
00003
00080
00081
00082 #include <stdio.h>
00083 #include "rpmio.h"
00084
00085 #ifdef __cplusplus
00086 extern "C" {
00087 #endif
00088
00089
00090 typedef long long int int_64;
00091 typedef int int_32;
00092 typedef short int int_16;
00093 typedef char int_8;
00094
00095
00096 typedef unsigned long long int uint_64;
00097 typedef unsigned int uint_32;
00098 typedef unsigned short uint_16;
00099 typedef unsigned char uint_8;
00100
00101
00104 typedef const char * errmsg_t;
00105
00108 typedef int_32 * hTAG_t;
00109 typedef int_32 * hTYP_t;
00110 typedef const void * hPTR_t;
00111 typedef int_32 * hCNT_t;
00112
00115 typedef struct headerToken_s * Header;
00116
00119 typedef struct headerIterator_s * HeaderIterator;
00120
00124 typedef struct headerTagTableEntry_s * headerTagTableEntry;
00125 #if !defined(SWIG)
00126 struct headerTagTableEntry_s {
00127
00128 const char * name;
00129 int val;
00130 int type;
00131 };
00132 #endif
00133
00136 typedef struct headerTagIndices_s * headerTagIndices;
00137 #if !defined(SWIG)
00138 struct headerTagIndices_s {
00139 int (*loadIndex) (headerTagTableEntry ** ipp, int * np,
00140 int (*cmp) (const void * avp, const void * bvp))
00141 ;
00142
00143 headerTagTableEntry * byName;
00144 int byNameSize;
00145 int (*byNameCmp) (const void * avp, const void * bvp)
00146 ;
00147 int (*tagValue) (const char * name)
00148 ;
00149
00150 headerTagTableEntry * byValue;
00151 int byValueSize;
00152 int (*byValueCmp) (const void * avp, const void * bvp)
00153 ;
00154 const char * (*tagName) (int value)
00155 ;
00156 int (*tagType) (int value)
00157 ;
00158 };
00159 #endif
00160
00163 enum headerSprintfExtensionType {
00164 HEADER_EXT_LAST = 0,
00165 HEADER_EXT_FORMAT,
00166 HEADER_EXT_MORE,
00167 HEADER_EXT_TAG
00168 };
00169
00182 typedef char * (*headerTagFormatFunction)(int_32 type,
00183 const void * data, char * formatPrefix,
00184 int padding, int element)
00185 ;
00186
00198 typedef int (*headerTagTagFunction) (Header h,
00199 hTYP_t type,
00200 hPTR_t * data,
00201 hCNT_t count,
00202 int * freeData)
00203
00204 ;
00205
00209 typedef struct headerSprintfExtension_s * headerSprintfExtension;
00210 #if !defined(SWIG)
00211 struct headerSprintfExtension_s {
00212 enum headerSprintfExtensionType type;
00213
00214 const char * name;
00215 union {
00216
00217 void * generic;
00218 headerTagFormatFunction formatFunction;
00219 headerTagTagFunction tagFunction;
00220 struct headerSprintfExtension_s * more;
00221 } u;
00222 };
00223 #endif
00224
00228
00229
00230 extern const struct headerSprintfExtension_s headerDefaultFormats[];
00231
00232
00236 enum hMagic {
00237 HEADER_MAGIC_NO = 0,
00238 HEADER_MAGIC_YES = 1
00239 };
00240
00244 typedef enum rpmTagType_e {
00245 RPM_NULL_TYPE = 0,
00246 RPM_CHAR_TYPE = 1,
00247 RPM_INT8_TYPE = 2,
00248 RPM_INT16_TYPE = 3,
00249 RPM_INT32_TYPE = 4,
00250 RPM_INT64_TYPE = 5,
00251 RPM_STRING_TYPE = 6,
00252 RPM_BIN_TYPE = 7,
00253 RPM_STRING_ARRAY_TYPE = 8,
00254 RPM_I18NSTRING_TYPE = 9,
00255 RPM_ASN1_TYPE = 10,
00256 RPM_OPENPGP_TYPE = 11,
00257 RPM_MASK_TYPE = 0x0000ffff
00258 } rpmTagType;
00259 #define RPM_MIN_TYPE 0
00260 #define RPM_MAX_TYPE 11
00261
00270
00271 typedef enum rpmSubTagType_e {
00272 RPM_REGION_TYPE = -10,
00273 RPM_BIN_ARRAY_TYPE = -11,
00276 RPM_XREF_TYPE = -12
00279 } rpmSubTagType;
00280
00281
00285
00286 typedef enum rpmTagReturnType_e {
00287 RPM_ANY_RETURN_TYPE = 0,
00288 RPM_SCALAR_RETURN_TYPE = 0x00010000,
00289 RPM_ARRAY_RETURN_TYPE = 0x00020000,
00290 RPM_MAPPING_RETURN_TYPE = 0x00040000,
00291 RPM_MASK_RETURN_TYPE = 0xffff0000
00292 } rpmTagReturnType;
00293
00294
00299 #define HEADER_IMAGE 61
00300 #define HEADER_SIGNATURES 62
00301 #define HEADER_IMMUTABLE 63
00302 #define HEADER_REGIONS 64
00303 #define HEADER_I18NTABLE 100
00304 #define HEADER_SIGBASE 256
00305 #define HEADER_TAGBASE 1000
00306
00309
00310 typedef union hRET_s * hRET_t;
00311 #if !defined(SWIG)
00312 union hRET_s {
00313 const void * ptr;
00314 const char ** argv;
00315 const char * str;
00316 uint_32 * ui32p;
00317 uint_16 * ui16p;
00318 int_32 * i32p;
00319 int_16 * i16p;
00320 int_8 * i8p;
00321 };
00322 #endif
00323
00324
00327
00328 typedef struct HE_s * HE_t;
00329 #if !defined(SWIG)
00330 struct HE_s {
00331 int_32 tag;
00332
00333 hTYP_t typ;
00334 union {
00335
00336 hPTR_t * ptr;
00337
00338 hRET_t * ret;
00339 } u;
00340
00341 hCNT_t cnt;
00342 };
00343 #endif
00344
00345
00350 typedef
00351 Header (*HDRnew) (void)
00352 ;
00353
00359 typedef
00360 Header (*HDRfree) ( Header h)
00361 ;
00362
00368 typedef
00369 Header (*HDRlink) (Header h)
00370 ;
00371
00377 typedef
00378 Header (*HDRunlink) ( Header h)
00379 ;
00380
00386 typedef
00387 void (*HDRsort) (Header h)
00388 ;
00389
00395 typedef
00396 void (*HDRunsort) (Header h)
00397 ;
00398
00405 typedef
00406 unsigned int (*HDRsizeof) ( Header h, enum hMagic magicp)
00407 ;
00408
00414 typedef
00415 void * (*HDRunload) (Header h)
00416 ;
00417
00425 typedef
00426 Header (*HDRreload) ( Header h, int tag)
00427 ;
00428
00434 typedef
00435 Header (*HDRcopy) (Header h)
00436 ;
00437
00443 typedef
00444 Header (*HDRload) ( void * uh)
00445 ;
00446
00452 typedef
00453 Header (*HDRcopyload) (const void * uh)
00454 ;
00455
00462 typedef
00463 Header (*HDRread) (FD_t fd, enum hMagic magicp)
00464 ;
00465
00473 typedef
00474 int (*HDRwrite) (FD_t fd, Header h, enum hMagic magicp)
00475
00476 ;
00477
00484 typedef
00485 int (*HDRisentry) (Header h, int_32 tag)
00486 ;
00487
00495 typedef
00496 void * (*HDRfreetag) (Header h,
00497 const void * data, rpmTagType type)
00498 ;
00499
00513 typedef
00514 int (*HDRget) (Header h, int_32 tag,
00515 hTYP_t type,
00516 void * p,
00517 hCNT_t c)
00518 ;
00519
00532 typedef
00533 int (*HDRgetmin) (Header h, int_32 tag,
00534 hTYP_t type,
00535 void * p,
00536 hCNT_t c)
00537 ;
00538
00553 typedef
00554 int (*HDRadd) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00555 ;
00556
00571 typedef
00572 int (*HDRappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00573 ;
00574
00585 typedef
00586 int (*HDRaddorappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00587 ;
00588
00609 typedef
00610 int (*HDRaddi18n) (Header h, int_32 tag, const char * string,
00611 const char * lang)
00612 ;
00613
00624 typedef
00625 int (*HDRmodify) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00626 ;
00627
00637 typedef
00638 int (*HDRremove) (Header h, int_32 tag)
00639 ;
00640
00652 typedef
00653 char * (*HDRsprintf) (Header h, const char * fmt,
00654 const struct headerTagTableEntry_s * tags,
00655 const struct headerSprintfExtension_s * extensions,
00656 errmsg_t * errmsg)
00657 ;
00658
00665 typedef
00666 void (*HDRcopytags) (Header headerFrom, Header headerTo, hTAG_t tagstocopy)
00667 ;
00668
00674 typedef
00675 HeaderIterator (*HDRfreeiter) ( HeaderIterator hi)
00676 ;
00677
00683 typedef
00684 HeaderIterator (*HDRinititer) (Header h)
00685 ;
00686
00696 typedef
00697 int (*HDRnextiter) (HeaderIterator hi,
00698 hTAG_t tag,
00699 hTYP_t type,
00700 hPTR_t * p,
00701 hCNT_t c)
00702 ;
00703
00709 typedef
00710 const char * (*HDRgetorigin) ( Header h)
00711 ;
00712
00719 typedef
00720 int (*HDRsetorigin) ( Header h, const char * origin)
00721 ;
00722
00728 typedef
00729 int (*HDRgetinstance) ( Header h)
00730 ;
00731
00738 typedef
00739 int (*HDRsetinstance) ( Header h, int instance)
00740 ;
00741
00745 typedef struct HV_s * HV_t;
00746 #if !defined(SWIG)
00747 struct HV_s {
00748 HDRlink hdrlink;
00749 HDRunlink hdrunlink;
00750 HDRfree hdrfree;
00751 HDRnew hdrnew;
00752 HDRsort hdrsort;
00753 HDRunsort hdrunsort;
00754 HDRsizeof hdrsizeof;
00755 HDRunload hdrunload;
00756 HDRreload hdrreload;
00757 HDRcopy hdrcopy;
00758 HDRload hdrload;
00759 HDRcopyload hdrcopyload;
00760 HDRread hdrread;
00761 HDRwrite hdrwrite;
00762 HDRisentry hdrisentry;
00763 HDRfreetag hdrfreetag;
00764 HDRget hdrget;
00765 HDRgetmin hdrgetmin;
00766 HDRadd hdradd;
00767 HDRappend hdrappend;
00768 HDRaddorappend hdraddorappend;
00769 HDRaddi18n hdraddi18n;
00770 HDRmodify hdrmodify;
00771 HDRremove hdrremove;
00772 HDRsprintf hdrsprintf;
00773 HDRcopytags hdrcopytags;
00774 HDRfreeiter hdrfreeiter;
00775 HDRinititer hdrinititer;
00776 HDRnextiter hdrnextiter;
00777 HDRgetorigin hdrgetorigin;
00778 HDRsetorigin hdrsetorigin;
00779 HDRgetinstance hdrgetinstance;
00780 HDRsetinstance hdrsetinstance;
00781
00782 void * hdrvecs;
00783
00784 void * hdrdata;
00785 int hdrversion;
00786 };
00787 #endif
00788
00789 #if !defined(SWIG)
00790
00799 static inline
00800 void * headerFreeData( const void * data, rpmTagType type)
00801
00802 {
00803 if (data) {
00804
00805 if (type == -1 ||
00806 type == RPM_STRING_ARRAY_TYPE ||
00807 type == RPM_I18NSTRING_TYPE ||
00808 type == RPM_BIN_TYPE)
00809 free((void *)data);
00810
00811 }
00812 return NULL;
00813 }
00814 #endif
00815
00816 #if !defined(__HEADER_PROTOTYPES__)
00817 #include "hdrinline.h"
00818 #endif
00819
00825 int headerMacrosLoad(Header h)
00826
00827 ;
00828
00834 int headerMacrosUnload(Header h)
00835
00836 ;
00837
00846 int headerNVR(Header h,
00847 const char ** np,
00848 const char ** vp,
00849 const char ** rp)
00850 ;
00851
00862 int headerNEVRA(Header h,
00863 const char ** np,
00864 const char ** ep,
00865 const char ** vp,
00866 const char ** rp,
00867 const char ** ap)
00868 ;
00869
00876
00877 char * hGetNEVR(Header h, const char ** np )
00878 ;
00879
00886
00887 char * hGetNEVRA(Header h, const char ** np )
00888 ;
00889
00895 uint_32 hGetColor(Header h)
00896 ;
00897
00898 #ifdef __cplusplus
00899 }
00900 #endif
00901
00902 #endif