diff options
author | Max Kellermann <max@duempel.org> | 2013-01-30 17:52:51 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-30 21:36:04 +0100 |
commit | 595b6a4f6c2a6f12fb2b3c83f4053942844ffa84 (patch) | |
tree | bdfaf87414fac0359a8fd2e15911098fbe9d6348 /test | |
parent | daa46477125145dd943122c8064c7271a1a9429f (diff) | |
download | mpd-595b6a4f6c2a6f12fb2b3c83f4053942844ffa84.tar.gz mpd-595b6a4f6c2a6f12fb2b3c83f4053942844ffa84.tar.xz mpd-595b6a4f6c2a6f12fb2b3c83f4053942844ffa84.zip |
ConfigFile: add enum ConfigOption
Look up top-level config options by enum (= integer), not by name
string.
Diffstat (limited to 'test')
-rw-r--r-- | test/dump_rva2.c | 3 | ||||
-rw-r--r-- | test/read_conf.cxx | 5 | ||||
-rw-r--r-- | test/run_convert.c | 3 | ||||
-rw-r--r-- | test/run_filter.cxx | 6 | ||||
-rw-r--r-- | test/run_output.cxx | 4 |
5 files changed, 13 insertions, 8 deletions
diff --git a/test/dump_rva2.c b/test/dump_rva2.c index 4a726518a..bb47fc137 100644 --- a/test/dump_rva2.c +++ b/test/dump_rva2.c @@ -33,7 +33,8 @@ #include <stdlib.h> const char * -config_get_string(G_GNUC_UNUSED const char *name, const char *default_value) +config_get_string(gcc_unused enum ConfigOption option, + const char *default_value) { return default_value; } diff --git a/test/read_conf.cxx b/test/read_conf.cxx index a9135d892..8759398da 100644 --- a/test/read_conf.cxx +++ b/test/read_conf.cxx @@ -57,7 +57,10 @@ int main(int argc, char **argv) return 1; } - const char *value = config_get_string(name, NULL); + ConfigOption option = ParseConfigOptionName(name); + const char *value = option != CONF_MAX + ? config_get_string(option, nullptr) + : nullptr; int ret; if (value != NULL) { g_print("%s\n", value); diff --git a/test/run_convert.c b/test/run_convert.c index 21be83f73..bdb3d2cf0 100644 --- a/test/run_convert.c +++ b/test/run_convert.c @@ -48,7 +48,8 @@ my_log_func(const gchar *log_domain, G_GNUC_UNUSED GLogLevelFlags log_level, } const char * -config_get_string(G_GNUC_UNUSED const char *name, const char *default_value) +config_get_string(gcc_unused enum ConfigOption option, + const char *default_value) { return default_value; } diff --git a/test/run_filter.cxx b/test/run_filter.cxx index b05e458aa..dbf6caa97 100644 --- a/test/run_filter.cxx +++ b/test/run_filter.cxx @@ -56,11 +56,11 @@ my_log_func(const gchar *log_domain, G_GNUC_UNUSED GLogLevelFlags log_level, } static const struct config_param * -find_named_config_block(const char *block, const char *name) +find_named_config_block(ConfigOption option, const char *name) { const struct config_param *param = NULL; - while ((param = config_get_next_param(block, param)) != NULL) { + while ((param = config_get_next_param(option, param)) != NULL) { const char *current_name = config_get_block_string(param, "name", NULL); if (current_name != NULL && strcmp(current_name, name) == 0) @@ -77,7 +77,7 @@ load_filter(const char *name) struct filter *filter; GError *error = NULL; - param = find_named_config_block("filter", name); + param = find_named_config_block(CONF_AUDIO_FILTER, name); if (param == NULL) { g_printerr("No such configured filter: %s\n", name); return nullptr; diff --git a/test/run_output.cxx b/test/run_output.cxx index 38f24fe5f..ec94beaad 100644 --- a/test/run_output.cxx +++ b/test/run_output.cxx @@ -81,11 +81,11 @@ filter_plugin_by_name(G_GNUC_UNUSED const char *name) } static const struct config_param * -find_named_config_block(const char *block, const char *name) +find_named_config_block(ConfigOption option, const char *name) { const struct config_param *param = NULL; - while ((param = config_get_next_param(block, param)) != NULL) { + while ((param = config_get_next_param(option, param)) != NULL) { const char *current_name = config_get_block_string(param, "name", NULL); if (current_name != NULL && strcmp(current_name, name) == 0) |