static int parse_properties(pa_config_parser_state *state) { struct rule *r; pa_proplist *n; pa_assert(state); r = state->userdata; if (!(n = pa_proplist_from_string(state->rvalue))) return -1; if (r->proplist) { pa_proplist_update(r->proplist, PA_UPDATE_MERGE, n); pa_proplist_free(n); } else r->proplist = n; return 0; }
static int parse_properties( const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata) { struct rule *r = userdata; pa_proplist *n; if (!(n = pa_proplist_from_string(rvalue))) return -1; if (r->proplist) { pa_proplist_update(r->proplist, PA_UPDATE_MERGE, n); pa_proplist_free(n); } else r->proplist = n; return 0; }
pa_format_info* pa_format_info_from_string(const char *str) { pa_format_info *f = pa_format_info_new(); char *encoding = NULL, *properties = NULL; size_t pos; pos = strcspn(str, ","); encoding = pa_xstrndup(str, pos); f->encoding = pa_encoding_from_string(pa_strip(encoding)); if (f->encoding == PA_ENCODING_INVALID) goto error; if (pos != strlen(str)) { pa_proplist *plist; properties = pa_xstrdup(&str[pos+1]); plist = pa_proplist_from_string(properties); if (!plist) goto error; pa_proplist_free(f->plist); f->plist = plist; } out: if (encoding) pa_xfree(encoding); if (properties) pa_xfree(properties); return f; error: pa_format_info_free(f); f = NULL; goto out; }