summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2014-04-02 16:01:02 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2014-04-02 16:01:02 +0200
commit95dd38f361630f81f7970286547216b6e35abafd (patch)
tree2e7293f441b6f379ac67198d91e3c4a2a421d9f7
parent0c509625066b59346b6a0be6bfaf96bfeb0fa0db (diff)
sfeed_stats: improve
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
-rw-r--r--sfeed_stats.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/sfeed_stats.c b/sfeed_stats.c
index 96fa52c..0190e2f 100644
--- a/sfeed_stats.c
+++ b/sfeed_stats.c
@@ -25,11 +25,11 @@ die(const char *s) {
int
main(void) {
- char *fields[FieldLast];
- unsigned long totalfeeds = 0, totalnew = 0;
+ char *fields[FieldLast], timenewestformat[64] = "";
+ unsigned long totalfeeds = 0, totalnew = 0, totalitems = 0;
unsigned int islink, isnew;
struct feed *f, *feedcurrent = NULL;
- time_t parsedtime, comparetime;
+ time_t parsedtime, comparetime, timenewest = 0;
size_t size = 0;
atexit(cleanup);
@@ -55,10 +55,15 @@ main(void) {
feedcurrent = f;
feeds = feedcurrent; /* first item. */
}
- if(isnew && parsedtime > feedcurrent->timenewest) {
+ if(parsedtime > timenewest) {
+ timenewest = parsedtime;
+ strncpy(timenewestformat, fields[FieldTimeFormatted],
+ sizeof(timenewestformat)); /* TODO: strlcpy */
+ }
+ if(parsedtime > feedcurrent->timenewest) {
feedcurrent->timenewest = parsedtime;
strncpy(feedcurrent->timenewestformat, fields[FieldTimeFormatted],
- sizeof(feedcurrent->timenewestformat));
+ sizeof(feedcurrent->timenewestformat)); /* TODO: strlcpy */
}
/* TODO: memcpy and make feedcurrent->name static? */
@@ -75,17 +80,20 @@ main(void) {
totalnew += isnew;
feedcurrent->totalnew += isnew;
feedcurrent->total++;
+ totalitems++;
}
- printf("Total new: %lu\n", totalnew);
for(feedcurrent = feeds; feedcurrent; feedcurrent = feedcurrent->next) {
if(!feedcurrent->name || feedcurrent->name[0] == '\0')
continue;
/* printfeednameid(feedcurrent->name, stdout);*/
- fprintf(stdout, "[%4lu / %4lu] %-20s", feedcurrent->totalnew, feedcurrent->total,
- feedcurrent->name);
+ fprintf(stdout, "%c %-20.20s [%4lu/%-4lu]", feedcurrent->totalnew > 0 ? 'N' : ' ',
+ feedcurrent->name, feedcurrent->totalnew, feedcurrent->total);
if(feedcurrent->timenewestformat && feedcurrent->timenewestformat[0])
- fprintf(stdout, " (newest %s)", feedcurrent->timenewestformat);
+ fprintf(stdout, " %s", feedcurrent->timenewestformat);
putchar('\n');
}
+ printf(" ================================\n");
+ printf("%c %-20.20s [%4lu/%-4lu] %s\n", totalnew > 0 ? 'N' : ' ', "Total:",
+ totalnew, totalitems, timenewestformat);
return EXIT_SUCCESS;
}