From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=altlinux.org; s=dkim; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=nyic0H3tDo8FGEt0lB2fL3MfUybZGe2k9tgYa0a0LHs=; b=a9LKZ7JKnqpA1ohbh02L3egvTr XqFqcUPvxw5dSKFuGtkKEAA/Tk0K19obIIaQZtiuipQXqWIRrYxilo8ZlU0AdS/aazor0zqtPLl1R CVlAHmdCeTBVj5YVHogJITNh0D9gRNFZUNxcesSyCYADVASR5RGyT7aUZZrby7GZKxcXEHp1vdX5i gm7C1GchkGQ5HVITdEw8FVBq5jzWhNrKpHVjGpvc26HoYNPHyFT/nDtigrFmcdvAGpn0nIjhABK27 J2LqPyvRWtXvfEPjBhmQdBgWJPSKD2OttAMyLdR7ueyte5JAIKuWV773c9yugqQ+tu17P3aEjFRIH k8dPZM3Q==; From: "Vladimir D. Seleznev" To: devel@lists.altlinux.org Date: Sun, 12 Apr 2020 06:02:26 +0300 Message-Id: <20200412030226.1886291-1-vseleznv@altlinux.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200411134655.da40352c20a0e0bde65a474d@altlinux.org> References: <20200411134655.da40352c20a0e0bde65a474d@altlinux.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 46.39.229.193 X-SA-Exim-Mail-From: vseleznv@altlinux.org X-SA-Exim-Version: 4.2.1 X-SA-Exim-Scanned: Yes (on mail.cs.msu.ru) Cc: vseleznv@altlinux.org Subject: [devel] [PATCH] Verbose QueryTags prints whether tag is an extension X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Apr 2020 03:02:45 -0000 Archived-At: List-Archive: List-Post: 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