summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-internal.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-10-30 13:52:40 +0100
committerLennart Poettering <lennart@poettering.net>2013-10-30 15:35:49 +0100
commit0f8bd8debb0ff7f5bff7738841931f6c41e40bc1 (patch)
tree50ab6e129131fd301e1665b15e8896ea80ff2e74 /src/libsystemd-bus/bus-internal.c
parent2004d23a0fcaa6e74631057a2ff75594a038d86e (diff)
bus: move ssh support into public API of libsystem-bus
Diffstat (limited to 'src/libsystemd-bus/bus-internal.c')
-rw-r--r--src/libsystemd-bus/bus-internal.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libsystemd-bus/bus-internal.c b/src/libsystemd-bus/bus-internal.c
index 942ac2b953..0bea8cac49 100644
--- a/src/libsystemd-bus/bus-internal.c
+++ b/src/libsystemd-bus/bus-internal.c
@@ -277,3 +277,29 @@ const char *bus_message_type_to_string(uint8_t u) {
else
return NULL;
}
+
+char *bus_address_escape(const char *v) {
+ const char *a;
+ char *r, *b;
+
+ r = new(char, strlen(v)*3+1);
+ if (!r)
+ return NULL;
+
+ for (a = v, b = r; *a; a++) {
+
+ if ((*a >= '0' && *a <= '9') ||
+ (*a >= 'a' && *a <= 'z') ||
+ (*a >= 'A' && *a <= 'Z') ||
+ strchr("_-/.", *a))
+ *(b++) = *a;
+ else {
+ *(b++) = '%';
+ *(b++) = hexchar(*a >> 4);
+ *(b++) = hexchar(*a & 0xF);
+ }
+ }
+
+ *b = 0;
+ return r;
+}