lib/formats.c File Reference

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

Go to the source code of this file.

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)
static char * xmlstrcpy (char *t, const char *s)
static char * xmlFormat (int_32 type, const void *data, char *formatPrefix, int padding, int element)
 Wrap tag data in simple header xml 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 i18nTag (Header h, int_32 tag, rpmTagType *type, const void **data, int_32 *count, int *freeData)
 Retrieve i18n text.
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 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.


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 150 of file formats.c.

References _, PGPARMOR_PUBKEY, PGPARMOR_SIGNATURE, pgpArmorWrap(), RPM_BIN_TYPE, RPM_CHAR_TYPE, RPM_I18NSTRING_TYPE, RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_INT8_TYPE, RPM_NULL_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 199 of file formats.c.

References _, _free(), RPM_BIN_TYPE, stpcpy(), xmalloc(), and xstrdup().

Referenced by xmlFormat().

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 510 of file formats.c.

References _, RPM_INT32_TYPE, RPMSENSE_EQUAL, RPMSENSE_GREATER, RPMSENSE_LESS, 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 1122 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 96 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 846 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 870 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 824 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 942 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 966 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 894 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 555 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 625 of file formats.c.

References _free(), headerGetEntryMinMemory(), RPM_INT32_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 1142 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 1005 of file formats.c.

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

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 587 of file formats.c.

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

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 62 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 397 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_BIN_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 918 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 1102 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 685 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 30 of file formats.c.

References _, RPM_INT32_TYPE, RPMSENSE_TRIGGERIN, RPMSENSE_TRIGGERPOSTUN, RPMSENSE_TRIGGERPREIN, RPMSENSE_TRIGGERUN, 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 762 of file formats.c.

References headerFreeData(), headerGetEntryMinMemory(), RPM_STRING_ARRAY_TYPE, RPMSENSE_TRIGGERIN, RPMSENSE_TRIGGERPOSTUN, RPMSENSE_TRIGGERPREIN, RPMSENSE_TRIGGERUN, 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 292 of file formats.c.

References _, _free(), alloca(), base64Format(), RPM_BIN_TYPE, RPM_CHAR_TYPE, RPM_I18NSTRING_TYPE, RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_INT8_TYPE, RPM_NULL_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, snprintf(), stpcpy(), xmalloc(), xmlstrcpy(), xmlstrlen(), and xstrdup().

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

Definition at line 262 of file formats.c.

References stpcpy().

Referenced by xmlFormat().

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

Definition at line 241 of file formats.c.

Referenced by xmlFormat().


Variable Documentation

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

Definition at line 993 of file formats.c.

Referenced by i18nTag().

const char* language = "LANGUAGE" [static]

Definition at line 990 of file formats.c.

Referenced by i18nTag().

struct headerSprintfExtension_s rpmHeaderFormats[]

Initial value:

 {
    { HEADER_EXT_TAG, "RPMTAG_GROUP",           { groupTag } },
    { HEADER_EXT_TAG, "RPMTAG_DESCRIPTION",     { descriptionTag } },
    { HEADER_EXT_TAG, "RPMTAG_SUMMARY",         { summaryTag } },
    { HEADER_EXT_TAG, "RPMTAG_FILECLASS",       { fileclassTag } },
    { HEADER_EXT_TAG, "RPMTAG_FILECONTEXTS",    { filecontextsTag } },
    { HEADER_EXT_TAG, "RPMTAG_FILENAMES",       { filenamesTag } },
    { HEADER_EXT_TAG, "RPMTAG_FILEPROVIDE",     { fileprovideTag } },
    { HEADER_EXT_TAG, "RPMTAG_FILEREQUIRE",     { filerequireTag } },
    { HEADER_EXT_TAG, "RPMTAG_FSCONTEXTS",      { fscontextsTag } },
    { HEADER_EXT_TAG, "RPMTAG_FSNAMES",         { fsnamesTag } },
    { HEADER_EXT_TAG, "RPMTAG_FSSIZES",         { fssizesTag } },
    { HEADER_EXT_TAG, "RPMTAG_INSTALLPREFIX",   { instprefixTag } },
    { HEADER_EXT_TAG, "RPMTAG_RECONTEXTS",      { recontextsTag } },
    { HEADER_EXT_TAG, "RPMTAG_TRIGGERCONDS",    { triggercondsTag } },
    { HEADER_EXT_TAG, "RPMTAG_TRIGGERTYPE",     { triggertypeTag } },
    { HEADER_EXT_FORMAT, "armor",               { armorFormat } },
    { HEADER_EXT_FORMAT, "base64",              { base64Format } },
    { HEADER_EXT_FORMAT, "pgpsig",              { pgpsigFormat } },
    { HEADER_EXT_FORMAT, "depflags",            { depflagsFormat } },
    { HEADER_EXT_FORMAT, "fflags",              { fflagsFormat } },
    { HEADER_EXT_FORMAT, "perms",               { permsFormat } },
    { HEADER_EXT_FORMAT, "permissions",         { permsFormat } },
    { HEADER_EXT_FORMAT, "triggertype",         { triggertypeFormat } },
    { HEADER_EXT_FORMAT, "xml",                 { xmlFormat } },
    { HEADER_EXT_MORE, NULL,            { (void *) headerDefaultFormats } }
}
Table of query format extensions.

Note:
Chains to headerDefaultFormats[].

Definition at line 1154 of file formats.c.

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


Generated on Fri Oct 12 08:44:55 2007 for rpm by  doxygen 1.5.2