summaryrefslogtreecommitdiff
path: root/lib/header.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-09-30 14:48:19 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-09-30 14:48:19 +0300
commit3d5455d42d48740ff23899f00a903f49b73eff00 (patch)
tree5fa0fa998f5b8e483d2a1f0dd6543f294a803770 /lib/header.c
parentd59e715c1b8e28206bfed45b6f4cf3c00322f95c (diff)
downloadlibrpm-tizen-3d5455d42d48740ff23899f00a903f49b73eff00.tar.gz
librpm-tizen-3d5455d42d48740ff23899f00a903f49b73eff00.tar.bz2
librpm-tizen-3d5455d42d48740ff23899f00a903f49b73eff00.zip
Add alternative header iterator method
- we dont always want the actual contents of the tag to be copied on iteration, so add an interface that returns the next tag in the header - this lets callers to decide what to do with the tag and how to retrieve it
Diffstat (limited to 'lib/header.c')
-rw-r--r--lib/header.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/header.c b/lib/header.c
index 441a0bc61..77e247375 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -1784,15 +1784,11 @@ HeaderIterator headerInitIterator(Header h)
return hi;
}
-int headerNext(HeaderIterator hi, rpmtd td)
+static indexEntry nextIndex(HeaderIterator hi)
{
Header h = hi->h;
int slot;
indexEntry entry = NULL;
- int rc;
-
- assert(td != NULL);
- rpmtdReset(td);
for (slot = hi->next_index; slot < h->indexUsed; slot++) {
entry = h->index + slot;
@@ -1801,15 +1797,28 @@ int headerNext(HeaderIterator hi, rpmtd td)
}
hi->next_index = slot;
if (entry == NULL || slot >= h->indexUsed)
- return 0;
+ return NULL;
hi->next_index++;
+ return entry;
+}
- td->tag = entry->info.tag;
+rpmTag headerNextTag(HeaderIterator hi)
+{
+ indexEntry entry = nextIndex(hi);
+ return entry ? entry->info.tag : RPMTAG_NOT_FOUND;
+}
- rc = copyTdEntry(entry, td, HEADERGET_DEFAULT);
+int headerNext(HeaderIterator hi, rpmtd td)
+{
+ indexEntry entry = nextIndex(hi);
+ int rc = 0;
- /* XXX 1 on success */
+ rpmtdReset(td);
+ if (entry) {
+ td->tag = entry->info.tag;
+ rc = copyTdEntry(entry, td, HEADERGET_DEFAULT);
+ }
return ((rc == 1) ? 1 : 0);
}