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

config/Param: use CamelCase

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