diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2010-02-08 10:01:19 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2010-02-09 09:35:52 +0200 |
commit | 121f73bb4932d15e618e82d5c6d7b43280dc0f7d (patch) | |
tree | 29fb2d243b7d22933bdc7adce5907dd8fe73129f | |
parent | a5dbbd4065a34664c4701f246bd7d8d537346a33 (diff) | |
download | rpm-121f73bb4932d15e618e82d5c6d7b43280dc0f7d.tar.gz |
Add macro expansion queryformat extension
- unused at the moment but doesn't hurt anything either...
-rw-r--r-- | doc/rpm.8 | 3 | ||||
-rw-r--r-- | lib/formats.c | 14 | ||||
-rw-r--r-- | lib/rpmtd.h | 1 |
3 files changed, 18 insertions, 0 deletions
@@ -469,6 +469,9 @@ Format dependency comparison operator. \fB:deptype\fR Format dependency type. .TP +\fB:expand\fR +Perform macro expansion. +.TP \fB:fflags\fR Format file flags. .TP diff --git a/lib/formats.c b/lib/formats.c index 8e7cb4c30..8cc16a00a 100644 --- a/lib/formats.c +++ b/lib/formats.c @@ -690,6 +690,19 @@ static char * vflagsFormat(rpmtd td, char * formatPrefix) return val; } + +static char * expandFormat(rpmtd td, char * formatPrefix) +{ + char *val = NULL; + if (rpmtdClass(td) != RPM_STRING_CLASS) { + val = xstrdup(_("(not a string)")); + } else { + val = rpmExpand(td->data, NULL); + } + strcat(formatPrefix, "s"); + return val; +} + void *rpmHeaderFormatFuncByName(const char *fmt) { const struct headerFormatFunc_s * ext; @@ -738,5 +751,6 @@ static const struct headerFormatFunc_s rpmHeaderFormats[] = { { RPMTD_FORMAT_ARRAYSIZE, "arraysize", arraysizeFormat }, { RPMTD_FORMAT_FSTATE, "fstate", fstateFormat }, { RPMTD_FORMAT_VFLAGS, "vflags", vflagsFormat }, + { RPMTD_FORMAT_EXPAND, "expand", expandFormat }, { -1, NULL, NULL } }; diff --git a/lib/rpmtd.h b/lib/rpmtd.h index 22914427b..879af264a 100644 --- a/lib/rpmtd.h +++ b/lib/rpmtd.h @@ -216,6 +216,7 @@ typedef enum rpmtdFormats_e { RPMTD_FORMAT_DEPTYPE = 15, /* dependency types (int types) */ RPMTD_FORMAT_FSTATE = 16, /* file states (int types) */ RPMTD_FORMAT_VFLAGS = 17, /* file verify flags (int types) */ + RPMTD_FORMAT_EXPAND = 18, /* macro expansion (string types) */ } rpmtdFormats; /** \ingroup rpmtd |