projects
/
darkstat
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update portability notes.
[darkstat]
/
daylog.c
diff --git
a/daylog.c
b/daylog.c
index
d443dcf
..
080f11f
100644
(file)
--- a/
daylog.c
+++ b/
daylog.c
@@
-1,5
+1,5
@@
/* darkstat 3
/* darkstat 3
- * copyright (c) 2007-201
1
Emil Mikulic.
+ * copyright (c) 2007-201
4
Emil Mikulic.
*
* daylog.c: daily usage log
*
*
* daylog.c: daily usage log
*
@@
-9,6
+9,7
@@
#define _GNU_SOURCE 1 /* for O_NOFOLLOW on Linux */
#define _GNU_SOURCE 1 /* for O_NOFOLLOW on Linux */
+#include "cdefs.h"
#include "err.h"
#include "daylog.h"
#include "str.h"
#include "err.h"
#include "daylog.h"
#include "str.h"
@@
-23,7
+24,7
@@
#include <unistd.h>
static const char *daylog_fn = NULL;
#include <unistd.h>
static const char *daylog_fn = NULL;
-static
long
today_real, tomorrow_real;
+static
time_t
today_real, tomorrow_real;
static uint64_t bytes_in, bytes_out, pkts_in, pkts_out;
#define DAYLOG_DATE_LEN 26 /* strlen("1900-01-01 00:00:00 +1234") + 1 */
static uint64_t bytes_in, bytes_out, pkts_in, pkts_out;
#define DAYLOG_DATE_LEN 26 /* strlen("1900-01-01 00:00:00 +1234") + 1 */
@@
-55,6
+56,7
@@
static time_t tomorrow(time_t t_before) {
}
/* Warns on error. */
}
/* Warns on error. */
+static void daylog_write(const char *format, ...) _printflike_(1, 2);
static void daylog_write(const char *format, ...) {
int fd;
ssize_t wr;
static void daylog_write(const char *format, ...) {
int fd;
ssize_t wr;
@@
-86,28
+88,33
@@
static void daylog_write(const char *format, ...) {
}
static void daylog_emit(void) {
}
static void daylog_emit(void) {
- daylog_write("%s|%ld|%qu|%qu|%qu|%qu\n",
- fmt_date(today_real), (long)today_real,
- bytes_in, bytes_out, pkts_in, pkts_out);
+ daylog_write("%s|%qu|%qu|%qu|%qu|%qu\n",
+ fmt_date(today_real),
+ (qu)today_real,
+ (qu)bytes_in,
+ (qu)bytes_out,
+ (qu)pkts_in,
+ (qu)pkts_out);
}
void daylog_init(const char *filename) {
daylog_fn = filename;
today_real = now_real();
tomorrow_real = tomorrow(today_real);
}
void daylog_init(const char *filename) {
daylog_fn = filename;
today_real = now_real();
tomorrow_real = tomorrow(today_real);
- verbosef("today is %ld, tomorrow is %ld",
- (long)today_real, (long)tomorrow_real);
+ verbosef("today is %llu, tomorrow is %llu",
+ (llu)today_real,
+ (llu)tomorrow_real);
bytes_in = bytes_out = pkts_in = pkts_out = 0;
bytes_in = bytes_out = pkts_in = pkts_out = 0;
- daylog_write("# logging started at %s (%
ld
)\n",
- fmt_date(today_real), (
long
)today_real);
+ daylog_write("# logging started at %s (%
qu
)\n",
+ fmt_date(today_real), (
qu
)today_real);
}
void daylog_free(void) {
today_real = now_real();
daylog_emit(); /* Emit what's currently accumulated before we exit. */
}
void daylog_free(void) {
today_real = now_real();
daylog_emit(); /* Emit what's currently accumulated before we exit. */
- daylog_write("# logging stopped at %s (%
ld
)\n",
- fmt_date(today_real), (
long
)today_real);
+ daylog_write("# logging stopped at %s (%
qu
)\n",
+ fmt_date(today_real), (
qu
)today_real);
}
void daylog_acct(uint64_t amount, enum graph_dir dir) {
}
void daylog_acct(uint64_t amount, enum graph_dir dir) {
@@
-121,7
+128,7
@@
void daylog_acct(uint64_t amount, enum graph_dir dir) {
today_real = now_real();
tomorrow_real = tomorrow(today_real);
bytes_in = bytes_out = pkts_in = pkts_out = 0;
today_real = now_real();
tomorrow_real = tomorrow(today_real);
bytes_in = bytes_out = pkts_in = pkts_out = 0;
- verbosef("updated daylog, tomorrow = %l
d", (long
)tomorrow_real);
+ verbosef("updated daylog, tomorrow = %l
lu", (llu
)tomorrow_real);
}
/* Accounting. */
}
/* Accounting. */