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: 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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=RI6B6Mlbo9SQ5FwrGMJXUgKEPMIkxkVMp5fqhNrSBIw=; b=wDqzqmSln1DEUIVALwFfdHaFxE jUPTfyeliZofEpn/3BgPKaghUFjDSglzYP68x+f058zKtfFuTvDXmlSNlcb0J2ooGzsI8reQIeApt dalRber+hztJydk9FhYDJ6dxXKwMVTDyi96G05WdvrvMqTKUv/dQvZYnU0sNBhftGy+krmIcT8vUZ kuXxiFXiWzUnJI3uvHKuw82X8t4PDai7xeZF+nKG/XBs79Dtch3jsOF5+99oHTNVuXzoIOWgU4lfB Q7zlpAKFAlh7547KnvAXWxcMEqk4LSp5TVfMT4AKVpnv2pLgFBP5ONYsQ5P7sa2SfIXRhfQ/8YR65 mUo149lw==; From: "Vladimir D. Seleznev" To: devel@lists.altlinux.org Date: Sat, 11 Apr 2020 02:19:17 +0300 Message-Id: <20200410231917.1482336-1-vseleznv@altlinux.org> X-Mailer: git-send-email 2.25.2 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 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: Fri, 10 Apr 2020 23:19:30 -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 return 0 if tag is real, 1 if tag is an extension or 2 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..5f0216bdc 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) + fprintf(fp, " -"); + if (ext) + fprintf(fp, " ext"); } else { fprintf(fp, "%s", sname); } diff --git a/lib/rpmtag.h b/lib/rpmtag.h index f74b451dc..8e860f927 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, 2 on not found + * @param tag tag value + * @return 0 if tag is real, 1 if tag is an extension, 2 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..791b38ade 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 2; +} + rpmTagClass rpmTagTypeGetClass(rpmTagType type) { rpmTagClass tclass; -- 2.25.2