vnstat  2.9
About: vnStat is a console-based network traffic monitor (using the /proc filesystem).
  Fossies Dox: vnstat-2.9.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

cfg.c
Go to the documentation of this file.
1#include "common.h"
2#include "cfg.h"
3
4int loadcfg(const char *cfgfile, const ConfigType type)
5{
6 FILE *fd;
7 int i;
8 unsigned int linelen, cfglen;
9
10 char value[512], cfgline[512];
11
12 struct cfgsetting cset[] =
13 {/* cfg string, char var name, int var name, char len, fill status */
14 {"Interface", cfg.iface, 0, 32, 0},
15 {"DatabaseDir", cfg.dbdir, 0, 512, 0},
16 {"Locale", cfg.locale, 0, 32, 0},
17 {"MonthRotate", 0, &cfg.monthrotate, 0, 0},
18 {"MonthRotateAffectsYears", 0, &cfg.monthrotateyears, 0, 0},
19 {"DayFormat", cfg.dformat, 0, 64, 0},
20 {"MonthFormat", cfg.mformat, 0, 64, 0},
21 {"TopFormat", cfg.tformat, 0, 64, 0},
22 {"RXCharacter", cfg.rxchar, 0, 2, 0},
23 {"TXCharacter", cfg.txchar, 0, 2, 0},
24 {"RXHourCharacter", cfg.rxhourchar, 0, 2, 0},
25 {"TXHourCharacter", cfg.txhourchar, 0, 2, 0},
26 {"UnitMode", 0, &cfg.unitmode, 0, 0},
27 {"RateUnitMode", 0, &cfg.rateunitmode, 0, 0},
28 {"OutputStyle", 0, &cfg.ostyle, 0, 0},
29 {"EstimateBarVisible", 0, &cfg.estimatebarvisible, 0, 0},
30 {"RateUnit", 0, &cfg.rateunit, 0, 0},
31 {"DefaultDecimals", 0, &cfg.defaultdecimals, 0, 0},
32 {"HourlyDecimals", 0, &cfg.hourlydecimals, 0, 0},
33 {"HourlySectionStyle", 0, &cfg.hourlystyle, 0, 0},
34 {"BandwidthDetection", 0, &cfg.bwdetection, 0, 0},
35 {"MaxBandwidth", 0, &cfg.maxbw, 0, 0},
36 {"Sampletime", 0, &cfg.sampletime, 0, 0},
37 {"QueryMode", 0, &cfg.qmode, 0, 0},
38 {"CheckDiskSpace", 0, &cfg.spacecheck, 0, 0},
39 {"BootVariation", 0, &cfg.bvar, 0, 0},
40 {"TrafficlessEntries", 0, &cfg.trafficlessentries, 0, 0},
41 {"List5Mins", 0, &cfg.listfivemins, 0, 0},
42 {"ListHours", 0, &cfg.listhours, 0, 0},
43 {"ListDays", 0, &cfg.listdays, 0, 0},
44 {"ListMonths", 0, &cfg.listmonths, 0, 0},
45 {"ListYears", 0, &cfg.listyears, 0, 0},
46 {"ListTop", 0, &cfg.listtop, 0, 0},
47 {"InterfaceMatchMethod", 0, &cfg.ifacematchmethod, 0, 0},
48 {"5MinuteHours", 0, &cfg.fiveminutehours, 0, 0},
49 {"HourlyDays", 0, &cfg.hourlydays, 0, 0},
50 {"DailyDays", 0, &cfg.dailydays, 0, 0},
51 {"MonthlyMonths", 0, &cfg.monthlymonths, 0, 0},
52 {"YearlyYears", 0, &cfg.yearlyyears, 0, 0},
53 {"TopDayEntries", 0, &cfg.topdayentries, 0, 0},
54 {"DaemonUser", cfg.daemonuser, 0, 33, 0},
55 {"DaemonGroup", cfg.daemongroup, 0, 33, 0},
56 {"TimeSyncWait", 0, &cfg.timesyncwait, 0, 0},
57 {"UpdateInterval", 0, &cfg.updateinterval, 0, 0},
58 {"PollInterval", 0, &cfg.pollinterval, 0, 0},
59 {"SaveInterval", 0, &cfg.saveinterval, 0, 0},
60 {"OfflineSaveInterval", 0, &cfg.offsaveinterval, 0, 0},
61 {"RescanDatabaseOnSave", 0, &cfg.rescanonsave, 0, 0},
62 {"AlwaysAddNewInterfaces", 0, &cfg.alwaysadd, 0, 0},
63 {"BandwidthDetectionInterval", 0, &cfg.bwdetectioninterval, 0, 0},
64 {"SaveOnStatusChange", 0, &cfg.savestatus, 0, 0},
65 {"UseLogging", 0, &cfg.uselogging, 0, 0},
66 {"CreateDirs", 0, &cfg.createdirs, 0, 0},
67 {"UpdateFileOwner", 0, &cfg.updatefileowner, 0, 0},
68 {"LogFile", cfg.logfile, 0, 512, 0},
69 {"PidFile", cfg.pidfile, 0, 512, 0},
70 {"64bitInterfaceCounters", 0, &cfg.is64bit, 0, 0},
71 {"DatabaseWriteAheadLogging", 0, &cfg.waldb, 0, 0},
72 {"DatabaseSynchronous", 0, &cfg.dbsynchronous, 0, 0},
73 {"UseUTC", 0, &cfg.useutc, 0, 0},
74 {"HeaderFormat", cfg.hformat, 0, 64, 0},
75 {"HourlyRate", 0, &cfg.hourlyrate, 0, 0},
76 {"SummaryRate", 0, &cfg.summaryrate, 0, 0},
77 {"TransparentBg", 0, &cfg.transbg, 0, 0},
78 {"LargeFonts", 0, &cfg.largefonts, 0, 0},
79 {"LineSpacingAdjustment", 0, &cfg.linespaceadjust, 0, 0},
80 {"ImageScale", 0, &cfg.imagescale, 0, 0},
81 {"5MinuteGraphResultCount", 0, &cfg.fivegresultcount, 0, 0},
82 {"5MinuteGraphHeight", 0, &cfg.fivegheight, 0, 0},
83 {"HourlyGraphMode", 0, &cfg.hourlygmode, 0, 0},
84 {"SummaryGraph", 0, &cfg.summarygraph, 0, 0},
85 {"EstimateStyle", 0, &cfg.estimatestyle, 0, 0},
86 {"BarColumnShowsRate", 0, &cfg.barshowsrate, 0, 0},
87 {"CBackground", cfg.cbg, 0, 8, 0},
88 {"CEdge", cfg.cedge, 0, 8, 0},
89 {"CHeader", cfg.cheader, 0, 8, 0},
90 {"CHeaderTitle", cfg.cheadertitle, 0, 8, 0},
91 {"CHeaderDate", cfg.cheaderdate, 0, 8, 0},
92 {"CText", cfg.ctext, 0, 8, 0},
93 {"CLine", cfg.cline, 0, 8, 0},
94 {"CLineL", cfg.clinel, 0, 8, 0},
95 {"CRx", cfg.crx, 0, 8, 0},
96 {"CRxD", cfg.crxd, 0, 8, 0},
97 {"CTx", cfg.ctx, 0, 8, 0},
98 {"CTxD", cfg.ctxd, 0, 8, 0},
99 {"Experimental", 0, &cfg.experimental, 0, 0},
100 {0, 0, 0, 0, 0}};
101
102 /* load default config */
103 defaultcfg();
104
105 i = opencfgfile(cfgfile, &fd);
106 if (i != 2)
107 return i;
108
109 rewind(fd);
110
111 /* parse every config file line */
112 while (!feof(fd)) {
113
114 cfgline[0] = '\0';
115 if (fgets(cfgline, 512, fd) == NULL) {
116 break;
117 }
118
119 linelen = (unsigned int)strlen(cfgline);
120 if (linelen <= 2 || cfgline[0] == '#' || cfgline[0] == ';') {
121 continue;
122 }
123
124 for (i = 0; cset[i].name != 0; i++) {
125
126 if (cset[i].found) {
127 continue;
128 }
129
130 cfglen = (unsigned int)strlen(cset[i].name);
131 if ((linelen < (cfglen + 2)) || (strncasecmp(cfgline, cset[i].name, cfglen) != 0)) {
132 continue;
133 }
134
135 if (!extractcfgvalue(value, 512, cfgline, cfglen)) {
136 if (debug)
137 printf(" c: %s -> \"%s\" with no value, keeping default.\n", cfgline, cset[i].name);
138 cset[i].found = 1;
139 break;
140 }
141
142 if (!setcfgvalue(&cset[i], value, cfgline)) {
143 continue;
144 }
145
146 cset[i].found = 1;
147 break;
148 }
149
150 if ((debug) && (!cset[i].found) && (strncasecmp(cfgline, "MaxBW", 5) != 0))
151 printf("Unknown configuration line: %s", cfgline);
152 }
153
154 fclose(fd);
155
156 /* validate config */
157 validatecfg(type);
158
159 return 1;
160}
161
162void validatebool(const char *cfgname, int32_t *cfgptr, const int32_t defaultvalue)
163{
164 validateint(cfgname, cfgptr, defaultvalue, 0, 1);
165}
166
167void validateint(const char *cfgname, int32_t *cfgptr, const int32_t defaultvalue, const int32_t minvalue, const int32_t maxvalue)
168{
169 if (maxvalue > minvalue) {
170 if (*cfgptr < minvalue || *cfgptr > maxvalue) {
171 snprintf(errorstring, 1024, "Invalid value \"%d\" for %s. Value needs to be between %d and %d. Using default value %d.", *cfgptr, cfgname, minvalue, maxvalue, defaultvalue);
173 *cfgptr = defaultvalue;
174 }
175 } else {
176 if (*cfgptr < minvalue) {
177 snprintf(errorstring, 1024, "Invalid value \"%d\" for %s. Value needs to be at least %d. Using default value %d.", *cfgptr, cfgname, minvalue, defaultvalue);
179 *cfgptr = defaultvalue;
180 }
181 }
182}
183
184void validatecfg(const ConfigType type)
185{
186 uint32_t rolloversecs;
187 const char *invalidvalue = "Invalid value for";
188 const char *resettingto = "using default value";
189 const char *noslashstart = "doesn't start with \"/\", using default value instead.";
190
191 validateint("UnitMode", &cfg.unitmode, UNITMODE, 0, 2);
192 validatebool("RateUnitMode", &cfg.rateunitmode, RATEUNITMODE);
193 validateint("OutputStyle", &cfg.ostyle, OSTYLE, 0, 3);
194 validatebool("EstimateBarVisible", &cfg.estimatebarvisible, ESTIMATEBARVISIBLE);
195 validateint("DefaultDecimals", &cfg.defaultdecimals, DEFAULTDECIMALS, 0, 2);
196 validateint("HourlyDecimals", &cfg.hourlydecimals, HOURLYDECIMALS, 0, 2);
197 validateint("HourlySectionStyle", &cfg.hourlystyle, HOURLYSTYLE, 0, 3);
198 validateint("BootVariation", &cfg.bvar, BVAR, 0, 300);
199 validateint("Sampletime", &cfg.sampletime, DEFSAMPTIME, 2, 600);
200 validateint("MonthRotate", &cfg.monthrotate, MONTHROTATE, 1, 28);
201 validatebool("MonthRotateAffectsYears", &cfg.monthrotateyears, MONTHROTATEYEARS);
202 validateint("MaxBandwidth", &cfg.maxbw, DEFMAXBW, 0, BWMAX);
203 validatebool("CheckDiskSpace", &cfg.spacecheck, USESPACECHECK);
204 validateint("TimeSyncWait", &cfg.timesyncwait, TIMESYNCWAIT, 0, 60);
205 validateint("PollInterval", &cfg.pollinterval, POLLINTERVAL, 2, 60);
206 validatebool("SaveOnStatusChange", &cfg.savestatus, SAVESTATUS);
207 validateint("UseLogging", &cfg.uselogging, USELOGGING, 0, 2);
208 validateint("CreateDirs", &cfg.createdirs, CREATEDIRS, 0, 2);
209 validateint("UpdateFileOwner", &cfg.updatefileowner, UPDATEFILEOWNER, 0, 2);
210 validateint("64bitInterfaceCounters", &cfg.is64bit, IS64BIT, -2, 1);
211 validatebool("DatabaseWriteAheadLogging", &cfg.waldb, WALDB);
212 validateint("DatabaseSynchronous", &cfg.dbsynchronous, DBSYNCHRONOUS, -1, 3);
213 validatebool("UseUTC", &cfg.useutc, USEUTC);
214 if (type == CT_Image || type == CT_All) {
215 validatebool("TransparentBg", &cfg.transbg, TRANSBG);
216 validatebool("LargeFonts", &cfg.largefonts, LARGEFONTS);
217 validateint("LineSpacingAdjustment", &cfg.linespaceadjust, LINESPACEADJUST, -5, 10);
218 validateint("ImageScale", &cfg.imagescale, IMAGESCALE, 50, 500);
219 validateint("5MinuteGraphResultCount", &cfg.fivegresultcount, FIVEGRESULTCOUNT, FIVEGMINRESULTCOUNT, 2000);
220 validateint("5MinuteGraphHeight", &cfg.fivegheight, FIVEGHEIGHT, FIVEGMINHEIGHT, 2000);
221 validateint("HourlyGraphMode", &cfg.hourlygmode, HOURLYGMODE, 0, 1);
222 validatebool("SummaryGraph", &cfg.summarygraph, SUMMARYGRAPH);
223 validateint("EstimateStyle", &cfg.estimatestyle, ESTIMATESTYLE, 0, 2);
224 validatebool("BarColumnShowsRate", &cfg.barshowsrate, BARSHOWSRATE);
225 validatebool("HourlyRate", &cfg.hourlyrate, HOURLYRATE);
226 validatebool("SummaryRate", &cfg.summaryrate, SUMMARYRATE);
227 }
228 validatebool("TrafficlessEntries", &cfg.trafficlessentries, TRAFFICLESSENTRIES);
229 validateint("List5Mins", &cfg.listfivemins, LISTFIVEMINS, 0, 0);
230 validateint("ListHours", &cfg.listhours, LISTHOURS, 0, 0);
231 validateint("ListDays", &cfg.listdays, LISTDAYS, 0, 0);
232 validateint("ListMonths", &cfg.listmonths, LISTMONTHS, 0, 0);
233 validateint("ListYears", &cfg.listyears, LISTYEARS, 0, 0);
234 validateint("ListTop", &cfg.listtop, LISTTOP, 0, 0);
235 validateint("InterfaceMatchMethod", &cfg.ifacematchmethod, IFACEMATCHMETHOD, 0, 3);
236 validateint("5MinuteHours", &cfg.fiveminutehours, FIVEMINUTEHOURS, -1, -1);
237 validateint("HourlyDays", &cfg.hourlydays, HOURLYDAYS, -1, -1);
238 validateint("DailyDays", &cfg.dailydays, DAILYDAYS, -1, -1);
239 validateint("MonthlyMonths", &cfg.monthlymonths, MONTHLYMONTHS, -1, -1);
240 validateint("YearlyYears", &cfg.yearlyyears, YEARLYYEARS, -1, -1);
241 validateint("TopDayEntries", &cfg.topdayentries, TOPDAYENTRIES, -1, -1);
242 validatebool("BandwidthDetection", &cfg.bwdetection, BWDETECT);
243 validateint("BandwidthDetectionInterval", &cfg.bwdetectioninterval, BWDETECTINTERVAL, 0, 30);
244 validatebool("Experimental", &cfg.experimental, 0);
245
246 if (cfg.useutc) {
247 strncpy_nt(cfg.dbtzmodifier, "", 14);
248 } else {
250 }
251
252 if (cfg.dbdir[0] != '/') {
254 snprintf(errorstring, 1024, "DatabaseDir %s", noslashstart);
256 }
257
258 if (cfg.logfile[0] != '/') {
260 snprintf(errorstring, 1024, "LogFile %s", noslashstart);
262 }
263
264 if (cfg.pidfile[0] != '/') {
266 snprintf(errorstring, 1024, "PidFile %s", noslashstart);
268 }
269
270 if (type == CT_Daemon || type == CT_All) {
271 validatebool("RescanDatabaseOnSave", &cfg.rescanonsave, RESCANONSAVE);
272 validatebool("AlwaysAddNewInterfaces", &cfg.alwaysadd, ALWAYSADD);
273
277 } else {
279 }
280 snprintf(errorstring, 1024, "%s UpdateInterval, %s %d.", invalidvalue, resettingto, cfg.updateinterval);
282 }
283
284 if ((cfg.saveinterval * 60) < cfg.updateinterval || cfg.saveinterval > 60) {
285 if (cfg.updateinterval > (SAVEINTERVAL * 60)) {
287 } else {
289 }
290 snprintf(errorstring, 1024, "%s SaveInterval, %s %d.", invalidvalue, resettingto, cfg.saveinterval);
292 }
293
297 } else {
299 }
300 snprintf(errorstring, 1024, "%s OfflineSaveInterval, %s %d.", invalidvalue, resettingto, cfg.offsaveinterval);
302 }
303
304 /* enforce update interval to be short enough that 32-bit interface counter rollover can be detected */
305 /* 1.02 is the same 2% safety buffer as used in processifinfo() in daemon.c */
306 if (cfg.maxbw > 0) {
307 rolloversecs = (uint32_t)((float)MAX32 / ((float)cfg.maxbw * 1024 * 1024 * (float)1.02 / 8));
308 if (rolloversecs <= (uint32_t)cfg.updateinterval) {
310 if (rolloversecs <= (uint32_t)cfg.updateinterval) {
311 cfg.updateinterval /= 2;
312 }
313 snprintf(errorstring, 1024, "UpdateInterval has been reset to %d seconds in order to ensure correct counter rollover detection at %d Mbit.", cfg.updateinterval, cfg.maxbw);
315 }
316 }
317 }
318
319 /* affects only image output */
320 if (type == CT_Image || type == CT_All) {
322 cfg.estimatestyle = 0;
323 if (debug) {
324 printf("BarColumnShowsRate and EstimateBarVisible both enabled -> EstimateStyle set to 0\n");
325 }
326 }
327
330 snprintf(errorstring, 1024, "Value \"%d\" for 5MinuteHours is too small for 5MinuteGraphResultCount with value \"%d\" (smallest supported value: %d). Value for 5MinuteHours needs to be at least %d if 5MinuteGraphResultCount is set to %d.", cfg.fiveminutehours, cfg.fivegresultcount, FIVEGMINRESULTCOUNT, FIVEGMINRESULTCOUNT / 12, FIVEGMINRESULTCOUNT);
332 } else {
333 snprintf(errorstring, 1024, "5MinuteGraphResultCount has been adjusted to %d because requested \"%d\" requires more data than can be available with value %d for 5MinuteHours.", cfg.fiveminutehours * 12, cfg.fivegresultcount, cfg.fiveminutehours);
335 }
337 }
338 }
339}
340
341void defaultcfg(void)
342{
343 ifacebw = NULL;
344
345 cfg.bvar = BVAR;
352 cfg.ostyle = OSTYLE;
367
375
382
395
396 cfg.daemonuser[0] = '\0';
397 cfg.daemongroup[0] = '\0';
412 cfg.waldb = WALDB;
414 cfg.useutc = USEUTC;
415
434 strncpy_nt(cfg.crx, CRX, 8);
435 strncpy_nt(cfg.crxd, CRXD, 8);
436 strncpy_nt(cfg.ctx, CTX, 8);
437 strncpy_nt(cfg.ctxd, CTXD, 8);
438
440 cfg.experimental = 0;
441}
442
443int opencfgfile(const char *cfgfile, FILE **fd)
444{
445 char buffer[512];
446 int i, tryhome;
447
448 /* clear buffer */
449 for (i = 0; i < 512; i++) {
450 buffer[i] = '\0';
451 }
452 cfg.cfgfile[0] = '\0';
453
454 /* possible config files: 1) --config 2) $HOME/.vnstatrc 3) /etc/vnstat.conf 4) none */
455
456 if (cfgfile[0] != '\0') {
457
458 /* try to open given file */
459 if ((*fd = fopen(cfgfile, "r")) != NULL) {
460 strncpy_nt(cfg.cfgfile, cfgfile, 512);
461 if (debug)
462 printf("Config file: --config\n");
463 } else {
464 snprintf(errorstring, 1024, "Unable to open given config file \"%s\": %s", cfgfile, strerror(errno));
466 return 0;
467 }
468
469 } else {
470
471 if (getenv("HOME")) {
472 strncpy_nt(buffer, getenv("HOME"), 500);
473 strcat(buffer, "/.vnstatrc");
474 tryhome = 1;
475 } else {
476 tryhome = 0;
477 }
478
479 /* try to open first available config file */
480 if (tryhome && (*fd = fopen(buffer, "r")) != NULL) {
481 strncpy_nt(cfg.cfgfile, buffer, 512);
482 } else if ((*fd = fopen("/etc/vnstat.conf", "r")) != NULL) {
483 snprintf(cfg.cfgfile, 512, "/etc/vnstat.conf");
484 } else if ((*fd = fopen("/usr/local/etc/vnstat.conf", "r")) != NULL) {
485 snprintf(cfg.cfgfile, 512, "/usr/local/etc/vnstat.conf");
486 } else {
487 if (debug)
488 printf("Config file: none\n");
489 return 1;
490 }
491 if (debug)
492 printf("Config file: %s\n", cfg.cfgfile);
493 }
494
495 return 2;
496}
497
498int extractcfgvalue(char *value, const unsigned int valuelen, const char *cfgline, const unsigned int cfglen)
499{
500
501 unsigned int i, j, linelen;
502
503 linelen = (unsigned int)strlen(cfgline);
504
505 for (i = 0; i < valuelen; i++) {
506 value[i] = '\0';
507 }
508
509 i = 0;
510 for (j = cfglen; j < linelen; j++) {
511 if (cfgline[j] == '\n' || cfgline[j] == '\r') {
512 break;
513 } else if (cfgline[j] == '\"') {
514 if (i == 0) {
515 continue;
516 } else {
517 break;
518 }
519 } else {
520 if (i == 0 && (cfgline[j] == ' ' || cfgline[j] == '=' || cfgline[j] == '\t')) {
521 continue;
522 } else {
523 value[i] = cfgline[j];
524 i++;
525 }
526 }
527 }
528
529 return (int)strlen(value);
530}
531
532int setcfgvalue(const struct cfgsetting *cset, const char *value, const char *cfgline)
533{
534 if (cset->namelen > 0) {
535 strncpy_nt(cset->locc, value, (size_t)cset->namelen);
536 if (debug)
537 printf(" c: %s -> \"%s\": \"%s\"\n", cfgline, cset->name, cset->locc);
538 } else if ((strlen(value) > 1 && isdigit(value[1])) || isdigit(value[0])) {
539 *cset->loci = (int32_t)strtol(value, (char **)NULL, 0);
540 if (debug)
541 printf(" i: %s -> \"%s\": %d\n", cfgline, cset->name, *cset->loci);
542 } else {
543 return 0;
544 }
545
546 return 1;
547}
548
549void configlocale(void)
550{
551 const char *env = getenv("LC_ALL");
552
553 if (cfg.locale[0] != '-' && strlen(cfg.locale) > 0) {
554 setlocale(LC_ALL, cfg.locale);
555 } else {
556 if (env) {
557 setlocale(LC_ALL, env);
558 } else {
559 setlocale(LC_ALL, "");
560 }
561 }
562 if (env) {
563 if (strstr(env, "UTF") != NULL) {
564 cfg.utflocale = 1;
565 } else {
566 cfg.utflocale = 0;
567 }
568 }
569}
void validateint(const char *cfgname, int32_t *cfgptr, const int32_t defaultvalue, const int32_t minvalue, const int32_t maxvalue)
Definition: cfg.c:167
int extractcfgvalue(char *value, const unsigned int valuelen, const char *cfgline, const unsigned int cfglen)
Definition: cfg.c:498
void validatecfg(const ConfigType type)
Definition: cfg.c:184
void validatebool(const char *cfgname, int32_t *cfgptr, const int32_t defaultvalue)
Definition: cfg.c:162
void configlocale(void)
Definition: cfg.c:549
int opencfgfile(const char *cfgfile, FILE **fd)
Definition: cfg.c:443
void defaultcfg(void)
Definition: cfg.c:341
int loadcfg(const char *cfgfile, const ConfigType type)
Definition: cfg.c:4
int setcfgvalue(const struct cfgsetting *cset, const char *value, const char *cfgline)
Definition: cfg.c:532
ConfigType
Definition: cfg.h:12
@ CT_Image
Definition: cfg.h:16
@ CT_Daemon
Definition: cfg.h:15
@ CT_All
Definition: cfg.h:13
ibwnode * ifacebw
Definition: common.c:7
char errorstring[1024]
Definition: common.c:6
int printe(const PrintType type)
Definition: common.c:14
int debug
Definition: common.c:8
CFG cfg
Definition: common.c:4
char * strncpy_nt(char *dest, const char *src, size_t n)
Definition: common.c:253
#define DEFIFACE
Definition: common.h:132
#define CREATEDIRS
Definition: common.h:241
#define DFORMAT
Definition: common.h:83
#define UNITMODE
Definition: common.h:100
#define USEUTC
Definition: common.h:250
#define USESPACECHECK
Definition: common.h:166
#define CBACKGROUND
Definition: common.h:287
#define CRXD
Definition: common.h:296
#define ESTIMATESTYLE
Definition: common.h:269
#define ESTIMATEBARVISIBLE
Definition: common.h:111
#define CTEXT
Definition: common.h:292
#define CRX
Definition: common.h:295
#define MAX32
Definition: common.h:214
#define LARGEFONTS
Definition: common.h:259
#define BVAR
Definition: common.h:163
#define LISTJSONXML
Definition: common.h:178
#define RXCHAR
Definition: common.h:93
#define DATABASEDIR
Definition: common.h:67
#define YEARLYYEARS
Definition: common.h:185
#define RESCANONSAVE
Definition: common.h:237
#define LINESPACEADJUST
Definition: common.h:262
#define DEFMAXBW
Definition: common.h:144
#define LISTFIVEMINS
Definition: common.h:172
#define FIVEMINUTEHOURS
Definition: common.h:181
#define UTFLOCALE
Definition: common.h:189
#define MONTHROTATEYEARS
Definition: common.h:79
#define TRANSBG
Definition: common.h:256
#define SAVESTATUS
Definition: common.h:239
#define IFACEMATCHMETHOD
Definition: common.h:160
#define DAILYDAYS
Definition: common.h:183
#define LISTDAYS
Definition: common.h:174
#define TRAFFICLESSENTRIES
Definition: common.h:169
#define USELOGGING
Definition: common.h:240
#define IMAGESCALE
Definition: common.h:265
#define SUMMARYGRAPH
Definition: common.h:284
#define TXCHAR
Definition: common.h:94
#define CTX
Definition: common.h:297
#define POLLINTERVAL
Definition: common.h:234
#define CLINEL
Definition: common.h:294
#define SUMMARYRATE
Definition: common.h:114
#define UPDATEINTERVAL
Definition: common.h:232
#define HOURLYGMODE
Definition: common.h:281
#define CTXD
Definition: common.h:298
#define HFORMAT
Definition: common.h:86
#define LOGFILE
Definition: common.h:243
#define CHEADERTITLE
Definition: common.h:290
#define DATABASELOCALTIMEMODIFIER
Definition: common.h:75
#define RXHOURCHAR
Definition: common.h:95
#define CHEADERDATE
Definition: common.h:291
#define MONTHLYMONTHS
Definition: common.h:184
#define TOPDAYENTRIES
Definition: common.h:186
#define DBSYNCHRONOUS
Definition: common.h:249
#define HOURLYDAYS
Definition: common.h:182
@ PT_Error
Definition: common.h:353
@ PT_Config
Definition: common.h:354
#define HOURLYSTYLE
Definition: common.h:128
#define MONTHROTATE
Definition: common.h:78
#define IS64BIT
Definition: common.h:245
#define OSTYLE
Definition: common.h:110
#define TXHOURCHAR
Definition: common.h:96
#define WALDB
Definition: common.h:246
#define LISTHOURS
Definition: common.h:173
#define FIVEGHEIGHT
Definition: common.h:276
#define BWDETECT
Definition: common.h:139
#define SAVEINTERVAL
Definition: common.h:235
#define FIVEGMINRESULTCOUNT
Definition: common.h:277
#define TIMESYNCWAIT
Definition: common.h:233
#define DEFSAMPTIME
Definition: common.h:150
#define RATEUNIT
Definition: common.h:121
#define MFORMAT
Definition: common.h:84
#define FIVEGMINHEIGHT
Definition: common.h:278
#define BWMAX
Definition: common.h:147
#define LISTYEARS
Definition: common.h:176
#define RATEUNITMODE
Definition: common.h:104
#define LOCALE
Definition: common.h:136
#define HOURLYDECIMALS
Definition: common.h:125
#define UPDATEFILEOWNER
Definition: common.h:242
#define CEDGE
Definition: common.h:288
#define CLINE
Definition: common.h:293
#define FIVEGRESULTCOUNT
Definition: common.h:275
#define HOURLYRATE
Definition: common.h:117
#define DEFAULTDECIMALS
Definition: common.h:124
#define TFORMAT
Definition: common.h:85
#define DEFQMODE
Definition: common.h:155
#define BARSHOWSRATE
Definition: common.h:272
#define LISTTOP
Definition: common.h:177
#define CHEADER
Definition: common.h:289
#define BWDETECTINTERVAL
Definition: common.h:140
#define LISTMONTHS
Definition: common.h:175
#define PIDFILE
Definition: common.h:244
#define ALWAYSADD
Definition: common.h:238
#define OFFSAVEINTERVAL
Definition: common.h:236
int32_t bwdetectioninterval
Definition: common.h:322
int32_t monthrotateyears
Definition: common.h:315
int32_t summarygraph
Definition: common.h:318
char cedge[8]
Definition: common.h:312
int32_t listfivemins
Definition: common.h:324
int32_t listtop
Definition: common.h:324
int32_t dailydays
Definition: common.h:323
int32_t estimatestyle
Definition: common.h:317
char ctext[8]
Definition: common.h:312
int32_t listjsonxml
Definition: common.h:324
char tformat[64]
Definition: common.h:307
int32_t alwaysadd
Definition: common.h:318
char mformat[64]
Definition: common.h:307
int32_t monthrotate
Definition: common.h:315
char cheadertitle[8]
Definition: common.h:312
char dformat[64]
Definition: common.h:307
int32_t imagescale
Definition: common.h:316
char iface[32]
Definition: common.h:308
char dbdir[512]
Definition: common.h:310
int32_t defaultdecimals
Definition: common.h:316
char locale[32]
Definition: common.h:309
int32_t yearlyyears
Definition: common.h:323
char pidfile[512]
Definition: common.h:319
char daemonuser[33]
Definition: common.h:320
int32_t saveinterval
Definition: common.h:321
int32_t trafficlessentries
Definition: common.h:315
int32_t rateunitmode
Definition: common.h:314
int32_t transbg
Definition: common.h:315
int32_t listmonths
Definition: common.h:324
char cbg[8]
Definition: common.h:312
int32_t linespaceadjust
Definition: common.h:317
int32_t fivegheight
Definition: common.h:318
int32_t rescanonsave
Definition: common.h:321
char rxhourchar[2]
Definition: common.h:311
int32_t updateinterval
Definition: common.h:321
char ctx[8]
Definition: common.h:313
int32_t summaryrate
Definition: common.h:314
int32_t ifacematchmethod
Definition: common.h:314
int32_t hourlydays
Definition: common.h:323
int32_t spacecheck
Definition: common.h:315
int32_t hourlydecimals
Definition: common.h:316
char daemongroup[33]
Definition: common.h:320
int32_t createdirs
Definition: common.h:322
int32_t bvar
Definition: common.h:314
char rxchar[2]
Definition: common.h:311
char hformat[64]
Definition: common.h:307
char txchar[2]
Definition: common.h:311
int32_t dbsynchronous
Definition: common.h:316
int32_t sampletime
Definition: common.h:314
int32_t utflocale
Definition: common.h:322
int32_t useutc
Definition: common.h:316
int32_t fiveminutehours
Definition: common.h:323
int32_t waldb
Definition: common.h:316
int32_t unitmode
Definition: common.h:314
int32_t bwdetection
Definition: common.h:322
int32_t savestatus
Definition: common.h:321
int32_t pollinterval
Definition: common.h:321
char ctxd[8]
Definition: common.h:313
int32_t qmode
Definition: common.h:314
int32_t ostyle
Definition: common.h:315
int32_t hourlyrate
Definition: common.h:314
char cline[8]
Definition: common.h:313
int32_t timesyncwait
Definition: common.h:321
char dbtzmodifier[14]
Definition: common.h:310
int32_t maxbw
Definition: common.h:315
int32_t uselogging
Definition: common.h:322
int32_t experimental
Definition: common.h:325
int32_t largefonts
Definition: common.h:317
int32_t is64bit
Definition: common.h:316
int32_t listdays
Definition: common.h:324
int32_t hourlystyle
Definition: common.h:316
int32_t listyears
Definition: common.h:324
char txhourchar[2]
Definition: common.h:311
int32_t fivegresultcount
Definition: common.h:317
int32_t hourlygmode
Definition: common.h:318
int32_t barshowsrate
Definition: common.h:317
char cheader[8]
Definition: common.h:312
char clinel[8]
Definition: common.h:313
int32_t timestampprints
Definition: common.h:325
char logfile[512]
Definition: common.h:319
int32_t updatefileowner
Definition: common.h:322
char crx[8]
Definition: common.h:313
int32_t offsaveinterval
Definition: common.h:321
int32_t estimatebarvisible
Definition: common.h:317
int32_t monthlymonths
Definition: common.h:323
int32_t listhours
Definition: common.h:324
char cheaderdate[8]
Definition: common.h:312
char cfgfile[512]
Definition: common.h:319
int32_t rateunit
Definition: common.h:314
int32_t topdayentries
Definition: common.h:323
char crxd[8]
Definition: common.h:313
Definition: cfg.h:4
char * locc
Definition: cfg.h:6
int32_t * loci
Definition: cfg.h:7
const char * name
Definition: cfg.h:5
short found
Definition: cfg.h:9
short namelen
Definition: cfg.h:8