[pulseaudio-discuss] [PATCH 1/2] conf-parser: New function: pa_config_parse_proplist().

Tanu Kaskinen tanuk at iki.fi
Fri Dec 2 12:31:02 PST 2011


From: Tanu Kaskinen <tanu.kaskinen at digia.com>

---
 src/pulsecore/conf-parser.c |   24 ++++++++++++++++++++++++
 src/pulsecore/conf-parser.h |    5 ++++-
 2 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/src/pulsecore/conf-parser.c b/src/pulsecore/conf-parser.c
index 7152955..673ca37 100644
--- a/src/pulsecore/conf-parser.c
+++ b/src/pulsecore/conf-parser.c
@@ -287,3 +287,27 @@ int pa_config_parse_string(const char *filename, unsigned line, const char *sect
     *s = *rvalue ? pa_xstrdup(rvalue) : NULL;
     return 0;
 }
+
+int pa_config_parse_proplist(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata) {
+    pa_proplist *parsed = NULL;
+    pa_proplist **p = data;
+
+    pa_assert(filename);
+    pa_assert(lvalue);
+    pa_assert(rvalue);
+    pa_assert(data);
+
+    if (!(parsed = pa_proplist_from_string(rvalue))) {
+        pa_log("[%s:%u] Failed to parse property list: %s", filename, line, rvalue);
+        return -1;
+    }
+
+    if (!*p)
+        *p = parsed;
+    else {
+        pa_proplist_update(*p, PA_UPDATE_REPLACE, parsed);
+        pa_proplist_free(parsed);
+    }
+
+    return 0;
+}
diff --git a/src/pulsecore/conf-parser.h b/src/pulsecore/conf-parser.h
index c6c8a14..f8c0e44 100644
--- a/src/pulsecore/conf-parser.h
+++ b/src/pulsecore/conf-parser.h
@@ -24,6 +24,8 @@
 
 #include <stdio.h>
 
+#include <pulse/proplist.h>
+
 /* An abstract parser for simple, line based, shallow configuration
  * files consisting of variable assignments only. */
 
@@ -42,12 +44,13 @@ typedef struct pa_config_item {
  * NULL */
 int pa_config_parse(const char *filename, FILE *f, const pa_config_item *t, void *userdata);
 
-/* Generic parsers for integers, size_t, booleans and strings */
+/* Generic parsers for integers, size_t, booleans, strings and proplists */
 int pa_config_parse_int(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
 int pa_config_parse_unsigned(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
 int pa_config_parse_size(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
 int pa_config_parse_bool(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
 int pa_config_parse_not_bool(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
 int pa_config_parse_string(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
+int pa_config_parse_proplist(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
 
 #endif
-- 
1.7.7.3



More information about the pulseaudio-discuss mailing list