1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "util.h"
static time_t comparetime;
static char *line = NULL;
static size_t size = 0;
static void
printfeed(FILE *fp, const char *feedname)
{
char *fields[FieldLast];
time_t parsedtime;
while(parseline(&line, &size, fields, FieldLast, '\t', fp) > 0) {
if(strtotime(fields[FieldUnixTimestamp], &parsedtime) != -1 &&
parsedtime >= comparetime)
fputs(" N ", stdout);
else
fputs(" ", stdout);
if(feedname[0])
printf("%-15.15s ", feedname);
printf(" %-30.30s ", fields[FieldTimeFormatted]);
printutf8pad(stdout, fields[FieldTitle], 70, ' ');
fputs(" ", stdout);
fputs(fields[FieldLink], stdout);
putchar('\n');
}
}
int
main(int argc, char *argv[])
{
FILE *fp;
char *name;
int i;
/* 1 day is old news */
comparetime = time(NULL) - (3600 * 24);
if(argc == 1) {
printfeed(stdin, "");
} else {
for(i = 1; i < argc; i++) {
if(!(fp = fopen(argv[i], "r")))
err(1, "fopen: %s", argv[i]);
name = xbasename(argv[i]);
printfeed(fp, name);
free(name);
if(ferror(fp))
err(1, "ferror: %s", argv[i]);
fclose(fp);
}
}
return 0;
}
|