summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-02-08 10:01:19 +0200
committerPanu Matilainen <pmatilai@redhat.com>2010-02-09 09:35:52 +0200
commit121f73bb4932d15e618e82d5c6d7b43280dc0f7d (patch)
tree29fb2d243b7d22933bdc7adce5907dd8fe73129f
parenta5dbbd4065a34664c4701f246bd7d8d537346a33 (diff)
downloadrpm-121f73bb4932d15e618e82d5c6d7b43280dc0f7d.tar.gz
Add macro expansion queryformat extension
- unused at the moment but doesn't hurt anything either...
-rw-r--r--doc/rpm.83
-rw-r--r--lib/formats.c14
-rw-r--r--lib/rpmtd.h1
3 files changed, 18 insertions, 0 deletions
diff --git a/doc/rpm.8 b/doc/rpm.8
index ae89d7955..47c7ee7f1 100644
--- a/doc/rpm.8
+++ b/doc/rpm.8
@@ -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