- return mktime(&tm);
-}
-
-static int
-daylog_open(void)
-{
- return open(daylog_fn, O_WRONLY | O_APPEND | O_CREAT | O_NOFOLLOW, 0600);
-}
-
-static void
-daylog_emit(void)
-{
- int fd = daylog_open();
-
- if (fd != -1) {
- struct str *buf = str_make();
- char *s;
- size_t len;
- str_appendf(buf, "%s|%u|%qu|%qu|%qu|%qu\n",
- fmt_date(today_time), (unsigned int)today_time,
- bytes_in, bytes_out, pkts_in, pkts_out);
- str_extract(buf, &len, &s);
-
- (void)write(fd, s, len); /* ignore write errors */
- close(fd);
- free(s);
- }