summaryrefslogtreecommitdiff
path: root/lib/formats.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-10-30 09:15:36 +0200
committerPanu Matilainen <pmatilai@redhat.com>2009-10-30 09:15:36 +0200
commit491cf5e3442af05b79b33e346f60e565f343513f (patch)
tree511ae663c3c3bb9e6434bd1bf16663b7b0106f29 /lib/formats.c
parent18cc1d23120c5eadad251f0edde1697ed418a3e1 (diff)
downloadrpm-491cf5e3442af05b79b33e346f60e565f343513f.tar.gz
rpm-491cf5e3442af05b79b33e346f60e565f343513f.tar.bz2
rpm-491cf5e3442af05b79b33e346f60e565f343513f.zip
Add file state format extension
Diffstat (limited to 'lib/formats.c')
-rw-r--r--lib/formats.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/formats.c b/lib/formats.c
index 82e00ee05..e984a007c 100644
--- a/lib/formats.c
+++ b/lib/formats.c
@@ -615,6 +615,46 @@ static char * arraysizeFormat(rpmtd td, char * formatPrefix)
return val;
}
+static char * fstateFormat(rpmtd td, char * formatPrefix)
+{
+ char * val = NULL;
+
+ if (rpmtdClass(td) != RPM_NUMERIC_CLASS) {
+ val = xstrdup(_("(not a number)"));
+ } else {
+ const char * str;
+ rpmfileState fstate = rpmtdGetNumber(td);
+ switch (fstate) {
+ case RPMFILE_STATE_NORMAL:
+ str = _("normal");
+ break;
+ case RPMFILE_STATE_REPLACED:
+ str = _("replaced");
+ break;
+ case RPMFILE_STATE_NOTINSTALLED:
+ str = _("not installed");
+ break;
+ case RPMFILE_STATE_NETSHARED:
+ str = _("net shared");
+ break;
+ case RPMFILE_STATE_WRONGCOLOR:
+ str = _("wrong color");
+ break;
+ /* XXX headers should never have this value as file state */
+ case RPMFILE_STATE_MISSING:
+ str = _("missing");
+ break;
+ default:
+ str = _("(unknown)");
+ break;
+ }
+
+ strcat(formatPrefix, "s");
+ rasprintf(&val, formatPrefix, str);
+ }
+ return val;
+}
+
void *rpmHeaderFormatFuncByName(const char *fmt)
{
const struct headerFormatFunc_s * ext;
@@ -661,5 +701,6 @@ static const struct headerFormatFunc_s rpmHeaderFormats[] = {
{ RPMTD_FORMAT_DAY, "day", dayFormat },
{ RPMTD_FORMAT_SHESCAPE, "shescape", shescapeFormat },
{ RPMTD_FORMAT_ARRAYSIZE, "arraysize", arraysizeFormat },
+ { RPMTD_FORMAT_FSTATE, "fstate", fstateFormat },
{ -1, NULL, NULL }
};