aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-10-01 04:36:59 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2016-10-01 04:36:59 +0200
commit952cf985dca6a97ee662f3b189788089abd2ef57 (patch)
tree288d0286386d14c3ecff9ca094a11079bf884a58
parent6234f686e011dfff6c585309de27204122cdbb8a (diff)
downloadliberty-952cf985dca6a97ee662f3b189788089abd2ef57.tar.gz
liberty-952cf985dca6a97ee662f3b189788089abd2ef57.tar.xz
liberty-952cf985dca6a97ee662f3b189788089abd2ef57.zip
Add config_read_from_file()
-rw-r--r--liberty.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/liberty.c b/liberty.c
index ca4d38a..c3051d8 100644
--- a/liberty.c
+++ b/liberty.c
@@ -5336,6 +5336,27 @@ config_item_clone (struct config_item *self)
return result;
}
+static struct config_item *
+config_read_from_file (const char *filename, struct error **e)
+{
+ struct config_item *root = NULL;
+
+ struct str data;
+ str_init (&data);
+ if (!read_file (filename, &data, e))
+ goto end;
+
+ struct error *error = NULL;
+ if (!(root = config_item_parse (data.str, data.len, false, &error)))
+ {
+ error_set (e, "parse error in `%s': %s", filename, error->message);
+ error_free (error);
+ }
+end:
+ str_free (&data);
+ return root;
+}
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/// "user_data" is passed so that it be immediately used by validation callbacks