rpm
4.5
|
#include "system.h"
#include <rpmio_internal.h>
#include <header_internal.h>
#include <rpmmacro.h>
#include "debug.h"
Go to the source code of this file.
Data Structures | |
struct | headerIterator_s |
Header tag iterator data structure. More... | |
struct | headerSprintfArgs_s |
Macros | |
#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. More... | |
#define | hdrchkType(_type) ((_type) < RPM_MIN_TYPE || (_type) > RPM_MAX_TYPE) |
Sanity check on type values. More... | |
#define | hdrchkData(_nbytes) ((_nbytes) & 0xff000000) |
Sanity check on data size and/or offset and/or count. More... | |
#define | hdrchkAlign(_type, _off) ((_off) & (typeAlign[_type]-1)) |
Sanity check on alignment for data type. More... | |
#define | hdrchkRange(_dl, _off) ((_off) < 0 || (_off) > (_dl)) |
Sanity check on range of data offset. More... | |
#define | isSEP(_c) ((_c) == ':' || (_c) == '|') |
Typedefs | |
typedef struct headerSprintfArgs_s * | headerSprintfArgs |
Functions | |
static void * | headerGetStats (Header h, int opx) |
Return header stats accumulator structure. More... | |
static Header | headerLink (Header h) |
Reference a header instance. More... | |
static Header | headerUnlink (Header h) |
Dereference a header instance. More... | |
static Header | headerFree (Header h) |
Dereference a header instance. More... | |
static 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... | |
static unsigned int | headerSizeof (Header h, enum hMagic magicp) |
Return size of on-disk header representation in bytes. More... | |
static int | dataLength (rpmTagType type, rpmTagData *p, rpmTagCount count, int onDisk, rpmTagData *pend) |
Return length of entry data. More... | |
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. More... | |
static void * | doHeaderUnload (Header h, size_t *lenp) |
static void * | headerUnload (Header h) |
Convert header to on-disk representation. More... | |
static indexEntry | findEntry (Header h, int_32 tag, rpmTagType type) |
Find matching (tag,type) entry in header. More... | |
static int | headerRemoveEntry (Header h, int_32 tag) |
Delete tag in header. More... | |
static Header | headerLoad (void *uh) |
Convert header to in-memory representation. More... | |
static const char * | headerGetOrigin (Header h) |
Return header origin (e.g path or URL). More... | |
static 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... | |
static uint32_t | headerGetInstance (Header h) |
static uint32_t | headerSetInstance (Header h, uint32_t instance) |
uint32_t | headerGetStartOff (Header h) |
Return header starting byte offset. More... | |
uint32_t | headerSetStartOff (Header h, uint32_t startoff) |
Store header starting byte offset. More... | |
uint32_t | headerGetEndOff (Header h) |
Return header ending byte offset. More... | |
uint32_t | headerSetEndOff (Header h, uint32_t endoff) |
Store header ending byte offset. More... | |
static Header | headerReload (Header h, int tag) |
Convert header to on-disk representation, and then reload. More... | |
static Header | headerCopyLoad (const void *uh) |
Make a copy and convert header to in-memory representation. More... | |
static Header | headerRead (void *_fd, enum hMagic magicp) |
Read (and load) header from file handle. More... | |
static int | headerWrite (void *_fd, Header h, enum hMagic magicp) |
Write (with unload) header to file handle. More... | |
static int | headerIsEntry (Header h, int_32 tag) |
Check if tag is in header. More... | |
static int | copyEntry (const indexEntry entry, rpmTagType *type, rpmTagData *p, rpmTagCount *c, 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, int_32 tag, rpmTagType *type, rpmTagData *p, rpmTagCount *c, int minMem) |
Retrieve tag data from header. More... | |
static void * | headerFreeTag (Header h, const void *data, rpmTagType type) |
Free data allocated when retrieved from header. More... | |
static int | headerGetEntry (Header h, int_32 tag, hTYP_t type, void *p, hCNT_t c) |
Retrieve tag value. More... | |
static int | headerGetEntryMinMemory (Header h, int_32 tag, hTYP_t type, void *p, hCNT_t c) |
Retrieve tag value using header internal array. More... | |
int | headerGetRawEntry (Header h, int_32 tag, rpmTagType *type, void *p, rpmTagCount *c) |
Retrieve tag value with type match. More... | |
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. More... | |
static int | headerAddEntry (Header h, int_32 tag, int_32 type, const void *p, int_32 c) |
Add tag to header. More... | |
static int | headerAppendEntry (Header h, int_32 tag, int_32 type, const void *p, int_32 c) |
Append element to tag array in header. More... | |
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. More... | |
static int | headerAddI18NString (Header h, int_32 tag, const char *string, const char *lang) |
Add locale specific tag to header. More... | |
static int | headerModifyEntry (Header h, int_32 tag, int_32 type, const void *p, int_32 c) |
Modify tag in header. More... | |
static char | escapedChar (const char ch) |
static HE_t | rpmheMark (HE_t he) |
Mark a tag container with headerGetEntry() freeData. More... | |
static HE_t | rpmheClean (HE_t he) |
Clean a tag container, free'ing attached malloc's. More... | |
static sprintfToken | freeFormat (sprintfToken format, int num) |
Destroy headerSprintf format array. More... | |
static HeaderIterator | headerFreeIterator (HeaderIterator hi) |
Destroy header tag iterator. More... | |
static HeaderIterator | headerInitIterator (Header h) |
Create header tag iterator. More... | |
static int | headerNextIterator (HeaderIterator hi, hTAG_t tag, hTYP_t type, hPTR_t *p, hCNT_t c) |
Return next tag from header. More... | |
static Header | headerCopy (Header h) |
Duplicate a header. More... | |
static headerSprintfArgs | hsaInit (headerSprintfArgs hsa) |
Initialize an hsa iteration. More... | |
static sprintfToken | hsaNext (headerSprintfArgs hsa) |
Return next hsa iteration item. More... | |
static headerSprintfArgs | hsaFini (headerSprintfArgs hsa) |
Finish an hsa iteration. More... | |
static char * | hsaReserve (headerSprintfArgs hsa, size_t need) |
Reserve sufficient buffer space for next output value. More... | |
static const char * | myTagName (headerTagTableEntry tbl, int val, int *typep) |
Return tag name from value. More... | |
static int | myTagType (headerTagTableEntry tbl, int val) |
static int | myTagValue (headerTagTableEntry tbl, const char *name) |
Return tag value from name. More... | |
static int | findTag (headerSprintfArgs hsa, sprintfToken token, const char *name) |
Search extensions and tags for a name. More... | |
char * | intFormat (HE_t he, const char **av, const char *fmt) |
Convert tag data representation. More... | |
static char * | octFormat (HE_t he, const char **av) |
Return octal formatted data. More... | |
static char * | hexFormat (HE_t he, const char **av) |
Return hex formatted data. More... | |
static char * | decFormat (HE_t he, const char **av) |
Return decimal formatted data. More... | |
static char * | realDateFormat (HE_t he, const char **av, const char *strftimeFormat) |
Return strftime formatted data. More... | |
static char * | dateFormat (HE_t he, const char **av) |
Return date formatted data. More... | |
static char * | dayFormat (HE_t he, const char **av) |
Return day formatted data. More... | |
static char * | shescapeFormat (HE_t he, const char **av) |
Return shell escape formatted data. More... | |
static int | parseExpression (headerSprintfArgs hsa, sprintfToken token, char *str, char **endPtr) |
Parse a headerSprintf expression. More... | |
static int | parseFormat (headerSprintfArgs hsa, char *str, sprintfToken *formatPtr, int *numTokensPtr, char **endPtr, int state) |
Parse a headerSprintf term. More... | |
static int | getExtension (headerSprintfArgs hsa, headerTagTagFunction fn, HE_t he, HE_t ec) |
Call a header extension only once, saving results. More... | |
static char * | formatValue (headerSprintfArgs hsa, sprintfTag tag, int element) |
Format a single item's value. More... | |
static char * | singleSprintf (headerSprintfArgs hsa, sprintfToken token, int element) |
Format a single headerSprintf item. More... | |
static HE_t | rpmecNew (const headerSprintfExtension exts, int *necp) |
Create an extension cache. More... | |
static HE_t | rpmecFree (const headerSprintfExtension exts, HE_t ec) |
Destroy an extension cache. More... | |
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. More... | |
static void | headerCopyTags (Header headerFrom, Header headerTo, hTAG_t tagstocopy) |
Duplicate tag values from one header into another. More... | |
Variables | |
int | _hdr_debug = 0 |
int | _tagcache = 1 |
static unsigned char | header_magic [8] |
static int | typeAlign [16] |
Alignment needed for header data types. More... | |
static int | typeSizes [16] |
Size of header data types. More... | |
static size_t | headerMaxbytes = (32*1024*1024) |
Maximum no. More... | |
HV_t | hdrVec = &hdrVec1 |
Header methods for rpm headers. More... | |
struct headerSprintfExtension_s | headerDefaultFormats [] |
Supported default header tag output formats. More... | |
struct headerTagTableEntry_s * | rpmTagTable |
Automatically generated table of tag name/value pairs. More... | |
static struct HV_s | hdrVec1 |
#define hdrchkAlign | ( | _type, | |
_off | |||
) | ((_off) & (typeAlign[_type]-1)) |
Sanity check on alignment for data type.
Definition at line 117 of file header.c.
Referenced by regionSwab().
#define hdrchkData | ( | _nbytes | ) | ((_nbytes) & 0xff000000) |
Sanity check on data size and/or offset and/or count.
This check imposes a limit of 16Mb, more than enough.
Definition at line 112 of file header.c.
Referenced by doHeaderUnload(), headerAddEntry(), headerCopyLoad(), headerLoad(), headerRead(), and regionSwab().
#define hdrchkRange | ( | _dl, | |
_off | |||
) | ((_off) < 0 || (_off) > (_dl)) |
#define hdrchkTags | ( | _ntags | ) | ((_ntags) & 0xffff0000) |
Sanity check on no.
of tags. This check imposes a limit of 65K tags, more than enough.
Definition at line 101 of file header.c.
Referenced by doHeaderUnload(), headerCopyLoad(), headerLoad(), and headerRead().
#define hdrchkType | ( | _type | ) | ((_type) < RPM_MIN_TYPE || (_type) > RPM_MAX_TYPE) |
Sanity check on type values.
Definition at line 106 of file header.c.
Referenced by headerAddEntry(), headerLoad(), and regionSwab().
#define isSEP | ( | _c | ) | ((_c) == ':' || (_c) == '|') |
Referenced by parseFormat().
#define PARSER_BEGIN 0 |
Definition at line 34 of file header.c.
Referenced by headerSprintf().
#define PARSER_IN_ARRAY 1 |
Definition at line 35 of file header.c.
Referenced by parseFormat().
#define PARSER_IN_EXPR 2 |
Definition at line 36 of file header.c.
Referenced by parseExpression(), and parseFormat().
typedef struct headerSprintfArgs_s * headerSprintfArgs |
|
static |
Definition at line 1924 of file header.c.
References RPM_I18NSTRING_TYPE, and RPM_STRING_ARRAY_TYPE.
Referenced by grabData(), and headerAppendEntry().
|
static |
Return length of entry data.
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) |
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(), headerAppendEntry(), and regionSwab().
|
static |
Return date formatted data.
he | tag container |
av | parameter array (or NULL) |
Definition at line 2953 of file header.c.
References _, and realDateFormat().
|
static |
Return day formatted data.
he | tag container |
av | parameter array (or NULL) |
Definition at line 2965 of file header.c.
References _, and realDateFormat().
|
static |
Return decimal formatted data.
he | tag container |
av | parameter array (or NULL) |
Definition at line 2908 of file header.c.
References intFormat().
|
static |
|
static |
Find matching (tag,type) entry in header.
h | header |
tag | entry tag |
type | entry type |
Definition at line 905 of file header.c.
References headerToken_s::flags, HEADERFLAG_SORTED, headerSort(), headerToken_s::index, indexCmp(), headerToken_s::indexUsed, indexEntry_s::info, RPM_NULL_TYPE, entryInfo_s::tag, and entryInfo_s::type.
Referenced by headerAddI18NString(), headerAddOrAppendEntry(), headerAppendEntry(), headerFindI18NString(), headerGetRawEntry(), headerIsEntry(), headerModifyEntry(), headerRemoveEntry(), and intGetEntry().
|
static |
Search extensions and tags for a name.
hsa | headerSprintf args |
token | parsed fields |
name | name to find |
Definition at line 2736 of file header.c.
References alloca(), argvCount(), sprintfTag_s::av, sprintfToken_s::cond, sprintfTag_s::ext, sprintfTag_s::extNum, headerSprintfArgs_s::exts, sprintfTag_s::fmtfuncs, headerSprintfExtension_s::fmtFunction, HEADER_EXT_FORMAT, HEADER_EXT_LAST, HEADER_EXT_MORE, HEADER_EXT_TAG, headerSprintfExtension_s::more, myTagValue(), name, headerSprintfExtension_s::name, stpcpy(), sprintfToken_s::tag, headerSprintfExtension_s::tagFunction, sprintfTag_s::tagno, headerSprintfArgs_s::tags, sprintfToken_s::type, headerSprintfExtension_s::type, sprintfToken_s::u, headerSprintfExtension_s::u, xcalloc(), and xstrcasecmp().
Referenced by parseExpression(), and parseFormat().
|
static |
Format a single item's value.
hsa | headerSprintf args |
tag | tag |
element | element index |
Definition at line 3515 of file header.c.
References _free(), _hdr_debug, _tagcache, alloca(), rpmDataType_u::argv, argvFree(), argvSplit(), sprintfTag_s::arrayCount, sprintfTag_s::av, _HE_s::avail, _HE_s::c, headerSprintfArgs_s::ec, sprintfTag_s::ext, sprintfTag_s::extNum, sprintfTag_s::fmtfuncs, sprintfTag_s::format, _HE_s::freeData, getExtension(), headerSprintfArgs_s::h, sprintfTag_s::he, headerGetEntry(), hsaReserve(), rpmDataType_u::i32p, rpmDataType_u::i64p, rpmDataType_u::i8p, intFormat(), _HE_s::ix, myTagType(), _HE_s::p, sprintfTag_s::pad, sprintfTag_s::params, rpmDataType_u::ptr, RPM_ARRAY_RETURN_TYPE, RPM_ASN1_TYPE, RPM_BIN_TYPE, RPM_CHAR_TYPE, RPM_I18NSTRING_TYPE, RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_INT64_TYPE, RPM_INT8_TYPE, RPM_MASK_RETURN_TYPE, RPM_OPENPGP_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, rpmExpand(), rpmheClean(), rpmheMark(), snprintf(), stpcpy(), rpmDataType_u::str, _HE_s::t, _HE_s::tag, sprintfTag_s::tagno, headerSprintfArgs_s::tags, rpmDataType_u::ui16p, headerSprintfArgs_s::val, headerSprintfArgs_s::vallen, xmalloc(), and xstrdup().
Referenced by singleSprintf().
|
static |
Destroy headerSprintf format array.
format | sprintf format array |
num | number of elements |
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 headerSprintf(), parseExpression(), and parseFormat().
|
static |
Call a header extension only once, saving results.
hsa | headerSprintf args |
fn | function |
he | tag container |
ec | extension cache |
Definition at line 3490 of file header.c.
References _HE_s::avail, _HE_s::freeData, headerSprintfArgs_s::h, and rpmheClean().
Referenced by formatValue(), and singleSprintf().
|
static |
Return (malloc'ed) copy of entry data.
type | entry data type |
*p | tag container data |
c | entry item count |
*lenp | no. bytes in returned data |
Definition at line 1959 of file header.c.
References copyData(), dataLength(), rpmDataType_u::ptr, and xmalloc().
Referenced by headerAddEntry(), and headerModifyEntry().
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.
h | header |
tag | tag |
type | tag value data type |
p | pointer to tag value(s) |
c | number of values |
Definition at line 1992 of file header.c.
References 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, rpmDataType_u::ptr, entryInfo_s::tag, entryInfo_s::type, and xrealloc().
Referenced by headerAddI18NString(), headerAddOrAppendEntry(), headerCopy(), and headerCopyTags().
|
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().
h | header |
tag | tag |
string | tag value |
lang | locale |
Definition at line 2132 of file header.c.
References _free(), alloca(), rpmDataType_u::argv, entryInfo_s::count, indexEntry_s::data, ENTRY_IN_REGION, findEntry(), HEADER_I18NTABLE, headerAddEntry(), indexEntry_s::info, lang, indexEntry_s::length, entryInfo_s::offset, rpmDataType_u::ptr, RPM_I18NSTRING_TYPE, RPM_STRING_ARRAY_TYPE, xmalloc(), and xrealloc().
|
static |
Add or append element to tag array in header.
h | header |
tag | tag |
type | tag value data type |
p | pointer to tag value(s) |
c | number of values |
Definition at line 2102 of file header.c.
References findEntry(), headerAddEntry(), and headerAppendEntry().
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!
h | header |
tag | tag |
type | tag value data type |
p | pointer to tag value(s) |
c | number of values |
Definition at line 2051 of file header.c.
References copyData(), entryInfo_s::count, indexEntry_s::data, dataLength(), ENTRY_IN_REGION, findEntry(), indexEntry_s::info, indexEntry_s::length, entryInfo_s::offset, rpmDataType_u::ptr, RPM_I18NSTRING_TYPE, RPM_STRING_TYPE, xmalloc(), and xrealloc().
Referenced by headerAddOrAppendEntry().
Duplicate a header.
h | header |
Definition at line 2526 of file header.c.
References alloca(), _HE_s::c, HEADER_IMAGE, headerAddEntry(), headerFreeData(), headerFreeIterator(), headerInitIterator(), headerNew(), headerNextIterator(), headerReload(), _HE_s::p, rpmDataType_u::ptr, _HE_s::t, and _HE_s::tag.
|
static |
Make a copy and convert header to in-memory representation.
uh | on-disk header blob (i.e. with offsets) |
Definition at line 1353 of file header.c.
References _free(), headerToken_s::flags, hdrchkData, hdrchkTags, HEADERFLAG_ALLOCATED, headerLoad(), headerMaxbytes, and xmalloc().
Duplicate tag values from one header into another.
headerFrom | source header |
headerTo | destination header |
tagstocopy | array of tags that are copied |
Definition at line 4099 of file header.c.
References headerAddEntry(), headerFreeData(), headerGetEntryMinMemory(), headerIsEntry(), and rpmDataType_u::ptr.
|
static |
Return i18n string from header that matches locale.
h | header |
entry | i18n string data |
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().
Dereference a header instance.
h | header |
Definition at line 189 of file header.c.
References _free(), headerToken_s::baseurl, headerToken_s::blob, indexEntry_s::data, headerToken_s::digest, ENTRY_IN_REGION, ENTRY_IS_REGION, headerToken_s::flags, HEADERFLAG_ALLOCATED, headerUnlink(), headerToken_s::index, headerToken_s::indexUsed, indexEntry_s::length, headerToken_s::nrefs, and headerToken_s::origin.
Referenced by headerFreeIterator(), headerReload(), and headerSprintf().
|
static |
Destroy header tag iterator.
hi | header tag iterator |
Definition at line 2440 of file header.c.
References _free(), headerIterator_s::h, and headerFree().
Referenced by headerCopy(), and hsaFini().
|
static |
Free data allocated when retrieved from header.
h | header |
data | data (or NULL) |
type | type of data (or -1 to force free) |
Definition at line 1822 of file header.c.
References _free(), RPM_ASN1_TYPE, RPM_BIN_TYPE, RPM_I18NSTRING_TYPE, RPM_OPENPGP_TYPE, and RPM_STRING_ARRAY_TYPE.
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).
h | header |
tag | tag |
*type | tag value data type (or NULL) |
*p | pointer to tag value(s) (or NULL) |
*c | number of values (or NULL) |
Definition at line 1852 of file header.c.
References headerGetStats(), intGetEntry(), rpmswEnter(), and rpmswExit().
Referenced by formatValue(), and singleSprintf().
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.
h | header |
tag | tag |
*type | tag value data type (or NULL) |
*p | tag value(s) (or NULL) |
*c | number of values (or NULL) |
Definition at line 1882 of file header.c.
References headerGetStats(), intGetEntry(), rpmswEnter(), and rpmswExit().
Referenced by headerCopyTags().
|
static |
Definition at line 1248 of file header.c.
References headerToken_s::instance.
|
static |
Return header origin (e.g path or URL).
h | header |
Definition at line 1178 of file header.c.
References headerToken_s::origin.
|
static |
Create header tag iterator.
h | header |
Definition at line 2456 of file header.c.
References headerIterator_s::h, headerLink(), headerSort(), headerIterator_s::next_index, and xmalloc().
Referenced by headerCopy(), and hsaInit().
Check if tag is in header.
h | header |
tag | tag |
Definition at line 1507 of file header.c.
References findEntry(), and RPM_NULL_TYPE.
Referenced by headerCopyTags(), headerGetRawEntry(), and singleSprintf().
Reference a header instance.
h | header |
Definition at line 147 of file header.c.
References _hdr_debug, and headerToken_s::nrefs.
Referenced by headerInitIterator(), headerLoad(), headerNew(), and headerSprintf().
|
static |
Convert header to in-memory representation.
uh | on-disk header blob (i.e. with offsets) |
Definition at line 997 of file header.c.
References _free(), alloca(), headerToken_s::blob, entryInfo_s::count, indexEntry_s::data, headerToken_s::flags, hdrchkData, hdrchkTags, hdrchkType, hdrVec, HEADER_BASENAMES, HEADER_I18NTABLE, HEADER_IMAGE, HEADER_OLDFILENAMES, HEADERFLAG_LEGACY, HEADERFLAG_SORTED, headerGetStats(), headerLink(), headerRemoveEntry(), headerSort(), headerToken_s::hv, headerToken_s::index, headerToken_s::indexAlloced, headerToken_s::indexUsed, indexEntry_s::info, indexEntry_s::length, 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 headerCopyLoad(), headerRead(), and headerReload().
|
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. *
td | header i18n table data, NUL terminated |
l | start of locale to match |
le | end of locale to match |
Definition at line 1647 of file header.c.
References alloca().
Referenced by headerFindI18NString().
Modify tag in header.
If there are multiple entries with this tag, the first one gets replaced.
h | header |
tag | tag |
type | tag value data type |
p | pointer to tag value(s) |
c | number of values |
Definition at line 2275 of file header.c.
References _free(), entryInfo_s::count, indexEntry_s::data, ENTRY_IN_REGION, findEntry(), grabData(), headerToken_s::index, indexEntry_s::info, indexEntry_s::length, entryInfo_s::offset, rpmDataType_u::ptr, entryInfo_s::tag, and entryInfo_s::type.
|
static |
Create new (empty) header instance.
Definition at line 229 of file header.c.
References headerToken_s::baseurl, headerToken_s::blob, headerToken_s::digest, headerToken_s::flags, hdrVec, HEADERFLAG_SORTED, headerLink(), headerToken_s::hv, headerToken_s::index, INDEX_MALLOC_SIZE, headerToken_s::indexAlloced, headerToken_s::indexUsed, headerToken_s::instance, headerToken_s::nrefs, headerToken_s::origin, and xcalloc().
Referenced by headerCopy().
|
static |
Return next tag from header.
hi | header tag iterator |
*tag | tag |
*type | tag value data type |
*p | pointer to tag value(s) |
*c | number of values |
Definition at line 2478 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, rpmswEnter(), rpmswExit(), and entryInfo_s::tag.
Referenced by headerCopy(), and hsaNext().
Read (and load) header from file handle.
_fd | file handle |
magicp | read (and verify) 8 bytes of (magic, 0)? |
Definition at line 1384 of file header.c.
References _fd, _free(), block(), fdGetOPath(), headerToken_s::flags, hdrchkData, hdrchkTags, header_magic, HEADER_MAGIC_YES, HEADERFLAG_ALLOCATED, headerLoad(), headerMaxbytes, headerSetOrigin(), timedRead(), and xmalloc().
Convert header to on-disk representation, and then reload.
This is used to insure that all header data is in one chunk.
h | header (with pointers) |
tag | region tag |
Definition at line 1299 of file header.c.
References _free(), headerToken_s::baseurl, headerToken_s::digest, doHeaderUnload(), ENTRY_IS_REGION, headerToken_s::flags, HEADER_IMMUTABLE, HEADER_SIGNATURES, HEADERFLAG_ALLOCATED, headerFree(), headerLoad(), headerSetBaseURL(), headerSetDigest(), headerSetInstance(), headerSetOrigin(), headerToken_s::index, indexEntry_s::info, headerToken_s::instance, headerToken_s::origin, headerToken_s::sb, entryInfo_s::tag, and xstrdup().
Referenced by headerCopy().
Delete tag in header.
Removes all entries of type tag from the header, returns 1 if none were found.
h | header |
tag | tag |
Definition at line 953 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, RPM_NULL_TYPE, and entryInfo_s::tag.
Referenced by headerLoad().
|
static |
Definition at line 1255 of file header.c.
References headerToken_s::instance.
Referenced by headerReload().
|
static |
Store header origin (e.g path or URL).
h | header |
origin | new header origin |
Definition at line 1191 of file header.c.
References _free(), headerToken_s::origin, and xstrdup().
Referenced by headerRead(), and headerReload().
Return size of on-disk header representation in bytes.
h | header |
magicp | include size of 8 bytes for (magic, 0)? |
Definition at line 318 of file header.c.
References entryInfo_s::count, ENTRY_IS_REGION, headerToken_s::flags, header_magic, HEADER_MAGIC_NO, HEADER_MAGIC_YES, HEADERFLAG_LEGACY, headerSort(), headerToken_s::index, indexEntry_s::info, indexEntry_s::length, entryInfo_s::offset, entryInfo_s::type, and typeSizes.
|
static |
Sort tags in header.
h | header |
Definition at line 272 of file header.c.
References headerToken_s::flags, HEADERFLAG_SORTED, headerToken_s::index, indexCmp(), and headerToken_s::indexUsed.
Referenced by doHeaderUnload(), findEntry(), headerInitIterator(), headerLoad(), and headerSizeof().
|
static |
Return formatted output string from header tags.
The returned string must be free()d.
h | header |
fmt | format to use |
tags | array of tag name/value/type triples |
exts | formatting extensions chained table |
*errmsg | error message (if any) |
Definition at line 3988 of file header.c.
References _free(), _hdr_debug, alloca(), headerSprintfArgs_s::alloced, sprintfToken_s::array, sprintfTag_s::av, headerSprintfArgs_s::ec, headerSprintfArgs_s::errmsg, headerSprintfArgs_s::exts, headerSprintfArgs_s::fmt, headerSprintfArgs_s::format, freeFormat(), headerSprintfArgs_s::h, 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, sprintfToken_s::type, sprintfToken_s::u, headerSprintfArgs_s::val, headerSprintfArgs_s::vallen, xrealloc(), and xstrdup().
Dereference a header instance.
h | header |
Definition at line 171 of file header.c.
References _hdr_debug, and headerToken_s::nrefs.
Referenced by headerFree().
|
static |
Convert header to on-disk representation.
h | header (with pointers) |
Definition at line 889 of file header.c.
References doHeaderUnload(), and indexEntry_s::length.
|
static |
Restore tags in header to original ordering.
h | header |
Definition at line 305 of file header.c.
References headerToken_s::index, headerToken_s::indexUsed, and offsetCmp().
Referenced by doHeaderUnload().
Write (with unload) header to file handle.
_fd | file handle |
h | header |
magicp | prefix write with 8 bytes of (magic, 0)? |
Definition at line 1465 of file header.c.
References _fd, _free(), doHeaderUnload(), Fwrite(), header_magic, HEADER_MAGIC_NO, and HEADER_MAGIC_YES.
|
static |
Return hex formatted data.
he | tag container |
av | parameter array (or NULL) |
Definition at line 2896 of file header.c.
References intFormat().
|
static |
Finish an hsa iteration.
hsa | headerSprintf args |
Definition at line 2637 of file header.c.
References headerFreeIterator(), headerSprintfArgs_s::hi, and headerSprintfArgs_s::i.
Referenced by headerSprintf().
|
static |
Initialize an hsa iteration.
hsa | headerSprintf args |
Definition at line 2573 of file header.c.
References sprintfToken_s::array, headerSprintfArgs_s::format, headerSprintfArgs_s::h, headerInitIterator(), headerSprintfArgs_s::hi, headerSprintfArgs_s::i, sprintfToken_s::tag, sprintfTag_s::tagno, sprintfToken_s::type, and sprintfToken_s::u.
Referenced by headerSprintf().
|
static |
Return next hsa iteration item.
hsa | headerSprintf args |
Definition at line 2599 of file header.c.
References sprintfToken_s::array, _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, sprintfToken_s::tag, _HE_s::tag, sprintfTag_s::tagno, sprintfToken_s::type, and sprintfToken_s::u.
Referenced by headerSprintf().
|
static |
Reserve sufficient buffer space for next output value.
hsa | headerSprintf args |
need | no. of bytes to reserve |
Definition at line 2656 of file header.c.
References headerSprintfArgs_s::alloced, headerSprintfArgs_s::val, headerSprintfArgs_s::vallen, and xrealloc().
Referenced by formatValue(), headerSprintf(), and singleSprintf().
|
static |
Definition at line 258 of file header.c.
References indexEntry_s::info, and entryInfo_s::tag.
Referenced by findEntry(), and headerSort().
char* intFormat | ( | HE_t | he, |
const char ** | av, | ||
const char * | fmt | ||
) |
Convert tag data representation.
he | tag container |
av | parameter array (or NULL) |
fmt | output radix (NULL or "" assumes d) |
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().
|
static |
Retrieve tag data from header.
h | header |
tag | tag to retrieve |
*type | type (or NULL) |
*p | data (or NULL) |
*c | count (or NULL) |
minMem | string pointers reference header memory? |
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.
Referenced by headerGetEntry(), and headerGetEntryMinMemory().
|
static |
Return tag name from value.
tbl | tag table |
val | tag value to find |
*typep | tag type (or NULL) |
Definition at line 2677 of file header.c.
References name, headerTagTableEntry_s::name, headerTagTableEntry_s::type, headerTagTableEntry_s::val, and xtolower().
Referenced by singleSprintf().
|
static |
Definition at line 2703 of file header.c.
References headerTagTableEntry_s::name, headerTagTableEntry_s::type, and headerTagTableEntry_s::val.
Referenced by formatValue().
|
static |
Return tag value from name.
tbl | tag table |
name | tag name to find |
Definition at line 2719 of file header.c.
References headerTagTableEntry_s::name, headerTagTableEntry_s::val, and xstrcasecmp().
Referenced by findTag().
|
static |
Return octal formatted data.
he | tag container |
av | parameter array (or NULL) |
Definition at line 2884 of file header.c.
References intFormat().
|
static |
Definition at line 283 of file header.c.
References indexEntry_s::data, indexEntry_s::info, entryInfo_s::offset, and entryInfo_s::tag.
Referenced by headerUnsort().
|
static |
Parse a headerSprintf expression.
hsa | headerSprintf args |
token | |
str |
*endPtr |
Definition at line 3379 of file header.c.
References _, _hdr_debug, sprintfToken_s::cond, headerSprintfArgs_s::errmsg, findTag(), freeFormat(), parseFormat(), PARSER_IN_EXPR, sprintfToken_s::type, and sprintfToken_s::u.
Referenced by parseFormat().
|
static |
Parse a headerSprintf term.
hsa | headerSprintf args |
str |
*formatPtr | |
*numTokensPtr | |
*endPtr |
state |
Definition at line 3070 of file header.c.
References _, _hdr_debug, argvAdd(), sprintfToken_s::array, sprintfTag_s::arrayCount, sprintfTag_s::av, headerSprintfArgs_s::errmsg, escapedChar(), findTag(), sprintfTag_s::format, freeFormat(), isSEP, sprintfTag_s::justOne, next, sprintfTag_s::pad, sprintfTag_s::params, parseExpression(), PARSER_IN_ARRAY, PARSER_IN_EXPR, sprintfToken_s::string, sprintfToken_s::tag, sprintfToken_s::type, sprintfToken_s::u, xcalloc(), and xisdigit().
Referenced by headerSprintf(), and parseExpression().
|
static |
Return strftime formatted data.
he | tag container |
av | parameter array (or NULL) |
strftimeFormat | strftime(3) format |
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().
|
static |
Destroy an extension cache.
exts | headerSprintf extensions |
ec | extension cache |
Definition at line 3958 of file header.c.
References _free(), HEADER_EXT_LAST, HEADER_EXT_MORE, headerSprintfExtension_s::more, rpmheClean(), headerSprintfExtension_s::type, and headerSprintfExtension_s::u.
Referenced by headerSprintf().
|
static |
Create an extension cache.
exts | headerSprintf extensions |
*necp | no. of elements (or NULL) |
Definition at line 3932 of file header.c.
References HEADER_EXT_LAST, HEADER_EXT_MORE, headerSprintfExtension_s::more, headerSprintfExtension_s::type, headerSprintfExtension_s::u, and xcalloc().
Referenced by headerSprintf().
Clean a tag container, free'ing attached malloc's.
he | tag container |
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.
he | tag container |
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().
|
static |
Return shell escape formatted data.
he | tag container |
av | parameter array (or NULL) |
Definition at line 2977 of file header.c.
References _, rpmDataType_u::i32p, rpmDataType_u::i64p, _HE_s::p, RPM_INT32_TYPE, RPM_INT64_TYPE, RPM_STRING_TYPE, snprintf(), rpmDataType_u::str, _HE_s::t, xmalloc(), and xstrdup().
|
static |
Format a single headerSprintf item.
hsa | headerSprintf args |
token | item to format |
element | element index |
Definition at line 3711 of file header.c.
References _, _tagcache, sprintfToken_s::array, sprintfTag_s::arrayCount, sprintfTag_s::av, _HE_s::avail, _HE_s::c, sprintfToken_s::cond, 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(), sprintfToken_s::string, _HE_s::t, sprintfToken_s::tag, _HE_s::tag, sprintfTag_s::tagno, headerSprintfArgs_s::tags, sprintfToken_s::type, sprintfToken_s::u, headerSprintfArgs_s::val, and headerSprintfArgs_s::vallen.
Referenced by headerSprintf().
int _hdr_debug = 0 |
Definition at line 22 of file header.c.
Referenced by escapedChar(), formatValue(), headerLink(), headerSprintf(), headerUnlink(), parseExpression(), and parseFormat().
int _tagcache = 1 |
Definition at line 25 of file header.c.
Referenced by formatValue(), freeFormat(), and singleSprintf().
struct headerTagTableEntry_s* rpmTagTable |