Skip to content

Commit

Permalink
Version 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
vergoh committed Feb 24, 2014
1 parent 3a16c7e commit 0178a3b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 18 deletions.
9 changes: 9 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
1.4 / 26-Mar-04

- Fix: major output problems when compiled with some compilers
(thanks to DukePyrolator for reporting this bug and
Juha / vlu for testing the patch)
- Fix: month rotation if database isn't updated every day
- Minor non-visible fixes and code cleanup


1.3 / 8-Mar-04

- Fix: support for 64bit counters
Expand Down
2 changes: 1 addition & 1 deletion INSTALL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(Updated 8.3.2003 based on version 1.3)
(Updated 26.3.2003 based on version 1.4)

'I don't read manuals' install
::::::::::::::::::::::::::::::
Expand Down
3 changes: 3 additions & 0 deletions UNINSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

Run 'make uninstall' and follow the instructions.

4 changes: 2 additions & 2 deletions UPGRADE
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(Updated 29.2.2004 based on version 1.3)
(Updated 26.3.2004 based on version 1.4)

This file will try to explain how vnStat is supposed to be upgraded
from version 1.0. The makefile should handle upgrades from version 1.1
to 1.3 without user interaction. But for those still using 1.0, please
to 1.4 without user interaction. But for those still using 1.0, please
read the instructions once before executing step by step.

But once again to make this clear:
Expand Down
6 changes: 3 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CC = gcc
CFLAGS = -O2 -Wall
CFLAGS = -O2
OBJS = proc.o db.o misc.o
OBJS64 = proc64.o db.o misc.o

Expand All @@ -23,8 +23,8 @@ proc.o: proc.c proc.h vnstat.h db.h
proc64.o: proc.c proc.h vnstat.h db.h
$(CC) $(CFLAGS) -c proc.c -o proc64.o -DBLIMIT

db.o: db.c db.h vnstat.h
$(CC) -O2 -c db.c
db.o: db.c db.h proc.h vnstat.h
$(CC) $(CFLAGS) -c db.c

misc.o: misc.c misc.h
$(CC) $(CFLAGS) -c misc.c
Expand Down
24 changes: 14 additions & 10 deletions src/db.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "vnstat.h"
#include "db.h"
#include "proc.h"

int dmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

Expand Down Expand Up @@ -118,11 +119,14 @@ void showdb(int qmode)
struct tm *d;
char datebuff[16];
char daytemp[128];
uint64_t e_rx, e_tx, t_rx, t_tx, t_rxk, t_txk;
uint64_t e_rx, e_tx, t_rx, t_tx;
int t_rxk, t_txk;
time_t current, yesterday;

current=time(NULL);
yesterday=current-86400;

e_rx=e_tx=t_rx=t_tx=t_rxk=t_txk=0;

if (data.totalrx+data.totaltx==0 && (data.totalrxk/(float)10+data.totaltxk/(float)10)==0) {

Expand Down Expand Up @@ -336,8 +340,8 @@ void showdb(int qmode)
printf("active;%d\n", data.active);
printf("interface;%s\n", data.interface);
printf("nick;%s\n", data.nick);
printf("created;%d\n", data.created);
printf("updated;%d\n", data.lastupdated);
printf("created;%d\n", (int)data.created);
printf("updated;%d\n", (int)data.lastupdated);

printf("totalrx;%Lu\n", data.totalrx);
printf("totaltx;%Lu\n", data.totaltx);
Expand All @@ -348,18 +352,18 @@ void showdb(int qmode)
printf("btime;%Lu\n", data.btime);

for (i=0;i<=29;i++) {
printf("d;%d;%d;%Lu;%Lu;%d;%d;%d\n",i, data.day[i].date, data.day[i].rx, data.day[i].tx, data.day[i].rxk, data.day[i].txk, data.day[i].used);
printf("d;%d;%d;%Lu;%Lu;%d;%d;%d\n",i, (int)data.day[i].date, data.day[i].rx, data.day[i].tx, data.day[i].rxk, data.day[i].txk, data.day[i].used);
}

for (i=0;i<=11;i++) {
printf("m;%d;%d;%Lu;%Lu;%d;%d;%d\n",i, data.month[i].month, data.month[i].rx, data.month[i].tx, data.month[i].rxk, data.month[i].txk, data.month[i].used);
printf("m;%d;%d;%Lu;%Lu;%d;%d;%d\n",i, (int)data.month[i].month, data.month[i].rx, data.month[i].tx, data.month[i].rxk, data.month[i].txk, data.month[i].used);
}

for (i=0;i<=9;i++) {
printf("t;%d;%d;%Lu;%Lu;%d;%d;%d\n",i,data.top10[i].date, data.top10[i].rx, data.top10[i].tx, data.top10[i].rxk, data.top10[i].txk, data.top10[i].used);
printf("t;%d;%d;%Lu;%Lu;%d;%d;%d\n",i,(int)data.top10[i].date, data.top10[i].rx, data.top10[i].tx, data.top10[i].rxk, data.top10[i].txk, data.top10[i].used);
}
for (i=0;i<=23;i++) {
printf("h;%d;%d;%Lu;%Lu\n",i,data.hour[i].date, data.hour[i].rx, data.hour[i].tx);
printf("h;%d;%d;%Lu;%Lu\n",i,(int)data.hour[i].date, data.hour[i].rx, data.hour[i].tx);
}

/* multiple dbs at one time */
Expand Down Expand Up @@ -658,7 +662,7 @@ void cleanhours(void)
data.hour[i].rx=0;
data.hour[i].tx=0;
if (debug) {
printf("Hour %d (%d) cleaned.\n",i, data.hour[i].date);
printf("Hour %d (%d) cleaned.\n",i, (int)data.hour[i].date);
}
}
}
Expand All @@ -672,7 +676,7 @@ void cleanhours(void)
data.hour[hour].rx=0;
data.hour[hour].tx=0;
if (debug) {
printf("Current hour %d (%d) cleaned.\n",hour, data.hour[i].date);
printf("Current hour %d (%d) cleaned.\n",hour, (int)data.hour[i].date);
}
data.hour[hour].date=current;
}
Expand Down Expand Up @@ -1025,6 +1029,6 @@ void showint(uint64_t mb, int kb, int len)
if ((flen+3<=len) && (kb!=-1) && (mb<1000) && (kB!=0)) {
printf("%'*Lu.%02d", len-3, mb, kB);
} else {
printf("%'*Lu", len);
printf("%'*Lu", len, mb);
}
}
2 changes: 1 addition & 1 deletion src/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void parseproc(int newdb)

/* rotate months in database if needed */
d=localtime(&data.month[0].month);
if ((d->tm_mon!=month) && (day==atoi(MONTHROTATE)))
if ((d->tm_mon!=month) && (day>=atoi(MONTHROTATE)))
rotatemonths();

}
Expand Down
2 changes: 1 addition & 1 deletion src/vnstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#define DBVERSION 3

/* version string */
#define VNSTATVERSION "1.3"
#define VNSTATVERSION "1.4"

#ifdef BLIMIT
/* 64 bit limit */
Expand Down

0 comments on commit 0178a3b

Please sign in to comment.