00001 #ifndef H_HEADER
00002 #define H_HEADER
00003
00080
00081
00082 #include <stdio.h>
00083 #include "rpmio.h"
00084
00085 #ifdef __cplusplus
00086 extern "C" {
00087 #endif
00088
00089 #if 0
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
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
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 struct headerToken_s * Header;
00118
00121 typedef struct headerIterator_s * HeaderIterator;
00122
00126 typedef struct headerTagTableEntry_s * headerTagTableEntry;
00127 struct headerTagTableEntry_s {
00128
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 char * (*headerTagFormatFunction)(int_32 type,
00156 const void * data, char * formatPrefix,
00157 int padding, int element)
00158 ;
00159
00171 typedef int (*headerTagTagFunction) (Header h,
00172 hTYP_t type,
00173 hPTR_t * data,
00174 hCNT_t count,
00175 int * freeData)
00176
00177 ;
00178
00182 typedef struct headerSprintfExtension_s * headerSprintfExtension;
00183 struct headerSprintfExtension_s {
00184 enum headerSprintfExtensionType type;
00185
00186 const char * name;
00187 union {
00188
00189 void * generic;
00190 headerTagFormatFunction formatFunction;
00191 headerTagTagFunction tagFunction;
00192 struct headerSprintfExtension_s * more;
00193 } u;
00194 };
00195
00199
00200
00201 extern const struct headerSprintfExtension_s headerDefaultFormats[];
00202
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
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
00239 typedef enum rpmSubTagType_e {
00240 RPM_REGION_TYPE = -10,
00241 RPM_BIN_ARRAY_TYPE = -11,
00244 RPM_XREF_TYPE = -12
00247 } rpmSubTagType;
00248
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
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
00276
00279
00280 typedef struct HE_s {
00281 int_32 tag;
00282
00283 hTYP_t typ;
00284 union {
00285
00286 hPTR_t * ptr;
00287
00288 hRET_t * ret;
00289 } u;
00290
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