summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-03-30 15:21:06 +0100
committerLennart Poettering <lennart@poettering.net>2013-03-30 15:21:55 +0100
commit2181a7f558eb52a22f09f8add9ac0abb4f2ee016 (patch)
tree0de6c09897dd3ff80d13a9ccfab62839e2234ae5 /src/shared/util.c
parenta3de5ae1d7d881bbd4869c6c4a200c84bda00ced (diff)
bus: implement server mode, and anonymous authentication
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 7281cc8ab8..873c95820a 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1069,6 +1069,32 @@ char *hexmem(const void *p, size_t l) {
return r;
}
+void *unhexmem(const char *p, size_t l) {
+ uint8_t *r, *z;
+ const char *x;
+
+ assert(p);
+
+ z = r = malloc((l + 1) / 2 + 1);
+ if (!r)
+ return NULL;
+
+ for (x = p; x < p + l; x += 2) {
+ int a, b;
+
+ a = unhexchar(x[0]);
+ if (x+1 < p + l)
+ b = unhexchar(x[1]);
+ else
+ b = 0;
+
+ *(z++) = (uint8_t) a << 4 | (uint8_t) b;
+ }
+
+ *z = 0;
+ return r;
+}
+
char octchar(int x) {
return '0' + (x & 7);
}