rpm 4.15.1

header.h
Go to the documentation of this file.
1 #ifndef H_HEADER
2 #define H_HEADER
3
13 /* RPM - Copyright (C) 1995-2001 Red Hat Software */
14
15 #include <rpm/rpmio.h>
16 #include <rpm/rpmtypes.h>
17 #include <rpm/rpmtd.h>
18 #include <rpm/rpmutil.h>
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
27 extern const unsigned char rpm_header_magic[8];
28
32 enum hMagic {
33 HEADER_MAGIC_NO = 0,
34 HEADER_MAGIC_YES = 1
35 };
36
41 Header headerNew(void);
42
48 Header headerFree( Header h);
49
55 Header headerLink(Header h);
56
63 unsigned int headerSizeof(Header h, int magicp);
64
71 void * headerUnload(Header h);
72
79 void * headerExport(Header h, unsigned int * bsize);
80
88 Header headerReload(Header h, rpmTagVal tag);
89
95 Header headerCopy(Header h);
96
103 Header headerLoad(void * uh);
104
111 Header headerCopyLoad(const void * uh);
112
113 enum headerImportFlags_e {
114 HEADERIMPORT_COPY = (1 << 0), /* Make copy of blob on import? */
115 HEADERIMPORT_FAST = (1 << 1), /* Faster but less safe? */
116 };
117
118 typedef rpmFlags headerImportFlags;
119
127 Header headerImport(void *blob, unsigned int bsize, headerImportFlags flags);
128
135 Header headerRead(FD_t fd, int magicp);
136
144 int headerWrite(FD_t fd, Header h, int magicp);
145
152 int headerIsEntry(Header h, rpmTagVal tag);
153
163 enum headerGetFlags_e {
164 HEADERGET_DEFAULT = 0, /* legacy headerGetEntry() behavior */
165 HEADERGET_MINMEM = (1 << 0), /* pointers can refer to header memory */
166 HEADERGET_EXT = (1 << 1), /* lookup extension types too */
167 HEADERGET_RAW = (1 << 2), /* return raw contents (no i18n lookups) */
168 HEADERGET_ALLOC = (1 << 3), /* always allocate memory for all data */
169 HEADERGET_ARGV = (1 << 4), /* return string arrays NULL-terminated */
170 };
171
172 typedef rpmFlags headerGetFlags;
173
182 int headerGet(Header h, rpmTagVal tag, rpmtd td, headerGetFlags flags);
183
184
185 enum headerPutFlags_e {
186 HEADERPUT_DEFAULT = 0,
187 HEADERPUT_APPEND = (1 << 0),
188 };
189
190 typedef rpmFlags headerPutFlags;
191
200 int headerPut(Header h, rpmtd td, headerPutFlags flags);
201
225 int headerPutBin(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size);
226 int headerPutString(Header h, rpmTagVal tag, const char *val);
227 int headerPutStringArray(Header h, rpmTagVal tag, const char **val, rpm_count_t size);
228 int headerPutChar(Header h, rpmTagVal tag, const char *val, rpm_count_t size);
229 int headerPutUint8(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size);
230 int headerPutUint16(Header h, rpmTagVal tag, const uint16_t *val, rpm_count_t size);
231 int headerPutUint32(Header h, rpmTagVal tag, const uint32_t *val, rpm_count_t size);
232 int headerPutUint64(Header h, rpmTagVal tag, const uint64_t *val, rpm_count_t size);
255 int headerAddI18NString(Header h, rpmTagVal tag, const char * string,
256 const char * lang);
257
265 int headerMod(Header h, rpmtd td);
266
276 int headerDel(Header h, rpmTagVal tag);
277
287 char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
288
295 void headerCopyTags(Header headerFrom, Header headerTo,
296 const rpmTagVal * tagstocopy);
297
303 HeaderIterator headerFreeIterator(HeaderIterator hi);
304
310 HeaderIterator headerInitIterator(Header h);
311
318 int headerNext(HeaderIterator hi, rpmtd td);
319
325 rpmTagVal headerNextTag(HeaderIterator hi);
326
333 char * headerGetAsString(Header h, rpmTagVal tag);
334
341 const char * headerGetString(Header h, rpmTagVal tag);
342
343 /* \ingroup header
344 * Return a simple number tag (or extension) from header
345 * @param h header
346 * @param tag tag to retrieve
347 * @return numeric tag value or 0 on failure
348 */
349 uint64_t headerGetNumber(Header h, rpmTagVal tag);
350
356 int headerIsSource(Header h);
357
363 unsigned int headerGetInstance(Header h);
364
365 typedef enum headerConvOps_e {
366 HEADERCONV_EXPANDFILELIST = 0,
367 HEADERCONV_COMPRESSFILELIST = 1,
368 HEADERCONV_RETROFIT_V3 = 2,
369 } headerConvOps;
370
377 int headerConvert(Header h, int op);
378
379 #ifdef __cplusplus
380 }
381 #endif
382
383 #endif /* H_HEADER */
rpmFlags
uint32_t rpmFlags
Definition: rpmtypes.h:42
rpm_count_t
uint32_t rpm_count_t
Definition: rpmtypes.h:29
headerGetAsString
char * headerGetAsString(Header h, rpmTagVal tag)
headerPutUint32
int headerPutUint32(Header h, rpmTagVal tag, const uint32_t *val, rpm_count_t size)
headerReload
Header headerReload(Header h, rpmTagVal tag)
headerGetString
const char * headerGetString(Header h, rpmTagVal tag)
headerImport
Header headerImport(void *blob, unsigned int bsize, headerImportFlags flags)
headerPutUint64
int headerPutUint64(Header h, rpmTagVal tag, const uint64_t *val, rpm_count_t size)
headerNew
Header headerNew(void)
HEADERIMPORT_COPY
@ HEADERIMPORT_COPY
Definition: header.h:114
headerConvOps
enum headerConvOps_e headerConvOps
headerFreeIterator
HeaderIterator headerFreeIterator(HeaderIterator hi)
HEADERGET_DEFAULT
@ HEADERGET_DEFAULT
Definition: header.h:164
HEADER_MAGIC_NO
@ HEADER_MAGIC_NO
Definition: header.h:33
headerAddI18NString
int headerAddI18NString(Header h, rpmTagVal tag, const char *string, const char *lang)
rpm_header_magic
const unsigned char rpm_header_magic[8]
HeaderIterator
struct headerIterator_s * HeaderIterator
Definition: rpmtypes.h:25
HEADERGET_ARGV
@ HEADERGET_ARGV
Definition: header.h:169
headerPutFlags
rpmFlags headerPutFlags
Definition: header.h:190
HEADERPUT_DEFAULT
@ HEADERPUT_DEFAULT
Definition: header.h:186
headerMod
int headerMod(Header h, rpmtd td)
headerUnload
void * headerUnload(Header h)
headerWrite
int headerWrite(FD_t fd, Header h, int magicp)
headerPutFlags_e
headerPutFlags_e
Definition: header.h:185
headerPutUint8
int headerPutUint8(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size)
headerPut
int headerPut(Header h, rpmtd td, headerPutFlags flags)
headerPutString
int headerPutString(Header h, rpmTagVal tag, const char *val)
headerCopy
Header headerCopy(Header h)
headerConvOps_e
headerConvOps_e
Definition: header.h:365
HEADERGET_EXT
@ HEADERGET_EXT
Definition: header.h:166
HEADERCONV_RETROFIT_V3
@ HEADERCONV_RETROFIT_V3
Definition: header.h:368
headerGetFlags
rpmFlags headerGetFlags
Definition: header.h:172
headerLink
Header headerLink(Header h)
headerNext
int headerNext(HeaderIterator hi, rpmtd td)
headerNextTag
rpmTagVal headerNextTag(HeaderIterator hi)
headerGetFlags_e
headerGetFlags_e
Definition: header.h:163
headerPutBin
int headerPutBin(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size)
headerPutChar
int headerPutChar(Header h, rpmTagVal tag, const char *val, rpm_count_t size)
headerImportFlags_e
headerImportFlags_e
Definition: header.h:113
headerRead
Header headerRead(FD_t fd, int magicp)
headerExport
void * headerExport(Header h, unsigned int *bsize)
HEADERGET_MINMEM
@ HEADERGET_MINMEM
Definition: header.h:165
headerPutUint16
int headerPutUint16(Header h, rpmTagVal tag, const uint16_t *val, rpm_count_t size)
rpmtd_s
Definition: rpmtd.h:32
headerSizeof
unsigned int headerSizeof(Header h, int magicp)
FD_t
struct _FD_s * FD_t
Definition: rpmtypes.h:98
headerConvert
int headerConvert(Header h, int op)
headerGet
int headerGet(Header h, rpmTagVal tag, rpmtd td, headerGetFlags flags)
HEADERCONV_COMPRESSFILELIST
@ HEADERCONV_COMPRESSFILELIST
Definition: header.h:367
headerPutStringArray
int headerPutStringArray(Header h, rpmTagVal tag, const char **val, rpm_count_t size)
rpmTagVal
rpm_tag_t rpmTagVal
Definition: rpmtypes.h:30
headerGetInstance
unsigned int headerGetInstance(Header h)
headerCopyTags
void headerCopyTags(Header headerFrom, Header headerTo, const rpmTagVal *tagstocopy)
HEADERCONV_EXPANDFILELIST
@ HEADERCONV_EXPANDFILELIST
Definition: header.h:366
hMagic
hMagic
Definition: header.h:32
HEADERPUT_APPEND
@ HEADERPUT_APPEND
Definition: header.h:187
headerGetNumber
uint64_t headerGetNumber(Header h, rpmTagVal tag)
headerCopyLoad
Header headerCopyLoad(const void *uh)
headerIsEntry
int headerIsEntry(Header h, rpmTagVal tag)
headerFormat
char * headerFormat(Header h, const char *fmt, errmsg_t *errmsg)
headerImportFlags
rpmFlags headerImportFlags
Definition: header.h:118
headerDel
int headerDel(Header h, rpmTagVal tag)
Header
struct headerToken_s * Header
Definition: rpmtypes.h:24
HEADERIMPORT_FAST
@ HEADERIMPORT_FAST
Definition: header.h:115
HEADERGET_ALLOC
@ HEADERGET_ALLOC
Definition: header.h:168
headerLoad
Header headerLoad(void *uh)
errmsg_t
const typedef char * errmsg_t
Definition: rpmtypes.h:17
headerFree
Header headerFree(Header h)
headerInitIterator
HeaderIterator headerInitIterator(Header h)
HEADERGET_RAW
@ HEADERGET_RAW
Definition: header.h:167
HEADER_MAGIC_YES
@ HEADER_MAGIC_YES
Definition: header.h:34
headerIsSource
int headerIsSource(Header h)