Data Structures | Files | Typedefs | Enumerations | Functions | Variables

# HEADER.

## Data Structures
struct | sprintfTag_s
struct | sprintfToken_s
struct | headerSprintfArgs_s
struct | headerToken_s
| The Header data structure. More...
union | rpmDataType_u
struct | _HE_s
## Files
file | formats.c
file | package.c
file | rpmlib.h

| In Memoriam: Steve Taylor <staylor@redhat.com> was here, now he's not.
file | header.c
file | header_internal.c
file | header_internal.h
file | rpmtag.h
## Typedefs
typedef struct sprintfTag_s * | sprintfTag
typedef struct sprintfToken_s * | sprintfToken
typedef struct headerSprintfArgs_s * | headerSprintfArgs
typedef struct entryInfo_s * | entryInfo
| Description of tag data.
typedef struct indexEntry_s * | indexEntry
| A single tag from a Header.
typedef const char * | errmsg_t
typedef struct headerToken_s * | Header
typedef enum rpmTagType_e | rpmTagType
typedef union rpmDataType_u | rpmTagData
typedef uint32_t | rpmTagCount
typedef struct _HE_s * | HE_t
typedef enum rpmSubTagType_e | rpmSubTagType
typedef enum rpmTagReturnType_e | rpmTagReturnType
| Identify how to return the header data type.
typedef struct headerIterator_s * | HeaderIterator
typedef struct headerTagIndices_s * | headerTagIndices
typedef struct headerSprintfExtension_s * | headerSprintfExtension
typedef enum rpmTag_e | rpmTag
typedef enum rpmSigTag_e | rpmSigTag
## Enumerations
enum | rpmTagType_e { RPM_UINT8_TYPE = 2, RPM_UINT16_TYPE = 3, RPM_UINT32_TYPE = 4, RPM_UINT64_TYPE = 5, RPM_STRING_TYPE = 6, RPM_BIN_TYPE = 7, RPM_STRING_ARRAY_TYPE = 8, RPM_I18NSTRING_TYPE = 9 }
| 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 }
enum | rpmTagReturnType_e { RPM_ANY_RETURN_TYPE = 0, RPM_SCALAR_RETURN_TYPE = 0x00010000, RPM_ARRAY_RETURN_TYPE = 0x00020000, RPM_MAPPING_RETURN_TYPE = 0x00040000, RPM_PROBE_RETURN_TYPE = 0x00100000, RPM_TREE_RETURN_TYPE = 0x00200000, RPM_OPENPGP_RETURN_TYPE = 0x00400000, RPM_X509_RETURN_TYPE = 0x00800000, RPM_ASN1_RETURN_TYPE = 0x01000000, RPM_OPAQUE_RETURN_TYPE = 0x10000000, RPM_MASK_RETURN_TYPE = 0xffff0000 }
| Identify how to return the header data type. More...
enum | rpmTag_e { RPMTAG_HEADERIMAGE = 61, RPMTAG_HEADERSIGNATURES = 62, RPMTAG_HEADERIMMUTABLE = 63, RPMTAG_HEADERREGIONS = 64, RPMTAG_HEADERI18NTABLE = 100, RPMTAG_SIG_BASE = 256, RPMTAG_SIGSIZE = RPMTAG_SIG_BASE+1, RPMTAG_SIGLEMD5_1 = RPMTAG_SIG_BASE+2, RPMTAG_SIGPGP = RPMTAG_SIG_BASE+3, RPMTAG_SIGLEMD5_2 = RPMTAG_SIG_BASE+4, RPMTAG_SIGMD5 = RPMTAG_SIG_BASE+5 }
| Tags identify data in package headers. More...
## Functions
static void | headerSort (Header h)
| Sort tags in header.
static void | headerUnsort (Header h)
| Restore tags in header to original ordering.
static uint32_t | regionSwab (indexEntry entry, uint32_t il, uint32_t dl, entryInfo pe, unsigned char *dataStart, const unsigned char *dataEnd, int32_t regionid)
| Swap uint32_t and uint16_t arrays within header region.
static int | headerRemoveEntry (Header h, rpmTag tag)
| Delete tag in header.
static int | copyEntry (const indexEntry entry, HE_t he, int minMem)
| Retrieve data from header entry.
static int | headerAddEntry (Header h, HE_t he)
| Add tag to header.
static int | headerAppendEntry (Header h, HE_t he)
| Append element to tag array in header.
static int | headerAddOrAppendEntry (Header h, HE_t he)
| Add or append element to tag array in header.
static int | headerModifyEntry (Header h, HE_t he)
| Modify tag in header.
static int | headerUsageCount (Header h)
| Return header reference count.
static rpmRC | rpmWriteHeader (FD_t fd, Header h, const char **msg)
| Write (with unload) header to file handle.
char * | headerSprintf (Header h, const char *fmt, headerTagTableEntry tags, headerSprintfExtension exts, errmsg_t *errmsg)
| Return formatted output string from header tags.
int | headerGet (Header h, HE_t he, unsigned int flags)
| Retrieve extension or tag value from a header.
int | headerPut (Header h, HE_t he, unsigned int flags)
| Add or append tag container to header.
int | headerDel (Header h, HE_t he, unsigned int flags)
| Remove tag container from header.
int | headerMod (Header h, HE_t he, unsigned int flags)
| Modify tag container in header.
HeaderIterator | headerFini (HeaderIterator hi)
| Destroy header tag container iterator.
HeaderIterator | headerInit (Header h)
| Create header tag iterator.
int | headerNext (HeaderIterator hi, HE_t he, unsigned int flags)
| Return next tag from header.
Header | headerLink (Header h)
| Reference a header instance.
Header | headerUnlink (Header h)
| Dereference a header instance.
Header | headerFree (Header h)
| Dereference a header instance.
Header | headerNew (void)
| Create new (empty) header instance.
size_t | headerSizeof (Header h)
| Return size of on-disk header representation in bytes.
void * | headerUnload (Header h, size_t *lenp)
Header | headerReload (Header h, int tag)
| Convert header to on-disk representation, and then reload.
Header | headerCopy (Header h)
| Duplicate a header.
Header | headerLoad (void *uh)
| Convert header to in-memory representation.
Header | headerCopyLoad (const void *uh)
| Make a copy and convert header to in-memory representation.
int | headerIsEntry (Header h, rpmTag tag)
| Check if tag is in header.
int | headerAddI18NString (Header h, rpmTag tag, const char *string, const char *lang)
| Add locale specific tag to header.
void | headerCopyTags (Header headerFrom, Header headerTo, rpmTag *tagstocopy)
| Duplicate tag values from one header into another.
int | headerGetMagic (Header h, unsigned char **magicp, size_t *nmagicp)
| Return header magic.
int | headerSetMagic (Header h, unsigned char *magic, size_t nmagic)
| Store header magic.
const char * | headerGetOrigin (Header h)
| Return header origin (e.g path or URL).
int | headerSetOrigin (Header h, const char *origin)
| Store header origin (e.g path or URL).
uint32_t | headerGetInstance (Header h)
| Return header instance (if from rpmdb).
uint32_t | headerSetInstance (Header h, uint32_t instance)
| Store header instance (e.g path or URL).
void * | headerGetStats (Header h, int opx)
| Return header stats accumulator structure.
int | headerNEVRA (Header h, const char **np, const char **ep, const char **vp, const char **rp, const char **ap)
| Return name, epoch, version, release, arch strings from header.
void | headerMergeLegacySigs (Header h, const Header sigh)
| Translate and merge legacy signature tags into header.
Header | headerRegenSigHeader (const Header h, int noArchiveSize)
| Regenerate signature header.
## Variables
static unsigned char | header_magic [8]
static int | typeSizes [16]
| Size of header data types.
static size_t | headerMaxbytes = (1024*1024*1024)
| Maximum no.
headerSprintfExtension | headerDefaultFormats
| Supported default header tag output formats.
headerSprintfExtension | headerCompoundFormats
| Supported default header extension/tag output formats.

## Typedef Documentation

typedef struct entryInfo_s* entryInfo

Description of tag data.

Definition at line 54 of file header_internal.h.

typedef const char* errmsg_t

Definition at line 17 of file rpmtag.h.

typedef struct _HE_s* HE_t

tag container.

Definition at line 58 of file rpmtag.h.

typedef struct headerToken_s* Header

Definition at line 21 of file rpmtag.h.

typedef struct headerIterator_s* HeaderIterator

Definition at line 125 of file rpmtag.h.

typedef struct headerSprintfArgs_s* headerSprintfArgs

Definition at line 1852 of file hdrfmt.c.

typedef struct headerSprintfExtension_s* headerSprintfExtension

Definition at line 133 of file rpmtag.h.

typedef struct headerTagIndices_s* headerTagIndices

Definition at line 129 of file rpmtag.h.

typedef struct indexEntry_s* indexEntry

A single tag from a Header.

Definition at line 72 of file header_internal.h.

typedef enum rpmSigTag_e rpmSigTag

Definition at line 446 of file rpmtag.h.

typedef enum rpmSubTagType_e rpmSubTagType

typedef enum rpmTag_e rpmTag

Definition at line 442 of file rpmtag.h.

typedef uint32_t rpmTagCount

tag data element count.

Definition at line 54 of file rpmtag.h.

typedef union rpmDataType_u rpmTagData

tag data.

Definition at line 50 of file rpmtag.h.

typedef enum rpmTagReturnType_e rpmTagReturnType

Identify how to return the header data type.

typedef enum rpmTagType_e rpmTagType

tag data type.

Definition at line 46 of file rpmtag.h.

typedef struct sprintfTag_s* sprintfTag

Definition at line 1791 of file hdrfmt.c.

typedef struct sprintfToken_s* sprintfToken

Definition at line 1814 of file hdrfmt.c.

## Enumeration Type Documentation

enum rpmSubTagType_e

Enumerator:

  RPM_REGION_TYPE |
  RPM_BIN_ARRAY_TYPE |
  RPM_XREF_TYPE |

Definition at line 84 of file rpmtag.h.

enum rpmTag_e

Tags identify data in package headers.

Note:
  tags should not have value 0!

Enumerator:

  RPMTAG_HEADERIMAGE | internal Current image.
  RPMTAG_HEADERSIGNATURES | internal Signatures.
  RPMTAG_HEADERIMMUTABLE | x Original image.
  RPMTAG_HEADERREGIONS | internal Regions.
  RPMTAG_HEADERI18NTABLE | s[] I18N string locales.
  RPMTAG_SIG_BASE |
  RPMTAG_SIGSIZE |
  RPMTAG_SIGLEMD5_1 |
  RPMTAG_SIGPGP |
  RPMTAG_SIGLEMD5_2 |
  RPMTAG_SIGMD5 |

Definition at line 152 of file rpmtag.h.

enum rpmTagReturnType_e

Identify how to return the header data type.

Enumerator:

  RPM_ANY_RETURN_TYPE |
  RPM_SCALAR_RETURN_TYPE |
  RPM_ARRAY_RETURN_TYPE |
  RPM_MAPPING_RETURN_TYPE |
  RPM_PROBE_RETURN_TYPE |
  RPM_TREE_RETURN_TYPE |
  RPM_OPENPGP_RETURN_TYPE |
  RPM_X509_RETURN_TYPE |
  RPM_ASN1_RETURN_TYPE |
  RPM_OPAQUE_RETURN_TYPE |
  RPM_MASK_RETURN_TYPE |

Definition at line 95 of file rpmtag.h.

enum rpmTagType_e

The basic types of data in tags from headers.

Enumerator:

  RPM_UINT8_TYPE |
  RPM_UINT16_TYPE |
  RPM_UINT32_TYPE |
  RPM_UINT64_TYPE |
  RPM_STRING_TYPE |
  RPM_BIN_TYPE |
  RPM_STRING_ARRAY_TYPE |
  RPM_I18NSTRING_TYPE |

Definition at line 26 of file rpmtag.h.

## Function Documentation

static int copyEntry | ( | const indexEntry | entry,
|  | HE_t | he,
|  | int | minMem
| ) |  | `[static]`

Retrieve data from header entry.

Todo:
  Permit retrieval of regions other than HEADER_IMUTABLE.

Parameters:

  entry | header entry

Return values:

  *he | tag container

Parameters:

  minMem | string pointers refer to header memory?

Returns:
  1 on success, otherwise error.

Definition at line 1199 of file header.c.

References rpmDataType_u::argv, _HE_s::c, entryInfo_s::count, indexEntry_s::data, ENTRY_IS_REGION, HEADER_IMAGE, indexEntry_s::info, indexEntry_s::length, entryInfo_s::offset, _HE_s::p, rpmDataType_u::ptr, indexEntry_s::rdlen, REGION_TAG_COUNT, regionSwab(), RPM_BIN_TYPE, RPM_I18NSTRING_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, rpmDataType_u::str, _HE_s::t, entryInfo_s::tag, entryInfo_s::type, rpmDataType_u::ui32p, and xmalloc().

Referenced by headerNext(), and intGetEntry().

static int headerAddEntry | ( | Header | h,
|  | HE_t | he
| ) |  | `[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
  he | tag container

Returns:
  1 on success, 0 on failure

< Are header entries sorted?

Definition at line 1545 of file header.c.

References _HE_s::c, entryInfo_s::count, indexEntry_s::data, headerToken_s::flags, grabData(), hdrchkData, hdrchkType, HEADERFLAG_SORTED, headerToken_s::index, INDEX_MALLOC_SIZE, headerToken_s::indexAlloced, headerToken_s::indexUsed, indexEntry_s::info, indexEntry_s::length, entryInfo_s::offset, _HE_s::p, rpmDataType_u::ptr, _HE_s::t, _HE_s::tag, entryInfo_s::tag, entryInfo_s::type, and xrealloc().

Referenced by headerAddI18NString(), headerAddOrAppendEntry(), headerCopy(), and headerPut().

int headerAddI18NString | ( | Header | h,
|  | rpmTag | 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 1654 of file header.c.

References _free(), alloca(), rpmDataType_u::argv, _HE_s::c, entryInfo_s::count, indexEntry_s::data, ENTRY_IN_REGION, findEntry(), HEADER_I18NTABLE, headerAddEntry(), indexEntry_s::info, lang, indexEntry_s::length, entryInfo_s::offset, _HE_s::p, rpmDataType_u::ptr, RPM_I18NSTRING_TYPE, RPM_STRING_ARRAY_TYPE, _HE_s::t, _HE_s::tag, xmalloc(), and xrealloc().

Referenced by handlePreambleTag(), parseDescription(), rpmcliImportPubkey(), and rpmtsImportPubkey().

static int headerAddOrAppendEntry | ( | Header | h,
|  | HE_t | he
| ) |  | `[static]`

Add or append element to tag array in header.

Parameters:

  h | header
  he | tag container

Returns:
  1 on success, 0 on failure

Definition at line 1646 of file header.c.

References findEntry(), headerAddEntry(), headerAppendEntry(), _HE_s::t, and _HE_s::tag.

Referenced by headerPut().

static int headerAppendEntry | ( | Header | h,
|  | HE_t | he
| ) |  | `[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.

Parameters:

  h | header
  he | tag container

Returns:
  1 on success, 0 on failure

Definition at line 1599 of file header.c.

References _HE_s::c, copyData(), entryInfo_s::count, indexEntry_s::data, dataLength(), ENTRY_IN_REGION, findEntry(), indexEntry_s::info, indexEntry_s::length, entryInfo_s::offset, _HE_s::p, rpmDataType_u::ptr, RPM_I18NSTRING_TYPE, RPM_STRING_TYPE, _HE_s::t, _HE_s::tag, xmalloc(), and xrealloc().

Referenced by headerAddOrAppendEntry().

Header headerCopy | ( | Header | h ) |

Duplicate a header.

Parameters:

  h | header

Returns:
  new header instance

Definition at line 1966 of file header.c.

References _free(), alloca(), HEADER_IMAGE, headerAddEntry(), headerFini(), headerInit(), headerNew(), headerNext(), headerReload(), _HE_s::p, and rpmDataType_u::ptr.

Referenced by hdrUnload(), and rpmdbRebuild().

Header headerCopyLoad | ( | 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

< Is 1st header region allocated?

Definition at line 1161 of file header.c.

References _free(), headerToken_s::flags, hdrchkData, hdrchkTags, HEADERFLAG_ALLOCATED, headerLoad(), headerMaxbytes, and xmalloc().

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

void headerCopyTags | ( | Header | headerFrom,
|  | Header | headerTo,
|  | rpmTag * | 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 1983 of file header.c.

References _free(), alloca(), headerGet(), headerIsEntry(), headerPut(), _HE_s::p, rpmDataType_u::ptr, and _HE_s::tag.

Referenced by packageBinaries(), and parsePreamble().

int headerDel | ( | Header | h,
|  | HE_t | he,
|  | unsigned int | flags
| ) |  |

Remove tag container from header.

Parameters:

  h | header
  he | tag container
  flags | (unused)

Returns:
  1 on success, 0 on failure

Definition at line 2084 of file header.c.

References headerRemoveEntry(), and _HE_s::tag.

Referenced by addFileToTag(), compressFilelist(), rpmdbAdd(), rpmfcGenerateDepends(), and rpmReSign().

HeaderIterator headerFini | ( | HeaderIterator | hi ) |

Destroy header tag container iterator.

Parameters:

  hi | header tag container iterator

Returns:
  NULL always

Definition at line 1910 of file header.c.

References _free(), headerIterator_s::h, and headerFree().

Referenced by checkForDuplicates(), hdrKeyList(), headerCopy(), headerMergeLegacySigs(), headerRegenSigHeader(), hsaFini(), initSourceHeader(), rpmpsmStage(), rpmReSign(), and rpmVerifySignatures().

Header headerFree | ( | Header | h ) |

Dereference a header instance.

Parameters:

  h | header

Returns:
  NULL always

< Is 1st header region allocated?

Definition at line 124 of file header.c.

References _free(), _hdr_stats, headerToken_s::blob, indexEntry_s::data, ENTRY_IN_REGION, ENTRY_IS_REGION, headerToken_s::flags, HEADERFLAG_ALLOCATED, headerGetStats(), headerUnlink(), headerToken_s::index, headerToken_s::indexUsed, indexEntry_s::length, headerToken_s::nrefs, headerToken_s::origin, and rpmswAdd().

Referenced by ckHeader(), delTE(), freePackage(), freeSpec(), hdr_dealloc(), hdrLoad(), hdrUnload(), headerFini(), headerReload(), headerSprintf(), IDTXfree(), IDTXglob(), makeHDRSignature(), miFreeHeader(), rdSignature(), readFile(), rpmcliImportPubkey(), rpmdb_subscript(), rpmdbFindByFile(), rpmdbRebuild(), rpmdbRemove(), rpmdsFree(), rpmfiFree(), rpmfiNew(), rpmgiFree(), rpmgiLoadReadHeader(), rpmgiNext(), rpmgiReadHeader(), rpmgiWalkReadHeader(), rpmInstallSourcePackage(), rpmpsmStage(), rpmReadHeader(), rpmReadHeaders(), rpmReadPackageFile(), rpmReSign(), rpmRollback(), rpmSingleHeaderFromFD(), rpmteSetHeader(), rpmts_HdrFromFdno(), rpmtsImportPubkey(), rpmtsRun(), rpmtsSolve(), rpmVerifySignatures(), showVerifyPackage(), and writeRPM().

int headerGet | ( | Header | h,
|  | HE_t | he,
|  | unsigned int | flags
| ) |  |

Retrieve extension or tag value from a header.

Parameters:

  h | header
  he | tag container
  flags | tag retrieval flags

Returns:
  1 on success, 0 on failure

Definition at line 2003 of file header.c.

References _HE_s::c, _HE_s::freeData, headerCompoundFormats, HEADERGET_NOEXTENSION, headerGetStats(), intGetEntry(), name, _HE_s::p, rpmDataType_u::ptr, rpmheRealloc(), rpmswEnter(), rpmswExit(), _HE_s::t, _HE_s::tag, tagName(), and xstrcasecmp().

Referenced by addFileToTag(), addReqProv(), addTE(), checkPackageSet(), compressFilelist(), ensureOlder(), findErases(), formatValue(), fssizesTag(), getSignid(), handleInstInstalledFiles(), handleOneTrigger(), handlePreambleTag(), handleRmvdInstalledFiles(), hCopyTag(), hdr_subscript(), headerCopyTags(), headerMacrosLoad(), headerMacrosUnload(), headerNEVRA(), hGetColor(), hLoadTID(), i18nTag(), IDTXglob(), IDTXload(), instprefixTag(), isMemberInEntry(), localeTag(), lookupPackage(), makeHDRSignature(), markReplacedFiles(), mireSkip(), packageBinaries(), parsePreamble(), parseSpec(), printNewSpecfile(), processBinaryFiles(), processPackageFiles(), providePackageNVR(), rdSignature(), readFile(), relocateFileList(), rpmcliInstall(), rpmdbAdd(), rpmdbExportInfo(), rpmdbFindByFile(), rpmdbFindFpList(), rpmdbRemove(), rpmdsNew(), rpmdsThis(), rpmfcGenerateScriptletDeps(), rpmfiBuildFNames(), rpmfiNew(), rpmHeadersIdentical(), rpmInstallSourcePackage(), rpmpsmStage(), rpmReadPackageFile(), rpmReSign(), rpmteChain(), rpmteNew(), rpmtsAddInstallElement(), rpmtsCallback(), rpmtsFindPubkey(), rpmtsSolve(), rpmVerifySignatures(), rpmVersionCompare(), runImmedTriggers(), runInstScript(), runScript(), singleSprintf(), stashSt(), timeCheck(), triggercondsTag(), triggertypeTag(), and writeRPM().

uint32_t headerGetInstance | ( | Header | h ) |

Return header instance (if from rpmdb).

Parameters:

  h | header

Returns:
  header instance

Definition at line 1115 of file header.c.

References headerToken_s::instance.

Referenced by dbinstanceTag(), rpmgiNext(), rpmpsmStage(), and verifyDependencies().

int headerGetMagic | ( | Header | h,
|  | unsigned char ** | magicp,
|  | size_t * | nmagicp
| ) |  |

Return header magic.

Parameters:

  h | header
  *magicp | magic array
  *nmagicp | no. bytes of magic

Returns:
  0 always

Definition at line 1079 of file header.c.

References header_magic, and headerToken_s::magic.

Referenced by headerCheck(), makeHDRSignature(), miFreeHeader(), rdSignature(), readFile(), rpmdbAdd(), rpmReadHeader(), rpmReadPackageFile(), and rpmWriteHeader().

const char* headerGetOrigin | ( | Header | h ) |

Return header origin (e.g path or URL).

Parameters:

  h | header

Returns:
  header origin

Definition at line 1101 of file header.c.

References headerToken_s::origin.

Referenced by hdrGetOrigin(), IDTXglob(), and populateInstallHeader().

void* headerGetStats | ( | Header | h,
|  | int | opx
| ) |  |

Return header stats accumulator structure.

Parameters:

  h | header
  opx | per-header accumulator index (aka rpmtsOpX)

Returns:
  per-header accumulator pointer

Definition at line 85 of file header.c.

References _hdr_stats, headerToken_s::h_getops, and headerToken_s::h_loadops.

Referenced by headerFree(), headerGet(), headerLoad(), headerNext(), and headerUnload().

HeaderIterator headerInit | ( | Header | h ) |

Create header tag iterator.

Parameters:

  h | header

Returns:
  header tag iterator

Definition at line 1919 of file header.c.

References headerIterator_s::h, headerLink(), headerSort(), headerIterator_s::next_index, and xmalloc().

Referenced by checkForDuplicates(), hdrKeyList(), headerCopy(), headerMergeLegacySigs(), headerRegenSigHeader(), hsaInit(), initSourceHeader(), rpmpsmStage(), rpmReSign(), and rpmVerifySignatures().

int headerIsEntry | ( | Header | h,
|  | rpmTag | tag
| ) |  |

Check if tag is in header.

Parameters:

  h | header
  tag | tag

Returns:
  1 on success, 0 on failure

Definition at line 1184 of file header.c.

References findEntry().

Referenced by addTE(), checkForRequired(), compressFilelist(), fillOutMainPackage(), fsmMapAttrs(), headerCopyTags(), headerMergeLegacySigs(), headerNEVRA(), headerRegenSigHeader(), IDTXglob(), initSourceHeader(), makeHDRSignature(), parseDescription(), parseScript(), parseSpec(), readFile(), relocateFileList(), rpmdbAdd(), rpmdbNextIterator(), rpmdbRebuild(), rpmfiNew(), rpmInstallSourcePackage(), rpmpsmStage(), rpmReadPackageFile(), rpmtsAddInstallElement(), rpmVerifySignatures(), showVerifyPackage(), singleSprintf(), unsatisfiedDepend(), and writeRPM().

Header headerLink | ( | Header | h ) |

Reference a header instance.

Parameters:

  h | header

Returns:
  referenced header instance

Definition at line 96 of file header.c.

References _hdr_debug, and headerToken_s::nrefs.

Referenced by hdr_Wrap(), hdrUnload(), headerInit(), headerLoad(), headerNew(), headerSprintf(), IDTXglob(), IDTXload(), rdSignature(), relocateFileList(), rpmdbFindByFile(), rpmdbRemove(), rpmdsDup(), rpmfiNew(), rpmgiLoadReadHeader(), rpmgiNext(), rpmgiWalkReadHeader(), rpmInstallSourcePackage(), rpmpsmStage(), rpmReadHeader(), rpmReadPackageFile(), rpmReSign(), rpmteHeader(), rpmteSetHeader(), rpmtsSolve(), showVerifyPackage(), and writeRPM().

Header headerLoad | ( | void * | uh ) |

Convert header to in-memory representation.

Parameters:

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

Returns:
  header

< Are header entries sorted?

< Header came from legacy source?

< Header came from legacy source?

< Are header entries sorted?

Definition at line 904 of file header.c.

References _free(), alloca(), headerToken_s::blob, entryInfo_s::count, indexEntry_s::data, headerToken_s::flags, hdrchkData, hdrchkTags, hdrchkType, HEADER_BASENAMES, HEADER_I18NTABLE, HEADER_IMAGE, header_magic, HEADER_OLDFILENAMES, HEADERFLAG_LEGACY, HEADERFLAG_SORTED, headerGetStats(), headerLink(), headerRemoveEntry(), headerSort(), headerToken_s::index, headerToken_s::indexAlloced, headerToken_s::indexUsed, indexEntry_s::info, indexEntry_s::length, headerToken_s::magic, headerToken_s::nrefs, entryInfo_s::offset, indexEntry_s::rdlen, REGION_TAG_COUNT, REGION_TAG_TYPE, regionSwab(), rpmswEnter(), rpmswExit(), save(), entryInfo_s::tag, entryInfo_s::type, and xcalloc().

Referenced by ckHeader(), hdrLoad(), headerCopyLoad(), headerReload(), rdSignature(), rpmdbNextIterator(), and rpmReadHeader().

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

Translate and merge legacy signature tags into header.

Todo:
  Remove headerSort() through headerInitIterator() modifies sig.

Parameters:

  h | header
  sigh | signature header

Definition at line 235 of file hdrNVR.c.

References _free(), alloca(), _HE_s::c, hdrchkData, hdrchkType, HEADER_SIGBASE, HEADER_TAGBASE, headerFini(), headerInit(), headerIsEntry(), headerNext(), headerPut(), _HE_s::p, rpmDataType_u::ptr, RPM_BIN_TYPE, RPM_I18NSTRING_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, RPM_UINT16_TYPE, RPM_UINT32_TYPE, RPM_UINT64_TYPE, RPM_UINT8_TYPE, RPMSIGTAG_DSA, RPMSIGTAG_MD5, RPMSIGTAG_PAYLOADSIZE, RPMSIGTAG_RSA, RPMSIGTAG_SHA1, RPMSIGTAG_SIZE, RPMTAG_SIGMD5, RPMTAG_SIGSIZE, _HE_s::t, and _HE_s::tag.

Referenced by rpmReadPackageFile(), and writeRPM().

int headerMod | ( | Header | h,
|  | HE_t | he,
|  | unsigned int | flags
| ) |  |

Modify tag container in header.

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

Parameters:

  h | header
  he | tag container
  flags | (unused)

Returns:
  1 on success, 0 on failure

Definition at line 2090 of file header.c.

References headerModifyEntry().

Referenced by relocateFileList().

static int headerModifyEntry | ( | Header | h,
|  | HE_t | he
| ) |  | `[static]`

Modify tag in header.

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

Parameters:

  h | header
  he | tag container

Returns:
  1 on success, 0 on failure

Definition at line 1809 of file header.c.

References _free(), _HE_s::c, entryInfo_s::count, indexEntry_s::data, ENTRY_IN_REGION, findEntry(), grabData(), headerToken_s::index, indexEntry_s::info, indexEntry_s::length, entryInfo_s::offset, _HE_s::p, rpmDataType_u::ptr, _HE_s::t, entryInfo_s::tag, _HE_s::tag, and entryInfo_s::type.

Referenced by headerMod().

int headerNEVRA | ( | Header | h,
|  | const char ** | np,
|  | const char ** | ep,
|  | const char ** | vp,
|  | const char ** | rp,
|  | const char ** | ap
| ) |  |

Return name, epoch, version, release, arch strings from header.

Parameters:

  h | header

Return values:

  *np | name pointer (or NULL)
  *ep | epoch pointer (or NULL)
  *vp | version pointer (or NULL)
  *rp | release pointer (or NULL)
  *ap | arch pointer (or NULL)

Returns:
  0 always

Definition at line 154 of file hdrNVR.c.

References _free(), alloca(), _HE_s::c, headerGet(), headerIsEntry(), _HE_s::p, rpmDataType_u::ptr, RPM_STRING_TYPE, rpmDataType_u::str, _HE_s::t, _HE_s::tag, and xstrdup().

Referenced by doSetupMacro(), genSourceRpmName(), hGetNVRA(), providePackageNVR(), rpmdbRebuild(), rpmdsThis(), and writeRPM().

Header headerNew | ( | void | ) |

Create new (empty) header instance.

Returns:
  header

< Are header entries sorted?

Definition at line 166 of file header.c.

References headerToken_s::blob, headerToken_s::flags, header_magic, HEADERFLAG_SORTED, headerLink(), headerToken_s::index, INDEX_MALLOC_SIZE, headerToken_s::indexAlloced, headerToken_s::indexUsed, headerToken_s::instance, headerToken_s::magic, headerToken_s::nrefs, headerToken_s::origin, and xcalloc().

Referenced by headerCopy(), headerRegenSigHeader(), newPackage(), newSpec(), rpmcliImportPubkey(), rpmpsmStage(), rpmReSign(), rpmtsImportPubkey(), and writeRPM().

int headerNext | ( | HeaderIterator | hi,
|  | HE_t | he,
|  | unsigned int | flags
| ) |  |

Return next tag from header.

Parameters:

  hi | header tag iterator
  he | tag container
  flags | (unused)

Returns:
  1 on success, 0 on failure

Definition at line 1930 of file header.c.

References copyEntry(), ENTRY_IS_REGION, headerIterator_s::h, headerGetStats(), headerToken_s::index, headerToken_s::indexUsed, indexEntry_s::info, headerIterator_s::next_index, rpmheRealloc(), rpmswEnter(), rpmswExit(), entryInfo_s::tag, and _HE_s::tag.

Referenced by checkForDuplicates(), hdrKeyList(), headerCopy(), headerMergeLegacySigs(), headerRegenSigHeader(), hsaNext(), initSourceHeader(), rpmpsmStage(), rpmReSign(), and rpmVerifySignatures().

int headerPut | ( | Header | h,
|  | HE_t | he,
|  | unsigned int | flags
| ) |  |

Add or append tag container to header.

Parameters:

  h | header
  he | tag container
  flags | (unused)

Returns:
  1 on success, 0 on failure

Definition at line 2065 of file header.c.

References _HE_s::append, headerAddEntry(), and headerAddOrAppendEntry().

Referenced by addChangelogEntry(), addFileToArrayTag(), addFileToTag(), addOrAppendListEntry(), addReqProv(), compressFilelist(), doIcon(), fillOutMainPackage(), genCpioListAndHeader(), handlePreambleTag(), hCopyTag(), headerCopyTags(), headerMergeLegacySigs(), headerRegenSigHeader(), hSaveBlinks(), hSaveFlinks(), initSourceHeader(), makeHDRSignature(), packageBinaries(), packageSources(), parsePreamble(), parseScript(), parseSpec(), populateInstallHeader(), postPopulateInstallHeader(), processMetadataFile(), processScriptFiles(), providePackageNVR(), relocateFileList(), rpmAddSignature(), rpmcliImportPubkey(), rpmdbAdd(), rpmdbRemove(), rpmfcGenerateDepends(), rpmlibMarkers(), rpmpsmStage(), rpmReSign(), rpmtsImportPubkey(), and writeRPM().

Header headerRegenSigHeader | ( | const Header | h,
|  | int | noArchiveSize
| ) |  |

Regenerate signature header.

Todo:
  Remove headerSort() through headerInitIterator() modifies h.

Parameters:

  h | header
  noArchiveSize | don't copy archive size tag (pre rpm-4.1)

Returns:
  regenerated signature header

Definition at line 302 of file hdrNVR.c.

References _free(), alloca(), HEADER_SIGBASE, HEADER_TAGBASE, headerFini(), headerInit(), headerIsEntry(), headerNew(), headerNext(), headerPut(), _HE_s::p, rpmDataType_u::ptr, RPMSIGTAG_MD5, RPMSIGTAG_PAYLOADSIZE, RPMSIGTAG_SIZE, RPMTAG_SIGMD5, RPMTAG_SIGSIZE, and _HE_s::tag.

Referenced by rpmpsmStage().

Header headerReload | ( | 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)

< Is 1st header region allocated?

< Is 1st header region allocated?

Definition at line 1127 of file header.c.

References _free(), ENTRY_IS_REGION, headerToken_s::flags, HEADER_IMMUTABLE, HEADER_SIGNATURES, HEADERFLAG_ALLOCATED, headerFree(), headerLoad(), headerSetInstance(), headerSetOrigin(), headerUnload(), headerToken_s::index, indexEntry_s::info, headerToken_s::instance, headerToken_s::origin, entryInfo_s::tag, and xstrdup().

Referenced by headerCopy(), rpmpsmStage(), rpmReSign(), and writeRPM().

static int headerRemoveEntry | ( | Header | h,
|  | rpmTag | tag
| ) |  | `[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 866 of file header.c.

References _free(), indexEntry_s::data, ENTRY_IN_REGION, findEntry(), headerToken_s::index, headerToken_s::indexUsed, indexEntry_s::info, indexEntry_s::length, and entryInfo_s::tag.

Referenced by headerDel(), and headerLoad().

uint32_t headerSetInstance | ( | Header | h,
|  | uint32_t | instance
| ) |  |

Store header instance (e.g path or URL).

Parameters:

  h | header
  origin | new header instance

Returns:
  0 always

Definition at line 1120 of file header.c.

References headerToken_s::instance.

Referenced by headerReload(), rpmdbAdd(), rpmdbNextIterator(), and rpmpsmStage().

int headerSetMagic | ( | Header | h,
|  | unsigned char * | magic,
|  | size_t | nmagic
| ) |  |

Store header magic.

Parameters:

  h | header
  magic | magic array
  nmagic | no. bytes of magic

Returns:
  0 always

Definition at line 1089 of file header.c.

References headerToken_s::magic.

int headerSetOrigin | ( | Header | h,
|  | const char * | origin
| ) |  |

Store header origin (e.g path or URL).

Parameters:

  h | header
  origin | new header origin

Returns:
  0 always

Definition at line 1106 of file header.c.

References _free(), headerToken_s::origin, and xstrdup().

Referenced by hdrSetOrigin(), headerReload(), rpmdbNextIterator(), and rpmReadHeader().

size_t headerSizeof | ( | Header | h ) |

Return size of on-disk header representation in bytes.

Parameters:

  h | header

Returns:
  size of on-disk header

< Header came from legacy source?

Definition at line 243 of file header.c.

References entryInfo_s::count, ENTRY_IS_REGION, headerToken_s::flags, header_magic, HEADERFLAG_LEGACY, headerSort(), headerToken_s::index, indexEntry_s::info, indexEntry_s::length, entryInfo_s::offset, entryInfo_s::type, and typeSizes.

Referenced by rdSignature(), readFile(), rpmdbAdd(), and wrSignature().

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

Sort tags in header.

Parameters:

  h | header

< Are header entries sorted?

< Are header entries sorted?

Definition at line 204 of file header.c.

References headerToken_s::flags, HEADERFLAG_SORTED, headerToken_s::index, indexCmp(), and headerToken_s::indexUsed.

Referenced by findEntry(), headerInit(), headerLoad(), headerSizeof(), and headerUnload().

char* headerSprintf | ( | Header | h,
|  | const char * | fmt,
|  | headerTagTableEntry | tags,
|  | headerSprintfExtension | exts,
|  | 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/type triples (NULL uses default)
  exts | formatting extensions chained table (NULL uses default)

Return values:

  errmsg | error message (if any)

Returns:
  formatted output string (malloc'ed)

Definition at line 3043 of file hdrfmt.c.

References _free(), _hdr_debug, alloca(), headerSprintfArgs_s::alloced, sprintfToken_s::array, headerSprintfArgs_s::ec, headerSprintfArgs_s::errmsg, headerSprintfArgs_s::exts, headerSprintfArgs_s::fmt, headerSprintfArgs_s::format, freeFormat(), headerSprintfArgs_s::h, headerCompoundFormats, headerFree(), headerLink(), hsaFini(), hsaInit(), hsaNext(), hsaReserve(), headerSprintfArgs_s::nec, headerSprintfArgs_s::numTokens, parseFormat(), PARSER_BEGIN, rpmecFree(), rpmecNew(), rpmTagTable, singleSprintf(), stpcpy(), sprintfToken_s::tag, sprintfTag_s::tagno, headerSprintfArgs_s::tags, sprintfTag_s::type, sprintfToken_s::type, sprintfToken_s::u, headerSprintfArgs_s::val, headerSprintfArgs_s::vallen, xrealloc(), and xstrdup().

Referenced by hdrSprintf(), packageBinaries(), parseForSimple(), printNewSpecfile(), queryHeader(), rpmcliImportPubkey(), rpmfiNew(), rpmpsmStage(), rpmShowProgress(), rpmtsImportPubkey(), and rpmtsSolve().

Header headerUnlink | ( | Header | h ) |

Dereference a header instance.

Parameters:

  h | header

Returns:
  NULL always

Definition at line 113 of file header.c.

References _hdr_debug, and headerToken_s::nrefs.

Referenced by headerFree().

void* headerUnload | ( | Header | h,
|  | size_t * | lenp
| ) |  |

Parameters:

  h | header

Return values:

  *lenp | no. bytes in unloaded header blob

Returns:
  unloaded header blob (NULL on error)

< Header came from legacy source?

< Header came from legacy source?

< Are header entries sorted?

Definition at line 529 of file header.c.

References _free(), entryInfo_s::count, indexEntry_s::data, ENTRY_IS_REGION, headerToken_s::flags, hdrchkData, hdrchkTags, HEADERFLAG_LEGACY, HEADERFLAG_SORTED, headerGetStats(), headerSort(), headerUnsort(), headerToken_s::index, headerToken_s::indexUsed, indexEntry_s::info, indexEntry_s::length, entryInfo_s::offset, indexEntry_s::rdlen, regionSwab(), RPM_UINT16_TYPE, RPM_UINT32_TYPE, RPM_UINT64_TYPE, rpmswEnter(), rpmswExit(), entryInfo_s::tag, entryInfo_s::type, typeSizes, and xmalloc().

Referenced by hdrUnload(), headerReload(), miFreeHeader(), rpmdbAdd(), and rpmWriteHeader().

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

Restore tags in header to original ordering.

Parameters:

  h | header

Definition at line 237 of file header.c.

References headerToken_s::index, headerToken_s::indexUsed, and offsetCmp().

Referenced by headerUnload().

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

Return header reference count.

Parameters:

  h | header

Returns:
  no. of references

Definition at line 129 of file header_internal.h.

References headerToken_s::nrefs.

static uint32_t regionSwab | ( | indexEntry | entry,
|  | uint32_t | il,
|  | uint32_t | dl,
|  | entryInfo | pe,
|  | unsigned char * | dataStart,
|  | const unsigned char * | dataEnd,
|  | int32_t | regionid
| ) |  | `[static]`

Swap uint32_t and uint16_t 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 start
  dataEnd | header data end
  regionid | region offset

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

Definition at line 386 of file header.c.

References entryInfo_s::count, indexEntry_s::data, dataLength(), hdrchkAlign, hdrchkData, hdrchkType, HEADER_I18NTABLE, HEADER_IMAGE, indexEntry_s::info, indexEntry_s::length, entryInfo_s::offset, rpmDataType_u::ptr, indexEntry_s::rdlen, REGION_TAG_COUNT, RPM_I18NSTRING_TYPE, RPM_UINT16_TYPE, RPM_UINT32_TYPE, RPM_UINT64_TYPE, entryInfo_s::tag, entryInfo_s::type, typeSizes, and rpmDataType_u::ui8p.

Referenced by copyEntry(), headerLoad(), and headerUnload().

static rpmRC rpmWriteHeader | ( | FD_t | fd,
|  | Header | h,
|  | const char ** | msg
| ) |  | `[static]`

Write (with unload) header to file handle.

Parameters:

  fd | file handle
  h | header

Returns:
  RPMRC_OK on success

Definition at line 68 of file pkgio.c.

References _, _free(), _pkgio_debug, Ferror(), Fstrerror(), Fwrite(), headerGetMagic(), headerUnload(), RPMRC_FAIL, RPMRC_OK, and xstrdup().

Referenced by wrHeader(), and wrSignature().

## Variable Documentation

unsigned char header_magic[8]`[static]`

Initial value:

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

Definition at line 34 of file header.c.

Referenced by headerGetMagic(), headerLoad(), headerNew(), and headerSizeof().

headerSprintfExtension headerCompoundFormats

Supported default header extension/tag output formats.

Definition at line 1714 of file hdrfmt.c.

Referenced by headerGet(), headerSprintf(), queryHeader(), and rpmDisplayQueryTags().

headerSprintfExtension headerDefaultFormats

Supported default header tag output formats.

Definition at line 275 of file hdrfmt.c.

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

Maximum no.

of bytes permitted in a header.

Definition at line 66 of file header.c.

Referenced by headerCopyLoad().

int typeSizes[16]`[static]`

Initial value:

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

Size of header data types.

Definition at line 43 of file header.c.

Referenced by dataLength(), headerSizeof(), headerUnload(), and regionSwab().