aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--degesch.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/degesch.c b/degesch.c
index 3733339..358e592 100644
--- a/degesch.c
+++ b/degesch.c
@@ -1936,38 +1936,43 @@ autofill_user_info (struct app_context *ctx, struct error **e)
}
static bool
-load_config (struct app_context *ctx, struct error **e)
+unescape_config (struct str_map *input, struct str_map *output, struct error **e)
{
- // TODO: employ a better configuration file format, so that we don't have
- // to do this convoluted post-processing anymore.
-
- struct str_map map;
- str_map_init (&map);
- map.free = free;
-
- if (!read_config_file (&map, e))
- return false;
-
+ struct error *error = NULL;
struct str_map_iter iter;
- str_map_iter_init (&iter, &map);
+ str_map_iter_init (&iter, input);
while (str_map_iter_next (&iter))
{
- struct error *e = NULL;
struct str value;
str_init (&value);
- if (!unescape_string (iter.link->data, &value, &e))
+ if (!unescape_string (iter.link->data, &value, &error))
{
- // FIXME: use the "e" argument, don't print it
- print_error ("error reading configuration: %s: %s",
- iter.link->key, e->message);
- error_free (e);
- exit (EXIT_FAILURE);
+ error_set (e, "error reading configuration: %s: %s",
+ iter.link->key, error->message);
+ error_free (error);
+ return false;
}
- str_map_set (&ctx->config, iter.link->key, str_steal (&value));
+ str_map_set (output, iter.link->key, str_steal (&value));
}
+ return true;
+}
+
+static bool
+load_config (struct app_context *ctx, struct error **e)
+{
+ // TODO: employ a better configuration file format, so that we don't have
+ // to do this convoluted post-processing anymore.
+
+ struct str_map map;
+ str_map_init (&map);
+ map.free = free;
- if (!autofill_user_info (ctx, e))
+ bool success = read_config_file (&map, e) &&
+ unescape_config (&map, &ctx->config, e) &&
+ autofill_user_info (ctx, e);
+ str_map_free (&map);
+ if (!success)
return false;
if (!irc_get_boolean_from_config (ctx, "reconnect", &ctx->reconnect, e))