ConfigGlobal: eliminate function config_get_next_param()
This commit is contained in:
parent
9e0ce23a03
commit
008723c62f
@ -105,7 +105,7 @@ listen_global_init(EventLoop &loop, Partition &partition, Error &error)
|
|||||||
{
|
{
|
||||||
int port = config_get_positive(CONF_PORT, DEFAULT_PORT);
|
int port = config_get_positive(CONF_PORT, DEFAULT_PORT);
|
||||||
const struct config_param *param =
|
const struct config_param *param =
|
||||||
config_get_next_param(CONF_BIND_TO_ADDRESS, nullptr);
|
config_get_param(CONF_BIND_TO_ADDRESS);
|
||||||
|
|
||||||
listen_socket = new ClientListener(loop, partition);
|
listen_socket = new ClientListener(loop, partition);
|
||||||
|
|
||||||
@ -129,10 +129,7 @@ listen_global_init(EventLoop &loop, Partition &partition, Error &error)
|
|||||||
param->line);
|
param->line);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} while ((param = param->next) != nullptr);
|
||||||
param = config_get_next_param(CONF_BIND_TO_ADDRESS,
|
|
||||||
param);
|
|
||||||
} while (param != nullptr);
|
|
||||||
} else {
|
} else {
|
||||||
/* no "bind_to_address" configured, bind the
|
/* no "bind_to_address" configured, bind the
|
||||||
configured port on all interfaces */
|
configured port on all interfaces */
|
||||||
|
@ -92,7 +92,7 @@ void initPermissions(void)
|
|||||||
permission_default = PERMISSION_READ | PERMISSION_ADD |
|
permission_default = PERMISSION_READ | PERMISSION_ADD |
|
||||||
PERMISSION_CONTROL | PERMISSION_ADMIN;
|
PERMISSION_CONTROL | PERMISSION_ADMIN;
|
||||||
|
|
||||||
param = config_get_next_param(CONF_PASSWORD, NULL);
|
param = config_get_param(CONF_PASSWORD);
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
permission_default = 0;
|
permission_default = 0;
|
||||||
@ -115,7 +115,7 @@ void initPermissions(void)
|
|||||||
|
|
||||||
permission_passwords.insert(std::make_pair(std::move(password),
|
permission_passwords.insert(std::make_pair(std::move(password),
|
||||||
permission));
|
permission));
|
||||||
} while ((param = config_get_next_param(CONF_PASSWORD, param)));
|
} while ((param = param->next) != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
param = config_get_param(CONF_DEFAULT_PERMS);
|
param = config_get_param(CONF_DEFAULT_PERMS);
|
||||||
|
@ -74,12 +74,10 @@ void config_global_check(void)
|
|||||||
Check(p);
|
Check(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct config_param *
|
const config_param *
|
||||||
config_get_next_param(ConfigOption option, const struct config_param * last)
|
config_get_param(ConfigOption option)
|
||||||
{
|
{
|
||||||
config_param *param = last != nullptr
|
config_param *param = config_data.params[unsigned(option)];
|
||||||
? last->next
|
|
||||||
: config_data.params[unsigned(option)];
|
|
||||||
if (param != nullptr)
|
if (param != nullptr)
|
||||||
param->used = true;
|
param->used = true;
|
||||||
return param;
|
return param;
|
||||||
@ -88,8 +86,8 @@ config_get_next_param(ConfigOption option, const struct config_param * last)
|
|||||||
const config_param *
|
const config_param *
|
||||||
config_find_block(ConfigOption option, const char *key, const char *value)
|
config_find_block(ConfigOption option, const char *key, const char *value)
|
||||||
{
|
{
|
||||||
const config_param *param = nullptr;
|
for (const config_param *param = config_get_param(option);
|
||||||
while ((param = config_get_next_param(option, param)) != nullptr) {
|
param != nullptr; param = param->next) {
|
||||||
const char *value2 = param->GetBlockValue(key);
|
const char *value2 = param->GetBlockValue(key);
|
||||||
if (value2 == nullptr)
|
if (value2 == nullptr)
|
||||||
FormatFatalError("block without '%s' name in line %d",
|
FormatFatalError("block without '%s' name in line %d",
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
class Error;
|
class Error;
|
||||||
class Path;
|
class Path;
|
||||||
class AllocatedPath;
|
class AllocatedPath;
|
||||||
|
struct config_param;
|
||||||
|
|
||||||
void config_global_init(void);
|
void config_global_init(void);
|
||||||
void config_global_finish(void);
|
void config_global_finish(void);
|
||||||
@ -39,19 +40,9 @@ void config_global_check(void);
|
|||||||
bool
|
bool
|
||||||
ReadConfigFile(Path path, Error &error);
|
ReadConfigFile(Path path, Error &error);
|
||||||
|
|
||||||
/* don't free the returned value
|
|
||||||
set _last_ to nullptr to get first entry */
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
const struct config_param *
|
const config_param *
|
||||||
config_get_next_param(enum ConfigOption option,
|
config_get_param(enum ConfigOption option);
|
||||||
const struct config_param *last);
|
|
||||||
|
|
||||||
gcc_pure
|
|
||||||
static inline const struct config_param *
|
|
||||||
config_get_param(enum ConfigOption option)
|
|
||||||
{
|
|
||||||
return config_get_next_param(option, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a block with a matching attribute.
|
* Find a block with a matching attribute.
|
||||||
|
@ -59,8 +59,8 @@ CreateNeighborExplorer(EventLoop &loop, NeighborListener &listener,
|
|||||||
bool
|
bool
|
||||||
NeighborGlue::Init(EventLoop &loop, NeighborListener &listener, Error &error)
|
NeighborGlue::Init(EventLoop &loop, NeighborListener &listener, Error &error)
|
||||||
{
|
{
|
||||||
const config_param *param = nullptr;
|
for (const config_param *param = config_get_param(CONF_NEIGHBORS);
|
||||||
while ((param = config_get_next_param(CONF_NEIGHBORS, param))) {
|
param != nullptr; param = param->next) {
|
||||||
NeighborExplorer *explorer =
|
NeighborExplorer *explorer =
|
||||||
CreateNeighborExplorer(loop, listener, *param, error);
|
CreateNeighborExplorer(loop, listener, *param, error);
|
||||||
if (explorer == nullptr) {
|
if (explorer == nullptr) {
|
||||||
|
@ -73,9 +73,8 @@ LoadOutput(EventLoop &event_loop, MixerListener &mixer_listener,
|
|||||||
void
|
void
|
||||||
MultipleOutputs::Configure(EventLoop &event_loop, PlayerControl &pc)
|
MultipleOutputs::Configure(EventLoop &event_loop, PlayerControl &pc)
|
||||||
{
|
{
|
||||||
const config_param *param = nullptr;
|
for (const config_param *param = config_get_param(CONF_AUDIO_OUTPUT);
|
||||||
while ((param = config_get_next_param(CONF_AUDIO_OUTPUT,
|
param != nullptr; param = param->next) {
|
||||||
param)) != nullptr) {
|
|
||||||
auto output = LoadOutput(event_loop, mixer_listener,
|
auto output = LoadOutput(event_loop, mixer_listener,
|
||||||
pc, *param);
|
pc, *param);
|
||||||
if (FindByName(output->name) != nullptr)
|
if (FindByName(output->name) != nullptr)
|
||||||
|
Loading…
Reference in New Issue
Block a user