From 9fc507041eb524799a0410839e961ec188a78491 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 20 Oct 2010 16:16:45 +0200 Subject: unit: introduce %f specifier to decode file names --- src/unit.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/unit.c') 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 } }; -- cgit v1.2.3-54-g00ecf