#include "system.h"
#include <rpmio_internal.h>
#include <header_internal.h>
#include <rpmmacro.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... | |
struct | headerSprintfArgs_s |
Defines | |
#define | __HEADER_PROTOTYPES__ |
#define | PARSER_BEGIN 0 |
#define | PARSER_IN_ARRAY 1 |
#define | PARSER_IN_EXPR 2 |
#define | hdrchkTags(_ntags) ((_ntags) & 0xffff0000) |
Sanity check on no. | |
#define | hdrchkType(_type) ((_type) < RPM_MIN_TYPE || (_type) > RPM_MAX_TYPE) |
Sanity check on type values. | |
#define | hdrchkData(_nbytes) ((_nbytes) & 0xff000000) |
Sanity check on data size and/or offset and/or count. | |
#define | hdrchkAlign(_type, _off) ((_off) & (typeAlign[_type]-1)) |
Sanity check on alignment for data type. | |
#define | hdrchkRange(_dl, _off) ((_off) < 0 || (_off) > (_dl)) |
Sanity check on range of data offset. | |
#define | isSEP(_c) ((_c) == ':' || (_c) == '|') |
Typedefs | |
typedef headerSprintfArgs_s * | headerSprintfArgs |
Functions | |
static void * | headerGetStats (Header h, int opx) |
Return header stats accumulator structure. | |
static Header | headerLink (Header h) |
Reference a header instance. | |
static Header | headerUnlink (Header h) |
Dereference a header instance. | |
static Header | headerFree (Header h) |
Dereference a header instance. | |
static Header | headerNew (void) |
Create new (empty) header instance. | |
static int | indexCmp (const void *avp, const void *bvp) |
static void | headerSort (Header h) |
Sort tags in header. | |
static int | offsetCmp (const void *avp, const void *bvp) |
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 int | dataLength (rpmTagType type, rpmTagData *p, rpmTagCount count, int onDisk, rpmTagData *pend) |
Return length of entry data. | |
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, size_t *lenp) |
static void * | headerUnload (Header h) |
Convert header to on-disk representation. | |
static indexEntry | findEntry (Header h, int_32 tag, rpmTagType type) |
Find matching (tag,type) entry in header. | |
static int | headerRemoveEntry (Header h, int_32 tag) |
Delete tag in header. | |
static Header | headerLoad (void *uh) |
Convert header to in-memory representation. | |
static const char * | headerGetOrigin (Header h) |
Return header origin (e.g path or URL). | |
static int | headerSetOrigin (Header h, const char *origin) |
Store header origin (e.g path or URL). | |
const char * | headerGetBaseURL (Header h) |
int | headerSetBaseURL (Header h, const char *baseurl) |
stat * | headerGetStatbuf (Header h) |
int | headerSetStatbuf (Header h, struct stat *st) |
const char * | headerGetDigest (Header h) |
int | headerSetDigest (Header h, const char *digest) |
static uint32_t | headerGetInstance (Header h) |
static uint32_t | headerSetInstance (Header h, uint32_t instance) |
uint32_t | headerGetStartOff (Header h) |
uint32_t | headerSetStartOff (Header h, uint32_t startoff) |
uint32_t | headerGetEndOff (Header h) |
uint32_t | headerSetEndOff (Header h, uint32_t endoff) |
static Header | headerReload (Header h, int tag) |
Convert header to on-disk representation, and then reload. | |
static Header | headerCopyLoad (const void *uh) |
Make a copy and convert header to in-memory representation. | |
static Header | headerRead (void *_fd, enum hMagic magicp) |
Read (and load) header from file handle. | |
static int | headerWrite (void *_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 int | copyEntry (const indexEntry entry, rpmTagType *type, rpmTagData *p, rpmTagCount *c, int minMem) |
Retrieve data from header entry. | |
static int | headerMatchLocale (const char *td, const char *l, const char *le) |
Does locale match entry in header i18n table? | |
static char * | headerFindI18NString (Header h, indexEntry entry) |
Return i18n string from header that matches locale. | |
static int | intGetEntry (Header h, int_32 tag, rpmTagType *type, rpmTagData *p, rpmTagCount *c, int minMem) |
Retrieve tag data from 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, void *p, hCNT_t c) |
Retrieve tag value using header internal array. | |
int | headerGetRawEntry (Header h, int_32 tag, rpmTagType *type, void *p, rpmTagCount *c) |
Retrieve tag value with type match. | |
static void | copyData (rpmTagType type, rpmTagData *dest, rpmTagData *src, rpmTagCount cnt, size_t len) |
static void * | grabData (rpmTagType type, rpmTagData *p, rpmTagCount c, int *lenp) |
Return (malloc'ed) copy of entry data. | |
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 char | escapedChar (const char ch) |
static HE_t | rpmheMark (HE_t he) |
Mark a tag container with headerGetEntry() freeData. | |
static HE_t | rpmheClean (HE_t he) |
Clean a tag container, free'ing attached malloc's. | |
static sprintfToken | freeFormat (sprintfToken format, int num) |
Destroy headerSprintf format array. | |
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 Header | headerCopy (Header h) |
Duplicate a header. | |
static headerSprintfArgs | hsaInit (headerSprintfArgs hsa) |
Initialize an hsa iteration. | |
static sprintfToken | hsaNext (headerSprintfArgs hsa) |
Return next hsa iteration item. | |
static headerSprintfArgs | hsaFini (headerSprintfArgs hsa) |
Finish an hsa iteration. | |
static char * | hsaReserve (headerSprintfArgs hsa, size_t need) |
Reserve sufficient buffer space for next output value. | |
static const char * | myTagName (headerTagTableEntry tbl, int val, int *typep) |
Return tag name from value. | |
static int | myTagType (headerTagTableEntry tbl, int val) |
static int | myTagValue (headerTagTableEntry tbl, const char *name) |
Return tag value from name. | |
static int | findTag (headerSprintfArgs hsa, sprintfToken token, const char *name) |
Search extensions and tags for a name. | |
char * | intFormat (HE_t he, const char **av, const char *fmt) |
Convert tag data representation. | |
static char * | octFormat (HE_t he, const char **av) |
Return octal formatted data. | |
static char * | hexFormat (HE_t he, const char **av) |
Return hex formatted data. | |
static char * | decFormat (HE_t he, const char **av) |
Return decimal formatted data. | |
static char * | realDateFormat (HE_t he, const char **av, const char *strftimeFormat) |
Return strftime formatted data. | |
static char * | dateFormat (HE_t he, const char **av) |
Return date formatted data. | |
static char * | dayFormat (HE_t he, const char **av) |
Return day formatted data. | |
static char * | shescapeFormat (HE_t he, const char **av) |
Return shell escape formatted data. | |
static int | parseExpression (headerSprintfArgs hsa, sprintfToken token, char *str, char **endPtr) |
Parse a headerSprintf expression. | |
static int | parseFormat (headerSprintfArgs hsa, char *str, sprintfToken *formatPtr, int *numTokensPtr, char **endPtr, int state) |
Parse a headerSprintf term. | |
static int | getExtension (headerSprintfArgs hsa, headerTagTagFunction fn, HE_t he, HE_t ec) |
Call a header extension only once, saving results. | |
static char * | formatValue (headerSprintfArgs hsa, sprintfTag tag, int element) |
Format a single item's value. | |
static char * | singleSprintf (headerSprintfArgs hsa, sprintfToken token, int element) |
Format a single headerSprintf item. | |
static HE_t | rpmecNew (const headerSprintfExtension exts, int *necp) |
Create an extension cache. | |
static HE_t | rpmecFree (const headerSprintfExtension exts, HE_t ec) |
Destroy an extension cache. | |
static char * | headerSprintf (Header h, const char *fmt, const struct headerTagTableEntry_s *tags, const struct headerSprintfExtension_s *exts, 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. | |
Variables | |
int | _hdr_debug = 0 |
int | _tagcache = 1 |
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. | |
HV_t | hdrVec = &hdrVec1 |
Header methods for rpm headers. | |
const struct headerSprintfExtension_s | headerDefaultFormats [] |
Supported default header tag output formats. | |
const struct headerTagTableEntry_s * | rpmTagTable |
Automatically generated table of tag name/value pairs. | |
static struct HV_s | hdrVec1 |
Definition in file header.c.
|
|
|
Sanity check on alignment for data type.
|
|
Sanity check on data size and/or offset and/or count. This check imposes a limit of 16Mb, more than enough. |
|
Sanity check on range of data offset.
|
|
Sanity check on no. of tags. This check imposes a limit of 65K tags, more than enough. |
|
Sanity check on type values.
|
|
Referenced by parseFormat(). |
|
|
|
Definition at line 35 of file header.c. Referenced by parseFormat(). |
|
Definition at line 36 of file header.c. Referenced by parseExpression(), and parseFormat(). |
|
|
|
Definition at line 1924 of file header.c. References RPM_I18NSTRING_TYPE, and RPM_STRING_ARRAY_TYPE. Referenced by grabData(). |
|
Return length of entry data.
Definition at line 389 of file header.c. References RPM_I18NSTRING_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, typeSizes, and rpmDataType_u::ui8p. Referenced by grabData(), and regionSwab(). |
|
Return date formatted data.
Definition at line 2953 of file header.c. References _, and realDateFormat(). |
|
Return day formatted data.
Definition at line 2965 of file header.c. References _, and realDateFormat(). |
|
Return decimal formatted data.
Definition at line 2908 of file header.c. References intFormat(). |
|
Definition at line 2318 of file header.c. References _hdr_debug. Referenced by parseFormat(). |
|
Find matching (tag,type) entry in header.
Definition at line 905 of file header.c. References headerToken_s::flags, HEADERFLAG_SORTED, headerSort(), indexCmp(), indexEntry_s::info, RPM_NULL_TYPE, entryInfo_s::tag, and entryInfo_s::type. Referenced by addMacro(), delMacro(), expandMacro(), headerFindI18NString(), headerGetRawEntry(), htGetEntry(), htHasEntry(), and intGetEntry(). |
|
Search extensions and tags for a name.
Definition at line 2736 of file header.c. References alloca(), argvCount(), sprintfTag_s::av, sprintfTag_s::ext, sprintfTag_s::extNum, headerSprintfArgs_s::exts, sprintfTag_s::fmtfuncs, HEADER_EXT_FORMAT, HEADER_EXT_LAST, HEADER_EXT_MORE, HEADER_EXT_TAG, myTagValue(), headerSprintfExtension_s::name, stpcpy(), sprintfTag_s::tagno, headerSprintfArgs_s::tags, headerSprintfExtension_s::type, sprintfToken_s::type, headerSprintfExtension_s::u, sprintfToken_s::u, xcalloc(), and xstrcasecmp(). Referenced by parseExpression(), and parseFormat(). |
|
|
Destroy headerSprintf format array.
Definition at line 2380 of file header.c. References _free(), _tagcache, argvFree(), sprintfToken_s::array, sprintfTag_s::av, sprintfToken_s::cond, sprintfTag_s::fmtfuncs, sprintfTag_s::he, sprintfTag_s::params, rpmheClean(), sprintfToken_s::tag, and sprintfToken_s::u. Referenced by parseExpression(), and parseFormat(). |
|
Call a header extension only once, saving results.
Definition at line 3488 of file header.c. References _HE_s::avail, _HE_s::freeData, headerSprintfArgs_s::h, and rpmheClean(). Referenced by formatValue(), and singleSprintf(). |
|
Return (malloc'ed) copy of entry data.
Definition at line 1959 of file header.c. References copyData(), dataLength(), rpmDataType_u::ptr, and xmalloc(). |
|
Return i18n string from header that matches locale.
Definition at line 1720 of file header.c. References _, indexEntry_s::data, findEntry(), getenv(), HEADER_I18NTABLE, headerMatchLocale(), lang, and RPM_STRING_ARRAY_TYPE. Referenced by intGetEntry(). |
|
|
|
|
|
|
|
Definition at line 1248 of file header.c. References headerToken_s::instance. |
|
|
|
|
|
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. *
Definition at line 1647 of file header.c. References alloca(). Referenced by headerFindI18NString(). |
|
|
|
|
|
|
|
Definition at line 1255 of file header.c. References headerToken_s::instance. |
|
|
|
|
|
Return hex formatted data.
Definition at line 2896 of file header.c. References intFormat(). |
|
Finish an hsa iteration.
Definition at line 2637 of file header.c. References headerFreeIterator(), headerSprintfArgs_s::hi, and headerSprintfArgs_s::i. |
|
Initialize an hsa iteration.
Definition at line 2573 of file header.c. References headerSprintfArgs_s::format, headerSprintfArgs_s::h, headerInitIterator(), headerSprintfArgs_s::hi, headerSprintfArgs_s::i, sprintfTag_s::tagno, sprintfToken_s::type, and sprintfToken_s::u. |
|
Return next hsa iteration item.
Definition at line 2599 of file header.c. References _HE_s::avail, _HE_s::c, headerSprintfArgs_s::format, sprintfTag_s::he, headerNextIterator(), headerSprintfArgs_s::hi, headerSprintfArgs_s::i, headerSprintfArgs_s::numTokens, _HE_s::p, rpmDataType_u::ptr, rpmheClean(), rpmheMark(), _HE_s::t, _HE_s::tag, sprintfTag_s::tagno, sprintfToken_s::type, and sprintfToken_s::u. |
|
Reserve sufficient buffer space for next output value.
Definition at line 2656 of file header.c. References headerSprintfArgs_s::alloced, headerSprintfArgs_s::val, headerSprintfArgs_s::vallen, and xrealloc(). Referenced by formatValue(), and singleSprintf(). |
|
Definition at line 258 of file header.c. References indexEntry_s::info, and entryInfo_s::tag. Referenced by findEntry(). |
|
Convert tag data representation.
Definition at line 2809 of file header.c. References _, alloca(), rpmDataType_u::argv, _HE_s::c, rpmDataType_u::i32p, rpmDataType_u::i64p, rpmDataType_u::i8p, _HE_s::ix, _HE_s::p, RPM_ASN1_TYPE, RPM_BIN_TYPE, RPM_CHAR_TYPE, RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_INT64_TYPE, RPM_INT8_TYPE, RPM_OPENPGP_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, snprintf(), rpmDataType_u::str, _HE_s::t, rpmDataType_u::ui16p, and xstrdup(). Referenced by decFormat(), formatValue(), hexFormat(), octFormat(), and rpnFormat(). |
|
Retrieve tag data from header.
Definition at line 1775 of file header.c. References copyEntry(), findEntry(), headerFindI18NString(), indexEntry_s::info, RPM_I18NSTRING_TYPE, RPM_NULL_TYPE, RPM_STRING_TYPE, and entryInfo_s::type. |
|
Return tag name from value.
Definition at line 2677 of file header.c. References headerTagTableEntry_s::name, name, headerTagTableEntry_s::type, headerTagTableEntry_s::val, and xtolower(). Referenced by singleSprintf(). |
|
Definition at line 2703 of file header.c. References headerTagTableEntry_s::name, headerTagTableEntry_s::type, and headerTagTableEntry_s::val. Referenced by formatValue(). |
|
Return tag value from name.
Definition at line 2719 of file header.c. References headerTagTableEntry_s::name, headerTagTableEntry_s::val, and xstrcasecmp(). Referenced by findTag(). |
|
Return octal formatted data.
Definition at line 2884 of file header.c. References intFormat(). |
|
Definition at line 283 of file header.c. References indexEntry_s::data, indexEntry_s::info, entryInfo_s::offset, and entryInfo_s::tag. |
|
Parse a headerSprintf expression.
Definition at line 3377 of file header.c. References _, _hdr_debug, headerSprintfArgs_s::errmsg, findTag(), freeFormat(), parseFormat(), PARSER_IN_EXPR, sprintfToken_s::type, and sprintfToken_s::u. Referenced by parseFormat(). |
|
Parse a headerSprintf term.
Definition at line 3068 of file header.c. References _, _hdr_debug, argvAdd(), headerSprintfArgs_s::errmsg, escapedChar(), findTag(), freeFormat(), isSEP, next, parseExpression(), PARSER_IN_ARRAY, PARSER_IN_EXPR, sprintfToken_s::type, sprintfToken_s::u, xcalloc(), and xisdigit(). Referenced by parseExpression(). |
|
Return strftime formatted data.
Definition at line 2921 of file header.c. References _, _HE_s::p, rpmDataType_u::ptr, RPM_INT64_TYPE, _HE_s::t, rpmDataType_u::ui64p, and xstrdup(). Referenced by dateFormat(), and dayFormat(). |
|
Destroy an extension cache.
Definition at line 3956 of file header.c. References _free(), HEADER_EXT_LAST, HEADER_EXT_MORE, rpmheClean(), headerSprintfExtension_s::type, and headerSprintfExtension_s::u. |
|
Create an extension cache.
Definition at line 3930 of file header.c. References HEADER_EXT_LAST, HEADER_EXT_MORE, headerSprintfExtension_s::type, headerSprintfExtension_s::u, and xcalloc(). |
|
Clean a tag container, free'ing attached malloc's.
Definition at line 2362 of file header.c. References _free(), _HE_s::freeData, _HE_s::p, and rpmDataType_u::ptr. Referenced by formatValue(), freeFormat(), getExtension(), hsaNext(), rpmecFree(), and singleSprintf(). |
|
Mark a tag container with headerGetEntry() freeData.
Definition at line 2340 of file header.c. References _HE_s::freeData, RPM_BIN_TYPE, RPM_I18NSTRING_TYPE, RPM_STRING_ARRAY_TYPE, and _HE_s::t. Referenced by formatValue(), hsaNext(), and singleSprintf(). |
|
Return shell escape formatted data.
Definition at line 2977 of file header.c. References _, rpmDataType_u::i32p, rpmDataType_u::i64p, _HE_s::p, rpmDataType_u::ptr, RPM_INT32_TYPE, RPM_INT64_TYPE, RPM_STRING_TYPE, snprintf(), rpmDataType_u::str, _HE_s::t, xmalloc(), xrealloc(), and xstrdup(). |
|
Format a single headerSprintf item.
Definition at line 3709 of file header.c. References _, _tagcache, sprintfTag_s::arrayCount, sprintfTag_s::av, _HE_s::avail, _HE_s::c, headerSprintfArgs_s::ec, headerSprintfArgs_s::errmsg, sprintfTag_s::ext, sprintfTag_s::extNum, formatValue(), _HE_s::freeData, getExtension(), headerSprintfArgs_s::h, sprintfTag_s::he, headerGetEntry(), headerIsEntry(), hsaReserve(), sprintfTag_s::justOne, myTagName(), _HE_s::p, RPM_ARRAY_RETURN_TYPE, RPM_ASN1_TYPE, RPM_BIN_TYPE, RPM_MASK_RETURN_TYPE, RPM_OPENPGP_TYPE, RPM_SCALAR_RETURN_TYPE, RPM_STRING_TYPE, rpmheClean(), rpmheMark(), snprintf(), stpcpy(), _HE_s::t, _HE_s::tag, sprintfTag_s::tagno, headerSprintfArgs_s::tags, sprintfToken_s::type, headerSprintfExtension_s::u, sprintfToken_s::u, headerSprintfArgs_s::val, and headerSprintfArgs_s::vallen. |
|
Definition at line 22 of file header.c. Referenced by escapedChar(), formatValue(), parseExpression(), and parseFormat(). |
|
Definition at line 25 of file header.c. Referenced by formatValue(), freeFormat(), and singleSprintf(). |
|
|
|
Automatically generated table of tag name/value pairs.
|