summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sfeed_mbox.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/sfeed_mbox.c b/sfeed_mbox.c
index 6b14786..96ec02e 100644
--- a/sfeed_mbox.c
+++ b/sfeed_mbox.c
@@ -13,6 +13,7 @@
static char *line;
static size_t linesize;
+static char host[256], *user, mtimebuf[32];
/* jenkins one-at-a-time hash, used for Message-Id */
static uint32_t
@@ -76,22 +77,9 @@ static void
printfeed(FILE *fp, const char *feedname)
{
struct tm tm;
- char *fields[FieldLast], timebuf[32], mtimebuf[32];
- char host[256], *user;
+ char *fields[FieldLast], timebuf[32];
time_t parsedtime;
- if (!(user = getenv("USER")))
- user = "you";
- if (gethostname(host, sizeof(host)) == -1)
- err(1, "gethostname");
-
- if ((parsedtime = time(NULL)) == -1)
- err(1, "time");
- if (!gmtime_r(&parsedtime, &tm))
- errx(1, "gmtime_r: can't get current time");
- if (!strftime(mtimebuf, sizeof(mtimebuf), "%a %b %d %H:%M:%S %Y", &tm))
- errx(1, "strftime: can't format current time");
-
while (parseline(&line, &linesize, fields, fp) > 0) {
parsedtime = 0;
strtotime(fields[FieldUnixTimestamp], &parsedtime);
@@ -140,10 +128,23 @@ printfeed(FILE *fp, const char *feedname)
int
main(int argc, char *argv[])
{
+ struct tm tm;
+ time_t t;
FILE *fp;
char *name;
int i;
+ if (!(user = getenv("USER")))
+ user = "you";
+ if (gethostname(host, sizeof(host)) == -1)
+ err(1, "gethostname");
+ if ((t = time(NULL)) == -1)
+ err(1, "time");
+ if (!gmtime_r(&t, &tm))
+ errx(1, "gmtime_r: can't get current time");
+ if (!strftime(mtimebuf, sizeof(mtimebuf), "%a %b %d %H:%M:%S %Y", &tm))
+ errx(1, "strftime: can't format current time");
+
if (argc == 1) {
printfeed(stdin, "");
} else {