mirror of
https://gitlab.com/mobian1/eg25-manager.git
synced 2025-08-28 23:03:24 +02:00
config: add config_get_table helper function
This commit is contained in:
14
src/config.c
14
src/config.c
@@ -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;
|
||||
}
|
||||
|
@@ -24,3 +24,4 @@ gboolean config_get_int(toml_table_t **config, const gchar *key, gint *result);
|
||||
gboolean config_get_uint(toml_table_t **config, const gchar *key, guint *result);
|
||||
gboolean config_get_string(toml_table_t **config, const gchar *key, gchar **result);
|
||||
gboolean config_get_array(toml_table_t **config, const gchar *key, toml_array_t **result);
|
||||
gboolean config_get_table(toml_table_t **config, const gchar *key, toml_table_t **result);
|
||||
|
Reference in New Issue
Block a user