rpm  4.18.0
About: RPM - The Red Hat Package Manager (rpm.org). See also the rpm 5 releases for Unix (not only Linux).
  Fossies Dox: rpm-4.18.0.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Loading...
Searching...
No Matches
RPM Tag Data Container API.

How to retrieve data from package headers. More...

Collaboration diagram for RPM Tag Data Container API.:

Files

file  rpmtd.h
 RPM Tag Data Container API.
 

Data Structures

struct  rpmtd_s
 Container for rpm tag data (from headers or extensions). More...
 

Functions

rpmtd rpmtdNew (void)
 Create new tag data container. More...
 
rpmtd rpmtdFree (rpmtd td)
 Destroy tag data container. More...
 
void rpmtdReset (rpmtd td)
 (Re-)initialize tag data container. More...
 
void rpmtdFreeData (rpmtd td)
 Free contained data. More...
 
rpm_count_t rpmtdCount (rpmtd td)
 Retrieve array size of the container. More...
 
rpm_count_t rpmtdSize (rpmtd td)
 Retrieve container data size (eg required for allocation). More...
 
rpmTagVal rpmtdTag (rpmtd td)
 Retrieve tag of the container. More...
 
rpmTagType rpmtdType (rpmtd td)
 Retrieve type of the container. More...
 
rpmTagClass rpmtdClass (rpmtd td)
 Retrieve class of the container. More...
 
rpmtdFlags rpmtdGetFlags (rpmtd td)
 Retrieve flags of the container (allocation details etc) More...
 
int rpmtdGetIndex (rpmtd td)
 Retrieve current iteration index of the container. More...
 
int rpmtdSetIndex (rpmtd td, int index)
 Set iteration index of the container. More...
 
int rpmtdInit (rpmtd td)
 Initialize tag container for iteration. More...
 
int rpmtdNext (rpmtd td)
 Iterate over tag data container. More...
 
uint32_t * rpmtdNextUint32 (rpmtd td)
 Iterate over uint32_t type tag data container. More...
 
uint64_t * rpmtdNextUint64 (rpmtd td)
 Iterate over uint64_t type tag data container. More...
 
const char * rpmtdNextString (rpmtd td)
 Iterate over string / string array type tag data container. More...
 
char * rpmtdGetChar (rpmtd td)
 Return char data from tag container. More...
 
uint16_t * rpmtdGetUint16 (rpmtd td)
 Return uint16_t data from tag container. More...
 
uint32_t * rpmtdGetUint32 (rpmtd td)
 Return uint32_t data from tag container. More...
 
uint64_t * rpmtdGetUint64 (rpmtd td)
 Return uint64_t data from tag container. More...
 
const char * rpmtdGetString (rpmtd td)
 Return string data from tag container. More...
 
uint64_t rpmtdGetNumber (rpmtd td)
 Return numeric value from tag container. More...
 
char * rpmtdFormat (rpmtd td, rpmtdFormats fmt, const char *errmsg)
 Format data from tag container to string presentation of given format. More...
 
int rpmtdSetTag (rpmtd td, rpmTagVal tag)
 Set container tag and type. More...
 
int rpmtdFromUint8 (rpmtd td, rpmTagVal tag, uint8_t *data, rpm_count_t count)
 Construct tag container from uint8_t pointer. More...
 
int rpmtdFromUint16 (rpmtd td, rpmTagVal tag, uint16_t *data, rpm_count_t count)
 Construct tag container from uint16_t pointer. More...
 
int rpmtdFromUint32 (rpmtd td, rpmTagVal tag, uint32_t *data, rpm_count_t count)
 Construct tag container from uint32_t pointer. More...
 
int rpmtdFromUint64 (rpmtd td, rpmTagVal tag, uint64_t *data, rpm_count_t count)
 Construct tag container from uint64_t pointer. More...
 
int rpmtdFromString (rpmtd td, rpmTagVal tag, const char *data)
 Construct tag container from a string. More...
 
int rpmtdFromStringArray (rpmtd td, rpmTagVal tag, const char **data, rpm_count_t count)
 Construct tag container from a string array. More...
 
int rpmtdFromArgv (rpmtd td, rpmTagVal tag, ARGV_t argv)
 Construct tag container from ARGV_t array. More...
 
int rpmtdFromArgi (rpmtd td, rpmTagVal tag, ARGI_t argi)
 Construct tag container from ARGI_t array. More...
 
rpmtd rpmtdDup (rpmtd td)
 Perform deep copy of container. More...
 
rpmsidrpmtdToPool (rpmtd td, rpmstrPool pool)
 Push string array container contents to a string pool, return string ids. More...
 

Detailed Description

How to retrieve data from package headers.

Function Documentation

◆ rpmtdClass()

rpmTagClass rpmtdClass ( rpmtd  td)

Retrieve class of the container.

Parameters
tdTag data container
Returns
Rpm tag class

Definition at line 74 of file rpmtd.c.

References rpmTagTypeGetClass(), and rpmtd_s::type.

Referenced by rpmHeaderFormatCall(), rpmii_iternext(), rpmtd_AsPyobj(), shescapeFormat(), stringFormat(), and xmlFormat().

◆ rpmtdCount()

◆ rpmtdDup()

rpmtd rpmtdDup ( rpmtd  td)

Perform deep copy of container.

Create a modifiable copy of tag data container (on string arrays each string is separately allocated)

Todo:
Only string arrays types are supported currently
Parameters
tdContainer to copy
Returns
New container or NULL on error

Definition at line 414 of file rpmtd.c.

References rpmtd_s::count, rpmtd_s::data, rpmtd_s::flags, RPM_I18NSTRING_TYPE, RPM_STRING_ARRAY_TYPE, RPMTD_ALLOCED, RPMTD_IMMUTABLE, RPMTD_PTR_ALLOCED, rpmtdGetString(), rpmtdNew(), rpmtdNext(), rpmtd_s::type, xmalloc, and xstrdup.

◆ rpmtdFormat()

char * rpmtdFormat ( rpmtd  td,
rpmtdFormats  fmt,
const char *  errmsg 
)

Format data from tag container to string presentation of given format.

Return malloced string presentation of current data in container, converting from integers etc as necessary. On array types, data from current iteration index is used for formatting.

Parameters
tdTag data container
fmtFormat to apply
errmsgError message from conversion (or NULL)
Returns
String representation of current data (malloc'ed), NULL on error

Definition at line 238 of file rpmtd.c.

References _, rpmHeaderFormatByValue(), and rpmHeaderFormatCall().

Referenced by headerGetAsString(), mireSkip(), rpmInstallLoadMacros(), and triggercondsTagFor().

◆ rpmtdFree()

rpmtd rpmtdFree ( rpmtd  td)

Destroy tag data container.

Parameters
tdTag data container
Returns
NULL always

Definition at line 17 of file rpmtd.c.

References rpmtdFreeData().

Referenced by addRpmTags(), getData(), hdrFullFilelist(), headerFormat(), replaceSignature(), rpmDisplayQueryTags(), rpmii_dealloc(), and rpmMergeHeaders().

◆ rpmtdFreeData()

◆ rpmtdFromArgi()

int rpmtdFromArgi ( rpmtd  td,
rpmTagVal  tag,
ARGI_t  argi 
)

Construct tag container from ARGI_t array.

Tag type is checked to be of integer array type and array is checked to be non-empty.

Parameters
tdTag data container
tagRpm tag to construct
argiARGI array
Returns
1 on success, 0 on error (eg wrong type)

Definition at line 402 of file rpmtd.c.

References argiCount(), argiData(), RPM_ARRAY_RETURN_TYPE, RPM_INT32_TYPE, rpmTagGetReturnType(), rpmTagGetTagType(), and rpmtdSet().

Referenced by rpmfcGenerateDepends().

◆ rpmtdFromArgv()

int rpmtdFromArgv ( rpmtd  td,
rpmTagVal  tag,
ARGV_t  argv 
)

Construct tag container from ARGV_t array.

Tag type is checked to be of string array type and array is checked to be non-empty.

Parameters
tdTag data container
tagRpm tag to construct
argvARGV array
Returns
1 on success, 0 on error (eg wrong type)

Definition at line 391 of file rpmtd.c.

References argvCount(), RPM_STRING_ARRAY_TYPE, rpmTagGetTagType(), and rpmtdSet().

◆ rpmtdFromString()

int rpmtdFromString ( rpmtd  td,
rpmTagVal  tag,
const char *  data 
)

Construct tag container from a string.

Tag type is checked to be of string type.

Parameters
tdTag data container
tagRpm tag to construct
dataString to use
Returns
1 on success, 0 on error (eg wrong type)

Definition at line 366 of file rpmtd.c.

References RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, rpmTagGetTagType(), and rpmtdSet().

◆ rpmtdFromStringArray()

int rpmtdFromStringArray ( rpmtd  td,
rpmTagVal  tag,
const char **  data,
rpm_count_t  count 
)

Construct tag container from a string array.

Tag type is checked to be of string or string array type. For non-array types count must be exactly 1.

Parameters
tdTag data container
tagRpm tag to construct
dataPointer to string array
countNumber of entries
Returns
1 on success, 0 on error (eg wrong type)

Definition at line 380 of file rpmtd.c.

References RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, rpmTagGetTagType(), and rpmtdSet().

◆ rpmtdFromUint16()

int rpmtdFromUint16 ( rpmtd  td,
rpmTagVal  tag,
uint16_t *  data,
rpm_count_t  count 
)

Construct tag container from uint16_t pointer.

Tag type is checked to be of INT16 type. For non-array types count must be exactly 1.

Parameters
tdTag data container
tagRpm tag to construct
dataPointer to uint16_t (value or array)
countNumber of entries
Returns
1 on success, 0 on error (eg wrong type)

Definition at line 330 of file rpmtd.c.

References RPM_ARRAY_RETURN_TYPE, RPM_INT16_TYPE, rpmTagGetReturnType(), rpmTagGetTagType(), and rpmtdSet().

◆ rpmtdFromUint32()

int rpmtdFromUint32 ( rpmtd  td,
rpmTagVal  tag,
uint32_t *  data,
rpm_count_t  count 
)

Construct tag container from uint32_t pointer.

Tag type is checked to be of INT32 type. For non-array types count must be exactly 1.

Parameters
tdTag data container
tagRpm tag to construct
dataPointer to uint32_t (value or array)
countNumber of entries
Returns
1 on success, 0 on error (eg wrong type)

Definition at line 342 of file rpmtd.c.

References RPM_ARRAY_RETURN_TYPE, RPM_INT32_TYPE, rpmTagGetReturnType(), rpmTagGetTagType(), and rpmtdSet().

◆ rpmtdFromUint64()

int rpmtdFromUint64 ( rpmtd  td,
rpmTagVal  tag,
uint64_t *  data,
rpm_count_t  count 
)

Construct tag container from uint64_t pointer.

Tag type is checked to be of INT64 type. For non-array types count must be exactly 1.

Parameters
tdTag data container
tagRpm tag to construct
dataPointer to uint64_t (value or array)
countNumber of entries
Returns
1 on success, 0 on error (eg wrong type)

Definition at line 354 of file rpmtd.c.

References RPM_ARRAY_RETURN_TYPE, RPM_INT64_TYPE, rpmTagGetReturnType(), rpmTagGetTagType(), and rpmtdSet().

◆ rpmtdFromUint8()

int rpmtdFromUint8 ( rpmtd  td,
rpmTagVal  tag,
uint8_t *  data,
rpm_count_t  count 
)

Construct tag container from uint8_t pointer.

Tag type is checked to be of compatible type (CHAR, INT8 or BIN). For non-array types (BIN is a special case of INT8 array) count must be exactly 1.

Parameters
tdTag data container
tagRpm tag to construct
dataPointer to uint8_t (value or array)
countNumber of entries
Returns
1 on success, 0 on error (eg wrong type)

Definition at line 303 of file rpmtd.c.

References RPM_ARRAY_RETURN_TYPE, RPM_BIN_TYPE, RPM_CHAR_TYPE, RPM_INT8_TYPE, rpmTagGetReturnType(), rpmTagGetTagType(), and rpmtdSet().

◆ rpmtdGetChar()

char * rpmtdGetChar ( rpmtd  td)

Return char data from tag container.

For scalar return type, just return pointer to the integer. On array types, return pointer to current iteration index. If the tag container is not for char type, NULL is returned.

Parameters
tdTag data container
Returns
Pointer to uint16_t, NULL on error

Definition at line 149 of file rpmtd.c.

References rpmtd_s::data, rpmtd_s::ix, RPM_CHAR_TYPE, and rpmtd_s::type.

Referenced by checkInstalledFiles(), markReplacedFiles(), and td2key().

◆ rpmtdGetFlags()

rpmtdFlags rpmtdGetFlags ( rpmtd  td)

Retrieve flags of the container (allocation details etc)

Parameters
tdTag data container
Returns
Container flags

Definition at line 79 of file rpmtd.c.

References rpmtd_s::flags.

Referenced by hdrGetTag().

◆ rpmtdGetIndex()

int rpmtdGetIndex ( rpmtd  td)

Retrieve current iteration index of the container.

Parameters
tdTag data container
Returns
Iteration index (or -1 if not iterating)

Definition at line 84 of file rpmtd.c.

References rpmtd_s::ix.

Referenced by haveLangTag(), headerFindSpec(), rpmsinfoInit(), and runImmedTriggers().

◆ rpmtdGetNumber()

uint64_t rpmtdGetNumber ( rpmtd  td)

Return numeric value from tag container.

Returns the value of numeric container (RPM_NUMERIC_CLASS) from current iteration index as uint64_t regardless of its internal presentation (8/16/32/64-bit integer).

Parameters
tdTag data container
Returns
Value of current iteration item as uint64_t, 0 for non-numeric types (error)

Definition at line 210 of file rpmtd.c.

References rpmtd_s::data, rpmtd_s::ix, RPM_CHAR_TYPE, RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_INT64_TYPE, RPM_INT8_TYPE, and rpmtd_s::type.

Referenced by buildSpec(), dbiFindMatches(), depflagsFormat(), deptypeFormat(), fflagsFormat(), fstateFormat(), headerGetNumber(), humanFormat(), numFormat(), permsFormat(), realDateFormat(), rpmdbFindByFile(), rpmRelocateFileList(), rpmScriptFromTriggerTag(), rpmtd_ItemAsPyobj(), shescapeFormat(), stringFormat(), triggertypeFormat(), and verifyFlags().

◆ rpmtdGetString()

const char * rpmtdGetString ( rpmtd  td)

Return string data from tag container.

For string types, just return the string. On string array types, return the string from current iteration index. If the tag container is not for a string type, NULL is returned.

Parameters
tdTag data container
Returns
String constant from container, NULL on error

Definition at line 192 of file rpmtd.c.

References rpmtd_s::data, rpmtd_s::ix, RPM_I18NSTRING_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, and rpmtd_s::type.

Referenced by armorFormat(), checkInstalledFiles(), compressFilelist(), expandFormat(), haveLangTag(), headerGetString(), logAddRemove(), rpmInstall(), rpmScriptFromTriggerTag(), rpmsinfoInit(), rpmtd_ItemAsPyobj(), rpmtdDup(), rpmtdNextString(), shescapeFormat(), stringFormat(), tag2index(), td2key(), and triggercondsTagFor().

◆ rpmtdGetUint16()

uint16_t * rpmtdGetUint16 ( rpmtd  td)

Return uint16_t data from tag container.

For scalar return type, just return pointer to the integer. On array types, return pointer to current iteration index. If the tag container is not for int16 type, NULL is returned.

Parameters
tdTag data container
Returns
Pointer to uint16_t, NULL on error

Definition at line 159 of file rpmtd.c.

References rpmtd_s::data, rpmtd_s::ix, RPM_INT16_TYPE, and rpmtd_s::type.

Referenced by td2key().

◆ rpmtdGetUint32()

uint32_t * rpmtdGetUint32 ( rpmtd  td)

Return uint32_t data from tag container.

For scalar return type, just return pointer to the integer. On array types, return pointer to current iteration index. If the tag container is not for int32 type, NULL is returned.

Parameters
tdTag data container
Returns
Pointer to uint32_t, NULL on error

Definition at line 170 of file rpmtd.c.

References rpmtd_s::data, rpmtd_s::ix, RPM_INT32_TYPE, and rpmtd_s::type.

Referenced by addTriggers(), checkInstalledFiles(), printSize(), rpmfilesPopulate(), rpmtdNextUint32(), runFileTriggers(), runImmedFileTriggers(), td2key(), triggercondsTagFor(), and triggertypeTagFor().

◆ rpmtdGetUint64()

uint64_t * rpmtdGetUint64 ( rpmtd  td)

Return uint64_t data from tag container.

For scalar return type, just return pointer to the integer. On array types, return pointer to current iteration index. If the tag container is not for int64 type, NULL is returned.

Parameters
tdTag data container
Returns
Pointer to uint64_t, NULL on error

Definition at line 181 of file rpmtd.c.

References rpmtd_s::data, rpmtd_s::ix, RPM_INT64_TYPE, and rpmtd_s::type.

Referenced by printSize(), rpmtdNextUint64(), and td2key().

◆ rpmtdInit()

int rpmtdInit ( rpmtd  td)

Initialize tag container for iteration.

Parameters
tdTag data container
Returns
0 on success

Definition at line 98 of file rpmtd.c.

References rpmtd_s::ix.

Referenced by addPrefixes(), mireSkip(), rpmRelocationBuild(), triggercondsTagFor(), and triggertypeTagFor().

◆ rpmtdNew()

rpmtd rpmtdNew ( void  )

Create new tag data container.

Returns
New, initialized tag data container.

Definition at line 10 of file rpmtd.c.

References rpmtdReset(), and xmalloc.

Referenced by addRpmTags(), getData(), hdrFullFilelist(), makeSigTag(), rpmDisplayQueryTags(), rpmii_Wrap(), rpmMergeHeaders(), and rpmtdDup().

◆ rpmtdNext()

int rpmtdNext ( rpmtd  td)

Iterate over tag data container.

Parameters
tdTag data container
Returns
Tag data container iterator index, -1 on termination

Definition at line 108 of file rpmtd.c.

References rpmtd_s::ix, and rpmtdCount().

Referenced by compressFilelist(), haveSignature(), mireSkip(), providePackageNVR(), rpmtd_AsPyobj(), rpmtdDup(), rpmtdNextString(), rpmtdNextUint32(), rpmtdNextUint64(), rpmvsAppend(), tag2index(), triggercondsTagFor(), and triggertypeTagFor().

◆ rpmtdNextString()

const char * rpmtdNextString ( rpmtd  td)

Iterate over string / string array type tag data container.

Parameters
tdTag data container
Returns
Pointer to next value, NULL on termination or error

Definition at line 140 of file rpmtd.c.

References rpmtdGetString(), and rpmtdNext().

Referenced by addPrefixes(), addRpmTags(), base2bin(), checkForEncoding(), handlePreambleTag(), haveLangTag(), headerFindSpec(), hex2bin(), hex2binv(), isMemberInEntry(), loadKeyringFromDB(), rpmDisplayQueryTags(), rpmRelocateSrpmFileList(), rpmRelocationBuild(), and runImmedTriggers().

◆ rpmtdNextUint32()

uint32_t * rpmtdNextUint32 ( rpmtd  td)

Iterate over uint32_t type tag data container.

Parameters
tdTag data container
Returns
Pointer to next value, NULL on termination or error

Definition at line 122 of file rpmtd.c.

References rpmtdGetUint32(), and rpmtdNext().

Referenced by get64(), headercolorTag(), headerFindSpec(), indexSane(), and tag2index().

◆ rpmtdNextUint64()

uint64_t * rpmtdNextUint64 ( rpmtd  td)

Iterate over uint64_t type tag data container.

Parameters
tdTag data container
Returns
Pointer to next value, NULL on termination or error

Definition at line 131 of file rpmtd.c.

References rpmtdGetUint64(), and rpmtdNext().

◆ rpmtdReset()

void rpmtdReset ( rpmtd  td)

(Re-)initialize tag data container.

Contents will be zeroed out and iteration index reset.

Parameters
tdTag data container

Definition at line 27 of file rpmtd.c.

References rpmtd_s::ix.

Referenced by hdrblobGet(), headerAddI18NString(), headerGet(), headerMergeLegacySigs(), headerNext(), headerPutType(), parseScript(), rpmdbIndexIteratorNextTd(), rpmGenerateSignature(), rpmSignFiles(), rpmSignVerity(), rpmTagGetNames(), rpmtdFreeData(), rpmtdNew(), and rpmtdSet().

◆ rpmtdSetIndex()

int rpmtdSetIndex ( rpmtd  td,
int  index 
)

Set iteration index of the container.

If new index is out of bounds for the container, -1 is returned and iteration index is left untouched.

Parameters
tdTag data container
indexNew index
Returns
New index, or -1 if index out of bounds

Definition at line 89 of file rpmtd.c.

References rpmtd_s::ix, and rpmtdCount().

Referenced by addTriggers(), checkInstalledFiles(), haveLangTag(), markReplacedFiles(), rpmdbFindByFile(), rpmRelocateFileList(), rpmScriptFromTriggerTag(), runFileTriggers(), and runImmedFileTriggers().

◆ rpmtdSetTag()

int rpmtdSetTag ( rpmtd  td,
rpmTagVal  tag 
)

Set container tag and type.

For empty container, any valid tag can be set. If the container has data, changing is only permitted to tag of same type.

Parameters
tdTag data container
tagNew tag
Returns
1 on success, 0 on error

Definition at line 257 of file rpmtd.c.

References rpmtd_s::count, rpmtd_s::data, RPM_NULL_TYPE, rpmTagGetTagType(), rpmtd_s::tag, and rpmtd_s::type.

Referenced by addPrefixes(), expandFilelist(), hdrFullFilelist(), and saveOrig().

◆ rpmtdSize()

rpm_count_t rpmtdSize ( rpmtd  td)

Retrieve container data size (eg required for allocation).

Note this currently only works for RPMTD_IMMUTABLE data.

Parameters
tdTag data container
Returns
Data size in bytes.

Definition at line 59 of file rpmtd.c.

References rpmtd_s::size.

Referenced by hex2binv().

◆ rpmtdTag()

rpmTagVal rpmtdTag ( rpmtd  td)

Retrieve tag of the container.

Parameters
tdTag data container
Returns
Rpm tag.

Definition at line 64 of file rpmtd.c.

References rpmtd_s::tag.

Referenced by haveSignature(), and rpmMergeHeaders().

◆ rpmtdToPool()

rpmsid * rpmtdToPool ( rpmtd  td,
rpmstrPool  pool 
)

Push string array container contents to a string pool, return string ids.

Parameters
tdTag data container
poolString pool
Returns
Array of string id's (malloced)

Definition at line 442 of file rpmtd.c.

References rpmtd_s::count, rpmtd_s::data, RPM_I18NSTRING_TYPE, RPM_STRING_ARRAY_TYPE, rpmstrPoolId(), rpmtd_s::type, and xmalloc.

Referenced by rpmdsNewPool(), rpmfnInit(), and tag2pool().

◆ rpmtdType()

rpmTagType rpmtdType ( rpmtd  td)

Retrieve type of the container.

Parameters
tdTag data container
Returns
Rpm tag type.

Definition at line 69 of file rpmtd.c.

References rpmtd_s::type.

Referenced by armorFormat(), get64(), logAddRemove(), tag2index(), and td2key().