aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-24 16:55:17 +0100
committerMax Kellermann <max@duempel.org>2014-01-24 16:55:17 +0100
commit9b1fbdbca63f03c357a2f9c01fca281f62b3570c (patch)
treef093e063f77625e1380e7b1e8f5654a4be254d85 /src/playlist
parent97391fd4b975eab7049c31c88b8a118be430c427 (diff)
downloadmpd-9b1fbdbca63f03c357a2f9c01fca281f62b3570c.tar.gz
mpd-9b1fbdbca63f03c357a2f9c01fca281f62b3570c.tar.xz
mpd-9b1fbdbca63f03c357a2f9c01fca281f62b3570c.zip
ConfigGlobal: add config_find_block()
Merge duplicate code.
Diffstat (limited to 'src/playlist')
-rw-r--r--src/playlist/PlaylistRegistry.cxx30
1 files changed, 2 insertions, 28 deletions
diff --git a/src/playlist/PlaylistRegistry.cxx b/src/playlist/PlaylistRegistry.cxx
index 5e6db15f4..55064849b 100644
--- a/src/playlist/PlaylistRegistry.cxx
+++ b/src/playlist/PlaylistRegistry.cxx
@@ -37,7 +37,6 @@
#include "util/Macros.hxx"
#include "config/ConfigGlobal.hxx"
#include "config/ConfigData.hxx"
-#include "system/FatalError.hxx"
#include "Log.hxx"
#include <assert.h>
@@ -73,32 +72,6 @@ static bool playlist_plugins_enabled[n_playlist_plugins];
playlist_plugins_for_each(plugin) \
if (playlist_plugins_enabled[playlist_plugin_iterator - playlist_plugins])
-/**
- * Find the "playlist" configuration block for the specified plugin.
- *
- * @param plugin_name the name of the playlist plugin
- * @return the configuration block, or nullptr if none was configured
- */
-static const struct config_param *
-playlist_plugin_config(const char *plugin_name)
-{
- const struct config_param *param = nullptr;
-
- assert(plugin_name != nullptr);
-
- while ((param = config_get_next_param(CONF_PLAYLIST_PLUGIN, param)) != nullptr) {
- const char *name = param->GetBlockValue("name");
- if (name == nullptr)
- FormatFatalError("playlist configuration without 'plugin' name in line %d",
- param->line);
-
- if (strcmp(name, plugin_name) == 0)
- return param;
- }
-
- return nullptr;
-}
-
void
playlist_list_global_init(void)
{
@@ -107,7 +80,8 @@ playlist_list_global_init(void)
for (unsigned i = 0; playlist_plugins[i] != nullptr; ++i) {
const struct playlist_plugin *plugin = playlist_plugins[i];
const struct config_param *param =
- playlist_plugin_config(plugin->name);
+ config_find_block(CONF_PLAYLIST_PLUGIN, "name",
+ plugin->name);
if (param == nullptr)
param = &empty;
else if (!param->GetBlockValue("enabled", true))