diff options
author | Max Kellermann <max@duempel.org> | 2014-01-24 16:55:17 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-24 16:55:17 +0100 |
commit | 9b1fbdbca63f03c357a2f9c01fca281f62b3570c (patch) | |
tree | f093e063f77625e1380e7b1e8f5654a4be254d85 /src/input/Init.cxx | |
parent | 97391fd4b975eab7049c31c88b8a118be430c427 (diff) |
ConfigGlobal: add config_find_block()
Merge duplicate code.
Diffstat (limited to 'src/input/Init.cxx')
-rw-r--r-- | src/input/Init.cxx | 35 |
1 files changed, 1 insertions, 34 deletions
diff --git a/src/input/Init.cxx b/src/input/Init.cxx index 14a7feef3..4b8eac320 100644 --- a/src/input/Init.cxx +++ b/src/input/Init.cxx @@ -22,7 +22,6 @@ #include "Registry.hxx" #include "InputPlugin.hxx" #include "util/Error.hxx" -#include "util/Domain.hxx" #include "config/ConfigGlobal.hxx" #include "config/ConfigOption.hxx" #include "config/ConfigData.hxx" @@ -30,35 +29,6 @@ #include <assert.h> #include <string.h> -extern constexpr Domain input_domain("input"); - -/** - * Find the "input" configuration block for the specified plugin. - * - * @param plugin_name the name of the input plugin - * @return the configuration block, or nullptr if none was configured - */ -static const struct config_param * -input_plugin_config(const char *plugin_name, Error &error) -{ - const struct config_param *param = nullptr; - - while ((param = config_get_next_param(CONF_INPUT, param)) != nullptr) { - const char *name = param->GetBlockValue("plugin"); - if (name == nullptr) { - error.Format(input_domain, - "input configuration without 'plugin' name in line %d", - param->line); - return nullptr; - } - - if (strcmp(name, plugin_name) == 0) - return param; - } - - return nullptr; -} - bool input_stream_global_init(Error &error) { @@ -72,11 +42,8 @@ input_stream_global_init(Error &error) assert(plugin->open != nullptr); const struct config_param *param = - input_plugin_config(plugin->name, error); + config_find_block(CONF_INPUT, "plugin", plugin->name); if (param == nullptr) { - if (error.IsDefined()) - return false; - param = ∅ } else if (!param->GetBlockValue("enabled", true)) /* the plugin is disabled in mpd.conf */ |