summaryrefslogtreecommitdiff
path: root/src/shared/bus-label.h
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2015-04-10 17:43:04 +0200
committerDavid Herrmann <dh.herrmann@gmail.com>2015-04-11 13:14:57 +0200
commitad922737f743a82ce95c5554c36e38016678e68e (patch)
treea775e432d54f0d35df9a88d3c811857373bd151f /src/shared/bus-label.h
parentcfe561a456c9ce61579c8e1207f9a13faf050e8a (diff)
bus: implement bus_label_unescape_n()
This is like bus_label_unescape() but takes a maximum length instead of relying on NULL-terminated strings. This is highly useful to unescape labels that are not at the end of a path.
Diffstat (limited to 'src/shared/bus-label.h')
-rw-r--r--src/shared/bus-label.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/shared/bus-label.h b/src/shared/bus-label.h
index c27c8517fd..ed1dc4e0a7 100644
--- a/src/shared/bus-label.h
+++ b/src/shared/bus-label.h
@@ -21,5 +21,12 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include <stdlib.h>
+#include <string.h>
+
char *bus_label_escape(const char *s);
-char *bus_label_unescape(const char *f);
+char *bus_label_unescape_n(const char *f, size_t l);
+
+static inline char *bus_label_unescape(const char *f) {
+ return bus_label_unescape_n(f, f ? strlen(f) : 0);
+}