2013-01-30 17:52:51 +01:00
|
|
|
/*
|
2015-01-01 19:48:13 +01:00
|
|
|
* Copyright (C) 2003-2015 The Music Player Daemon Project
|
2013-01-30 17:52:51 +01:00
|
|
|
* 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"
|
2014-12-09 22:04:34 +01:00
|
|
|
#include "util/Macros.hxx"
|
2013-01-30 17:52:51 +01:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2015-01-21 22:13:44 +01:00
|
|
|
const ConfigTemplate config_param_templates[] = {
|
2015-06-26 00:11:23 +02:00
|
|
|
{ "music_directory" },
|
|
|
|
{ "playlist_directory" },
|
|
|
|
{ "follow_inside_symlinks" },
|
|
|
|
{ "follow_outside_symlinks" },
|
|
|
|
{ "db_file" },
|
|
|
|
{ "sticker_file" },
|
|
|
|
{ "log_file" },
|
|
|
|
{ "pid_file" },
|
|
|
|
{ "state_file" },
|
|
|
|
{ "state_file_interval" },
|
|
|
|
{ "restore_paused" },
|
|
|
|
{ "user" },
|
|
|
|
{ "group" },
|
2015-01-21 22:13:44 +01:00
|
|
|
{ "bind_to_address", true },
|
2015-06-26 00:11:23 +02:00
|
|
|
{ "port" },
|
|
|
|
{ "log_level" },
|
|
|
|
{ "zeroconf_name" },
|
|
|
|
{ "zeroconf_enabled" },
|
2015-01-21 22:13:44 +01:00
|
|
|
{ "password", true },
|
2015-06-26 00:11:23 +02:00
|
|
|
{ "default_permissions" },
|
|
|
|
{ "audio_output_format" },
|
|
|
|
{ "mixer_type" },
|
|
|
|
{ "replaygain" },
|
|
|
|
{ "replaygain_preamp" },
|
|
|
|
{ "replaygain_missing_preamp" },
|
|
|
|
{ "replaygain_limit" },
|
|
|
|
{ "volume_normalization" },
|
|
|
|
{ "samplerate_converter" },
|
|
|
|
{ "audio_buffer_size" },
|
|
|
|
{ "buffer_before_play" },
|
|
|
|
{ "http_proxy_host" },
|
|
|
|
{ "http_proxy_port" },
|
|
|
|
{ "http_proxy_user" },
|
|
|
|
{ "http_proxy_password" },
|
|
|
|
{ "connection_timeout" },
|
|
|
|
{ "max_connections" },
|
|
|
|
{ "max_playlist_length" },
|
|
|
|
{ "max_command_list_size" },
|
|
|
|
{ "max_output_buffer_size" },
|
|
|
|
{ "filesystem_charset" },
|
|
|
|
{ "id3v1_encoding" },
|
|
|
|
{ "metadata_to_use" },
|
|
|
|
{ "save_absolute_paths_in_playlists" },
|
|
|
|
{ "gapless_mp3_playback" },
|
|
|
|
{ "auto_update" },
|
|
|
|
{ "auto_update_depth" },
|
|
|
|
{ "despotify_user" },
|
|
|
|
{ "despotify_password" },
|
|
|
|
{ "despotify_high_bitrate" },
|
2013-01-30 17:52:51 +01:00
|
|
|
};
|
|
|
|
|
2015-01-21 22:13:44 +01:00
|
|
|
static constexpr unsigned n_config_param_templates =
|
|
|
|
ARRAY_SIZE(config_param_templates);
|
2013-01-30 17:52:51 +01:00
|
|
|
|
2015-01-21 22:13:44 +01:00
|
|
|
static_assert(n_config_param_templates == unsigned(ConfigOption::MAX),
|
|
|
|
"Wrong number of config_param_templates");
|
|
|
|
|
|
|
|
const ConfigTemplate config_block_templates[] = {
|
|
|
|
{ "audio_output", true },
|
|
|
|
{ "decoder", true },
|
|
|
|
{ "input", true },
|
|
|
|
{ "playlist_plugin", true },
|
2015-06-26 00:11:23 +02:00
|
|
|
{ "resampler" },
|
2015-01-21 22:13:44 +01:00
|
|
|
{ "filter", true },
|
2015-06-26 00:11:23 +02:00
|
|
|
{ "database" },
|
2015-01-21 22:13:44 +01:00
|
|
|
{ "neighbors", true },
|
|
|
|
};
|
|
|
|
|
|
|
|
static constexpr unsigned n_config_block_templates =
|
|
|
|
ARRAY_SIZE(config_block_templates);
|
|
|
|
|
|
|
|
static_assert(n_config_block_templates == unsigned(ConfigBlockOption::MAX),
|
|
|
|
"Wrong number of config_block_templates");
|
|
|
|
|
|
|
|
gcc_pure
|
|
|
|
static inline unsigned
|
|
|
|
ParseConfigTemplateName(const ConfigTemplate templates[], unsigned count,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
unsigned i = 0;
|
|
|
|
for (; i < count; ++i)
|
|
|
|
if (strcmp(templates[i].name, name) == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
2013-01-30 17:52:51 +01:00
|
|
|
|
|
|
|
ConfigOption
|
|
|
|
ParseConfigOptionName(const char *name)
|
|
|
|
{
|
2015-01-21 22:13:44 +01:00
|
|
|
return ConfigOption(ParseConfigTemplateName(config_param_templates,
|
|
|
|
n_config_param_templates,
|
|
|
|
name));
|
|
|
|
}
|
2013-01-30 17:52:51 +01:00
|
|
|
|
2015-01-21 22:13:44 +01:00
|
|
|
ConfigBlockOption
|
|
|
|
ParseConfigBlockOptionName(const char *name)
|
|
|
|
{
|
|
|
|
return ConfigBlockOption(ParseConfigTemplateName(config_block_templates,
|
|
|
|
n_config_block_templates,
|
|
|
|
name));
|
2013-01-30 17:52:51 +01:00
|
|
|
}
|