From fbe7d9926bbdafdfb42609aa614ba50a172f3150 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sun, 11 Mar 2018 18:32:43 +0100 Subject: sfeed_tail improvements keep sfeed_tail until sfeed is reworked to support tail -f (eventually) --- README | 1 + sfeed_tail.c | 28 ++++++++++------------------ util.h | 4 ++-- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/README b/README index b5bbd03..c1ebdc1 100644 --- a/README +++ b/README @@ -111,6 +111,7 @@ sfeed_opml_export - Generate an OPML XML file from a sfeedrc config file. sfeed_opml_import - Generate a sfeedrc config file from an OPML XML file. sfeed_mbox - Format feed data (TSV) to mbox. sfeed_plain - Format feed data (TSV) to a plain-text list. +sfeed_tail - format unseen feed data (TSV) to a plain-text list. sfeed_update - Update feeds and merge with old feeds in the directory $HOME/.sfeed/feeds by default. sfeed_web - Find urls to RSS/Atom feed from a webpage. diff --git a/sfeed_tail.c b/sfeed_tail.c index cf0a0ba..18ccb3a 100644 --- a/sfeed_tail.c +++ b/sfeed_tail.c @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -107,26 +109,16 @@ printfeed(FILE *fp, const char *feedname) if (firsttime) continue; - /* output parsed line: it may not be the same as the input. */ - for (i = 0; i < FieldLast; i++) { - if (i) - putchar('\t'); - fputs(fields[i], stdout); + if (feedname[0]) { + printutf8pad(stdout, feedname, 15, ' '); + fputs(" ", stdout); } - putchar('\n'); - fflush(stdout); - -#if 0 - if (fields[FieldFeedName][0]) - printf("%-15.15s ", fields[FieldFeedName]); - else if (feedname[0]) - printf("%-15.15s ", feedname); - printf("%04d-%02d-%02d %02d:%02d ", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min); + + fprintf(stdout, "%04d-%02d-%02d %02d:%02d ", + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min); printutf8pad(stdout, fields[FieldTitle], 70, ' '); printf(" %s\n", fields[FieldLink]); -#endif } } @@ -168,7 +160,7 @@ main(int argc, char *argv[]) fclose(fp); } } - // DEBUG: TODO: gc first run. + /* DEBUG: TODO: gc first run. */ gc(); sleep(sleepsecs); diff --git a/util.h b/util.h index 2d1a184..4542e4e 100644 --- a/util.h +++ b/util.h @@ -31,8 +31,8 @@ struct uri { }; enum { - FieldUnixTimestamp = 0, FieldTitle, FieldLink, - FieldContent, FieldContentType, FieldId, FieldAuthor, FieldLast + FieldUnixTimestamp = 0, FieldTitle, FieldLink, FieldContent, + FieldContentType, FieldId, FieldAuthor, FieldLast }; int absuri(char *, size_t, const char *, const char *); -- cgit v1.2.3