Handle RPM_CHAR_TYPE too in stringFormat()
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 20 May 2008 05:53:05 +0000 (08:53 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 21 May 2008 09:04:50 +0000 (12:04 +0300)
- used by filestates and nothing else apparently, duh..

lib/formats.c
lib/rpmtd.c
lib/rpmtd.h

index f841a10..0f44688 100644 (file)
@@ -51,11 +51,18 @@ static char * stringFormat(rpmtd td, char *formatPrefix, size_t padding)
     size_t need;
 
     switch (rpmtdType(td)) {
+       case RPM_INT8_TYPE:
+       case RPM_CHAR_TYPE:
+           need = 10 + padding + 20; /* we can do better, just for now ... */
+           val = xmalloc(need);
+           strcat(formatPrefix, "hhd");
+           sprintf(val, formatPrefix, *rpmtdGetChar(td));
+           break;
        case RPM_INT16_TYPE:
            need = 10 + padding + 20; /* we can do better, just for now ... */
            val = xmalloc(need);
-           strcat(formatPrefix, "d");
-           sprintf(val, formatPrefix, *rpmtdGetUint32(td));
+           strcat(formatPrefix, "hd");
+           sprintf(val, formatPrefix, *rpmtdGetUint16(td));
            break;
        case RPM_INT32_TYPE:
            need = 10 + padding + 20; /* we can do better, just for now ... */
index e0a29de..ee55435 100644 (file)
@@ -82,6 +82,18 @@ int rpmtdNext(rpmtd td)
     return i;
 }
 
+char * rpmtdGetChar(rpmtd td)
+{
+    char *res = NULL;
+
+    assert(td != NULL);
+
+    if (td->type == RPM_CHAR_TYPE) {
+       int ix = (td->ix >= 0 ? td->ix : 0);
+       res = (char *) td->data + ix;
+    } 
+    return res;
+}
 uint16_t * rpmtdGetUint16(rpmtd td)
 {
     uint16_t *res = NULL;
index b7f1a20..c058f5b 100644 (file)
@@ -80,6 +80,16 @@ int rpmtdInit(rpmtd td);
 int rpmtdNext(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
+ * is not for char type, NULL is returned.
+ * @param td           Tag data container
+ * @return             Pointer to uint16_t, NULL on error
+ */
+char *rpmtdGetChar(rpmtd td);
+
+/** \ingroup rpmtd
  * Return uint16_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