1 #ifndef H_HEADER_INTERNAL
2 #define H_HEADER_INTERNAL
5 * \file lib/header_internal.h
10 #if !defined(__LCLINT__)
11 #include <netinet/in.h>
12 #endif /* __LCLINT__ */
14 #define INDEX_MALLOC_SIZE 8
17 * Teach header.c about legacy tags.
19 #define HEADER_OLDFILENAMES 1027
20 #define HEADER_BASENAMES 1117
23 * Description of tag data.
25 typedef /*@abstract@*/ struct entryInfo * entryInfo;
27 int_32 tag; /*!< Tag identifier. */
28 int_32 type; /*!< Tag data type. */
29 int_32 offset; /*!< Offset into data segment (ondisk only). */
30 int_32 count; /*!< Number of tag elements. */
33 #define REGION_TAG_TYPE RPM_BIN_TYPE
34 #define REGION_TAG_COUNT sizeof(struct entryInfo)
36 #define ENTRY_IS_REGION(_e) \
37 (((_e)->info.tag >= HEADER_IMAGE) && ((_e)->info.tag < HEADER_REGIONS))
38 #define ENTRY_IN_REGION(_e) ((_e)->info.offset < 0)
41 * A single tag from a Header.
43 typedef /*@abstract@*/ struct indexEntry * indexEntry;
45 struct entryInfo info; /*!< Description of tag data. */
46 /*@owned@*/ void * data; /*!< Location of tag data. */
47 int length; /*!< No. bytes of data. */
48 int rdlen; /*!< No. bytes of data in region. */
52 * The Header data structure.
55 /*@unused@*/ struct HV_s hv; /*!< Header public methods. */
56 void * blob; /*!< Header region blob. */
57 /*@owned@*/ indexEntry index; /*!< Array of tags. */
58 int indexUsed; /*!< Current size of tag array. */
59 int indexAlloced; /*!< Allocated size of tag array. */
61 #define HEADERFLAG_SORTED (1 << 0) /*!< Are header entries sorted? */
62 #define HEADERFLAG_ALLOCATED (1 << 1) /*!< Is 1st header region allocated? */
63 #define HEADERFLAG_LEGACY (1 << 2) /*!< Header came from legacy source? */
64 /*@refs@*/ int nrefs; /*!< Reference count. */
69 typedef /*@abstract@*/ struct sprintfTag * sprintfTag;
71 /*@null@*/ headerTagTagFunction ext; /*!< if NULL tag element is invalid */
76 /*@kept@*/ char * format;
77 /*@kept@*/ /*@null@*/ char * type;
83 typedef /*@abstract@*/ struct extensionCache * extensionCache;
84 struct extensionCache {
89 /*@owned@*/ const void * data;
95 typedef /*@abstract@*/ struct sprintfToken * sprintfToken;
106 /*@only@*/ sprintfToken format;
109 struct sprintfTag tag;
111 /*@dependent@*/ char * string;
115 /*@only@*/ /*@null@*/ sprintfToken ifFormat;
117 /*@only@*/ /*@null@*/ sprintfToken elseFormat;
119 struct sprintfTag tag;
130 * Return array of locales found in header.
131 * The array is terminated with a NULL sentinel.
133 * @return array of locales (or NULL on error)
136 /*@only@*/ /*@null@*/ char ** headerGetLangs(Header h)
140 * Retrieve tag value with type match.
141 * If *type is RPM_NULL_TYPE any type will match, otherwise only *type will
146 * @retval type address of tag value data type (or NULL)
147 * @retval p address of pointer to tag value(s) (or NULL)
148 * @retval c address of number of values (or NULL)
149 * @return 1 on success, 0 on failure
152 int headerGetRawEntry(Header h, int_32 tag,
153 /*@null@*/ /*@out@*/ hTYP_t type,
154 /*@null@*/ /*@out@*/ hPTR_t * p,
155 /*@null@*/ /*@out@*/ hCNT_t c)
156 /*@modifies *type, *p, *c @*/;
160 * Return header reference count.
162 * @return no. of references
164 /*@unused@*/ static inline int headerUsageCount(Header h) /*@*/ {
169 * Dump a header in human readable format (for debugging).
171 * @param flags 0 or HEADER_DUMP_LINLINE
172 * @param tags array of tag name/value pairs
175 void headerDump(Header h, FILE *f, int flags,
176 const struct headerTagTableEntry_s * tags)
177 /*@modifies f, fileSystem @*/;
178 #define HEADER_DUMP_INLINE 1
184 #endif /* H_HEADER_INTERNAL */