lib/formats.c File Reference

#include "system.h"
#include "rpmio_internal.h"
#include <rpmlib.h>
#include <rpmmacro.h>
#include <rpmds.h>
#include <rpmfi.h>
#include "legacy.h"
#include "manifest.h"
#include "argv.h"
#include "misc.h"
#include "fs.h"
#include "debug.h"

Include dependency graph for formats.c:

Go to the source code of this file.

Defines

#define _RPMEVR_INTERNAL

Functions

static char * triggertypeFormat (int_32 type, const void *data, char *formatPrefix, int padding, int element)
 Identify type of trigger.
static char * permsFormat (int_32 type, const void *data, char *formatPrefix, int padding, int element)
 Format file permissions for display.
static char * fflagsFormat (int_32 type, const void *data, char *formatPrefix, int padding, int element)
 Format file flags for display.
static char * armorFormat (int_32 type, const void *data, char *formatPrefix, int padding, int element)
 Wrap a pubkey in ascii armor for display.
static char * base64Format (int_32 type, const void *data, char *formatPrefix, int padding, int element)
 Encode binary data in base64 for display.
static size_t xmlstrlen (const char *s)
 Return length of string represented with xml characters substituted.
static char * xmlstrcpy (char *t, const char *s)
 Copy source string to target, substituting for xml characters.
static char * xmlFormat (int_32 type, const void *data, char *formatPrefix, int padding, int element)
 Wrap tag data in simple header xml markup.
static size_t yamlstrlen (const char *s, int lvl)
 Return length of string represented with yaml indentation.
static char * yamlstrcpy (char *t, const char *s, int lvl)
 Copy source string to target, indenting for yaml.
static char * yamlFormat (int_32 type, const void *data, char *formatPrefix, int padding, int element)
 Wrap tag data in simple header yaml markup.
static char * pgpsigFormat (int_32 type, const void *data, char *formatPrefix, int padding, int element)
 Display signature fingerprint and time.
static char * depflagsFormat (int_32 type, const void *data, char *formatPrefix, int padding, int element)
 Format dependency flags for display.
static int fsnamesTag (Header h, int_32 *type, void **data, int_32 *count, int *freeData)
 Retrieve mounted file system paths.
static int instprefixTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve install prefixes.
static int fssizesTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve mounted file system space.
static int triggercondsTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve trigger info.
static int triggertypeTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve trigger type info.
static int filenamesTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve file paths.
static int fileclassTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve file classes.
static int filecontextsTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve file contexts from header.
static int fscontextsTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve file contexts from file system.
static int recontextsTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve file contexts from policy RE's.
static int fileprovideTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve file provides.
static int filerequireTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve file requires.
static int missingokTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve Requires(missingok): array for Suggests: or Enhances:.
static int i18nTag (Header h, int_32 tag, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve i18n text.
static int localeTag (Header h, int_32 tag, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve text and convert to locale.
static int summaryTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve summary text.
static int descriptionTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve description text.
static int changelognameTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
static int changelogtextTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
static int groupTag (Header h, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve group text.

Variables

static const char * language = "LANGUAGE"
static const char * _macro_i18ndomains = "%{?_i18ndomains}"
headerSprintfExtension_s rpmHeaderFormats []
 Table of query format extensions.


Detailed Description

Definition in file formats.c.


Define Documentation

#define _RPMEVR_INTERNAL

Definition at line 11 of file formats.c.


Function Documentation

static char* armorFormat ( int_32  type,
const void *  data,
char *  formatPrefix,
int  padding,
int  element 
) [static]

Wrap a pubkey in ascii armor for display.

Todo:
Permit selectable display formats (i.e. binary).
Parameters:
type tag type
data tag value
formatPrefix (unused)
padding (unused)
element no. bytes of binary data
Returns:
formatted string

Definition at line 155 of file formats.c.

References _, PGPARMOR_PUBKEY, PGPARMOR_SIGNATURE, pgpArmorWrap(), 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_NULL_TYPE, RPM_OPENPGP_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, and xstrdup().

static char* base64Format ( int_32  type,
const void *  data,
char *  formatPrefix,
int  padding,
int  element 
) [static]

Encode binary data in base64 for display.

Todo:
Permit selectable display formats (i.e. binary).
Parameters:
type tag type
data tag value
formatPrefix (unused)
padding 
element 
Returns:
formatted string

Definition at line 207 of file formats.c.

References _, _free(), RPM_ASN1_TYPE, RPM_BIN_TYPE, RPM_OPENPGP_TYPE, stpcpy(), xcalloc(), and xstrdup().

Referenced by xmlFormat(), and yamlFormat().

static int changelognameTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Definition at line 1527 of file formats.c.

References localeTag(), and RPMTAG_CHANGELOGNAME.

static int changelogtextTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Definition at line 1537 of file formats.c.

References localeTag(), and RPMTAG_CHANGELOGTEXT.

static char* depflagsFormat ( int_32  type,
const void *  data,
char *  formatPrefix,
int  padding,
int  element 
) [static]

Format dependency flags for display.

Parameters:
type tag type
data tag value
formatPrefix 
padding 
element (unused)
Returns:
formatted string

Definition at line 772 of file formats.c.

References _, alloca(), RPM_INT32_TYPE, RPMSENSE_EQUAL, RPMSENSE_GREATER, RPMSENSE_LESS, RPMSENSE_SENSEMASK, stpcpy(), xmalloc(), and xstrdup().

Referenced by triggercondsTag().

static int descriptionTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve description text.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 1516 of file formats.c.

References i18nTag(), and RPMTAG_DESCRIPTION.

static char* fflagsFormat ( int_32  type,
const void *  data,
char *  formatPrefix,
int  padding,
int  element 
) [static]

Format file flags for display.

Parameters:
type tag type
data tag value
formatPrefix 
padding 
element (unused)
Returns:
formatted string

Definition at line 101 of file formats.c.

References _, RPM_INT32_TYPE, RPMFILE_CONFIG, RPMFILE_DOC, RPMFILE_GHOST, RPMFILE_LICENSE, RPMFILE_MISSINGOK, RPMFILE_NOREPLACE, RPMFILE_README, RPMFILE_SPECFILE, xmalloc(), and xstrdup().

static int fileclassTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve file classes.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 1124 of file formats.c.

References RPM_STRING_ARRAY_TYPE, and rpmfiBuildFClasses().

static int filecontextsTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve file contexts from header.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 1148 of file formats.c.

References RPM_STRING_ARRAY_TYPE, and rpmfiBuildFContexts().

static int filenamesTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve file paths.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 1102 of file formats.c.

References RPM_STRING_ARRAY_TYPE, rpmfiBuildFNames(), and RPMTAG_BASENAMES.

static int fileprovideTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve file provides.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 1220 of file formats.c.

References RPM_STRING_ARRAY_TYPE, rpmfiBuildFDeps(), and RPMTAG_PROVIDENAME.

static int filerequireTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve file requires.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 1244 of file formats.c.

References RPM_STRING_ARRAY_TYPE, rpmfiBuildFDeps(), and RPMTAG_REQUIRENAME.

static int fscontextsTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve file contexts from file system.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 1172 of file formats.c.

References RPM_STRING_ARRAY_TYPE, and rpmfiBuildFSContexts().

static int fsnamesTag ( Header  h,
int_32 type,
void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve mounted file system paths.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 833 of file formats.c.

References RPM_STRING_ARRAY_TYPE, and rpmGetFilesystemList().

static int fssizesTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve mounted file system space.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 903 of file formats.c.

References _free(), headerGetEntryMinMemory(), RPM_INT64_TYPE, rpmfiBuildFNames(), rpmGetFilesystemList(), rpmGetFilesystemUsage(), RPMTAG_BASENAMES, RPMTAG_FILESIZES, and xcalloc().

static int groupTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve group text.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 1556 of file formats.c.

References i18nTag(), and RPMTAG_GROUP.

static int i18nTag ( Header  h,
int_32  tag,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve i18n text.

Parameters:
h header
tag tag
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 1347 of file formats.c.

References _free(), _macro_i18ndomains, alloca(), dgettext, getenv(), headerGetEntryMinMemory(), headerNVR(), language, RPM_STRING_TYPE, rpmExpand(), setenv(), tagName(), unsetenv(), xstrdup(), and xstrtolocale().

Referenced by descriptionTag(), groupTag(), and summaryTag().

static int instprefixTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve install prefixes.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 865 of file formats.c.

References headerFreeData(), headerGetEntryMinMemory(), RPM_STRING_TYPE, RPMTAG_INSTALLPREFIX, RPMTAG_INSTPREFIXES, and xstrdup().

static int localeTag ( Header  h,
int_32  tag,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve text and convert to locale.

Definition at line 1439 of file formats.c.

References _free(), headerGetEntryMinMemory(), RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, xmalloc(), xstrdup(), and xstrtolocale().

Referenced by changelognameTag(), and changelogtextTag().

static int missingokTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve Requires(missingok): array for Suggests: or Enhances:.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 1268 of file formats.c.

References argvAdd(), argvFree(), RPM_STRING_ARRAY_TYPE, rpmdsDNEVR(), rpmdsFlags(), rpmdsFree(), rpmdsInit(), rpmdsNew(), rpmdsNext(), RPMTAG_REQUIRENAME, stpcpy(), and xcalloc().

static char* permsFormat ( int_32  type,
const void *  data,
char *  formatPrefix,
int  padding,
int  element 
) [static]

Format file permissions for display.

Parameters:
type tag type
data tag value
formatPrefix 
padding 
element (unused)
Returns:
formatted string

Definition at line 67 of file formats.c.

References _, _free(), RPM_INT32_TYPE, rpmPermsString(), xmalloc(), and xstrdup().

static char* pgpsigFormat ( int_32  type,
const void *  data,
char *  formatPrefix,
int  padding,
int  element 
) [static]

Display signature fingerprint and time.

Parameters:
type tag type
data tag value
formatPrefix (unused)
padding 
element (unused)
Returns:
formatted string

Definition at line 659 of file formats.c.

References _, pgpDigParams_s::hash_algo, pgpFreeDig(), pgpGrab(), PGPHASHALGO_MD5, PGPHASHALGO_SHA1, pgpHexStr(), pgpLen(), pgpNewDig(), pgpPrtPkts(), PGPPUBKEYALGO_DSA, PGPPUBKEYALGO_RSA, PGPTAG_SIGNATURE, pgpDigParams_s::pubkey_algo, RPM_ASN1_TYPE, RPM_BIN_TYPE, RPM_OPENPGP_TYPE, pgpDig_s::signature, pgpDigParams_s::signid, snprintf(), stpcpy(), pgpDigParams_s::time, xrealloc(), and xstrdup().

static int recontextsTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve file contexts from policy RE's.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 1196 of file formats.c.

References RPM_STRING_ARRAY_TYPE, and rpmfiBuildREContexts().

static int summaryTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve summary text.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 1496 of file formats.c.

References i18nTag(), and RPMTAG_SUMMARY.

static int triggercondsTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve trigger info.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 963 of file formats.c.

References _free(), depflagsFormat(), headerFreeData(), headerGetEntryMinMemory(), RPM_INT32_TYPE, RPM_STRING_ARRAY_TYPE, RPMSENSE_SENSEMASK, RPMTAG_TRIGGERFLAGS, RPMTAG_TRIGGERINDEX, RPMTAG_TRIGGERNAME, RPMTAG_TRIGGERSCRIPTS, RPMTAG_TRIGGERVERSION, xmalloc(), xrealloc(), and xstrdup().

static char* triggertypeFormat ( int_32  type,
const void *  data,
char *  formatPrefix,
int  padding,
int  element 
) [static]

Identify type of trigger.

Parameters:
type tag type
data tag value
formatPrefix (unused)
padding (unused)
element (unused)
Returns:
formatted string

Definition at line 35 of file formats.c.

References _, RPM_INT32_TYPE, and xstrdup().

static int triggertypeTag ( Header  h,
rpmTagType type,
const void **  data,
int_32 count,
int *  freeData 
) [static]

Retrieve trigger type info.

Parameters:
h header
Return values:
*type tag type
*data tag value
*count no. of data items
*freeData data-was-malloc'ed indicator
Returns:
0 on success

Definition at line 1040 of file formats.c.

References headerFreeData(), headerGetEntryMinMemory(), RPM_STRING_ARRAY_TYPE, RPMTAG_TRIGGERFLAGS, RPMTAG_TRIGGERINDEX, RPMTAG_TRIGGERSCRIPTS, xmalloc(), and xstrdup().

static char* xmlFormat ( int_32  type,
const void *  data,
char *  formatPrefix,
int  padding,
int  element 
) [static]

Wrap tag data in simple header xml markup.

Parameters:
type tag type
data tag value
formatPrefix 
padding 
element (unused)
Returns:
formatted string

Definition at line 313 of file formats.c.

References _, _free(), alloca(), base64Format(), 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_NULL_TYPE, RPM_OPENPGP_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, snprintf(), stpcpy(), xmalloc(), xmlstrcpy(), xmlstrlen(), xstrdup(), and xstrtolocale().

static char* xmlstrcpy ( char *  t,
const char *  s 
) [static]

Copy source string to target, substituting for xml characters.

Parameters:
t target xml string
s source string
Returns:
target xml string

Definition at line 283 of file formats.c.

References stpcpy().

Referenced by xmlFormat().

static size_t xmlstrlen ( const char *  s  )  [static]

Return length of string represented with xml characters substituted.

Parameters:
s string
Returns:
length of xml string

Definition at line 257 of file formats.c.

Referenced by xmlFormat().

static char* yamlFormat ( int_32  type,
const void *  data,
char *  formatPrefix,
int  padding,
int  element 
) [static]

Wrap tag data in simple header yaml markup.

Parameters:
type tag type
data tag value
formatPrefix 
padding 
element element index (or -1 for non-array).
Returns:
formatted string

Definition at line 492 of file formats.c.

References _, _free(), alloca(), base64Format(), 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_NULL_TYPE, RPM_OPENPGP_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, snprintf(), stpcpy(), xmalloc(), xstrdup(), xstrtolocale(), yamlstrcpy(), and yamlstrlen().

static char* yamlstrcpy ( char *  t,
const char *  s,
int  lvl 
) [static]

Copy source string to target, indenting for yaml.

Parameters:
t target yaml string
s source string
lvl indentation level
Returns:
target yaml string

Definition at line 456 of file formats.c.

References indent.

Referenced by yamlFormat().

static size_t yamlstrlen ( const char *  s,
int  lvl 
) [static]

Return length of string represented with yaml indentation.

Parameters:
s string
lvl indentation level
Returns:
length of yaml string

Definition at line 427 of file formats.c.

References indent.

Referenced by yamlFormat().


Variable Documentation

const char* _macro_i18ndomains = "%{?_i18ndomains}" [static]

Definition at line 1335 of file formats.c.

Referenced by i18nTag().

const char* language = "LANGUAGE" [static]

Definition at line 1332 of file formats.c.

Referenced by i18nTag().

struct headerSprintfExtension_s rpmHeaderFormats[]

Table of query format extensions.

Note:
Chains to headerDefaultFormats[].

Definition at line 1568 of file formats.c.

Referenced by hdr_subscript(), hdrPrintErased(), hdrPrintInstalled(), hdrSprintf(), init_rpm(), packageBinaries(), printNewSpecfile(), queryHeader(), rpmcliImportPubkey(), rpmDisplayQueryTags(), rpmHeaderGetEntry(), rpmpsmStage(), rpmShowProgress(), rpmtsSolve(), and runScript().


Generated on Wed Feb 6 22:32:08 2008 for rpm by  doxygen 1.5.1