chiark / gitweb /
unit: introduce %f specifier to decode file names
[elogind.git] / src / unit-name.c
index dbaa4a7b12c3acdf5b02b323e236477e0336d8cb..d0cfca62549cb9af5329d7a84e491de355679903 100644 (file)
@@ -427,3 +427,26 @@ char *unit_name_to_path(const char *name) {
 
         return e;
 }
+
+char *unit_name_path_unescape(const char *f) {
+        char *e;
+
+        assert(f);
+
+        if (!(e = unit_name_unescape(f)))
+                return NULL;
+
+        if (e[0] != '/') {
+                char *w;
+
+                w = strappend("/", e);
+                free(e);
+
+                if (!w)
+                        return NULL;
+
+                e = w;
+        }
+
+        return e;
+}