diff options
Diffstat (limited to '')
-rw-r--r-- | atom.c | 33 |
1 files changed, 14 insertions, 19 deletions
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( - <entry> - <title>[subject]</title> - <author> - <name>[from.name]</name> - <email>[from.mailbox]@[from.host]</email> - </author> - <updated>[date]</updated> - <id>[id]</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( + <entry> + <title>[subject]</title> + <author> + <name>[from.name]</name> + <email>[from.mailbox]@[from.host]</email> + </author> + <updated>[date]</updated> + <id>[id]</id> + ); + int error = templateRender(file, Entry, vars, escapeXML); free(id); return error; } |