From 48372db7f6d048e77e169c520bdb51e43f9c1702 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Thu, 25 Apr 2019 19:50:47 +0200 Subject: sfeed_atom: add content too (for completeness) --- sfeed_atom.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/sfeed_atom.c b/sfeed_atom.c index 3040b8c..69d946d 100644 --- a/sfeed_atom.c +++ b/sfeed_atom.c @@ -13,6 +13,29 @@ static time_t comparetime; static char *line; static size_t linesize; +static void +printcontent(const char *s) +{ + for (; *s; ++s) { + switch (*s) { + case '<': fputs("<", stdout); break; + case '>': fputs(">", stdout); break; + case '\'': fputs("'", stdout); break; + case '&': fputs("&", stdout); break; + case '"': fputs(""", stdout); break; + case '\\': + s++; + switch (*s) { + case 'n': putchar('\n'); break; + case '\\': putchar('\\'); break; + case 't': putchar('\t'); break; + } + break; + default: putchar(*s); + } + } +} + static void printfeed(FILE *fp, const char *feedname) { @@ -59,6 +82,18 @@ printfeed(FILE *fp, const char *feedname) xmlencode(fields[FieldAuthor], stdout); fputs("\n", stdout); } + if (fields[FieldContent][0]) { + if (!strcmp(fields[FieldContentType], "html")) { + fputs("\t", stdout); + } else { + /* NOTE: an RSS/Atom viewer may or may not format + whitespace such as newlines. + Workaround: type="html" and ]]> */ + fputs("\t", stdout); + } + printcontent(fields[FieldContent]); + fputs("\n", stdout); + } fputs("\n", stdout); } } -- cgit v1.2.3