rpm  4.14.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 
41 Header headerNew(void);
42 
49 
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 
89 
96 
103 Header headerLoad(void * uh);
104 
111 Header headerCopyLoad(const void * uh);
112 
114  HEADERIMPORT_COPY = (1 << 0), /* Make copy of blob on import? */
115  HEADERIMPORT_FAST = (1 << 1), /* Faster but less safe? */
116 };
117 
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 
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 
173 
182 int headerGet(Header h, rpmTagVal tag, rpmtd td, headerGetFlags flags);
183 
184 
187  HEADERPUT_APPEND = (1 << 0),
188 };
189 
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 
304 
311 
318 int headerNext(HeaderIterator hi, rpmtd td);
319 
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 {
369 } headerConvOps;
370 
377 int headerConvert(Header h, int op);
378 
379 #ifdef __cplusplus
380 }
381 #endif
382 
383 #endif /* H_HEADER */
void * headerExport(Header h, unsigned int *bsize)
Export header to on-disk representation.
Header headerNew(void)
Create new (empty) header instance.
int headerPutBin(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size)
Type-safe methods for inserting tag data to header.
HeaderIterator headerInitIterator(Header h)
Create header tag iterator.
unsigned int headerSizeof(Header h, int magicp)
Return size of on-disk header representation in bytes.
Header headerImport(void *blob, unsigned int bsize, headerImportFlags flags)
Import header to in-memory representation.
headerImportFlags_e
Definition: header.h:113
int headerPut(Header h, rpmtd td, headerPutFlags flags)
Add or append tag to header.
void headerCopyTags(Header headerFrom, Header headerTo, const rpmTagVal *tagstocopy)
Duplicate tag values from one header into another.
char * headerFormat(Header h, const char *fmt, errmsg_t *errmsg)
Return formatted output string from header tags.
Header headerFree(Header h)
Dereference a header instance.
HeaderIterator headerFreeIterator(HeaderIterator hi)
Destroy header tag iterator.
Header headerCopyLoad(const void *uh)
Make a copy and convert header to in-memory representation.
Header headerLink(Header h)
Reference a header instance.
int headerDel(Header h, rpmTagVal tag)
Delete tag in header.
headerGetFlags_e
Modifier flags for headerGet() operation.
Definition: header.h:163
uint32_t rpmFlags
Definition: rpmtypes.h:42
int headerPutString(Header h, rpmTagVal tag, const char *val)
int headerGet(Header h, rpmTagVal tag, rpmtd td, headerGetFlags flags)
Retrieve tag value.
const unsigned char rpm_header_magic[8]
Header magic value.
int headerPutStringArray(Header h, rpmTagVal tag, const char **val, rpm_count_t size)
struct _FD_s * FD_t
RPM IO file descriptor type.
Definition: rpmtypes.h:98
uint64_t headerGetNumber(Header h, rpmTagVal tag)
rpmFlags headerImportFlags
Definition: header.h:118
int headerConvert(Header h, int op)
Convert header to/from (legacy) data presentation.
int headerPutUint8(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size)
Header headerLoad(void *uh)
Convert header to in-memory representation.
struct headerToken_s * Header
RPM header and data retrieval types.
Definition: rpmtypes.h:24
struct headerIterator_s * HeaderIterator
Definition: rpmtypes.h:25
rpmTagVal headerNextTag(HeaderIterator hi)
Return next tag number from header.
uint32_t rpm_count_t
Definition: rpmtypes.h:29
Header headerCopy(Header h)
Duplicate a header.
int headerPutUint64(Header h, rpmTagVal tag, const uint64_t *val, rpm_count_t size)
Header headerReload(Header h, rpmTagVal tag)
Convert header to on-disk representation, and then reload.
rpm_tag_t rpmTagVal
Definition: rpmtypes.h:30
Header headerRead(FD_t fd, int magicp)
Read (and load) header from file handle.
int headerMod(Header h, rpmtd td)
Modify tag in header.
rpmFlags headerPutFlags
Definition: header.h:190
char * headerGetAsString(Header h, rpmTagVal tag)
Return any non-array tag from header, converted to string.
int headerPutChar(Header h, rpmTagVal tag, const char *val, rpm_count_t size)
unsigned int headerGetInstance(Header h)
Return header instance, ie is the header from rpmdb.
headerPutFlags_e
Definition: header.h:185
int headerNext(HeaderIterator hi, rpmtd td)
Return next tag contents from header.
rpmFlags headerGetFlags
Definition: header.h:172
Container for rpm tag data (from headers or extensions).
Definition: rpmtd.h:32
int headerIsSource(Header h)
Check if header is a source or binary package header.
int headerIsEntry(Header h, rpmTagVal tag)
Check if tag is in header.
int headerAddI18NString(Header h, rpmTagVal tag, const char *string, const char *lang)
Add locale specific tag to header.
int headerWrite(FD_t fd, Header h, int magicp)
Write (with unload) header to file handle.
enum headerConvOps_e headerConvOps
const char * headerGetString(Header h, rpmTagVal tag)
Return a simple string tag from header.
void * headerUnload(Header h)
Convert header to on-disk representation.
const char * errmsg_t
Definition: rpmtypes.h:17
int headerPutUint16(Header h, rpmTagVal tag, const uint16_t *val, rpm_count_t size)
hMagic
Include calculation for 8 bytes of (magic, 0)?
Definition: header.h:32
int headerPutUint32(Header h, rpmTagVal tag, const uint32_t *val, rpm_count_t size)
headerConvOps_e
Definition: header.h:365