summaryrefslogtreecommitdiffstats
path: root/src/pulse/proplist.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-01-17 01:59:37 +0100
committerLennart Poettering <lennart@poettering.net>2009-01-17 01:59:37 +0100
commita45f971e43ed22f73c681bb9962aa9717534d0a2 (patch)
treed140183e5bd5c33b5f822124a109085b21c1f9c3 /src/pulse/proplist.c
parent4a66837b83d85ef9cad61f1d0e9fb776b0236368 (diff)
add pa_proplist_to_string_sep()
Diffstat (limited to 'src/pulse/proplist.c')
-rw-r--r--src/pulse/proplist.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index 60a92d44..282fe5cc 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -259,21 +259,24 @@ const char *pa_proplist_iterate(pa_proplist *p, void **state) {
return prop->key;
}
-char *pa_proplist_to_string(pa_proplist *p) {
+char *pa_proplist_to_string_sep(pa_proplist *p, const char *sep) {
const char *key;
void *state = NULL;
pa_strbuf *buf;
pa_assert(p);
+ pa_assert(sep);
buf = pa_strbuf_new();
while ((key = pa_proplist_iterate(p, &state))) {
-
const char *v;
+ if (!pa_strbuf_isempty(buf))
+ pa_strbuf_puts(buf, sep);
+
if ((v = pa_proplist_gets(p, key)))
- pa_strbuf_printf(buf, "%s = \"%s\"\n", key, v);
+ pa_strbuf_printf(buf, "%s = \"%s\"", key, v);
else {
const void *value;
size_t nbytes;
@@ -283,7 +286,7 @@ char *pa_proplist_to_string(pa_proplist *p) {
c = pa_xmalloc(nbytes*2+1);
pa_hexstr((const uint8_t*) value, nbytes, c, nbytes*2+1);
- pa_strbuf_printf(buf, "%s = hex:%s\n", key, c);
+ pa_strbuf_printf(buf, "%s = hex:%s", key, c);
pa_xfree(c);
}
}
@@ -291,6 +294,16 @@ char *pa_proplist_to_string(pa_proplist *p) {
return pa_strbuf_tostring_free(buf);
}
+char *pa_proplist_to_string(pa_proplist *p) {
+ char *s, *t;
+
+ s = pa_proplist_to_string_sep(p, "\n");
+ t = pa_sprintf_malloc("%s\n", s);
+ pa_xfree(s);
+
+ return t;
+}
+
/* Remove all whitepsapce from the beginning and the end of *s. *s may
* be modified. (from conf-parser.c) */
#define WHITESPACE " \t\n"