]> code.delx.au - pulseaudio/commitdiff
sample: introduce pa_proplist_setp()
authorLennart Poettering <lennart@poettering.net>
Mon, 25 May 2009 21:50:18 +0000 (23:50 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 25 May 2009 21:50:18 +0000 (23:50 +0200)
src/map-file
src/pulse/proplist.c
src/pulse/proplist.h

index c6a576ed5dbd7675bc4701d34f998ef354ed88a4..201e837a5f86fb0fa564a5ae06a7e4f9bc3f39e3 100644 (file)
@@ -175,6 +175,7 @@ pa_proplist_iterate;
 pa_proplist_new;
 pa_proplist_set;
 pa_proplist_setf;
+pa_proplist_setp;
 pa_proplist_sets;
 pa_proplist_size;
 pa_proplist_to_string;
index db4c9344ffa60b97e0fcb17b3d1cbb496629e8fa..c904f533e9ec6b9fa52b7118c82efb14c49f3ac7 100644 (file)
@@ -140,6 +140,21 @@ static int proplist_setn(pa_proplist *p, const char *key, size_t key_length, con
     return 0;
 }
 
+/** Will accept only valid UTF-8 */
+int pa_proplist_setp(pa_proplist *p, const char *pair) {
+    const char *t;
+
+    pa_assert(p);
+    pa_assert(pair);
+
+    if (!(t = strchr(pair, '=')))
+        return -1;
+
+    return proplist_setn(p,
+                         pair, t - pair,
+                         t + 1, strchr(pair, 0) - t - 1);
+}
+
 static int proplist_sethex(pa_proplist *p, const char *key, size_t key_length, const char *value, size_t value_length) {
     struct property *prop;
     pa_bool_t add = FALSE;
index 2e7e5ad0ede08f82649b9b9b4419fc2c4be97063..7d680d061e1a43ab64b0e748d68ce472ef18819e 100644 (file)
@@ -231,6 +231,14 @@ void pa_proplist_free(pa_proplist* p);
  * UTF-8. \since 0.9.11 */
 int pa_proplist_sets(pa_proplist *p, const char *key, const char *value);
 
+/** Append a new string entry to the property list, possibly
+ * overwriting an already existing entry with the same key. An
+ * internal copy of the data passed is made. Will accept only valid
+ * UTF-8. The string passed in must contain a '='. Left hand side of
+ * the '=' is used as key name, the right hand side as string
+ * data. \since 0.9.16 */
+int pa_proplist_setp(pa_proplist *p, const char *pair);
+
 /** Append a new string entry to the property list, possibly
  * overwriting an already existing entry with the same key. An
  * internal copy of the data passed is made. Will accept only valid