diff options
-rw-r--r-- | sfeed_plain.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/sfeed_plain.c b/sfeed_plain.c index 92509d5..d300c27 100644 --- a/sfeed_plain.c +++ b/sfeed_plain.c @@ -2,13 +2,14 @@ #include <string.h> #include <stdlib.h> #include <time.h> -#include "common.c" +#include "common.h" +#include "compat.h" void printutf8padded(const char *s, size_t len) { - unsigned int n = 0, i = 0; + size_t n = 0, i; - for(; s[i] && n < len; i++) { + for(i = 0; s[i] && n < len; i++) { if((s[i] & 0xc0) != 0x80) /* start of character */ n++; putchar(s[i]); @@ -18,26 +19,27 @@ printutf8padded(const char *s, size_t len) { } int -main(void) { +main(int argc, char **argv) { char *line = NULL, *fields[FieldLast]; time_t parsedtime, comparetime; + int isnew; size_t size = 0; - tzset(); comparetime = time(NULL) - (3600 * 24); /* 1 day is old news */ - while(parseline(&line, &size, fields, FieldLast, stdin, FieldSeparator) > 0) { + while(parseline(&line, &size, fields, FieldLast, '\t', stdin) > 0) { + isnew = (parsedtime >= comparetime); parsedtime = (time_t)strtol(fields[FieldUnixTimestamp], NULL, 10); - printf(" %c ", (parsedtime >= comparetime) ? 'N' : ' '); + printf(" %c ", isnew ? 'N' : ' '); if(fields[FieldFeedName][0] != '\0') printf("%-15.15s ", fields[FieldFeedName]); - fputs(fields[FieldTimeFormatted], stdout); + printf("%-30.30s", fields[FieldTimeFormatted]); fputs(" ", stdout); printutf8padded(fields[FieldTitle], 70); fputs(" ", stdout); if(fields[FieldBaseSiteUrl][0] != '\0') - printlink(fields[FieldLink], fields[FieldBaseSiteUrl]); + printlink(fields[FieldLink], fields[FieldBaseSiteUrl], stdout); else - printlink(fields[FieldLink], fields[FieldFeedUrl]); + printlink(fields[FieldLink], fields[FieldFeedUrl], stdout); putchar('\n'); } free(line); |