rpm 5.2.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Functions | Variables
header.c File Reference
HEADER.
`#include "system.h"`
`#include <rpmiotypes.h>`
`#include <rpmio.h>`
`#include <header_internal.h>`
`#include "debug.h"`
Include dependency graph for header.c:

Go to the source code of this file.

## Data Structures
struct | headerIterator_s
| Header tag iterator data structure. More...

## Macros
#define | _RPMTAG_INTERNAL

## Functions
void * | headerGetStats (Header h, int opx)
| Return header stats accumulator structure. More...
static void | headerScrub (void *_h)
static Header | headerGetPool (rpmioPool pool)
Header | headerNew (void)
| Create new (empty) header instance. More...
static int | indexCmp (const void *avp, const void *bvp)
static void | headerSort (Header h)
| Sort tags in header. More...
static int | offsetCmp (const void *avp, const void *bvp)
static void | headerUnsort (Header h)
| Restore tags in header to original ordering. More...
size_t | headerSizeof (Header h)
| Return size of on-disk header representation in bytes. More...
static size_t | dataLength (rpmTagType type, rpmTagData *p, rpmTagCount count, int onDisk, rpmTagData *pend)
| Return length of entry data. More...
static unsigned char * | tagSwab (unsigned char *t, const HE_t he, size_t nb)
| Swab rpmuint64_t/rpmuint32_t/rpmuint16_t arrays within header region. More...
static int | rpmheRealloc (HE_t he)
| Always realloc HE_t memory. More...
static rpmuint32_t | regionSwab (indexEntry entry, rpmuint32_t il, rpmuint32_t dl, entryInfo pe, unsigned char *dataStart, const unsigned char *dataEnd, rpmint32_t regionid)
| Swab rpmuint64_t/rpmuint32_t/rpmuint16_t arrays within header region. More...
void * | headerUnload (Header h, size_t *lenp)
| headerUnload. More...
static indexEntry | findEntry (Header h, rpmTag tag, rpmTagType type)
| Find matching (tag,type) entry in header. More...
static int | headerRemoveEntry (Header h, rpmTag tag)
| Delete tag in header. More...
Header | headerLoad (void *uh)
| Convert header to in-memory representation. More...
int | headerGetMagic (Header h, unsigned char **magicp, size_t *nmagicp)
| Return header magic. More...
int | headerSetMagic (Header h, unsigned char *magic, size_t nmagic)
| Store header magic. More...
const char * | headerGetOrigin (Header h)
| Return header origin (e.g path or URL). More...
int | headerSetOrigin (Header h, const char *origin)
| Store header origin (e.g path or URL). More...
const char * | headerGetBaseURL (Header h)
| Return header base URL (e.g path or URL). More...
int | headerSetBaseURL (Header h, const char *baseurl)
| Store header base URL (e.g path or URL). More...
struct stat * | headerGetStatbuf (Header h)
| Return header stat(2) buffer (of origin *.rpm file). More...
int | headerSetStatbuf (Header h, struct stat *st)
| Copy into header stat(2) buffer (of origin *.rpm file). More...
const char * | headerGetDigest (Header h)
| Return digest of origin *.rpm file. More...
int | headerSetDigest (Header h, const char *digest)
| Store digest of origin *.rpm file. More...
void * | headerGetRpmdb (Header h)
| Return rpmdb pointer. More...
void * | headerSetRpmdb (Header h, void *rpmdb)
| Store rpmdb pointer. More...
rpmuint32_t | headerGetInstance (Header h)
| Return header instance (if from rpmdb). More...
rpmuint32_t | headerSetInstance (Header h, rpmuint32_t instance)
| Store header instance (e.g path or URL). More...
rpmuint32_t | headerGetStartOff (Header h)
| Return header starting byte offset. More...
rpmuint32_t | headerSetStartOff (Header h, rpmuint32_t startoff)
| Store header starting byte offset. More...
rpmuint32_t | headerGetEndOff (Header h)
| Return header ending byte offset. More...
rpmuint32_t | headerSetEndOff (Header h, rpmuint32_t endoff)
| Store header ending byte offset. More...
Header | headerReload (Header h, int tag)
| Convert header to on-disk representation, and then reload. More...
static Header | headerMap (const void *uh, int map)
Header | headerCopyLoad (const void *uh)
| Make a copy and convert header to in-memory representation. More...
int | headerIsEntry (Header h, rpmTag tag)
| Check if tag is in header. More...
static int | copyEntry (const indexEntry entry, HE_t he, int minMem)
| Retrieve data from header entry. More...
static int | headerMatchLocale (const char *td, const char *l, const char *le)
| Does locale match entry in header i18n table? More...
static char * | headerFindI18NString (Header h, indexEntry entry)
| Return i18n string from header that matches locale. More...
static int | intGetEntry (Header h, HE_t he, int flags)
| Retrieve tag data from header. More...
static int | copyData (char *t, const HE_t he, size_t nb)
| Copy (swab'd) data into store. More...
static void * | grabData (HE_t he, size_t *lenp)
| Return (malloc'ed) copy of (swab'd) entry data. More...
static int | headerAddEntry (Header h, HE_t he)
| Add tag to header. More...
static int | headerAppendEntry (Header h, HE_t he)
| Append element to tag array in header. More...
static int | headerAddOrAppendEntry (Header h, HE_t he)
| Add or append element to tag array in header. More...
int | headerAddI18NString (Header h, rpmTag tag, const char *string, const char *lang)
| Add locale specific tag to header. More...
static int | headerModifyEntry (Header h, HE_t he)
| Modify tag in header. More...
HeaderIterator | headerFini (HeaderIterator hi)
| Destroy header tag container iterator. More...
HeaderIterator | headerInit (Header h)
| Create header tag iterator. More...
int | headerNext (HeaderIterator hi, HE_t he, unsigned int flags)
| Return next tag from header. More...
Header | headerCopy (Header h)
| Duplicate a header. More...
void | headerCopyTags (Header headerFrom, Header headerTo, rpmTag *tagstocopy)
| Duplicate tag values from one header into another. More...
int | headerGet (Header h, HE_t he, unsigned int flags)
| Retrieve extension or tag value from a header. More...
int | headerPut (Header h, HE_t he, unsigned int flags)
| Add or append tag container to header. More...
int | headerDel (Header h, HE_t he, unsigned int flags)
| Remove tag container from header. More...
int | headerMod (Header h, HE_t he, unsigned int flags)
| Modify tag container in header. More...

## Variables
int | _hdr_debug = 0
static unsigned char | header_magic [8]
static int | typeSizes [16]
| Size of header data types. More...
static size_t | headerMaxbytes = (1024*1024*1024)
| Maximum no. More...
int | _hdr_stats = 0
| Global header stats enabler. More...
static struct rpmop_s | hdr_loadops
rpmop | _hdr_loadops = &hdr_loadops
static struct rpmop_s | hdr_getops
rpmop | _hdr_getops = &hdr_getops
rpmioPool | _headerPool

## Macro Definition Documentation

#define _RPMTAG_INTERNAL

Definition at line 15 of file header.c.

## Function Documentation

static int copyData | ( | char * | t,
|  | const HE_t | he,
|  | size_t | nb
| ) |  |
| static

Copy (swab'd) data into store.

Parameters

  t | data store
  he | tag container
  nb | no. bytes in store

Returns
  0 on success

Definition at line 1664 of file header.c.

References rpmDataType_u::argv, _HE_s::c, _HE_s::p, RPM_I18NSTRING_TYPE, RPM_STRING_ARRAY_TYPE, _HE_s::t, and tagSwab().

Referenced by grabData(), and headerAppendEntry().

static size_t dataLength | ( | rpmTagType | type,
|  | rpmTagData * | p,
|  | rpmTagCount | count,
|  | int | onDisk,
|  | rpmTagData * | pend
| ) |  |
| static

Return length of entry data.

Parameters

  type | entry data type
  *p | tag container data
  count | entry item count
  onDisk | data is concatenated strings (with NUL's))?
  *pend | pointer to end of tag container data (or NULL)

Returns
  no. bytes in data, 0 on failure

Definition at line 314 of file header.c.

References RPM_I18NSTRING_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, typeSizes, and rpmDataType_u::ui8p.

Referenced by grabData(), headerAppendEntry(), and regionSwab().

static indexEntry findEntry | ( | Header | h,
|  | rpmTag | tag,
|  | rpmTagType | type
| ) |  |
| static

Find matching (tag,type) entry in header.

Parameters

  h | header
  tag | entry tag
  type | entry type

Returns
  header entry

< Are header entries sorted?

Definition at line 854 of file header.c.

References headerToken_s::flags, HEADERFLAG_SORTED, headerSort(), headerToken_s::index, indexCmp(), headerToken_s::indexUsed, indexEntry_s::info, entryInfo_s::tag, and entryInfo_s::type.

Referenced by headerAddI18NString(), headerAddOrAppendEntry(), headerAppendEntry(), headerFindI18NString(), headerIsEntry(), headerModifyEntry(), headerRemoveEntry(), and intGetEntry().

static void* grabData | ( | HE_t | he,
|  | size_t * | lenp
| ) |  |
| static

Return (malloc'ed) copy of (swab'd) entry data.

Parameters

  he | tag container

Return values

  *lenp | no. bytes in returned data

Returns
  (malloc'ed) copy of entry data, NULL on error

Definition at line 1699 of file header.c.

References _free(), _HE_s::c, copyData(), dataLength(), _HE_s::p, _HE_s::t, and xmalloc().

Referenced by headerAddEntry(), and headerModifyEntry().

static char* headerFindI18NString | ( | Header | h,
|  | indexEntry | entry
| ) |  |
| static

Return i18n string from header that matches locale.

Parameters

  h | header
  entry | i18n string data

Returns
  matching i18n string (or 1st string if no match)

Definition at line 1566 of file header.c.

References indexEntry_s::data, findEntry(), getenv(), HEADER_I18NTABLE, headerMatchLocale(), lang, and RPM_STRING_ARRAY_TYPE.

Referenced by intGetEntry().

static Header headerGetPool | ( | rpmioPool | pool | ) |
| static

Definition at line 151 of file header.c.

References _hdr_debug, _headerPool, headerScrub(), rpmioGetPool(), and rpmioNewPool().

Referenced by headerLoad(), and headerNew().

static Header headerMap | ( | const void * | uh,
|  | int | map
| ) |  |
| static

< Is 1st header region mmap'd?

< Is 1st header region rdonly?

< Is 1st header region allocated?

Definition at line 1308 of file header.c.

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

Referenced by headerCopyLoad().

static int headerMatchLocale | ( | const char * | td,
|  | const char * | l,
|  | const char * | le
| ) |  |
| static

Does locale match entry in header i18n table?

    * The range [l,le) contains the next locale to match:
    *    ll[_CC][.EEEEE][@dddd]
    * where
    *    ll ISO language code (in lowercase).
    *    CC (optional) ISO coutnry code (in uppercase).
    *    EEEEE      (optional) encoding (not really standardized).
    *    dddd       (optional) dialect.
    *

Parameters

  td | header i18n table data, NUL terminated
  l | start of locale to match
  le | end of locale to match

Returns
  1 on match, 0 on no match

Definition at line 1493 of file header.c.

References alloca().

Referenced by headerFindI18NString().

static void headerScrub | ( | void * | _h | ) |
| static

< Is 1st header region allocated?

< Is 1st header region mmap'd?

< Is 1st header region mmap'd?

Definition at line 98 of file header.c.

References _free(), _hdr_stats, headerToken_s::baseurl, headerToken_s::blob, headerToken_s::bloblen, indexEntry_s::data, headerToken_s::digest, ENTRY_IN_REGION, ENTRY_IS_REGION, errno, headerToken_s::flags, HEADERFLAG_ALLOCATED, HEADERFLAG_MAPPED, headerGetStats(), headerToken_s::index, headerToken_s::indexUsed, indexEntry_s::length, headerToken_s::origin, and rpmswAdd().

Referenced by headerGetPool().

static int indexCmp | ( | const void * | avp,
|  | const void * | bvp
| ) |  |
| static

Definition at line 197 of file header.c.

References indexEntry_s::info, and entryInfo_s::tag.

Referenced by findEntry(), and headerSort().

static int intGetEntry | ( | Header | h,
|  | HE_t | he,
|  | int | flags
| ) |  |
| static

Retrieve tag data from header.

Parameters

  h | header
  he | tag container
  flags | headerGet flags

Returns
  1 on success, 0 on not found

Definition at line 1618 of file header.c.

References _HE_s::c, copyEntry(), findEntry(), headerFindI18NString(), HEADERGET_NOI18NSTRING, indexEntry_s::info, _HE_s::p, rpmDataType_u::ptr, RPM_I18NSTRING_TYPE, RPM_STRING_TYPE, rpmDataType_u::str, _HE_s::t, _HE_s::tag, and entryInfo_s::type.

Referenced by headerGet().

static int offsetCmp | ( | const void * | avp,
|  | const void * | bvp
| ) |  |
| static

Definition at line 222 of file header.c.

References indexEntry_s::data, indexEntry_s::info, entryInfo_s::offset, and entryInfo_s::tag.

Referenced by headerUnsort().

static int rpmheRealloc | ( | HE_t | he | ) |
| static

Always realloc HE_t memory.

Parameters

  he | tag container

Returns
  1 on success, 0 on failure

Definition at line 416 of file header.c.

References _free(), _HE_s::c, _HE_s::freeData, _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, rpmDataType_u::str, _HE_s::t, tagSwab(), rpmDataType_u::ui16p, rpmDataType_u::ui32p, rpmDataType_u::ui64p, rpmDataType_u::ui8p, and xmalloc().

Referenced by headerGet(), and headerNext().

## Variable Documentation

int _hdr_debug = 0

Definition at line 21 of file header.c.

Referenced by headerGet(), and headerGetPool().

rpmop _hdr_getops = &hdr_getops

Definition at line 83 of file header.c.

Referenced by rpmtsPrintStats().

rpmop _hdr_loadops = &hdr_loadops

Definition at line 79 of file header.c.

Referenced by rpmtsPrintStats().

int _hdr_stats = 0

Global header stats enabler.

Definition at line 73 of file header.c.

Referenced by headerGetStats(), headerScrub(), and rpmcliInit().

rpmioPool _headerPool

Definition at line 149 of file header.c.

Referenced by headerGetPool(), and rpmcliFini().

struct rpmop_s hdr_getops
| static

Definition at line 81 of file header.c.

struct rpmop_s hdr_loadops
| static

Definition at line 77 of file header.c.