00001 #ifndef H_HEADER
00002 #define H_HEADER
00003
00078
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
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
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 struct headerToken * Header;
00124
00127 typedef struct headerIteratorS * HeaderIterator;
00128
00132 typedef struct headerTagTableEntry_s * headerTagTableEntry;
00133 struct headerTagTableEntry_s {
00134 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 char * (*headerTagFormatFunction)(int_32 type,
00160 const void * data, char * formatPrefix,
00161 int padding, int element)
00162 ;
00163
00175 typedef int (*headerTagTagFunction) (Header h,
00176 hTYP_t type,
00177 hPTR_t * data,
00178 hCNT_t count,
00179 int * freeData)
00180
00181 ;
00182
00186 typedef struct headerSprintfExtension_s * headerSprintfExtension;
00187 struct headerSprintfExtension_s {
00188 enum headerSprintfExtensionType type;
00189
00190 const char * name;
00191 union {
00192
00193 void * generic;
00194 headerTagFormatFunction formatFunction;
00195 headerTagTagFunction tagFunction;
00196 struct headerSprintfExtension_s * more;
00197 } u;
00198 };
00199
00203
00204
00205 extern const struct headerSprintfExtension_s headerDefaultFormats[];
00206
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
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
00243 typedef enum rpmSubTagType_e {
00244 RPM_REGION_TYPE = -10,
00245 RPM_BIN_ARRAY_TYPE = -11,
00248 RPM_XREF_TYPE = -12
00251 } rpmSubTagType;
00252
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
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
00280
00283
00284 typedef struct HE_s {
00285 int_32 tag;
00286 hTYP_t typ;
00287 union {
00288 hPTR_t * ptr;
00289 hRET_t * ret;
00290 } u;
00291 hCNT_t cnt;
00292 } * HE_t;
00293
00294
00299 typedef
00300 Header (*HDRnew) (void)
00301 ;
00302
00308 typedef
00309 Header (*HDRfree) ( Header h)
00310 ;
00311
00317 typedef
00318 Header (*HDRlink) (Header h)
00319 ;
00320
00326 typedef
00327 Header (*HDRunlink) ( Header h)
00328 ;
00329
00335 typedef
00336 void (*HDRsort) (Header h)
00337 ;
00338
00344 typedef
00345 void (*HDRunsort) (Header h)
00346 ;
00347
00354 typedef
00355 unsigned int (*HDRsizeof) ( Header h, enum hMagic magicp)
00356 ;
00357
00363 typedef
00364 void * (*HDRunload) (Header h)
00365 ;
00366
00374 typedef
00375 Header (*HDRreload) ( Header h, int tag)
00376 ;
00377
00383 typedef
00384 Header (*HDRcopy) (Header h)
00385 ;
00386
00392 typedef
00393 Header (*HDRload) ( void * uh)
00394 ;
00395
00401 typedef
00402 Header (*HDRcopyload) (const void * uh)
00403 ;
00404
00411 typedef
00412 Header (*HDRread) (FD_t fd, enum hMagic magicp)
00413 ;
00414
00422 typedef
00423 int (*HDRwrite) (FD_t fd, Header h, enum hMagic magicp)
00424
00425 ;
00426
00433 typedef
00434 int (*HDRisentry) (Header h, int_32 tag)
00435 ;
00436
00444 typedef
00445 void * (*HDRfreetag) (Header h,
00446 const void * data, rpmTagType type)
00447 ;
00448
00462 typedef
00463 int (*HDRget) (Header h, int_32 tag,
00464 hTYP_t type,
00465 void ** p,
00466 hCNT_t c)
00467 ;
00468
00481 typedef
00482 int (*HDRgetmin) (Header h, int_32 tag,
00483 hTYP_t type,
00484 hPTR_t * p,
00485 hCNT_t c)
00486 ;
00487
00502 typedef
00503 int (*HDRadd) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00504 ;
00505
00520 typedef
00521 int (*HDRappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00522 ;
00523
00534 typedef
00535 int (*HDRaddorappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00536 ;
00537
00558 typedef
00559 int (*HDRaddi18n) (Header h, int_32 tag, const char * string,
00560 const char * lang)
00561 ;
00562
00573 typedef
00574 int (*HDRmodify) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
00575 ;
00576
00586 typedef
00587 int (*HDRremove) (Header h, int_32 tag)
00588 ;
00589
00601 typedef
00602 char * (*HDRsprintf) (Header h, const char * fmt,
00603 const struct headerTagTableEntry_s * tags,
00604 const struct headerSprintfExtension_s * extensions,
00605 errmsg_t * errmsg)
00606 ;
00607
00614 typedef
00615 void (*HDRcopytags) (Header headerFrom, Header headerTo, hTAG_t tagstocopy)
00616 ;
00617
00623 typedef
00624 HeaderIterator (*HDRfreeiter) ( HeaderIterator hi)
00625 ;
00626
00632 typedef
00633 HeaderIterator (*HDRinititer) (Header h)
00634 ;
00635
00645 typedef
00646 int (*HDRnextiter) (HeaderIterator hi,
00647 hTAG_t tag,
00648 hTYP_t type,
00649 hPTR_t * p,
00650 hCNT_t c)
00651 ;
00652
00656 typedef 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
00688 void * hdrvecs;
00689
00690 void * hdrdata;
00691 int hdrversion;
00692 };
00693
00703 static inline
00704 void * headerFreeData( const void * data, rpmTagType type)
00705
00706 {
00707 if (data) {
00708
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
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