Commit 1c3f5517 authored by Max Kellermann's avatar Max Kellermann

config/Option: convert to strictly-typed enum

parent 10972da0
......@@ -39,7 +39,7 @@ getOutputAudioFormat(AudioFormat inAudioFormat)
void initAudioConfig(void)
{
const struct config_param *param = config_get_param(CONF_AUDIO_OUTPUT_FORMAT);
const struct config_param *param = config_get_param(ConfigOption::AUDIO_OUTPUT_FORMAT);
if (param == nullptr)
return;
......
......@@ -103,9 +103,9 @@ listen_systemd_activation(Error &error_r)
bool
listen_global_init(EventLoop &loop, Partition &partition, Error &error)
{
int port = config_get_positive(CONF_PORT, DEFAULT_PORT);
int port = config_get_positive(ConfigOption::PORT, DEFAULT_PORT);
const struct config_param *param =
config_get_param(CONF_BIND_TO_ADDRESS);
config_get_param(ConfigOption::BIND_TO_ADDRESS);
listen_socket = new ClientListener(loop, partition);
......
......@@ -139,14 +139,14 @@ log_init(bool verbose, bool use_stdout, Error &error)
if (verbose)
SetLogThreshold(LogLevel::DEBUG);
else if ((param = config_get_param(CONF_LOG_LEVEL)) != nullptr)
else if ((param = config_get_param(ConfigOption::LOG_LEVEL)) != nullptr)
SetLogThreshold(parse_log_level(param->value.c_str(),
param->line));
if (use_stdout) {
return true;
} else {
param = config_get_param(CONF_LOG_FILE);
param = config_get_param(ConfigOption::LOG_FILE);
if (param == nullptr) {
#ifdef HAVE_SYSLOG
/* no configuration: default to syslog (if
......@@ -164,7 +164,7 @@ log_init(bool verbose, bool use_stdout, Error &error)
return true;
#endif
} else {
out_path = config_get_path(CONF_LOG_FILE, error);
out_path = config_get_path(ConfigOption::LOG_FILE, error);
return !out_path.IsNull() &&
log_init_file(param->line, error);
}
......
......@@ -141,12 +141,12 @@ static StateFile *state_file;
static bool
glue_daemonize_init(const struct options *options, Error &error)
{
auto pid_file = config_get_path(CONF_PID_FILE, error);
auto pid_file = config_get_path(ConfigOption::PID_FILE, error);
if (pid_file.IsNull() && error.IsDefined())
return false;
daemonize_init(config_get_string(CONF_USER, nullptr),
config_get_string(CONF_GROUP, nullptr),
daemonize_init(config_get_string(ConfigOption::USER, nullptr),
config_get_string(ConfigOption::GROUP, nullptr),
std::move(pid_file));
if (options->kill)
......@@ -160,7 +160,7 @@ glue_daemonize_init(const struct options *options, Error &error)
static bool
glue_mapper_init(Error &error)
{
auto playlist_dir = config_get_path(CONF_PLAYLIST_DIR, error);
auto playlist_dir = config_get_path(ConfigOption::PLAYLIST_DIR, error);
if (playlist_dir.IsNull() && error.IsDefined())
return false;
......@@ -255,7 +255,7 @@ glue_sticker_init(void)
{
#ifdef ENABLE_SQLITE
Error error;
auto sticker_file = config_get_path(CONF_STICKER_FILE, error);
auto sticker_file = config_get_path(ConfigOption::STICKER_FILE, error);
if (sticker_file.IsNull()) {
if (error.IsDefined())
FatalError(error);
......@@ -270,7 +270,7 @@ glue_sticker_init(void)
static bool
glue_state_file_init(Error &error)
{
auto path_fs = config_get_path(CONF_STATE_FILE, error);
auto path_fs = config_get_path(ConfigOption::STATE_FILE, error);
if (path_fs.IsNull()) {
if (error.IsDefined())
return false;
......@@ -286,8 +286,9 @@ glue_state_file_init(Error &error)
#endif
}
unsigned interval = config_get_unsigned(CONF_STATE_FILE_INTERVAL,
StateFile::DEFAULT_INTERVAL);
const unsigned interval =
config_get_unsigned(ConfigOption::STATE_FILE_INTERVAL,
StateFile::DEFAULT_INTERVAL);
state_file = new StateFile(std::move(path_fs), interval,
*instance->partition,
......@@ -324,7 +325,7 @@ initialize_decoder_and_player(void)
const struct config_param *param;
size_t buffer_size;
param = config_get_param(CONF_AUDIO_BUFFER_SIZE);
param = config_get_param(ConfigOption::AUDIO_BUFFER_SIZE);
if (param != nullptr) {
char *test;
long tmp = strtol(param->value.c_str(), &test, 10);
......@@ -345,7 +346,7 @@ initialize_decoder_and_player(void)
(unsigned long)buffer_size);
float perc;
param = config_get_param(CONF_BUFFER_BEFORE_PLAY);
param = config_get_param(ConfigOption::BUFFER_BEFORE_PLAY);
if (param != nullptr) {
char *test;
perc = strtod(param->value.c_str(), &test);
......@@ -363,7 +364,7 @@ initialize_decoder_and_player(void)
buffered_before_play = buffered_chunks;
const unsigned max_length =
config_get_positive(CONF_MAX_PLAYLIST_LENGTH,
config_get_positive(ConfigOption::MAX_PLAYLIST_LENGTH,
DEFAULT_PLAYLIST_MAX_LENGTH);
instance->partition = new Partition(*instance,
......@@ -503,7 +504,8 @@ int mpd_main(int argc, char *argv[])
}
#endif
const unsigned max_clients = config_get_positive(CONF_MAX_CONN, 10);
const unsigned max_clients =
config_get_positive(ConfigOption::MAX_CONN, 10);
instance->client_list = new ClientList(max_clients);
initialize_decoder_and_player();
......@@ -630,14 +632,14 @@ static int mpd_main_after_fork(struct options options)
instance->partition->outputs.SetReplayGainMode(replay_gain_get_real_mode(instance->partition->playlist.queue.random));
#ifdef ENABLE_DATABASE
if (config_get_bool(CONF_AUTO_UPDATE, false)) {
if (config_get_bool(ConfigOption::AUTO_UPDATE, false)) {
#ifdef ENABLE_INOTIFY
if (instance->storage != nullptr &&
instance->update != nullptr)
mpd_inotify_init(*instance->event_loop,
*instance->storage,
*instance->update,
config_get_unsigned(CONF_AUTO_UPDATE_DEPTH,
config_get_unsigned(ConfigOption::AUTO_UPDATE_DEPTH,
INT_MAX));
#else
FormatWarning(main_domain,
......
......@@ -92,7 +92,7 @@ void initPermissions(void)
permission_default = PERMISSION_READ | PERMISSION_ADD |
PERMISSION_CONTROL | PERMISSION_ADMIN;
param = config_get_param(CONF_PASSWORD);
param = config_get_param(ConfigOption::PASSWORD);
if (param) {
permission_default = 0;
......@@ -118,7 +118,7 @@ void initPermissions(void)
} while ((param = param->next) != nullptr);
}
param = config_get_param(CONF_DEFAULT_PERMS);
param = config_get_param(ConfigOption::DEFAULT_PERMS);
if (param)
permission_default = parsePermissions(param->value.c_str());
......
......@@ -53,11 +53,12 @@ bool playlist_saveAbsolutePaths = DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS;
void
spl_global_init(void)
{
playlist_max_length = config_get_positive(CONF_MAX_PLAYLIST_LENGTH,
DEFAULT_PLAYLIST_MAX_LENGTH);
playlist_max_length =
config_get_positive(ConfigOption::MAX_PLAYLIST_LENGTH,
DEFAULT_PLAYLIST_MAX_LENGTH);
playlist_saveAbsolutePaths =
config_get_bool(CONF_SAVE_ABSOLUTE_PATHS,
config_get_bool(ConfigOption::SAVE_ABSOLUTE_PATHS,
DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS);
}
......
......@@ -81,7 +81,8 @@ replay_gain_set_mode_string(const char *p)
void replay_gain_global_init(void)
{
const struct config_param *param = config_get_param(CONF_REPLAYGAIN);
const struct config_param *param =
config_get_param(ConfigOption::REPLAYGAIN);
if (param != nullptr &&
!replay_gain_set_mode_string(param->value.c_str())) {
......@@ -89,7 +90,7 @@ void replay_gain_global_init(void)
param->value.c_str(), param->line);
}
param = config_get_param(CONF_REPLAYGAIN_PREAMP);
param = config_get_param(ConfigOption::REPLAYGAIN_PREAMP);
if (param) {
char *test;
......@@ -110,7 +111,7 @@ void replay_gain_global_init(void)
replay_gain_preamp = pow(10, f / 20.0);
}
param = config_get_param(CONF_REPLAYGAIN_MISSING_PREAMP);
param = config_get_param(ConfigOption::REPLAYGAIN_MISSING_PREAMP);
if (param) {
char *test;
......@@ -131,7 +132,8 @@ void replay_gain_global_init(void)
replay_gain_missing_preamp = pow(10, f / 20.0);
}
replay_gain_limit = config_get_bool(CONF_REPLAYGAIN_LIMIT, DEFAULT_REPLAYGAIN_LIMIT);
replay_gain_limit = config_get_bool(ConfigOption::REPLAYGAIN_LIMIT,
DEFAULT_REPLAYGAIN_LIMIT);
}
ReplayGainMode
......
......@@ -31,15 +31,15 @@ size_t client_max_output_buffer_size;
void client_manager_init(void)
{
client_timeout = config_get_positive(CONF_CONN_TIMEOUT,
client_timeout = config_get_positive(ConfigOption::CONN_TIMEOUT,
CLIENT_TIMEOUT_DEFAULT);
client_max_command_list_size =
config_get_positive(CONF_MAX_COMMAND_LIST_SIZE,
config_get_positive(ConfigOption::MAX_COMMAND_LIST_SIZE,
CLIENT_MAX_COMMAND_LIST_DEFAULT / 1024)
* 1024;
client_max_output_buffer_size =
config_get_positive(CONF_MAX_OUTPUT_BUFFER_SIZE,
config_get_positive(ConfigOption::MAX_OUTPUT_BUFFER_SIZE,
CLIENT_MAX_OUTPUT_BUFFER_SIZE_DEFAULT / 1024)
* 1024;
}
......@@ -175,7 +175,7 @@ ReadConfigFile(ConfigData &config_data, FILE *fp, Error &error)
"repeatable" flag */
const ConfigOption o = ParseConfigOptionName(name);
if (o == CONF_MAX) {
if (o == ConfigOption::MAX) {
error.Format(config_file_domain,
"unrecognized parameter in config file at "
"line %i: %s\n", count, name);
......
......@@ -22,68 +22,78 @@
#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_STATE_FILE_INTERVAL,
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_NEIGHBORS,
CONF_MAX
#if defined(WIN32) && CLANG_OR_GCC_VERSION(4,7)
/* "INPUT" is declared by winuser.h */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#endif
enum class ConfigOption {
MUSIC_DIR,
PLAYLIST_DIR,
FOLLOW_INSIDE_SYMLINKS,
FOLLOW_OUTSIDE_SYMLINKS,
DB_FILE,
STICKER_FILE,
LOG_FILE,
PID_FILE,
STATE_FILE,
STATE_FILE_INTERVAL,
RESTORE_PAUSED,
USER,
GROUP,
BIND_TO_ADDRESS,
PORT,
LOG_LEVEL,
ZEROCONF_NAME,
ZEROCONF_ENABLED,
PASSWORD,
DEFAULT_PERMS,
AUDIO_OUTPUT,
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,
CONN_TIMEOUT,
MAX_CONN,
MAX_PLAYLIST_LENGTH,
MAX_COMMAND_LIST_SIZE,
MAX_OUTPUT_BUFFER_SIZE,
FS_CHARSET,
ID3V1_ENCODING,
METADATA_TO_USE,
SAVE_ABSOLUTE_PATHS,
DECODER,
INPUT,
GAPLESS_MP3_PLAYBACK,
PLAYLIST_PLUGIN,
AUTO_UPDATE,
AUTO_UPDATE_DEPTH,
DESPOTIFY_USER,
DESPOTIFY_PASSWORD,
DESPOTIFY_HIGH_BITRATE,
AUDIO_FILTER,
DATABASE,
NEIGHBORS,
MAX
};
#if defined(WIN32) && CLANG_OR_GCC_VERSION(4,7)
#pragma GCC diagnostic pop
#endif
/**
* @return #CONF_MAX if not found
* @return #ConfigOption::MAX if not found
*/
gcc_pure
enum ConfigOption
......
......@@ -70,7 +70,7 @@ GetHome(Error &error)
static AllocatedPath
GetConfiguredHome(Error &error)
{
const char *user = config_get_string(CONF_USER, nullptr);
const char *user = config_get_string(ConfigOption::USER, nullptr);
return user != nullptr
? GetHome(user, error)
: GetHome(error);
......
......@@ -84,7 +84,7 @@ const ConfigTemplate config_templates[] = {
static constexpr unsigned n_config_templates = ARRAY_SIZE(config_templates);
static_assert(n_config_templates == unsigned(CONF_MAX),
static_assert(n_config_templates == unsigned(ConfigOption::MAX),
"Wrong number of config_templates");
ConfigOption
......@@ -94,5 +94,5 @@ ParseConfigOptionName(const char *name)
if (strcmp(config_templates[i].name, name) == 0)
return ConfigOption(i);
return CONF_MAX;
return ConfigOption::MAX;
}
......@@ -27,7 +27,7 @@
struct config_param;
struct ConfigData {
std::array<config_param *, std::size_t(CONF_MAX)> params;
std::array<config_param *, std::size_t(ConfigOption::MAX)> params;
void Clear();
};
......
......@@ -32,8 +32,8 @@ Database *
CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener,
Error &error)
{
const struct config_param *param = config_get_param(CONF_DATABASE);
const struct config_param *path = config_get_param(CONF_DB_FILE);
const auto *param = config_get_param(ConfigOption::DATABASE);
const auto *path = config_get_param(ConfigOption::DB_FILE);
if (param != nullptr && path != nullptr) {
error.Format(config_domain,
......
......@@ -57,11 +57,11 @@ UpdateWalk::UpdateWalk(EventLoop &_loop, DatabaseListener &_listener,
{
#ifndef WIN32
follow_inside_symlinks =
config_get_bool(CONF_FOLLOW_INSIDE_SYMLINKS,
config_get_bool(ConfigOption::FOLLOW_INSIDE_SYMLINKS,
DEFAULT_FOLLOW_INSIDE_SYMLINKS);
follow_outside_symlinks =
config_get_bool(CONF_FOLLOW_OUTSIDE_SYMLINKS,
config_get_bool(ConfigOption::FOLLOW_OUTSIDE_SYMLINKS,
DEFAULT_FOLLOW_OUTSIDE_SYMLINKS);
#endif
}
......
......@@ -132,7 +132,8 @@ void decoder_plugin_init_all(void)
for (unsigned i = 0; decoder_plugins[i] != nullptr; ++i) {
const DecoderPlugin &plugin = *decoder_plugins[i];
const struct config_param *param =
config_find_block(CONF_DECODER, "plugin", plugin.name);
config_find_block(ConfigOption::DECODER, "plugin",
plugin.name);
if (param == nullptr)
param = &empty;
......
......@@ -109,7 +109,7 @@ mad_fixed_to_24_buffer(int32_t *dest, const struct mad_synth *synth,
static bool
mp3_plugin_init(gcc_unused const config_param &param)
{
gapless_playback = config_get_bool(CONF_GAPLESS_MP3_PLAYBACK,
gapless_playback = config_get_bool(ConfigOption::GAPLESS_MP3_PLAYBACK,
DEFAULT_GAPLESS_MP3_PLAYBACK);
return true;
}
......
......@@ -35,7 +35,8 @@ static bool
filter_chain_append_new(Filter &chain, const char *template_name, Error &error)
{
const struct config_param *cfg =
config_find_block(CONF_AUDIO_FILTER, "name", template_name);
config_find_block(ConfigOption::AUDIO_FILTER, "name",
template_name);
if (cfg == nullptr) {
error.Format(config_domain,
"filter template not found: %s",
......
......@@ -35,7 +35,7 @@ ConfigureFS(Error &error)
#ifdef HAVE_FS_CHARSET
const char *charset = nullptr;
charset = config_get_string(CONF_FS_CHARSET, nullptr);
charset = config_get_string(ConfigOption::FS_CHARSET, nullptr);
if (charset == nullptr) {
#ifdef WIN32
/* Glib claims that file system encoding is always utf-8
......
......@@ -43,7 +43,8 @@ input_stream_global_init(Error &error)
assert(plugin->open != nullptr);
const struct config_param *param =
config_find_block(CONF_INPUT, "plugin", plugin->name);
config_find_block(ConfigOption::INPUT, "plugin",
plugin->name);
if (param == nullptr) {
param = &empty;
} else if (!param->GetBlockValue("enabled", true))
......
......@@ -564,10 +564,10 @@ input_curl_init(const config_param &param, Error &error)
if (proxy == nullptr) {
/* deprecated proxy configuration */
proxy = config_get_string(CONF_HTTP_PROXY_HOST, nullptr);
proxy_port = config_get_positive(CONF_HTTP_PROXY_PORT, 0);
proxy_user = config_get_string(CONF_HTTP_PROXY_USER, nullptr);
proxy_password = config_get_string(CONF_HTTP_PROXY_PASSWORD,
proxy = config_get_string(ConfigOption::HTTP_PROXY_HOST, nullptr);
proxy_port = config_get_positive(ConfigOption::HTTP_PROXY_PORT, 0);
proxy_user = config_get_string(ConfigOption::HTTP_PROXY_USER, nullptr);
proxy_password = config_get_string(ConfigOption::HTTP_PROXY_PASSWORD,
"");
}
......
......@@ -124,9 +124,9 @@ mpd_despotify_get_session()
return g_session;
const char *const user =
config_get_string(CONF_DESPOTIFY_USER, nullptr);
config_get_string(ConfigOption::DESPOTIFY_USER, nullptr);
const char *const passwd =
config_get_string(CONF_DESPOTIFY_PASSWORD, nullptr);
config_get_string(ConfigOption::DESPOTIFY_PASSWORD, nullptr);
if (user == nullptr || passwd == nullptr) {
LogDebug(despotify_domain,
......@@ -140,7 +140,7 @@ mpd_despotify_get_session()
}
const bool high_bitrate =
config_get_bool(CONF_DESPOTIFY_HIGH_BITRATE, true);
config_get_bool(ConfigOption::DESPOTIFY_HIGH_BITRATE, true);
g_session = despotify_init_client(callback, nullptr,
high_bitrate, true);
if (!g_session) {
......
......@@ -59,7 +59,7 @@ CreateNeighborExplorer(EventLoop &loop, NeighborListener &listener,
bool
NeighborGlue::Init(EventLoop &loop, NeighborListener &listener, Error &error)
{
for (const config_param *param = config_get_param(CONF_NEIGHBORS);
for (const auto *param = config_get_param(ConfigOption::NEIGHBORS);
param != nullptr; param = param->next) {
NeighborExplorer *explorer =
CreateNeighborExplorer(loop, listener, *param, error);
......
......@@ -108,7 +108,7 @@ audio_output_mixer_type(const config_param &param)
/* fall back to the global "mixer_type" setting (also
deprecated) */
return mixer_type_parse(config_get_string(CONF_MIXER_TYPE,
return mixer_type_parse(config_get_string(ConfigOption::MIXER_TYPE,
"hardware"));
}
......@@ -191,7 +191,7 @@ AudioOutput::Configure(const config_param &param, Error &error)
/* create the normalization filter (if configured) */
if (config_get_bool(CONF_VOLUME_NORMALIZATION, false)) {
if (config_get_bool(ConfigOption::VOLUME_NORMALIZATION, false)) {
Filter *normalize_filter =
filter_new(&normalize_filter_plugin, config_param(),
IgnoreError());
......
......@@ -74,7 +74,7 @@ LoadOutput(EventLoop &event_loop, MixerListener &mixer_listener,
void
MultipleOutputs::Configure(EventLoop &event_loop, PlayerControl &pc)
{
for (const config_param *param = config_get_param(CONF_AUDIO_OUTPUT);
for (const auto *param = config_get_param(ConfigOption::AUDIO_OUTPUT);
param != nullptr; param = param->next) {
auto output = LoadOutput(event_loop, mixer_listener,
pc, *param);
......
......@@ -53,7 +53,7 @@ bool
pcm_resampler_global_init(Error &error)
{
const char *converter =
config_get_string(CONF_SAMPLERATE_CONVERTER, "");
config_get_string(ConfigOption::SAMPLERATE_CONVERTER, "");
if (strcmp(converter, "internal") == 0)
return true;
......
......@@ -81,9 +81,9 @@ playlist_list_global_init(void)
for (unsigned i = 0; playlist_plugins[i] != nullptr; ++i) {
const struct playlist_plugin *plugin = playlist_plugins[i];
const struct config_param *param =
config_find_block(CONF_PLAYLIST_PLUGIN, "name",
plugin->name);
const auto *param =
config_find_block(ConfigOption::PLAYLIST_PLUGIN,
"name", plugin->name);
if (param == nullptr)
param = &empty;
else if (!param->GetBlockValue("enabled", true))
......
......@@ -195,7 +195,7 @@ playlist_state_restore(const char *line, TextFile &file,
current = 0;
if (state == PlayerState::PLAY &&
config_get_bool(CONF_RESTORE_PAUSED, false))
config_get_bool(ConfigOption::RESTORE_PAUSED, false))
/* the user doesn't want MPD to auto-start
playback after startup; fall back to
"pause" */
......
......@@ -44,7 +44,7 @@ CreateConfiguredStorageUri(EventLoop &event_loop, const char *uri,
static AllocatedPath
GetConfiguredMusicDirectory(Error &error)
{
AllocatedPath path = config_get_path(CONF_MUSIC_DIR, error);
AllocatedPath path = config_get_path(ConfigOption::MUSIC_DIR, error);
if (path.IsNull() && !error.IsDefined())
path = GetUserMusicDir();
......@@ -68,7 +68,7 @@ CreateConfiguredStorage(EventLoop &event_loop, Error &error)
{
assert(!error.IsDefined());
auto uri = config_get_string(CONF_MUSIC_DIR, nullptr);
auto uri = config_get_string(ConfigOption::MUSIC_DIR, nullptr);
if (uri != nullptr && uri_has_scheme(uri))
return CreateConfiguredStorageUri(event_loop, uri, error);
......@@ -78,5 +78,5 @@ CreateConfiguredStorage(EventLoop &event_loop, Error &error)
bool
IsStorageConfigured()
{
return config_get_string(CONF_MUSIC_DIR, nullptr) != nullptr;
return config_get_string(ConfigOption::MUSIC_DIR, nullptr) != nullptr;
}
......@@ -35,7 +35,8 @@
void
TagLoadConfig()
{
const char *value = config_get_string(CONF_METADATA_TO_USE, nullptr);
const char *value = config_get_string(ConfigOption::METADATA_TO_USE,
nullptr);
if (value == nullptr)
return;
......
......@@ -99,7 +99,8 @@ import_id3_string(bool is_id3v1, const id3_ucs4_t *ucs4)
/* use encoding field here? */
const char *encoding;
if (is_id3v1 &&
(encoding = config_get_string(CONF_ID3V1_ENCODING, nullptr)) != nullptr) {
(encoding = config_get_string(ConfigOption::ID3V1_ENCODING,
nullptr)) != nullptr) {
id3_latin1_t *isostr = id3_ucs4_latin1duplicate(ucs4);
if (gcc_unlikely(isostr == nullptr))
return nullptr;
......
......@@ -44,7 +44,7 @@ ZeroconfInit(gcc_unused EventLoop &loop)
{
const char *serviceName;
zeroconfEnabled = config_get_bool(CONF_ZEROCONF_ENABLED,
zeroconfEnabled = config_get_bool(ConfigOption::ZEROCONF_ENABLED,
DEFAULT_ZEROCONF_ENABLED);
if (!zeroconfEnabled)
return;
......@@ -56,7 +56,8 @@ ZeroconfInit(gcc_unused EventLoop &loop)
return;
}
serviceName = config_get_string(CONF_ZEROCONF_NAME, SERVICE_NAME);
serviceName = config_get_string(ConfigOption::ZEROCONF_NAME,
SERVICE_NAME);
#ifdef HAVE_AVAHI
AvahiInit(loop, serviceName);
......
......@@ -120,7 +120,7 @@ main(int argc, char **argv)
/* do it */
const struct config_param *path = config_get_param(CONF_DB_FILE);
const auto *path = config_get_param(ConfigOption::DB_FILE);
config_param param("database", path != nullptr ? path->line : -1);
if (path != nullptr)
param.AddBlockParam("path", path->value.c_str(), path->line);
......
......@@ -46,7 +46,7 @@ int main(int argc, char **argv)
}
ConfigOption option = ParseConfigOptionName(name);
const char *value = option != CONF_MAX
const char *value = option != ConfigOption::MAX
? config_get_string(option, nullptr)
: nullptr;
int ret;
......
......@@ -51,7 +51,7 @@ static Filter *
load_filter(const char *name)
{
const config_param *param =
config_find_block(CONF_AUDIO_FILTER, "name", name);
config_find_block(ConfigOption::AUDIO_FILTER, "name", name);
if (param == NULL) {
fprintf(stderr, "No such configured filter: %s\n", name);
return nullptr;
......
......@@ -62,7 +62,7 @@ static AudioOutput *
load_audio_output(EventLoop &event_loop, const char *name)
{
const config_param *param =
config_find_block(CONF_AUDIO_OUTPUT, "name", name);
config_find_block(ConfigOption::AUDIO_OUTPUT, "name", name);
if (param == NULL) {
fprintf(stderr, "No such configured audio output: %s\n", name);
return nullptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment