diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-04-21 03:27:44 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-04-21 03:27:44 +0200 |
commit | a16e112358ea8fea381ee106b89e645aed8b0a8c (patch) | |
tree | f38b204ec041c25974397a7711a105cbe7509c07 /unit-name.c | |
parent | 0d9068141e07ba29483ebe8bc4aaed6aacde1562 (diff) |
reload: implement reload/reexec logic
Diffstat (limited to 'unit-name.c')
-rw-r--r-- | unit-name.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/unit-name.c b/unit-name.c index 5053d30f29..5d428dd446 100644 --- a/unit-name.c +++ b/unit-name.c @@ -371,3 +371,43 @@ char *unit_name_template(const char *f) { return r; } + +char *unit_name_from_path(const char *path, const char *suffix) { + assert(path); + assert(suffix); + + if (path[0] == '/') + path++; + + if (path[0] == 0) + return strappend("-", suffix); + + return unit_name_build_escape(path, NULL, suffix); +} + +char *unit_name_to_path(const char *name) { + char *w, *e; + + assert(name); + + if (!(w = unit_name_to_prefix(name))) + return NULL; + + e = unit_name_unescape(w); + free(w); + + if (!e) + return NULL; + + if (e[0] != '/') { + w = strappend("/", e); + free(e); + + if (!w) + return NULL; + + e = w; + } + + return e; +} |