From 197b503f3ecbf68191b37a7c5fb9c25e975059ce Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 24 Jan 2014 00:20:01 +0100 Subject: Config*: move to config/ --- Makefile.am | 18 +- src/AudioConfig.cxx | 6 +- src/ClientGlobal.cxx | 2 +- src/CommandLine.cxx | 2 +- src/ConfigData.cxx | 159 ------------- src/ConfigData.hxx | 134 ----------- src/ConfigDefaults.hxx | 26 --- src/ConfigError.cxx | 23 -- src/ConfigError.hxx | 25 -- src/ConfigFile.cxx | 269 ---------------------- src/ConfigFile.hxx | 30 --- src/ConfigGlobal.cxx | 175 -------------- src/ConfigGlobal.hxx | 95 -------- src/ConfigOption.hxx | 90 -------- src/ConfigParser.cxx | 40 ---- src/ConfigParser.hxx | 26 --- src/ConfigPath.cxx | 131 ----------- src/ConfigPath.hxx | 29 --- src/ConfigTemplates.cxx | 96 -------- src/ConfigTemplates.hxx | 31 --- src/DatabaseGlue.cxx | 2 +- src/DespotifyUtils.cxx | 4 +- src/FilterConfig.cxx | 8 +- src/FilterPlugin.cxx | 4 +- src/InputInit.cxx | 6 +- src/Listen.cxx | 6 +- src/LogInit.cxx | 6 +- src/Main.cxx | 8 +- src/Permission.cxx | 6 +- src/PlaylistFile.cxx | 6 +- src/PlaylistState.cxx | 4 +- src/ReplayGainConfig.cxx | 4 +- src/UpdateWalk.cxx | 4 +- src/config/ConfigData.cxx | 159 +++++++++++++ src/config/ConfigData.hxx | 134 +++++++++++ src/config/ConfigDefaults.hxx | 26 +++ src/config/ConfigError.cxx | 23 ++ src/config/ConfigError.hxx | 25 ++ src/config/ConfigFile.cxx | 269 ++++++++++++++++++++++ src/config/ConfigFile.hxx | 30 +++ src/config/ConfigGlobal.cxx | 175 ++++++++++++++ src/config/ConfigGlobal.hxx | 95 ++++++++ src/config/ConfigOption.hxx | 90 ++++++++ src/config/ConfigParser.cxx | 40 ++++ src/config/ConfigParser.hxx | 26 +++ src/config/ConfigPath.cxx | 131 +++++++++++ src/config/ConfigPath.hxx | 29 +++ src/config/ConfigTemplates.cxx | 96 ++++++++ src/config/ConfigTemplates.hxx | 31 +++ src/db/ProxyDatabasePlugin.cxx | 2 +- src/db/SimpleDatabasePlugin.cxx | 2 +- src/db/UpnpDatabasePlugin.cxx | 2 +- src/decoder/DecoderAPI.hxx | 2 +- src/decoder/DecoderList.cxx | 4 +- src/decoder/plugins/MadDecoderPlugin.cxx | 2 +- src/encoder/EncoderAPI.hxx | 2 +- src/encoder/plugins/FlacEncoderPlugin.cxx | 2 +- src/encoder/plugins/LameEncoderPlugin.cxx | 2 +- src/encoder/plugins/OpusEncoderPlugin.cxx | 2 +- src/encoder/plugins/ShineEncoderPlugin.cxx | 2 +- src/encoder/plugins/TwolameEncoderPlugin.cxx | 2 +- src/encoder/plugins/VorbisEncoderPlugin.cxx | 2 +- src/filter/AutoConvertFilterPlugin.cxx | 2 +- src/filter/RouteFilterPlugin.cxx | 4 +- src/fs/Config.cxx | 2 +- src/input/CdioParanoiaInputPlugin.cxx | 4 +- src/input/CurlInputPlugin.cxx | 4 +- src/mixer/OssMixerPlugin.cxx | 2 +- src/mixer/SoftwareMixerPlugin.cxx | 2 +- src/output/OutputAPI.hxx | 2 +- src/output/OutputAll.cxx | 6 +- src/output/OutputInit.cxx | 4 +- src/output/plugins/FifoOutputPlugin.cxx | 2 +- src/output/plugins/JackOutputPlugin.cxx | 2 +- src/output/plugins/PipeOutputPlugin.cxx | 2 +- src/output/plugins/RecorderOutputPlugin.cxx | 2 +- src/output/plugins/ShoutOutputPlugin.cxx | 2 +- src/pcm/ConfiguredResampler.cxx | 6 +- src/playlist/PlaylistRegistry.cxx | 4 +- src/playlist/plugins/SoundCloudPlaylistPlugin.cxx | 2 +- src/tag/TagConfig.cxx | 4 +- src/tag/TagId3.cxx | 2 +- src/zeroconf/ZeroconfGlue.cxx | 4 +- test/DumpDatabase.cxx | 4 +- test/dump_playlist.cxx | 2 +- test/dump_rva2.cxx | 2 +- test/dump_text_file.cxx | 2 +- test/read_conf.cxx | 2 +- test/read_mixer.cxx | 2 +- test/run_convert.cxx | 2 +- test/run_encoder.cxx | 2 +- test/run_filter.cxx | 4 +- test/run_input.cxx | 2 +- test/run_output.cxx | 6 +- test/test_vorbis_encoder.cxx | 2 +- test/visit_archive.cxx | 2 +- 96 files changed, 1490 insertions(+), 1490 deletions(-) delete mode 100644 src/ConfigData.cxx delete mode 100644 src/ConfigData.hxx delete mode 100644 src/ConfigDefaults.hxx delete mode 100644 src/ConfigError.cxx delete mode 100644 src/ConfigError.hxx delete mode 100644 src/ConfigFile.cxx delete mode 100644 src/ConfigFile.hxx delete mode 100644 src/ConfigGlobal.cxx delete mode 100644 src/ConfigGlobal.hxx delete mode 100644 src/ConfigOption.hxx delete mode 100644 src/ConfigParser.cxx delete mode 100644 src/ConfigParser.hxx delete mode 100644 src/ConfigPath.cxx delete mode 100644 src/ConfigPath.hxx delete mode 100644 src/ConfigTemplates.cxx delete mode 100644 src/ConfigTemplates.hxx create mode 100644 src/config/ConfigData.cxx create mode 100644 src/config/ConfigData.hxx create mode 100644 src/config/ConfigDefaults.hxx create mode 100644 src/config/ConfigError.cxx create mode 100644 src/config/ConfigError.hxx create mode 100644 src/config/ConfigFile.cxx create mode 100644 src/config/ConfigFile.hxx create mode 100644 src/config/ConfigGlobal.cxx create mode 100644 src/config/ConfigGlobal.hxx create mode 100644 src/config/ConfigOption.hxx create mode 100644 src/config/ConfigParser.cxx create mode 100644 src/config/ConfigParser.hxx create mode 100644 src/config/ConfigPath.cxx create mode 100644 src/config/ConfigPath.hxx create mode 100644 src/config/ConfigTemplates.cxx create mode 100644 src/config/ConfigTemplates.hxx diff --git a/Makefile.am b/Makefile.am index 405f51ef7..77a37d09d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -489,15 +489,15 @@ endif # configuration library libconf_a_SOURCES = \ - src/ConfigDefaults.hxx \ - src/ConfigPath.cxx src/ConfigPath.hxx \ - src/ConfigData.cxx src/ConfigData.hxx \ - src/ConfigParser.cxx src/ConfigParser.hxx \ - src/ConfigGlobal.cxx src/ConfigGlobal.hxx \ - src/ConfigFile.cxx src/ConfigFile.hxx \ - src/ConfigTemplates.cxx src/ConfigTemplates.hxx \ - src/ConfigError.cxx src/ConfigError.hxx \ - src/ConfigOption.hxx + src/config/ConfigDefaults.hxx \ + src/config/ConfigPath.cxx src/config/ConfigPath.hxx \ + src/config/ConfigData.cxx src/config/ConfigData.hxx \ + src/config/ConfigParser.cxx src/config/ConfigParser.hxx \ + src/config/ConfigGlobal.cxx src/config/ConfigGlobal.hxx \ + src/config/ConfigFile.cxx src/config/ConfigFile.hxx \ + src/config/ConfigTemplates.cxx src/config/ConfigTemplates.hxx \ + src/config/ConfigError.cxx src/config/ConfigError.hxx \ + src/config/ConfigOption.hxx # tag plugins diff --git a/src/AudioConfig.cxx b/src/AudioConfig.cxx index 9fa12f382..d54f59e17 100644 --- a/src/AudioConfig.cxx +++ b/src/AudioConfig.cxx @@ -21,9 +21,9 @@ #include "AudioConfig.hxx" #include "AudioFormat.hxx" #include "AudioParser.hxx" -#include "ConfigData.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigOption.hxx" +#include "config/ConfigData.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigOption.hxx" #include "util/Error.hxx" #include "system/FatalError.hxx" diff --git a/src/ClientGlobal.cxx b/src/ClientGlobal.cxx index 676c18405..8d90721e9 100644 --- a/src/ClientGlobal.cxx +++ b/src/ClientGlobal.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "ClientInternal.hxx" -#include "ConfigGlobal.hxx" +#include "config/ConfigGlobal.hxx" #define CLIENT_TIMEOUT_DEFAULT (60) #define CLIENT_MAX_COMMAND_LIST_DEFAULT (2048*1024) diff --git a/src/CommandLine.cxx b/src/CommandLine.cxx index 399ecb393..3659dfcda 100644 --- a/src/CommandLine.cxx +++ b/src/CommandLine.cxx @@ -22,7 +22,7 @@ #include "ls.hxx" #include "LogInit.hxx" #include "Log.hxx" -#include "ConfigGlobal.hxx" +#include "config/ConfigGlobal.hxx" #include "DatabaseRegistry.hxx" #include "DatabasePlugin.hxx" #include "decoder/DecoderList.hxx" diff --git a/src/ConfigData.cxx b/src/ConfigData.cxx deleted file mode 100644 index 70e1e55ed..000000000 --- a/src/ConfigData.cxx +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" -#include "ConfigData.hxx" -#include "ConfigParser.hxx" -#include "ConfigPath.hxx" -#include "util/Error.hxx" -#include "fs/AllocatedPath.hxx" -#include "system/FatalError.hxx" - -#include -#include - -int -block_param::GetIntValue() const -{ - char *endptr; - long value2 = strtol(value.c_str(), &endptr, 0); - if (*endptr != 0) - FormatFatalError("Not a valid number in line %i", line); - - return value2; -} - -unsigned -block_param::GetUnsignedValue() const -{ - char *endptr; - unsigned long value2 = strtoul(value.c_str(), &endptr, 0); - if (*endptr != 0) - FormatFatalError("Not a valid number in line %i", line); - - return (unsigned)value2; -} - -bool -block_param::GetBoolValue() const -{ - bool value2; - if (!get_bool(value.c_str(), &value2)) - FormatFatalError("%s is not a boolean value (yes, true, 1) or " - "(no, false, 0) on line %i\n", - name.c_str(), line); - - return value2; -} - -config_param::config_param(const char *_value, int _line) - :next(nullptr), value(_value), line(_line), used(false) {} - -config_param::~config_param() -{ - delete next; -} - -const block_param * -config_param::GetBlockParam(const char *name) const -{ - for (const auto &i : block_params) { - if (i.name == name) { - i.used = true; - return &i; - } - } - - return NULL; -} - -const char * -config_param::GetBlockValue(const char *name, const char *default_value) const -{ - const block_param *bp = GetBlockParam(name); - if (bp == nullptr) - return default_value; - - return bp->value.c_str(); -} - -AllocatedPath -config_param::GetBlockPath(const char *name, const char *default_value, - Error &error) const -{ - assert(!error.IsDefined()); - - int line2 = line; - const char *s; - - const block_param *bp = GetBlockParam(name); - if (bp != nullptr) { - line2 = bp->line; - s = bp->value.c_str(); - } else { - if (default_value == nullptr) - return AllocatedPath::Null(); - - s = default_value; - } - - AllocatedPath path = ParsePath(s, error); - if (gcc_unlikely(path.IsNull())) - error.FormatPrefix("Invalid path in \"%s\" at line %i: ", - name, line2); - - return path; -} - -AllocatedPath -config_param::GetBlockPath(const char *name, Error &error) const -{ - return GetBlockPath(name, nullptr, error); -} - -int -config_param::GetBlockValue(const char *name, int default_value) const -{ - const block_param *bp = GetBlockParam(name); - if (bp == nullptr) - return default_value; - - return bp->GetIntValue(); -} - -unsigned -config_param::GetBlockValue(const char *name, unsigned default_value) const -{ - const block_param *bp = GetBlockParam(name); - if (bp == nullptr) - return default_value; - - return bp->GetUnsignedValue(); -} - -gcc_pure -bool -config_param::GetBlockValue(const char *name, bool default_value) const -{ - const block_param *bp = GetBlockParam(name); - if (bp == NULL) - return default_value; - - return bp->GetBoolValue(); -} diff --git a/src/ConfigData.hxx b/src/ConfigData.hxx deleted file mode 100644 index e42d674ba..000000000 --- a/src/ConfigData.hxx +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPD_CONFIG_DATA_HXX -#define MPD_CONFIG_DATA_HXX - -#include "ConfigOption.hxx" -#include "Compiler.h" - -#include -#include -#include - -class AllocatedPath; -class Error; - -struct block_param { - std::string name; - std::string value; - int line; - - /** - * This flag is false when nobody has queried the value of - * this option yet. - */ - mutable bool used; - - gcc_nonnull_all - block_param(const char *_name, const char *_value, int _line=-1) - :name(_name), value(_value), line(_line), used(false) {} - - gcc_pure - int GetIntValue() const; - - gcc_pure - unsigned GetUnsignedValue() const; - - gcc_pure - bool GetBoolValue() const; -}; - -struct config_param { - /** - * The next config_param with the same name. The destructor - * deletes the whole chain. - */ - struct config_param *next; - - std::string value; - - unsigned int line; - - std::vector block_params; - - /** - * This flag is false when nobody has queried the value of - * this option yet. - */ - bool used; - - config_param(int _line=-1) - :next(nullptr), line(_line), used(false) {} - - gcc_nonnull_all - config_param(const char *_value, int _line=-1); - - config_param(const config_param &) = delete; - - ~config_param(); - - config_param &operator=(const config_param &) = delete; - - /** - * Determine if this is a "null" instance, i.e. an empty - * object that was synthesized and not loaded from a - * configuration file. - */ - bool IsNull() const { - return line == unsigned(-1); - } - - gcc_nonnull_all - void AddBlockParam(const char *_name, const char *_value, - int _line=-1) { - block_params.emplace_back(_name, _value, _line); - } - - gcc_nonnull_all gcc_pure - const block_param *GetBlockParam(const char *_name) const; - - gcc_pure - const char *GetBlockValue(const char *name, - const char *default_value=nullptr) const; - - /** - * Same as config_dup_path(), but looks up the setting in the - * specified block. - */ - AllocatedPath GetBlockPath(const char *name, const char *default_value, - Error &error) const; - - AllocatedPath GetBlockPath(const char *name, Error &error) const; - - gcc_pure - int GetBlockValue(const char *name, int default_value) const; - - gcc_pure - unsigned GetBlockValue(const char *name, unsigned default_value) const; - - gcc_pure - bool GetBlockValue(const char *name, bool default_value) const; -}; - -struct ConfigData { - std::array params; -}; - -#endif diff --git a/src/ConfigDefaults.hxx b/src/ConfigDefaults.hxx deleted file mode 100644 index c50f28c91..000000000 --- a/src/ConfigDefaults.hxx +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPD_CONFIG_DEFAULTS_HXX -#define MPD_CONFIG_DEFAULTS_HXX - -static constexpr unsigned DEFAULT_PLAYLIST_MAX_LENGTH = 16 * 1024; -static constexpr bool DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS = false; - -#endif diff --git a/src/ConfigError.cxx b/src/ConfigError.cxx deleted file mode 100644 index 70aff7175..000000000 --- a/src/ConfigError.cxx +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "ConfigError.hxx" -#include "util/Domain.hxx" - -const Domain config_domain("config"); diff --git a/src/ConfigError.hxx b/src/ConfigError.hxx deleted file mode 100644 index cbfa79df3..000000000 --- a/src/ConfigError.hxx +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPD_CONFIG_ERROR_HXX -#define MPD_CONFIG_ERROR_HXX - -extern const class Domain config_domain; - -#endif diff --git a/src/ConfigFile.cxx b/src/ConfigFile.cxx deleted file mode 100644 index f045213a4..000000000 --- a/src/ConfigFile.cxx +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" -#include "ConfigFile.hxx" -#include "ConfigData.hxx" -#include "ConfigTemplates.hxx" -#include "util/Tokenizer.hxx" -#include "util/StringUtil.hxx" -#include "util/Error.hxx" -#include "util/Domain.hxx" -#include "fs/Limits.hxx" -#include "fs/Path.hxx" -#include "fs/FileSystem.hxx" -#include "Log.hxx" - -#include -#include - -#define MAX_STRING_SIZE MPD_PATH_MAX+80 - -#define CONF_COMMENT '#' - -static constexpr Domain config_file_domain("config_file"); - -static bool -config_read_name_value(struct config_param *param, char *input, unsigned line, - Error &error) -{ - Tokenizer tokenizer(input); - - const char *name = tokenizer.NextWord(error); - if (name == nullptr) { - assert(!tokenizer.IsEnd()); - return false; - } - - const char *value = tokenizer.NextString(error); - if (value == nullptr) { - if (tokenizer.IsEnd()) { - error.Set(config_file_domain, "Value missing"); - } else { - assert(error.IsDefined()); - } - - return false; - } - - if (!tokenizer.IsEnd() && tokenizer.CurrentChar() != CONF_COMMENT) { - error.Set(config_file_domain, "Unknown tokens after value"); - return false; - } - - const struct block_param *bp = param->GetBlockParam(name); - if (bp != nullptr) { - error.Format(config_file_domain, - "\"%s\" is duplicate, first defined on line %i", - name, bp->line); - return false; - } - - param->AddBlockParam(name, value, line); - return true; -} - -static struct config_param * -config_read_block(FILE *fp, int *count, char *string, Error &error) -{ - struct config_param *ret = new config_param(*count); - - while (true) { - char *line; - - line = fgets(string, MAX_STRING_SIZE, fp); - if (line == nullptr) { - delete ret; - error.Set(config_file_domain, - "Expected '}' before end-of-file"); - return nullptr; - } - - (*count)++; - line = strchug_fast(line); - if (*line == 0 || *line == CONF_COMMENT) - continue; - - if (*line == '}') { - /* end of this block; return from the function - (and from this "while" loop) */ - - line = strchug_fast(line + 1); - if (*line != 0 && *line != CONF_COMMENT) { - delete ret; - error.Format(config_file_domain, - "line %i: Unknown tokens after '}'", - *count); - return nullptr; - } - - return ret; - } - - /* parse name and value */ - - if (!config_read_name_value(ret, line, *count, error)) { - assert(*line != 0); - delete ret; - error.FormatPrefix("line %i: ", *count); - return nullptr; - } - } -} - -gcc_nonnull_all -static void -Append(config_param *&head, config_param *p) -{ - assert(p->next == nullptr); - - config_param **i = &head; - while (*i != nullptr) - i = &(*i)->next; - - *i = p; -} - -static bool -ReadConfigFile(ConfigData &config_data, FILE *fp, Error &error) -{ - assert(fp != nullptr); - - char string[MAX_STRING_SIZE + 1]; - int count = 0; - struct config_param *param; - - while (fgets(string, MAX_STRING_SIZE, fp)) { - char *line; - const char *name, *value; - - count++; - - line = strchug_fast(string); - if (*line == 0 || *line == CONF_COMMENT) - continue; - - /* the first token in each line is the name, followed - by either the value or '{' */ - - Tokenizer tokenizer(line); - name = tokenizer.NextWord(error); - if (name == nullptr) { - assert(!tokenizer.IsEnd()); - error.FormatPrefix("line %i: ", count); - return false; - } - - /* get the definition of that option, and check the - "repeatable" flag */ - - const ConfigOption o = ParseConfigOptionName(name); - if (o == CONF_MAX) { - error.Format(config_file_domain, - "unrecognized parameter in config file at " - "line %i: %s\n", count, name); - return false; - } - - const unsigned i = unsigned(o); - const ConfigTemplate &option = config_templates[i]; - config_param *&head = config_data.params[i]; - - if (head != nullptr && !option.repeatable) { - param = head; - error.Format(config_file_domain, - "config parameter \"%s\" is first defined " - "on line %i and redefined on line %i\n", - name, param->line, count); - return false; - } - - /* now parse the block or the value */ - - if (option.block) { - /* it's a block, call config_read_block() */ - - if (tokenizer.CurrentChar() != '{') { - error.Format(config_file_domain, - "line %i: '{' expected", count); - return false; - } - - line = strchug_fast(tokenizer.Rest() + 1); - if (*line != 0 && *line != CONF_COMMENT) { - error.Format(config_file_domain, - "line %i: Unknown tokens after '{'", - count); - return false; - } - - param = config_read_block(fp, &count, string, error); - if (param == nullptr) { - return false; - } - } else { - /* a string value */ - - value = tokenizer.NextString(error); - if (value == nullptr) { - if (tokenizer.IsEnd()) - error.Format(config_file_domain, - "line %i: Value missing", - count); - else - error.FormatPrefix("line %i: ", count); - - return false; - } - - if (!tokenizer.IsEnd() && - tokenizer.CurrentChar() != CONF_COMMENT) { - error.Format(config_file_domain, - "line %i: Unknown tokens after value", - count); - return false; - } - - param = new config_param(value, count); - } - - Append(head, param); - } - - return true; -} - -bool -ReadConfigFile(ConfigData &config_data, Path path, Error &error) -{ - assert(!path.IsNull()); - const std::string path_utf8 = path.ToUTF8(); - - FormatDebug(config_file_domain, "loading file %s", path_utf8.c_str()); - - FILE *fp = FOpen(path, FOpenMode::ReadText); - if (fp == nullptr) { - error.FormatErrno("Failed to open %s", path_utf8.c_str()); - return false; - } - - bool result = ReadConfigFile(config_data, fp, error); - fclose(fp); - return result; -} diff --git a/src/ConfigFile.hxx b/src/ConfigFile.hxx deleted file mode 100644 index b87182c6a..000000000 --- a/src/ConfigFile.hxx +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPD_CONFIG_FILE_HXX -#define MPD_CONFIG_FILE_HXX - -class Error; -class Path; -struct ConfigData; - -bool -ReadConfigFile(ConfigData &data, Path path, Error &error); - -#endif diff --git a/src/ConfigGlobal.cxx b/src/ConfigGlobal.cxx deleted file mode 100644 index c7d16d3e7..000000000 --- a/src/ConfigGlobal.cxx +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" -#include "ConfigGlobal.hxx" -#include "ConfigParser.hxx" -#include "ConfigData.hxx" -#include "ConfigFile.hxx" -#include "ConfigPath.hxx" -#include "ConfigError.hxx" -#include "fs/Path.hxx" -#include "fs/AllocatedPath.hxx" -#include "util/Error.hxx" -#include "system/FatalError.hxx" -#include "Log.hxx" - -#include - -static ConfigData config_data; - -void config_global_finish(void) -{ - for (auto i : config_data.params) - delete i; -} - -void config_global_init(void) -{ -} - -bool -ReadConfigFile(Path path, Error &error) -{ - return ReadConfigFile(config_data, path, error); -} - -static void -Check(const config_param *param) -{ - if (!param->used) - /* this whole config_param was not queried at all - - the feature might be disabled at compile time? - Silently ignore it here. */ - return; - - for (const auto &i : param->block_params) { - if (!i.used) - FormatWarning(config_domain, - "option '%s' on line %i was not recognized", - i.name.c_str(), i.line); - } -} - -void config_global_check(void) -{ - for (auto i : config_data.params) - for (const config_param *p = i; p != nullptr; p = p->next) - Check(p); -} - -const struct config_param * -config_get_next_param(ConfigOption option, const struct config_param * last) -{ - config_param *param = last != nullptr - ? last->next - : config_data.params[unsigned(option)]; - if (param != nullptr) - param->used = true; - return param; -} - -const char * -config_get_string(ConfigOption option, const char *default_value) -{ - const struct config_param *param = config_get_param(option); - - if (param == nullptr) - return default_value; - - return param->value.c_str(); -} - -AllocatedPath -config_get_path(ConfigOption option, Error &error) -{ - const struct config_param *param = config_get_param(option); - if (param == nullptr) - return AllocatedPath::Null(); - - return config_parse_path(param, error); -} - -AllocatedPath -config_parse_path(const struct config_param *param, Error & error) -{ - AllocatedPath path = ParsePath(param->value.c_str(), error); - if (gcc_unlikely(path.IsNull())) - error.FormatPrefix("Invalid path at line %i: ", - param->line); - - return path; -} - -unsigned -config_get_unsigned(ConfigOption option, unsigned default_value) -{ - const struct config_param *param = config_get_param(option); - long value; - char *endptr; - - if (param == nullptr) - return default_value; - - value = strtol(param->value.c_str(), &endptr, 0); - if (*endptr != 0 || value < 0) - FormatFatalError("Not a valid non-negative number in line %i", - param->line); - - return (unsigned)value; -} - -unsigned -config_get_positive(ConfigOption option, unsigned default_value) -{ - const struct config_param *param = config_get_param(option); - long value; - char *endptr; - - if (param == nullptr) - return default_value; - - value = strtol(param->value.c_str(), &endptr, 0); - if (*endptr != 0) - FormatFatalError("Not a valid number in line %i", param->line); - - if (value <= 0) - FormatFatalError("Not a positive number in line %i", - param->line); - - return (unsigned)value; -} - -bool -config_get_bool(ConfigOption option, bool default_value) -{ - const struct config_param *param = config_get_param(option); - bool success, value; - - if (param == nullptr) - return default_value; - - success = get_bool(param->value.c_str(), &value); - if (!success) - FormatFatalError("Expected boolean value (yes, true, 1) or " - "(no, false, 0) on line %i\n", - param->line); - - return value; -} diff --git a/src/ConfigGlobal.hxx b/src/ConfigGlobal.hxx deleted file mode 100644 index abce424de..000000000 --- a/src/ConfigGlobal.hxx +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPD_CONFIG_GLOBAL_HXX -#define MPD_CONFIG_GLOBAL_HXX - -#include "ConfigOption.hxx" -#include "Compiler.h" - -class Error; -class Path; -class AllocatedPath; - -void config_global_init(void); -void config_global_finish(void); - -/** - * Call this function after all configuration has been evaluated. It - * checks for unused parameters, and logs warnings. - */ -void config_global_check(void); - -bool -ReadConfigFile(Path path, Error &error); - -/* don't free the returned value - set _last_ to nullptr to get first entry */ -gcc_pure -const struct config_param * -config_get_next_param(enum ConfigOption option, - const struct config_param *last); - -gcc_pure -static inline const struct config_param * -config_get_param(enum ConfigOption option) -{ - return config_get_next_param(option, nullptr); -} - -/* Note on gcc_pure: Some of the functions declared pure are not - really pure in strict sense. They have side effect such that they - validate parameter's value and signal an error if it's invalid. - However, if the argument was already validated or we don't care - about the argument at all, this may be ignored so in the end, we - should be fine with calling those functions pure. */ - -gcc_pure -const char * -config_get_string(enum ConfigOption option, const char *default_value); - -/** - * Returns an optional configuration variable which contains an - * absolute path. If there is a tilde prefix, it is expanded. - * Returns AllocatedPath::Null() if the value is not present. If the path - * could not be parsed, returns AllocatedPath::Null() and sets the error. - */ -AllocatedPath -config_get_path(enum ConfigOption option, Error &error); - -/** - * Parse a configuration parameter as a path. - * If there is a tilde prefix, it is expanded. If the path could - * not be parsed, returns AllocatedPath::Null() and sets the error. - */ -AllocatedPath -config_parse_path(const struct config_param *param, Error & error_r); - -gcc_pure -unsigned -config_get_unsigned(enum ConfigOption option, unsigned default_value); - -gcc_pure -unsigned -config_get_positive(enum ConfigOption option, unsigned default_value); - -gcc_pure -bool config_get_bool(enum ConfigOption option, bool default_value); - -#endif diff --git a/src/ConfigOption.hxx b/src/ConfigOption.hxx deleted file mode 100644 index 4ee108196..000000000 --- a/src/ConfigOption.hxx +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPD_CONFIG_OPTION_HXX -#define MPD_CONFIG_OPTION_HXX - -#include "Compiler.h" - -enum ConfigOption { - CONF_MUSIC_DIR, - CONF_PLAYLIST_DIR, - CONF_FOLLOW_INSIDE_SYMLINKS, - CONF_FOLLOW_OUTSIDE_SYMLINKS, - CONF_DB_FILE, - CONF_STICKER_FILE, - CONF_LOG_FILE, - CONF_PID_FILE, - CONF_STATE_FILE, - CONF_RESTORE_PAUSED, - CONF_USER, - CONF_GROUP, - CONF_BIND_TO_ADDRESS, - CONF_PORT, - CONF_LOG_LEVEL, - CONF_ZEROCONF_NAME, - CONF_ZEROCONF_ENABLED, - CONF_PASSWORD, - CONF_DEFAULT_PERMS, - CONF_AUDIO_OUTPUT, - CONF_AUDIO_OUTPUT_FORMAT, - CONF_MIXER_TYPE, - CONF_REPLAYGAIN, - CONF_REPLAYGAIN_PREAMP, - CONF_REPLAYGAIN_MISSING_PREAMP, - CONF_REPLAYGAIN_LIMIT, - CONF_VOLUME_NORMALIZATION, - CONF_SAMPLERATE_CONVERTER, - CONF_AUDIO_BUFFER_SIZE, - CONF_BUFFER_BEFORE_PLAY, - CONF_HTTP_PROXY_HOST, - CONF_HTTP_PROXY_PORT, - CONF_HTTP_PROXY_USER, - CONF_HTTP_PROXY_PASSWORD, - CONF_CONN_TIMEOUT, - CONF_MAX_CONN, - CONF_MAX_PLAYLIST_LENGTH, - CONF_MAX_COMMAND_LIST_SIZE, - CONF_MAX_OUTPUT_BUFFER_SIZE, - CONF_FS_CHARSET, - CONF_ID3V1_ENCODING, - CONF_METADATA_TO_USE, - CONF_SAVE_ABSOLUTE_PATHS, - CONF_DECODER, - CONF_INPUT, - CONF_GAPLESS_MP3_PLAYBACK, - CONF_PLAYLIST_PLUGIN, - CONF_AUTO_UPDATE, - CONF_AUTO_UPDATE_DEPTH, - CONF_DESPOTIFY_USER, - CONF_DESPOTIFY_PASSWORD, - CONF_DESPOTIFY_HIGH_BITRATE, - CONF_AUDIO_FILTER, - CONF_DATABASE, - CONF_MAX -}; - -/** - * @return #CONF_MAX if not found - */ -gcc_pure -enum ConfigOption -ParseConfigOptionName(const char *name); - -#endif diff --git a/src/ConfigParser.cxx b/src/ConfigParser.cxx deleted file mode 100644 index 3535c9a13..000000000 --- a/src/ConfigParser.cxx +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "ConfigParser.hxx" -#include "util/StringUtil.hxx" - -bool -get_bool(const char *value, bool *value_r) -{ - static const char *t[] = { "yes", "true", "1", nullptr }; - static const char *f[] = { "no", "false", "0", nullptr }; - - if (string_array_contains(t, value)) { - *value_r = true; - return true; - } - - if (string_array_contains(f, value)) { - *value_r = false; - return true; - } - - return false; -} diff --git a/src/ConfigParser.hxx b/src/ConfigParser.hxx deleted file mode 100644 index 06151b0bd..000000000 --- a/src/ConfigParser.hxx +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPD_CONFIG_PARSER_HXX -#define MPD_CONFIG_PARSER_HXX - -bool -get_bool(const char *value, bool *value_r); - -#endif diff --git a/src/ConfigPath.cxx b/src/ConfigPath.cxx deleted file mode 100644 index a3b3f83a5..000000000 --- a/src/ConfigPath.cxx +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" -#include "ConfigPath.hxx" -#include "fs/AllocatedPath.hxx" -#include "fs/Traits.hxx" -#include "fs/Domain.hxx" -#include "fs/StandardDirectory.hxx" -#include "util/Error.hxx" -#include "ConfigGlobal.hxx" - -#include -#include - -#ifndef WIN32 -#include - -/** - * Determine a given user's home directory. - */ -static AllocatedPath -GetHome(const char *user, Error &error) -{ - AllocatedPath result = GetHomeDir(user); - if (result.IsNull()) { - error.Format(path_domain, - "no such user: %s", user); - return AllocatedPath::Null(); - } - - return result; -} - -/** - * Determine the current user's home directory. - */ -static AllocatedPath -GetHome(Error &error) -{ - AllocatedPath result = GetHomeDir(); - if (result.IsNull()) { - error.Set(path_domain, - "problems getting home for current user"); - return AllocatedPath::Null(); - } - - return result; -} - -/** - * Determine the configured user's home directory. - */ -static AllocatedPath -GetConfiguredHome(Error &error) -{ - const char *user = config_get_string(CONF_USER, nullptr); - return user != nullptr - ? GetHome(user, error) - : GetHome(error); -} - -#endif - -AllocatedPath -ParsePath(const char *path, Error &error) -{ - assert(path != nullptr); - -#ifndef WIN32 - if (path[0] == '~') { - ++path; - - if (*path == '\0') - return GetConfiguredHome(error); - - AllocatedPath home = AllocatedPath::Null(); - - if (*path == '/') { - home = GetConfiguredHome(error); - - ++path; - } else { - const char *slash = strchr(path, '/'); - const char *end = slash == nullptr - ? path + strlen(path) - : slash; - const std::string user(path, end); - home = GetHome(user.c_str(), error); - - if (slash == nullptr) - return home; - - path = slash + 1; - } - - if (home.IsNull()) - return AllocatedPath::Null(); - - AllocatedPath path2 = AllocatedPath::FromUTF8(path, error); - if (path2.IsNull()) - return AllocatedPath::Null(); - - return AllocatedPath::Build(home, path2); - } else if (!PathTraitsUTF8::IsAbsolute(path)) { - error.Format(path_domain, - "not an absolute path: %s", path); - return AllocatedPath::Null(); - } else { -#endif - return AllocatedPath::FromUTF8(path, error); -#ifndef WIN32 - } -#endif -} diff --git a/src/ConfigPath.hxx b/src/ConfigPath.hxx deleted file mode 100644 index a5518a497..000000000 --- a/src/ConfigPath.hxx +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPD_CONFIG_PATH_HXX -#define MPD_CONFIG_PATH_HXX - -class AllocatedPath; -class Error; - -AllocatedPath -ParsePath(const char *path, Error &error); - -#endif diff --git a/src/ConfigTemplates.cxx b/src/ConfigTemplates.cxx deleted file mode 100644 index e9cd68b5b..000000000 --- a/src/ConfigTemplates.cxx +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "ConfigTemplates.hxx" -#include "ConfigOption.hxx" - -#include - -const ConfigTemplate config_templates[] = { - { "music_directory", false, false }, - { "playlist_directory", false, false }, - { "follow_inside_symlinks", false, false }, - { "follow_outside_symlinks", false, false }, - { "db_file", false, false }, - { "sticker_file", false, false }, - { "log_file", false, false }, - { "pid_file", false, false }, - { "state_file", false, false }, - { "restore_paused", false, false }, - { "user", false, false }, - { "group", false, false }, - { "bind_to_address", true, false }, - { "port", false, false }, - { "log_level", false, false }, - { "zeroconf_name", false, false }, - { "zeroconf_enabled", false, false }, - { "password", true, false }, - { "default_permissions", false, false }, - { "audio_output", true, true }, - { "audio_output_format", false, false }, - { "mixer_type", false, false }, - { "replaygain", false, false }, - { "replaygain_preamp", false, false }, - { "replaygain_missing_preamp", false, false }, - { "replaygain_limit", false, false }, - { "volume_normalization", false, false }, - { "samplerate_converter", false, false }, - { "audio_buffer_size", false, false }, - { "buffer_before_play", false, false }, - { "http_proxy_host", false, false }, - { "http_proxy_port", false, false }, - { "http_proxy_user", false, false }, - { "http_proxy_password", false, false }, - { "connection_timeout", false, false }, - { "max_connections", false, false }, - { "max_playlist_length", false, false }, - { "max_command_list_size", false, false }, - { "max_output_buffer_size", false, false }, - { "filesystem_charset", false, false }, - { "id3v1_encoding", false, false }, - { "metadata_to_use", false, false }, - { "save_absolute_paths_in_playlists", false, false }, - { "decoder", true, true }, - { "input", true, true }, - { "gapless_mp3_playback", false, false }, - { "playlist_plugin", true, true }, - { "auto_update", false, false }, - { "auto_update_depth", false, false }, - { "despotify_user", false, false }, - { "despotify_password", false, false}, - { "despotify_high_bitrate", false, false }, - { "filter", true, true }, - { "database", false, true }, -}; - -static constexpr unsigned n_config_templates = - sizeof(config_templates) / sizeof(config_templates[0]); - -static_assert(n_config_templates == unsigned(CONF_MAX), - "Wrong number of config_templates"); - -ConfigOption -ParseConfigOptionName(const char *name) -{ - for (unsigned i = 0; i < n_config_templates; ++i) - if (strcmp(config_templates[i].name, name) == 0) - return ConfigOption(i); - - return CONF_MAX; -} diff --git a/src/ConfigTemplates.hxx b/src/ConfigTemplates.hxx deleted file mode 100644 index 90d098dc0..000000000 --- a/src/ConfigTemplates.hxx +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2003-2014 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPD_CONFIG_TEMPLATES_HXX -#define MPD_CONFIG_TEMPLATES_HXX - -struct ConfigTemplate { - const char *const name; - const bool repeatable; - const bool block; -}; - -extern const ConfigTemplate config_templates[]; - -#endif diff --git a/src/DatabaseGlue.cxx b/src/DatabaseGlue.cxx index a479df70d..ce53ec184 100644 --- a/src/DatabaseGlue.cxx +++ b/src/DatabaseGlue.cxx @@ -24,7 +24,7 @@ #include "DatabaseError.hxx" #include "Directory.hxx" #include "util/Error.hxx" -#include "ConfigData.hxx" +#include "config/ConfigData.hxx" #include "Stats.hxx" #include "DatabasePlugin.hxx" #include "db/SimpleDatabasePlugin.hxx" diff --git a/src/DespotifyUtils.cxx b/src/DespotifyUtils.cxx index 8b9d468d6..47a83e49b 100644 --- a/src/DespotifyUtils.cxx +++ b/src/DespotifyUtils.cxx @@ -20,8 +20,8 @@ #include "DespotifyUtils.hxx" #include "tag/Tag.hxx" #include "tag/TagBuilder.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigOption.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigOption.hxx" #include "util/Domain.hxx" #include "Log.hxx" diff --git a/src/FilterConfig.cxx b/src/FilterConfig.cxx index 5f5442a1e..a3a8f7ddc 100644 --- a/src/FilterConfig.cxx +++ b/src/FilterConfig.cxx @@ -21,10 +21,10 @@ #include "FilterConfig.hxx" #include "filter/ChainFilterPlugin.hxx" #include "FilterPlugin.hxx" -#include "ConfigData.hxx" -#include "ConfigOption.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigError.hxx" +#include "config/ConfigData.hxx" +#include "config/ConfigOption.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigError.hxx" #include "util/Error.hxx" #include diff --git a/src/FilterPlugin.cxx b/src/FilterPlugin.cxx index 74d8cd45b..98314f771 100644 --- a/src/FilterPlugin.cxx +++ b/src/FilterPlugin.cxx @@ -20,8 +20,8 @@ #include "config.h" #include "FilterPlugin.hxx" #include "FilterRegistry.hxx" -#include "ConfigData.hxx" -#include "ConfigError.hxx" +#include "config/ConfigData.hxx" +#include "config/ConfigError.hxx" #include "util/Error.hxx" #include diff --git a/src/InputInit.cxx b/src/InputInit.cxx index 56683dc20..d1d844830 100644 --- a/src/InputInit.cxx +++ b/src/InputInit.cxx @@ -23,9 +23,9 @@ #include "InputPlugin.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigOption.hxx" -#include "ConfigData.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigOption.hxx" +#include "config/ConfigData.hxx" #include #include diff --git a/src/Listen.cxx b/src/Listen.cxx index 9d9b02c48..9cdf1b823 100644 --- a/src/Listen.cxx +++ b/src/Listen.cxx @@ -22,9 +22,9 @@ #include "Main.hxx" #include "Instance.hxx" #include "Client.hxx" -#include "ConfigData.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigOption.hxx" +#include "config/ConfigData.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigOption.hxx" #include "event/ServerSocket.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" diff --git a/src/LogInit.cxx b/src/LogInit.cxx index 0b781da23..2a5d4d7c5 100644 --- a/src/LogInit.cxx +++ b/src/LogInit.cxx @@ -21,9 +21,9 @@ #include "LogInit.hxx" #include "LogBackend.hxx" #include "Log.hxx" -#include "ConfigData.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigOption.hxx" +#include "config/ConfigData.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigOption.hxx" #include "system/FatalError.hxx" #include "fs/AllocatedPath.hxx" #include "fs/FileSystem.hxx" diff --git a/src/Main.cxx b/src/Main.cxx index 8f6780661..a5ffb33dc 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -61,10 +61,10 @@ #include "util/Error.hxx" #include "util/Domain.hxx" #include "thread/Id.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigData.hxx" -#include "ConfigDefaults.hxx" -#include "ConfigOption.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigData.hxx" +#include "config/ConfigDefaults.hxx" +#include "config/ConfigOption.hxx" #include "Stats.hxx" #ifdef ENABLE_INOTIFY diff --git a/src/Permission.cxx b/src/Permission.cxx index cd2d31b04..d2d9d4297 100644 --- a/src/Permission.cxx +++ b/src/Permission.cxx @@ -19,9 +19,9 @@ #include "config.h" #include "Permission.hxx" -#include "ConfigData.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigOption.hxx" +#include "config/ConfigData.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigOption.hxx" #include "system/FatalError.hxx" #include diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx index 2707bcb76..befa45d94 100644 --- a/src/PlaylistFile.cxx +++ b/src/PlaylistFile.cxx @@ -26,9 +26,9 @@ #include "DetachedSong.hxx" #include "Mapper.hxx" #include "fs/TextFile.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigOption.hxx" -#include "ConfigDefaults.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigOption.hxx" +#include "config/ConfigDefaults.hxx" #include "Idle.hxx" #include "fs/Limits.hxx" #include "fs/AllocatedPath.hxx" diff --git a/src/PlaylistState.cxx b/src/PlaylistState.cxx index e727ecd1f..4a4e37345 100644 --- a/src/PlaylistState.cxx +++ b/src/PlaylistState.cxx @@ -29,8 +29,8 @@ #include "queue/QueueSave.hxx" #include "fs/TextFile.hxx" #include "PlayerControl.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigOption.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigOption.hxx" #include "fs/Limits.hxx" #include "util/CharUtil.hxx" #include "util/StringUtil.hxx" diff --git a/src/ReplayGainConfig.cxx b/src/ReplayGainConfig.cxx index 9cf9f6e39..c3bbcac3c 100644 --- a/src/ReplayGainConfig.cxx +++ b/src/ReplayGainConfig.cxx @@ -20,8 +20,8 @@ #include "config.h" #include "ReplayGainConfig.hxx" #include "Idle.hxx" -#include "ConfigData.hxx" -#include "ConfigGlobal.hxx" +#include "config/ConfigData.hxx" +#include "config/ConfigGlobal.hxx" #include "system/FatalError.hxx" #include diff --git a/src/UpdateWalk.cxx b/src/UpdateWalk.cxx index 430e63af0..21754b31d 100644 --- a/src/UpdateWalk.cxx +++ b/src/UpdateWalk.cxx @@ -32,8 +32,8 @@ #include "playlist/PlaylistRegistry.hxx" #include "Mapper.hxx" #include "ExcludeList.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigOption.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigOption.hxx" #include "fs/AllocatedPath.hxx" #include "fs/Traits.hxx" #include "fs/FileSystem.hxx" diff --git a/src/config/ConfigData.cxx b/src/config/ConfigData.cxx new file mode 100644 index 000000000..70e1e55ed --- /dev/null +++ b/src/config/ConfigData.cxx @@ -0,0 +1,159 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" +#include "ConfigData.hxx" +#include "ConfigParser.hxx" +#include "ConfigPath.hxx" +#include "util/Error.hxx" +#include "fs/AllocatedPath.hxx" +#include "system/FatalError.hxx" + +#include +#include + +int +block_param::GetIntValue() const +{ + char *endptr; + long value2 = strtol(value.c_str(), &endptr, 0); + if (*endptr != 0) + FormatFatalError("Not a valid number in line %i", line); + + return value2; +} + +unsigned +block_param::GetUnsignedValue() const +{ + char *endptr; + unsigned long value2 = strtoul(value.c_str(), &endptr, 0); + if (*endptr != 0) + FormatFatalError("Not a valid number in line %i", line); + + return (unsigned)value2; +} + +bool +block_param::GetBoolValue() const +{ + bool value2; + if (!get_bool(value.c_str(), &value2)) + FormatFatalError("%s is not a boolean value (yes, true, 1) or " + "(no, false, 0) on line %i\n", + name.c_str(), line); + + return value2; +} + +config_param::config_param(const char *_value, int _line) + :next(nullptr), value(_value), line(_line), used(false) {} + +config_param::~config_param() +{ + delete next; +} + +const block_param * +config_param::GetBlockParam(const char *name) const +{ + for (const auto &i : block_params) { + if (i.name == name) { + i.used = true; + return &i; + } + } + + return NULL; +} + +const char * +config_param::GetBlockValue(const char *name, const char *default_value) const +{ + const block_param *bp = GetBlockParam(name); + if (bp == nullptr) + return default_value; + + return bp->value.c_str(); +} + +AllocatedPath +config_param::GetBlockPath(const char *name, const char *default_value, + Error &error) const +{ + assert(!error.IsDefined()); + + int line2 = line; + const char *s; + + const block_param *bp = GetBlockParam(name); + if (bp != nullptr) { + line2 = bp->line; + s = bp->value.c_str(); + } else { + if (default_value == nullptr) + return AllocatedPath::Null(); + + s = default_value; + } + + AllocatedPath path = ParsePath(s, error); + if (gcc_unlikely(path.IsNull())) + error.FormatPrefix("Invalid path in \"%s\" at line %i: ", + name, line2); + + return path; +} + +AllocatedPath +config_param::GetBlockPath(const char *name, Error &error) const +{ + return GetBlockPath(name, nullptr, error); +} + +int +config_param::GetBlockValue(const char *name, int default_value) const +{ + const block_param *bp = GetBlockParam(name); + if (bp == nullptr) + return default_value; + + return bp->GetIntValue(); +} + +unsigned +config_param::GetBlockValue(const char *name, unsigned default_value) const +{ + const block_param *bp = GetBlockParam(name); + if (bp == nullptr) + return default_value; + + return bp->GetUnsignedValue(); +} + +gcc_pure +bool +config_param::GetBlockValue(const char *name, bool default_value) const +{ + const block_param *bp = GetBlockParam(name); + if (bp == NULL) + return default_value; + + return bp->GetBoolValue(); +} diff --git a/src/config/ConfigData.hxx b/src/config/ConfigData.hxx new file mode 100644 index 000000000..e42d674ba --- /dev/null +++ b/src/config/ConfigData.hxx @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_CONFIG_DATA_HXX +#define MPD_CONFIG_DATA_HXX + +#include "ConfigOption.hxx" +#include "Compiler.h" + +#include +#include +#include + +class AllocatedPath; +class Error; + +struct block_param { + std::string name; + std::string value; + int line; + + /** + * This flag is false when nobody has queried the value of + * this option yet. + */ + mutable bool used; + + gcc_nonnull_all + block_param(const char *_name, const char *_value, int _line=-1) + :name(_name), value(_value), line(_line), used(false) {} + + gcc_pure + int GetIntValue() const; + + gcc_pure + unsigned GetUnsignedValue() const; + + gcc_pure + bool GetBoolValue() const; +}; + +struct config_param { + /** + * The next config_param with the same name. The destructor + * deletes the whole chain. + */ + struct config_param *next; + + std::string value; + + unsigned int line; + + std::vector block_params; + + /** + * This flag is false when nobody has queried the value of + * this option yet. + */ + bool used; + + config_param(int _line=-1) + :next(nullptr), line(_line), used(false) {} + + gcc_nonnull_all + config_param(const char *_value, int _line=-1); + + config_param(const config_param &) = delete; + + ~config_param(); + + config_param &operator=(const config_param &) = delete; + + /** + * Determine if this is a "null" instance, i.e. an empty + * object that was synthesized and not loaded from a + * configuration file. + */ + bool IsNull() const { + return line == unsigned(-1); + } + + gcc_nonnull_all + void AddBlockParam(const char *_name, const char *_value, + int _line=-1) { + block_params.emplace_back(_name, _value, _line); + } + + gcc_nonnull_all gcc_pure + const block_param *GetBlockParam(const char *_name) const; + + gcc_pure + const char *GetBlockValue(const char *name, + const char *default_value=nullptr) const; + + /** + * Same as config_dup_path(), but looks up the setting in the + * specified block. + */ + AllocatedPath GetBlockPath(const char *name, const char *default_value, + Error &error) const; + + AllocatedPath GetBlockPath(const char *name, Error &error) const; + + gcc_pure + int GetBlockValue(const char *name, int default_value) const; + + gcc_pure + unsigned GetBlockValue(const char *name, unsigned default_value) const; + + gcc_pure + bool GetBlockValue(const char *name, bool default_value) const; +}; + +struct ConfigData { + std::array params; +}; + +#endif diff --git a/src/config/ConfigDefaults.hxx b/src/config/ConfigDefaults.hxx new file mode 100644 index 000000000..c50f28c91 --- /dev/null +++ b/src/config/ConfigDefaults.hxx @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_CONFIG_DEFAULTS_HXX +#define MPD_CONFIG_DEFAULTS_HXX + +static constexpr unsigned DEFAULT_PLAYLIST_MAX_LENGTH = 16 * 1024; +static constexpr bool DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS = false; + +#endif diff --git a/src/config/ConfigError.cxx b/src/config/ConfigError.cxx new file mode 100644 index 000000000..70aff7175 --- /dev/null +++ b/src/config/ConfigError.cxx @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "ConfigError.hxx" +#include "util/Domain.hxx" + +const Domain config_domain("config"); diff --git a/src/config/ConfigError.hxx b/src/config/ConfigError.hxx new file mode 100644 index 000000000..cbfa79df3 --- /dev/null +++ b/src/config/ConfigError.hxx @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_CONFIG_ERROR_HXX +#define MPD_CONFIG_ERROR_HXX + +extern const class Domain config_domain; + +#endif diff --git a/src/config/ConfigFile.cxx b/src/config/ConfigFile.cxx new file mode 100644 index 000000000..f045213a4 --- /dev/null +++ b/src/config/ConfigFile.cxx @@ -0,0 +1,269 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" +#include "ConfigFile.hxx" +#include "ConfigData.hxx" +#include "ConfigTemplates.hxx" +#include "util/Tokenizer.hxx" +#include "util/StringUtil.hxx" +#include "util/Error.hxx" +#include "util/Domain.hxx" +#include "fs/Limits.hxx" +#include "fs/Path.hxx" +#include "fs/FileSystem.hxx" +#include "Log.hxx" + +#include +#include + +#define MAX_STRING_SIZE MPD_PATH_MAX+80 + +#define CONF_COMMENT '#' + +static constexpr Domain config_file_domain("config_file"); + +static bool +config_read_name_value(struct config_param *param, char *input, unsigned line, + Error &error) +{ + Tokenizer tokenizer(input); + + const char *name = tokenizer.NextWord(error); + if (name == nullptr) { + assert(!tokenizer.IsEnd()); + return false; + } + + const char *value = tokenizer.NextString(error); + if (value == nullptr) { + if (tokenizer.IsEnd()) { + error.Set(config_file_domain, "Value missing"); + } else { + assert(error.IsDefined()); + } + + return false; + } + + if (!tokenizer.IsEnd() && tokenizer.CurrentChar() != CONF_COMMENT) { + error.Set(config_file_domain, "Unknown tokens after value"); + return false; + } + + const struct block_param *bp = param->GetBlockParam(name); + if (bp != nullptr) { + error.Format(config_file_domain, + "\"%s\" is duplicate, first defined on line %i", + name, bp->line); + return false; + } + + param->AddBlockParam(name, value, line); + return true; +} + +static struct config_param * +config_read_block(FILE *fp, int *count, char *string, Error &error) +{ + struct config_param *ret = new config_param(*count); + + while (true) { + char *line; + + line = fgets(string, MAX_STRING_SIZE, fp); + if (line == nullptr) { + delete ret; + error.Set(config_file_domain, + "Expected '}' before end-of-file"); + return nullptr; + } + + (*count)++; + line = strchug_fast(line); + if (*line == 0 || *line == CONF_COMMENT) + continue; + + if (*line == '}') { + /* end of this block; return from the function + (and from this "while" loop) */ + + line = strchug_fast(line + 1); + if (*line != 0 && *line != CONF_COMMENT) { + delete ret; + error.Format(config_file_domain, + "line %i: Unknown tokens after '}'", + *count); + return nullptr; + } + + return ret; + } + + /* parse name and value */ + + if (!config_read_name_value(ret, line, *count, error)) { + assert(*line != 0); + delete ret; + error.FormatPrefix("line %i: ", *count); + return nullptr; + } + } +} + +gcc_nonnull_all +static void +Append(config_param *&head, config_param *p) +{ + assert(p->next == nullptr); + + config_param **i = &head; + while (*i != nullptr) + i = &(*i)->next; + + *i = p; +} + +static bool +ReadConfigFile(ConfigData &config_data, FILE *fp, Error &error) +{ + assert(fp != nullptr); + + char string[MAX_STRING_SIZE + 1]; + int count = 0; + struct config_param *param; + + while (fgets(string, MAX_STRING_SIZE, fp)) { + char *line; + const char *name, *value; + + count++; + + line = strchug_fast(string); + if (*line == 0 || *line == CONF_COMMENT) + continue; + + /* the first token in each line is the name, followed + by either the value or '{' */ + + Tokenizer tokenizer(line); + name = tokenizer.NextWord(error); + if (name == nullptr) { + assert(!tokenizer.IsEnd()); + error.FormatPrefix("line %i: ", count); + return false; + } + + /* get the definition of that option, and check the + "repeatable" flag */ + + const ConfigOption o = ParseConfigOptionName(name); + if (o == CONF_MAX) { + error.Format(config_file_domain, + "unrecognized parameter in config file at " + "line %i: %s\n", count, name); + return false; + } + + const unsigned i = unsigned(o); + const ConfigTemplate &option = config_templates[i]; + config_param *&head = config_data.params[i]; + + if (head != nullptr && !option.repeatable) { + param = head; + error.Format(config_file_domain, + "config parameter \"%s\" is first defined " + "on line %i and redefined on line %i\n", + name, param->line, count); + return false; + } + + /* now parse the block or the value */ + + if (option.block) { + /* it's a block, call config_read_block() */ + + if (tokenizer.CurrentChar() != '{') { + error.Format(config_file_domain, + "line %i: '{' expected", count); + return false; + } + + line = strchug_fast(tokenizer.Rest() + 1); + if (*line != 0 && *line != CONF_COMMENT) { + error.Format(config_file_domain, + "line %i: Unknown tokens after '{'", + count); + return false; + } + + param = config_read_block(fp, &count, string, error); + if (param == nullptr) { + return false; + } + } else { + /* a string value */ + + value = tokenizer.NextString(error); + if (value == nullptr) { + if (tokenizer.IsEnd()) + error.Format(config_file_domain, + "line %i: Value missing", + count); + else + error.FormatPrefix("line %i: ", count); + + return false; + } + + if (!tokenizer.IsEnd() && + tokenizer.CurrentChar() != CONF_COMMENT) { + error.Format(config_file_domain, + "line %i: Unknown tokens after value", + count); + return false; + } + + param = new config_param(value, count); + } + + Append(head, param); + } + + return true; +} + +bool +ReadConfigFile(ConfigData &config_data, Path path, Error &error) +{ + assert(!path.IsNull()); + const std::string path_utf8 = path.ToUTF8(); + + FormatDebug(config_file_domain, "loading file %s", path_utf8.c_str()); + + FILE *fp = FOpen(path, FOpenMode::ReadText); + if (fp == nullptr) { + error.FormatErrno("Failed to open %s", path_utf8.c_str()); + return false; + } + + bool result = ReadConfigFile(config_data, fp, error); + fclose(fp); + return result; +} diff --git a/src/config/ConfigFile.hxx b/src/config/ConfigFile.hxx new file mode 100644 index 000000000..b87182c6a --- /dev/null +++ b/src/config/ConfigFile.hxx @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_CONFIG_FILE_HXX +#define MPD_CONFIG_FILE_HXX + +class Error; +class Path; +struct ConfigData; + +bool +ReadConfigFile(ConfigData &data, Path path, Error &error); + +#endif diff --git a/src/config/ConfigGlobal.cxx b/src/config/ConfigGlobal.cxx new file mode 100644 index 000000000..c7d16d3e7 --- /dev/null +++ b/src/config/ConfigGlobal.cxx @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" +#include "ConfigGlobal.hxx" +#include "ConfigParser.hxx" +#include "ConfigData.hxx" +#include "ConfigFile.hxx" +#include "ConfigPath.hxx" +#include "ConfigError.hxx" +#include "fs/Path.hxx" +#include "fs/AllocatedPath.hxx" +#include "util/Error.hxx" +#include "system/FatalError.hxx" +#include "Log.hxx" + +#include + +static ConfigData config_data; + +void config_global_finish(void) +{ + for (auto i : config_data.params) + delete i; +} + +void config_global_init(void) +{ +} + +bool +ReadConfigFile(Path path, Error &error) +{ + return ReadConfigFile(config_data, path, error); +} + +static void +Check(const config_param *param) +{ + if (!param->used) + /* this whole config_param was not queried at all - + the feature might be disabled at compile time? + Silently ignore it here. */ + return; + + for (const auto &i : param->block_params) { + if (!i.used) + FormatWarning(config_domain, + "option '%s' on line %i was not recognized", + i.name.c_str(), i.line); + } +} + +void config_global_check(void) +{ + for (auto i : config_data.params) + for (const config_param *p = i; p != nullptr; p = p->next) + Check(p); +} + +const struct config_param * +config_get_next_param(ConfigOption option, const struct config_param * last) +{ + config_param *param = last != nullptr + ? last->next + : config_data.params[unsigned(option)]; + if (param != nullptr) + param->used = true; + return param; +} + +const char * +config_get_string(ConfigOption option, const char *default_value) +{ + const struct config_param *param = config_get_param(option); + + if (param == nullptr) + return default_value; + + return param->value.c_str(); +} + +AllocatedPath +config_get_path(ConfigOption option, Error &error) +{ + const struct config_param *param = config_get_param(option); + if (param == nullptr) + return AllocatedPath::Null(); + + return config_parse_path(param, error); +} + +AllocatedPath +config_parse_path(const struct config_param *param, Error & error) +{ + AllocatedPath path = ParsePath(param->value.c_str(), error); + if (gcc_unlikely(path.IsNull())) + error.FormatPrefix("Invalid path at line %i: ", + param->line); + + return path; +} + +unsigned +config_get_unsigned(ConfigOption option, unsigned default_value) +{ + const struct config_param *param = config_get_param(option); + long value; + char *endptr; + + if (param == nullptr) + return default_value; + + value = strtol(param->value.c_str(), &endptr, 0); + if (*endptr != 0 || value < 0) + FormatFatalError("Not a valid non-negative number in line %i", + param->line); + + return (unsigned)value; +} + +unsigned +config_get_positive(ConfigOption option, unsigned default_value) +{ + const struct config_param *param = config_get_param(option); + long value; + char *endptr; + + if (param == nullptr) + return default_value; + + value = strtol(param->value.c_str(), &endptr, 0); + if (*endptr != 0) + FormatFatalError("Not a valid number in line %i", param->line); + + if (value <= 0) + FormatFatalError("Not a positive number in line %i", + param->line); + + return (unsigned)value; +} + +bool +config_get_bool(ConfigOption option, bool default_value) +{ + const struct config_param *param = config_get_param(option); + bool success, value; + + if (param == nullptr) + return default_value; + + success = get_bool(param->value.c_str(), &value); + if (!success) + FormatFatalError("Expected boolean value (yes, true, 1) or " + "(no, false, 0) on line %i\n", + param->line); + + return value; +} diff --git a/src/config/ConfigGlobal.hxx b/src/config/ConfigGlobal.hxx new file mode 100644 index 000000000..abce424de --- /dev/null +++ b/src/config/ConfigGlobal.hxx @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_CONFIG_GLOBAL_HXX +#define MPD_CONFIG_GLOBAL_HXX + +#include "ConfigOption.hxx" +#include "Compiler.h" + +class Error; +class Path; +class AllocatedPath; + +void config_global_init(void); +void config_global_finish(void); + +/** + * Call this function after all configuration has been evaluated. It + * checks for unused parameters, and logs warnings. + */ +void config_global_check(void); + +bool +ReadConfigFile(Path path, Error &error); + +/* don't free the returned value + set _last_ to nullptr to get first entry */ +gcc_pure +const struct config_param * +config_get_next_param(enum ConfigOption option, + const struct config_param *last); + +gcc_pure +static inline const struct config_param * +config_get_param(enum ConfigOption option) +{ + return config_get_next_param(option, nullptr); +} + +/* Note on gcc_pure: Some of the functions declared pure are not + really pure in strict sense. They have side effect such that they + validate parameter's value and signal an error if it's invalid. + However, if the argument was already validated or we don't care + about the argument at all, this may be ignored so in the end, we + should be fine with calling those functions pure. */ + +gcc_pure +const char * +config_get_string(enum ConfigOption option, const char *default_value); + +/** + * Returns an optional configuration variable which contains an + * absolute path. If there is a tilde prefix, it is expanded. + * Returns AllocatedPath::Null() if the value is not present. If the path + * could not be parsed, returns AllocatedPath::Null() and sets the error. + */ +AllocatedPath +config_get_path(enum ConfigOption option, Error &error); + +/** + * Parse a configuration parameter as a path. + * If there is a tilde prefix, it is expanded. If the path could + * not be parsed, returns AllocatedPath::Null() and sets the error. + */ +AllocatedPath +config_parse_path(const struct config_param *param, Error & error_r); + +gcc_pure +unsigned +config_get_unsigned(enum ConfigOption option, unsigned default_value); + +gcc_pure +unsigned +config_get_positive(enum ConfigOption option, unsigned default_value); + +gcc_pure +bool config_get_bool(enum ConfigOption option, bool default_value); + +#endif diff --git a/src/config/ConfigOption.hxx b/src/config/ConfigOption.hxx new file mode 100644 index 000000000..4ee108196 --- /dev/null +++ b/src/config/ConfigOption.hxx @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_CONFIG_OPTION_HXX +#define MPD_CONFIG_OPTION_HXX + +#include "Compiler.h" + +enum ConfigOption { + CONF_MUSIC_DIR, + CONF_PLAYLIST_DIR, + CONF_FOLLOW_INSIDE_SYMLINKS, + CONF_FOLLOW_OUTSIDE_SYMLINKS, + CONF_DB_FILE, + CONF_STICKER_FILE, + CONF_LOG_FILE, + CONF_PID_FILE, + CONF_STATE_FILE, + CONF_RESTORE_PAUSED, + CONF_USER, + CONF_GROUP, + CONF_BIND_TO_ADDRESS, + CONF_PORT, + CONF_LOG_LEVEL, + CONF_ZEROCONF_NAME, + CONF_ZEROCONF_ENABLED, + CONF_PASSWORD, + CONF_DEFAULT_PERMS, + CONF_AUDIO_OUTPUT, + CONF_AUDIO_OUTPUT_FORMAT, + CONF_MIXER_TYPE, + CONF_REPLAYGAIN, + CONF_REPLAYGAIN_PREAMP, + CONF_REPLAYGAIN_MISSING_PREAMP, + CONF_REPLAYGAIN_LIMIT, + CONF_VOLUME_NORMALIZATION, + CONF_SAMPLERATE_CONVERTER, + CONF_AUDIO_BUFFER_SIZE, + CONF_BUFFER_BEFORE_PLAY, + CONF_HTTP_PROXY_HOST, + CONF_HTTP_PROXY_PORT, + CONF_HTTP_PROXY_USER, + CONF_HTTP_PROXY_PASSWORD, + CONF_CONN_TIMEOUT, + CONF_MAX_CONN, + CONF_MAX_PLAYLIST_LENGTH, + CONF_MAX_COMMAND_LIST_SIZE, + CONF_MAX_OUTPUT_BUFFER_SIZE, + CONF_FS_CHARSET, + CONF_ID3V1_ENCODING, + CONF_METADATA_TO_USE, + CONF_SAVE_ABSOLUTE_PATHS, + CONF_DECODER, + CONF_INPUT, + CONF_GAPLESS_MP3_PLAYBACK, + CONF_PLAYLIST_PLUGIN, + CONF_AUTO_UPDATE, + CONF_AUTO_UPDATE_DEPTH, + CONF_DESPOTIFY_USER, + CONF_DESPOTIFY_PASSWORD, + CONF_DESPOTIFY_HIGH_BITRATE, + CONF_AUDIO_FILTER, + CONF_DATABASE, + CONF_MAX +}; + +/** + * @return #CONF_MAX if not found + */ +gcc_pure +enum ConfigOption +ParseConfigOptionName(const char *name); + +#endif diff --git a/src/config/ConfigParser.cxx b/src/config/ConfigParser.cxx new file mode 100644 index 000000000..3535c9a13 --- /dev/null +++ b/src/config/ConfigParser.cxx @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "ConfigParser.hxx" +#include "util/StringUtil.hxx" + +bool +get_bool(const char *value, bool *value_r) +{ + static const char *t[] = { "yes", "true", "1", nullptr }; + static const char *f[] = { "no", "false", "0", nullptr }; + + if (string_array_contains(t, value)) { + *value_r = true; + return true; + } + + if (string_array_contains(f, value)) { + *value_r = false; + return true; + } + + return false; +} diff --git a/src/config/ConfigParser.hxx b/src/config/ConfigParser.hxx new file mode 100644 index 000000000..06151b0bd --- /dev/null +++ b/src/config/ConfigParser.hxx @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_CONFIG_PARSER_HXX +#define MPD_CONFIG_PARSER_HXX + +bool +get_bool(const char *value, bool *value_r); + +#endif diff --git a/src/config/ConfigPath.cxx b/src/config/ConfigPath.cxx new file mode 100644 index 000000000..a3b3f83a5 --- /dev/null +++ b/src/config/ConfigPath.cxx @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" +#include "ConfigPath.hxx" +#include "fs/AllocatedPath.hxx" +#include "fs/Traits.hxx" +#include "fs/Domain.hxx" +#include "fs/StandardDirectory.hxx" +#include "util/Error.hxx" +#include "ConfigGlobal.hxx" + +#include +#include + +#ifndef WIN32 +#include + +/** + * Determine a given user's home directory. + */ +static AllocatedPath +GetHome(const char *user, Error &error) +{ + AllocatedPath result = GetHomeDir(user); + if (result.IsNull()) { + error.Format(path_domain, + "no such user: %s", user); + return AllocatedPath::Null(); + } + + return result; +} + +/** + * Determine the current user's home directory. + */ +static AllocatedPath +GetHome(Error &error) +{ + AllocatedPath result = GetHomeDir(); + if (result.IsNull()) { + error.Set(path_domain, + "problems getting home for current user"); + return AllocatedPath::Null(); + } + + return result; +} + +/** + * Determine the configured user's home directory. + */ +static AllocatedPath +GetConfiguredHome(Error &error) +{ + const char *user = config_get_string(CONF_USER, nullptr); + return user != nullptr + ? GetHome(user, error) + : GetHome(error); +} + +#endif + +AllocatedPath +ParsePath(const char *path, Error &error) +{ + assert(path != nullptr); + +#ifndef WIN32 + if (path[0] == '~') { + ++path; + + if (*path == '\0') + return GetConfiguredHome(error); + + AllocatedPath home = AllocatedPath::Null(); + + if (*path == '/') { + home = GetConfiguredHome(error); + + ++path; + } else { + const char *slash = strchr(path, '/'); + const char *end = slash == nullptr + ? path + strlen(path) + : slash; + const std::string user(path, end); + home = GetHome(user.c_str(), error); + + if (slash == nullptr) + return home; + + path = slash + 1; + } + + if (home.IsNull()) + return AllocatedPath::Null(); + + AllocatedPath path2 = AllocatedPath::FromUTF8(path, error); + if (path2.IsNull()) + return AllocatedPath::Null(); + + return AllocatedPath::Build(home, path2); + } else if (!PathTraitsUTF8::IsAbsolute(path)) { + error.Format(path_domain, + "not an absolute path: %s", path); + return AllocatedPath::Null(); + } else { +#endif + return AllocatedPath::FromUTF8(path, error); +#ifndef WIN32 + } +#endif +} diff --git a/src/config/ConfigPath.hxx b/src/config/ConfigPath.hxx new file mode 100644 index 000000000..a5518a497 --- /dev/null +++ b/src/config/ConfigPath.hxx @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_CONFIG_PATH_HXX +#define MPD_CONFIG_PATH_HXX + +class AllocatedPath; +class Error; + +AllocatedPath +ParsePath(const char *path, Error &error); + +#endif diff --git a/src/config/ConfigTemplates.cxx b/src/config/ConfigTemplates.cxx new file mode 100644 index 000000000..e9cd68b5b --- /dev/null +++ b/src/config/ConfigTemplates.cxx @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "ConfigTemplates.hxx" +#include "ConfigOption.hxx" + +#include + +const ConfigTemplate config_templates[] = { + { "music_directory", false, false }, + { "playlist_directory", false, false }, + { "follow_inside_symlinks", false, false }, + { "follow_outside_symlinks", false, false }, + { "db_file", false, false }, + { "sticker_file", false, false }, + { "log_file", false, false }, + { "pid_file", false, false }, + { "state_file", false, false }, + { "restore_paused", false, false }, + { "user", false, false }, + { "group", false, false }, + { "bind_to_address", true, false }, + { "port", false, false }, + { "log_level", false, false }, + { "zeroconf_name", false, false }, + { "zeroconf_enabled", false, false }, + { "password", true, false }, + { "default_permissions", false, false }, + { "audio_output", true, true }, + { "audio_output_format", false, false }, + { "mixer_type", false, false }, + { "replaygain", false, false }, + { "replaygain_preamp", false, false }, + { "replaygain_missing_preamp", false, false }, + { "replaygain_limit", false, false }, + { "volume_normalization", false, false }, + { "samplerate_converter", false, false }, + { "audio_buffer_size", false, false }, + { "buffer_before_play", false, false }, + { "http_proxy_host", false, false }, + { "http_proxy_port", false, false }, + { "http_proxy_user", false, false }, + { "http_proxy_password", false, false }, + { "connection_timeout", false, false }, + { "max_connections", false, false }, + { "max_playlist_length", false, false }, + { "max_command_list_size", false, false }, + { "max_output_buffer_size", false, false }, + { "filesystem_charset", false, false }, + { "id3v1_encoding", false, false }, + { "metadata_to_use", false, false }, + { "save_absolute_paths_in_playlists", false, false }, + { "decoder", true, true }, + { "input", true, true }, + { "gapless_mp3_playback", false, false }, + { "playlist_plugin", true, true }, + { "auto_update", false, false }, + { "auto_update_depth", false, false }, + { "despotify_user", false, false }, + { "despotify_password", false, false}, + { "despotify_high_bitrate", false, false }, + { "filter", true, true }, + { "database", false, true }, +}; + +static constexpr unsigned n_config_templates = + sizeof(config_templates) / sizeof(config_templates[0]); + +static_assert(n_config_templates == unsigned(CONF_MAX), + "Wrong number of config_templates"); + +ConfigOption +ParseConfigOptionName(const char *name) +{ + for (unsigned i = 0; i < n_config_templates; ++i) + if (strcmp(config_templates[i].name, name) == 0) + return ConfigOption(i); + + return CONF_MAX; +} diff --git a/src/config/ConfigTemplates.hxx b/src/config/ConfigTemplates.hxx new file mode 100644 index 000000000..90d098dc0 --- /dev/null +++ b/src/config/ConfigTemplates.hxx @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_CONFIG_TEMPLATES_HXX +#define MPD_CONFIG_TEMPLATES_HXX + +struct ConfigTemplate { + const char *const name; + const bool repeatable; + const bool block; +}; + +extern const ConfigTemplate config_templates[]; + +#endif diff --git a/src/db/ProxyDatabasePlugin.cxx b/src/db/ProxyDatabasePlugin.cxx index b5ed09eb3..7253ba0d0 100644 --- a/src/db/ProxyDatabasePlugin.cxx +++ b/src/db/ProxyDatabasePlugin.cxx @@ -28,7 +28,7 @@ #include "LightSong.hxx" #include "SongFilter.hxx" #include "Compiler.h" -#include "ConfigData.hxx" +#include "config/ConfigData.hxx" #include "tag/TagBuilder.hxx" #include "tag/Tag.hxx" #include "util/Error.hxx" diff --git a/src/db/SimpleDatabasePlugin.cxx b/src/db/SimpleDatabasePlugin.cxx index f77d98ea5..73e080b41 100644 --- a/src/db/SimpleDatabasePlugin.cxx +++ b/src/db/SimpleDatabasePlugin.cxx @@ -29,7 +29,7 @@ #include "DatabaseLock.hxx" #include "DatabaseError.hxx" #include "fs/TextFile.hxx" -#include "ConfigData.hxx" +#include "config/ConfigData.hxx" #include "fs/FileSystem.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" diff --git a/src/db/UpnpDatabasePlugin.cxx b/src/db/UpnpDatabasePlugin.cxx index f18dd95d2..46084061f 100644 --- a/src/db/UpnpDatabasePlugin.cxx +++ b/src/db/UpnpDatabasePlugin.cxx @@ -31,7 +31,7 @@ #include "DatabaseError.hxx" #include "LightDirectory.hxx" #include "LightSong.hxx" -#include "ConfigData.hxx" +#include "config/ConfigData.hxx" #include "tag/TagBuilder.hxx" #include "tag/TagTable.hxx" #include "util/Error.hxx" diff --git a/src/decoder/DecoderAPI.hxx b/src/decoder/DecoderAPI.hxx index 0ce861fb1..0a7b84371 100644 --- a/src/decoder/DecoderAPI.hxx +++ b/src/decoder/DecoderAPI.hxx @@ -36,7 +36,7 @@ #include "tag/Tag.hxx" #include "AudioFormat.hxx" #include "MixRampInfo.hxx" -#include "ConfigData.hxx" +#include "config/ConfigData.hxx" // IWYU pragma: end_exports diff --git a/src/decoder/DecoderList.cxx b/src/decoder/DecoderList.cxx index a644d2eae..5423a85ab 100644 --- a/src/decoder/DecoderList.cxx +++ b/src/decoder/DecoderList.cxx @@ -20,8 +20,8 @@ #include "config.h" #include "DecoderList.hxx" #include "DecoderPlugin.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigData.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigData.hxx" #include "plugins/AudiofileDecoderPlugin.hxx" #include "plugins/PcmDecoderPlugin.hxx" #include "plugins/DsdiffDecoderPlugin.hxx" diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx index 07fd05f1b..8c32018f3 100644 --- a/src/decoder/plugins/MadDecoderPlugin.cxx +++ b/src/decoder/plugins/MadDecoderPlugin.cxx @@ -21,7 +21,7 @@ #include "MadDecoderPlugin.hxx" #include "../DecoderAPI.hxx" #include "InputStream.hxx" -#include "ConfigGlobal.hxx" +#include "config/ConfigGlobal.hxx" #include "tag/TagId3.hxx" #include "tag/TagRva2.hxx" #include "tag/TagHandler.hxx" diff --git a/src/encoder/EncoderAPI.hxx b/src/encoder/EncoderAPI.hxx index 267affa3a..b147eac21 100644 --- a/src/encoder/EncoderAPI.hxx +++ b/src/encoder/EncoderAPI.hxx @@ -30,7 +30,7 @@ #include "EncoderPlugin.hxx" #include "AudioFormat.hxx" #include "tag/Tag.hxx" -#include "ConfigData.hxx" +#include "config/ConfigData.hxx" // IWYU pragma: end_exports diff --git a/src/encoder/plugins/FlacEncoderPlugin.cxx b/src/encoder/plugins/FlacEncoderPlugin.cxx index ebdd101f3..26987fe99 100644 --- a/src/encoder/plugins/FlacEncoderPlugin.cxx +++ b/src/encoder/plugins/FlacEncoderPlugin.cxx @@ -22,7 +22,7 @@ #include "../EncoderAPI.hxx" #include "AudioFormat.hxx" #include "pcm/PcmBuffer.hxx" -#include "ConfigError.hxx" +#include "config/ConfigError.hxx" #include "util/Manual.hxx" #include "util/DynamicFifoBuffer.hxx" #include "util/Error.hxx" diff --git a/src/encoder/plugins/LameEncoderPlugin.cxx b/src/encoder/plugins/LameEncoderPlugin.cxx index 484c4d0fe..3878b52bb 100644 --- a/src/encoder/plugins/LameEncoderPlugin.cxx +++ b/src/encoder/plugins/LameEncoderPlugin.cxx @@ -21,7 +21,7 @@ #include "LameEncoderPlugin.hxx" #include "../EncoderAPI.hxx" #include "AudioFormat.hxx" -#include "ConfigError.hxx" +#include "config/ConfigError.hxx" #include "util/NumberParser.hxx" #include "util/ReusableArray.hxx" #include "util/Manual.hxx" diff --git a/src/encoder/plugins/OpusEncoderPlugin.cxx b/src/encoder/plugins/OpusEncoderPlugin.cxx index 9fbdc8711..2d3194c26 100644 --- a/src/encoder/plugins/OpusEncoderPlugin.cxx +++ b/src/encoder/plugins/OpusEncoderPlugin.cxx @@ -23,7 +23,7 @@ #include "OggSerial.hxx" #include "../EncoderAPI.hxx" #include "AudioFormat.hxx" -#include "ConfigError.hxx" +#include "config/ConfigError.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" #include "system/ByteOrder.hxx" diff --git a/src/encoder/plugins/ShineEncoderPlugin.cxx b/src/encoder/plugins/ShineEncoderPlugin.cxx index 5b1b95a27..00b8eec7c 100644 --- a/src/encoder/plugins/ShineEncoderPlugin.cxx +++ b/src/encoder/plugins/ShineEncoderPlugin.cxx @@ -21,7 +21,7 @@ #include "config.h" #include "../EncoderAPI.hxx" #include "AudioFormat.hxx" -#include "ConfigError.hxx" +#include "config/ConfigError.hxx" #include "util/Manual.hxx" #include "util/NumberParser.hxx" #include "util/DynamicFifoBuffer.hxx" diff --git a/src/encoder/plugins/TwolameEncoderPlugin.cxx b/src/encoder/plugins/TwolameEncoderPlugin.cxx index cea72bfdd..2eb6b2b1c 100644 --- a/src/encoder/plugins/TwolameEncoderPlugin.cxx +++ b/src/encoder/plugins/TwolameEncoderPlugin.cxx @@ -21,7 +21,7 @@ #include "TwolameEncoderPlugin.hxx" #include "../EncoderAPI.hxx" #include "AudioFormat.hxx" -#include "ConfigError.hxx" +#include "config/ConfigError.hxx" #include "util/NumberParser.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" diff --git a/src/encoder/plugins/VorbisEncoderPlugin.cxx b/src/encoder/plugins/VorbisEncoderPlugin.cxx index 356d67571..7fdb3066f 100644 --- a/src/encoder/plugins/VorbisEncoderPlugin.cxx +++ b/src/encoder/plugins/VorbisEncoderPlugin.cxx @@ -24,7 +24,7 @@ #include "../EncoderAPI.hxx" #include "tag/Tag.hxx" #include "AudioFormat.hxx" -#include "ConfigError.hxx" +#include "config/ConfigError.hxx" #include "util/NumberParser.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" diff --git a/src/filter/AutoConvertFilterPlugin.cxx b/src/filter/AutoConvertFilterPlugin.cxx index 34ba7eef2..b9bc12f31 100644 --- a/src/filter/AutoConvertFilterPlugin.cxx +++ b/src/filter/AutoConvertFilterPlugin.cxx @@ -24,7 +24,7 @@ #include "FilterInternal.hxx" #include "FilterRegistry.hxx" #include "AudioFormat.hxx" -#include "ConfigData.hxx" +#include "config/ConfigData.hxx" #include diff --git a/src/filter/RouteFilterPlugin.cxx b/src/filter/RouteFilterPlugin.cxx index 75b5cffba..50073778a 100644 --- a/src/filter/RouteFilterPlugin.cxx +++ b/src/filter/RouteFilterPlugin.cxx @@ -40,8 +40,8 @@ */ #include "config.h" -#include "ConfigError.hxx" -#include "ConfigData.hxx" +#include "config/ConfigError.hxx" +#include "config/ConfigData.hxx" #include "AudioFormat.hxx" #include "FilterPlugin.hxx" #include "FilterInternal.hxx" diff --git a/src/fs/Config.cxx b/src/fs/Config.cxx index b88de69cf..c9555bcc2 100644 --- a/src/fs/Config.cxx +++ b/src/fs/Config.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "Config.hxx" #include "Charset.hxx" -#include "ConfigGlobal.hxx" +#include "config/ConfigGlobal.hxx" #include diff --git a/src/input/CdioParanoiaInputPlugin.cxx b/src/input/CdioParanoiaInputPlugin.cxx index f9264979f..297ee84dc 100644 --- a/src/input/CdioParanoiaInputPlugin.cxx +++ b/src/input/CdioParanoiaInputPlugin.cxx @@ -31,8 +31,8 @@ #include "system/ByteOrder.hxx" #include "fs/AllocatedPath.hxx" #include "Log.hxx" -#include "ConfigData.hxx" -#include "ConfigError.hxx" +#include "config/ConfigData.hxx" +#include "config/ConfigError.hxx" #include #include diff --git a/src/input/CurlInputPlugin.cxx b/src/input/CurlInputPlugin.cxx index ccb73a448..64321b38d 100644 --- a/src/input/CurlInputPlugin.cxx +++ b/src/input/CurlInputPlugin.cxx @@ -21,8 +21,8 @@ #include "CurlInputPlugin.hxx" #include "InputStream.hxx" #include "InputPlugin.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigData.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigData.hxx" #include "tag/Tag.hxx" #include "tag/TagBuilder.hxx" #include "IcyMetaDataParser.hxx" diff --git a/src/mixer/OssMixerPlugin.cxx b/src/mixer/OssMixerPlugin.cxx index ef5992d1d..4e116c2fb 100644 --- a/src/mixer/OssMixerPlugin.cxx +++ b/src/mixer/OssMixerPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "MixerInternal.hxx" -#include "ConfigData.hxx" +#include "config/ConfigData.hxx" #include "system/fd_util.h" #include "util/ASCII.hxx" #include "util/Error.hxx" diff --git a/src/mixer/SoftwareMixerPlugin.cxx b/src/mixer/SoftwareMixerPlugin.cxx index 9609a7c81..ad23baa2c 100644 --- a/src/mixer/SoftwareMixerPlugin.cxx +++ b/src/mixer/SoftwareMixerPlugin.cxx @@ -25,7 +25,7 @@ #include "FilterInternal.hxx" #include "filter/VolumeFilterPlugin.hxx" #include "pcm/Volume.hxx" -#include "ConfigData.hxx" +#include "config/ConfigData.hxx" #include "util/Error.hxx" #include diff --git a/src/output/OutputAPI.hxx b/src/output/OutputAPI.hxx index 322ed3971..cfbc43196 100644 --- a/src/output/OutputAPI.hxx +++ b/src/output/OutputAPI.hxx @@ -26,7 +26,7 @@ #include "OutputInternal.hxx" #include "AudioFormat.hxx" #include "tag/Tag.hxx" -#include "ConfigData.hxx" +#include "config/ConfigData.hxx" // IWYU pragma: end_exports diff --git a/src/output/OutputAll.cxx b/src/output/OutputAll.cxx index b3623f1af..ded9fa1e1 100644 --- a/src/output/OutputAll.cxx +++ b/src/output/OutputAll.cxx @@ -28,9 +28,9 @@ #include "MusicChunk.hxx" #include "system/FatalError.hxx" #include "util/Error.hxx" -#include "ConfigData.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigOption.hxx" +#include "config/ConfigData.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigOption.hxx" #include "notify.hxx" #include diff --git a/src/output/OutputInit.cxx b/src/output/OutputInit.cxx index f5b1bdc81..920a04997 100644 --- a/src/output/OutputInit.cxx +++ b/src/output/OutputInit.cxx @@ -33,8 +33,8 @@ #include "filter/AutoConvertFilterPlugin.hxx" #include "filter/ReplayGainFilterPlugin.hxx" #include "filter/ChainFilterPlugin.hxx" -#include "ConfigError.hxx" -#include "ConfigGlobal.hxx" +#include "config/ConfigError.hxx" +#include "config/ConfigGlobal.hxx" #include "util/Error.hxx" #include "Log.hxx" diff --git a/src/output/plugins/FifoOutputPlugin.cxx b/src/output/plugins/FifoOutputPlugin.cxx index 5f14bcbbe..6e3a4d332 100644 --- a/src/output/plugins/FifoOutputPlugin.cxx +++ b/src/output/plugins/FifoOutputPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "FifoOutputPlugin.hxx" -#include "ConfigError.hxx" +#include "config/ConfigError.hxx" #include "../OutputAPI.hxx" #include "Timer.hxx" #include "fs/AllocatedPath.hxx" diff --git a/src/output/plugins/JackOutputPlugin.cxx b/src/output/plugins/JackOutputPlugin.cxx index 5a0d2bf16..b981c1292 100644 --- a/src/output/plugins/JackOutputPlugin.cxx +++ b/src/output/plugins/JackOutputPlugin.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "JackOutputPlugin.hxx" #include "../OutputAPI.hxx" -#include "ConfigError.hxx" +#include "config/ConfigError.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" #include "Log.hxx" diff --git a/src/output/plugins/PipeOutputPlugin.cxx b/src/output/plugins/PipeOutputPlugin.cxx index 802e1ba4d..2eb0c6dd8 100644 --- a/src/output/plugins/PipeOutputPlugin.cxx +++ b/src/output/plugins/PipeOutputPlugin.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "PipeOutputPlugin.hxx" #include "../OutputAPI.hxx" -#include "ConfigError.hxx" +#include "config/ConfigError.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" diff --git a/src/output/plugins/RecorderOutputPlugin.cxx b/src/output/plugins/RecorderOutputPlugin.cxx index 16fe2c692..685438009 100644 --- a/src/output/plugins/RecorderOutputPlugin.cxx +++ b/src/output/plugins/RecorderOutputPlugin.cxx @@ -22,7 +22,7 @@ #include "../OutputAPI.hxx" #include "encoder/EncoderPlugin.hxx" #include "encoder/EncoderList.hxx" -#include "ConfigError.hxx" +#include "config/ConfigError.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" #include "system/fd_util.h" diff --git a/src/output/plugins/ShoutOutputPlugin.cxx b/src/output/plugins/ShoutOutputPlugin.cxx index e0ec6ce3d..f86e5ce4b 100644 --- a/src/output/plugins/ShoutOutputPlugin.cxx +++ b/src/output/plugins/ShoutOutputPlugin.cxx @@ -22,7 +22,7 @@ #include "../OutputAPI.hxx" #include "encoder/EncoderPlugin.hxx" #include "encoder/EncoderList.hxx" -#include "ConfigError.hxx" +#include "config/ConfigError.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" #include "system/FatalError.hxx" diff --git a/src/pcm/ConfiguredResampler.cxx b/src/pcm/ConfiguredResampler.cxx index a9429ef37..f6aec3f95 100644 --- a/src/pcm/ConfiguredResampler.cxx +++ b/src/pcm/ConfiguredResampler.cxx @@ -20,9 +20,9 @@ #include "config.h" #include "ConfiguredResampler.hxx" #include "FallbackResampler.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigOption.hxx" -#include "ConfigError.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigOption.hxx" +#include "config/ConfigError.hxx" #include "util/Error.hxx" #ifdef HAVE_LIBSAMPLERATE diff --git a/src/playlist/PlaylistRegistry.cxx b/src/playlist/PlaylistRegistry.cxx index 94244f14c..7e80d8d8e 100644 --- a/src/playlist/PlaylistRegistry.cxx +++ b/src/playlist/PlaylistRegistry.cxx @@ -35,8 +35,8 @@ #include "util/StringUtil.hxx" #include "util/Error.hxx" #include "util/Macros.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigData.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigData.hxx" #include "system/FatalError.hxx" #include "Log.hxx" diff --git a/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx b/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx index fac052d19..62936ced5 100644 --- a/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx +++ b/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx @@ -21,7 +21,7 @@ #include "SoundCloudPlaylistPlugin.hxx" #include "../PlaylistPlugin.hxx" #include "../MemorySongEnumerator.hxx" -#include "ConfigData.hxx" +#include "config/ConfigData.hxx" #include "InputStream.hxx" #include "tag/TagBuilder.hxx" #include "util/StringUtil.hxx" diff --git a/src/tag/TagConfig.cxx b/src/tag/TagConfig.cxx index cfdd2e1eb..3e941c8d9 100644 --- a/src/tag/TagConfig.cxx +++ b/src/tag/TagConfig.cxx @@ -21,8 +21,8 @@ #include "TagConfig.hxx" #include "TagSettings.h" #include "Tag.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigOption.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigOption.hxx" #include "system/FatalError.hxx" #include "util/Alloc.hxx" #include "util/ASCII.hxx" diff --git a/src/tag/TagId3.cxx b/src/tag/TagId3.cxx index 459692e79..4ecd4baa6 100644 --- a/src/tag/TagId3.cxx +++ b/src/tag/TagId3.cxx @@ -25,7 +25,7 @@ #include "util/Error.hxx" #include "util/Domain.hxx" #include "Log.hxx" -#include "ConfigGlobal.hxx" +#include "config/ConfigGlobal.hxx" #include "Riff.hxx" #include "Aiff.hxx" #include "fs/Path.hxx" diff --git a/src/zeroconf/ZeroconfGlue.cxx b/src/zeroconf/ZeroconfGlue.cxx index 05bb3c17c..95797491b 100644 --- a/src/zeroconf/ZeroconfGlue.cxx +++ b/src/zeroconf/ZeroconfGlue.cxx @@ -21,8 +21,8 @@ #include "ZeroconfGlue.hxx" #include "ZeroconfAvahi.hxx" #include "ZeroconfBonjour.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigOption.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigOption.hxx" #include "Listen.hxx" #include "util/Domain.hxx" #include "Log.hxx" diff --git a/test/DumpDatabase.cxx b/test/DumpDatabase.cxx index 7b959a215..caf433ac1 100644 --- a/test/DumpDatabase.cxx +++ b/test/DumpDatabase.cxx @@ -25,8 +25,8 @@ #include "LightDirectory.hxx" #include "LightSong.hxx" #include "PlaylistVector.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigData.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigData.hxx" #include "tag/TagConfig.hxx" #include "fs/Path.hxx" #include "event/Loop.hxx" diff --git a/test/dump_playlist.cxx b/test/dump_playlist.cxx index 37fcfd391..292f3987e 100644 --- a/test/dump_playlist.cxx +++ b/test/dump_playlist.cxx @@ -22,7 +22,7 @@ #include "DetachedSong.hxx" #include "playlist/SongEnumerator.hxx" #include "InputStream.hxx" -#include "ConfigGlobal.hxx" +#include "config/ConfigGlobal.hxx" #include "decoder/DecoderList.hxx" #include "InputInit.hxx" #include "IOThread.hxx" diff --git a/test/dump_rva2.cxx b/test/dump_rva2.cxx index 08e5352b8..fd46ee36c 100644 --- a/test/dump_rva2.cxx +++ b/test/dump_rva2.cxx @@ -21,7 +21,7 @@ #include "tag/TagId3.hxx" #include "tag/TagRva2.hxx" #include "ReplayGainInfo.hxx" -#include "ConfigGlobal.hxx" +#include "config/ConfigGlobal.hxx" #include "util/Error.hxx" #include "fs/Path.hxx" #include "Log.hxx" diff --git a/test/dump_text_file.cxx b/test/dump_text_file.cxx index 581bb8829..5ce5e9da4 100644 --- a/test/dump_text_file.cxx +++ b/test/dump_text_file.cxx @@ -21,7 +21,7 @@ #include "IOThread.hxx" #include "InputInit.hxx" #include "InputStream.hxx" -#include "ConfigGlobal.hxx" +#include "config/ConfigGlobal.hxx" #include "stdbin.h" #include "TextInputStream.hxx" #include "util/Error.hxx" diff --git a/test/read_conf.cxx b/test/read_conf.cxx index b519f4d78..42afdfb4b 100644 --- a/test/read_conf.cxx +++ b/test/read_conf.cxx @@ -18,7 +18,7 @@ */ #include "config.h" -#include "ConfigGlobal.hxx" +#include "config/ConfigGlobal.hxx" #include "fs/Path.hxx" #include "util/Error.hxx" #include "Log.hxx" diff --git a/test/read_mixer.cxx b/test/read_mixer.cxx index 41261a310..60c60c86a 100644 --- a/test/read_mixer.cxx +++ b/test/read_mixer.cxx @@ -25,7 +25,7 @@ #include "GlobalEvents.hxx" #include "Main.hxx" #include "event/Loop.hxx" -#include "ConfigData.hxx" +#include "config/ConfigData.hxx" #include "util/Error.hxx" #include "Log.hxx" diff --git a/test/run_convert.cxx b/test/run_convert.cxx index 192ce808a..3c75b2c19 100644 --- a/test/run_convert.cxx +++ b/test/run_convert.cxx @@ -27,7 +27,7 @@ #include "AudioParser.hxx" #include "AudioFormat.hxx" #include "pcm/PcmConvert.hxx" -#include "ConfigGlobal.hxx" +#include "config/ConfigGlobal.hxx" #include "util/FifoBuffer.hxx" #include "util/Error.hxx" #include "Log.hxx" diff --git a/test/run_encoder.cxx b/test/run_encoder.cxx index ace9faf18..f16d8cb0a 100644 --- a/test/run_encoder.cxx +++ b/test/run_encoder.cxx @@ -22,7 +22,7 @@ #include "encoder/EncoderPlugin.hxx" #include "AudioFormat.hxx" #include "AudioParser.hxx" -#include "ConfigData.hxx" +#include "config/ConfigData.hxx" #include "util/Error.hxx" #include "Log.hxx" #include "stdbin.h" diff --git a/test/run_filter.cxx b/test/run_filter.cxx index a577cf8ee..16808ebb2 100644 --- a/test/run_filter.cxx +++ b/test/run_filter.cxx @@ -18,8 +18,8 @@ */ #include "config.h" -#include "ConfigData.hxx" -#include "ConfigGlobal.hxx" +#include "config/ConfigData.hxx" +#include "config/ConfigGlobal.hxx" #include "fs/Path.hxx" #include "AudioParser.hxx" #include "AudioFormat.hxx" diff --git a/test/run_input.cxx b/test/run_input.cxx index 2587a80b0..48892dc28 100644 --- a/test/run_input.cxx +++ b/test/run_input.cxx @@ -21,7 +21,7 @@ #include "TagSave.hxx" #include "stdbin.h" #include "tag/Tag.hxx" -#include "ConfigGlobal.hxx" +#include "config/ConfigGlobal.hxx" #include "InputStream.hxx" #include "InputInit.hxx" #include "IOThread.hxx" diff --git a/test/run_output.cxx b/test/run_output.cxx index c18451e10..de2152337 100644 --- a/test/run_output.cxx +++ b/test/run_output.cxx @@ -21,9 +21,9 @@ #include "output/OutputControl.hxx" #include "output/OutputInternal.hxx" #include "output/OutputPlugin.hxx" -#include "ConfigData.hxx" -#include "ConfigGlobal.hxx" -#include "ConfigOption.hxx" +#include "config/ConfigData.hxx" +#include "config/ConfigGlobal.hxx" +#include "config/ConfigOption.hxx" #include "Idle.hxx" #include "Main.hxx" #include "event/Loop.hxx" diff --git a/test/test_vorbis_encoder.cxx b/test/test_vorbis_encoder.cxx index fba0040d2..59b901da2 100644 --- a/test/test_vorbis_encoder.cxx +++ b/test/test_vorbis_encoder.cxx @@ -21,7 +21,7 @@ #include "encoder/EncoderList.hxx" #include "encoder/EncoderPlugin.hxx" #include "AudioFormat.hxx" -#include "ConfigData.hxx" +#include "config/ConfigData.hxx" #include "stdbin.h" #include "tag/Tag.hxx" #include "tag/TagBuilder.hxx" diff --git a/test/visit_archive.cxx b/test/visit_archive.cxx index 001b9067b..ee9fd1a4e 100644 --- a/test/visit_archive.cxx +++ b/test/visit_archive.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "stdbin.h" #include "tag/Tag.hxx" -#include "ConfigGlobal.hxx" +#include "config/ConfigGlobal.hxx" #include "IOThread.hxx" #include "InputInit.hxx" #include "archive/ArchiveList.hxx" -- cgit v1.2.3