diff --git a/src/config.c b/src/config.c index d4ce151..2c5aafa 100644 --- a/src/config.c +++ b/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; +} diff --git a/src/config.h b/src/config.h index d1a214f..5f2d1e2 100644 --- a/src/config.h +++ b/src/config.h @@ -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);