diff options
-rw-r--r-- | include/template.h | 1 | ||||
-rw-r--r-- | src/template.c | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/include/template.h b/include/template.h index 82ae180..b802d5e 100644 --- a/include/template.h +++ b/include/template.h @@ -8,5 +8,6 @@ typedef struct { } template_t; template_t *template_create(void); +char *template_ingest(template_t *template, char *body); #endif diff --git a/src/template.c b/src/template.c index 311ab3b..fae66dc 100644 --- a/src/template.c +++ b/src/template.c @@ -1,9 +1,11 @@ +#include <string.h> #define _GNU_SOURCE #include <filehandler.h> #include <lexer.h> #include <stdlib.h> #include <template.h> +#include <util.h> #include "../config.h" @@ -22,3 +24,27 @@ template_create(void) return template; } + +char * +template_ingest(template_t *template, char *body) +{ + (void) body; + char *output = malloc(1); + strcpy(output, ""); + + for (size_t i = 0; i < template->components->size; i++) { + directive_t *match = list_get(template->components, i); + + switch (match->type) { + case _RAW: + xstrcat(output, match->operands); + break; + + /* TODO: Handle this gracefully */ + default: + break; + } + } + + return output; +} |