aboutsummaryrefslogtreecommitdiffstats
path: root/src/config/ConfigGlobal.cxx
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/config/ConfigGlobal.cxx
parent97391fd4b975eab7049c31c88b8a118be430c427 (diff)
downloadmpd-9b1fbdbca63f03c357a2f9c01fca281f62b3570c.tar.gz
mpd-9b1fbdbca63f03c357a2f9c01fca281f62b3570c.tar.xz
mpd-9b1fbdbca63f03c357a2f9c01fca281f62b3570c.zip
ConfigGlobal: add config_find_block()
Merge duplicate code.
Diffstat (limited to '')
-rw-r--r--src/config/ConfigGlobal.cxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/config/ConfigGlobal.cxx b/src/config/ConfigGlobal.cxx
index c7d16d3e7..dd76e3ca3 100644
--- a/src/config/ConfigGlobal.cxx
+++ b/src/config/ConfigGlobal.cxx
@@ -85,6 +85,23 @@ config_get_next_param(ConfigOption option, const struct config_param * last)
return param;
}
+const config_param *
+config_find_block(ConfigOption option, const char *key, const char *value)
+{
+ const config_param *param = nullptr;
+ while ((param = config_get_next_param(option, param)) != nullptr) {
+ const char *value2 = param->GetBlockValue(key);
+ if (value2 == nullptr)
+ FormatFatalError("block without '%s' name in line %d",
+ key, param->line);
+
+ if (strcmp(value2, value) == 0)
+ return param;
+ }
+
+ return nullptr;
+}
+
const char *
config_get_string(ConfigOption option, const char *default_value)
{