Commit 5b2b4bf1 authored by Max Kellermann's avatar Max Kellermann

config/Param: use CamelCase

parent 4bd67bc2
...@@ -39,7 +39,7 @@ getOutputAudioFormat(AudioFormat inAudioFormat) ...@@ -39,7 +39,7 @@ getOutputAudioFormat(AudioFormat inAudioFormat)
void initAudioConfig(void) void initAudioConfig(void)
{ {
const struct config_param *param = config_get_param(ConfigOption::AUDIO_OUTPUT_FORMAT); const auto *param = config_get_param(ConfigOption::AUDIO_OUTPUT_FORMAT);
if (param == nullptr) if (param == nullptr)
return; return;
......
...@@ -60,7 +60,7 @@ int listen_port; ...@@ -60,7 +60,7 @@ int listen_port;
static bool static bool
listen_add_config_param(unsigned int port, listen_add_config_param(unsigned int port,
const struct config_param *param, const ConfigParam *param,
Error &error_r) Error &error_r)
{ {
assert(param != nullptr); assert(param != nullptr);
...@@ -104,8 +104,7 @@ bool ...@@ -104,8 +104,7 @@ bool
listen_global_init(EventLoop &loop, Partition &partition, Error &error) listen_global_init(EventLoop &loop, Partition &partition, Error &error)
{ {
int port = config_get_positive(ConfigOption::PORT, DEFAULT_PORT); int port = config_get_positive(ConfigOption::PORT, DEFAULT_PORT);
const struct config_param *param = const auto *param = config_get_param(ConfigOption::BIND_TO_ADDRESS);
config_get_param(ConfigOption::BIND_TO_ADDRESS);
listen_socket = new ClientListener(loop, partition); listen_socket = new ClientListener(loop, partition);
......
...@@ -124,18 +124,16 @@ log_init(bool verbose, bool use_stdout, Error &error) ...@@ -124,18 +124,16 @@ log_init(bool verbose, bool use_stdout, Error &error)
return true; return true;
#else #else
const struct config_param *param;
if (verbose) if (verbose)
SetLogThreshold(LogLevel::DEBUG); SetLogThreshold(LogLevel::DEBUG);
else if ((param = config_get_param(ConfigOption::LOG_LEVEL)) != nullptr) else if (const auto &param = config_get_param(ConfigOption::LOG_LEVEL))
SetLogThreshold(parse_log_level(param->value.c_str(), SetLogThreshold(parse_log_level(param->value.c_str(),
param->line)); param->line));
if (use_stdout) { if (use_stdout) {
return true; return true;
} else { } else {
param = config_get_param(ConfigOption::LOG_FILE); const auto *param = config_get_param(ConfigOption::LOG_FILE);
if (param == nullptr) { if (param == nullptr) {
#ifdef HAVE_SYSLOG #ifdef HAVE_SYSLOG
/* no configuration: default to syslog (if /* no configuration: default to syslog (if
......
...@@ -307,7 +307,7 @@ static void winsock_init(void) ...@@ -307,7 +307,7 @@ static void winsock_init(void)
static void static void
initialize_decoder_and_player(void) initialize_decoder_and_player(void)
{ {
const struct config_param *param; const ConfigParam *param;
size_t buffer_size; size_t buffer_size;
param = config_get_param(ConfigOption::AUDIO_BUFFER_SIZE); param = config_get_param(ConfigOption::AUDIO_BUFFER_SIZE);
......
...@@ -87,7 +87,7 @@ static unsigned parsePermissions(const char *string) ...@@ -87,7 +87,7 @@ static unsigned parsePermissions(const char *string)
void initPermissions(void) void initPermissions(void)
{ {
unsigned permission; unsigned permission;
const struct config_param *param; const ConfigParam *param;
permission_default = PERMISSION_READ | PERMISSION_ADD | permission_default = PERMISSION_READ | PERMISSION_ADD |
PERMISSION_CONTROL | PERMISSION_ADMIN; PERMISSION_CONTROL | PERMISSION_ADMIN;
......
...@@ -78,8 +78,7 @@ replay_gain_set_mode_string(const char *p) ...@@ -78,8 +78,7 @@ replay_gain_set_mode_string(const char *p)
void replay_gain_global_init(void) void replay_gain_global_init(void)
{ {
const struct config_param *param = const auto *param = config_get_param(ConfigOption::REPLAYGAIN);
config_get_param(ConfigOption::REPLAYGAIN);
if (param != nullptr && if (param != nullptr &&
!replay_gain_set_mode_string(param->value.c_str())) { !replay_gain_set_mode_string(param->value.c_str())) {
......
...@@ -145,11 +145,11 @@ ReadConfigBlock(ConfigData &config_data, BufferedReader &reader, ...@@ -145,11 +145,11 @@ ReadConfigBlock(ConfigData &config_data, BufferedReader &reader,
gcc_nonnull_all gcc_nonnull_all
static void static void
Append(config_param *&head, config_param *p) Append(ConfigParam *&head, ConfigParam *p)
{ {
assert(p->next == nullptr); assert(p->next == nullptr);
config_param **i = &head; auto **i = &head;
while (*i != nullptr) while (*i != nullptr)
i = &(*i)->next; i = &(*i)->next;
...@@ -163,10 +163,10 @@ ReadConfigParam(ConfigData &config_data, BufferedReader &reader, ...@@ -163,10 +163,10 @@ ReadConfigParam(ConfigData &config_data, BufferedReader &reader,
{ {
const unsigned i = unsigned(o); const unsigned i = unsigned(o);
const ConfigTemplate &option = config_param_templates[i]; const ConfigTemplate &option = config_param_templates[i];
config_param *&head = config_data.params[i]; auto *&head = config_data.params[i];
if (head != nullptr && !option.repeatable) { if (head != nullptr && !option.repeatable) {
struct config_param *param = head; auto *param = head;
throw FormatRuntimeError("config parameter \"%s\" is first defined " throw FormatRuntimeError("config parameter \"%s\" is first defined "
"on line %d and redefined on line %u\n", "on line %d and redefined on line %u\n",
name, param->line, name, param->line,
...@@ -184,7 +184,7 @@ ReadConfigParam(ConfigData &config_data, BufferedReader &reader, ...@@ -184,7 +184,7 @@ ReadConfigParam(ConfigData &config_data, BufferedReader &reader,
throw FormatRuntimeError("line %u: Unknown tokens after value", throw FormatRuntimeError("line %u: Unknown tokens after value",
reader.GetLineNumber()); reader.GetLineNumber());
auto *param = new config_param(value, reader.GetLineNumber()); auto *param = new ConfigParam(value, reader.GetLineNumber());
Append(head, param); Append(head, param);
} }
......
...@@ -75,10 +75,10 @@ void config_global_check(void) ...@@ -75,10 +75,10 @@ void config_global_check(void)
Check(*p); Check(*p);
} }
const config_param * const ConfigParam *
config_get_param(ConfigOption option) config_get_param(ConfigOption option)
{ {
config_param *param = config_data.params[unsigned(option)]; auto *param = config_data.params[unsigned(option)];
if (param != nullptr) if (param != nullptr)
param->used = true; param->used = true;
return param; return param;
...@@ -113,7 +113,7 @@ config_find_block(ConfigBlockOption option, const char *key, const char *value) ...@@ -113,7 +113,7 @@ config_find_block(ConfigBlockOption option, const char *key, const char *value)
const char * const char *
config_get_string(ConfigOption option, const char *default_value) config_get_string(ConfigOption option, const char *default_value)
{ {
const struct config_param *param = config_get_param(option); const auto *param = config_get_param(option);
if (param == nullptr) if (param == nullptr)
return default_value; return default_value;
...@@ -124,7 +124,7 @@ config_get_string(ConfigOption option, const char *default_value) ...@@ -124,7 +124,7 @@ config_get_string(ConfigOption option, const char *default_value)
AllocatedPath AllocatedPath
config_get_path(ConfigOption option, Error &error) config_get_path(ConfigOption option, Error &error)
{ {
const struct config_param *param = config_get_param(option); const auto *param = config_get_param(option);
if (param == nullptr) if (param == nullptr)
return AllocatedPath::Null(); return AllocatedPath::Null();
...@@ -132,7 +132,7 @@ config_get_path(ConfigOption option, Error &error) ...@@ -132,7 +132,7 @@ config_get_path(ConfigOption option, Error &error)
} }
AllocatedPath AllocatedPath
config_parse_path(const struct config_param *param, Error & error) config_parse_path(const ConfigParam *param, Error & error)
{ {
AllocatedPath path = ParsePath(param->value.c_str(), error); AllocatedPath path = ParsePath(param->value.c_str(), error);
if (gcc_unlikely(path.IsNull())) if (gcc_unlikely(path.IsNull()))
...@@ -145,7 +145,7 @@ config_parse_path(const struct config_param *param, Error & error) ...@@ -145,7 +145,7 @@ config_parse_path(const struct config_param *param, Error & error)
unsigned unsigned
config_get_unsigned(ConfigOption option, unsigned default_value) config_get_unsigned(ConfigOption option, unsigned default_value)
{ {
const struct config_param *param = config_get_param(option); const auto *param = config_get_param(option);
long value; long value;
char *endptr; char *endptr;
...@@ -163,7 +163,7 @@ config_get_unsigned(ConfigOption option, unsigned default_value) ...@@ -163,7 +163,7 @@ config_get_unsigned(ConfigOption option, unsigned default_value)
unsigned unsigned
config_get_positive(ConfigOption option, unsigned default_value) config_get_positive(ConfigOption option, unsigned default_value)
{ {
const struct config_param *param = config_get_param(option); const auto *param = config_get_param(option);
long value; long value;
char *endptr; char *endptr;
...@@ -184,7 +184,7 @@ config_get_positive(ConfigOption option, unsigned default_value) ...@@ -184,7 +184,7 @@ config_get_positive(ConfigOption option, unsigned default_value)
bool bool
config_get_bool(ConfigOption option, bool default_value) config_get_bool(ConfigOption option, bool default_value)
{ {
const struct config_param *param = config_get_param(option); const auto *param = config_get_param(option);
bool success, value; bool success, value;
if (param == nullptr) if (param == nullptr)
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
class Error; class Error;
class Path; class Path;
class AllocatedPath; class AllocatedPath;
struct config_param; struct ConfigParam;
struct ConfigBlock; struct ConfigBlock;
void void
...@@ -46,7 +46,7 @@ void ...@@ -46,7 +46,7 @@ void
ReadConfigFile(Path path); ReadConfigFile(Path path);
gcc_pure gcc_pure
const config_param * const ConfigParam *
config_get_param(enum ConfigOption option); config_get_param(enum ConfigOption option);
gcc_pure gcc_pure
...@@ -90,7 +90,7 @@ config_get_path(enum ConfigOption option, Error &error); ...@@ -90,7 +90,7 @@ config_get_path(enum ConfigOption option, Error &error);
* not be parsed, returns AllocatedPath::Null() and sets the error. * not be parsed, returns AllocatedPath::Null() and sets the error.
*/ */
AllocatedPath AllocatedPath
config_parse_path(const struct config_param *param, Error & error_r); config_parse_path(const ConfigParam *param, Error & error_r);
gcc_pure gcc_pure
unsigned unsigned
......
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
#include <array> #include <array>
struct config_param; struct ConfigParam;
struct ConfigBlock; struct ConfigBlock;
struct ConfigData { struct ConfigData {
std::array<config_param *, std::size_t(ConfigOption::MAX)> params; std::array<ConfigParam *, std::size_t(ConfigOption::MAX)> params;
std::array<ConfigBlock *, std::size_t(ConfigBlockOption::MAX)> blocks; std::array<ConfigBlock *, std::size_t(ConfigBlockOption::MAX)> blocks;
void Clear(); void Clear();
......
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
#include "config.h" #include "config.h"
#include "Param.hxx" #include "Param.hxx"
config_param::config_param(const char *_value, int _line) ConfigParam::ConfigParam(const char *_value, int _line)
:next(nullptr), value(_value), line(_line), used(false) {} :next(nullptr), value(_value), line(_line), used(false) {}
config_param::~config_param() ConfigParam::~ConfigParam()
{ {
delete next; delete next;
} }
...@@ -25,12 +25,12 @@ ...@@ -25,12 +25,12 @@
#include <string> #include <string>
struct config_param { struct ConfigParam {
/** /**
* The next config_param with the same name. The destructor * The next ConfigParam with the same name. The destructor
* deletes the whole chain. * deletes the whole chain.
*/ */
struct config_param *next; ConfigParam *next;
std::string value; std::string value;
...@@ -42,17 +42,17 @@ struct config_param { ...@@ -42,17 +42,17 @@ struct config_param {
*/ */
bool used; bool used;
explicit config_param(int _line=-1) explicit ConfigParam(int _line=-1)
:next(nullptr), line(_line), used(false) {} :next(nullptr), line(_line), used(false) {}
gcc_nonnull_all gcc_nonnull_all
config_param(const char *_value, int _line=-1); ConfigParam(const char *_value, int _line=-1);
config_param(const config_param &) = delete; ConfigParam(const ConfigParam &) = delete;
~config_param(); ~ConfigParam();
config_param &operator=(const config_param &) = delete; ConfigParam &operator=(const ConfigParam &) = delete;
/** /**
* Determine if this is a "null" instance, i.e. an empty * Determine if this is a "null" instance, i.e. an empty
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <forward_list> #include <forward_list>
struct config_param;
class EventLoop; class EventLoop;
class NeighborExplorer; class NeighborExplorer;
class NeighborListener; class NeighborListener;
......
...@@ -145,7 +145,7 @@ struct AudioOutputPlugin { ...@@ -145,7 +145,7 @@ struct AudioOutputPlugin {
/** /**
* The mixer plugin associated with this output plugin. This * The mixer plugin associated with this output plugin. This
* may be nullptr if no mixer plugin is implemented. When * may be nullptr if no mixer plugin is implemented. When
* created, this mixer plugin gets the same #config_param as * created, this mixer plugin gets the same #ConfigParam as
* this audio output device. * this audio output device.
*/ */
const MixerPlugin *mixer_plugin; const MixerPlugin *mixer_plugin;
......
...@@ -71,7 +71,7 @@ MakeResamplerDefaultConfig(ConfigBlock &block) ...@@ -71,7 +71,7 @@ MakeResamplerDefaultConfig(ConfigBlock &block)
* "resampler" block. * "resampler" block.
*/ */
static const ConfigBlock * static const ConfigBlock *
MigrateResamplerConfig(const config_param &param, ConfigBlock &block) MigrateResamplerConfig(const ConfigParam &param, ConfigBlock &block)
{ {
assert(block.IsEmpty()); assert(block.IsEmpty());
...@@ -102,7 +102,7 @@ MigrateResamplerConfig(const config_param &param, ConfigBlock &block) ...@@ -102,7 +102,7 @@ MigrateResamplerConfig(const config_param &param, ConfigBlock &block)
} }
static const ConfigBlock * static const ConfigBlock *
MigrateResamplerConfig(const config_param *param, ConfigBlock &buffer) MigrateResamplerConfig(const ConfigParam *param, ConfigBlock &buffer)
{ {
assert(buffer.IsEmpty()); assert(buffer.IsEmpty());
......
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