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 #if 0   /* XXX hpux needs -Ae in CFLAGS to grok this */
00090 typedef long long int int_64;
00091 #endif
00092 typedef int int_32;
00093 typedef short int int_16;
00094 typedef char int_8;
00095 
00096 #if 0   /* XXX hpux needs -Ae in CFLAGS to grok this */
00097 typedef unsigned long long int uint_64;
00098 #endif
00099 typedef unsigned int uint_32;
00100 typedef unsigned short uint_16;
00101 typedef unsigned char uint_8;
00102 
00103 /*@-redef@*/    /* LCL: no clue */
00106 typedef const char *    errmsg_t;
00107 
00110 typedef int_32 *        hTAG_t;
00111 typedef int_32 *        hTYP_t;
00112 typedef const void *    hPTR_t;
00113 typedef int_32 *        hCNT_t;
00114 
00117 typedef /*@abstract@*/ /*@refcounted@*/ struct headerToken_s * Header;
00118 
00121 typedef /*@abstract@*/ struct headerIterator_s * HeaderIterator;
00122 
00126 typedef /*@abstract@*/ struct headerTagTableEntry_s * headerTagTableEntry;
00127 struct headerTagTableEntry_s {
00128 /*@observer@*/ /*@null@*/
00129     const char * name;          
00130     int val;                    
00131     int type;                   
00132 };
00133 
00136 enum headerSprintfExtensionType {
00137     HEADER_EXT_LAST = 0,        
00138     HEADER_EXT_FORMAT,          
00139     HEADER_EXT_MORE,            
00140     HEADER_EXT_TAG              
00141 };
00142 
00155 typedef /*only@*/ char * (*headerTagFormatFunction)(int_32 type,
00156                                 const void * data, char * formatPrefix,
00157                                 int padding, int element)
00158         /*@requires maxSet(data) >= 0 @*/;
00159 
00171 typedef int (*headerTagTagFunction) (Header h,
00172                 /*@null@*/ /*@out@*/ hTYP_t type,
00173                 /*@null@*/ /*@out@*/ hPTR_t * data,
00174                 /*@null@*/ /*@out@*/ hCNT_t count,
00175                 /*@null@*/ /*@out@*/ int * freeData)
00176         /*@requires maxSet(type) >= 0 /\ maxSet(data) >= 0
00177                 /\ maxSet(count) >= 0 /\ maxSet(freeData) >= 0 @*/;
00178 
00182 typedef /*@abstract@*/ struct headerSprintfExtension_s * headerSprintfExtension;
00183 struct headerSprintfExtension_s {
00184     enum headerSprintfExtensionType type;       
00185 /*@observer@*/ /*@null@*/
00186     const char * name;                          
00187     union {
00188 /*@observer@*/ /*@null@*/
00189         void * generic;                         
00190         headerTagFormatFunction formatFunction; 
00191         headerTagTagFunction tagFunction;       
00192         struct headerSprintfExtension_s * more; 
00193     } u;
00194 };
00195 
00199 /*@-redecl@*/
00200 /*@observer@*/
00201 extern const struct headerSprintfExtension_s headerDefaultFormats[];
00202 /*@=redecl@*/
00203 
00207 enum hMagic {
00208     HEADER_MAGIC_NO             = 0,
00209     HEADER_MAGIC_YES            = 1
00210 };
00211 
00215 typedef enum rpmTagType_e {
00216 #define RPM_MIN_TYPE            0
00217     RPM_NULL_TYPE               =  0,
00218     RPM_CHAR_TYPE               =  1,
00219     RPM_INT8_TYPE               =  2,
00220     RPM_INT16_TYPE              =  3,
00221     RPM_INT32_TYPE              =  4,
00222 /*    RPM_INT64_TYPE    = 5,   ---- These aren't supported (yet) */
00223     RPM_STRING_TYPE             =  6,
00224     RPM_BIN_TYPE                =  7,
00225     RPM_STRING_ARRAY_TYPE       =  8,
00226     RPM_I18NSTRING_TYPE         =  9
00227 #define RPM_MAX_TYPE            9
00228 } rpmTagType;
00229 
00238 /*@-enummemuse -typeuse @*/
00239 typedef enum rpmSubTagType_e {
00240     RPM_REGION_TYPE             = -10,
00241     RPM_BIN_ARRAY_TYPE          = -11,
00244     RPM_XREF_TYPE               = -12
00247 } rpmSubTagType;
00248 /*@=enummemuse =typeuse @*/
00249 
00254 #define HEADER_IMAGE            61
00255 #define HEADER_SIGNATURES       62
00256 #define HEADER_IMMUTABLE        63
00257 #define HEADER_REGIONS          64
00258 #define HEADER_I18NTABLE        100
00259 #define HEADER_SIGBASE          256
00260 #define HEADER_TAGBASE          1000
00261 
00264 /*@-typeuse -fielduse@*/
00265 typedef union hRET_s {
00266     const void * ptr;
00267     const char ** argv;
00268     const char * str;
00269     uint_32 * ui32p;
00270     uint_16 * ui16p;
00271     int_32 * i32p;
00272     int_16 * i16p;
00273     int_8 * i8p;
00274 } * hRET_t;
00275 /*@=typeuse =fielduse@*/
00276 
00279 /*@-typeuse -fielduse@*/
00280 typedef struct HE_s {
00281     int_32 tag;
00282 /*@null@*/
00283     hTYP_t typ;
00284     union {
00285 /*@null@*/
00286         hPTR_t * ptr;
00287 /*@null@*/
00288         hRET_t * ret;
00289     } u;
00290 /*@null@*/
00291     hCNT_t cnt;
00292 } * HE_t;
00293 /*@=typeuse =fielduse@*/
00294 
00299 typedef
00300 Header (*HDRnew) (void)
00301         /*@*/;
00302 
00308 typedef
00309 /*@null@*/ Header (*HDRfree) (/*@killref@*/ /*@null@*/ Header h)
00310         /*@modifies h @*/;
00311 
00317 typedef
00318 Header (*HDRlink) (Header h)
00319         /*@modifies h @*/;
00320 
00326 typedef
00327 Header (*HDRunlink) (/*@killref@*/ /*@null@*/ Header h)
00328         /*@modifies h @*/;
00329 
00335 typedef
00336 void (*HDRsort) (Header h)
00337         /*@modifies h @*/;
00338 
00344 typedef
00345 void (*HDRunsort) (Header h)
00346         /*@modifies h @*/;
00347 
00354 typedef
00355 unsigned int (*HDRsizeof) (/*@null@*/ Header h, enum hMagic magicp)
00356         /*@modifies h @*/;
00357 
00363 typedef
00364 /*@only@*/ /*@null@*/ void * (*HDRunload) (Header h)
00365         /*@modifies h @*/;
00366 
00374 typedef
00375 /*@null@*/ Header (*HDRreload) (/*@only@*/ Header h, int tag)
00376         /*@modifies h @*/;
00377 
00383 typedef
00384 Header (*HDRcopy) (Header h)
00385         /*@modifies h @*/;
00386 
00392 typedef
00393 /*@null@*/ Header (*HDRload) (/*@kept@*/ void * uh)
00394         /*@modifies uh @*/;
00395 
00401 typedef
00402 /*@null@*/ Header (*HDRcopyload) (const void * uh)
00403         /*@*/;
00404 
00411 typedef
00412 /*@null@*/ Header (*HDRread) (FD_t fd, enum hMagic magicp)
00413         /*@modifies fd @*/;
00414 
00422 typedef
00423 int (*HDRwrite) (FD_t fd, /*@null@*/ Header h, enum hMagic magicp)
00424         /*@globals fileSystem @*/
00425         /*@modifies fd, h, fileSystem @*/;
00426 
00433 typedef
00434 int (*HDRisentry) (/*@null@*/Header h, int_32 tag)
00435         /*@*/;  
00436 
00444 typedef
00445 /*@null@*/ void * (*HDRfreetag) (Header h,
00446                 /*@only@*/ /*@null@*/ const void * data, rpmTagType type)
00447         /*@modifies data @*/;
00448 
00462 typedef
00463 int (*HDRget) (Header h, int_32 tag,
00464                         /*@null@*/ /*@out@*/ hTYP_t type,
00465                         /*@null@*/ /*@out@*/ void ** p,
00466                         /*@null@*/ /*@out@*/ hCNT_t c)
00467         /*@modifies *type, *p, *c @*/;
00468 
00481 typedef
00482 int (*HDRgetmin) (Header h, int_32 tag,
00483                         /*@null@*/ /*@out@*/ hTYP_t type,
00484                         /*@null@*/ /*@out@*/ hPTR_t * p,
00485                         /*@null@*/ /*@out@*/ hCNT_t c)
00486         /*@modifies *type, *p, *c @*/;
00487 
00502 typedef
00503 int (*HDRadd) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00504         /*@modifies h @*/;
00505 
00520 typedef
00521 int (*HDRappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00522         /*@modifies h @*/;
00523 
00534 typedef
00535 int (*HDRaddorappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00536         /*@modifies h @*/;
00537 
00558 typedef
00559 int (*HDRaddi18n) (Header h, int_32 tag, const char * string,
00560                 const char * lang)
00561         /*@modifies h @*/;
00562 
00573 typedef
00574 int (*HDRmodify) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00575         /*@modifies h @*/;
00576 
00586 typedef
00587 int (*HDRremove) (Header h, int_32 tag)
00588         /*@modifies h @*/;
00589 
00601 typedef
00602 /*@only@*/ char * (*HDRsprintf) (Header h, const char * fmt,
00603                      const struct headerTagTableEntry_s * tags,
00604                      const struct headerSprintfExtension_s * extensions,
00605                      /*@null@*/ /*@out@*/ errmsg_t * errmsg)
00606         /*@modifies *errmsg @*/;
00607 
00614 typedef
00615 void (*HDRcopytags) (Header headerFrom, Header headerTo, hTAG_t tagstocopy)
00616         /*@modifies headerFrom, headerTo @*/;
00617 
00623 typedef
00624 HeaderIterator (*HDRfreeiter) (/*@only@*/ HeaderIterator hi)
00625         /*@modifies hi @*/;
00626 
00632 typedef
00633 HeaderIterator (*HDRinititer) (Header h)
00634         /*@modifies h */;
00635 
00645 typedef
00646 int (*HDRnextiter) (HeaderIterator hi,
00647                 /*@null@*/ /*@out@*/ hTAG_t tag,
00648                 /*@null@*/ /*@out@*/ hTYP_t type,
00649                 /*@null@*/ /*@out@*/ hPTR_t * p,
00650                 /*@null@*/ /*@out@*/ hCNT_t c)
00651         /*@modifies hi, *tag, *type, *p, *c @*/;
00652 
00656 typedef /*@abstract@*/ struct HV_s * HV_t;
00657 struct HV_s {
00658     HDRlink     hdrlink;
00659     HDRunlink   hdrunlink;
00660     HDRfree     hdrfree;
00661     HDRnew      hdrnew;
00662     HDRsort     hdrsort;
00663     HDRunsort   hdrunsort;
00664     HDRsizeof   hdrsizeof;
00665     HDRunload   hdrunload;
00666     HDRreload   hdrreload;
00667     HDRcopy     hdrcopy;
00668     HDRload     hdrload;
00669     HDRcopyload hdrcopyload;
00670     HDRread     hdrread;
00671     HDRwrite    hdrwrite;
00672     HDRisentry  hdrisentry;
00673     HDRfreetag  hdrfreetag;
00674     HDRget      hdrget;
00675     HDRgetmin   hdrgetmin;
00676     HDRadd      hdradd;
00677     HDRappend   hdrappend;
00678     HDRaddorappend hdraddorappend;
00679     HDRaddi18n  hdraddi18n;
00680     HDRmodify   hdrmodify;
00681     HDRremove   hdrremove;
00682     HDRsprintf  hdrsprintf;
00683     HDRcopytags hdrcopytags;
00684     HDRfreeiter hdrfreeiter;
00685     HDRinititer hdrinititer;
00686     HDRnextiter hdrnextiter;
00687 /*@null@*/
00688     void *      hdrvecs;
00689 /*@null@*/
00690     void *      hdrdata;
00691     int         hdrversion;
00692 };
00693 
00703 /*@unused@*/ static inline /*@null@*/
00704 void * headerFreeData( /*@only@*/ /*@null@*/ const void * data, rpmTagType type)
00705         /*@modifies data @*/
00706 {
00707     if (data) {
00708         /*@-branchstate@*/
00709         if (type == -1 ||
00710             type == RPM_STRING_ARRAY_TYPE ||
00711             type == RPM_I18NSTRING_TYPE ||
00712             type == RPM_BIN_TYPE)
00713                 free((void *)data);
00714         /*@=branchstate@*/
00715     }
00716     return NULL;
00717 }
00718 
00719 #if !defined(__HEADER_PROTOTYPES__)
00720 #include "hdrinline.h"
00721 #endif
00722 
00723 #ifdef __cplusplus
00724 }
00725 #endif
00726 
00727 #endif  /* H_HEADER */

Generated on Fri Oct 12 08:44:54 2007 for rpm by  doxygen 1.5.2