rpm  4.5
header.h
Go to the documentation of this file.
1 #ifndef H_HEADER
2 #define H_HEADER
3 
80 /* RPM - Copyright (C) 1995-2001 Red Hat Software */
81 
82 #include "rpmio.h"
83 
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
87 
88 /* XXX hpux needs -Ae in CFLAGS to grok this */
89 typedef long long int int_64;
90 typedef int int_32;
91 typedef short int int_16;
92 typedef char int_8;
93 
94 /* XXX hpux needs -Ae in CFLAGS to grok this */
95 typedef unsigned long long int uint_64;
96 typedef unsigned int uint_32;
97 typedef unsigned short uint_16;
98 typedef unsigned char uint_8;
99 
102 typedef const char * errmsg_t;
103 
106 typedef /*@abstract@*/ /*@refcounted@*/ struct headerToken_s * Header;
107 
124  RPM_MASK_TYPE = 0x0000ffff
125 };
126 #define RPM_MIN_TYPE 0
127 #define RPM_MAX_TYPE 11
128 
129 #define RPM_UINT8_TYPE RPM_INT8_TYPE
130 #define RPM_UINT16_TYPE RPM_INT16_TYPE
131 #define RPM_UINT32_TYPE RPM_INT32_TYPE
132 #define RPM_UINT64_TYPE RPM_INT64_TYPE
133 
137 
140 typedef union rpmDataType_u rpmTagData;
141 
144 typedef int_32 rpmTagCount;
145 
148 typedef struct _HE_s * HE_t; /* tag container. */
149 
152 /*@-typeuse -fielduse@*/
153 typedef union rpmDataType_u hRET_t;
154 #if !defined(SWIG)
156  void * ptr;
157  int_8 * i8p;
158  int_32 * i32p;
159  int_16 * i16p;
160  int_64 * i64p;
161  const char * str;
162  unsigned char * blob;
163  const char ** argv;
164  uint_8 * ui8p;
165  uint_16 * ui16p;
166  uint_32 * ui32p;
167  uint_64 * ui64p;
168  HE_t * he;
169 };
170 #endif
171 /*@=typeuse =fielduse@*/
172 
175 typedef int_32 * hTAG_t;
176 #ifdef NOTYET
177 typedef rpmTagType * hTYP_t;
178 typedef rpmTagData * hPTR_t;
179 typedef rpmTagCount * hCNT_t;
180 #else
181 typedef int_32 * hTYP_t;
182 typedef const void * hPTR_t;
183 typedef int_32 * hCNT_t;
184 #endif
185 
188 /*@-typeuse -fielduse@*/
189 #if !defined(SWIG)
190 struct _HE_s {
191  int_32 tag;
192  rpmTagType t;
193 /*@owned@*/ /*@null@*/
195  rpmTagCount c;
196  int ix;
197  unsigned int freeData : 1;
198  unsigned int avail : 1;
199  unsigned int append : 1;
200 };
201 typedef struct _HE_s HE_s;
202 #endif
203 /*@=typeuse =fielduse@*/
204 
207 typedef /*@abstract@*/ struct headerIterator_s * HeaderIterator;
208 
212 typedef /*@abstract@*/ struct headerTagTableEntry_s * headerTagTableEntry;
213 #if !defined(SWIG)
215 /*@observer@*/ /*@relnull@*/
216  const char * name;
217  int val;
218  int type;
219 };
220 #endif
221 
224 typedef /*@abstract@*/ struct headerTagIndices_s * headerTagIndices;
225 #if !defined(SWIG)
227  int (*loadIndex) (headerTagTableEntry ** ipp, int * np,
228  int (*cmp) (const void * avp, const void * bvp))
229  /*@ modifies *ipp, *np */;
230 /*@relnull@*/
231  headerTagTableEntry * byName;
233  int (*byNameCmp) (const void * avp, const void * bvp)
234  /*@*/;
235  int (*tagValue) (const char * name)
236  /*@*/; /* return value from name. */
237 /*@relnull@*/
238  headerTagTableEntry * byValue;
240  int (*byValueCmp) (const void * avp, const void * bvp)
241  /*@*/;
242  const char * (*tagName) (int value)
243  /*@*/; /* Return name from value. */
244  int (*tagType) (int value)
245  /*@*/; /* Return type from value. */
246 };
247 #endif
248 
256 };
257 
264 typedef /*only@*/ char * (*headerTagFormatFunction) (HE_t he, /*@null@*/ const char ** av)
265  /*@modifies he @*/;
266 
275 typedef int (*headerTagTagFunction) (Header h, HE_t he)
276  /*@modifies he @*/;
277 
281 typedef /*@abstract@*/ struct headerSprintfExtension_s * headerSprintfExtension;
282 #if !defined(SWIG)
285 /*@observer@*/ /*@null@*/
286  const char * name;
287  union {
288 /*@observer@*/ /*@null@*/
289  void * generic;
293  } u;
294 };
295 #endif
296 
300 /*@-redecl@*/
301 /*@observer@*/
302 extern const struct headerSprintfExtension_s headerDefaultFormats[];
303 /*@=redecl@*/
304 
308 enum hMagic {
311 };
312 
321 /*@-enummemuse -typeuse @*/
322 typedef enum rpmSubTagType_e {
330 } rpmSubTagType;
331 /*@=enummemuse =typeuse @*/
332 
336 /*@-enummemuse -typeuse @*/
337 typedef enum rpmTagReturnType_e {
340  RPM_ARRAY_RETURN_TYPE = 0x00020000,
342  RPM_MASK_RETURN_TYPE = 0xffff0000
344 /*@=enummemuse =typeuse @*/
345 
350 #define HEADER_IMAGE 61
351 #define HEADER_SIGNATURES 62
352 #define HEADER_IMMUTABLE 63
353 #define HEADER_REGIONS 64
354 #define HEADER_I18NTABLE 100
355 #define HEADER_SIGBASE 256
356 #define HEADER_TAGBASE 1000
357 
365 typedef /*@null@*/
366  void * (*HFD_t) (/*@only@*/ /*@null@*/ const void * data, rpmTagType type)
367  /*@modifies data @*/;
368 
383 typedef int (*HGE_t) (Header h, int_32 tag,
384  /*@null@*/ /*@out@*/ rpmTagType * type,
385  /*@null@*/ /*@out@*/ void * p,
386  /*@null@*/ /*@out@*/ int_32 * c)
387  /*@modifies *type, *p, *c @*/;
388 
404 typedef int (*HAE_t) (Header h, int_32 tag, rpmTagType type,
405  const void * p, int_32 c)
406  /*@modifies h @*/;
407 
419 typedef int (*HME_t) (Header h, int_32 tag, rpmTagType type,
420  const void * p, int_32 c)
421  /*@modifies h @*/;
422 
433 typedef int (*HRE_t) (Header h, int_32 tag)
434  /*@modifies h @*/;
435 
440 typedef
441 Header (*HDRnew) (void)
442  /*@*/;
443 
449 typedef
450 /*@null@*/ Header (*HDRfree) (/*@killref@*/ /*@null@*/ Header h)
451  /*@modifies h @*/;
452 
458 typedef
459 Header (*HDRlink) (Header h)
460  /*@modifies h @*/;
461 
467 typedef
468 Header (*HDRunlink) (/*@killref@*/ /*@null@*/ Header h)
469  /*@modifies h @*/;
470 
476 typedef
477 void (*HDRsort) (Header h)
478  /*@modifies h @*/;
479 
485 typedef
486 void (*HDRunsort) (Header h)
487  /*@modifies h @*/;
488 
495 typedef
496 unsigned int (*HDRsizeof) (/*@null@*/ Header h, enum hMagic magicp)
497  /*@modifies h @*/;
498 
504 typedef
505 /*@only@*/ /*@null@*/ void * (*HDRunload) (Header h)
506  /*@modifies h @*/;
507 
515 typedef
516 /*@null@*/ Header (*HDRreload) (/*@only@*/ Header h, int tag)
517  /*@modifies h @*/;
518 
524 typedef
525 Header (*HDRcopy) (Header h)
526  /*@modifies h @*/;
527 
533 typedef
534 /*@null@*/ Header (*HDRload) (/*@kept@*/ void * uh)
535  /*@modifies uh @*/;
536 
542 typedef
543 /*@null@*/ Header (*HDRcopyload) (const void * uh)
544  /*@*/;
545 
552 typedef
553 /*@null@*/ Header (*HDRread) (void * _fd, enum hMagic magicp)
554  /*@modifies _fd @*/;
555 
563 typedef
564 int (*HDRwrite) (void * _fd, /*@null@*/ Header h, enum hMagic magicp)
565  /*@globals fileSystem @*/
566  /*@modifies _fd, h, fileSystem @*/;
567 
574 typedef
575 int (*HDRisentry) (/*@null@*/Header h, int_32 tag)
576  /*@*/;
577 
585 typedef
586 /*@null@*/ void * (*HDRfreetag) (Header h,
587  /*@only@*/ /*@null@*/ const void * data, rpmTagType type)
588  /*@modifies data @*/;
589 
600 typedef
601 int (*HDRext) (Header h, int_32 tag,
602  /*@null@*/ /*@out@*/ hTYP_t type,
603  /*@null@*/ /*@out@*/ hRET_t * p,
604  /*@null@*/ /*@out@*/ hCNT_t c)
605  /*@modifies *type, *p, *c @*/;
606 
620 typedef
621 int (*HDRget) (Header h, int_32 tag,
622  /*@null@*/ /*@out@*/ hTYP_t type,
623  /*@null@*/ /*@out@*/ void * p,
624  /*@null@*/ /*@out@*/ hCNT_t c)
625  /*@modifies *type, *p, *c @*/;
626 
639 typedef
640 int (*HDRgetmin) (Header h, int_32 tag,
641  /*@null@*/ /*@out@*/ hTYP_t type,
642  /*@null@*/ /*@out@*/ void * p,
643  /*@null@*/ /*@out@*/ hCNT_t c)
644  /*@modifies *type, *p, *c @*/;
645 
660 typedef
661 int (*HDRadd) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
662  /*@modifies h @*/;
663 
678 typedef
679 int (*HDRappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
680  /*@modifies h @*/;
681 
692 typedef
693 int (*HDRaddorappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
694  /*@modifies h @*/;
695 
716 typedef
717 int (*HDRaddi18n) (Header h, int_32 tag, const char * string,
718  const char * lang)
719  /*@modifies h @*/;
720 
731 typedef
732 int (*HDRmodify) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
733  /*@modifies h @*/;
734 
744 typedef
745 int (*HDRremove) (Header h, int_32 tag)
746  /*@modifies h @*/;
747 
759 typedef
760 /*@only@*/ char * (*HDRsprintf) (Header h, const char * fmt,
761  const struct headerTagTableEntry_s * tags,
762  const struct headerSprintfExtension_s * exts,
763  /*@null@*/ /*@out@*/ errmsg_t * errmsg)
764  /*@modifies *errmsg @*/;
765 
772 typedef
773 void (*HDRcopytags) (Header headerFrom, Header headerTo, hTAG_t tagstocopy)
774  /*@modifies headerFrom, headerTo @*/;
775 
781 typedef
782 HeaderIterator (*HDRfreeiter) (/*@only@*/ HeaderIterator hi)
783  /*@modifies hi @*/;
784 
790 typedef
792  /*@modifies h */;
793 
803 typedef
804 int (*HDRnextiter) (HeaderIterator hi,
805  /*@null@*/ /*@out@*/ hTAG_t tag,
806  /*@null@*/ /*@out@*/ hTYP_t type,
807  /*@null@*/ /*@out@*/ hPTR_t * p,
808  /*@null@*/ /*@out@*/ hCNT_t c)
809  /*@modifies hi, *tag, *type, *p, *c @*/;
810 
818 typedef
819 int (*HDRgetmagic)(/*@null@*/ Header h, unsigned char **magicp, size_t *nmagicp)
820  /*@*/;
821 
829 typedef
830 int (*HDRsetmagic)(/*@null@*/ Header h, unsigned char * magic, size_t nmagic)
831  /*@modifies h @*/;
832 
838 typedef /*@observer@*/ /*@null@*/
839 const char * (*HDRgetorigin) (/*@null@*/ Header h)
840  /*@*/;
841 
848 typedef
849 int (*HDRsetorigin) (/*@null@*/ Header h, const char * origin)
850  /*@modifies h @*/;
851 
857 typedef
858 int (*HDRgetinstance) (/*@null@*/ Header h)
859  /*@*/;
860 
867 typedef
868 int (*HDRsetinstance) (/*@null@*/ Header h, int instance)
869  /*@modifies h @*/;
870 
877 typedef
878 /*@null@*/ void * (*HDRgetstats) (Header h, int opx)
879  /*@*/;
880 
884 typedef /*@abstract@*/ struct HV_s * HV_t;
885 #if !defined(SWIG)
886 struct HV_s {
920 /*@null@*/
921  void * hdrvecs;
922 /*@null@*/
923  void * hdrdata;
925 };
926 #endif
927 
928 #if !defined(SWIG)
929 
938 /*@unused@*/ static inline /*@null@*/
939 void * headerFreeData( /*@only@*/ /*@null@*/ const void * data, rpmTagType type)
940  /*@modifies data @*/
941 {
942  if (data) {
943  /*@-branchstate@*/
944  if (type == -1 ||
945  type == RPM_STRING_ARRAY_TYPE ||
946  type == RPM_I18NSTRING_TYPE ||
947  type == RPM_BIN_TYPE)
948  free((void *)data);
949  /*@=branchstate@*/
950  }
951  return NULL;
952 }
953 #endif
954 
955 #if !defined(__HEADER_PROTOTYPES__)
956 #include "hdrinline.h"
957 #endif
958 
964 int headerMacrosLoad(Header h)
965  /*@globals rpmGlobalMacroContext @*/
966  /*@modifies rpmGlobalMacroContext @*/;
967 
973 int headerMacrosUnload(Header h)
974  /*@globals rpmGlobalMacroContext @*/
975  /*@modifies rpmGlobalMacroContext @*/;
976 
985 int headerNVR(Header h,
986  /*@null@*/ /*@out@*/ const char ** np,
987  /*@null@*/ /*@out@*/ const char ** vp,
988  /*@null@*/ /*@out@*/ const char ** rp)
989  /*@modifies *np, *vp, *rp @*/;
990 
1001 int headerNEVRA(Header h,
1002  /*@null@*/ /*@out@*/ const char ** np,
1003  /*@null@*/ /*@out@*/ /*@unused@*/ const char ** ep,
1004  /*@null@*/ /*@out@*/ const char ** vp,
1005  /*@null@*/ /*@out@*/ const char ** rp,
1006  /*@null@*/ /*@out@*/ const char ** ap)
1007  /*@modifies *np, *vp, *rp, *ap @*/;
1008 
1015 /*@only@*/
1016 char * hGetNEVR(Header h, /*@null@*/ /*@out@*/ const char ** np )
1017  /*@modifies *np @*/;
1018 
1025 /*@only@*/
1026 char * hGetNEVRA(Header h, /*@null@*/ /*@out@*/ const char ** np )
1027  /*@modifies *np @*/;
1028 
1034 uint_32 hGetColor(Header h)
1035  /*@modifies h @*/;
1036 
1037 #ifdef __cplusplus
1038 }
1039 #endif
1040 
1041 #endif /* H_HEADER */