From daa46477125145dd943122c8064c7271a1a9429f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 30 Jan 2013 17:53:13 +0100 Subject: ConfigOption: rename to ConfigTemplate --- Makefile.am | 1 + src/ConfigFile.cxx | 6 +-- src/ConfigOptions.hxx | 98 ------------------------------------------------- src/ConfigTemplates.hxx | 98 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 101 deletions(-) delete mode 100644 src/ConfigOptions.hxx create mode 100644 src/ConfigTemplates.hxx diff --git a/Makefile.am b/Makefile.am index 5d34286c..68552f74 100644 --- a/Makefile.am +++ b/Makefile.am @@ -148,6 +148,7 @@ src_mpd_SOURCES = \ src/Idle.cxx src/Idle.hxx \ src/CommandLine.cxx src/CommandLine.hxx \ src/ConfigFile.cxx \ + src/ConfigTemplates.hxx \ src/CrossFade.cxx src/CrossFade.hxx \ src/cue/cue_parser.c src/cue/cue_parser.h \ src/decoder_error.h \ diff --git a/src/ConfigFile.cxx b/src/ConfigFile.cxx index c49e4a48..2c8238c2 100644 --- a/src/ConfigFile.cxx +++ b/src/ConfigFile.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "conf.h" -#include "ConfigOptions.hxx" +#include "ConfigTemplates.hxx" extern "C" { #include "utils.h" @@ -46,7 +46,7 @@ extern "C" { #define CONF_COMMENT '#' -static GSList *config_params[G_N_ELEMENTS(config_options)]; +static GSList *config_params[G_N_ELEMENTS(config_templates)]; static bool get_bool(const char *value, bool *value_r) @@ -318,7 +318,7 @@ ReadConfigFile(const Path &path, GError **error_r) return false; } - const ConfigOption &option = config_options[i]; + const ConfigTemplate &option = config_templates[i]; GSList *¶ms = config_params[i]; if (params != NULL && !option.repeatable) { diff --git a/src/ConfigOptions.hxx b/src/ConfigOptions.hxx deleted file mode 100644 index 5e2ec189..00000000 --- a/src/ConfigOptions.hxx +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2003-2013 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 "gcc.h" - -#include - -#include - -struct ConfigOption { - const char *const name; - const bool repeatable; - const bool block; -}; - -static constexpr struct ConfigOption config_options[] = { - { CONF_MUSIC_DIR, false, false }, - { CONF_PLAYLIST_DIR, false, false }, - { CONF_FOLLOW_INSIDE_SYMLINKS, false, false }, - { CONF_FOLLOW_OUTSIDE_SYMLINKS, false, false }, - { CONF_DB_FILE, false, false }, - { CONF_STICKER_FILE, false, false }, - { CONF_LOG_FILE, false, false }, - { CONF_PID_FILE, false, false }, - { CONF_STATE_FILE, false, false }, - { "restore_paused", false, false }, - { CONF_USER, false, false }, - { CONF_GROUP, false, false }, - { CONF_BIND_TO_ADDRESS, true, false }, - { CONF_PORT, false, false }, - { CONF_LOG_LEVEL, false, false }, - { CONF_ZEROCONF_NAME, false, false }, - { CONF_ZEROCONF_ENABLED, false, false }, - { CONF_PASSWORD, true, false }, - { CONF_DEFAULT_PERMS, false, false }, - { CONF_AUDIO_OUTPUT, true, true }, - { CONF_AUDIO_OUTPUT_FORMAT, false, false }, - { CONF_MIXER_TYPE, false, false }, - { CONF_REPLAYGAIN, false, false }, - { CONF_REPLAYGAIN_PREAMP, false, false }, - { CONF_REPLAYGAIN_MISSING_PREAMP, false, false }, - { CONF_REPLAYGAIN_LIMIT, false, false }, - { CONF_VOLUME_NORMALIZATION, false, false }, - { CONF_SAMPLERATE_CONVERTER, false, false }, - { CONF_AUDIO_BUFFER_SIZE, false, false }, - { CONF_BUFFER_BEFORE_PLAY, false, false }, - { CONF_HTTP_PROXY_HOST, false, false }, - { CONF_HTTP_PROXY_PORT, false, false }, - { CONF_HTTP_PROXY_USER, false, false }, - { CONF_HTTP_PROXY_PASSWORD, false, false }, - { CONF_CONN_TIMEOUT, false, false }, - { CONF_MAX_CONN, false, false }, - { CONF_MAX_PLAYLIST_LENGTH, false, false }, - { CONF_MAX_COMMAND_LIST_SIZE, false, false }, - { CONF_MAX_OUTPUT_BUFFER_SIZE, false, false }, - { CONF_FS_CHARSET, false, false }, - { CONF_ID3V1_ENCODING, false, false }, - { CONF_METADATA_TO_USE, false, false }, - { CONF_SAVE_ABSOLUTE_PATHS, false, false }, - { CONF_DECODER, true, true }, - { CONF_INPUT, true, true }, - { CONF_GAPLESS_MP3_PLAYBACK, false, false }, - { CONF_PLAYLIST_PLUGIN, true, true }, - { CONF_AUTO_UPDATE, false, false }, - { CONF_AUTO_UPDATE_DEPTH, false, false }, - { CONF_DESPOTIFY_USER, false, false }, - { CONF_DESPOTIFY_PASSWORD, false, false}, - { CONF_DESPOTIFY_HIGH_BITRATE, false, false }, - { "filter", true, true }, - { "database", false, true }, -}; - -gcc_pure -static int -ConfigFindByName(const char *name) -{ - for (unsigned i = 0; i < G_N_ELEMENTS(config_options); ++i) - if (strcmp(config_options[i].name, name) == 0) - return i; - - return -1; -} diff --git a/src/ConfigTemplates.hxx b/src/ConfigTemplates.hxx new file mode 100644 index 00000000..8592070c --- /dev/null +++ b/src/ConfigTemplates.hxx @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2003-2013 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 "gcc.h" + +#include + +#include + +struct ConfigTemplate { + const char *const name; + const bool repeatable; + const bool block; +}; + +static constexpr struct ConfigTemplate config_templates[] = { + { CONF_MUSIC_DIR, false, false }, + { CONF_PLAYLIST_DIR, false, false }, + { CONF_FOLLOW_INSIDE_SYMLINKS, false, false }, + { CONF_FOLLOW_OUTSIDE_SYMLINKS, false, false }, + { CONF_DB_FILE, false, false }, + { CONF_STICKER_FILE, false, false }, + { CONF_LOG_FILE, false, false }, + { CONF_PID_FILE, false, false }, + { CONF_STATE_FILE, false, false }, + { "restore_paused", false, false }, + { CONF_USER, false, false }, + { CONF_GROUP, false, false }, + { CONF_BIND_TO_ADDRESS, true, false }, + { CONF_PORT, false, false }, + { CONF_LOG_LEVEL, false, false }, + { CONF_ZEROCONF_NAME, false, false }, + { CONF_ZEROCONF_ENABLED, false, false }, + { CONF_PASSWORD, true, false }, + { CONF_DEFAULT_PERMS, false, false }, + { CONF_AUDIO_OUTPUT, true, true }, + { CONF_AUDIO_OUTPUT_FORMAT, false, false }, + { CONF_MIXER_TYPE, false, false }, + { CONF_REPLAYGAIN, false, false }, + { CONF_REPLAYGAIN_PREAMP, false, false }, + { CONF_REPLAYGAIN_MISSING_PREAMP, false, false }, + { CONF_REPLAYGAIN_LIMIT, false, false }, + { CONF_VOLUME_NORMALIZATION, false, false }, + { CONF_SAMPLERATE_CONVERTER, false, false }, + { CONF_AUDIO_BUFFER_SIZE, false, false }, + { CONF_BUFFER_BEFORE_PLAY, false, false }, + { CONF_HTTP_PROXY_HOST, false, false }, + { CONF_HTTP_PROXY_PORT, false, false }, + { CONF_HTTP_PROXY_USER, false, false }, + { CONF_HTTP_PROXY_PASSWORD, false, false }, + { CONF_CONN_TIMEOUT, false, false }, + { CONF_MAX_CONN, false, false }, + { CONF_MAX_PLAYLIST_LENGTH, false, false }, + { CONF_MAX_COMMAND_LIST_SIZE, false, false }, + { CONF_MAX_OUTPUT_BUFFER_SIZE, false, false }, + { CONF_FS_CHARSET, false, false }, + { CONF_ID3V1_ENCODING, false, false }, + { CONF_METADATA_TO_USE, false, false }, + { CONF_SAVE_ABSOLUTE_PATHS, false, false }, + { CONF_DECODER, true, true }, + { CONF_INPUT, true, true }, + { CONF_GAPLESS_MP3_PLAYBACK, false, false }, + { CONF_PLAYLIST_PLUGIN, true, true }, + { CONF_AUTO_UPDATE, false, false }, + { CONF_AUTO_UPDATE_DEPTH, false, false }, + { CONF_DESPOTIFY_USER, false, false }, + { CONF_DESPOTIFY_PASSWORD, false, false}, + { CONF_DESPOTIFY_HIGH_BITRATE, false, false }, + { "filter", true, true }, + { "database", false, true }, +}; + +gcc_pure +static int +ConfigFindByName(const char *name) +{ + for (unsigned i = 0; i < G_N_ELEMENTS(config_templates); ++i) + if (strcmp(config_templates[i].name, name) == 0) + return i; + + return -1; +} -- cgit v1.2.3