X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Futil.c;h=f1a7bbdc7124b1d977d536fcb4c83bea80213478;hp=7903ca07b99fe64d493948f579eb9e34f3adbd31;hb=11ce3427242b8b4ddf638ed5703d69041d719b4c;hpb=d06dacd0020af7e31ff6089deff339b00ed979e3 diff --git a/src/util.c b/src/util.c index 7903ca07b..f1a7bbdc7 100644 --- a/src/util.c +++ b/src/util.c @@ -3004,6 +3004,19 @@ int touch(const char *path) { return 0; } +char *unquote(const char *s, const char quote) { + size_t l; + assert(s); + + if ((l = strlen(s)) < 2) + return strdup(s); + + if (s[0] == quote && s[l-1] == quote) + return strndup(s+1, l-2); + + return strdup(s); +} + static const char *const ioprio_class_table[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime",