rpm  4.17.0
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 {
35 };
36 
42 
49 
56 
63 unsigned int headerSizeof(Header h, int magicp);
64 
72 void * headerUnload(Header h);
73 
80 void * headerExport(Header h, unsigned int * bsize);
81 
90 
97 
105 Header headerLoad(void * uh);
106 
114 Header headerCopyLoad(const void * uh);
115 
117  HEADERIMPORT_COPY = (1 << 0), /* Make copy of blob on import? */
118  HEADERIMPORT_FAST = (1 << 1), /* Faster but less safe? */
119 };
120 
122 
130 Header headerImport(void *blob, unsigned int bsize, headerImportFlags flags);
131 
138 Header headerRead(FD_t fd, int magicp);
139 
147 int headerWrite(FD_t fd, Header h, int magicp);
148 
156 
167  HEADERGET_DEFAULT = 0, /* legacy headerGetEntry() behavior */
168  HEADERGET_MINMEM = (1 << 0), /* pointers can refer to header memory */
169  HEADERGET_EXT = (1 << 1), /* lookup extension types too */
170  HEADERGET_RAW = (1 << 2), /* return raw contents (no i18n lookups) */
171  HEADERGET_ALLOC = (1 << 3), /* always allocate memory for all data */
172  HEADERGET_ARGV = (1 << 4), /* return string arrays NULL-terminated */
173 };
174 
176 
186 
187 
190  HEADERPUT_APPEND = (1 << 0),
191 };
192 
194 
204 
228 int headerPutBin(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size);
229 int headerPutString(Header h, rpmTagVal tag, const char *val);
230 int headerPutStringArray(Header h, rpmTagVal tag, const char **val, rpm_count_t size);
231 int headerPutChar(Header h, rpmTagVal tag, const char *val, rpm_count_t size);
232 int headerPutUint8(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size);
233 int headerPutUint16(Header h, rpmTagVal tag, const uint16_t *val, rpm_count_t size);
234 int headerPutUint32(Header h, rpmTagVal tag, const uint32_t *val, rpm_count_t size);
235 int headerPutUint64(Header h, rpmTagVal tag, const uint64_t *val, rpm_count_t size);
258 int headerAddI18NString(Header h, rpmTagVal tag, const char * string,
259  const char * lang);
260 
268 int headerMod(Header h, rpmtd td);
269 
280 
290 char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
291 
298 void headerCopyTags(Header headerFrom, Header headerTo,
299  const rpmTagVal * tagstocopy);
300 
307 
314 
322 
329 
337 
344 const char * headerGetString(Header h, rpmTagVal tag);
345 
353 
360 
366 unsigned int headerGetInstance(Header h);
367 
368 typedef enum headerConvOps_e {
373 
380 int headerConvert(Header h, int op);
381 
382 #ifdef __cplusplus
383 }
384 #endif
385 
386 #endif /* H_HEADER */
Header headerFree(Header h)
Dereference a header instance.
int headerAddI18NString(Header h, rpmTagVal tag, const char *string, const char *lang)
Add locale specific tag to header.
int headerPutUint64(Header h, rpmTagVal tag, const uint64_t *val, rpm_count_t size)
int headerMod(Header h, rpmtd td)
Modify tag in header.
int headerPut(Header h, rpmtd td, headerPutFlags flags)
Add or append tag to header.
hMagic
Include calculation for 8 bytes of (magic, 0)?
Definition: header.h:32
Header headerRead(FD_t fd, int magicp)
Read (and load) header from file handle.
void * headerExport(Header h, unsigned int *bsize)
Export header to on-disk representation.
const char * headerGetString(Header h, rpmTagVal tag)
Return a simple string tag from header.
void headerCopyTags(Header headerFrom, Header headerTo, const rpmTagVal *tagstocopy)
Duplicate tag values from one header into another.
int headerIsSource(Header h)
Check if header is a source or binary package header.
int headerPutStringArray(Header h, rpmTagVal tag, const char **val, rpm_count_t size)
int headerDel(Header h, rpmTagVal tag)
Delete tag in header.
RPM_GNUC_DEPRECATED void * headerUnload(Header h)
Convert header to on-disk representation.
const unsigned char rpm_header_magic[8]
Header magic value.
int headerPutUint8(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size)
int headerGet(Header h, rpmTagVal tag, rpmtd td, headerGetFlags flags)
Retrieve tag value.
RPM_GNUC_DEPRECATED Header headerCopyLoad(const void *uh)
Make a copy and convert header to in-memory representation.
uint64_t headerGetNumber(Header h, rpmTagVal tag)
Return a simple number tag (or extension) from header.
char * headerGetAsString(Header h, rpmTagVal tag)
Return any non-array tag from header, converted to string.
RPM_GNUC_DEPRECATED Header headerLoad(void *uh)
Convert header to in-memory representation.
HeaderIterator headerFreeIterator(HeaderIterator hi)
Destroy header tag iterator.
int headerPutString(Header h, rpmTagVal tag, const char *val)
int headerNext(HeaderIterator hi, rpmtd td)
Return next tag contents from header.
int headerPutBin(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size)
Type-safe methods for inserting tag data to header.
int headerPutChar(Header h, rpmTagVal tag, const char *val, rpm_count_t size)
int headerPutUint32(Header h, rpmTagVal tag, const uint32_t *val, rpm_count_t size)
int headerPutUint16(Header h, rpmTagVal tag, const uint16_t *val, rpm_count_t size)
unsigned int headerGetInstance(Header h)
Return header instance, ie is the header from rpmdb.
int headerConvert(Header h, int op)
Convert header to/from (legacy) data presentation.
Header headerLink(Header h)
Reference a header instance.
Header headerNew(void)
Create new (empty) header instance.
int headerWrite(FD_t fd, Header h, int magicp)
Write (with unload) header to file handle.
unsigned int headerSizeof(Header h, int magicp)
Return size of on-disk header representation in bytes.
Header headerCopy(Header h)
Duplicate a header.
char * headerFormat(Header h, const char *fmt, errmsg_t *errmsg)
Return formatted output string from header tags.
headerGetFlags_e
Modifier flags for headerGet() operation.
Definition: header.h:166
HeaderIterator headerInitIterator(Header h)
Create header tag iterator.
Header headerReload(Header h, rpmTagVal tag)
Convert header to on-disk representation, and then reload.
Header headerImport(void *blob, unsigned int bsize, headerImportFlags flags)
Import header to in-memory representation.
rpmTagVal headerNextTag(HeaderIterator hi)
Return next tag number from header.
int headerIsEntry(Header h, rpmTagVal tag)
Check if tag is in header.
@ HEADER_MAGIC_NO
Definition: header.h:33
@ HEADER_MAGIC_YES
Definition: header.h:34
@ HEADERGET_DEFAULT
Definition: header.h:167
@ HEADERGET_EXT
Definition: header.h:169
@ HEADERGET_ARGV
Definition: header.h:172
@ HEADERGET_ALLOC
Definition: header.h:171
@ HEADERGET_RAW
Definition: header.h:170
@ HEADERGET_MINMEM
Definition: header.h:168
struct headerIterator_s * HeaderIterator
Definition: rpmtypes.h:25
struct _FD_s * FD_t
RPM IO file descriptor type.
Definition: rpmtypes.h:99
uint32_t rpm_count_t
Definition: rpmtypes.h:29
rpm_tag_t rpmTagVal
Definition: rpmtypes.h:30
uint32_t rpmFlags
Definition: rpmtypes.h:42
struct headerToken_s * Header
RPM header and data retrieval types.
Definition: rpmtypes.h:24
headerPutFlags_e
Definition: header.h:188
@ HEADERPUT_APPEND
Definition: header.h:190
@ HEADERPUT_DEFAULT
Definition: header.h:189
rpmFlags headerPutFlags
Definition: header.h:193
rpmFlags headerImportFlags
Definition: header.h:121
headerConvOps_e
Definition: header.h:368
@ HEADERCONV_EXPANDFILELIST
Definition: header.h:369
@ HEADERCONV_RETROFIT_V3
Definition: header.h:371
@ HEADERCONV_COMPRESSFILELIST
Definition: header.h:370
headerImportFlags_e
Definition: header.h:116
@ HEADERIMPORT_FAST
Definition: header.h:118
@ HEADERIMPORT_COPY
Definition: header.h:117
rpmFlags headerGetFlags
Definition: header.h:175
enum headerConvOps_e headerConvOps
const char * errmsg_t
Definition: rpmtypes.h:17
#define RPM_GNUC_DEPRECATED
Definition: rpmutil.h:81
Container for rpm tag data (from headers or extensions).
Definition: rpmtd.h:32