aboutsummaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-07-10 01:44:02 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-07-10 01:44:02 +0200
commit0fd53af0d102af83db18801cceb78bdd55d7c0a6 (patch)
tree12eec1d9772c2c2110f626126d3e4b3ad118bfe6 /degesch.c
parentd39ffe440fe502181bffb20da5b5afd9674f5b77 (diff)
downloadxK-0fd53af0d102af83db18801cceb78bdd55d7c0a6.tar.gz
xK-0fd53af0d102af83db18801cceb78bdd55d7c0a6.tar.xz
xK-0fd53af0d102af83db18801cceb78bdd55d7c0a6.zip
degesch: factor out get_aliases_config()
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/degesch.c b/degesch.c
index 7e50ad9..35e7891 100644
--- a/degesch.c
+++ b/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 *
write_configuration_file (const struct str *data, struct error **e)
{
@@ -6294,12 +6308,6 @@ dump_matching_options
// --- 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
validate_server_name (const char *name)
{
@@ -7684,10 +7692,8 @@ expand_alias_definition (const struct str *definition, const char *arguments)
static char *
expand_alias (struct app_context *ctx, const char *alias_name, char *input)
{
- struct str_map *aliases =
- &config_item_get (ctx->config.root, "aliases", NULL)->value.object;
-
- struct config_item_ *entry = str_map_find (aliases, alias_name);
+ struct config_item_ *entry =
+ str_map_find (get_aliases_config (ctx), alias_name);
if (!entry)
return NULL;
@@ -8612,8 +8618,7 @@ const char *g_default_aliases[][2] =
static void
load_default_aliases (struct app_context *ctx)
{
- struct str_map *aliases =
- &config_item_get (ctx->config.root, "aliases", NULL)->value.object;
+ struct str_map *aliases = get_aliases_config (ctx);
for (size_t i = 0; i < N_ELEMENTS (g_default_aliases); i++)
{
const char **pair = g_default_aliases[i];