From 796f5a869e2330818f549ebec74f4b18e937f1c7 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Thu, 9 Apr 2020 21:58:10 -0400 Subject: Factor out templateURL --- html.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index 85b6f6b..e404434 100644 --- a/html.c +++ b/html.c @@ -14,7 +14,6 @@ * along with this program. If not, see . */ -#include #include #include #include @@ -50,21 +49,7 @@ int htmlEnvelope(FILE *file, const struct Envelope *envelope) { { "messageID", envelope->messageID }, {0}, }; - - size_t cap = sizeof(Mailto); - for (struct Variable *var = mailtoVars; var->value; ++var) { - cap += ESCAPE_URL_CAP(strlen(var->value)); - } - char *mailto = malloc(cap); - if (!mailto) err(EX_OSERR, "malloc"); - - FILE *url = fmemopen(mailto, cap, "w"); - if (!url) err(EX_OSERR, "fmemopen"); - - int error = 0 - || templateRender(url, Mailto, mailtoVars, escapeURL) - || fclose(url); - assert(!error); + char *mailto = templateURL(Mailto, mailtoVars); const char *from = envelope->from.name; if (!from) from = envelope->from.mailbox; @@ -84,7 +69,7 @@ int htmlEnvelope(FILE *file, const struct Envelope *envelope) { { "date", date }, {0}, }; - error = templateRender(file, Summary, summaryVars, escapeXML); + int error = templateRender(file, Summary, summaryVars, escapeXML); free(mailto); if (error) return error; -- cgit 1.4.1