summaryrefslogtreecommitdiff
path: root/lib/header.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-07-03 14:46:06 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-07-03 14:46:06 +0300
commit683d30858610c548ae3a3999b458b438d7275546 (patch)
tree16934fbcfed015eaa9e911b66b0ee9f4777c2a1a /lib/header.c
parente18aedbf97d0948b9010877270d9559d8a64c861 (diff)
downloadrpm-683d30858610c548ae3a3999b458b438d7275546.tar.gz
rpm-683d30858610c548ae3a3999b458b438d7275546.tar.bz2
rpm-683d30858610c548ae3a3999b458b438d7275546.zip
Unify extension + header data getter calling conventions
- simplifies headerGet() & friends a bit and reduces redundancy - also just return an error instead of dying with assert on NULL td argument
Diffstat (limited to 'lib/header.c')
-rw-r--r--lib/header.c39
1 files changed, 10 insertions, 29 deletions
diff --git a/lib/header.c b/lib/header.c
index 1afd4eb09..aa84720e2 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -1327,23 +1327,18 @@ exit:
/**
* Retrieve tag data from header.
* @param h header
- * @param tag tag to retrieve
* @retval td tag data container
* @param flags flags to control retrieval
* @return 1 on success, 0 on not found
*/
-static int intGetTdEntry(Header h, rpmTag tag, rpmtd td, headerGetFlags flags)
+static int intGetTdEntry(Header h, rpmtd td, headerGetFlags flags)
{
indexEntry entry;
int rc;
- assert(td != NULL);
- /* ensure clean state */
- rpmtdReset(td);
- td->tag = tag;
/* First find the tag */
/* FIX: h modified by sort. */
- entry = findEntry(h, tag, RPM_NULL_TYPE);
+ entry = findEntry(h, td->tag, RPM_NULL_TYPE);
if (entry == NULL) {
/* Td is zeroed above, just return... */
return 0;
@@ -1366,35 +1361,21 @@ static int intGetTdEntry(Header h, rpmTag tag, rpmtd td, headerGetFlags flags)
return ((rc == 1) ? 1 : 0);
}
-/*
- * XXX temporary kludgery until tag extensions have been converted to
- * take rpmtd as argument
- */
-static int intGetTagExt(Header h, rpmTag tag, rpmtd td, headerTagTagFunction tagfunc)
-{
- int rc;
- rpmtdReset(td);
- rc = tagfunc(h, td, HEADERGET_DEFAULT);
- td->tag = tag;
- return rc;
-}
-
int headerGet(Header h, rpmTag tag, rpmtd td, headerGetFlags flags)
{
int rc;
- headerTagTagFunction tagfunc = NULL;
+ headerTagTagFunction tagfunc = intGetTdEntry;
- assert(td != NULL);
+ if (td == NULL) return 0;
+
+ rpmtdReset(td);
+ td->tag = tag;
if (flags & HEADERGET_EXT) {
- tagfunc = rpmHeaderTagFunc(tag);
- }
-
- if (tagfunc) {
- rc = intGetTagExt(h, tag, td, tagfunc);
- } else {
- rc = intGetTdEntry(h, tag, td, flags);
+ headerTagTagFunction extfunc = rpmHeaderTagFunc(tag);
+ if (extfunc) tagfunc = extfunc;
}
+ rc = tagfunc(h, td, flags);
assert(tag == td->tag);
return rc;