traffic.o: traffic.c traffic.h common.h ifinfo.h misc.h
dbxml.o: dbxml.c dbxml.h common.h
dbshow.o: dbshow.c dbshow.h misc.h common.h
-dbaccess.o: dbaccess.c dbaccess.h common.h
+dbaccess.o: dbaccess.c dbaccess.h misc.h common.h
dbmerge.o: dbmerge.c dbmerge.h dbaccess.h common.h
dbcache.o: dbcache.c dbcache.h dbaccess.h common.h ifinfo.h
common.o: common.c common.h
#include "common.h"
#include "dbaccess.h"
+#include "misc.h"
int readdb(const char *iface, const char *dirname)
{
printf("db: Months rotated. Current month: \"%d\".\n", d->tm_mon+1);
}
}
+
+void cleartop10(const char *iface, const char *dirname)
+{
+ int i;
+
+ if (readdb(iface, dirname)!=0) {
+ exit(EXIT_FAILURE);
+ }
+
+ for (i=0; i<=9; i++) {
+ data.top10[i].rx=data.top10[i].tx=0;
+ data.top10[i].rxk=data.top10[i].txk=0;
+ data.top10[i].used=0;
+ }
+
+ writedb(iface, dirname, 0);
+ printf("Top10 cleared for interface \"%s\".\n", data.interface);
+}
+
+void rebuilddbtotal(const char *iface, const char *dirname)
+{
+ int i;
+
+ if (readdb(iface, dirname)!=0) {
+ exit(EXIT_FAILURE);
+ }
+
+ data.totalrx=data.totaltx=data.totalrxk=data.totaltxk=0;
+ for (i=0; i<=11; i++) {
+ if (data.month[i].used) {
+ addtraffic(&data.totalrx, &data.totalrxk, data.month[i].rx, data.month[i].rxk);
+ addtraffic(&data.totaltx, &data.totaltxk, data.month[i].tx, data.month[i].txk);
+ }
+ }
+
+ writedb(iface, dirname, 0);
+ printf("Total transfer rebuild completed for interface \"%s\".\n", data.interface);
+}
void cleanhours(void);
void rotatedays(void);
void rotatemonths(void);
+void cleartop10(const char *iface, const char *dirname);
+void rebuilddbtotal(const char *iface, const char *dirname);
/* version 1.0 database format aka db v1 */
return 1;
}
if (force) {
- readdb(interface, dirname);
-
- for (i=0; i<=9; i++) {
- data.top10[i].rx=data.top10[i].tx=0;
- data.top10[i].rxk=data.top10[i].txk=0;
- data.top10[i].used=0;
- }
-
- writedb(interface, dirname, 0);
- printf("Top10 cleared for interface \"%s\".\n", data.interface);
+ cleartop10(interface, dirname);
query=0;
} else {
printf("Warning:\nThe current option would clear the top10 for \"%s\".\n", interface);
return 1;
}
if (force) {
- readdb(interface, dirname);
-
- data.totalrx=data.totaltx=data.totalrxk=data.totaltxk=0;
- for (i=0; i<=11; i++) {
- if (data.month[i].used) {
- addtraffic(&data.totalrx, &data.totalrxk, data.month[i].rx, data.month[i].rxk);
- addtraffic(&data.totaltx, &data.totaltxk, data.month[i].tx, data.month[i].txk);
- }
- }
-
- writedb(interface, dirname, 0);
- printf("Total transfer rebuild completed for interface \"%s\".\n", data.interface);
+ rebuilddbtotal(interface, dirname);
query=0;
} else {
printf("Warning:\nThe current option would rebuild total tranfers for \"%s\".\n", interface);
common.o: common.c common.h
ifinfo.o: ifinfo.c ifinfo.h common.h dbaccess.h misc.h cfg.h
-dbaccess.o: dbaccess.c dbaccess.h common.h
+dbaccess.o: dbaccess.c dbaccess.h misc.h common.h
dbcache.o: dbcache.c dbcache.h dbaccess.h common.h ifinfo.h
cfg.o: cfg.c cfg.h common.h
misc.o: misc.c misc.h common.h