HEADER.


Files

file  formats.c
file  package.c
file  rpmlib.h
 In Memoriam: Steve Taylor <staylor@redhat.com> was here, now he's not.
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

Data Structures

struct  headerToken_s
 The Header data structure. More...

Typedefs

typedef const char * errmsg_t
typedef int_32hTAG_t
typedef headerToken_sHeader
typedef headerIterator_sHeaderIterator
typedef headerTagTableEntry_sheaderTagTableEntry
 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_sheaderSprintfExtension
 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(*) HDRread (FD_t fd, enum hMagic magicp)
 Read (and load) header from file handle.
typedef int(*) HDRwrite (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 *(*) HDRsprintf (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_sHV_t
 Header method vectors.
typedef entryInfo_sentryInfo
 Description of tag data.
typedef indexEntry_sindexEntry
 A single tag from a Header.
typedef sprintfTag_ssprintfTag
typedef rpmec_srpmec
 Extension cache.
typedef sprintfToken_ssprintfToken

Enumerations

enum  headerSprintfExtensionType { 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

int headerNVR (Header h, const char **np, const char **vp, const char **rp)
 Return name, version, release strings from header.
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.
int rpmHeaderGetEntry (Header h, int_32 tag, int_32 *type, void **p, int_32 *c)
 Retrieve tag info from header.
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, unsigned char *dataStart, const unsigned char *dataEnd, int regionid)
 Swap int_32 and int_16 arrays within header region.
static void * doHeaderUnload (Header h, int *lengthPtr)
 
Parameters:
h header

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).
char * bin2hex (const char *data, size_t count)
 Convert binary blob to printable hex string.

Variables

HV_shdrVec
 Header methods for rpm headers.
static unsigned char header_magic [8]
static int typeAlign [16]
 Alignment needed for header data types.
static int typeSizes [16]
 Size of header data types.
static size_t headerMaxbytes = (32*1024*1024)
 Maximum no.
headerSprintfExtension_s headerDefaultFormats []
 Supported default header tag output formats.

Typedef Documentation

typedef struct entryInfo_s* entryInfo

Description of tag data.

Definition at line 25 of file header_internal.h.

typedef const char* errmsg_t

Definition at line 106 of file header.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 503 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 559 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 535 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 521 of file header.h.

typedef Header(*) HDRcopy(Header h)

Duplicate a header.

Parameters:
h header
Returns:
new header instance

Definition at line 384 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 402 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 615 of file header.h.

typedef Header(*) HDRfree(Header h)

Dereference a header instance.

Parameters:
h header
Returns:
NULL always

Definition at line 309 of file header.h.

typedef HeaderIterator(*) HDRfreeiter(HeaderIterator hi)

Destroy header tag iterator.

Parameters:
hi header tag iterator
Returns:
NULL always

Definition at line 624 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 445 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 463 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 482 of file header.h.

typedef HeaderIterator(*) HDRinititer(Header h)

Create header tag iterator.

Parameters:
h header
Returns:
header tag iterator

Definition at line 633 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 434 of file header.h.

typedef Header(*) HDRlink(Header h)

Reference a header instance.

Parameters:
h header
Returns:
referenced header instance

Definition at line 318 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 393 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 574 of file header.h.

typedef Header(*) HDRnew(void)

Create new (empty) header instance.

Returns:
header

Definition at line 300 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 646 of file header.h.

typedef Header(*) HDRread(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 412 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 375 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 587 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 355 of file header.h.

typedef void(*) HDRsort(Header h)

Sort tags in header.

Todo:
Eliminate from API.
Parameters:
h header

Definition at line 336 of file header.h.

typedef char*(*) HDRsprintf(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 602 of file header.h.

typedef Header(*) HDRunlink(Header h)

Dereference a header instance.

Parameters:
h header
Returns:
NULL always

Definition at line 327 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 364 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 345 of file header.h.

typedef int(*) HDRwrite(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 423 of file header.h.

typedef struct headerToken_s* Header

Definition at line 117 of file header.h.

typedef struct headerIterator_s* HeaderIterator

Definition at line 121 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 RPM_BIN_TYPE: no. bytes of data
Returns:
formatted string

Definition at line 155 of file header.h.

typedef struct headerTagTableEntry_s* headerTagTableEntry

Associate tag names with numeric values.

Definition at line 126 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 tag type
*data tag value
*count no. of data items
*freedata data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 171 of file header.h.

typedef int_32* hTAG_t

Definition at line 110 of file header.h.

typedef struct HV_s* HV_t

Header method vectors.

Definition at line 656 of file header.h.

typedef struct indexEntry_s* indexEntry

A single tag from a Header.

Definition at line 43 of file header_internal.h.

typedef struct rpmec_s* rpmec

Extension cache.

Definition at line 95 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_s* sprintfTag

Definition at line 75 of file header_internal.h.

typedef struct sprintfToken_s* sprintfToken

Definition at line 107 of file header_internal.h.


Enumeration Type Documentation

enum headerSprintfExtensionType

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

char* bin2hex ( const char *  data,
size_t  count 
)

Convert binary blob to printable hex string.

Parameters:
data binary data
size size of data in bytes

Definition at line 176 of file header_internal.c.

References headerTagTableEntry_s::val, and xmalloc().

Referenced by formatValue().

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 1400 of file header.c.

References entryInfo_s::count, ENTRY_IS_REGION, HEADER_IMAGE, indexEntry_s::info, REGION_TAG_COUNT, regionSwab(), RPM_BIN_TYPE, RPM_I18NSTRING_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, entryInfo_s::type, and xmalloc().

Referenced by headerGetRawEntry(), and intGetEntry().

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

Parameters:
h header

Return values:
*lengthPtr no. bytes in unloaded header blob
Returns:
unloaded header blob (NULL on error)

Definition at line 608 of file header.c.

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

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(), legacyRetrofit(), makeHDRSignature(), mungeFilelist(), packageBinaries(), packageSources(), parsePreamble(), parseScript(), parseSpec(), readIcon(), rhnLoad(), rhnUnload(), rpmAddSignature(), rpmcliImportPubkey(), rpmdbAdd(), rpmdbRemove(), rpmfcGenerateDepends(), rpmfiNew(), rpmMergeHeaders(), rpmpsmStage(), rpmReSign(), rpmxpProcess(), 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(), parseDescription(), and rpmxpProcess().

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(), addReqProv(), ftsCacheUpdate(), genCpioListAndHeader(), processMetadataFile(), processScriptFiles(), processSourceFiles(), providePackageNVR(), rpmcliImportPubkey(), and rpmxpProcess().

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(), 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 rpmdbNextIterator(), rpmpsmStage(), 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 headerInject(), 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
f file handle
flags 0 or HEADER_DUMP_INLINE
tags array of tag name/value pairs

Definition at line 35 of file header_internal.c.

References _, entryInfo_s::count, indexEntry_s::data, HEADER_DUMP_INLINE, headerToken_s::index, headerToken_s::indexUsed, indexEntry_s::info, headerTagTableEntry_s::name, entryInfo_s::offset, 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, entryInfo_s::tag, entryInfo_s::type, headerTagTableEntry_s::type, and headerTagTableEntry_s::val.

Referenced by main(), and spewHeader().

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 _rpmtsAddRollbackElement(), delTE(), freeItem(), freePackage(), freeSpec(), ftsStashLatest(), getRepackageHeaderFromTE(), hdr_dealloc(), hdrLoad(), hdrUnload(), headerInject(), IDTXfree(), IDTXglob(), main(), makeHDRSignature(), miFreeHeader(), readFile(), readRPM(), rhnLoad(), rhnUnload(), rpmcliImportPubkey(), rpmdb_subscript(), rpmdbFindByFile(), rpmdbRebuild(), rpmdsFree(), rpmfiFree(), rpmFreeSignature(), rpmgiFree(), rpmgiLoadReadHeader(), rpmgiNext(), rpmgiReadHeader(), rpmgiWalkReadHeader(), rpmGraph(), rpmInstall(), rpmInstallSourcePackage(), rpmMergeHeaders(), rpmpsmStage(), rpmReadHeader(), rpmReadHeaders(), rpmReadPackageFile(), rpmReadSignature(), rpmReSign(), rpmRollback(), rpmSingleHeaderFromFD(), rpmteSetHeader(), rpmts_HdrFromFdno(), rpmtsRun(), rpmtsSolve(), rpmxpProcess(), 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 704 of file header.h.

References RPM_BIN_TYPE, RPM_I18NSTRING_TYPE, and RPM_STRING_ARRAY_TYPE.

Referenced by addReqProv(), compressFilelist(), formatValue(), getSignid(), handleOneTrigger(), handlePreambleTag(), headerMergeLegacySigs(), headerRegenSigHeader(), initSourceHeader(), instprefixTag(), isMemberInEntry(), makeHDRSignature(), mireSkip(), providePackageNVR(), readFile(), relocateFileList(), rhnUnload(), rpmdbAdd(), rpmdbFindByFile(), rpmdbFindFpList(), rpmdbRemove(), rpmdsFree(), rpmfiBuildFNames(), rpmfiFree(), rpmfiNew(), rpmInstall(), rpmMergeHeaders(), rpmpsmStage(), rpmReadPackageFile(), rpmReSign(), rpmtsCleanDig(), rpmtsFindPubkey(), rpmtsSetSig(), rpmVerifySignatures(), runImmedTriggers(), runInstScript(), runScript(), 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 checkForDuplicates(), hdrKeyList(), headerCopyWithConvert(), headerMergeLegacySigs(), headerRegenSigHeader(), hsaFini(), initSourceHeader(), rpmMergeHeaders(), rpmpsmStage(), rpmReSign(), and rpmVerifySignatures().

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

Free data allocated when retrieved from header.

Parameters:
h header
data pointer to tag value(s)
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 tag value data type (or NULL)
*p pointer to tag value(s) (or NULL)
*c 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 formatValue(), ftsStashLatest(), getRepackageHeaderFromTE(), getSignid(), headerCheckPayloadFormat(), headerNEVRA(), headerNVR(), hGetNEVRA(), IDTXglob(), IDTXload(), legacyRetrofit(), main(), makeHDRSignature(), readFile(), rhnLoad(), rhnUnload(), rpmdsNew(), rpmfiNew(), rpmHeaderGetEntry(), rpmInstall(), rpmMergeHeaders(), rpmpsmStage(), rpmReadPackageFile(), rpmReadSignature(), rpmReSign(), rpmteNew(), rpmtsFindPubkey(), rpmtsSolve(), rpmVerifySignatures(), rpmVersionCompare(), singleSprintf(), and writeRPM().

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 tag value data type (or NULL)
*p pointer to tag value(s) (or NULL)
*c 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(), addReqProv(), addTE(), compressFilelist(), fssizesTag(), ftsCacheUpdate(), handlePreambleTag(), hGetColor(), i18nTag(), instprefixTag(), isMemberInEntry(), mireSkip(), processPackageFiles(), providePackageNVR(), rpmdbAdd(), rpmdbFindByFile(), rpmdbFindFpList(), rpmdbRemove(), rpmdsNew(), rpmdsNVRMatchesDep(), rpmdsThis(), rpmfiBuildFNames(), rpmfiNew(), rpmtsAddInstallElement(), stashSt(), timeCheck(), triggercondsTag(), triggertypeTag(), 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 13 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(), hsaInit(), initSourceHeader(), rpmMergeHeaders(), rpmpsmStage(), rpmReSign(), and rpmVerifySignatures().

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(), addTE(), checkForRequired(), checkSpec(), compressFilelist(), expandFilelist(), fillOutMainPackage(), headerGetRawEntry(), headerInject(), headerMergeLegacySigs(), headerRegenSigHeader(), IDTXglob(), legacyRetrofit(), makeHDRSignature(), mungeFilelist(), parseDescription(), parseScript(), parseSpec(), readFile(), relocateFileList(), rhnLoad(), rhnUnload(), rpmdbAdd(), rpmdbNextIterator(), rpmdbRebuild(), rpmInstall(), rpmInstallSourcePackage(), rpmpsmStage(), rpmReadPackageFile(), rpmtsAddInstallElement(), rpmVerifySignatures(), showVerifyPackage(), singleSprintf(), and spewHeader().

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 _rpmtsAddRollbackElement(), ftsStashLatest(), getRepackageHeaderFromTE(), hdr_Wrap(), hdrUnload(), IDTXglob(), IDTXload(), relocateFileList(), rhnUnload(), rpmdbFindByFile(), rpmdbRemove(), rpmdsDup(), rpmdsNew(), rpmfiNew(), rpmgiLoadReadHeader(), rpmgiNext(), rpmgiWalkReadHeader(), rpmInstallSourcePackage(), rpmpsmStage(), rpmReadHeader(), rpmReadPackageFile(), rpmReadSignature(), rpmReSign(), rpmteHeader(), rpmteSetHeader(), rpmtsSolve(), 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 hdrLoad(), rhnLoad(), rhnUnload(), rpmdbNextIterator(), rpmReadHeader(), and rpmReadSignature().

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 98 of file package.c.

References hdrchkData, hdrchkType, HEADER_SIGBASE, HEADER_TAGBASE, headerAddEntry(), headerFreeData(), headerFreeIterator(), headerInitIterator(), headerIsEntry(), headerNextIterator(), 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, RPMSIGTAG_DSA, RPMSIGTAG_GPG, RPMSIGTAG_LEMD5_1, RPMSIGTAG_LEMD5_2, RPMSIGTAG_MD5, RPMSIGTAG_PAYLOADSIZE, RPMSIGTAG_PGP, RPMSIGTAG_PGP5, RPMSIGTAG_RSA, RPMSIGTAG_SHA1, RPMSIGTAG_SIZE, RPMTAG_ARCHIVESIZE, RPMTAG_SIGGPG, RPMTAG_SIGLEMD5_1, RPMTAG_SIGLEMD5_2, RPMTAG_SIGMD5, RPMTAG_SIGPGP, RPMTAG_SIGPGP5, and RPMTAG_SIGSIZE.

Referenced by rpmReadPackageFile(), 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 rpmfiNew().

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 34 of file hdrNVR.c.

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

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(), rpmcliImportPubkey(), rpmNewSignature(), rpmpsmStage(), rpmReSign(), and rpmxpProcess().

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 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 494 of file hdrinline.h.

References HV_s::hdrnextiter, and hdrVec.

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

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 name pointer (or NULL)
*vp version pointer (or NULL)
*rp release pointer (or NULL)
Returns:
0 always

Definition at line 9 of file hdrNVR.c.

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

Referenced by doSetupMacro(), genSourceRpmName(), handleOneTrigger(), hGetNEVR(), hGetNEVRA(), i18nTag(), lookupPackage(), packageBinaries(), parsePreamble(), parseSpec(), printNewSpecfile(), processBinaryFiles(), providePackageNVR(), rpmdbRebuild(), rpmdbRemove(), rpmdsNVRMatchesDep(), rpmdsThis(), rpmInstall(), rpmtsCallback(), runScript(), 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 main(), makeHDRSignature(), readFile(), rpmgiNext(), rpmMergeHeaders(), rpmReadHeaders(), rpmSingleHeaderFromFD(), 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 178 of file package.c.

References HEADER_SIGBASE, HEADER_TAGBASE, headerAddEntry(), headerFreeData(), headerFreeIterator(), headerInitIterator(), headerIsEntry(), headerNextIterator(), rpmNewSignature(), RPMSIGTAG_GPG, RPMSIGTAG_LEMD5_1, RPMSIGTAG_LEMD5_2, RPMSIGTAG_MD5, RPMSIGTAG_PAYLOADSIZE, RPMSIGTAG_PGP, RPMSIGTAG_PGP5, RPMSIGTAG_SIZE, RPMTAG_ARCHIVESIZE, RPMTAG_DSAHEADER, RPMTAG_RSAHEADER, RPMTAG_SHA1HEADER, RPMTAG_SIGGPG, RPMTAG_SIGLEMD5_1, RPMTAG_SIGLEMD5_2, RPMTAG_SIGMD5, RPMTAG_SIGPGP, RPMTAG_SIGPGP5, and RPMTAG_SIGSIZE.

Referenced by rpmpsmStage().

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(), rpmpsmStage(), rpmReSign(), 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(), legacyRetrofit(), rpmdbAdd(), rpmfcGenerateDepends(), rpmfiNew(), 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 hdrUnload(), miFreeHeader(), readFile(), 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 doHeaderUnload(), findEntry(), and headerInject().

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(), main(), packageBinaries(), printNewSpecfile(), queryHeader(), rpmcliImportPubkey(), rpmHeaderGetEntry(), rpmpsmStage(), rpmShowProgress(), rpmtsSolve(), runScript(), and spewHeader().

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 hdrUnload(), miFreeHeader(), rhnUnload(), and rpmdbAdd().

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 186 of file header_internal.h.

References headerToken_s::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 makeHDRSignature(), rpmpsmStage(), rpmWriteSignature(), rpmxpProcess(), spewHeader(), and writeRPM().

static int regionSwab ( indexEntry  entry,
int  il,
int  dl,
entryInfo  pe,
unsigned char *  dataStart,
const unsigned char *  dataEnd,
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 start
dataEnd header data end
regionid region offset
Returns:
no. bytes of data in region, -1 on error

Definition at line 473 of file header.c.

References entryInfo_s::count, dataLength(), hdrchkAlign, hdrchkData, hdrchkType, HEADER_I18NTABLE, HEADER_IMAGE, indexEntry_s::info, entryInfo_s::offset, REGION_TAG_COUNT, RPM_I18NSTRING_TYPE, RPM_INT16_TYPE, RPM_INT32_TYPE, entryInfo_s::tag, entryInfo_s::type, and typeSizes.

Referenced by copyEntry(), and doHeaderUnload().

int rpmHeaderGetEntry ( Header  h,
int_32  tag,
int_32 type,
void **  p,
int_32 c 
)

Retrieve tag info from header.

This is a "dressed" entry to headerGetEntry to do: 1) DIRNAME/BASENAME/DIRINDICES -> FILENAMES tag conversions. 2) i18n lookaside (if enabled).

Parameters:
h header
tag tag
Return values:
type address of tag value data type
p address of pointer to tag value(s)
c address of number of values
Returns:
0 on success, 1 on bad magic, 2 on error

Definition at line 248 of file misc.c.

References headerGetEntry(), headerSprintf(), RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, rpmfiBuildFNames(), rpmHeaderFormats, RPMTAG_BASENAMES, RPMTAG_DESCRIPTION, RPMTAG_GROUP, RPMTAG_OLDFILENAMES, RPMTAG_SUMMARY, rpmTagTable, stpcpy(), and tagName().

Referenced by hdr_subscript().


Variable Documentation

struct HV_s* hdrVec

Header methods for rpm headers.

Definition at line 121 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 37 of file header.c.

struct headerSprintfExtension_s headerDefaultFormats[]

Supported default header tag output formats.

Definition at line 3693 of file header.c.

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

Maximum no.

of bytes permitted in a header.

Definition at line 91 of file header.c.

int typeAlign[16] [static]

Initial value:

  {
    1,  
    1,  
    1,  
    2,  
    4,  
    8,  
    1,  
    1,  
    1,  
    1,  
    0,
    0,
    0,
    0,
    0,
    0
}
Alignment needed for header data types.

Definition at line 45 of file header.c.

int typeSizes[16] [static]

Initial value:

  { 
    0,  
    1,  
    1,  
    2,  
    4,  
    -1, 
    -1, 
    1,  
    -1, 
    -1, 
    0,
    0,
    0,
    0,
    0,
    0
}
Size of header data types.

Definition at line 68 of file header.c.

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


Generated on Fri Oct 12 08:44:57 2007 for rpm by  doxygen 1.5.2