rpmTagFoo() getters take arbitrary integers, not rpmTag enums

- Another step to clean up the enum braindamage...
- rpmTag values are the only values that will be found, but it doesn't
  mean the values passed are rpmTag enum members - eg anything from
  a header is not. rpmTagGetValue() does come close to returning true
  enums, but there's RPMDBI_PACKAGES and then RPMTAG_NOT_FOUND, neither
  of which are actually tags.
- Introducing a new rpmTagVal typedef. It's just an alias for the
  "lowlevel" rpm_tag_t type but visually more in line with the other
  rpmTagFoo bits - to be used with the "higher level" tags whereas
  rpm_tag_t is the "physical" type. Not that it makes any difference...
This commit is contained in:
Panu Matilainen 2010-10-22 09:40:43 +03:00
parent 4b1e482983
commit 935d0654a6
3 changed files with 23 additions and 22 deletions

View File

@ -397,42 +397,42 @@ typedef rpmFlags rpmTagReturnType;
* @param tag tag value
* @return tag name, "(unknown)" on not found
*/
const char * rpmTagGetName(rpmTag tag);
const char * rpmTagGetName(rpmTagVal tag);
/** \ingroup rpmtag
* Return tag data type from value.
* @param tag tag value
* @return tag data type + return type, RPM_NULL_TYPE on not found.
*/
rpmTagType rpmTagGetType(rpmTag tag);
rpmTagType rpmTagGetType(rpmTagVal tag);
/** \ingroup rpmtag
* Return tag data type from value.
* @param tag tag value
* @return tag data type, RPM_NULL_TYPE on not found.
*/
rpmTagType rpmTagGetTagType(rpmTag tag);
rpmTagType rpmTagGetTagType(rpmTagVal tag);
/** \ingroup rpmtag
* Return tag data type from value.
* @param tag tag value
* @return tag data return type, RPM_NULL_TYPE on not found.
*/
rpmTagReturnType rpmTagGetReturnType(rpmTag tag);
rpmTagReturnType rpmTagGetReturnType(rpmTagVal tag);
/** \ingroup rpmtag
* Return tag data class from value.
* @param tag tag value
* @return tag data class, RPM_NULL_CLASS on not found.
*/
rpmTagClass rpmTagGetClass(rpmTag tag);
rpmTagClass rpmTagGetClass(rpmTagVal tag);
/** \ingroup rpmtag
* Return tag value from name.
* @param tagstr name of tag
* @return tag value, -1 on not found
*/
rpmTag rpmTagGetValue(const char * tagstr);
rpmTagVal rpmTagGetValue(const char * tagstr);
/** \ingroup rpmtag
* Return data class of type

View File

@ -27,6 +27,7 @@ typedef struct headerIterator_s * HeaderIterator;
typedef int32_t rpm_tag_t;
typedef uint32_t rpm_tagtype_t;
typedef uint32_t rpm_count_t;
typedef rpm_tag_t rpmTagVal;
typedef void * rpm_data_t;
typedef const void * rpm_constdata_t;

View File

@ -15,7 +15,7 @@ typedef const struct headerTagTableEntry_s * headerTagTableEntry;
struct headerTagTableEntry_s {
const char * name; /*!< Tag name. */
const char * shortname; /*!< "Human readable" short name. */
rpmTag val; /*!< Tag numeric value. */
rpmTagVal val; /*!< Tag numeric value. */
rpmTagType type; /*!< Tag type. */
rpmTagReturnType retype; /*!< Tag return type. */
int extension; /*!< Extension or "real" tag */
@ -36,12 +36,12 @@ struct headerTagIndices_s {
headerTagTableEntry * byName; /*!< header tags sorted by name. */
int byNameSize; /*!< no. of entries. */
int (*byNameCmp) (const void * avp, const void * bvp); /*!< compare entries by name. */
rpmTag (*tagValue) (const char * name); /* return value from name. */
rpmTagVal (*tagValue) (const char * name); /* return value from name. */
headerTagTableEntry * byValue; /*!< header tags sorted by value. */
int byValueSize; /*!< no. of entries. */
int (*byValueCmp) (const void * avp, const void * bvp); /*!< compare entries by value. */
const char * (*tagName) (rpmTag value); /* Return name from value. */
rpmTagType (*tagType) (rpmTag value); /* Return type from value. */
const char * (*tagName) (rpmTagVal value); /* Return name from value. */
rpmTagType (*tagType) (rpmTagVal value); /* Return type from value. */
};
/**
@ -104,9 +104,9 @@ assert(n == rpmTagTableSize);
/* forward refs */
static const char * _tagName(rpmTag tag);
static rpmTagType _tagType(rpmTag tag);
static rpmTag _tagValue(const char * tagstr);
static const char * _tagName(rpmTagVal tag);
static rpmTagType _tagType(rpmTagVal tag);
static rpmTagVal _tagValue(const char * tagstr);
static struct headerTagIndices_s _rpmTags = {
tagLoadIndex,
@ -116,7 +116,7 @@ static struct headerTagIndices_s _rpmTags = {
static headerTagIndices const rpmTags = &_rpmTags;
static const char * _tagName(rpmTag tag)
static const char * _tagName(rpmTagVal tag)
{
const char *name = "(unknown)";
const struct headerTagTableEntry_s *t;
@ -169,7 +169,7 @@ static const char * _tagName(rpmTag tag)
return name;
}
static rpmTagType _tagType(rpmTag tag)
static rpmTagType _tagType(rpmTagVal tag)
{
const struct headerTagTableEntry_s *t;
int comparison, i, l, u;
@ -204,7 +204,7 @@ static rpmTagType _tagType(rpmTag tag)
return RPM_NULL_TYPE;
}
static rpmTag _tagValue(const char * tagstr)
static rpmTagVal _tagValue(const char * tagstr)
{
const struct headerTagTableEntry_s *t;
int comparison, i, l, u;
@ -236,22 +236,22 @@ static rpmTag _tagValue(const char * tagstr)
return RPMTAG_NOT_FOUND;
}
const char * rpmTagGetName(rpmTag tag)
const char * rpmTagGetName(rpmTagVal tag)
{
return ((*rpmTags->tagName)(tag));
}
rpmTagType rpmTagGetType(rpmTag tag)
rpmTagType rpmTagGetType(rpmTagVal tag)
{
return ((*rpmTags->tagType)(tag));
}
rpmTagType rpmTagGetTagType(rpmTag tag)
rpmTagType rpmTagGetTagType(rpmTagVal tag)
{
return (rpmTagType)((*rpmTags->tagType)(tag) & RPM_MASK_TYPE);
}
rpmTagReturnType rpmTagGetReturnType(rpmTag tag)
rpmTagReturnType rpmTagGetReturnType(rpmTagVal tag)
{
return ((*rpmTags->tagType)(tag) & RPM_MASK_RETURN_TYPE);
}
@ -283,12 +283,12 @@ rpmTagClass rpmTagTypeGetClass(rpmTagType type)
return tclass;
}
rpmTagClass rpmTagGetClass(rpmTag tag)
rpmTagClass rpmTagGetClass(rpmTagVal tag)
{
return rpmTagTypeGetClass(rpmTagGetTagType(tag));
}
rpmTag rpmTagGetValue(const char * tagstr)
rpmTagVal rpmTagGetValue(const char * tagstr)
{
return ((*rpmTags->tagValue)(tagstr));
}