diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2010-10-22 09:40:43 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2010-10-22 09:40:43 +0300 |
commit | 935d0654a612c28494d104f168f00e18f411d247 (patch) | |
tree | 735dbb0910125a8393d305b644a812a41e08e797 /lib | |
parent | 4b1e48298324cab35e5cac030dac06e7f37bf66b (diff) | |
download | librpm-tizen-935d0654a612c28494d104f168f00e18f411d247.tar.gz librpm-tizen-935d0654a612c28494d104f168f00e18f411d247.tar.bz2 librpm-tizen-935d0654a612c28494d104f168f00e18f411d247.zip |
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...
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rpmtag.h | 12 | ||||
-rw-r--r-- | lib/rpmtypes.h | 1 | ||||
-rw-r--r-- | lib/tagname.c | 32 |
3 files changed, 23 insertions, 22 deletions
diff --git a/lib/rpmtag.h b/lib/rpmtag.h index 414dfa58f..ae9f7b926 100644 --- a/lib/rpmtag.h +++ b/lib/rpmtag.h @@ -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 diff --git a/lib/rpmtypes.h b/lib/rpmtypes.h index 5e4937528..936546a14 100644 --- a/lib/rpmtypes.h +++ b/lib/rpmtypes.h @@ -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; diff --git a/lib/tagname.c b/lib/tagname.c index c8477281b..adc717876 100644 --- a/lib/tagname.c +++ b/lib/tagname.c @@ -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)); } |