[devel] [PATCH] Verbose QueryTags prints whether tag is an extension

Vladimir D. Seleznev vseleznv на altlinux.org
Вс Апр 12 06:02:26 MSK 2020


Verbose QueryTags prints four field: tagname, tagvalue, tagtype and whether
it is an extension. To make it possible QueryTags uses new function
rpmTagIsExtension() that returns 0 if tag is real, 1 if tag is an extension
or -1 if tag is not found.

* lib/query.c(rpmDisplayQueryTags): Print whether tag is an extension.
* lib/rpmtag.h(rpmTagIsExtension): New definition.
* lib/tagname.c(rpmTagIsExtension): New function.
---
 lib/query.c   |  5 +++++
 lib/rpmtag.h  |  7 +++++++
 lib/tagname.c | 14 ++++++++++++++
 3 files changed, 26 insertions(+)

diff --git a/lib/query.c b/lib/query.c
index 60d3a0269..f27b15a7c 100644
--- a/lib/query.c
+++ b/lib/query.c
@@ -253,9 +253,14 @@ void rpmDisplayQueryTags(FILE * fp)
 	if (rpmIsVerbose()) {
 	    rpmTagVal tag = rpmTagGetValue(sname);
 	    rpmTagType type = rpmTagGetTagType(tag);
+	    int ext = rpmTagIsExtension(tag);
 	    fprintf(fp, "%-20s %6d", sname, tag);
 	    if (type > RPM_NULL_TYPE && type <= RPM_MAX_TYPE)
 		fprintf(fp, " %s", tagTypeNames[type]);
+	    else if (ext == 1)
+		fprintf(fp, " -");
+	    if (ext == 1)
+		fprintf(fp, " ext");
 	} else {
 	    fprintf(fp, "%s", sname);
 	}
diff --git a/lib/rpmtag.h b/lib/rpmtag.h
index f74b451dc..501fd7b2f 100644
--- a/lib/rpmtag.h
+++ b/lib/rpmtag.h
@@ -519,6 +519,13 @@ rpmTagType rpmTagGetTagType(rpmTagVal tag);
  */
 rpmTagReturnType rpmTagGetReturnType(rpmTagVal tag);
 
+/** \ingroup rpmtag
+ * Return 0 if tag is real, 1 if tag is an extension, -1 on not found
+ * @param tag		tag value
+ * @return		0 if tag is real, 1 if tag is an extension, -1 on not found
+ */
+int rpmTagIsExtension(rpmTagVal tag);
+
 /** \ingroup rpmtag
  * Return tag data class from value.
  * @param tag		tag value
diff --git a/lib/tagname.c b/lib/tagname.c
index 532437740..405dd8aa4 100644
--- a/lib/tagname.c
+++ b/lib/tagname.c
@@ -197,6 +197,20 @@ rpmTagReturnType rpmTagGetReturnType(rpmTagVal tag)
     return (rpmTagGetType(tag) & RPM_MASK_RETURN_TYPE);
 }
 
+int rpmTagIsExtension(rpmTagVal tag)
+{
+    const struct headerTagTableEntry_s *t;
+
+    pthread_once(&tagsLoaded, loadTags);
+
+    t = entryByTag(tag);
+
+    if (t)
+	return t->extension;
+    else
+	return -1;
+}
+
 rpmTagClass rpmTagTypeGetClass(rpmTagType type)
 {
     rpmTagClass tclass;
-- 
2.25.2



Подробная информация о списке рассылки Devel