sfeed

Simple RSS and Atom feed parser
git clone https://git.sinitax.com/codemadness/sfeed
Log | Files | Refs | README | LICENSE | Upstream | sfeed.txt

commit 2f5bbf19394778800083c66f7dc629ee166df357
parent 6131391e5944acd1ca8d0a8f326d87b0424d827a
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Thu, 23 Dec 2021 18:29:26 +0100

sfeed_atom: add category field(s)

Diffstat:
Msfeed_atom.c | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/sfeed_atom.c b/sfeed_atom.c @@ -37,10 +37,11 @@ printcontent(const char *s) static void printfeed(FILE *fp, const char *feedname) { - char *fields[FieldLast]; + char *fields[FieldLast], *p, *tmp; struct tm parsedtm, *tm; time_t parsedtime; ssize_t linelen; + int c; while ((linelen = getline(&line, &linesize, fp)) > 0) { if (line[linelen - 1] == '\n') @@ -98,6 +99,16 @@ printfeed(FILE *fp, const char *feedname) printcontent(fields[FieldContent]); fputs("</content>\n", stdout); } + for (p = fields[FieldCategory]; (tmp = strchr(p, '|')); p = tmp + 1) { + c = *tmp; + *tmp = '\0'; /* temporary NUL-terminate */ + if (*p) { + fputs("\t<category term=\"", stdout); + xmlencode(p, stdout); + fputs("\" />\n", stdout); + } + *tmp = c; /* restore */ + } fputs("</entry>\n", stdout); } }