diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2021-12-23 18:29:26 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2021-12-23 18:29:26 +0100 |
commit | 2f5bbf19394778800083c66f7dc629ee166df357 (patch) | |
tree | 86f1d0c4ba782791037e0d180e112d0ad5caa7fc | |
parent | 6131391e5944acd1ca8d0a8f326d87b0424d827a (diff) |
sfeed_atom: add category field(s)
-rw-r--r-- | sfeed_atom.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sfeed_atom.c b/sfeed_atom.c index 96376a8..1dff75b 100644 --- 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); } } |