aboutsummaryrefslogtreecommitdiff
path: root/src/template.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/template.c')
-rw-r--r--src/template.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/template.c b/src/template.c
index 95a54d9..e3ce60a 100644
--- a/src/template.c
+++ b/src/template.c
@@ -8,21 +8,25 @@
#include "../config.h"
-void
-template_initialize(char **base_pre, char **base_post)
+template_t *
+template_create(void)
{
+ template_t *template = malloc(sizeof(template_t));
+
FILE *base = fopen(DIRECTORY "/" BASE_TEMPLATE, "r");
unsigned int size = fsize(base);
char *contents = fcontent(base, size);
+ fclose(base);
key_match_t *match = find_next_key(contents);
- asprintf(base_pre, "%.*s", match->offset, contents);
- asprintf(base_post,
+ asprintf(&template->pre, "%.*s", match->offset, contents);
+ asprintf(&template->post,
"%.*s",
size - match->offset - match->length,
contents + match->offset + match->length);
free(contents);
- fclose(base);
+ free(match);
+ return template;
}