aboutsummaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index b268057..46a3ad2 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1,6 +1,7 @@
#define _GNU_SOURCE
#include <config.h>
+#include <filehandler.h>
#include <list.h>
#include <stdio.h>
#include <stdlib.h>
@@ -60,3 +61,22 @@ config_parse(char *content)
config->array_values = array_values;
return config;
}
+
+config_t *
+config_fetch_and_parse(char *path)
+{
+ FILE *f = fopen(path, "r");
+ if (f == NULL) {
+ printf("Could not open %s\n", path);
+ return NULL;
+ }
+
+ size_t s = fsize(f);
+ char *content = fcontent(f, s);
+ fclose(f);
+
+ config_t *config = config_parse(content);
+ free(content);
+
+ return config;
+}