Data Structures | |
struct | headerToken |
The Header data structure. More... | |
Files | |
file | formats.c |
file | hdrinline.h |
file | header.c |
file | header.h |
An rpm header carries all information about a package. | |
file | header_internal.c |
file | header_internal.h |
file | package.c |
file | rpmlib.h |
Typedefs | |
typedef const char * | errmsg_t |
typedef int_32 * | hTAG_t |
typedef struct headerToken * | Header |
typedef struct headerIteratorS * | HeaderIterator |
typedef struct headerTagTableEntry_s * | headerTagTableEntry |
Associate tag names with numeric values. | |
typedef char *(* | headerTagFormatFunction )(int_32 type, const void *data, char *formatPrefix, int padding, int element) |
HEADER_EXT_TAG format function prototype. | |
typedef int(* | headerTagTagFunction )(Header h, hTYP_t type, hPTR_t *data, hCNT_t count, int *freeData) |
HEADER_EXT_FORMAT format function prototype. | |
typedef struct headerSprintfExtension_s * | headerSprintfExtension |
Define header tag output formats. | |
typedef enum rpmTagType_e | rpmTagType |
The basic types of data in tags from headers. | |
typedef enum rpmSubTagType_e | rpmSubTagType |
New rpm data types under consideration/development. | |
typedef Header(* | HDRnew )(void) |
Create new (empty) header instance. | |
typedef Header(* | HDRfree )(Header h) |
Dereference a header instance. | |
typedef Header(* | HDRlink )(Header h) |
Reference a header instance. | |
typedef Header(* | HDRunlink )(Header h) |
Dereference a header instance. | |
typedef void(* | HDRsort )(Header h) |
Sort tags in header. | |
typedef void(* | HDRunsort )(Header h) |
Restore tags in header to original ordering. | |
typedef unsigned int(* | HDRsizeof )(Header h, enum hMagic magicp) |
Return size of on-disk header representation in bytes. | |
typedef void *(* | HDRunload )(Header h) |
Convert header to on-disk representation. | |
typedef Header(* | HDRreload )(Header h, int tag) |
Convert header to on-disk representation, and then reload. | |
typedef Header(* | HDRcopy )(Header h) |
Duplicate a header. | |
typedef Header(* | HDRload )(void *uh) |
Convert header to in-memory representation. | |
typedef Header(* | HDRcopyload )(const void *uh) |
Make a copy and convert header to in-memory representation. | |
typedef Header(* | HDRhdrread )(FD_t fd, enum hMagic magicp) |
Read (and load) header from file handle. | |
typedef int(* | HDRhdrwrite )(FD_t fd, Header h, enum hMagic magicp) |
Write (with unload) header to file handle. | |
typedef int(* | HDRisentry )(Header h, int_32 tag) |
Check if tag is in header. | |
typedef void *(* | HDRfreetag )(Header h, const void *data, rpmTagType type) |
Free data allocated when retrieved from header. | |
typedef int(* | HDRget )(Header h, int_32 tag, hTYP_t type, void **p, hCNT_t c) |
Retrieve tag value. | |
typedef int(* | HDRgetmin )(Header h, int_32 tag, hTYP_t type, hPTR_t *p, hCNT_t c) |
Retrieve tag value using header internal array. | |
typedef int(* | HDRadd )(Header h, int_32 tag, int_32 type, const void *p, int_32 c) |
Add tag to header. | |
typedef int(* | HDRappend )(Header h, int_32 tag, int_32 type, const void *p, int_32 c) |
Append element to tag array in header. | |
typedef int(* | HDRaddorappend )(Header h, int_32 tag, int_32 type, const void *p, int_32 c) |
Add or append element to tag array in header. | |
typedef int(* | HDRaddi18n )(Header h, int_32 tag, const char *string, const char *lang) |
Add locale specific tag to header. | |
typedef int(* | HDRmodify )(Header h, int_32 tag, int_32 type, const void *p, int_32 c) |
Modify tag in header. | |
typedef int(* | HDRremove )(Header h, int_32 tag) |
Delete tag in header. | |
typedef char *(* | HDRhdrsprintf )(Header h, const char *fmt, const struct headerTagTableEntry_s *tags, const struct headerSprintfExtension_s *extensions, errmsg_t *errmsg) |
Return formatted output string from header tags. | |
typedef void(* | HDRcopytags )(Header headerFrom, Header headerTo, hTAG_t tagstocopy) |
Duplicate tag values from one header into another. | |
typedef HeaderIterator(* | HDRfreeiter )(HeaderIterator hi) |
Destroy header tag iterator. | |
typedef HeaderIterator(* | HDRinititer )(Header h) |
Create header tag iterator. | |
typedef int(* | HDRnextiter )(HeaderIterator hi, hTAG_t tag, hTYP_t type, hPTR_t *p, hCNT_t c) |
Return next tag from header. | |
typedef struct HV_s * | HV_t |
Header method vectors. | |
typedef struct entryInfo * | entryInfo |
Description of tag data. | |
typedef struct indexEntry * | indexEntry |
A single tag from a Header. | |
typedef struct sprintfTag * | sprintfTag |
typedef struct extensionCache * | extensionCache |
typedef struct sprintfToken * | sprintfToken |
Enumerations | |
enum | headerSprintfExtenstionType { HEADER_EXT_LAST = 0, HEADER_EXT_FORMAT, HEADER_EXT_MORE, HEADER_EXT_TAG } |
enum | hMagic { HEADER_MAGIC_NO = 0, HEADER_MAGIC_YES = 1 } |
Include calculation for 8 bytes of (magic, 0)? More... | |
enum | rpmTagType_e |
The basic types of data in tags from headers. More... | |
enum | rpmSubTagType_e { RPM_REGION_TYPE = -10, RPM_BIN_ARRAY_TYPE = -11, RPM_XREF_TYPE = -12 } |
New rpm data types under consideration/development. More... | |
Functions | |
static HV_t | h2hv (Header h) |
static Header | headerNew (void) |
Create new (empty) header instance. | |
static Header | headerFree (Header h) |
Dereference a header instance. | |
static Header | headerLink (Header h) |
Reference a header instance. | |
static Header | headerUnlink (Header h) |
Dereference a header instance. | |
static void | headerSort (Header h) |
Sort tags in header. | |
static void | headerUnsort (Header h) |
Restore tags in header to original ordering. | |
static unsigned int | headerSizeof (Header h, enum hMagic magicp) |
Return size of on-disk header representation in bytes. | |
static void * | headerUnload (Header h) |
Convert header to on-disk representation. | |
static Header | headerReload (Header h, int tag) |
Convert header to on-disk representation, and then reload. | |
static Header | headerCopy (Header h) |
Duplicate a header. | |
static Header | headerLoad (void *uh) |
Convert header to in-memory representation. | |
static Header | headerCopyLoad (const void *uh) |
Make a copy and convert header to in-memory representation. | |
static Header | headerRead (FD_t fd, enum hMagic magicp) |
Read (and load) header from file handle. | |
static int | headerWrite (FD_t fd, Header h, enum hMagic magicp) |
Write (with unload) header to file handle. | |
static int | headerIsEntry (Header h, int_32 tag) |
Check if tag is in header. | |
static void * | headerFreeTag (Header h, const void *data, rpmTagType type) |
Free data allocated when retrieved from header. | |
static int | headerGetEntry (Header h, int_32 tag, hTYP_t type, void **p, hCNT_t c) |
Retrieve tag value. | |
static int | headerGetEntryMinMemory (Header h, int_32 tag, hTYP_t type, hPTR_t *p, hCNT_t c) |
Retrieve tag value using header internal array. | |
static int | headerAddEntry (Header h, int_32 tag, int_32 type, const void *p, int_32 c) |
Add tag to header. | |
static int | headerAppendEntry (Header h, int_32 tag, int_32 type, const void *p, int_32 c) |
Append element to tag array in header. | |
static int | headerAddOrAppendEntry (Header h, int_32 tag, int_32 type, const void *p, int_32 c) |
Add or append element to tag array in header. | |
static int | headerAddI18NString (Header h, int_32 tag, const char *string, const char *lang) |
Add locale specific tag to header. | |
static int | headerModifyEntry (Header h, int_32 tag, int_32 type, const void *p, int_32 c) |
Modify tag in header. | |
static int | headerRemoveEntry (Header h, int_32 tag) |
Delete tag in header. | |
static char * | headerSprintf (Header h, const char *fmt, const struct headerTagTableEntry_s *tbltags, const struct headerSprintfExtension_s *extensions, errmsg_t *errmsg) |
Return formatted output string from header tags. | |
static void | headerCopyTags (Header headerFrom, Header headerTo, hTAG_t tagstocopy) |
Duplicate tag values from one header into another. | |
static HeaderIterator | headerFreeIterator (HeaderIterator hi) |
Destroy header tag iterator. | |
static HeaderIterator | headerInitIterator (Header h) |
Create header tag iterator. | |
static int | headerNextIterator (HeaderIterator hi, hTAG_t tag, hTYP_t type, hPTR_t *p, hCNT_t c) |
Return next tag from header. | |
static int | regionSwab (indexEntry entry, int il, int dl, entryInfo pe, char *dataStart, int regionid) |
Swap int_32 and int_16 arrays within header region. | |
static void * | doHeaderUnload (Header h, int *lengthPtr) |
static int | copyEntry (const indexEntry entry, hTYP_t type, hPTR_t *p, hCNT_t c, int minMem) |
Retrieve data from header entry. | |
static void * | headerFreeData (const void *data, rpmTagType type) |
Free data allocated when retrieved from header. | |
char ** | headerGetLangs (Header h) |
Return array of locales found in header. | |
int | headerGetRawEntry (Header h, int_32 tag, hTYP_t type, hPTR_t *p, hCNT_t c) |
Retrieve tag value with type match. | |
static int | headerUsageCount (Header h) |
Return header reference count. | |
void | headerDump (Header h, FILE *f, int flags, const struct headerTagTableEntry_s *tags) |
Dump a header in human readable format (for debugging). | |
int | headerNVR (Header h, const char **np, const char **vp, const char **rp) |
Return name, version, release strings from header. | |
void | headerMergeLegacySigs (Header h, const Header sig) |
Translate and merge legacy signature tags into header. | |
Header | headerRegenSigHeader (const Header h) |
Regenerate signature header. | |
Variables | |
struct HV_s * | hdrVec = &hdrVec1 |
Header methods for rpm headers. | |
static unsigned char | header_magic [8] |
static size_t | headerMaxbytes = (32*1024*1024) |
Maximum no. | |
static int | typeSizes [] |
Alignment needs (and sizeof scalars types) for internal rpm data types. | |
struct headerSprintfExtension_s | headerDefaultFormats [] |
Supported default header tag output formats. |
Description of tag data.
Definition at line 25 of file header_internal.h.
typedef struct extensionCache* extensionCache |
Definition at line 83 of file header_internal.h.
Add tag to header.
Duplicate tags are okay, but only defined for iteration (with the exceptions noted below). While you are allowed to add i18n string arrays through this function, you probably don't mean to. See headerAddI18NString() instead.
h | header | |
tag | tag | |
type | tag value data type | |
p | pointer to tag value(s) | |
c | number of values |
typedef int(* HDRaddi18n)(Header h, int_32 tag, const char *string, const char *lang) |
Add locale specific tag to header.
A NULL lang is interpreted as the C locale. Here are the rules:
* - If the tag isn't in the header, it's added with the passed string * as new value. * - If the tag occurs multiple times in entry, which tag is affected * by the operation is undefined. * - If the tag is in the header w/ this language, the entry is * *replaced* (like headerModifyEntry()). *
This function is intended to just "do the right thing". If you need more fine grained control use headerAddEntry() and headerModifyEntry().
h | header | |
tag | tag | |
string | tag value | |
lang | locale |
typedef int(* HDRaddorappend)(Header h, int_32 tag, int_32 type, const void *p, int_32 c) |
Append element to tag array in header.
Appends item p to entry w/ tag and type as passed. Won't work on RPM_STRING_TYPE. Any pointers into header memory returned from headerGetEntryMinMemory() for this entry are invalid after this call has been made!
h | header | |
tag | tag | |
type | tag value data type | |
p | pointer to tag value(s) | |
c | number of values |
typedef Header(* HDRcopyload)(const void *uh) |
typedef void(* HDRcopytags)(Header headerFrom, Header headerTo, hTAG_t tagstocopy) |
typedef HeaderIterator(* HDRfreeiter)(HeaderIterator hi) |
typedef void*(* HDRfreetag)(Header h,const void *data, rpmTagType type) |
Retrieve tag value.
Will never return RPM_I18NSTRING_TYPE! RPM_STRING_TYPE elements with RPM_I18NSTRING_TYPE equivalent entries are translated (if HEADER_I18NTABLE entry is present).
h | header | |
tag | tag |
type | address of tag value data type (or NULL) | |
p | address of pointer to tag value(s) (or NULL) | |
c | address of number of values (or NULL) |
Retrieve tag value using header internal array.
Get an entry using as little extra RAM as possible to return the tag value. This is only an issue for RPM_STRING_ARRAY_TYPE.
h | header | |
tag | tag |
type | address of tag value data type (or NULL) | |
p | address of pointer to tag value(s) (or NULL) | |
c | address of number of values (or NULL) |
typedef Header(* HDRhdrread)(FD_t fd, enum hMagic magicp) |
typedef char*(* HDRhdrsprintf)(Header h, const char *fmt, const struct headerTagTableEntry_s *tags, const struct headerSprintfExtension_s *extensions,errmsg_t *errmsg) |
Return formatted output string from header tags.
The returned string must be free()d.
h | header | |
fmt | format to use | |
tags | array of tag name/value pairs | |
extensions | chained table of formatting extensions. |
errmsg | error message (if any) |
typedef int(* HDRhdrwrite)(FD_t fd,Header h, enum hMagic magicp) |
typedef HeaderIterator(* HDRinititer)(Header h) |
typedef int(* HDRisentry)(Header h, int_32 tag) |
typedef int(* HDRnextiter)(HeaderIterator hi,hTAG_t tag,hTYP_t type,hPTR_t *p,hCNT_t c) |
typedef struct headerToken* Header |
typedef struct headerIteratorS* HeaderIterator |
typedef struct headerSprintfExtension_s* headerSprintfExtension |
typedef char*(* headerTagFormatFunction)(int_32 type, const void *data, char *formatPrefix, int padding, int element) |
typedef struct headerTagTableEntry_s* headerTagTableEntry |
typedef int(* headerTagTagFunction)(Header h,hTYP_t type,hPTR_t *data,hCNT_t count,int *freeData) |
HEADER_EXT_FORMAT format function prototype.
This is allowed to fail, which indicates the tag doesn't exist.
h | header |
type | address of tag type | |
data | address of tag value pointer | |
count | address of no. of data items | |
freedata | address of data-was-malloc'ed indicator |
typedef struct indexEntry* indexEntry |
A single tag from a Header.
Definition at line 43 of file header_internal.h.
typedef enum rpmSubTagType_e rpmSubTagType |
New rpm data types under consideration/development.
These data types may (or may not) be added to rpm at some point. In order to avoid incompatibility with legacy versions of rpm, these data (sub-)types are introduced into the header by overloading RPM_BIN_TYPE, with the binary value of the tag a 16 byte image of what should/will be in the header index, followed by per-tag private data.
typedef enum rpmTagType_e rpmTagType |
The basic types of data in tags from headers.
typedef struct sprintfTag* sprintfTag |
Definition at line 69 of file header_internal.h.
typedef struct sprintfToken* sprintfToken |
Definition at line 95 of file header_internal.h.
HEADER_EXT_LAST |
End of extension chain. |
HEADER_EXT_FORMAT |
headerTagFormatFunction() extension |
HEADER_EXT_MORE |
Chain to next table. |
HEADER_EXT_TAG |
headerTagTagFunction() extension |
enum hMagic |
enum rpmSubTagType_e |
New rpm data types under consideration/development.
These data types may (or may not) be added to rpm at some point. In order to avoid incompatibility with legacy versions of rpm, these data (sub-)types are introduced into the header by overloading RPM_BIN_TYPE, with the binary value of the tag a 16 byte image of what should/will be in the header index, followed by per-tag private data.
enum rpmTagType_e |
static int copyEntry | ( | const indexEntry | entry, | |
hTYP_t | type, | |||
hPTR_t * | p, | |||
hCNT_t | c, | |||
int | minMem | |||
) | [static] |
Retrieve data from header entry.
entry | header entry |
type | address of type (or NULL) | |
p | address of data (or NULL) | |
c | address of count (or NULL) |
minMem | string pointers refer to header memory? |
static void* doHeaderUnload | ( | Header | h, | |
int * | lengthPtr | |||
) | [static] |
Definition at line 22 of file hdrinline.h.
static int headerAddEntry | ( | Header | h, | |
int_32 | tag, | |||
int_32 | type, | |||
const void * | p, | |||
int_32 | c | |||
) | [inline, static] |
Add tag to header.
Duplicate tags are okay, but only defined for iteration (with the exceptions noted below). While you are allowed to add i18n string arrays through this function, you probably don't mean to. See headerAddI18NString() instead.
h | header | |
tag | tag | |
type | tag value data type | |
p | pointer to tag value(s) | |
c | number of values |
static int headerAddI18NString | ( | Header | h, | |
int_32 | tag, | |||
const char * | string, | |||
const char * | lang | |||
) | [inline, static] |
Add locale specific tag to header.
A NULL lang is interpreted as the C locale. Here are the rules:
* - If the tag isn't in the header, it's added with the passed string * as new value. * - If the tag occurs multiple times in entry, which tag is affected * by the operation is undefined. * - If the tag is in the header w/ this language, the entry is * *replaced* (like headerModifyEntry()). *
This function is intended to just "do the right thing". If you need more fine grained control use headerAddEntry() and headerModifyEntry().
h | header | |
tag | tag | |
string | tag value | |
lang | locale |
static int headerAddOrAppendEntry | ( | Header | h, | |
int_32 | tag, | |||
int_32 | type, | |||
const void * | p, | |||
int_32 | c | |||
) | [inline, static] |
Add or append element to tag array in header.
h | header | |
tag | tag | |
type | tag value data type | |
p | pointer to tag value(s) | |
c | number of values |
h | header | |
tag | tag | |
type | tag value data type | |
p | pointer to tag value(s) | |
c | number of values |
static int headerAppendEntry | ( | Header | h, | |
int_32 | tag, | |||
int_32 | type, | |||
const void * | p, | |||
int_32 | c | |||
) | [inline, static] |
Append element to tag array in header.
Appends item p to entry w/ tag and type as passed. Won't work on RPM_STRING_TYPE. Any pointers into header memory returned from headerGetEntryMinMemory() for this entry are invalid after this call has been made!
h | header | |
tag | tag | |
type | tag value data type | |
p | pointer to tag value(s) | |
c | number of values |
static Header headerCopyLoad | ( | const void * | uh | ) | [inline, static] |
void headerDump | ( | Header | h, | |
FILE * | f, | |||
int | flags, | |||
const struct headerTagTableEntry_s * | tags | |||
) |
Dump a header in human readable format (for debugging).
h | header | |
flags | 0 or HEADER_DUMP_INLINE | |
tags | array of tag name/value pairs |
Definition at line 30 of file header_internal.c.
static void* headerFreeData | ( | const void * | data, | |
rpmTagType | type | |||
) | [inline, static] |
Free data allocated when retrieved from header.
data | address of data (or NULL) | |
type | type of data (or -1 to force free) |
static HeaderIterator headerFreeIterator | ( | HeaderIterator | hi | ) | [inline, static] |
static void * headerFreeTag | ( | Header | h, | |
const void * | data, | |||
rpmTagType | type | |||
) | [inline, static] |
static int headerGetEntry | ( | Header | h, | |
int_32 | tag, | |||
hTYP_t | type, | |||
void ** | p, | |||
hCNT_t | c | |||
) | [inline, static] |
Retrieve tag value.
Will never return RPM_I18NSTRING_TYPE! RPM_STRING_TYPE elements with RPM_I18NSTRING_TYPE equivalent entries are translated (if HEADER_I18NTABLE entry is present).
h | header | |
tag | tag |
type | address of tag value data type (or NULL) | |
p | address of pointer to tag value(s) (or NULL) | |
c | address of number of values (or NULL) |
static int headerGetEntryMinMemory | ( | Header | h, | |
int_32 | tag, | |||
hTYP_t | type, | |||
hPTR_t * | p, | |||
hCNT_t | c | |||
) | [inline, static] |
Retrieve tag value using header internal array.
Get an entry using as little extra RAM as possible to return the tag value. This is only an issue for RPM_STRING_ARRAY_TYPE.
h | header | |
tag | tag |
type | address of tag value data type (or NULL) | |
p | address of pointer to tag value(s) (or NULL) | |
c | address of number of values (or NULL) |
char** headerGetLangs | ( | Header | h | ) |
Return array of locales found in header.
The array is terminated with a NULL sentinel.
h | header |
Definition at line 11 of file header_internal.c.
Retrieve tag value with type match.
If *type is RPM_NULL_TYPE any type will match, otherwise only *type will match.
h | header | |
tag | tag |
type | address of tag value data type (or NULL) | |
p | address of pointer to tag value(s) (or NULL) | |
c | address of number of values (or NULL) |
static HeaderIterator headerInitIterator | ( | Header | h | ) | [inline, static] |
static Header headerLoad | ( | void * | uh | ) | [inline, static] |
static Header headerNew | ( | void | ) | [inline, static] |
static int headerNextIterator | ( | HeaderIterator | hi, | |
hTAG_t | tag, | |||
hTYP_t | type, | |||
hPTR_t * | p, | |||
hCNT_t | c | |||
) | [inline, static] |
int headerNVR | ( | Header | h, | |
const char ** | np, | |||
const char ** | vp, | |||
const char ** | rp | |||
) |
static void headerSort | ( | Header | h | ) | [inline, static] |
static char * headerSprintf | ( | Header | h, | |
const char * | fmt, | |||
const struct headerTagTableEntry_s * | tbltags, | |||
const struct headerSprintfExtension_s * | extensions, | |||
errmsg_t * | errmsg | |||
) | [inline, static] |
Return formatted output string from header tags.
The returned string must be free()d.
h | header | |
fmt | format to use | |
tbltags | array of tag name/value pairs | |
extensions | chained table of formatting extensions. |
errmsg | error message (if any) |
static void * headerUnload | ( | Header | h | ) | [inline, static] |
static void headerUnsort | ( | Header | h | ) | [inline, static] |
static int headerUsageCount | ( | Header | h | ) | [inline, static] |
Return header reference count.
h | header |
Definition at line 164 of file header_internal.h.
static int regionSwab | ( | indexEntry | entry, | |
int | il, | |||
int | dl, | |||
entryInfo | pe, | |||
char * | dataStart, | |||
int | regionid | |||
) | [static] |
Swap int_32 and int_16 arrays within header region.
This code is way more twisty than I would like.
A bug with RPM_I18NSTRING_TYPE in rpm-2.5.x (fixed in August 1998) causes the offset and length of elements in a header region to disagree regarding the total length of the region data.
The "fix" is to compute the size using both offset and length and return the larger of the two numbers as the size of the region. Kinda like computing left and right Riemann sums of the data elements to determine the size of a data structure, go figger :-).
There's one other twist if a header region tag is in the set to be swabbed, as the data for a header region is located after all other tag data.
entry | header entry | |
il | no. of entries | |
dl | start no. bytes of data | |
pe | header physical entry pointer (swapped) | |
dataStart | header data | |
regionid | region offset |
unsigned char header_magic[8] [static] |
size_t headerMaxbytes = (32*1024*1024) [static] |