diff options
author | Raghuram Subramani <raghus2247@gmail.com> | 2025-07-10 22:12:22 +0530 |
---|---|---|
committer | Raghuram Subramani <raghus2247@gmail.com> | 2025-07-10 22:12:22 +0530 |
commit | 2a65c3971513c44fa0c124c4e1e6e89c823c8501 (patch) | |
tree | a28f8669607bb4293f02c5846c00f6571104d7b4 | |
parent | 9a2b779bb2f5f771604c22ddd0ac6d7932b900ff (diff) |
template: template_ingest() should work with _RAW
-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; +} |