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 <stdio.h>
00083 #include "rpmio.h"
00084 
00085 #ifdef __cplusplus
00086 extern "C" {
00087 #endif
00088 
00089 /* XXX hpux needs -Ae in CFLAGS to grok this */
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 /* XXX hpux needs -Ae in CFLAGS to grok this */
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 /*@-redef@*/    /* LCL: no clue */
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 /*@abstract@*/ /*@refcounted@*/ struct headerToken_s * Header;
00116 
00119 typedef /*@abstract@*/ struct headerIterator_s * HeaderIterator;
00120 
00124 typedef /*@abstract@*/ struct headerTagTableEntry_s * headerTagTableEntry;
00125 #if !defined(SWIG)
00126 struct headerTagTableEntry_s {
00127 /*@observer@*/ /*@relnull@*/
00128     const char * name;          
00129     int val;                    
00130     int type;                   
00131 };
00132 #endif
00133 
00136 typedef /*@abstract@*/ 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         /*@ modifies *ipp, *np */;      
00142 /*@relnull@*/
00143     headerTagTableEntry * byName;       
00144     int byNameSize;                     
00145     int (*byNameCmp) (const void * avp, const void * bvp)
00146         /*@*/;                          
00147     int (*tagValue) (const char * name)
00148         /*@*/;                          /* return value from name. */
00149 /*@relnull@*/
00150     headerTagTableEntry * byValue;      
00151     int byValueSize;                    
00152     int (*byValueCmp) (const void * avp, const void * bvp)
00153         /*@*/;                          
00154     const char * (*tagName) (int value)
00155         /*@*/;                          /* Return name from value. */
00156     int (*tagType) (int value)
00157         /*@*/;                          /* Return type from value. */
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 /*only@*/ char * (*headerTagFormatFunction)(int_32 type,
00183                                 const void * data, char * formatPrefix,
00184                                 int padding, int element)
00185         /*@requires maxSet(data) >= 0 @*/;
00186 
00198 typedef int (*headerTagTagFunction) (Header h,
00199                 /*@null@*/ /*@out@*/ hTYP_t type,
00200                 /*@null@*/ /*@out@*/ hPTR_t * data,
00201                 /*@null@*/ /*@out@*/ hCNT_t count,
00202                 /*@null@*/ /*@out@*/ int * freeData)
00203         /*@requires maxSet(type) >= 0 /\ maxSet(data) >= 0
00204                 /\ maxSet(count) >= 0 /\ maxSet(freeData) >= 0 @*/;
00205 
00209 typedef /*@abstract@*/ struct headerSprintfExtension_s * headerSprintfExtension;
00210 #if !defined(SWIG)
00211 struct headerSprintfExtension_s {
00212     enum headerSprintfExtensionType type;       
00213 /*@observer@*/ /*@null@*/
00214     const char * name;                          
00215     union {
00216 /*@observer@*/ /*@null@*/
00217         void * generic;                         
00218         headerTagFormatFunction formatFunction; 
00219         headerTagTagFunction tagFunction;       
00220         struct headerSprintfExtension_s * more; 
00221     } u;
00222 };
00223 #endif
00224 
00228 /*@-redecl@*/
00229 /*@observer@*/
00230 extern const struct headerSprintfExtension_s headerDefaultFormats[];
00231 /*@=redecl@*/
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 /*@-enummemuse -typeuse @*/
00271 typedef enum rpmSubTagType_e {
00272     RPM_REGION_TYPE             = -10,
00273     RPM_BIN_ARRAY_TYPE          = -11,
00276     RPM_XREF_TYPE               = -12
00279 } rpmSubTagType;
00280 /*@=enummemuse =typeuse @*/
00281 
00285 /*@-enummemuse -typeuse @*/
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 /*@=enummemuse =typeuse @*/
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 /*@-typeuse -fielduse@*/
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 /*@=typeuse =fielduse@*/
00324 
00327 /*@-typeuse -fielduse@*/
00328 typedef struct HE_s * HE_t;
00329 #if !defined(SWIG)
00330 struct HE_s {
00331     int_32 tag;
00332 /*@null@*/
00333     hTYP_t typ;
00334     union {
00335 /*@null@*/
00336         hPTR_t * ptr;
00337 /*@null@*/
00338         hRET_t * ret;
00339     } u;
00340 /*@null@*/
00341     hCNT_t cnt;
00342 };
00343 #endif
00344 /*@=typeuse =fielduse@*/
00345 
00350 typedef
00351 Header (*HDRnew) (void)
00352         /*@*/;
00353 
00359 typedef
00360 /*@null@*/ Header (*HDRfree) (/*@killref@*/ /*@null@*/ Header h)
00361         /*@modifies h @*/;
00362 
00368 typedef
00369 Header (*HDRlink) (Header h)
00370         /*@modifies h @*/;
00371 
00377 typedef
00378 Header (*HDRunlink) (/*@killref@*/ /*@null@*/ Header h)
00379         /*@modifies h @*/;
00380 
00386 typedef
00387 void (*HDRsort) (Header h)
00388         /*@modifies h @*/;
00389 
00395 typedef
00396 void (*HDRunsort) (Header h)
00397         /*@modifies h @*/;
00398 
00405 typedef
00406 unsigned int (*HDRsizeof) (/*@null@*/ Header h, enum hMagic magicp)
00407         /*@modifies h @*/;
00408 
00414 typedef
00415 /*@only@*/ /*@null@*/ void * (*HDRunload) (Header h)
00416         /*@modifies h @*/;
00417 
00425 typedef
00426 /*@null@*/ Header (*HDRreload) (/*@only@*/ Header h, int tag)
00427         /*@modifies h @*/;
00428 
00434 typedef
00435 Header (*HDRcopy) (Header h)
00436         /*@modifies h @*/;
00437 
00443 typedef
00444 /*@null@*/ Header (*HDRload) (/*@kept@*/ void * uh)
00445         /*@modifies uh @*/;
00446 
00452 typedef
00453 /*@null@*/ Header (*HDRcopyload) (const void * uh)
00454         /*@*/;
00455 
00462 typedef
00463 /*@null@*/ Header (*HDRread) (FD_t fd, enum hMagic magicp)
00464         /*@modifies fd @*/;
00465 
00473 typedef
00474 int (*HDRwrite) (FD_t fd, /*@null@*/ Header h, enum hMagic magicp)
00475         /*@globals fileSystem @*/
00476         /*@modifies fd, h, fileSystem @*/;
00477 
00484 typedef
00485 int (*HDRisentry) (/*@null@*/Header h, int_32 tag)
00486         /*@*/;  
00487 
00495 typedef
00496 /*@null@*/ void * (*HDRfreetag) (Header h,
00497                 /*@only@*/ /*@null@*/ const void * data, rpmTagType type)
00498         /*@modifies data @*/;
00499 
00513 typedef
00514 int (*HDRget) (Header h, int_32 tag,
00515                         /*@null@*/ /*@out@*/ hTYP_t type,
00516                         /*@null@*/ /*@out@*/ void * p,
00517                         /*@null@*/ /*@out@*/ hCNT_t c)
00518         /*@modifies *type, *p, *c @*/;
00519 
00532 typedef
00533 int (*HDRgetmin) (Header h, int_32 tag,
00534                         /*@null@*/ /*@out@*/ hTYP_t type,
00535                         /*@null@*/ /*@out@*/ void * p,
00536                         /*@null@*/ /*@out@*/ hCNT_t c)
00537         /*@modifies *type, *p, *c @*/;
00538 
00553 typedef
00554 int (*HDRadd) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00555         /*@modifies h @*/;
00556 
00571 typedef
00572 int (*HDRappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00573         /*@modifies h @*/;
00574 
00585 typedef
00586 int (*HDRaddorappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00587         /*@modifies h @*/;
00588 
00609 typedef
00610 int (*HDRaddi18n) (Header h, int_32 tag, const char * string,
00611                 const char * lang)
00612         /*@modifies h @*/;
00613 
00624 typedef
00625 int (*HDRmodify) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00626         /*@modifies h @*/;
00627 
00637 typedef
00638 int (*HDRremove) (Header h, int_32 tag)
00639         /*@modifies h @*/;
00640 
00652 typedef
00653 /*@only@*/ char * (*HDRsprintf) (Header h, const char * fmt,
00654                      const struct headerTagTableEntry_s * tags,
00655                      const struct headerSprintfExtension_s * extensions,
00656                      /*@null@*/ /*@out@*/ errmsg_t * errmsg)
00657         /*@modifies *errmsg @*/;
00658 
00665 typedef
00666 void (*HDRcopytags) (Header headerFrom, Header headerTo, hTAG_t tagstocopy)
00667         /*@modifies headerFrom, headerTo @*/;
00668 
00674 typedef
00675 HeaderIterator (*HDRfreeiter) (/*@only@*/ HeaderIterator hi)
00676         /*@modifies hi @*/;
00677 
00683 typedef
00684 HeaderIterator (*HDRinititer) (Header h)
00685         /*@modifies h */;
00686 
00696 typedef
00697 int (*HDRnextiter) (HeaderIterator hi,
00698                 /*@null@*/ /*@out@*/ hTAG_t tag,
00699                 /*@null@*/ /*@out@*/ hTYP_t type,
00700                 /*@null@*/ /*@out@*/ hPTR_t * p,
00701                 /*@null@*/ /*@out@*/ hCNT_t c)
00702         /*@modifies hi, *tag, *type, *p, *c @*/;
00703 
00709 typedef /*@observer@*/ /*@null@*/
00710 const char * (*HDRgetorigin) (/*@null@*/ Header h)
00711         /*@*/;
00712 
00719 typedef
00720 int (*HDRsetorigin) (/*@null@*/ Header h, const char * origin)
00721         /*@modifies h @*/;
00722 
00728 typedef
00729 int (*HDRgetinstance) (/*@null@*/ Header h)
00730         /*@*/;
00731 
00738 typedef
00739 int (*HDRsetinstance) (/*@null@*/ Header h, int instance)
00740         /*@modifies h @*/;
00741 
00745 typedef /*@abstract@*/ 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 /*@null@*/
00782     void *      hdrvecs;
00783 /*@null@*/
00784     void *      hdrdata;
00785     int         hdrversion;
00786 };
00787 #endif
00788 
00789 #if !defined(SWIG)
00790 
00799 /*@unused@*/ static inline /*@null@*/
00800 void * headerFreeData( /*@only@*/ /*@null@*/ const void * data, rpmTagType type)
00801         /*@modifies data @*/
00802 {
00803     if (data) {
00804         /*@-branchstate@*/
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         /*@=branchstate@*/
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         /*@globals rpmGlobalMacroContext @*/
00827         /*@modifies rpmGlobalMacroContext @*/;
00828 
00834 int headerMacrosUnload(Header h)
00835         /*@globals rpmGlobalMacroContext @*/
00836         /*@modifies rpmGlobalMacroContext @*/;
00837 
00846 int headerNVR(Header h,
00847                 /*@null@*/ /*@out@*/ const char ** np,
00848                 /*@null@*/ /*@out@*/ const char ** vp,
00849                 /*@null@*/ /*@out@*/ const char ** rp)
00850         /*@modifies *np, *vp, *rp @*/;
00851 
00862 int headerNEVRA(Header h,
00863                 /*@null@*/ /*@out@*/ const char ** np,
00864                 /*@null@*/ /*@out@*/ /*@unused@*/ const char ** ep,
00865                 /*@null@*/ /*@out@*/ const char ** vp,
00866                 /*@null@*/ /*@out@*/ const char ** rp,
00867                 /*@null@*/ /*@out@*/ const char ** ap)
00868         /*@modifies *np, *vp, *rp, *ap @*/;
00869 
00876 /*@only@*/
00877 char * hGetNEVR(Header h, /*@null@*/ /*@out@*/ const char ** np )
00878         /*@modifies *np @*/;
00879 
00886 /*@only@*/
00887 char * hGetNEVRA(Header h, /*@null@*/ /*@out@*/ const char ** np )
00888         /*@modifies *np @*/;
00889 
00895 uint_32 hGetColor(Header h)
00896         /*@modifies h @*/;
00897 
00898 #ifdef __cplusplus
00899 }
00900 #endif
00901 
00902 #endif  /* H_HEADER */

Generated on Fri Aug 31 10:38:34 2007 for rpm by  doxygen 1.5.1