summaryrefslogtreecommitdiff
path: root/sfeed_frames.c
diff options
context:
space:
mode:
Diffstat (limited to 'sfeed_frames.c')
-rw-r--r--sfeed_frames.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/sfeed_frames.c b/sfeed_frames.c
index 89838cc..53f44a6 100644
--- a/sfeed_frames.c
+++ b/sfeed_frames.c
@@ -1,5 +1,3 @@
-#include <sys/types.h>
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -34,7 +32,8 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f)
}
fputs("<pre>\n", fpitems);
- while ((linelen = getline(&line, &linesize, fpin)) > 0) {
+ while ((linelen = getline(&line, &linesize, fpin)) > 0 &&
+ !ferror(fpitems)) {
if (line[linelen - 1] == '\n')
line[--linelen] = '\0';
parseline(line, fields);
@@ -86,10 +85,8 @@ main(int argc, char *argv[])
if (!(feeds = calloc(argc, sizeof(struct feed))))
err(1, "calloc");
- if ((comparetime = time(NULL)) == -1)
- err(1, "time");
- /* 1 day is old news */
- comparetime -= 86400;
+ if ((comparetime = getcomparetime()) == (time_t)-1)
+ errx(1, "getcomparetime");
/* write main index page */
if (!(fpindex = fopen("index.html", "wb")))
@@ -114,6 +111,7 @@ main(int argc, char *argv[])
if (argc == 1) {
feeds[0].name = "";
printfeed(fpitems, stdin, &feeds[0]);
+ checkfileerror(stdin, "<stdin>", 'r');
} else {
for (i = 1; i < argc; i++) {
name = ((name = strrchr(argv[i], '/'))) ? name + 1 : argv[i];
@@ -122,8 +120,8 @@ main(int argc, char *argv[])
if (!(fp = fopen(argv[i], "r")))
err(1, "fopen: %s", argv[i]);
printfeed(fpitems, fp, &feeds[i - 1]);
- if (ferror(fp))
- err(1, "ferror: %s", argv[i]);
+ checkfileerror(fp, argv[i], 'r');
+ checkfileerror(fpitems, "items.html", 'w');
fclose(fp);
}
}
@@ -174,10 +172,15 @@ main(int argc, char *argv[])
"</frameset>\n"
"</html>\n", fpindex);
+ checkfileerror(fpindex, "index.html", 'w');
+ checkfileerror(fpitems, "items.html", 'w');
+
fclose(fpindex);
fclose(fpitems);
- if (fpmenu)
+ if (fpmenu) {
+ checkfileerror(fpmenu, "menu.html", 'w');
fclose(fpmenu);
+ }
return 0;
}