From 6f1fc87b39335b4f60d2368413c6da7e732a0d97 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Fri, 10 Apr 2020 10:57:10 -0400 Subject: Rearrange Atom templating code --- atom.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'atom.c') diff --git a/atom.c b/atom.c index 8991ca7..6692acc 100644 --- a/atom.c +++ b/atom.c @@ -22,40 +22,35 @@ #include "archive.h" -static const char *Envelope = TEMPLATE( - - [subject] - - [from.name] - [from.mailbox]@[from.host] - - [date] - [id] -); - int atomEnvelope(FILE *file, const struct Envelope *envelope) { - const char *from = envelope->from.name; - if (!from) from = envelope->from.mailbox; - - char date[sizeof("0000-00-00T00:00:00Z")]; - strftime(date, sizeof(date), "%FT%TZ", gmtime(&envelope->utc)); - struct Variable idVars[] = { { "messageID", envelope->messageID }, {0}, }; char *id = templateURL("mailto:?In-Reply-To=[messageID]", idVars); + char date[sizeof("0000-00-00T00:00:00Z")]; + strftime(date, sizeof(date), "%FT%TZ", gmtime(&envelope->utc)); struct Variable vars[] = { { "subject", envelope->subject }, - { "from.name", from }, + { "from.name", addressName(envelope->from) }, { "from.mailbox", envelope->from.mailbox }, { "from.host", envelope->from.host }, { "date", date }, { "id", id }, {0}, }; - int error = templateRender(file, Envelope, vars, escapeXML); + const char *Entry = TEMPLATE( + + [subject] + + [from.name] + [from.mailbox]@[from.host] + + [date] + [id] + ); + int error = templateRender(file, Entry, vars, escapeXML); free(id); return error; } -- cgit 1.4.1