From cadd8ae8e6c1e5673258df9541042c74e705e518 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Thu, 4 Jun 2020 18:01:15 +0200 Subject: sfeed_atom: make the output more conform - Set mandatory entry tags: id, updated. - Change entry published (optional tag) to updated (mandatory). - Add tags: author name, id, updated, title. Thanks lich for the feedback and testing. --- sfeed_atom.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/sfeed_atom.c b/sfeed_atom.c index 33bd9a7..722a400 100644 --- a/sfeed_atom.c +++ b/sfeed_atom.c @@ -7,6 +7,7 @@ #include "util.h" +static time_t now; static char *line; static size_t linesize; @@ -65,12 +66,19 @@ printfeed(FILE *fp, const char *feedname) xmlencode(fields[FieldLink], stdout); fputs("\" />\n", stdout); } + /* prefer link over id for Atom . */ + fputs("\t", stdout); + if (fields[FieldLink][0]) + xmlencode(fields[FieldLink], stdout); + else if (fields[FieldId][0]) + xmlencode(fields[FieldId], stdout); + fputs("\n", stdout); if (fields[FieldEnclosure][0]) { fputs("\t\n", stdout); } - fprintf(stdout, "\t%04d-%02d-%02dT%02d:%02d:%02dZ\n", + fprintf(stdout, "\t%04d-%02d-%02dT%02d:%02d:%02dZ\n", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); if (fields[FieldAuthor][0]) { @@ -97,6 +105,7 @@ printfeed(FILE *fp, const char *feedname) int main(int argc, char *argv[]) { + struct tm *tm; FILE *fp; char *name; int i; @@ -109,9 +118,20 @@ main(int argc, char *argv[]) err(1, "pledge"); } + if ((now = time(NULL)) == -1) + err(1, "time"); + if (!(tm = gmtime(&now))) + err(1, "gmtime"); + fputs("\n" - "\n", - stdout); + "\n" + "\tNewsfeed\n" + "\tsfeed\n", stdout); + printf("\turn:newsfeed:%lld\n" + "\t%04d-%02d-%02dT%02d:%02d:%02dZ\n", + (long long)now, + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); if (argc == 1) { printfeed(stdin, ""); -- cgit v1.2.3