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

lib/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 headerSprintfExtenstionType {
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);
00173 typedef int (*headerTagTagFunction) (Header h,
00174                 /*@null@*/ /*@out@*/ hTYP_t type,
00175                 /*@null@*/ /*@out@*/ hPTR_t * data,
00176                 /*@null@*/ /*@out@*/ hCNT_t count,
00177                 /*@null@*/ /*@out@*/ int * freeData);
00178 
00182 typedef /*@abstract@*/ struct headerSprintfExtension_s * headerSprintfExtension;
00183 struct headerSprintfExtension_s {
00184     enum headerSprintfExtenstionType type;      
00185 /*@observer@*/ /*@null@*/ const char * name;    
00186     union {
00187 /*@unused@*/ void * generic;                    
00188         headerTagFormatFunction formatFunction; 
00189         headerTagTagFunction tagFunction;       
00190         struct headerSprintfExtension_s * more; 
00191     } u;
00192 };
00193 
00197 /*@-redecl@*/
00198 extern const struct headerSprintfExtension_s headerDefaultFormats[];
00199 /*@=redecl@*/
00200 
00204 enum hMagic {
00205         HEADER_MAGIC_NO         = 0,
00206         HEADER_MAGIC_YES        = 1
00207 };
00208 
00212 typedef enum rpmTagType_e {
00213 #define RPM_MIN_TYPE            0
00214     RPM_NULL_TYPE               =  0,
00215     RPM_CHAR_TYPE               =  1,
00216     RPM_INT8_TYPE               =  2,
00217     RPM_INT16_TYPE              =  3,
00218     RPM_INT32_TYPE              =  4,
00219 /*    RPM_INT64_TYPE    = 5,   ---- These aren't supported (yet) */
00220     RPM_STRING_TYPE             =  6,
00221     RPM_BIN_TYPE                =  7,
00222     RPM_STRING_ARRAY_TYPE       =  8,
00223     RPM_I18NSTRING_TYPE         =  9
00224 #define RPM_MAX_TYPE            9
00225 } rpmTagType;
00226 
00235 /*@-enummemuse -typeuse @*/
00236 typedef enum rpmSubTagType_e {
00237         RPM_REGION_TYPE         = -10,
00238         RPM_BIN_ARRAY_TYPE      = -11,
00241         RPM_XREF_TYPE           = -12
00244 } rpmSubTagType;
00245 /*@=enummemuse =typeuse @*/
00246 
00251 #define HEADER_IMAGE            61
00252 #define HEADER_SIGNATURES       62
00253 #define HEADER_IMMUTABLE        63
00254 #define HEADER_REGIONS          64
00255 #define HEADER_I18NTABLE        100
00256 #define HEADER_SIGBASE          256
00257 #define HEADER_TAGBASE          1000
00258 
00261 /*@-typeuse -fielduse@*/
00262 typedef union hRET_s {
00263     const void * ptr;
00264     const char ** argv;
00265     const char * str;
00266     uint_32 * ui32p;
00267     uint_16 * ui16p;
00268     int_32 * i32p;
00269     int_16 * i16p;
00270     int_8 * i8p;
00271 } * hRET_t;
00272 /*@=typeuse =fielduse@*/
00273 
00276 /*@-typeuse -fielduse@*/
00277 typedef struct HE_s {
00278     int_32 tag;
00279 /*@null@*/ hTYP_t typ;
00280     union {
00281 /*@null@*/ hPTR_t * ptr;
00282 /*@null@*/ hRET_t * ret;
00283     } u;
00284 /*@null@*/ hCNT_t cnt;
00285 } * HE_t;
00286 /*@=typeuse =fielduse@*/
00287 
00292 typedef
00293 Header (*HDRnew) (void)
00294         /*@*/;
00295 
00301 typedef
00302 /*@null@*/ Header (*HDRfree) (/*@null@*/ /*@killref@*/ Header h)
00303         /*@modifies h @*/;
00304 
00310 typedef
00311 Header (*HDRlink) (Header h)
00312         /*@modifies h @*/;
00313 
00319 typedef
00320 void (*HDRsort) (Header h)
00321         /*@modifies h @*/;
00322 
00328 typedef
00329 void (*HDRunsort) (Header h)
00330         /*@modifies h @*/;
00331 
00338 typedef
00339 unsigned int (*HDRsizeof) (/*@null@*/ Header h, enum hMagic magicp)
00340         /*@modifies h @*/;
00341 
00347 typedef
00348 /*@only@*/ /*@null@*/ void * (*HDRunload) (Header h)
00349         /*@modifies h @*/;
00350 
00358 typedef
00359 /*@null@*/ Header (*HDRreload) (/*@only@*/ Header h, int tag)
00360         /*@modifies h @*/;
00361 
00367 typedef
00368 Header (*HDRcopy) (Header h)
00369         /*@modifies h @*/;
00370 
00376 typedef
00377 /*@null@*/ Header (*HDRload) (/*@kept@*/ void * uh)
00378         /*@modifies uh @*/;
00379 
00385 typedef
00386 /*@null@*/ Header (*HDRcopyload) (const void * uh)
00387         /*@*/;
00388 
00395 typedef
00396 /*@null@*/ Header (*HDRhdrread) (FD_t fd, enum hMagic magicp)
00397         /*@modifies fd, fileSystem @*/;
00398 
00406 typedef
00407 int (*HDRhdrwrite) (FD_t fd, /*@null@*/ Header h, enum hMagic magicp)
00408         /*@modifies fd, h, fileSystem @*/;
00409 
00416 typedef
00417 int (*HDRisentry) (/*@null@*/Header h, int_32 tag)
00418         /*@*/;  
00419 
00427 typedef
00428 /*@null@*/ void * (*HDRfreetag) (Header h,
00429                 /*@only@*/ /*@null@*/ const void * data, rpmTagType type)
00430         /*@modifies data @*/;
00431 
00445 typedef
00446 int (*HDRget) (Header h, int_32 tag,
00447                         /*@null@*/ /*@out@*/ hTYP_t type,
00448                         /*@null@*/ /*@out@*/ void ** p,
00449                         /*@null@*/ /*@out@*/ hCNT_t c)
00450         /*@modifies *type, *p, *c @*/;
00451 
00464 typedef
00465 int (*HDRgetmin) (Header h, int_32 tag,
00466                         /*@null@*/ /*@out@*/ hTYP_t type,
00467                         /*@null@*/ /*@out@*/ hPTR_t * p,
00468                         /*@null@*/ /*@out@*/ hCNT_t c)
00469         /*@modifies *type, *p, *c @*/;
00470 
00485 typedef
00486 int (*HDRadd) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00487         /*@modifies h @*/;
00488 
00503 typedef
00504 int (*HDRappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00505         /*@modifies h @*/;
00506 
00517 typedef
00518 int (*HDRaddorappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00519         /*@modifies h @*/;
00520 
00541 typedef
00542 int (*HDRaddi18n) (Header h, int_32 tag, const char * string,
00543                 const char * lang)
00544         /*@modifies h @*/;
00545 
00556 typedef
00557 int (*HDRmodify) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00558         /*@modifies h @*/;
00559 
00569 typedef
00570 int (*HDRremove) (Header h, int_32 tag)
00571         /*@modifies h @*/;
00572 
00584 typedef
00585 /*@only@*/ char * (*HDRhdrsprintf) (Header h, const char * fmt,
00586                      const struct headerTagTableEntry_s * tags,
00587                      const struct headerSprintfExtension_s * extensions,
00588                      /*@null@*/ /*@out@*/ errmsg_t * errmsg)
00589         /*@modifies *errmsg @*/;
00590 
00597 typedef
00598 void (*HDRcopytags) (Header headerFrom, Header headerTo, hTAG_t tagstocopy)
00599         /*@modifies headerFrom, headerTo @*/;
00600 
00606 typedef
00607 HeaderIterator (*HDRfreeiter) (/*@only@*/ HeaderIterator hi)
00608         /*@modifies hi @*/;
00609 
00615 typedef
00616 HeaderIterator (*HDRinititer) (Header h)
00617         /*@modifies h */;
00618 
00628 typedef
00629 int (*HDRnextiter) (HeaderIterator hi,
00630                 /*@null@*/ /*@out@*/ hTAG_t tag,
00631                 /*@null@*/ /*@out@*/ hTYP_t type,
00632                 /*@null@*/ /*@out@*/ hPTR_t * p,
00633                 /*@null@*/ /*@out@*/ hCNT_t c)
00634         /*@modifies hi, *tag, *type, *p, *c @*/;
00635 
00639 typedef /*@abstract@*/ struct HV_s * HV_t;
00640 struct HV_s {
00641     HDRnew      hdrnew;
00642     HDRfree     hdrfree;
00643     HDRlink     hdrlink;
00644     HDRsort     hdrsort;
00645     HDRunsort   hdrunsort;
00646     HDRsizeof   hdrsizeof;
00647     HDRunload   hdrunload;
00648     HDRreload   hdrreload;
00649     HDRcopy     hdrcopy;
00650     HDRload     hdrload;
00651     HDRcopyload hdrcopyload;
00652     HDRhdrread  hdrread;
00653     HDRhdrwrite hdrwrite;
00654     HDRisentry  hdrisentry;
00655     HDRfreetag  hdrfreetag;
00656     HDRget      hdrget;
00657     HDRgetmin   hdrgetmin;
00658     HDRadd      hdradd;
00659     HDRappend   hdrappend;
00660     HDRaddorappend hdraddorappend;
00661     HDRaddi18n  hdraddi18n;
00662     HDRmodify   hdrmodify;
00663     HDRremove   hdrremove;
00664     HDRhdrsprintf hdrsprintf;
00665     HDRcopytags hdrcopytags;
00666     HDRfreeiter hdrfreeiter;
00667     HDRinititer hdrinititer;
00668     HDRnextiter hdrnextiter;
00669     void *      hdrvecs;
00670     void *      hdrdata;
00671     int         hdrversion;
00672 };
00673 
00683 /*@unused@*/ static inline /*@null@*/
00684 void * headerFreeData( /*@only@*/ /*@null@*/ const void * data, rpmTagType type)
00685         /*@modifies data @*/
00686 {
00687     if (data) {
00688         /*@-branchstate@*/
00689         if (type == -1 ||
00690             type == RPM_STRING_ARRAY_TYPE ||
00691             type == RPM_I18NSTRING_TYPE ||
00692             type == RPM_BIN_TYPE)
00693                 free((void *)data);
00694         /*@=branchstate@*/
00695     }
00696     return NULL;
00697 }
00698 
00699 #if defined(__HEADER_PROTOTYPES__)
00700 #include <hdrproto.h>
00701 #else
00702 #include <hdrinline.h>
00703 #endif
00704 
00705 #ifdef __cplusplus
00706 }
00707 #endif
00708 
00709 #endif  /* H_HEADER */

Generated at Mon Sep 24 10:37:17 2001 for rpm by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001