From d381d7b78c47ea2cddb46b9e50782372a45a62d9 Mon Sep 17 00:00:00 2001 From: Olivier Thauvin Date: Sun, 25 Apr 2004 10:44:42 +0000 Subject: =?UTF-8?q?-=20add=20$pkg->queryformat()=20function=20-=20$=C3=BBr?= =?UTF-8?q?pm->list=5Frpm=5Ftag=20show=20all=20tag,=20value=20for=20unpars?= =?UTF-8?q?able=20tag=20is=20'undef'=20in=20hash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- URPM.pm | 7 +++++++ URPM.xs | 34 +++++++++++++++++++++++++++++++++- URPM/Query.pm | 2 +- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/URPM.pm b/URPM.pm index 37b626f..ee8529f 100644 --- a/URPM.pm +++ b/URPM.pm @@ -441,6 +441,13 @@ Returns a string NAME-VERSION-RELEASE.ARCH in scalar context. Returns an array containing values of $tagid. $tagid is the numerical value of rpm tags. See rpmlib.h. +=item $package->queryformat($format) + +Querying the package like rpm --queryformat do. + +The function call directlly the rpmlib, then use headers informations, so it +silently failed if you use synthesis instead hdlist/rpms/headers files or rpmdb. + =item $package->get_tag_modifiers($tagid) Return an array of human readable view of tag values. $tagid is the numerical value of rpm tags. diff --git a/URPM.xs b/URPM.xs index 2cdf386..307512f 100644 --- a/URPM.xs +++ b/URPM.xs @@ -2304,6 +2304,18 @@ Pkg_changelog_text(pkg) return_list_str(NULL, pkg->h, RPMTAG_CHANGELOGTEXT, 0, 0, callback_list_str_xpush, NULL); SPAGAIN; +void +Pkg_queryformat(pkg, fmt) + URPM::Package pkg; + char *fmt + PPCODE: + char *s; + if (pkg->h) { + s = headerSprintf(pkg->h, fmt, + rpmTagTable, rpmHeaderFormats, NULL); + XPUSHs(sv_2mortal(newSVpv(s,0))); + } + void Pkg_get_tag(pkg, tagname) URPM::Package pkg @@ -3185,13 +3197,33 @@ Urpm_list_rpm_tag(urpm=Nullsv) SV *urpm PREINIT: int i = 0; + const struct headerSprintfExtension_s * ext = rpmHeaderFormats; PPCODE: read_config_files(0); + + + for (i = 0; i < rpmTagTableSize; i++) { - XPUSHs(sv_2mortal(newSVpv(rpmTagTable[i].name, 0))); + XPUSHs(sv_2mortal(newSVpv(rpmTagTable[i].name + 7, 0))); XPUSHs(sv_2mortal(newSViv(rpmTagTable[i].val))); } + while (ext->name != NULL) { + if (ext->type == HEADER_EXT_MORE) { + ext = ext->u.more; + continue; + } + for (i = 0; i < rpmTagTableSize; i++) { + if (!strcmp(rpmTagTable[i].name, ext->name)) + break; + } + if (i >= rpmTagTableSize && ext->type == HEADER_EXT_TAG) { + XPUSHs(sv_2mortal(newSVpv(ext->name + 7, 0))); + XPUSHs(sv_newmortal()); + } + ext++; + } + int Urpm_ranges_overlap(a, b, b_nopromote=0) char *a diff --git a/URPM/Query.pm b/URPM/Query.pm index c249470..8900355 100644 --- a/URPM/Query.pm +++ b/URPM/Query.pm @@ -14,7 +14,7 @@ use strict; sub tag2id { my @l = @_; my %taglist = URPM::list_rpm_tag; - map { $taglist{uc("RPMTAG_$_")} || undef } @l; + map { $taglist{uc($_)} || undef } @l; } sub query_pkg { -- cgit v1.2.1