# rpmdb/tagname.c File Reference

`#include "system.h"`
`#include <rpmio_internal.h>`
`#include <rpmmacro.h>`
`#include <argv.h>`
`#include <rpmtag.h>`
`#include "debug.h"`

Include dependency graph for tagname.c:

Go to the source code of this file.

## Defines
#define | _RPMTAG_INTERNAL
## Functions
static int | tagLoadATags (ARGV_t *argvp, int(*cmp)(const void *avp, const void *bvp))
| Load/sort arbitrary tags.
static int | tagCmpName (const void *avp, const void *bvp)
| Compare tag table entries by name.
static int | tagCmpValue (const void *avp, const void *bvp)
| Compare tag table entries by value.
static int | tagLoadIndex (headerTagTableEntry **ipp, size_t *np, int(*cmp)(const void *avp, const void *bvp))
| Load/sort a tag index.
static char * | _tagCanonicalize (const char *s)
static rpmTag | _tagGenerate (const char *s)
static const char * | _tagName (rpmTag tag)
static unsigned int | _tagType (rpmTag tag)
static rpmTag | _tagValue (const char *tagstr)
const char * | tagName (rpmTag tag)
| Return tag name from value.
unsigned int | tagType (rpmTag tag)
| Return tag data type from value.
rpmTag | tagValue (const char *tagstr)
| Return tag value from name.
char * | tagCanonicalize (const char *s)
| Canonicalize a rpmTag string.
rpmTag | tagGenerate (const char *s)
| Generate a tag from arbitrary string.
void | tagClean (headerTagIndices _rpmTags)
| Free memory in header tag indices.
tagStore_t | tagStoreFree (tagStore_t dbiTags, size_t dbiNTags)
| Destroy tagStore array.
## Variables
static struct headerTagIndices_s | _rpmTags
headerTagIndices | rpmTags = &_rpmTags

## Detailed Description

Definition in file tagname.c.

## Define Documentation

#define _RPMTAG_INTERNAL

Definition at line 10 of file tagname.c.

## Function Documentation

static char* _tagCanonicalize | ( | const char * | s | ) | `[static]`

Definition at line 110 of file tagname.c.

References xisalnum(), xmalloc(), xtolower(), and xtoupper().

Referenced by _tagValue().

static rpmTag _tagGenerate | ( | const char * | s | ) | `[static]`

Definition at line 137 of file tagname.c.

References _free(), PGPHASHALGO_SHA1, RPMDIGEST_NONE, rpmDigestFinal(), rpmDigestInit(), and rpmDigestUpdate().

Referenced by _tagValue().

static const char * _tagName | ( | rpmTag | tag | ) | `[static]`

Definition at line 183 of file tagname.c.

References _free(), RPMDBI_ADDED, RPMDBI_ARGLIST, RPMDBI_AVAILABLE, RPMDBI_DEPENDS, RPMDBI_FTSWALK, RPMDBI_HDLIST, RPMDBI_PACKAGES, RPMDBI_REMOVED, RPMTAG_CONFLICTS, RPMTAG_HDRID, snprintf(), tagCmpValue(), tagLoadATags(), tagLoadIndex(), and xcalloc().

static unsigned int _tagType | ( | rpmTag | tag | ) | `[static]`

Definition at line 279 of file tagname.c.

References RPMDBI_ADDED, RPMDBI_ARGLIST, RPMDBI_AVAILABLE, RPMDBI_DEPENDS, RPMDBI_FTSWALK, RPMDBI_HDLIST, RPMDBI_PACKAGES, RPMDBI_REMOVED, tagCmpValue(), tagLoadATags(), and tagLoadIndex().

static rpmTag _tagValue | ( | const char * | tagstr | ) | `[static]`

Definition at line 330 of file tagname.c.

References _free(), _tagCanonicalize(), _tagGenerate(), RPMDBI_ADDED, RPMDBI_ARGLIST, RPMDBI_AVAILABLE, RPMDBI_DEPENDS, RPMDBI_FTSWALK, RPMDBI_HDLIST, RPMDBI_PACKAGES, RPMDBI_REMOVED, tagCmpName(), tagLoadATags(), tagLoadIndex(), and xstrcasecmp().

char* tagCanonicalize | ( | const char * | s | ) |

Canonicalize a rpmTag string.

Parameters:

  | s | string

Returns:
  canonicalized string

Definition at line 406 of file tagname.c.

Referenced by fillOutMainPackage(), findPreambleTag(), and isPart().

void tagClean | ( | headerTagIndices | _rpmTags | ) |

Free memory in header tag indices.

Parameters:

  | _rpmTags | header tag indices (NULL uses rpmTags)

Definition at line 416 of file tagname.c.

References _free(), and argvFree().

Referenced by rpmcliFini().

static int tagCmpName | ( | const void * | avp,
|  | const void * | bvp |
| ) |  |  | `[static]`

Compare tag table entries by name.

Parameters:

  | *avp | tag table entry a
  | *bvp | tag table entry b

Returns:
  comparison

Definition at line 53 of file tagname.c.

Referenced by _tagValue().

static int tagCmpValue | ( | const void * | avp,
|  | const void * | bvp |
| ) |  |  | `[static]`

Compare tag table entries by value.

Parameters:

  | *avp | tag table entry a
  | *bvp | tag table entry b

Returns:
  comparison

Definition at line 67 of file tagname.c.

Referenced by _tagName(), and _tagType().

rpmTag tagGenerate | ( | const char * | s | ) |

Generate a tag from arbitrary string.

Parameters:

  | s | string

Returns:
  generated tag value

Definition at line 411 of file tagname.c.

Referenced by fillOutMainPackage(), findPreambleTag(), and isPart().

static int tagLoadATags | ( | ARGV_t * | argvp,
|  | int(*)(const void *avp, const void *bvp) | cmp |
| ) |  |  | `[static]`

Load/sort arbitrary tags.

Return values:

  | *argvp | arbitrary tag array

Returns:
  0 always

Definition at line 22 of file tagname.c.

References _free(), argvFree(), argvSort(), argvSplit(), rpmExpand(), and xcalloc().

Referenced by _tagName(), _tagType(), and _tagValue().

static int tagLoadIndex | ( | headerTagTableEntry ** | ipp,
|  | size_t * | np,
|  | int(*)(const void *avp, const void *bvp) | cmp |
| ) |  |  | `[static]`

Load/sort a tag index.

Return values:

  | *ipp | tag index
  | *np | no. of tags

Parameters:

  | cmp | sort compare routine

Returns:
  0 always

Definition at line 86 of file tagname.c.

References rpmTagTable, rpmTagTableSize, and xcalloc().

Referenced by _tagName(), _tagType(), and _tagValue().

const char* tagName | ( | rpmTag | tag | ) |

Return tag name from value.

Parameters:

  | tag | tag value

Returns:
  tag name, "(unknown)" on not found

Definition at line 391 of file tagname.c.

Referenced by checkForDuplicates(), checkForRequired(), dbiFindMatches(), dbiOpen(), findPreambleTag(), handlePreambleTag(), headerGet(), i18nTag(), isPart(), mapTagName(), miFreeHeader(), myTagName(), printNewSpecfile(), rpmdbAdd(), rpmdbCountPackages(), rpmdbFindByFile(), rpmdbGrowIterator(), rpmdbInitIterator(), rpmdbMoveDatabase(), rpmdbRemove(), rpmdbRemoveDatabase(), rpmdsMergePRCO(), rpmdsTagName(), rpmfcMergePR(), rpmgiInitFilter(), rpmgiNext(), sql_copen(), sql_initDB(), sql_open(), stashSt(), XrpmgiLink(), and XrpmgiUnlink().

tagStore_t tagStoreFree | ( | tagStore_t | dbiTags,
|  | size_t | dbiNTags |
| ) |  |  |

Destroy tagStore array.

Parameters:

  | dbiTags | dbi tag storage
  | dbiNTags | no. of dbi tags

Returns:
  NULL always

Definition at line 428 of file tagname.c.

References _free(), and freeStringBuf().

Referenced by dbiTagsInit(), freeSpec(), rpmdbClose(), and rpmdbRebuild().

unsigned int tagType | ( | rpmTag | tag | ) |

Return tag data type from value.

Todo:
  Return rpmTagType-like, not unsigned int. There's no clear typedef yet.

Parameters:

  | tag | tag value

Returns:
  tag data type, 0 on not found.

Definition at line 396 of file tagname.c.

Referenced by myTagName(), sql_bind_key(), sql_copen(), and sql_initDB().

rpmTag tagValue | ( | const char * | tagstr | ) |

Return tag value from name.

Parameters:

  | tagstr | name of tag

Returns:
  tag value, 0xffffffff on not found

Definition at line 401 of file tagname.c.

Referenced by dbiTagsInit(), initSourceHeader(), myTagValue(), rpmDisplayQueryTags(), rpmdsSysinfo(), rpmgiInitFilter(), and tagNumFromPyObject().

## Variable Documentation

struct headerTagIndices_s _rpmTags`[static]`

Initial value:

     {
        tagLoadIndex,
        NULL, 0, tagCmpName, _tagValue,
        NULL, 0, tagCmpValue, _tagName, _tagType,
        256, NULL, NULL, _tagCanonicalize, _tagGenerate
    }

Definition at line 170 of file tagname.c.

headerTagIndices rpmTags = &_rpmTags

Definition at line 179 of file tagname.c.

Referenced by findPreambleTag(), and isPart().