Add access methods for 64bit integer types to rpmtd
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 6 Jun 2008 20:47:37 +0000 (23:47 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 6 Jun 2008 20:47:37 +0000 (23:47 +0300)
lib/rpmtd.c
lib/rpmtd.h

index e1d2408..2c377a4 100644 (file)
@@ -123,6 +123,16 @@ uint32_t *rpmtdNextUint32(rpmtd td)
     return res;
 }
 
+uint64_t *rpmtdNextUint64(rpmtd td)
+{
+    assert(td != NULL);
+    uint64_t *res = NULL;
+    if (rpmtdNext(td) >= 0) {
+       res = rpmtdGetUint64(td);
+    }
+    return res;
+}
+
 const char *rpmtdNextString(rpmtd td)
 {
     assert(td != NULL);
@@ -170,6 +180,20 @@ uint32_t * rpmtdGetUint32(rpmtd td)
     } 
     return res;
 }
+
+uint64_t * rpmtdGetUint64(rpmtd td)
+{
+    uint64_t *res = NULL;
+
+    assert(td != NULL);
+
+    if (td->type == RPM_INT64_TYPE) {
+       int ix = (td->ix >= 0 ? td->ix : 0);
+       res = (uint64_t *) td->data + ix;
+    } 
+    return res;
+}
+
 const char * rpmtdGetString(rpmtd td)
 {
     const char *str = NULL;
index 6da2482..ac72ddd 100644 (file)
@@ -111,6 +111,13 @@ int rpmtdNext(rpmtd td);
 uint32_t *rpmtdNextUint32(rpmtd td);
 
 /** \ingroup rpmtd
+ * Iterate over uint64_t type tag data container.
+ * @param td           Tag data container
+ * @return             Pointer to next value, NULL on termination or error
+ */
+uint64_t *rpmtdNextUint64(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
@@ -148,6 +155,16 @@ uint16_t * rpmtdGetUint16(rpmtd td);
 uint32_t * rpmtdGetUint32(rpmtd td);
 
 /** \ingroup rpmtd
+ * Return uint64_t 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
+ * is not for int64 type, NULL is returned.
+ * @param td           Tag data container
+ * @return             Pointer to uint64_t, NULL on error
+ */
+uint64_t * rpmtdGetUint64(rpmtd td);
+
+/** \ingroup rpmtd
  * Return string data from tag container.
  * For string types, just return the string. On string array types,
  * return the string from current iteration index. If the tag container