libobs/util: Add config_remove_value function

This commit is contained in:
jp9000
2015-07-03 09:48:49 -07:00
parent 526b9e6bc1
commit 6bf2be407b
2 changed files with 32 additions and 0 deletions

View File

@@ -609,6 +609,35 @@ double config_get_double(const config_t *config, const char *section,
return 0.0;
}
bool config_remove_value(config_t *config, const char *section,
const char *name)
{
struct darray *sections = &config->sections;
for (size_t i = 0; i < sections->num; i++) {
struct config_section *sec = darray_item(
sizeof(struct config_section), sections, i);
if (astrcmpi(sec->name, section) != 0)
continue;
for (size_t j = 0; j < sec->items.num; j++) {
struct config_item *item = darray_item(
sizeof(struct config_item),
&sec->items, j);
if (astrcmpi(item->name, name) == 0) {
config_item_free(item);
darray_erase(sizeof(struct config_item),
&sec->items, j);
return true;
}
}
}
return false;
}
const char *config_get_default_string(const config_t *config,
const char *section, const char *name)
{

View File

@@ -73,6 +73,9 @@ EXPORT bool config_get_bool(const config_t *config, const char *section,
EXPORT double config_get_double(const config_t *config, const char *section,
const char *name);
EXPORT bool config_remove_value(config_t *config, const char *section,
const char *name);
/*
* DEFAULT VALUES
*