diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-10-07 03:39:30 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-10-07 03:39:30 +0200 |
commit | 692ce73899285c6ed07e93084a5f830a9a8effcc (patch) | |
tree | fb57aacd95086eb35787f902353857daf3f8fe95 /src/pulsecore/core-util.c | |
parent | b3592a160f0d2a28605048a81c0261bf7c45acbb (diff) | |
parent | 019331d25b6af107fb8cacc3ada552e7567a64bf (diff) |
Merge remote branch 'tanuk/dbus-work'
Diffstat (limited to 'src/pulsecore/core-util.c')
-rw-r--r-- | src/pulsecore/core-util.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 8e98e857..27e09cbc 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -2678,6 +2678,28 @@ char *pa_replace(const char*s, const char*a, const char *b) { return pa_strbuf_tostring_free(sb); } +char *pa_escape(const char *p, const char *chars) { + const char *s; + const char *c; + pa_strbuf *buf = pa_strbuf_new(); + + for (s = p; *s; ++s) { + if (*s == '\\') + pa_strbuf_putc(buf, '\\'); + else if (chars) { + for (c = chars; *c; ++c) { + if (*s == *c) { + pa_strbuf_putc(buf, '\\'); + break; + } + } + } + pa_strbuf_putc(buf, *s); + } + + return pa_strbuf_tostring_free(buf); +} + char *pa_unescape(char *p) { char *s, *d; pa_bool_t escaped = FALSE; |