summaryrefslogtreecommitdiff
path: root/src/shared
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
parenta3de5ae1d7d881bbd4869c6c4a200c84bda00ced (diff)
bus: implement server mode, and anonymous authentication
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/util.c26
-rw-r--r--src/shared/util.h2
2 files changed, 28 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);
}
diff --git a/src/shared/util.h b/src/shared/util.h
index 485733f650..0d05cd6653 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -609,5 +609,7 @@ static inline void *mempset(void *s, int c, size_t n) {
}
char *hexmem(const void *p, size_t l);
+void *unhexmem(const char *p, size_t l);
+
char *strextend(char **x, ...);
char *strrep(const char *s, unsigned n);