Dom't muck with rpmTagTable internals in rpmDisplayQueryTags()
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 21 May 2008 14:03:15 +0000 (17:03 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 21 May 2008 14:03:15 +0000 (17:03 +0300)
lib/query.c

index c637b2e..35c9aa2 100644 (file)
@@ -253,27 +253,28 @@ exit:
 
 void rpmDisplayQueryTags(FILE * fp)
 {
-    const struct headerTagTableEntry_s * t;
-    int i, ttype;
-
-    for (i = 0, t = rpmTagTable; i < rpmTagTableSize; i++, t++) {
-       if (t->name == NULL)
-           continue;
+    static const char * const tagTypeNames[] = {
+       "", "char", "int8", "int16", "int32", "int64",
+       "string", "blob", "argv", "i18nstring"
+    };
+    const char *tname, *sname;
+    rpmtd names = rpmTagGetNames(1);
+
+    while ((tname = rpmtdNextString(names))) {
+       sname = tname + strlen("RPMTAG_");
        if (rpmIsVerbose()) {
-           static const char * const tagtypes[] = {
-               "", "char", "int8", "int16", "int32", "int64",
-               "string", "blob", "argv", "i18nstring"
-           };
-           fprintf(fp, "%-20s %6d", t->name + 7, t->val);
-           ttype = t->type & RPM_MASK_TYPE;
-           if (ttype > RPM_NULL_TYPE && ttype <= RPM_MAX_TYPE)
-               fprintf(fp, " %s", tagtypes[ttype]);
+           rpmTag tag = rpmTagGetValue(tname);
+           rpmTagType type = rpmTagGetType(tag) & RPM_MASK_TYPE;
+           fprintf(fp, "%-20s %6d", sname, tag);
+           if (type > RPM_NULL_TYPE && type <= RPM_MAX_TYPE)
+               fprintf(fp, " %s", tagTypeNames[type]);
        } else {
-           fprintf(fp, "%s", t->name + 7);
+           fprintf(fp, "%s", sname);
        }
-           
        fprintf(fp, "\n");
     }
+    rpmtdFreeData(names);
+    rpmtdFree(names);
 }
 
 static int rpmgiShowMatches(QVA_t qva, rpmts ts)