diff options
Diffstat (limited to '')
-rw-r--r-- | atom.c | 90 |
1 files changed, 44 insertions, 46 deletions
diff --git a/atom.c b/atom.c index 7bc4fe9..35cc840 100644 --- a/atom.c +++ b/atom.c @@ -31,12 +31,12 @@ static char *atomID(const struct Envelope *envelope) { } static int atomAuthor(FILE *file, struct Address addr) { - const char *template = TEMPLATE( - <author> - <name>[name]</name> - <email>[mailbox]@[host]</email> - </author> - ); + const char *template = { + Q(<author>) + Q(<name>[name]</name>) + Q(<email>[mailbox]@[host]</email>) + Q(</author>) + }; struct Variable vars[] = { { "name", addressName(addr) }, { "mailbox", addr.mailbox }, @@ -62,13 +62,13 @@ static const char *atomUpdated(time_t time) { } int atomEntryOpen(FILE *file, const struct Envelope *envelope) { - const char *template = TEMPLATE( - <entry> - <id>[id]</id> - <title>[title]</title> - <updated>[updated]</updated> - <link rel="alternate" type="application/mbox" href="[base][url]"/> - ); + const char *template = { + Q(<entry>) + Q(<id>[id]</id>) + Q(<title>[title]</title>) + Q(<updated>[updated]</updated>) + Q(<link rel="alternate" type="application/mbox" href="[base][url]"/>) + }; char *id = atomID(envelope); char *url = atomEntryURL(envelope); struct Variable vars[] = { @@ -88,13 +88,13 @@ int atomEntryOpen(FILE *file, const struct Envelope *envelope) { } int atomContent(FILE *file, const char *content) { - const char *template = TEMPLATE( - <content type="xhtml"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <pre>[content]</pre> - </div> - </content> - ); + const char *template = { + Q(<content type="xhtml">) + Q(<div xmlns="http://www.w3.org/1999/xhtml">) + Q(<pre>[content]</pre>) + Q(</div>) + Q(</content>) + }; struct Variable vars[] = { { "content", content }, {0}, @@ -103,7 +103,7 @@ int atomContent(FILE *file, const char *content) { } int atomEntryClose(FILE *file) { - return templateRender(file, TEMPLATE(</entry>), NULL, NULL); + return templateRender(file, Q(</entry>), NULL, NULL); } static char *atomThreadURL(const struct Envelope *envelope, const char *type) { @@ -116,23 +116,22 @@ static char *atomThreadURL(const struct Envelope *envelope, const char *type) { } int atomThreadOpen(FILE *file, const struct Envelope *envelope) { - const char *template = TEMPLATE( - <[q]xml version="1.0" encoding="utf-8"[q]> - <feed xmlns="http://www.w3.org/2005/Atom"> - <generator uri="[generator]">bubger</generator> - <id>[id]</id> - <title>[title]</title> - <updated>[updated]</updated> - <link rel="self" href="[base][atom]"/> - <link rel="alternate" type="text/html" href="[base][html]"/> - <link rel="alternate" type="application/mbox" href="[base][mbox]"/> - ); + const char *template = { + "<?" Q(xml version="1.0" encoding="utf-8") "?>" + Q(<feed xmlns="http://www.w3.org/2005/Atom">) + Q(<generator uri="[generator]">bubger</generator>) + Q(<id>[id]</id>) + Q(<title>[title]</title>) + Q(<updated>[updated]</updated>) + Q(<link rel="self" href="[base][atom]"/>) + Q(<link rel="alternate" type="text/html" href="[base][html]"/>) + Q(<link rel="alternate" type="application/mbox" href="[base][mbox]"/>) + }; char *id = atomID(envelope); char *atom = atomThreadURL(envelope, "atom"); char *html = atomThreadURL(envelope, "html"); char *mbox = atomThreadURL(envelope, "mbox"); struct Variable vars[] = { - { "q", "?" }, { "generator", GENERATOR_URL }, { "id", id }, { "title", envelope->subject }, @@ -154,22 +153,21 @@ int atomThreadOpen(FILE *file, const struct Envelope *envelope) { } int atomThreadClose(FILE *file) { - return templateRender(file, TEMPLATE(</feed>), NULL, NULL); + return templateRender(file, Q(</feed>), NULL, NULL); } int atomIndexOpen(FILE *file) { - const char *template = TEMPLATE( - <[q]xml version="1.0" encoding="utf-8"[q]> - <feed xmlns="http://www.w3.org/2005/Atom"> - <generator uri="[generator]">bubger</generator> - <id>mailto:[mailto]</id> - <title>[title]</title> - <updated>[updated]</updated> - <link rel="self" href="[base]/index.atom"/> - <link rel="alternate" type="text/html" href="[base]/index.html"/> - ); + const char *template = { + "<?" Q(xml version="1.0" encoding="utf-8") "?>" + Q(<feed xmlns="http://www.w3.org/2005/Atom">) + Q(<generator uri="[generator]">bubger</generator>) + Q(<id>mailto:[mailto]</id>) + Q(<title>[title]</title>) + Q(<updated>[updated]</updated>) + Q(<link rel="self" href="[base]/index.atom"/>) + Q(<link rel="alternate" type="text/html" href="[base]/index.html"/>) + }; struct Variable vars[] = { - { "q", "?" }, { "generator", GENERATOR_URL }, { "mailto", baseMailto }, { "title", baseTitle }, @@ -181,5 +179,5 @@ int atomIndexOpen(FILE *file) { } int atomIndexClose(FILE *file) { - return templateRender(file, TEMPLATE(</feed>), NULL, NULL); + return templateRender(file, Q(</feed>), NULL, NULL); } |