aboutsummaryrefslogtreecommitdiffstats
path: root/src/FilterConfig.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-19 16:26:51 +0200
committerMax Kellermann <max@duempel.org>2013-10-19 16:26:51 +0200
commit04a737e04cccaf6c7b609ad45992bbf60b037904 (patch)
tree4530b14dbbe087536233b4f46025d378442f258f /src/FilterConfig.cxx
parent966c54bef570d1f42b7b4990f75391c47e20bdf2 (diff)
downloadmpd-04a737e04cccaf6c7b609ad45992bbf60b037904.tar.gz
mpd-04a737e04cccaf6c7b609ad45992bbf60b037904.tar.xz
mpd-04a737e04cccaf6c7b609ad45992bbf60b037904.zip
FilterConfig: move code to filter_chain_append_new()
Diffstat (limited to '')
-rw-r--r--src/FilterConfig.cxx39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/FilterConfig.cxx b/src/FilterConfig.cxx
index dec75766c..2af44b9c0 100644
--- a/src/FilterConfig.cxx
+++ b/src/FilterConfig.cxx
@@ -64,6 +64,28 @@ filter_plugin_config(const char *filter_template_name, Error &error)
return NULL;
}
+static bool
+filter_chain_append_new(Filter &chain, const char *template_name, Error &error)
+{
+ const struct config_param *cfg =
+ filter_plugin_config(template_name, error);
+ if (cfg == nullptr)
+ // The error has already been set, just stop.
+ return false;
+
+ // Instantiate one of those filter plugins with the template name as a hint
+ Filter *f = filter_configured_new(*cfg, error);
+ if (f == nullptr)
+ // The error has already been set, just stop.
+ return false;
+
+ const char *plugin_name = cfg->GetBlockValue("plugin",
+ "unknown");
+ filter_chain_append(chain, plugin_name, f);
+
+ return true;
+}
+
unsigned int
filter_chain_parse(Filter &chain, const char *spec, Error &error)
{
@@ -79,24 +101,9 @@ filter_chain_parse(Filter &chain, const char *spec, Error &error)
// Squeeze whitespace
g_strstrip(*template_names);
- const struct config_param *cfg =
- filter_plugin_config(*template_names, error);
- if (cfg == NULL) {
- // The error has already been set, just stop.
- break;
- }
-
- // Instantiate one of those filter plugins with the template name as a hint
- Filter *f = filter_configured_new(*cfg, error);
- if (f == NULL) {
- // The error has already been set, just stop.
+ if (!filter_chain_append_new(chain, *template_names, error))
break;
- }
-
- const char *plugin_name = cfg->GetBlockValue("plugin",
- "unknown");
- filter_chain_append(chain, plugin_name, f);
++added_filters;
++template_names;