summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-05-21 14:49:12 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-05-21 14:49:12 +0300
commit35c0252857822faac53b7df9c9632d21bed926d5 (patch)
treea52feeeefd03cafb14e1762e55b786c3efa5a123 /lib
parent3d8656f040d2c780c88d0cd63594898f0605a6fa (diff)
downloadlibrpm-tizen-35c0252857822faac53b7df9c9632d21bed926d5.tar.gz
librpm-tizen-35c0252857822faac53b7df9c9632d21bed926d5.tar.bz2
librpm-tizen-35c0252857822faac53b7df9c9632d21bed926d5.zip
Add per-datatype iterators to rpmtd
- just uint32 and string iterators for now, those are the most common ones - allows somewhat more convenient code constructs when type is known, eg no need to separately check for non-null inside loops
Diffstat (limited to 'lib')
-rw-r--r--lib/rpmtd.c20
-rw-r--r--lib/rpmtd.h14
2 files changed, 34 insertions, 0 deletions
diff --git a/lib/rpmtd.c b/lib/rpmtd.c
index d1c49cf33..daac14542 100644
--- a/lib/rpmtd.c
+++ b/lib/rpmtd.c
@@ -96,6 +96,26 @@ int rpmtdNext(rpmtd td)
return i;
}
+uint32_t *rpmtdNextUint32(rpmtd td)
+{
+ assert(td != NULL);
+ uint32_t *res = NULL;
+ if (rpmtdNext(td) >= 0) {
+ res = rpmtdGetUint32(td);
+ }
+ return res;
+}
+
+const char *rpmtdNextString(rpmtd td)
+{
+ assert(td != NULL);
+ const char *res = NULL;
+ if (rpmtdNext(td) >= 0) {
+ res = rpmtdGetString(td);
+ }
+ return res;
+}
+
char * rpmtdGetChar(rpmtd td)
{
char *res = NULL;
diff --git a/lib/rpmtd.h b/lib/rpmtd.h
index c5e4a8fc3..30d28c0c8 100644
--- a/lib/rpmtd.h
+++ b/lib/rpmtd.h
@@ -87,6 +87,20 @@ int rpmtdInit(rpmtd td);
int rpmtdNext(rpmtd td);
/** \ingroup rpmtd
+ * Iterate over uint32_t type tag data container.
+ * @param td Tag data container
+ * @return Pointer to next value, NULL on termination or error
+ */
+uint32_t *rpmtdNextUint32(rpmtd td);
+
+/** \ingroup rpmtd
+ * Iterate over string / string array type tag data container.
+ * @param td Tag data container
+ * @return Pointer to next value, NULL on termination or error
+ */
+const char *rpmtdNextString(rpmtd td);
+
+/** \ingroup rpmtd
* Return char data from tag container.
* For scalar return type, just return pointer to the integer. On array
* types, return pointer to current iteration index. If the tag container