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 
00078 /* RPM - Copyright (C) 1995-2001 Red Hat Software */
00079 
00080 #include <stdio.h>
00081 #include <rpmio.h>
00082 
00083 #ifdef __cplusplus
00084 extern "C" {
00085 #endif
00086 
00087 #if defined(__alpha__) || defined(__alpha)
00088 typedef long int int_64;
00089 typedef int int_32;
00090 typedef short int int_16;
00091 typedef char int_8;
00092 
00093 typedef unsigned int uint_32;
00094 typedef unsigned short uint_16;
00095 
00096 #else
00097 
00098 #if 0   /* XXX hpux needs -Ae in CFLAGS to grok this */
00099 typedef long long int int_64;
00100 #endif
00101 typedef int int_32;
00102 typedef short int int_16;
00103 typedef char int_8;
00104 
00105 typedef unsigned int uint_32;
00106 typedef unsigned short uint_16;
00107 #endif
00108 
00109 /*@-redef@*/    /* LCL: no clue */
00112 typedef const char *    errmsg_t;
00113 
00116 typedef int_32 *        hTAG_t;
00117 typedef int_32 *        hTYP_t;
00118 typedef const void *    hPTR_t;
00119 typedef int_32 *        hCNT_t;
00120 
00123 typedef /*@abstract@*/ /*@refcounted@*/ struct headerToken * Header;
00124 
00127 typedef /*@abstract@*/ struct headerIteratorS * HeaderIterator;
00128 
00132 typedef /*@abstract@*/ struct headerTagTableEntry_s * headerTagTableEntry;
00133 struct headerTagTableEntry_s {
00134 /*@observer@*/ /*@null@*/ const char * name;    
00135     int val;                                    
00136 };
00137 
00140 enum headerSprintfExtensionType {
00141     HEADER_EXT_LAST = 0,        
00142     HEADER_EXT_FORMAT,          
00143     HEADER_EXT_MORE,            
00144     HEADER_EXT_TAG              
00145 };
00146 
00159 typedef /*only@*/ char * (*headerTagFormatFunction)(int_32 type,
00160                                 const void * data, char * formatPrefix,
00161                                 int padding, int element)
00162         /*@requires maxSet(data) >= 0 @*/;
00163 
00175 typedef int (*headerTagTagFunction) (Header h,
00176                 /*@null@*/ /*@out@*/ hTYP_t type,
00177                 /*@null@*/ /*@out@*/ hPTR_t * data,
00178                 /*@null@*/ /*@out@*/ hCNT_t count,
00179                 /*@null@*/ /*@out@*/ int * freeData)
00180         /*@requires maxSet(type) >= 0 /\ maxSet(data) >= 0
00181                 /\ maxSet(count) >= 0 /\ maxSet(freeData) >= 0 @*/;
00182 
00186 typedef /*@abstract@*/ struct headerSprintfExtension_s * headerSprintfExtension;
00187 struct headerSprintfExtension_s {
00188     enum headerSprintfExtensionType type;       
00189 /*@observer@*/ /*@null@*/
00190     const char * name;                          
00191     union {
00192 /*@observer@*/ /*@null@*/
00193         void * generic;                         
00194         headerTagFormatFunction formatFunction; 
00195         headerTagTagFunction tagFunction;       
00196         struct headerSprintfExtension_s * more; 
00197     } u;
00198 };
00199 
00203 /*@-redecl@*/
00204 /*@observer@*/
00205 extern const struct headerSprintfExtension_s headerDefaultFormats[];
00206 /*@=redecl@*/
00207 
00211 enum hMagic {
00212     HEADER_MAGIC_NO             = 0,
00213     HEADER_MAGIC_YES            = 1
00214 };
00215 
00219 typedef enum rpmTagType_e {
00220 #define RPM_MIN_TYPE            0
00221     RPM_NULL_TYPE               =  0,
00222     RPM_CHAR_TYPE               =  1,
00223     RPM_INT8_TYPE               =  2,
00224     RPM_INT16_TYPE              =  3,
00225     RPM_INT32_TYPE              =  4,
00226 /*    RPM_INT64_TYPE    = 5,   ---- These aren't supported (yet) */
00227     RPM_STRING_TYPE             =  6,
00228     RPM_BIN_TYPE                =  7,
00229     RPM_STRING_ARRAY_TYPE       =  8,
00230     RPM_I18NSTRING_TYPE         =  9
00231 #define RPM_MAX_TYPE            9
00232 } rpmTagType;
00233 
00242 /*@-enummemuse -typeuse @*/
00243 typedef enum rpmSubTagType_e {
00244     RPM_REGION_TYPE             = -10,
00245     RPM_BIN_ARRAY_TYPE          = -11,
00248     RPM_XREF_TYPE               = -12
00251 } rpmSubTagType;
00252 /*@=enummemuse =typeuse @*/
00253 
00258 #define HEADER_IMAGE            61
00259 #define HEADER_SIGNATURES       62
00260 #define HEADER_IMMUTABLE        63
00261 #define HEADER_REGIONS          64
00262 #define HEADER_I18NTABLE        100
00263 #define HEADER_SIGBASE          256
00264 #define HEADER_TAGBASE          1000
00265 
00268 /*@-typeuse -fielduse@*/
00269 typedef union hRET_s {
00270     const void * ptr;
00271     const char ** argv;
00272     const char * str;
00273     uint_32 * ui32p;
00274     uint_16 * ui16p;
00275     int_32 * i32p;
00276     int_16 * i16p;
00277     int_8 * i8p;
00278 } * hRET_t;
00279 /*@=typeuse =fielduse@*/
00280 
00283 /*@-typeuse -fielduse@*/
00284 typedef struct HE_s {
00285     int_32 tag;
00286 /*@null@*/ hTYP_t typ;
00287     union {
00288 /*@null@*/ hPTR_t * ptr;
00289 /*@null@*/ hRET_t * ret;
00290     } u;
00291 /*@null@*/ 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 Wed Sep 4 12:49:55 2002 for rpm by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002