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 <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 };
00132 
00135 enum headerSprintfExtensionType {
00136     HEADER_EXT_LAST = 0,        
00137     HEADER_EXT_FORMAT,          
00138     HEADER_EXT_MORE,            
00139     HEADER_EXT_TAG              
00140 };
00141 
00154 typedef /*only@*/ char * (*headerTagFormatFunction)(int_32 type,
00155                                 const void * data, char * formatPrefix,
00156                                 int padding, int element)
00157         /*@requires maxSet(data) >= 0 @*/;
00158 
00170 typedef int (*headerTagTagFunction) (Header h,
00171                 /*@null@*/ /*@out@*/ hTYP_t type,
00172                 /*@null@*/ /*@out@*/ hPTR_t * data,
00173                 /*@null@*/ /*@out@*/ hCNT_t count,
00174                 /*@null@*/ /*@out@*/ int * freeData)
00175         /*@requires maxSet(type) >= 0 /\ maxSet(data) >= 0
00176                 /\ maxSet(count) >= 0 /\ maxSet(freeData) >= 0 @*/;
00177 
00181 typedef /*@abstract@*/ struct headerSprintfExtension_s * headerSprintfExtension;
00182 struct headerSprintfExtension_s {
00183     enum headerSprintfExtensionType type;       
00184 /*@observer@*/ /*@null@*/
00185     const char * name;                          
00186     union {
00187 /*@observer@*/ /*@null@*/
00188         void * generic;                         
00189         headerTagFormatFunction formatFunction; 
00190         headerTagTagFunction tagFunction;       
00191         struct headerSprintfExtension_s * more; 
00192     } u;
00193 };
00194 
00198 /*@-redecl@*/
00199 /*@observer@*/
00200 extern const struct headerSprintfExtension_s headerDefaultFormats[];
00201 /*@=redecl@*/
00202 
00206 enum hMagic {
00207     HEADER_MAGIC_NO             = 0,
00208     HEADER_MAGIC_YES            = 1
00209 };
00210 
00214 typedef enum rpmTagType_e {
00215 #define RPM_MIN_TYPE            0
00216     RPM_NULL_TYPE               =  0,
00217     RPM_CHAR_TYPE               =  1,
00218     RPM_INT8_TYPE               =  2,
00219     RPM_INT16_TYPE              =  3,
00220     RPM_INT32_TYPE              =  4,
00221 /*    RPM_INT64_TYPE    = 5,   ---- These aren't supported (yet) */
00222     RPM_STRING_TYPE             =  6,
00223     RPM_BIN_TYPE                =  7,
00224     RPM_STRING_ARRAY_TYPE       =  8,
00225     RPM_I18NSTRING_TYPE         =  9
00226 #define RPM_MAX_TYPE            9
00227 } rpmTagType;
00228 
00237 /*@-enummemuse -typeuse @*/
00238 typedef enum rpmSubTagType_e {
00239     RPM_REGION_TYPE             = -10,
00240     RPM_BIN_ARRAY_TYPE          = -11,
00243     RPM_XREF_TYPE               = -12
00246 } rpmSubTagType;
00247 /*@=enummemuse =typeuse @*/
00248 
00253 #define HEADER_IMAGE            61
00254 #define HEADER_SIGNATURES       62
00255 #define HEADER_IMMUTABLE        63
00256 #define HEADER_REGIONS          64
00257 #define HEADER_I18NTABLE        100
00258 #define HEADER_SIGBASE          256
00259 #define HEADER_TAGBASE          1000
00260 
00263 /*@-typeuse -fielduse@*/
00264 typedef union hRET_s {
00265     const void * ptr;
00266     const char ** argv;
00267     const char * str;
00268     uint_32 * ui32p;
00269     uint_16 * ui16p;
00270     int_32 * i32p;
00271     int_16 * i16p;
00272     int_8 * i8p;
00273 } * hRET_t;
00274 /*@=typeuse =fielduse@*/
00275 
00278 /*@-typeuse -fielduse@*/
00279 typedef struct HE_s {
00280     int_32 tag;
00281 /*@null@*/
00282     hTYP_t typ;
00283     union {
00284 /*@null@*/
00285         hPTR_t * ptr;
00286 /*@null@*/
00287         hRET_t * ret;
00288     } u;
00289 /*@null@*/
00290     hCNT_t cnt;
00291 } * HE_t;
00292 /*@=typeuse =fielduse@*/
00293 
00298 typedef
00299 Header (*HDRnew) (void)
00300         /*@*/;
00301 
00307 typedef
00308 /*@null@*/ Header (*HDRfree) (/*@killref@*/ /*@null@*/ Header h)
00309         /*@modifies h @*/;
00310 
00316 typedef
00317 Header (*HDRlink) (Header h)
00318         /*@modifies h @*/;
00319 
00325 typedef
00326 Header (*HDRunlink) (/*@killref@*/ /*@null@*/ Header h)
00327         /*@modifies h @*/;
00328 
00334 typedef
00335 void (*HDRsort) (Header h)
00336         /*@modifies h @*/;
00337 
00343 typedef
00344 void (*HDRunsort) (Header h)
00345         /*@modifies h @*/;
00346 
00353 typedef
00354 unsigned int (*HDRsizeof) (/*@null@*/ Header h, enum hMagic magicp)
00355         /*@modifies h @*/;
00356 
00362 typedef
00363 /*@only@*/ /*@null@*/ void * (*HDRunload) (Header h)
00364         /*@modifies h @*/;
00365 
00373 typedef
00374 /*@null@*/ Header (*HDRreload) (/*@only@*/ Header h, int tag)
00375         /*@modifies h @*/;
00376 
00382 typedef
00383 Header (*HDRcopy) (Header h)
00384         /*@modifies h @*/;
00385 
00391 typedef
00392 /*@null@*/ Header (*HDRload) (/*@kept@*/ void * uh)
00393         /*@modifies uh @*/;
00394 
00400 typedef
00401 /*@null@*/ Header (*HDRcopyload) (const void * uh)
00402         /*@*/;
00403 
00410 typedef
00411 /*@null@*/ Header (*HDRread) (FD_t fd, enum hMagic magicp)
00412         /*@modifies fd @*/;
00413 
00421 typedef
00422 int (*HDRwrite) (FD_t fd, /*@null@*/ Header h, enum hMagic magicp)
00423         /*@globals fileSystem @*/
00424         /*@modifies fd, h, fileSystem @*/;
00425 
00432 typedef
00433 int (*HDRisentry) (/*@null@*/Header h, int_32 tag)
00434         /*@*/;  
00435 
00443 typedef
00444 /*@null@*/ void * (*HDRfreetag) (Header h,
00445                 /*@only@*/ /*@null@*/ const void * data, rpmTagType type)
00446         /*@modifies data @*/;
00447 
00461 typedef
00462 int (*HDRget) (Header h, int_32 tag,
00463                         /*@null@*/ /*@out@*/ hTYP_t type,
00464                         /*@null@*/ /*@out@*/ void ** p,
00465                         /*@null@*/ /*@out@*/ hCNT_t c)
00466         /*@modifies *type, *p, *c @*/;
00467 
00480 typedef
00481 int (*HDRgetmin) (Header h, int_32 tag,
00482                         /*@null@*/ /*@out@*/ hTYP_t type,
00483                         /*@null@*/ /*@out@*/ hPTR_t * p,
00484                         /*@null@*/ /*@out@*/ hCNT_t c)
00485         /*@modifies *type, *p, *c @*/;
00486 
00501 typedef
00502 int (*HDRadd) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00503         /*@modifies h @*/;
00504 
00519 typedef
00520 int (*HDRappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00521         /*@modifies h @*/;
00522 
00533 typedef
00534 int (*HDRaddorappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00535         /*@modifies h @*/;
00536 
00557 typedef
00558 int (*HDRaddi18n) (Header h, int_32 tag, const char * string,
00559                 const char * lang)
00560         /*@modifies h @*/;
00561 
00572 typedef
00573 int (*HDRmodify) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00574         /*@modifies h @*/;
00575 
00585 typedef
00586 int (*HDRremove) (Header h, int_32 tag)
00587         /*@modifies h @*/;
00588 
00600 typedef
00601 /*@only@*/ char * (*HDRsprintf) (Header h, const char * fmt,
00602                      const struct headerTagTableEntry_s * tags,
00603                      const struct headerSprintfExtension_s * extensions,
00604                      /*@null@*/ /*@out@*/ errmsg_t * errmsg)
00605         /*@modifies *errmsg @*/;
00606 
00613 typedef
00614 void (*HDRcopytags) (Header headerFrom, Header headerTo, hTAG_t tagstocopy)
00615         /*@modifies headerFrom, headerTo @*/;
00616 
00622 typedef
00623 HeaderIterator (*HDRfreeiter) (/*@only@*/ HeaderIterator hi)
00624         /*@modifies hi @*/;
00625 
00631 typedef
00632 HeaderIterator (*HDRinititer) (Header h)
00633         /*@modifies h */;
00634 
00644 typedef
00645 int (*HDRnextiter) (HeaderIterator hi,
00646                 /*@null@*/ /*@out@*/ hTAG_t tag,
00647                 /*@null@*/ /*@out@*/ hTYP_t type,
00648                 /*@null@*/ /*@out@*/ hPTR_t * p,
00649                 /*@null@*/ /*@out@*/ hCNT_t c)
00650         /*@modifies hi, *tag, *type, *p, *c @*/;
00651 
00655 typedef /*@abstract@*/ struct HV_s * HV_t;
00656 struct HV_s {
00657     HDRlink     hdrlink;
00658     HDRunlink   hdrunlink;
00659     HDRfree     hdrfree;
00660     HDRnew      hdrnew;
00661     HDRsort     hdrsort;
00662     HDRunsort   hdrunsort;
00663     HDRsizeof   hdrsizeof;
00664     HDRunload   hdrunload;
00665     HDRreload   hdrreload;
00666     HDRcopy     hdrcopy;
00667     HDRload     hdrload;
00668     HDRcopyload hdrcopyload;
00669     HDRread     hdrread;
00670     HDRwrite    hdrwrite;
00671     HDRisentry  hdrisentry;
00672     HDRfreetag  hdrfreetag;
00673     HDRget      hdrget;
00674     HDRgetmin   hdrgetmin;
00675     HDRadd      hdradd;
00676     HDRappend   hdrappend;
00677     HDRaddorappend hdraddorappend;
00678     HDRaddi18n  hdraddi18n;
00679     HDRmodify   hdrmodify;
00680     HDRremove   hdrremove;
00681     HDRsprintf  hdrsprintf;
00682     HDRcopytags hdrcopytags;
00683     HDRfreeiter hdrfreeiter;
00684     HDRinititer hdrinititer;
00685     HDRnextiter hdrnextiter;
00686 /*@null@*/
00687     void *      hdrvecs;
00688 /*@null@*/
00689     void *      hdrdata;
00690     int         hdrversion;
00691 };
00692 
00702 /*@unused@*/ static inline /*@null@*/
00703 void * headerFreeData( /*@only@*/ /*@null@*/ const void * data, rpmTagType type)
00704         /*@modifies data @*/
00705 {
00706     if (data) {
00707         /*@-branchstate@*/
00708         if (type == -1 ||
00709             type == RPM_STRING_ARRAY_TYPE ||
00710             type == RPM_I18NSTRING_TYPE ||
00711             type == RPM_BIN_TYPE)
00712                 free((void *)data);
00713         /*@=branchstate@*/
00714     }
00715     return NULL;
00716 }
00717 
00718 #if !defined(__HEADER_PROTOTYPES__)
00719 #include "hdrinline.h"
00720 #endif
00721 
00722 #ifdef __cplusplus
00723 }
00724 #endif
00725 
00726 #endif  /* H_HEADER */

Generated on Sun Oct 26 13:02:02 2003 for rpm by doxygen1.2.18