# HEADER.

## 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

## Data Structures

struct | headerToken
| The Header data structure. More...

## Typedefs

typedef const char * | errmsg_t
typedef int_32 * | hTAG_t
typedef headerToken * | Header
typedef headerIteratorS * | HeaderIterator
typedef 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 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 HV_s * | HV_t
| Header method vectors.
typedef entryInfo * | entryInfo
| Description of tag data.
typedef indexEntry * | indexEntry
| A single tag from a Header.
typedef sprintfTag * | sprintfTag
typedef extensionCache * | extensionCache
typedef 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 { RPM_NULL_TYPE = 0, RPM_CHAR_TYPE = 1, RPM_INT8_TYPE = 2, RPM_INT16_TYPE = 3, RPM_INT32_TYPE = 4, RPM_STRING_TYPE = 6, RPM_BIN_TYPE = 7, RPM_STRING_ARRAY_TYPE = 8, RPM_I18NSTRING_TYPE }
| 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

HV_s * | hdrVec
| 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.
const struct headerSprintfExtension_s | headerDefaultFormats []
| Supported default header tag output formats.

## Typedef Documentation

typedef struct entryInfo* entryInfo

| Description of tag data. Definition at line 25 of file header_internal.h.

typedef const char* errmsg_t

| Definition at line 112 of file header.h.

typedef struct extensionCache* extensionCache

| Definition at line 83 of file header_internal.h.

typedef int(* HDRadd)(Header h, int_32 tag, int_32 type, const void *p, int_32 c)

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.

Parameters:

  | h | header
  | tag | tag
  | type | tag value data type
  | p | pointer to tag value(s)
  | c | number of values

Returns:
  1 on success, 0 on failure

Definition at line 499 of file header.h.

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().

Parameters:

  | h | header
  | tag | tag
  | string | tag value
  | lang | locale

Returns:
  1 on success, 0 on failure

Definition at line 555 of file header.h.

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.

Todo:
  Arg "p" should have const.

Parameters:

  | h | header
  | tag | tag
  | type | tag value data type
  | p | pointer to tag value(s)
  | c | number of values

Returns:
  1 on success, 0 on failure

Definition at line 531 of file header.h.

typedef int(* HDRappend)(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!

Parameters:

  | h | header
  | tag | tag
  | type | tag value data type
  | p | pointer to tag value(s)
  | c | number of values

Returns:
  1 on success, 0 on failure

Definition at line 517 of file header.h.

typedef Header(* HDRcopy)(Header h)

Duplicate a header.

Parameters:

  | h | header

Returns:
  new header instance

Definition at line 380 of file header.h.

typedef Header(* HDRcopyload)(const void *uh)

Make a copy and convert header to in-memory representation.

Parameters:

  | uh | on-disk header blob (i.e. with offsets)

Returns:
  header

Definition at line 398 of file header.h.

typedef void(* HDRcopytags)(Header headerFrom, Header headerTo, hTAG_t tagstocopy)

Duplicate tag values from one header into another.

Parameters:

  | headerFrom | source header
  | headerTo | destination header
  | tagstocopy | array of tags that are copied

Definition at line 611 of file header.h.

typedef Header(* HDRfree)(Header h)

Dereference a header instance.

Parameters:

  | h | header

Returns:
  NULL always

Definition at line 305 of file header.h.

typedef HeaderIterator(* HDRfreeiter)(HeaderIterator hi)

Destroy header tag iterator.

Parameters:

  | hi | header tag iterator

Returns:
  NULL always

Definition at line 620 of file header.h.

typedef void*(* HDRfreetag)(Header h,const void *data, rpmTagType type)

Free data allocated when retrieved from header.

Parameters:

  | h | header
  | data | address of data (or NULL)
  | type | type of data (or -1 to force free)

Returns:
  NULL always

Definition at line 441 of file header.h.

typedef int(* HDRget)(Header h, int_32 tag,hTYP_t type,void **p,hCNT_t c)

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).

Parameters:

  | h | header
  | tag | tag

Return values:

  | 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)

Returns:
  1 on success, 0 on failure

Definition at line 459 of file header.h.

typedef int(* HDRgetmin)(Header h, int_32 tag,hTYP_t type,hPTR_t *p,hCNT_t c)

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.

Parameters:

  | h | header
  | tag | tag

Return values:

  | 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)

Returns:
  1 on success, 0 on failure

Definition at line 478 of file header.h.

typedef Header(* HDRhdrread)(FD_t fd, enum hMagic magicp)

Read (and load) header from file handle.

Parameters:

  | fd | file handle
  | magicp | read (and verify) 8 bytes of (magic, 0)?

Returns:
  header (or NULL on error)

Definition at line 408 of file header.h.

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.

Parameters:

  | h | header
  | fmt | format to use
  | tags | array of tag name/value pairs
  | extensions | chained table of formatting extensions.

Return values:

  | errmsg | error message (if any)

Returns:
  formatted output string (malloc'ed)

Definition at line 598 of file header.h.

typedef int(* HDRhdrwrite)(FD_t fd,Header h, enum hMagic magicp)

Write (with unload) header to file handle.

Parameters:

  | fd | file handle
  | h | header
  | magicp | prefix write with 8 bytes of (magic, 0)?

Returns:
  0 on success, 1 on error

Definition at line 419 of file header.h.

typedef HeaderIterator(* HDRinititer)(Header h)

Create header tag iterator.

Parameters:

  | h | header

Returns:
  header tag iterator

Definition at line 629 of file header.h.

typedef int(* HDRisentry)(Header h, int_32 tag)

Check if tag is in header.

Parameters:

  | h | header
  | tag | tag

Returns:
  1 on success, 0 on failure

Definition at line 430 of file header.h.

typedef Header(* HDRlink)(Header h)

Reference a header instance.

Parameters:

  | h | header

Returns:
  referenced header instance

Definition at line 314 of file header.h.

typedef Header(* HDRload)(void *uh)

Convert header to in-memory representation.

Parameters:

  | uh | on-disk header blob (i.e. with offsets)

Returns:
  header

Definition at line 389 of file header.h.

typedef int(* HDRmodify)(Header h, int_32 tag, int_32 type, const void *p, int_32 c)

Modify tag in header.

If there are multiple entries with this tag, the first one gets replaced.

Parameters:

  | h | header
  | tag | tag
  | type | tag value data type
  | p | pointer to tag value(s)
  | c | number of values

Returns:
  1 on success, 0 on failure

Definition at line 570 of file header.h.

typedef Header(* HDRnew)(void)

Create new (empty) header instance.

Returns:
  header

Definition at line 296 of file header.h.

typedef int(* HDRnextiter)(HeaderIterator hi,hTAG_t tag,hTYP_t type,hPTR_t *p,hCNT_t c)

Return next tag from header.

Parameters:

  | hi | header tag iterator

Return values:

  | tag | address of tag
  | type | address of tag value data type
  | p | address of pointer to tag value(s)
  | c | address of number of values

Returns:
  1 on success, 0 on failure

Definition at line 642 of file header.h.

typedef Header(* HDRreload)(Header h, int tag)

Convert header to on-disk representation, and then reload.

This is used to insure that all header data is in one chunk.

Parameters:

  | h | header (with pointers)
  | tag | region tag

Returns:
  on-disk header (with offsets)

Definition at line 371 of file header.h.

typedef int(* HDRremove)(Header h, int_32 tag)

Delete tag in header.

Removes all entries of type tag from the header, returns 1 if none were found.

Parameters:

  | h | header
  | tag | tag

Returns:
  0 on success, 1 on failure (INCONSISTENT)

Definition at line 583 of file header.h.

typedef unsigned int(* HDRsizeof)(Header h, enum hMagic magicp)

Return size of on-disk header representation in bytes.

Parameters:

  | h | header
  | magicp | include size of 8 bytes for (magic, 0)?

Returns:
  size of on-disk header

Definition at line 351 of file header.h.

typedef void(* HDRsort)(Header h)

Sort tags in header.

Todo:
  Eliminate from API.

Parameters:

  | h | header

Definition at line 332 of file header.h.

typedef Header(* HDRunlink)(Header h)

Dereference a header instance.

Parameters:

  | h | header

Returns:
  NULL always

Definition at line 323 of file header.h.

typedef void*(* HDRunload)(Header h)

Convert header to on-disk representation.

Parameters:

  | h | header (with pointers)

Returns:
  on-disk header blob (i.e. with offsets)

Definition at line 360 of file header.h.

typedef void(* HDRunsort)(Header h)

Restore tags in header to original ordering.

Todo:
  Eliminate from API.

Parameters:

  | h | header

Definition at line 341 of file header.h.

typedef struct headerToken* Header

| Definition at line 123 of file header.h.

typedef struct headerIteratorS* HeaderIterator

| Definition at line 127 of file header.h.

typedef struct headerSprintfExtension_s* headerSprintfExtension

| Define header tag output formats. Definition at line 182 of file header.h.

typedef char*(* headerTagFormatFunction)(int_32 type, const void *data, char *formatPrefix, int padding, int element)

HEADER_EXT_TAG format function prototype.

This will only ever be passed RPM_INT32_TYPE or RPM_STRING_TYPE to help keep things simple.

Parameters:

  | type | tag type
  | data | tag value
  | formatPrefix |
  | padding |
  | element |

Returns:
  formatted string

Definition at line 159 of file header.h.

typedef struct headerTagTableEntry_s* headerTagTableEntry

| Associate tag names with numeric values. Definition at line 132 of file header.h.

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.

Parameters:

  | h | header

Return values:

  | 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

Returns:
  0 on success

Definition at line 173 of file header.h.

typedef int_32* hTAG_t

| Definition at line 116 of file header.h.

typedef struct HV_s* HV_t

| Header method vectors. Definition at line 652 of file header.h.

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.

## Enumeration Type Documentation

enum headerSprintfExtenstionType

Enumerator:

  HEADER_EXT_LAST | End of extension chain.
  HEADER_EXT_FORMAT | headerTagFormatFunction() extension
  HEADER_EXT_MORE | Chain to next table.
  HEADER_EXT_TAG | headerTagTagFunction() extension

Definition at line 140 of file header.h.

enum hMagic

Include calculation for 8 bytes of (magic, 0)?

Enumerator:

  HEADER_MAGIC_NO |
  HEADER_MAGIC_YES |

Definition at line 207 of file header.h.

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.

Enumerator:

  RPM_REGION_TYPE |

  RPM_BIN_ARRAY_TYPE

  Todo:
    Implement, kinda like RPM_STRING_ARRAY_TYPE for known (but variable) length binary data.

  RPM_XREF_TYPE

  Todo:
    Implement, intent is to to carry a (???,tagNum,valNum) cross reference to retrieve data from other tags.

Definition at line 239 of file header.h.

enum rpmTagType_e

The basic types of data in tags from headers.

Enumerator:

  RPM_NULL_TYPE |
  RPM_CHAR_TYPE |
  RPM_INT8_TYPE |
  RPM_INT16_TYPE |
  RPM_INT32_TYPE |
  RPM_STRING_TYPE |
  RPM_BIN_TYPE |
  RPM_STRING_ARRAY_TYPE |
  RPM_I18NSTRING_TYPE |

Definition at line 215 of file header.h.

## Function Documentation

static int copyEntry | ( | const indexEntry | entry,
|  | hTYP_t | type,
|  | hPTR_t * | p,
|  | hCNT_t | c,
|  | int | minMem
| ) | `[static]`

Retrieve data from header entry.

Todo:
  Permit retrieval of regions other than HEADER_IMUTABLE.

Parameters:

  | entry | header entry

Return values:

  | type | address of type (or NULL)
  | p | address of data (or NULL)
  | c | address of count (or NULL)

Parameters:

  | minMem | string pointers refer to header memory?

Returns:
  1 on success, otherwise error.

Definition at line 1249 of file header.c.

References entryInfo::count, indexEntry::data, ENTRY_IS_REGION, HEADER_IMAGE, indexEntry::info, REGION_TAG_COUNT, regionSwab(), RPM_BIN_TYPE, RPM_I18NSTRING_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, entryInfo::type, and xmalloc().

Referenced by headerGetRawEntry(), and intGetEntry().

static void* doHeaderUnload | ( | Header | h,
|  | int * | lengthPtr
| ) | `[static]`

| Definition at line 501 of file header.c. References entryInfo::count, ENTRY_IS_REGION, headerToken::flags, HEADERFLAG_LEGACY, headerUnsort(), headerToken::index, headerToken::indexUsed, indexEntry::info, indexEntry::length, entryInfo::offset, indexEntry::rdlen, entryInfo::type, and typeSizes.

static HV_t h2hv | ( | Header | h | ) | `[inline, static]`

Definition at line 22 of file hdrinline.h.

Referenced by headerAddEntry(), headerAddI18NString(), headerAddOrAppendEntry(), headerAppendEntry(), headerCopy(), headerFree(), headerFreeTag(), headerGetEntry(), headerGetEntryMinMemory(), headerIsEntry(), headerLink(), headerModifyEntry(), headerReload(), headerRemoveEntry(), headerSizeof(), headerSort(), headerSprintf(), headerUnlink(), headerUnload(), headerUnsort(), and headerWrite().

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.

Parameters:

  | h | header
  | tag | tag
  | type | tag value data type
  | p | pointer to tag value(s)
  | c | number of values

Returns:
  1 on success, 0 on failure

Definition at line 315 of file hdrinline.h.

References h2hv(), and HV_s::hdradd.

Referenced by addChangelogEntry(), addFileToTag(), compressFilelist(), expandFilelist(), fillOutMainPackage(), genCpioListAndHeader(), handlePreambleTag(), headerCopyWithConvert(), headerInject(), headerMergeLegacySigs(), headerRegenSigHeader(), initSourceHeader(), loadFi(), mungeFilelist(), packageBinaries(), packageSources(), parsePreamble(), parseScript(), psmStage(), readIcon(), readPackageHeaders(), rhnLoad(), rhnUnload(), rpmAddSignature(), rpmdbAdd(), rpmdbRemove(), rpmMergeHeaders(), rpmReadSignature(), and writeRPM().

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().

Parameters:

  | h | header
  | tag | tag
  | string | tag value
  | lang | locale

Returns:
  1 on success, 0 on failure

Definition at line 382 of file hdrinline.h.

References h2hv(), and HV_s::hdraddi18n.

Referenced by handlePreambleTag(), and parseDescription().

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.

Todo:
  Arg "p" should have const.

Parameters:

  | h | header
  | tag | tag
  | type | tag value data type
  | p | pointer to tag value(s)
  | c | number of values

Returns:
  1 on success, 0 on failure

Definition at line 354 of file hdrinline.h.

References h2hv(), and HV_s::hdraddorappend.

Referenced by addFileToArrayTag(), addOrAppendListEntry(), genCpioListAndHeader(), processScriptFiles(), processSourceFiles(), and providePackageNVR().

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!

Parameters:

  | h | header
  | tag | tag
  | type | tag value data type
  | p | pointer to tag value(s)
  | c | number of values

Returns:
  1 on success, 0 on failure

Definition at line 336 of file hdrinline.h.

References h2hv(), and HV_s::hdrappend.

Referenced by addChangelogEntry().

static Header headerCopy | ( | Header | h | ) | `[inline, static]`

Duplicate a header.

Parameters:

  | h | header

Returns:
  new header instance

Definition at line 163 of file hdrinline.h.

References h2hv(), and HV_s::hdrcopy.

Referenced by hdrUnload(), psmStage(), relocateFileList(), and rpmdbRebuild().

static Header headerCopyLoad | ( | const void * | uh | ) | `[inline, static]`

Make a copy and convert header to in-memory representation.

Parameters:

  | uh | on-disk header blob (i.e. with offsets)

Returns:
  header

Definition at line 187 of file hdrinline.h.

References HV_s::hdrcopyload, and hdrVec.

Referenced by psmStage(), rpmdbNextIterator(), and rpmReSign().

static void headerCopyTags | ( | Header | headerFrom,
|  | Header | headerTo,
|  | hTAG_t | tagstocopy
| ) | `[inline, static]`

Duplicate tag values from one header into another.

Parameters:

  | headerFrom | source header
  | headerTo | destination header
  | tagstocopy | array of tags that are copied

Definition at line 451 of file hdrinline.h.

References HV_s::hdrcopytags, and hdrVec.

Referenced by packageBinaries(), and parsePreamble().

void headerDump | ( | Header | h,
|  | FILE * | f,
|  | int | flags,
|  | const struct headerTagTableEntry_s * | tags
| ) |

Dump a header in human readable format (for debugging).

Parameters:

  | h | header
  | flags | 0 or HEADER_DUMP_INLINE
  | tags | array of tag name/value pairs

Definition at line 30 of file header_internal.c.

References headerToken::index, headerToken::indexUsed, indexEntry::info, RPM_BIN_TYPE, RPM_CHAR_TYPE, RPM_I18NSTRING_TYPE, RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_INT8_TYPE, RPM_NULL_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, and entryInfo::type.

Referenced by main().

static Header headerFree | ( | Header | h | ) | `[inline, static]`

Dereference a header instance.

Parameters:

  | h | header

Returns:
  NULL always

Definition at line 47 of file hdrinline.h.

References h2hv(), and HV_s::hdrfree.

Referenced by db1cput(), dbiFindMatches(), doGetRecord(), freeFi(), freePackage(), freeSpec(), hdrDealloc(), hdrUnload(), IDTXfree(), IDTXglob(), loadFi(), main(), psmStage(), readPackageHeaders(), readRPM(), rhnLoad(), rhnUnload(), rpmdbFindByFile(), rpmdbFreeIterator(), rpmdbNextIterator(), rpmdbRebuild(), rpmdepFreeConflicts(), rpmFreeSignature(), rpmInstallSourcePackage(), rpmMergeHeaders(), rpmProblemSetFree(), rpmQueryVerify(), rpmReadSignature(), rpmReSign(), rpmRollback(), and writeRPM().

static void* headerFreeData | ( | const void * | data,
|  | rpmTagType | type
| ) | `[inline, static]`

Free data allocated when retrieved from header.

Deprecated:
  Use headerFreeTag() instead.

Todo:
  Remove from API.

Parameters:

  | data | address of data (or NULL)
  | type | type of data (or -1 to force free)

Returns:
  NULL always

Definition at line 700 of file header.h.

References RPM_BIN_TYPE, RPM_I18NSTRING_TYPE, and RPM_STRING_ARRAY_TYPE.

Referenced by addReqProv(), alAddPackage(), alFree(), checkPackageDeps(), compressFilelist(), doBuildFileList(), formatValue(), fpLookupHeader(), freeFi(), handleInstInstalledFiles(), handleOneTrigger(), handlePreambleTag(), headerMergeLegacySigs(), headerRegenSigHeader(), initSourceHeader(), instprefixTag(), isMemberInEntry(), loadFi(), mergeFiles(), mireSkip(), printDeps(), providePackageNVR(), psmStage(), rangeMatchesDepFlags(), relocateFileList(), rhnUnload(), rpmCheckSig(), rpmdbAdd(), rpmdbFindByFile(), rpmdbFindFpList(), rpmdbRemove(), rpmdepCheck(), rpmInstallSourcePackage(), rpmMergeHeaders(), rpmtransAddPackage(), rpmVerifyDigest(), rpmVerifyFile(), runImmedTriggers(), runInstScript(), runScript(), showQueryPackage(), timeCheck(), triggercondsTag(), and triggertypeTag().

static HeaderIterator headerFreeIterator | ( | HeaderIterator | hi | ) | `[inline, static]`

Destroy header tag iterator.

Parameters:

  | hi | header tag iterator

Returns:
  NULL always

Definition at line 466 of file hdrinline.h.

References HV_s::hdrfreeiter, and hdrVec.

Referenced by hdrKeyList(), headerCopyWithConvert(), psmStage(), rpmCheckSig(), and rpmMergeHeaders().

static void * headerFreeTag | ( | Header | h,
|  | const void * | data,
|  | rpmTagType | type
| ) | `[inline, static]`

Free data allocated when retrieved from header.

Parameters:

  | h | header
  | data | address of data (or NULL)
  | type | type of data (or -1 to force free)

Returns:
  NULL always

Definition at line 247 of file hdrinline.h.

References h2hv(), and HV_s::hdrfreetag.

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).

Parameters:

  | h | header
  | tag | tag

Return values:

  | 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)

Returns:
  1 on success, 0 on failure

Definition at line 268 of file hdrinline.h.

References h2hv(), and HV_s::hdrget.

Referenced by addLostFiles(), archOkay(), findPackagesWithRelocatedFiles(), findUpgradePackages(), formatValue(), hdrVerifyFile(), headerNVR(), IDTXglob(), IDTXload(), loadFi(), main(), osOkay(), psGetArchScore(), psmStage(), readPackageHeaders(), removeMovedFilesAlreadyHandled(), rhnLoad(), rhnUnload(), rpmHeaderGetEntry(), rpmMergeHeaders(), rpmPackageGetEntry(), rpmReadSignature(), rpmReSign(), rpmVerifyDigest(), rpmVersionCompare(), and unmarkPackagesAlreadyInstalled().

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.

Parameters:

  | h | header
  | tag | tag

Return values:

  | 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)

Returns:
  1 on success, 0 on failure

Definition at line 290 of file hdrinline.h.

References h2hv(), and HV_s::hdrgetmin.

Referenced by addFileToTag(), addLostFiles(), addReqProv(), alAddPackage(), checkPackageDeps(), compressFilelist(), doBuildFileList(), doGetRecord(), findPackagesWithObsoletes(), findPackagesWithRelocatedFiles(), findUpgradePackages(), fpLookupHeader(), fssizesTag(), handlePreambleTag(), headerMatchesDepFlags(), i18nTag(), instprefixTag(), isMemberInEntry(), loadFi(), mireSkip(), printDeps(), processPackageFiles(), providePackageNVR(), rangeMatchesDepFlags(), removeMovedFilesAlreadyHandled(), rpmdbAdd(), rpmdbFindByFile(), rpmdbFindFpList(), rpmdbRemove(), rpmdepCheck(), rpmtransAddPackage(), rpmVerifyFile(), showQueryPackage(), stashSt(), timeCheck(), triggercondsTag(), triggertypeTag(), verifyHeader(), and writeRPM().

char** headerGetLangs | ( | Header | h | ) |

Return array of locales found in header.

The array is terminated with a NULL sentinel.

Parameters:

  | h | header

Returns:
  array of locales (or NULL on error)

Definition at line 11 of file header_internal.c.

References HEADER_I18NTABLE, headerGetRawEntry(), and xcalloc().

int headerGetRawEntry | ( | Header | h,
|  | int_32 | tag,
|  | hTYP_t | type,
|  | hPTR_t * | p,
|  | hCNT_t | c
| ) |

Retrieve tag value with type match.

If *type is RPM_NULL_TYPE any type will match, otherwise only *type will match.

Parameters:

  | h | header
  | tag | tag

Return values:

  | 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)

Returns:
  1 on success, 0 on failure

static HeaderIterator headerInitIterator | ( | Header | h | ) | `[inline, static]`

Create header tag iterator.

Parameters:

  | h | header

Returns:
  header tag iterator

Definition at line 478 of file hdrinline.h.

References HV_s::hdrinititer, and hdrVec.

Referenced by checkForDuplicates(), hdrKeyList(), headerCopyWithConvert(), headerMergeLegacySigs(), headerRegenSigHeader(), initSourceHeader(), psmStage(), rpmCheckSig(), and rpmMergeHeaders().

static int headerIsEntry | ( | Header | h,
|  | int_32 | tag
| ) | `[inline, static]`

Check if tag is in header.

Parameters:

  | h | header
  | tag | tag

Returns:
  1 on success, 0 on failure

Definition at line 230 of file hdrinline.h.

References h2hv(), and HV_s::hdrisentry.

Referenced by addChangelogEntry(), checkForRequired(), checkSpec(), compressFilelist(), doGetRecord(), expandFilelist(), fillOutMainPackage(), headerGetRawEntry(), headerInject(), headerMergeLegacySigs(), headerRegenSigHeader(), mungeFilelist(), parseDescription(), parseScript(), processBinaryFiles(), psmStage(), readPackageHeaders(), relocateFileList(), rhnLoad(), rhnUnload(), rpmdbAdd(), rpmdbNextIterator(), rpmdbRebuild(), rpmHeaderFromPackage(), rpmPackageGetEntry(), rpmReadSignature(), rpmtransAddPackage(), singleSprintf(), and verifyHeader().

static Header headerLink | ( | Header | h | ) | `[inline, static]`

Reference a header instance.

Parameters:

  | h | header

Returns:
  new header reference

Definition at line 62 of file hdrinline.h.

References h2hv(), and HV_s::hdrlink.

Referenced by alAddPackage(), checkPackageDeps(), dbiFindMatches(), getTsHeader(), hdrUnload(), IDTXglob(), IDTXload(), loadFi(), psAppend(), relocateFileList(), rhnUnload(), rpmdbFindByFile(), rpmdbMINext(), rpmdbRemove(), rpmdbSubscript(), rpmReSign(), and writeRPM().

static Header headerLoad | ( | void * | uh | ) | `[inline, static]`

Convert header to in-memory representation.

Parameters:

  | uh | on-disk header blob (i.e. with offsets)

Returns:
  header

Definition at line 175 of file hdrinline.h.

References HV_s::hdrload, and hdrVec.

Referenced by db1cput(), hdrLoad(), rhnLoad(), and rhnUnload().

void headerMergeLegacySigs | ( | Header | h,
|  | const Header | sig
| ) |

Translate and merge legacy signature tags into header.

Parameters:

  | h | header
  | sig | signature header

Definition at line 20 of file package.c.

References HEADER_SIGBASE, HEADER_TAGBASE, headerAddEntry(), headerFreeData(), headerInitIterator(), headerIsEntry(), headerNextIterator(), RPMSIGTAG_GPG, RPMSIGTAG_LEMD5_1, RPMSIGTAG_LEMD5_2, RPMSIGTAG_MD5, RPMSIGTAG_PGP, RPMSIGTAG_PGP5, RPMSIGTAG_SIZE, RPMTAG_SIGGPG, RPMTAG_SIGLEMD5_1, RPMTAG_SIGLEMD5_2, RPMTAG_SIGMD5, RPMTAG_SIGPGP, RPMTAG_SIGPGP5, RPMTAG_SIGSIZE, sprintfTag::tag, and sprintfTag::type.

Referenced by rpmReadPackageHeader(), rpmReadPackageInfo(), and writeRPM().

static int headerModifyEntry | ( | Header | h,
|  | int_32 | tag,
|  | int_32 | type,
|  | const void * | p,
|  | int_32 | c
| ) | `[inline, static]`

Modify tag in header.

If there are multiple entries with this tag, the first one gets replaced.

Parameters:

  | h | header
  | tag | tag
  | type | tag value data type
  | p | pointer to tag value(s)
  | c | number of values

Returns:
  1 on success, 0 on failure

Definition at line 400 of file hdrinline.h.

References h2hv(), and HV_s::hdrmodify.

Referenced by loadFi().

static Header headerNew | ( | void |  | ) | `[inline, static]`

Create new (empty) header instance.

Returns:
  header

Definition at line 35 of file hdrinline.h.

References HV_s::hdrnew, and hdrVec.

Referenced by headerCopyWithConvert(), initSourceHeader(), newPackage(), newSpec(), psmStage(), rpmNewSignature(), and rpmReadSignature().

static int headerNextIterator | ( | HeaderIterator | hi,
|  | hTAG_t | tag,
|  | hTYP_t | type,
|  | hPTR_t * | p,
|  | hCNT_t | c
| ) | `[inline, static]`

Return next tag from header.

Parameters:

  | hi | header tag iterator

Return values:

  | tag | address of tag
  | type | address of tag value data type
  | p | address of pointer to tag value(s)
  | c | address of number of values

Returns:
  1 on success, 0 on failure

Definition at line 494 of file hdrinline.h.

References HV_s::hdrnextiter, and hdrVec.

Referenced by checkForDuplicates(), hdrKeyList(), headerCopyWithConvert(), headerMergeLegacySigs(), headerRegenSigHeader(), initSourceHeader(), psmStage(), rpmCheckSig(), and rpmMergeHeaders().

int headerNVR | ( | Header | h,
|  | const char ** | np,
|  | const char ** | vp,
|  | const char ** | rp
| ) |

Return name, version, release strings from header.

Parameters:

  | h | header

Return values:

  | np | address of name pointer (or NULL)
  | vp | address of version pointer (or NULL)
  | rp | address of release pointer (or NULL)

Returns:
  0 always

Definition at line 31 of file depends.c.

References headerGetEntry(), RPM_STRING_TYPE, RPMTAG_NAME, RPMTAG_RELEASE, and RPMTAG_VERSION.

Referenced by alAddPackage(), checkPackageDeps(), doSetupMacro(), genSourceRpmName(), handleOneTrigger(), headerMatchesDepFlags(), i18nTag(), IDTXglob(), IDTXload(), lookupPackage(), packageBinaries(), parsePreamble(), printNewSpecfile(), processBinaryFiles(), providePackageNVR(), psAppend(), rpmdbAdd(), rpmdbNextIterator(), rpmdbRebuild(), rpmdbRemove(), rpmtransAddPackage(), runScript(), showQueryPackage(), showVerifyPackage(), verifyDependencies(), and writeRPM().

static Header headerRead | ( | FD_t | fd,
|  | enum hMagic | magicp
| ) | `[inline, static]`

Read (and load) header from file handle.

Parameters:

  | fd | file handle
  | magicp | read (and verify) 8 bytes of (magic, 0)?

Returns:
  header (or NULL on error)

Definition at line 200 of file hdrinline.h.

References HV_s::hdrread, and hdrVec.

Referenced by doGetRecord(), main(), readPackageHeaders(), rpmMergeHeaders(), rpmReadHeaders(), rpmReadSignature(), and writeRPM().

Header headerRegenSigHeader | ( | const Header | h | ) |

Regenerate signature header.

Parameters:

  | h | header

Returns:
  regenerated signature header

Definition at line 69 of file package.c.

References HEADER_SIGBASE, HEADER_TAGBASE, headerAddEntry(), headerFreeData(), headerInitIterator(), headerIsEntry(), headerNextIterator(), rpmNewSignature(), RPMSIGTAG_GPG, RPMSIGTAG_LEMD5_1, RPMSIGTAG_LEMD5_2, RPMSIGTAG_MD5, RPMSIGTAG_PGP, RPMSIGTAG_PGP5, RPMSIGTAG_SIZE, RPMTAG_SIGGPG, RPMTAG_SIGLEMD5_1, RPMTAG_SIGLEMD5_2, RPMTAG_SIGMD5, RPMTAG_SIGPGP, RPMTAG_SIGPGP5, RPMTAG_SIGSIZE, sprintfTag::tag, and sprintfTag::type.

Referenced by psmStage().

static Header headerReload | ( | Header | h,
|  | int | tag
| ) | `[inline, static]`

Convert header to on-disk representation, and then reload.

This is used to insure that all header data is in one chunk.

Parameters:

  | h | header (with pointers)
  | tag | region tag

Returns:
  on-disk header (with offsets)

Definition at line 149 of file hdrinline.h.

References h2hv(), and HV_s::hdrreload.

Referenced by rhnUnload(), and writeRPM().

static int headerRemoveEntry | ( | Header | h,
|  | int_32 | tag
| ) | `[inline, static]`

Delete tag in header.

Removes all entries of type tag from the header, returns 1 if none were found.

Parameters:

  | h | header
  | tag | tag

Returns:
  0 on success, 1 on failure (INCONSISTENT)

Definition at line 417 of file hdrinline.h.

References h2hv(), and HV_s::hdrremove.

Referenced by addFileToTag(), compressFilelist(), expandFilelist(), loadFi(), readPackageHeaders(), rpmdbAdd(), rpmMergeHeaders(), and rpmReSign().

static unsigned int headerSizeof | ( | Header | h,
|  | enum hMagic | magicp
| ) | `[inline, static]`

Return size of on-disk header representation in bytes.

Parameters:

  | h | header
  | magicp | include size of 8 bytes for (magic, 0)?

Returns:
  size of on-disk header

Definition at line 120 of file hdrinline.h.

References h2hv(), and HV_s::hdrsizeof.

Referenced by db1cput(), dbiUpdateRecord(), hdrUnload(), rhnUnload(), rpmdbAdd(), rpmReadSignature(), and rpmWriteSignature().

static void headerSort | ( | Header | h | ) | `[inline, static]`

Sort tags in header.

Parameters:

  | h | header

Definition at line 89 of file hdrinline.h.

References h2hv(), and HV_s::hdrsort.

Referenced by findEntry().

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.

Parameters:

  | h | header
  | fmt | format to use
  | tbltags | array of tag name/value pairs
  | extensions | chained table of formatting extensions.

Return values:

  | errmsg | error message (if any)

Returns:
  formatted output string (malloc'ed)

Definition at line 435 of file hdrinline.h.

References h2hv(), and HV_s::hdrsprintf.

Referenced by hdrSprintf(), packageBinaries(), psmStage(), queryHeader(), rpmHeaderGetEntry(), and rpmShowProgress().

static Header headerUnlink | ( | Header | h | ) | `[inline, static]`

Dereference a header instance.

Parameters:

  | h | header

Returns:
  new header reference

Definition at line 74 of file hdrinline.h.

References h2hv(), and HV_s::hdrunlink.

static void * headerUnload | ( | Header | h | ) | `[inline, static]`

Convert header to on-disk representation.

Parameters:

  | h | header (with pointers)

Returns:
  on-disk header blob (i.e. with offsets)

Definition at line 135 of file hdrinline.h.

References h2hv(), and HV_s::hdrunload.

Referenced by dbiUpdateRecord(), hdrUnload(), and rhnUnload().

static void headerUnsort | ( | Header | h | ) | `[inline, static]`

Restore tags in header to original ordering.

Parameters:

  | h | header

Definition at line 103 of file hdrinline.h.

References h2hv(), and HV_s::hdrunsort.

Referenced by doHeaderUnload().

static int headerUsageCount | ( | Header | h | ) | `[inline, static]`

Return header reference count.

Parameters:

  | h | header

Returns:
  no. of references

Definition at line 164 of file header_internal.h.

References headerToken::nrefs.

static int headerWrite | ( | FD_t | fd,
|  | Header | h,
|  | enum hMagic | magicp
| ) | `[inline, static]`

Write (with unload) header to file handle.

Parameters:

  | fd | file handle
  | h | header
  | magicp | prefix write with 8 bytes of (magic, 0)?

Returns:
  0 on success, 1 on error

Definition at line 214 of file hdrinline.h.

References h2hv(), and HV_s::hdrwrite.

Referenced by db1cput(), main(), psmStage(), rpmWriteSignature(), and writeRPM().

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.

Parameters:

  | 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

Returns:
  no. bytes of data in region, -1 on error

Definition at line 403 of file header.c.

References entryInfo::count, dataLength(), HEADER_I18NTABLE, HEADER_IMAGE, indexEntry::info, entryInfo::offset, REGION_TAG_COUNT, RPM_I18NSTRING_TYPE, RPM_INT32_TYPE, RPM_MAX_TYPE, RPM_MIN_TYPE, entryInfo::tag, entryInfo::type, and typeSizes.

Referenced by copyEntry().

## Variable Documentation

struct HV_s* hdrVec

| Header methods for rpm headers. Definition at line 78 of file header.c. Referenced by headerCopyLoad(), headerCopyTags(), headerFreeIterator(), headerInitIterator(), headerLoad(), headerNew(), headerNextIterator(), and headerRead().

unsigned char header_magic[8]`[static]`

Initial value:

     {
            0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00
    }

Definition at line 38 of file header.c.

const struct headerSprintfExtension_s headerDefaultFormats[]

| Supported default header tag output formats. Definition at line 3064 of file header.c.

size_t headerMaxbytes = (32*1024*1024)`[static]`

| Maximum no. of bytes permitted in a header. Definition at line 46 of file header.c.

int typeSizes[]`[static]`

Initial value:

      {
            0,
            1,
            1,
            2,
            4,
            -1,
            -1,
            1,
            -1,
            -1
    }

Alignment needs (and sizeof scalars types) for internal rpm data types.

Definition at line 64 of file header.c.

Referenced by dataLength(), doHeaderUnload(), and regionSwab().