summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sfeed_atom.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/sfeed_atom.c b/sfeed_atom.c
index 3040b8c..69d946d 100644
--- a/sfeed_atom.c
+++ b/sfeed_atom.c
@@ -14,6 +14,29 @@ static char *line;
static size_t linesize;
static void
+printcontent(const char *s)
+{
+ for (; *s; ++s) {
+ switch (*s) {
+ case '<': fputs("&lt;", stdout); break;
+ case '>': fputs("&gt;", stdout); break;
+ case '\'': fputs("&#39;", stdout); break;
+ case '&': fputs("&amp;", stdout); break;
+ case '"': fputs("&quot;", 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)
{
char *fields[FieldLast];
@@ -59,6 +82,18 @@ printfeed(FILE *fp, const char *feedname)
xmlencode(fields[FieldAuthor], stdout);
fputs("</name></author>\n", stdout);
}
+ if (fields[FieldContent][0]) {
+ if (!strcmp(fields[FieldContentType], "html")) {
+ fputs("\t<content type=\"html\">", stdout);
+ } else {
+ /* NOTE: an RSS/Atom viewer may or may not format
+ whitespace such as newlines.
+ Workaround: type="html" and <![CDATA[<pre></pre>]]> */
+ fputs("\t<content type=\"text\">", stdout);
+ }
+ printcontent(fields[FieldContent]);
+ fputs("</content>\n", stdout);
+ }
fputs("</entry>\n", stdout);
}
}