diff options
author | Raghuram Subramani <raghus2247@gmail.com> | 2025-06-24 11:34:55 +0530 |
---|---|---|
committer | Raghuram Subramani <raghus2247@gmail.com> | 2025-06-24 11:34:55 +0530 |
commit | 5c4124a71f37875656b5f622f90a1ba02a26be44 (patch) | |
tree | 6982336e46c4453f2ad6bb87e500c70ec3110421 /src/template.c | |
parent | 7e4a3ce413eb967d440de3c417f10f8833f1e064 (diff) |
(template): introduce template struct
Diffstat (limited to 'src/template.c')
-rw-r--r-- | src/template.c | 14 |
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; } |