Switch header APIs to use rpmTagVal instead of rpmTag

- The header getters are used for both signature header and the "normal"
  header, and even beyond that there's no requirement for a tag in
  the header to be part of rpmTag enum. The headerPutFoo() variants
  technically do require the tag to be found in the tag table (ie be
  an rpmTag) but they still operate on the integer value, they dont
  require it to be a "true" enum.
- Inside tagexts.c there are a few "true" enum uses in the
  internal helper functions, leave them be.
- While this technically changes some the most commonly used API's,
  this wont affect callers really: if the callers were using an enum
  before, enum can always be cast naturally to an integer. The other
  way around was the problematic part (ie the braindamage we're fixing
  here now...)
This commit is contained in:
Panu Matilainen 2010-10-22 09:48:24 +03:00
parent 935d0654a6
commit 757d0b443b
8 changed files with 65 additions and 65 deletions

View File

@ -719,7 +719,7 @@ void * headerUnload(Header h)
* @return header entry
*/
static
indexEntry findEntry(Header h, rpmTag tag, rpmTagType type)
indexEntry findEntry(Header h, rpmTagVal tag, rpmTagType type)
{
indexEntry entry;
struct indexEntry_s key;
@ -746,7 +746,7 @@ indexEntry findEntry(Header h, rpmTag tag, rpmTagType type)
return NULL;
}
int headerDel(Header h, rpmTag tag)
int headerDel(Header h, rpmTagVal tag)
{
indexEntry last = h->index + h->indexUsed;
indexEntry entry, first;
@ -915,7 +915,7 @@ errxit:
return h;
}
Header headerReload(Header h, rpmTag tag)
Header headerReload(Header h, rpmTagVal tag)
{
Header nh;
size_t length;
@ -1044,7 +1044,7 @@ exit:
return (nb == length ? 0 : 1);
}
int headerIsEntry(Header h, rpmTag tag)
int headerIsEntry(Header h, rpmTagVal tag)
{
/* FIX: h modified by sort. */
return (findEntry(h, tag, RPM_NULL_TYPE) ? 1 : 0);
@ -1339,7 +1339,7 @@ static int intGetTdEntry(Header h, rpmtd td, headerGetFlags flags)
return ((rc == 1) ? 1 : 0);
}
int headerGet(Header h, rpmTag tag, rpmtd td, headerGetFlags flags)
int headerGet(Header h, rpmTagVal tag, rpmtd td, headerGetFlags flags)
{
int rc;
headerTagTagFunction tagfunc = intGetTdEntry;
@ -1505,7 +1505,7 @@ int headerPut(Header h, rpmtd td, headerPutFlags flags)
return rc;
}
int headerAddI18NString(Header h, rpmTag tag, const char * string,
int headerAddI18NString(Header h, rpmTagVal tag, const char * string,
const char * lang)
{
indexEntry table, entry;
@ -1728,7 +1728,7 @@ static indexEntry nextIndex(HeaderIterator hi)
return entry;
}
rpmTag headerNextTag(HeaderIterator hi)
rpmTagVal headerNextTag(HeaderIterator hi)
{
indexEntry entry = nextIndex(hi);
return entry ? entry->info.tag : RPMTAG_NOT_FOUND;

View File

@ -99,7 +99,7 @@ void * headerUnload(Header h);
* @param tag region tag
* @return on-disk header (with offsets)
*/
Header headerReload(Header h, rpmTag tag);
Header headerReload(Header h, rpmTagVal tag);
/** \ingroup header
* Duplicate a header.
@ -145,7 +145,7 @@ int headerWrite(FD_t fd, Header h, enum hMagic magicp);
* @param tag tag
* @return 1 on success, 0 on failure
*/
int headerIsEntry(Header h, rpmTag tag);
int headerIsEntry(Header h, rpmTagVal tag);
/** \ingroup header
* Modifier flags for headerGet() operation.
@ -175,7 +175,7 @@ typedef rpmFlags headerGetFlags;
* @param flags retrieval modifier flags
* @return 1 on success, 0 on failure
*/
int headerGet(Header h, rpmTag tag, rpmtd td, headerGetFlags flags);
int headerGet(Header h, rpmTagVal tag, rpmtd td, headerGetFlags flags);
enum headerPutFlags_e {
@ -218,14 +218,14 @@ int headerPut(Header h, rpmtd td, headerPutFlags flags);
* @return 1 on success, 0 on failure
*
*/
int headerPutString(Header h, rpmTag tag, const char *val);
int headerPutStringArray(Header h, rpmTag tag, const char **val, rpm_count_t size);
int headerPutBin(Header h, rpmTag tag, const uint8_t *val, rpm_count_t size);
int headerPutChar(Header h, rpmTag tag, const char *val, rpm_count_t size);
int headerPutUint8(Header h, rpmTag tag, const uint8_t *val, rpm_count_t size);
int headerPutUint16(Header h, rpmTag tag, const uint16_t *val, rpm_count_t size);
int headerPutUint32(Header h, rpmTag tag, const uint32_t *val, rpm_count_t size);
int headerPutUint64(Header h, rpmTag tag, const uint64_t *val, rpm_count_t size);
int headerPutString(Header h, rpmTagVal tag, const char *val);
int headerPutStringArray(Header h, rpmTagVal tag, const char **val, rpm_count_t size);
int headerPutBin(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size);
int headerPutChar(Header h, rpmTagVal tag, const char *val, rpm_count_t size);
int headerPutUint8(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size);
int headerPutUint16(Header h, rpmTagVal tag, const uint16_t *val, rpm_count_t size);
int headerPutUint32(Header h, rpmTagVal tag, const uint32_t *val, rpm_count_t size);
int headerPutUint64(Header h, rpmTagVal tag, const uint64_t *val, rpm_count_t size);
/** @} */
/** \ingroup header
@ -248,7 +248,7 @@ int headerPutUint64(Header h, rpmTag tag, const uint64_t *val, rpm_count_t size)
* @param lang locale
* @return 1 on success, 0 on failure
*/
int headerAddI18NString(Header h, rpmTag tag, const char * string,
int headerAddI18NString(Header h, rpmTagVal tag, const char * string,
const char * lang);
/** \ingroup header
@ -269,7 +269,7 @@ int headerMod(Header h, rpmtd td);
* @param tag tag
* @return 0 on success, 1 on failure (INCONSISTENT)
*/
int headerDel(Header h, rpmTag tag);
int headerDel(Header h, rpmTagVal tag);
/** \ingroup header
* Return formatted output string from header tags.
@ -289,7 +289,7 @@ char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
* @param tagstocopy array of tags that are copied
*/
void headerCopyTags(Header headerFrom, Header headerTo,
const rpmTag * tagstocopy);
const rpmTagVal * tagstocopy);
/** \ingroup header
* Destroy header tag iterator.
@ -318,7 +318,7 @@ int headerNext(HeaderIterator hi, rpmtd td);
* @param hi header tag iterator
* @return next tag, RPMTAG_NOT_FOUND to stop iteration
*/
rpmTag headerNextTag(HeaderIterator hi);
rpmTagVal headerNextTag(HeaderIterator hi);
/** \ingroup header
* Return name, version, release strings from header.
@ -385,7 +385,7 @@ char * headerGetEVR(Header h, const char **np);
* @param tag tag to retrieve
* @return string pointer (malloced) or NULL on failure
*/
char * headerGetAsString(Header h, rpmTag tag);
char * headerGetAsString(Header h, rpmTagVal tag);
/** \ingroup header
* Return a simple string tag from header
@ -393,7 +393,7 @@ char * headerGetAsString(Header h, rpmTag tag);
* @param tag tag to retrieve
* @return string pointer (to header memory) or NULL on failure
*/
const char * headerGetString(Header h, rpmTag tag);
const char * headerGetString(Header h, rpmTagVal tag);
/* \ingroup header
* Return a simple number tag (or extension) from header
@ -401,7 +401,7 @@ const char * headerGetString(Header h, rpmTag tag);
* @param tag tag to retrieve
* @return numeric tag value or 0 on failure
*/
uint64_t headerGetNumber(Header h, rpmTag tag);
uint64_t headerGetNumber(Header h, rpmTagVal tag);
/** \ingroup header
* Return header color.

View File

@ -21,7 +21,7 @@
typedef struct sprintfTag_s * sprintfTag;
struct sprintfTag_s {
headerTagFormatFunction fmt;
rpmTag tag;
rpmTagVal tag;
int justOne;
char * format;
char * type;
@ -566,7 +566,7 @@ static int parseExpression(headerSprintfArgs hsa, sprintfToken token,
return 0;
}
static rpmtd getCached(rpmtd *cache, rpmTag tag)
static rpmtd getCached(rpmtd *cache, rpmTagVal tag)
{
rpmtd td = NULL;
@ -585,7 +585,7 @@ static rpmtd getCached(rpmtd *cache, rpmTag tag)
* @retval *countptr
* @return 1 on success, 0 on failure
*/
static rpmtd getData(headerSprintfArgs hsa, rpmTag tag)
static rpmtd getData(headerSprintfArgs hsa, rpmTagVal tag)
{
rpmtd td = NULL;

View File

@ -88,9 +88,9 @@ Header headerCopy(Header h)
}
void headerCopyTags(Header headerFrom, Header headerTo,
const rpmTag * tagstocopy)
const rpmTagVal * tagstocopy)
{
const rpmTag * p;
const rpmTagVal * p;
struct rpmtd_s td;
if (headerFrom == headerTo)
@ -106,7 +106,7 @@ void headerCopyTags(Header headerFrom, Header headerTo,
}
}
char * headerGetAsString(Header h, rpmTag tag)
char * headerGetAsString(Header h, rpmTagVal tag)
{
char *res = NULL;
struct rpmtd_s td;
@ -120,7 +120,7 @@ char * headerGetAsString(Header h, rpmTag tag)
return res;
}
const char * headerGetString(Header h, rpmTag tag)
const char * headerGetString(Header h, rpmTagVal tag)
{
const char *res = NULL;
struct rpmtd_s td;
@ -134,7 +134,7 @@ const char * headerGetString(Header h, rpmTag tag)
return res;
}
uint64_t headerGetNumber(Header h, rpmTag tag)
uint64_t headerGetNumber(Header h, rpmTagVal tag)
{
uint64_t res = 0;
struct rpmtd_s td;
@ -152,7 +152,7 @@ uint64_t headerGetNumber(Header h, rpmTag tag)
* Sanity check data types against tag table before putting. Assume
* append on all array-types.
*/
static int headerPutType(Header h, rpmTag tag, rpmTagType reqtype,
static int headerPutType(Header h, rpmTagVal tag, rpmTagType reqtype,
rpm_constdata_t data, rpm_count_t size)
{
struct rpmtd_s td;
@ -191,7 +191,7 @@ static int headerPutType(Header h, rpmTag tag, rpmTagType reqtype,
return valid;
}
int headerPutString(Header h, rpmTag tag, const char *val)
int headerPutString(Header h, rpmTagVal tag, const char *val)
{
rpmTagType type = rpmTagGetTagType(tag);
const void *sptr = NULL;
@ -208,37 +208,37 @@ int headerPutString(Header h, rpmTag tag, const char *val)
return headerPutType(h, tag, type, sptr, 1);
}
int headerPutStringArray(Header h, rpmTag tag, const char **array, rpm_count_t size)
int headerPutStringArray(Header h, rpmTagVal tag, const char **array, rpm_count_t size)
{
return headerPutType(h, tag, RPM_STRING_ARRAY_TYPE, array, size);
}
int headerPutChar(Header h, rpmTag tag, const char *val, rpm_count_t size)
int headerPutChar(Header h, rpmTagVal tag, const char *val, rpm_count_t size)
{
return headerPutType(h, tag, RPM_CHAR_TYPE, val, size);
}
int headerPutUint8(Header h, rpmTag tag, const uint8_t *val, rpm_count_t size)
int headerPutUint8(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size)
{
return headerPutType(h, tag, RPM_INT8_TYPE, val, size);
}
int headerPutUint16(Header h, rpmTag tag, const uint16_t *val, rpm_count_t size)
int headerPutUint16(Header h, rpmTagVal tag, const uint16_t *val, rpm_count_t size)
{
return headerPutType(h, tag, RPM_INT16_TYPE, val, size);
}
int headerPutUint32(Header h, rpmTag tag, const uint32_t *val, rpm_count_t size)
int headerPutUint32(Header h, rpmTagVal tag, const uint32_t *val, rpm_count_t size)
{
return headerPutType(h, tag, RPM_INT32_TYPE, val, size);
}
int headerPutUint64(Header h, rpmTag tag, const uint64_t *val, rpm_count_t size)
int headerPutUint64(Header h, rpmTagVal tag, const uint64_t *val, rpm_count_t size)
{
return headerPutType(h, tag, RPM_INT64_TYPE, val, size);
}
int headerPutBin(Header h, rpmTag tag, const uint8_t *val, rpm_count_t size)
int headerPutBin(Header h, rpmTagVal tag, const uint8_t *val, rpm_count_t size)
{
return headerPutType(h, tag, RPM_BIN_TYPE, val, size);
}

View File

@ -31,7 +31,7 @@ typedef char * (*headerTagFormatFunction) (rpmtd td, char * formatPrefix);
typedef int (*headerTagTagFunction) (Header h, rpmtd td, headerGetFlags hgflags);
RPM_GNUC_INTERNAL
headerTagTagFunction rpmHeaderTagFunc(rpmTag tag);
headerTagTagFunction rpmHeaderTagFunc(rpmTagVal tag);
RPM_GNUC_INTERNAL
headerTagFormatFunction rpmHeaderFormatFuncByName(const char *fmt);

View File

@ -56,7 +56,7 @@ rpm_count_t rpmtdCount(rpmtd td)
return (td->type == RPM_BIN_TYPE) ? 1 : td->count;
}
rpmTag rpmtdTag(rpmtd td)
rpmTagVal rpmtdTag(rpmtd td)
{
assert(td != NULL);
return td->tag;
@ -261,7 +261,7 @@ char *rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg)
return str;
}
int rpmtdSetTag(rpmtd td, rpmTag tag)
int rpmtdSetTag(rpmtd td, rpmTagVal tag)
{
assert(td != NULL);
rpmTagType newtype = rpmTagGetTagType(tag);
@ -289,7 +289,7 @@ exit:
return rc;
}
static inline int rpmtdSet(rpmtd td, rpmTag tag, rpmTagType type,
static inline int rpmtdSet(rpmtd td, rpmTagVal tag, rpmTagType type,
rpm_constdata_t data, rpm_count_t count)
{
rpmtdReset(td);
@ -305,7 +305,7 @@ static inline int rpmtdSet(rpmtd td, rpmTag tag, rpmTagType type,
return 1;
}
int rpmtdFromUint8(rpmtd td, rpmTag tag, uint8_t *data, rpm_count_t count)
int rpmtdFromUint8(rpmtd td, rpmTagVal tag, uint8_t *data, rpm_count_t count)
{
rpmTagType type = rpmTagGetTagType(tag);
rpmTagReturnType retype = rpmTagGetReturnType(tag);
@ -332,7 +332,7 @@ int rpmtdFromUint8(rpmtd td, rpmTag tag, uint8_t *data, rpm_count_t count)
return rpmtdSet(td, tag, type, data, count);
}
int rpmtdFromUint16(rpmtd td, rpmTag tag, uint16_t *data, rpm_count_t count)
int rpmtdFromUint16(rpmtd td, rpmTagVal tag, uint16_t *data, rpm_count_t count)
{
rpmTagType type = rpmTagGetTagType(tag);
rpmTagReturnType retype = rpmTagGetReturnType(tag);
@ -344,7 +344,7 @@ int rpmtdFromUint16(rpmtd td, rpmTag tag, uint16_t *data, rpm_count_t count)
return rpmtdSet(td, tag, type, data, count);
}
int rpmtdFromUint32(rpmtd td, rpmTag tag, uint32_t *data, rpm_count_t count)
int rpmtdFromUint32(rpmtd td, rpmTagVal tag, uint32_t *data, rpm_count_t count)
{
rpmTagType type = rpmTagGetTagType(tag);
rpmTagReturnType retype = rpmTagGetReturnType(tag);
@ -356,7 +356,7 @@ int rpmtdFromUint32(rpmtd td, rpmTag tag, uint32_t *data, rpm_count_t count)
return rpmtdSet(td, tag, type, data, count);
}
int rpmtdFromUint64(rpmtd td, rpmTag tag, uint64_t *data, rpm_count_t count)
int rpmtdFromUint64(rpmtd td, rpmTagVal tag, uint64_t *data, rpm_count_t count)
{
rpmTagType type = rpmTagGetTagType(tag);
rpmTagReturnType retype = rpmTagGetReturnType(tag);
@ -368,7 +368,7 @@ int rpmtdFromUint64(rpmtd td, rpmTag tag, uint64_t *data, rpm_count_t count)
return rpmtdSet(td, tag, type, data, count);
}
int rpmtdFromString(rpmtd td, rpmTag tag, const char *data)
int rpmtdFromString(rpmtd td, rpmTagVal tag, const char *data)
{
rpmTagType type = rpmTagGetTagType(tag);
int rc = 0;
@ -382,7 +382,7 @@ int rpmtdFromString(rpmtd td, rpmTag tag, const char *data)
return rc;
}
int rpmtdFromStringArray(rpmtd td, rpmTag tag, const char **data, rpm_count_t count)
int rpmtdFromStringArray(rpmtd td, rpmTagVal tag, const char **data, rpm_count_t count)
{
rpmTagType type = rpmTagGetTagType(tag);
if (type != RPM_STRING_ARRAY_TYPE || count < 1)
@ -393,7 +393,7 @@ int rpmtdFromStringArray(rpmtd td, rpmTag tag, const char **data, rpm_count_t co
return rpmtdSet(td, tag, type, data, count);
}
int rpmtdFromArgv(rpmtd td, rpmTag tag, ARGV_t argv)
int rpmtdFromArgv(rpmtd td, rpmTagVal tag, ARGV_t argv)
{
int count = argvCount(argv);
rpmTagType type = rpmTagGetTagType(tag);
@ -404,7 +404,7 @@ int rpmtdFromArgv(rpmtd td, rpmTag tag, ARGV_t argv)
return rpmtdSet(td, tag, type, argv, count);
}
int rpmtdFromArgi(rpmtd td, rpmTag tag, ARGI_t argi)
int rpmtdFromArgi(rpmtd td, rpmTagVal tag, ARGI_t argi)
{
int count = argiCount(argi);
rpmTagType type = rpmTagGetTagType(tag);

View File

@ -70,7 +70,7 @@ rpm_count_t rpmtdCount(rpmtd td);
* @param td Tag data container
* @return Rpm tag.
*/
rpmTag rpmtdTag(rpmtd td);
rpmTagVal rpmtdTag(rpmtd td);
/** \ingroup rpmtd
* Retrieve type of the container.
@ -243,7 +243,7 @@ char *rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg);
* @param tag New tag
* @return 1 on success, 0 on error
*/
int rpmtdSetTag(rpmtd td, rpmTag tag);
int rpmtdSetTag(rpmtd td, rpmTagVal tag);
/** \ingroup rpmtd
* Construct tag container from uint8_t pointer.
@ -256,7 +256,7 @@ int rpmtdSetTag(rpmtd td, rpmTag tag);
* @param count Number of entries
* @return 1 on success, 0 on error (eg wrong type)
*/
int rpmtdFromUint8(rpmtd td, rpmTag tag, uint8_t *data, rpm_count_t count);
int rpmtdFromUint8(rpmtd td, rpmTagVal tag, uint8_t *data, rpm_count_t count);
/** \ingroup rpmtd
* Construct tag container from uint16_t pointer.
@ -268,7 +268,7 @@ int rpmtdFromUint8(rpmtd td, rpmTag tag, uint8_t *data, rpm_count_t count);
* @param count Number of entries
* @return 1 on success, 0 on error (eg wrong type)
*/
int rpmtdFromUint16(rpmtd td, rpmTag tag, uint16_t *data, rpm_count_t count);
int rpmtdFromUint16(rpmtd td, rpmTagVal tag, uint16_t *data, rpm_count_t count);
/** \ingroup rpmtd
* Construct tag container from uint32_t pointer.
@ -280,7 +280,7 @@ int rpmtdFromUint16(rpmtd td, rpmTag tag, uint16_t *data, rpm_count_t count);
* @param count Number of entries
* @return 1 on success, 0 on error (eg wrong type)
*/
int rpmtdFromUint32(rpmtd td, rpmTag tag, uint32_t *data, rpm_count_t count);
int rpmtdFromUint32(rpmtd td, rpmTagVal tag, uint32_t *data, rpm_count_t count);
/** \ingroup rpmtd
* Construct tag container from uint64_t pointer.
@ -292,7 +292,7 @@ int rpmtdFromUint32(rpmtd td, rpmTag tag, uint32_t *data, rpm_count_t count);
* @param count Number of entries
* @return 1 on success, 0 on error (eg wrong type)
*/
int rpmtdFromUint64(rpmtd td, rpmTag tag, uint64_t *data, rpm_count_t count);
int rpmtdFromUint64(rpmtd td, rpmTagVal tag, uint64_t *data, rpm_count_t count);
/** \ingroup rpmtd
* Construct tag container from a string.
@ -302,7 +302,7 @@ int rpmtdFromUint64(rpmtd td, rpmTag tag, uint64_t *data, rpm_count_t count);
* @param data String to use
* @return 1 on success, 0 on error (eg wrong type)
*/
int rpmtdFromString(rpmtd td, rpmTag tag, const char *data);
int rpmtdFromString(rpmtd td, rpmTagVal tag, const char *data);
/** \ingroup rpmtd
* Construct tag container from a string array.
@ -314,7 +314,7 @@ int rpmtdFromString(rpmtd td, rpmTag tag, const char *data);
* @param count Number of entries
* @return 1 on success, 0 on error (eg wrong type)
*/
int rpmtdFromStringArray(rpmtd td, rpmTag tag, const char **data, rpm_count_t count);
int rpmtdFromStringArray(rpmtd td, rpmTagVal tag, const char **data, rpm_count_t count);
/** \ingroup rpmtd
* Construct tag container from ARGV_t array.
@ -325,7 +325,7 @@ int rpmtdFromStringArray(rpmtd td, rpmTag tag, const char **data, rpm_count_t co
* @param argv ARGV array
* @return 1 on success, 0 on error (eg wrong type)
*/
int rpmtdFromArgv(rpmtd td, rpmTag tag, ARGV_t argv);
int rpmtdFromArgv(rpmtd td, rpmTagVal tag, ARGV_t argv);
/** \ingroup rpmtd
* Construct tag container from ARGI_t array.
@ -336,7 +336,7 @@ int rpmtdFromArgv(rpmtd td, rpmTag tag, ARGV_t argv);
* @param argi ARGI array
* @return 1 on success, 0 on error (eg wrong type)
*/
int rpmtdFromArgi(rpmtd td, rpmTag tag, ARGI_t argi);
int rpmtdFromArgi(rpmtd td, rpmTagVal tag, ARGI_t argi);
/* \ingroup rpmtd
* Perform deep copy of container.

View File

@ -738,7 +738,7 @@ static const struct headerTagFunc_s rpmHeaderTagExtensions[] = {
{ 0, NULL }
};
headerTagTagFunction rpmHeaderTagFunc(rpmTag tag)
headerTagTagFunction rpmHeaderTagFunc(rpmTagVal tag)
{
const struct headerTagFunc_s * ext;
headerTagTagFunction func = NULL;