config: add config_get_table helper function

This commit is contained in:
Arnaud Ferraris
2021-11-24 01:02:11 +01:00
parent d9725981bb
commit f8b3e28434
2 changed files with 15 additions and 0 deletions

View File

@@ -81,3 +81,17 @@ gboolean config_get_array(toml_table_t **config, const gchar *key, toml_array_t
return !!array;
}
gboolean config_get_table(toml_table_t **config, const gchar *key, toml_table_t **result)
{
toml_table_t *table = NULL;
if (config[EG25_CONFIG_USER])
table = toml_table_in(config[EG25_CONFIG_USER], key);
if (!table)
table = toml_table_in(config[EG25_CONFIG_SYS], key);
if (table && result)
*result = table;
return !!table;
}