header.h
Go to the documentation of this file.
#ifndef H_HEADER
#define H_HEADER
/* RPM - Copyright (C) 1995-2001 Red Hat Software */
#include <rpm/rpmio.h>
#include <rpm/rpmtypes.h>
#include <rpm/rpmtd.h>
#include <rpm/rpmutil.h>
#ifdef __cplusplus
extern "C" {
#endif
extern const unsigned char rpm_header_magic[8];
enum hMagic {
HEADER_MAGIC_NO = 0,
HEADER_MAGIC_YES = 1
};
Header headerNew(void);
Header headerFree( Header h);
Header headerLink(Header h);
void headerSort(Header h);
void headerUnsort(Header h);
unsigned int headerSizeof(Header h, int magicp);
int headerVerifyInfo(int il, int dl, const void * pev, void * iv, int negate);
void * headerUnload(Header h);
void * headerExport(Header h, unsigned int * bsize);
Header headerReload(Header h, rpmTagVal tag);
Header headerCopy(Header h);
Header headerLoad(void * uh);
Header headerCopyLoad(const void * uh);
enum headerImportFlags_e {
HEADERIMPORT_COPY = (1 << 0), /* Make copy of blob on import? */
HEADERIMPORT_FAST = (1 << 1), /* Faster but less safe? */
};
typedef rpmFlags headerImportFlags;
Header headerImport(void *blob, unsigned int bsize, headerImportFlags flags);
Header headerRead(FD_t fd, int magicp);
int headerWrite(FD_t fd, Header h, int magicp);
int headerIsEntry(Header h, rpmTagVal tag);
enum headerGetFlags_e {
HEADERGET_DEFAULT = 0, /* legacy headerGetEntry() behavior */
HEADERGET_MINMEM = (1 << 0), /* pointers can refer to header memory */
HEADERGET_EXT = (1 << 1), /* lookup extension types too */
HEADERGET_RAW = (1 << 2), /* return raw contents (no i18n lookups) */
HEADERGET_ALLOC = (1 << 3), /* always allocate memory for all data */
HEADERGET_ARGV = (1 << 4), /* return string arrays NULL-terminated */
};
typedef rpmFlags headerGetFlags;
int headerGet(Header h, rpmTagVal tag, rpmtd td, headerGetFlags flags);
enum headerPutFlags_e {
HEADERPUT_DEFAULT = 0,
HEADERPUT_APPEND = (1 << 0),
};
typedef rpmFlags headerPutFlags;
int headerPut(Header h, rpmtd td, headerPutFlags flags);
int headerPutBin(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size);
int headerPutString(Header h, rpmTagVal tag, const char *val);
int headerPutStringArray(Header h, rpmTagVal tag, const char **val, rpm_count_t size);
int headerPutChar(Header h, rpmTagVal tag, const char *val, rpm_count_t size);
int headerPutUint8(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size);
int headerPutUint16(Header h, rpmTagVal tag, const uint16_t *val, rpm_count_t size);
int headerPutUint32(Header h, rpmTagVal tag, const uint32_t *val, rpm_count_t size);
int headerPutUint64(Header h, rpmTagVal tag, const uint64_t *val, rpm_count_t size);
int headerAddI18NString(Header h, rpmTagVal tag, const char * string,
const char * lang);
int headerMod(Header h, rpmtd td);
int headerDel(Header h, rpmTagVal tag);
char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
void headerCopyTags(Header headerFrom, Header headerTo,
const rpmTagVal * tagstocopy);
HeaderIterator headerFreeIterator(HeaderIterator hi);
HeaderIterator headerInitIterator(Header h);
int headerNext(HeaderIterator hi, rpmtd td);
rpmTagVal headerNextTag(HeaderIterator hi);
RPM_GNUC_DEPRECATED
int headerNVR(Header h,
const char ** np,
const char ** vp,
const char ** rp);
RPM_GNUC_DEPRECATED
int headerNEVRA(Header h,
const char ** np,
uint32_t ** ep,
const char ** vp,
const char ** rp,
const char ** ap);
RPM_GNUC_DEPRECATED
char * headerGetNEVR(Header h, const char ** np );
RPM_GNUC_DEPRECATED
char * headerGetNEVRA(Header h, const char ** np );
/* \ingroup header
* Return (malloc'd) header (epoch:)version-release string.
* @param h header
* @retval np name tag value (or NULL)
* @return (epoch:)version-release string
*/
RPM_GNUC_DEPRECATED
char * headerGetEVR(Header h, const char **np);
char * headerGetAsString(Header h, rpmTagVal tag);
const char * headerGetString(Header h, rpmTagVal tag);
/* \ingroup header
* Return a simple number tag (or extension) from header
* @param h header
* @param tag tag to retrieve
* @return numeric tag value or 0 on failure
*/
uint64_t headerGetNumber(Header h, rpmTagVal tag);
RPM_GNUC_DEPRECATED
rpm_color_t headerGetColor(Header h);
int headerIsSource(Header h);
unsigned int headerGetInstance(Header h);
typedef enum headerConvOps_e {
HEADERCONV_EXPANDFILELIST = 0,
HEADERCONV_COMPRESSFILELIST = 1,
HEADERCONV_RETROFIT_V3 = 2,
} headerConvOps;
int headerConvert(Header h, int op);
#ifdef __cplusplus
}
#endif
#endif /* H_HEADER */
headerPutUint8
int headerPutUint8(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size)
headerReload
Header headerReload(Header h, rpmTagVal tag)
Convert header to on-disk representation, and then reload.
headerInitIterator
HeaderIterator headerInitIterator(Header h)
Create header tag iterator.
HEADER_MAGIC_NO
Definition: header.h:33
headerPutBin
int headerPutBin(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size)
Type-safe methods for inserting tag data to header.
headerCopyLoad
Header headerCopyLoad(const void *uh)
Make a copy and convert header to in-memory representation.
headerGetEVR
RPM_GNUC_DEPRECATED char * headerGetEVR(Header h, const char **np)
headerIsEntry
int headerIsEntry(Header h, rpmTagVal tag)
Check if tag is in header.
FD_t
struct _FD_s * FD_t
RPM IO file descriptor type.
Definition: rpmtypes.h:98
headerIsSource
int headerIsSource(Header h)
Check if header is a source or binary package header.
rpm_count_t
uint32_t rpm_count_t
Definition: rpmtypes.h:29
HEADERCONV_EXPANDFILELIST
Definition: header.h:456
HEADERCONV_RETROFIT_V3
Definition: header.h:458
headerDel
int headerDel(Header h, rpmTagVal tag)
Delete tag in header.
headerImportFlags_e
headerImportFlags_e
Definition: header.h:136
headerNVR
RPM_GNUC_DEPRECATED int headerNVR(Header h, const char **np, const char **vp, const char **rp)
Return name, version, release strings from header.
headerPutString
int headerPutString(Header h, rpmTagVal tag, const char *val)
HEADERIMPORT_FAST
Definition: header.h:138
headerGetAsString
char * headerGetAsString(Header h, rpmTagVal tag)
Return any non-array tag from header, converted to string.
headerGetFlags_e
headerGetFlags_e
Modifier flags for headerGet() operation.
Definition: header.h:186
headerFreeIterator
HeaderIterator headerFreeIterator(HeaderIterator hi)
Destroy header tag iterator.
HEADER_MAGIC_YES
Definition: header.h:34
headerPutUint32
int headerPutUint32(Header h, rpmTagVal tag, const uint32_t *val, rpm_count_t size)
RPM_GNUC_DEPRECATED
#define RPM_GNUC_DEPRECATED
Definition: rpmutil.h:80
headerSort
void headerSort(Header h)
Sort tags in header.
HEADERGET_EXT
Definition: header.h:189
rpmTagVal
rpm_tag_t rpmTagVal
Definition: rpmtypes.h:30
headerNext
int headerNext(HeaderIterator hi, rpmtd td)
Return next tag contents from header.
headerGetInstance
unsigned int headerGetInstance(Header h)
Return header instance, ie is the header from rpmdb.
headerGetNEVR
RPM_GNUC_DEPRECATED char * headerGetNEVR(Header h, const char **np)
Return (malloc&#39;d) header name-version-release string.
headerUnsort
void headerUnsort(Header h)
Restore tags in header to original ordering.
headerConvert
int headerConvert(Header h, int op)
Convert header to/from (legacy) data presentation.
headerGetNEVRA
RPM_GNUC_DEPRECATED char * headerGetNEVRA(Header h, const char **np)
Return (malloc&#39;d) header name-version-release.arch string.
headerWrite
int headerWrite(FD_t fd, Header h, int magicp)
Write (with unload) header to file handle.
HEADERGET_ALLOC
Definition: header.h:191
headerGetNumber
uint64_t headerGetNumber(Header h, rpmTagVal tag)
headerFree
Header headerFree(Header h)
Dereference a header instance.
headerImportFlags
rpmFlags headerImportFlags
Definition: header.h:141
headerGetColor
RPM_GNUC_DEPRECATED rpm_color_t headerGetColor(Header h)
Return header color.
headerPutChar
int headerPutChar(Header h, rpmTagVal tag, const char *val, rpm_count_t size)
headerImport
Header headerImport(void *blob, unsigned int bsize, headerImportFlags flags)
Import header to in-memory representation.
headerPutUint16
int headerPutUint16(Header h, rpmTagVal tag, const uint16_t *val, rpm_count_t size)
headerNextTag
rpmTagVal headerNextTag(HeaderIterator hi)
Return next tag number from header.
headerMod
int headerMod(Header h, rpmtd td)
Modify tag in header.
rpmFlags
uint32_t rpmFlags
Definition: rpmtypes.h:42
headerLoad
Header headerLoad(void *uh)
Convert header to in-memory representation.
headerGetString
const char * headerGetString(Header h, rpmTagVal tag)
Return a simple string tag from header.
headerSizeof
unsigned int headerSizeof(Header h, int magicp)
Return size of on-disk header representation in bytes.
headerPutFlags
rpmFlags headerPutFlags
Definition: header.h:213
headerPut
int headerPut(Header h, rpmtd td, headerPutFlags flags)
Add or append tag to header.
headerUnload
void * headerUnload(Header h)
Convert header to on-disk representation.
HEADERCONV_COMPRESSFILELIST
Definition: header.h:457
headerPutFlags_e
headerPutFlags_e
Definition: header.h:208
headerGetFlags
rpmFlags headerGetFlags
Definition: header.h:195
rpm_color_t
uint32_t rpm_color_t
Definition: rpmtypes.h:38
rpmtd_s
Container for rpm tag data (from headers or extensions).
Definition: rpmtd.h:26
HeaderIterator
struct headerIterator_s * HeaderIterator
Definition: rpmtypes.h:25
HEADERGET_ARGV
Definition: header.h:192
headerCopy
Header headerCopy(Header h)
Duplicate a header.
headerVerifyInfo
int headerVerifyInfo(int il, int dl, const void *pev, void *iv, int negate)
Perform simple sanity and range checks on header tag(s).
HEADERGET_RAW
Definition: header.h:190
headerPutUint64
int headerPutUint64(Header h, rpmTagVal tag, const uint64_t *val, rpm_count_t size)
headerRead
Header headerRead(FD_t fd, int magicp)
Read (and load) header from file handle.
headerGet
int headerGet(Header h, rpmTagVal tag, rpmtd td, headerGetFlags flags)
Retrieve tag value.
headerExport
void * headerExport(Header h, unsigned int *bsize)
Export header to on-disk representation.
HEADERGET_DEFAULT
Definition: header.h:187
headerNew
Header headerNew(void)
Create new (empty) header instance.
HEADERIMPORT_COPY
Definition: header.h:137
hMagic
hMagic
Include calculation for 8 bytes of (magic, 0)?
Definition: header.h:32
headerLink
Header headerLink(Header h)
Reference a header instance.
rpm_header_magic
const unsigned char rpm_header_magic[8]
Header magic value.
headerNEVRA
RPM_GNUC_DEPRECATED int headerNEVRA(Header h, const char **np, uint32_t **ep, const char **vp, const char **rp, const char **ap)
Return name, epoch, version, release, arch strings from header.
headerFormat
char * headerFormat(Header h, const char *fmt, errmsg_t *errmsg)
Return formatted output string from header tags.
headerCopyTags
void headerCopyTags(Header headerFrom, Header headerTo, const rpmTagVal *tagstocopy)
Duplicate tag values from one header into another.
headerPutStringArray
int headerPutStringArray(Header h, rpmTagVal tag, const char **val, rpm_count_t size)
headerConvOps
enum headerConvOps_e headerConvOps
headerAddI18NString
int headerAddI18NString(Header h, rpmTagVal tag, const char *string, const char *lang)
Add locale specific tag to header.
errmsg_t
const char * errmsg_t
Definition: rpmtypes.h:17
HEADERPUT_APPEND
Definition: header.h:210
HEADERGET_MINMEM
Definition: header.h:188
HEADERPUT_DEFAULT
Definition: header.h:209
headerConvOps_e
headerConvOps_e
Definition: header.h:455
Header
struct headerToken_s * Header
RPM header and data retrieval types.
Definition: rpmtypes.h:24