context: implement prop updates with for_each

This commit is contained in:
Wim Taymans 2022-02-01 16:51:59 +01:00
parent 432f464297
commit 5839400aa0
2 changed files with 18 additions and 14 deletions

View file

@ -753,3 +753,21 @@ int pw_context_parse_conf_section(struct pw_context *context,
return data.count;
}
static int update_props(void *user_data, const char *location, const char *key,
const char *val, size_t len)
{
struct data *data = user_data;
data->count += pw_properties_update_string(data->props, val, len);
return 0;
}
SPA_EXPORT
int pw_context_conf_update_props(struct pw_context *context,
const char *section, struct pw_properties *props)
{
struct data data = { .context = context, .props = props };
pw_context_conf_section_for_each(context, section,
update_props, &data);
return data.count;
}

View file

@ -537,20 +537,6 @@ const char *pw_context_get_conf_section(struct pw_context *context, const char *
return pw_properties_get(context->conf, section);
}
SPA_EXPORT
int pw_context_conf_update_props(struct pw_context *context,
const char *section, struct pw_properties *props)
{
struct pw_properties *conf = context->conf;
const char *str;
int count = 0;
if ((str = pw_properties_get(conf, section)) != NULL)
count = pw_properties_update_string(props, str, strlen(str));
return count;
}
/** Update context properties
*
* \param context a context