summaryrefslogtreecommitdiff
path: root/src/unit.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-10-20 16:16:45 +0200
committerLennart Poettering <lennart@poettering.net>2010-10-20 16:16:45 +0200
commit9fc507041eb524799a0410839e961ec188a78491 (patch)
tree029b0dee9d8d382b5abc5d7a4aa4078b9033a1a6 /src/unit.c
parent980d87505c391682c7d9da2d48a1ba68f35c0339 (diff)
unit: introduce %f specifier to decode file names
Diffstat (limited to 'src/unit.c')
-rw-r--r--src/unit.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/unit.c b/src/unit.c
index 07978134de..ab6eb20227 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -1880,6 +1880,16 @@ static char *specifier_instance_unescaped(char specifier, void *data, void *user
return strdup("");
}
+static char *specifier_filename(char specifier, void *data, void *userdata) {
+ Unit *u = userdata;
+ assert(u);
+
+ if (u->meta.instance)
+ return unit_name_path_unescape(u->meta.instance);
+
+ return unit_name_to_path(u->meta.instance);
+}
+
char *unit_name_printf(Unit *u, const char* format) {
/*
@@ -1918,6 +1928,7 @@ char *unit_full_printf(Unit *u, const char *format) {
{ 'P', specifier_prefix_unescaped, NULL },
{ 'i', specifier_string, u->meta.instance },
{ 'I', specifier_instance_unescaped, NULL },
+ { 'f', specifier_filename, NULL },
{ 0, NULL, NULL }
};