projects
/
darkstat-debian
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Pull in darkstat-3.0.718
[darkstat-debian]
/
daylog.c
diff --git
a/daylog.c
b/daylog.c
index
fe1928f
..
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;
@@
-87,27
+89,32
@@
static void daylog_write(const char *format, ...) {
static void daylog_emit(void) {
daylog_write("%s|%qu|%qu|%qu|%qu|%qu\n",
static void daylog_emit(void) {
daylog_write("%s|%qu|%qu|%qu|%qu|%qu\n",
- fmt_date(today_real), (uint64_t)today_real,
- bytes_in, bytes_out, pkts_in, pkts_out);
+ 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;
daylog_write("# logging started at %s (%qu)\n",
bytes_in = bytes_out = pkts_in = pkts_out = 0;
daylog_write("# logging started at %s (%qu)\n",
- fmt_date(today_real), (
uint64_t
)today_real);
+ 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. */
daylog_write("# logging stopped at %s (%qu)\n",
}
void daylog_free(void) {
today_real = now_real();
daylog_emit(); /* Emit what's currently accumulated before we exit. */
daylog_write("# logging stopped at %s (%qu)\n",
- fmt_date(today_real), (
uint64_t
)today_real);
+ 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. */