diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-01-31 16:21:00 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-02-12 20:00:42 -0500 |
commit | 95052df3760523e1f3bb9705c918d85aae7fb431 (patch) | |
tree | a5d8b8516314a5e751787db02d405783cf6fd5f6 /src/basic/escape.c | |
parent | fa45182ed6b833017dde5a7cee27cdf25985790a (diff) | |
download | systemd-95052df3760523e1f3bb9705c918d85aae7fb431.tar.gz systemd-95052df3760523e1f3bb9705c918d85aae7fb431.tar.bz2 systemd-95052df3760523e1f3bb9705c918d85aae7fb431.zip |
resolve: parse CAA records
Diffstat (limited to 'src/basic/escape.c')
-rw-r--r-- | src/basic/escape.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/basic/escape.c b/src/basic/escape.c index f276c36c56..d59aa9f42f 100644 --- a/src/basic/escape.c +++ b/src/basic/escape.c @@ -415,6 +415,34 @@ char *xescape(const char *s, const char *bad) { return r; } +char *octescape(const char *s, size_t len) { + char *r, *t; + const char *f; + + /* Escapes all chars in bad, in addition to \ and " chars, + * in \nnn style escaping. */ + + r = new(char, len * 4 + 1); + if (!r) + return NULL; + + for (f = s, t = r; f < s + len; f++) { + + if (*f < ' ' || *f >= 127 || *f == '\\' || *f == '"') { + *(t++) = '\\'; + *(t++) = '0' + (*f >> 6); + *(t++) = '0' + ((*f >> 3) & 8); + *(t++) = '0' + (*f & 8); + } else + *(t++) = *f; + } + + *t = 0; + + return r; + +} + static char *strcpy_backslash_escaped(char *t, const char *s, const char *bad) { assert(bad); |