about summary refs log tree commit diff
path: root/archive.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-09 18:55:16 -0400
committerJune McEnroe <june@causal.agency>2020-04-09 18:55:16 -0400
commitef48616f2b63973830a07199c6bbe3b9a7ea6cc8 (patch)
tree7d92c7dc3560d75469e72e33f1f69dfc2089dcf1 /archive.c
parentTrim angle brackets from message IDs (diff)
downloadbubger-ef48616f2b63973830a07199c6bbe3b9a7ea6cc8.tar.gz
bubger-ef48616f2b63973830a07199c6bbe3b9a7ea6cc8.zip
Render basic HTML envelopes with templating
Diffstat (limited to 'archive.c')
-rw-r--r--archive.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/archive.c b/archive.c
index 889f253..fd8ef53 100644
--- a/archive.c
+++ b/archive.c
@@ -240,16 +240,26 @@ static void exportMessage(struct List items) {
 	if (!header) errx(EX_PROTOCOL, "missing BODY[HEADER.FIELDS] data item");
 	if (!body) errx(EX_PROTOCOL, "missing BODY[TEXT] data item");
 
-	const char *path = uidPath(uid, "mbox");
-	FILE *file = fopen(path, "w");
-	if (!file) err(EX_CANTCREAT, "%s", path);
+	const char *path;
+	FILE *file;
+	int error;
 
-	int error = mboxFrom(file)
+	path = uidPath(uid, "mbox");
+	file = fopen(path, "w");
+	if (!file) err(EX_CANTCREAT, "%s", path);
+	error = mboxFrom(file)
 		|| mboxHeader(file, header)
 		|| mboxBody(file, body)
 		|| fclose(file);
 	if (error) err(EX_IOERR, "%s", path);
 
+	path = uidPath(uid, "html");
+	file = fopen(path, "w");
+	if (!file) err(EX_CANTCREAT, "%s", path);
+	error = htmlEnvelope(file, &envelope)
+		|| fclose(file);
+	if (error) err(EX_IOERR, "%s", path);
+
 	envelopeFree(envelope);
 }