Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

rpmdb/header.h

Go to the documentation of this file.
00001 #ifndef H_HEADER
00002 #define H_HEADER
00003 
00080 /* RPM - Copyright (C) 1995-2001 Red Hat Software */
00081 
00082 #include "rpmio.h"
00083 
00084 #ifdef __cplusplus
00085 extern "C" {
00086 #endif
00087 
00088 /* XXX hpux needs -Ae in CFLAGS to grok this */
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 /* XXX hpux needs -Ae in CFLAGS to grok this */
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 /*@abstract@*/ /*@refcounted@*/ 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;            /* tag container. */
00149 
00152 /*@-typeuse -fielduse@*/
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 /*@=typeuse =fielduse@*/
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 /*@-typeuse -fielduse@*/
00189 #if !defined(SWIG)
00190 struct _HE_s {
00191     int_32 tag;
00192     rpmTagType t;
00193 /*@owned@*/ /*@null@*/
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 /*@=typeuse =fielduse@*/
00204 
00207 typedef /*@abstract@*/ struct headerIterator_s * HeaderIterator;
00208 
00212 typedef /*@abstract@*/ struct headerTagTableEntry_s * headerTagTableEntry;
00213 #if !defined(SWIG)
00214 struct headerTagTableEntry_s {
00215 /*@observer@*/ /*@relnull@*/
00216     const char * name;          
00217     int val;                    
00218     int type;                   
00219 };
00220 #endif
00221 
00224 typedef /*@abstract@*/ 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         /*@ modifies *ipp, *np */;      
00230 /*@relnull@*/
00231     headerTagTableEntry * byName;       
00232     int byNameSize;                     
00233     int (*byNameCmp) (const void * avp, const void * bvp)
00234         /*@*/;                          
00235     int (*tagValue) (const char * name)
00236         /*@*/;                          /* return value from name. */
00237 /*@relnull@*/
00238     headerTagTableEntry * byValue;      
00239     int byValueSize;                    
00240     int (*byValueCmp) (const void * avp, const void * bvp)
00241         /*@*/;                          
00242     const char * (*tagName) (int value)
00243         /*@*/;                          /* Return name from value. */
00244     int (*tagType) (int value)
00245         /*@*/;                          /* Return type from value. */
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 /*only@*/ char * (*headerTagFormatFunction) (HE_t he, /*@null@*/ const char ** av)
00265         /*@modifies he @*/;
00266 
00275 typedef int (*headerTagTagFunction) (Header h, HE_t he)
00276         /*@modifies he @*/;
00277 
00281 typedef /*@abstract@*/ struct headerSprintfExtension_s * headerSprintfExtension;
00282 #if !defined(SWIG)
00283 struct headerSprintfExtension_s {
00284     enum headerSprintfExtensionType type;       
00285 /*@observer@*/ /*@null@*/
00286     const char * name;                          
00287     union {
00288 /*@observer@*/ /*@null@*/
00289         void * generic;                         
00290         headerTagFormatFunction fmtFunction; 
00291         headerTagTagFunction tagFunction;   
00292         struct headerSprintfExtension_s * more; 
00293     } u;
00294 };
00295 #endif
00296 
00300 /*@-redecl@*/
00301 /*@observer@*/
00302 extern const struct headerSprintfExtension_s headerDefaultFormats[];
00303 /*@=redecl@*/
00304 
00308 enum hMagic {
00309     HEADER_MAGIC_NO             = 0,
00310     HEADER_MAGIC_YES            = 1
00311 };
00312 
00321 /*@-enummemuse -typeuse @*/
00322 typedef enum rpmSubTagType_e {
00323     RPM_REGION_TYPE             = -10,
00324     RPM_BIN_ARRAY_TYPE          = -11,
00327     RPM_XREF_TYPE               = -12
00330 } rpmSubTagType;
00331 /*@=enummemuse =typeuse @*/
00332 
00336 /*@-enummemuse -typeuse @*/
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 /*@=enummemuse =typeuse @*/
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 /*@null@*/
00366     void * (*HFD_t) (/*@only@*/ /*@null@*/ const void * data, rpmTagType type)
00367         /*@modifies data @*/;
00368 
00383 typedef int (*HGE_t) (Header h, int_32 tag,
00384                         /*@null@*/ /*@out@*/ rpmTagType * type,
00385                         /*@null@*/ /*@out@*/ void * p,
00386                         /*@null@*/ /*@out@*/ int_32 * c)
00387         /*@modifies *type, *p, *c @*/;
00388 
00404 typedef int (*HAE_t) (Header h, int_32 tag, rpmTagType type,
00405                         const void * p, int_32 c)
00406         /*@modifies h @*/;
00407 
00419 typedef int (*HME_t) (Header h, int_32 tag, rpmTagType type,
00420                         const void * p, int_32 c)
00421         /*@modifies h @*/;
00422 
00433 typedef int (*HRE_t) (Header h, int_32 tag)
00434         /*@modifies h @*/;
00435 
00440 typedef
00441 Header (*HDRnew) (void)
00442         /*@*/;
00443 
00449 typedef
00450 /*@null@*/ Header (*HDRfree) (/*@killref@*/ /*@null@*/ Header h)
00451         /*@modifies h @*/;
00452 
00458 typedef
00459 Header (*HDRlink) (Header h)
00460         /*@modifies h @*/;
00461 
00467 typedef
00468 Header (*HDRunlink) (/*@killref@*/ /*@null@*/ Header h)
00469         /*@modifies h @*/;
00470 
00476 typedef
00477 void (*HDRsort) (Header h)
00478         /*@modifies h @*/;
00479 
00485 typedef
00486 void (*HDRunsort) (Header h)
00487         /*@modifies h @*/;
00488 
00495 typedef
00496 unsigned int (*HDRsizeof) (/*@null@*/ Header h, enum hMagic magicp)
00497         /*@modifies h @*/;
00498 
00504 typedef
00505 /*@only@*/ /*@null@*/ void * (*HDRunload) (Header h)
00506         /*@modifies h @*/;
00507 
00515 typedef
00516 /*@null@*/ Header (*HDRreload) (/*@only@*/ Header h, int tag)
00517         /*@modifies h @*/;
00518 
00524 typedef
00525 Header (*HDRcopy) (Header h)
00526         /*@modifies h @*/;
00527 
00533 typedef
00534 /*@null@*/ Header (*HDRload) (/*@kept@*/ void * uh)
00535         /*@modifies uh @*/;
00536 
00542 typedef
00543 /*@null@*/ Header (*HDRcopyload) (const void * uh)
00544         /*@*/;
00545 
00552 typedef
00553 /*@null@*/ Header (*HDRread) (void * _fd, enum hMagic magicp)
00554         /*@modifies _fd @*/;
00555 
00563 typedef
00564 int (*HDRwrite) (void * _fd, /*@null@*/ Header h, enum hMagic magicp)
00565         /*@globals fileSystem @*/
00566         /*@modifies _fd, h, fileSystem @*/;
00567 
00574 typedef
00575 int (*HDRisentry) (/*@null@*/Header h, int_32 tag)
00576         /*@*/;  
00577 
00585 typedef
00586 /*@null@*/ void * (*HDRfreetag) (Header h,
00587                 /*@only@*/ /*@null@*/ const void * data, rpmTagType type)
00588         /*@modifies data @*/;
00589 
00600 typedef
00601 int (*HDRext) (Header h, int_32 tag,
00602                         /*@null@*/ /*@out@*/ hTYP_t type,
00603                         /*@null@*/ /*@out@*/ hRET_t * p,
00604                         /*@null@*/ /*@out@*/ hCNT_t c)
00605         /*@modifies *type, *p, *c @*/;
00606 
00620 typedef
00621 int (*HDRget) (Header h, int_32 tag,
00622                         /*@null@*/ /*@out@*/ hTYP_t type,
00623                         /*@null@*/ /*@out@*/ void * p,
00624                         /*@null@*/ /*@out@*/ hCNT_t c)
00625         /*@modifies *type, *p, *c @*/;
00626 
00639 typedef
00640 int (*HDRgetmin) (Header h, int_32 tag,
00641                         /*@null@*/ /*@out@*/ hTYP_t type,
00642                         /*@null@*/ /*@out@*/ void * p,
00643                         /*@null@*/ /*@out@*/ hCNT_t c)
00644         /*@modifies *type, *p, *c @*/;
00645 
00660 typedef
00661 int (*HDRadd) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00662         /*@modifies h @*/;
00663 
00678 typedef
00679 int (*HDRappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00680         /*@modifies h @*/;
00681 
00692 typedef
00693 int (*HDRaddorappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00694         /*@modifies h @*/;
00695 
00716 typedef
00717 int (*HDRaddi18n) (Header h, int_32 tag, const char * string,
00718                 const char * lang)
00719         /*@modifies h @*/;
00720 
00731 typedef
00732 int (*HDRmodify) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00733         /*@modifies h @*/;
00734 
00744 typedef
00745 int (*HDRremove) (Header h, int_32 tag)
00746         /*@modifies h @*/;
00747 
00759 typedef
00760 /*@only@*/ char * (*HDRsprintf) (Header h, const char * fmt,
00761                      const struct headerTagTableEntry_s * tags,
00762                      const struct headerSprintfExtension_s * exts,
00763                      /*@null@*/ /*@out@*/ errmsg_t * errmsg)
00764         /*@modifies *errmsg @*/;
00765 
00772 typedef
00773 void (*HDRcopytags) (Header headerFrom, Header headerTo, hTAG_t tagstocopy)
00774         /*@modifies headerFrom, headerTo @*/;
00775 
00781 typedef
00782 HeaderIterator (*HDRfreeiter) (/*@only@*/ HeaderIterator hi)
00783         /*@modifies hi @*/;
00784 
00790 typedef
00791 HeaderIterator (*HDRinititer) (Header h)
00792         /*@modifies h */;
00793 
00803 typedef
00804 int (*HDRnextiter) (HeaderIterator hi,
00805                 /*@null@*/ /*@out@*/ hTAG_t tag,
00806                 /*@null@*/ /*@out@*/ hTYP_t type,
00807                 /*@null@*/ /*@out@*/ hPTR_t * p,
00808                 /*@null@*/ /*@out@*/ hCNT_t c)
00809         /*@modifies hi, *tag, *type, *p, *c @*/;
00810 
00818 typedef
00819 int (*HDRgetmagic)(/*@null@*/ Header h, unsigned char **magicp, size_t *nmagicp)
00820         /*@*/;
00821 
00829 typedef
00830 int (*HDRsetmagic)(/*@null@*/ Header h, unsigned char * magic, size_t nmagic)
00831         /*@modifies h @*/;
00832 
00838 typedef /*@observer@*/ /*@null@*/
00839 const char * (*HDRgetorigin) (/*@null@*/ Header h)
00840         /*@*/;
00841 
00848 typedef
00849 int (*HDRsetorigin) (/*@null@*/ Header h, const char * origin)
00850         /*@modifies h @*/;
00851 
00857 typedef
00858 int (*HDRgetinstance) (/*@null@*/ Header h)
00859         /*@*/;
00860 
00867 typedef
00868 int (*HDRsetinstance) (/*@null@*/ Header h, int instance)
00869         /*@modifies h @*/;
00870 
00877 typedef
00878 /*@null@*/ void * (*HDRgetstats) (Header h, int opx)
00879         /*@*/;
00880 
00884 typedef /*@abstract@*/ 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 /*@null@*/
00921     void *      hdrvecs;
00922 /*@null@*/
00923     void *      hdrdata;
00924     int         hdrversion;
00925 };
00926 #endif
00927 
00928 #if !defined(SWIG)
00929 
00938 /*@unused@*/ static inline /*@null@*/
00939 void * headerFreeData( /*@only@*/ /*@null@*/ const void * data, rpmTagType type)
00940         /*@modifies data @*/
00941 {
00942     if (data) {
00943         /*@-branchstate@*/
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         /*@=branchstate@*/
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         /*@globals rpmGlobalMacroContext @*/
00966         /*@modifies rpmGlobalMacroContext @*/;
00967 
00973 int headerMacrosUnload(Header h)
00974         /*@globals rpmGlobalMacroContext @*/
00975         /*@modifies rpmGlobalMacroContext @*/;
00976 
00985 int headerNVR(Header h,
00986                 /*@null@*/ /*@out@*/ const char ** np,
00987                 /*@null@*/ /*@out@*/ const char ** vp,
00988                 /*@null@*/ /*@out@*/ const char ** rp)
00989         /*@modifies *np, *vp, *rp @*/;
00990 
01001 int headerNEVRA(Header h,
01002                 /*@null@*/ /*@out@*/ const char ** np,
01003                 /*@null@*/ /*@out@*/ /*@unused@*/ const char ** ep,
01004                 /*@null@*/ /*@out@*/ const char ** vp,
01005                 /*@null@*/ /*@out@*/ const char ** rp,
01006                 /*@null@*/ /*@out@*/ const char ** ap)
01007         /*@modifies *np, *vp, *rp, *ap @*/;
01008 
01015 /*@only@*/
01016 char * hGetNEVR(Header h, /*@null@*/ /*@out@*/ const char ** np )
01017         /*@modifies *np @*/;
01018 
01025 /*@only@*/
01026 char * hGetNEVRA(Header h, /*@null@*/ /*@out@*/ const char ** np )
01027         /*@modifies *np @*/;
01028 
01034 uint_32 hGetColor(Header h)
01035         /*@modifies h @*/;
01036 
01037 #ifdef __cplusplus
01038 }
01039 #endif
01040 
01041 #endif  /* H_HEADER */

Generated on Sun Aug 18 10:48:23 2013 for rpm by  doxygen 1.4.4