degesch: factor out get_aliases_config()
This commit is contained in:
parent
d39ffe440f
commit
0fd53af0d1
29
degesch.c
29
degesch.c
@ -1669,6 +1669,20 @@ get_config_boolean (struct config_item_ *root, const char *key)
|
|||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
static struct str_map *
|
||||||
|
get_servers_config (struct app_context *ctx)
|
||||||
|
{
|
||||||
|
return &config_item_get (ctx->config.root, "servers", NULL)->value.object;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct str_map *
|
||||||
|
get_aliases_config (struct app_context *ctx)
|
||||||
|
{
|
||||||
|
return &config_item_get (ctx->config.root, "aliases", NULL)->value.object;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
write_configuration_file (const struct str *data, struct error **e)
|
write_configuration_file (const struct str *data, struct error **e)
|
||||||
{
|
{
|
||||||
@ -6294,12 +6308,6 @@ dump_matching_options
|
|||||||
|
|
||||||
// --- Server management -------------------------------------------------------
|
// --- Server management -------------------------------------------------------
|
||||||
|
|
||||||
static struct str_map *
|
|
||||||
get_servers_config (struct app_context *ctx)
|
|
||||||
{
|
|
||||||
return &config_item_get (ctx->config.root, "servers", NULL)->value.object;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
validate_server_name (const char *name)
|
validate_server_name (const char *name)
|
||||||
{
|
{
|
||||||
@ -7684,10 +7692,8 @@ expand_alias_definition (const struct str *definition, const char *arguments)
|
|||||||
static char *
|
static char *
|
||||||
expand_alias (struct app_context *ctx, const char *alias_name, char *input)
|
expand_alias (struct app_context *ctx, const char *alias_name, char *input)
|
||||||
{
|
{
|
||||||
struct str_map *aliases =
|
struct config_item_ *entry =
|
||||||
&config_item_get (ctx->config.root, "aliases", NULL)->value.object;
|
str_map_find (get_aliases_config (ctx), alias_name);
|
||||||
|
|
||||||
struct config_item_ *entry = str_map_find (aliases, alias_name);
|
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -8612,8 +8618,7 @@ const char *g_default_aliases[][2] =
|
|||||||
static void
|
static void
|
||||||
load_default_aliases (struct app_context *ctx)
|
load_default_aliases (struct app_context *ctx)
|
||||||
{
|
{
|
||||||
struct str_map *aliases =
|
struct str_map *aliases = get_aliases_config (ctx);
|
||||||
&config_item_get (ctx->config.root, "aliases", NULL)->value.object;
|
|
||||||
for (size_t i = 0; i < N_ELEMENTS (g_default_aliases); i++)
|
for (size_t i = 0; i < N_ELEMENTS (g_default_aliases); i++)
|
||||||
{
|
{
|
||||||
const char **pair = g_default_aliases[i];
|
const char **pair = g_default_aliases[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user