aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2025-07-11 11:20:27 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2025-07-11 11:20:27 +0530
commit7eb270eabb42bb896f41f8ad36fdd79cc6371d26 (patch)
tree06be10bc770484c83d4aa2c58ee2721a3176416e /src
parentcde16169e0dec04ecef4bd228f770c254314f148 (diff)
template: template_ingest() must write to a FILE
Diffstat (limited to 'src')
-rw-r--r--src/template.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/template.c b/src/template.c
index d4aa9ed..8ad11a2 100644
--- a/src/template.c
+++ b/src/template.c
@@ -3,6 +3,7 @@
#include <filehandler.h>
#include <lexer.h>
+#include <stdio.h>
#include <stdlib.h>
#include <template.h>
#include <util.h>
@@ -33,10 +34,9 @@ template_delete(template_t *template)
free(template);
}
-char *
-template_ingest(template_t *template, list_t *content_headers, char *body)
+void
+template_ingest(template_t *template, list_t *content_headers, FILE *f)
{
- (void) body;
char *output = malloc(1);
strcpy(output, "");
@@ -45,14 +45,18 @@ template_ingest(template_t *template, list_t *content_headers, char *body)
switch (match->type) {
case _RAW:
- xstrcat(output, match->operands);
+ fprintf(f, "%s", (char *) match->operands);
break;
+ case CONTENT: {
+ char *content = find_contentfor_value(content_headers, match->operands);
+ fprintf(f, "%s", content);
+ break;
+ }
+
/* TODO: Handle this gracefully */
default:
break;
}
}
-
- return output;
}