"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/vnstat_func.c" between
vnstat-2.7.tar.gz and vnstat-2.8.tar.gz

About: vnStat is a console-based network traffic monitor (using the /proc filesystem).

vnstat_func.c  (vnstat-2.7):vnstat_func.c  (vnstat-2.8)
skipping to change at line 144 skipping to change at line 144
/* parse parameters, maybe not the best way but... */ /* parse parameters, maybe not the best way but... */
for (currentarg = 1; currentarg < argc; currentarg++) { for (currentarg = 1; currentarg < argc; currentarg++) {
if (debug) if (debug)
printf("arg %d: \"%s\"\n", currentarg, argv[currentarg]); printf("arg %d: \"%s\"\n", currentarg, argv[currentarg]);
if (strcmp(argv[currentarg], "--longhelp") == 0) { if (strcmp(argv[currentarg], "--longhelp") == 0) {
showlonghelp(p); showlonghelp(p);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} else if ((strcmp(argv[currentarg], "-?") == 0) || (strcmp(argv[ currentarg], "--help") == 0)) { } else if ((strcmp(argv[currentarg], "-?") == 0) || (strcmp(argv[ currentarg], "--help") == 0)) {
showhelp(p); showhelp(p);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} else if ((strcmp(argv[currentarg], "-i") == 0) || (strcmp(argv[ currentarg], "--iface") == 0)) { } else if ((strcmp(argv[currentarg], "-i") == 0) || (strcmp(argv[ currentarg], "--iface") == 0) || (strcmp(argv[currentarg], "--interface") == 0)) {
if (currentarg + 1 < argc) { if (currentarg + 1 < argc) {
if (strlen(argv[currentarg + 1]) > 31) { if (strlen(argv[currentarg + 1]) > 31) {
printf("Error: Interface name is limited to 31 characters.\n"); printf("Error: Interface name is limited to 31 characters.\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
strncpy_nt(p->interface, argv[currentarg + 1], 32 ); strncpy_nt(p->interface, argv[currentarg + 1], 32 );
if (strlen(p->interface)) { if (strlen(p->interface)) {
p->defaultiface = 0; p->defaultiface = 0;
} else { } else {
strncpy_nt(p->definterface, p->interface, 32); strncpy_nt(p->definterface, p->interface, 32);
skipping to change at line 184 skipping to change at line 184
p->setalias = 1; p->setalias = 1;
currentarg++; currentarg++;
} else { } else {
printf("Error: Alias for %s missing.\n", argv[cur rentarg]); printf("Error: Alias for %s missing.\n", argv[cur rentarg]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} else if ((strcmp(argv[currentarg], "--style")) == 0) { } else if ((strcmp(argv[currentarg], "--style")) == 0) {
if (currentarg + 1 < argc && isdigit(argv[currentarg + 1] [0])) { if (currentarg + 1 < argc && isdigit(argv[currentarg + 1] [0])) {
cfg.ostyle = atoi(argv[currentarg + 1]); cfg.ostyle = atoi(argv[currentarg + 1]);
if (cfg.ostyle > 4 || cfg.ostyle < 0) { if (cfg.ostyle > 4 || cfg.ostyle < 0) {
printf("Error: Invalid style parameter \" printf("Error: Invalid style parameter \"
%d\" for --style.\n", cfg.ostyle); %d\"\n", cfg.ostyle);
printf(" Valid parameters:\n"); showstylehelp();
printf(" 0 - a more narrow output\n");
printf(" 1 - enable bar column if avai
lable\n");
printf(" 2 - average traffic rate in s
ummary output\n");
printf(" 3 - average traffic rate in a
ll outputs if available\n");
printf(" 4 - disable terminal control
characters in -l / --live\n");
printf(" and show raw values in --
oneline\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (debug) if (debug)
printf("Style changed: %d\n", cfg.ostyle) ; printf("Style changed: %d\n", cfg.ostyle) ;
currentarg++; currentarg++;
} else { } else {
printf("Error: Style parameter for --style missin g.\n"); printf("Error: Style parameter for --style missin g.\n");
printf(" Valid parameters:\n"); showstylehelp();
printf(" 0 - a more narrow output\n");
printf(" 1 - enable bar column if available\n"
);
printf(" 2 - average traffic rate in summary o
utput\n");
printf(" 3 - average traffic rate in all outpu
ts if available\n");
printf(" 4 - disable terminal control characte
rs in -l / --live\n");
printf(" and show raw values in --oneline\
n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} else if ((strcmp(argv[currentarg], "--dbdir")) == 0) { } else if ((strcmp(argv[currentarg], "--dbdir")) == 0) {
if (currentarg + 1 < argc) { if (currentarg + 1 < argc) {
strncpy_nt(cfg.dbdir, argv[currentarg + 1], 512); strncpy_nt(cfg.dbdir, argv[currentarg + 1], 512);
if (debug) if (debug)
printf("DatabaseDir: \"%s\"\n", cfg.dbdir ); printf("DatabaseDir: \"%s\"\n", cfg.dbdir );
currentarg++; currentarg++;
} else { } else {
printf("Error: Directory for %s missing.\n", argv [currentarg]); printf("Error: Directory for %s missing.\n", argv [currentarg]);
skipping to change at line 304 skipping to change at line 292
if (currentarg + 1 < argc && isdigit(argv[currentarg + 1] [0])) { if (currentarg + 1 < argc && isdigit(argv[currentarg + 1] [0])) {
cfg.listfivemins = atoi(argv[currentarg + 1]); cfg.listfivemins = atoi(argv[currentarg + 1]);
if (cfg.listfivemins < 0) { if (cfg.listfivemins < 0) {
printf("Error: Invalid limit parameter \" %s\" for %s. Only a zero and positive numbers are allowed.\n", argv[currentarg + 1], argv[currentarg]); printf("Error: Invalid limit parameter \" %s\" for %s. Only a zero and positive numbers are allowed.\n", argv[currentarg + 1], argv[currentarg]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
currentarg++; currentarg++;
} }
} else if (strcmp(argv[currentarg], "--oneline") == 0) { } else if (strcmp(argv[currentarg], "--oneline") == 0) {
cfg.qmode = 9; cfg.qmode = 9;
if (currentarg + 1 < argc && argv[currentarg + 1][0] != ' -') { if (currentarg + 1 < argc && (strlen(argv[currentarg + 1] ) == 1 || ishelprequest(argv[currentarg + 1]))) {
if (argv[currentarg + 1][0] == 'b') { if (argv[currentarg + 1][0] == 'b') {
cfg.ostyle = 4; cfg.ostyle = 4;
currentarg++; currentarg++;
} else { } else {
printf("Error: Invalid mode parameter \"% if (!ishelprequest(argv[currentarg + 1]))
s\" for --oneline.\n", argv[currentarg + 1]); printf("Error: Invalid mode param
printf(" Valid parameters:\n"); eter \"%s\".\n", argv[currentarg + 1]);
printf(" Valid parameters for --oneline:\
n");
printf(" (none) - automatically scaled units visible\n"); printf(" (none) - automatically scaled units visible\n");
printf(" b - all values in bytes\ n"); printf(" b - all values in bytes\ n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
} else if (strcmp(argv[currentarg], "--xml") == 0) { } else if (strcmp(argv[currentarg], "--xml") == 0) {
cfg.qmode = 8; cfg.qmode = 8;
if (currentarg + 1 < argc && argv[currentarg + 1][0] != ' -' && !isdigit(argv[currentarg + 1][0])) { if (currentarg + 1 < argc && (strlen(argv[currentarg + 1] ) == 1 || ishelprequest(argv[currentarg + 1]))) {
p->xmlmode = argv[currentarg + 1][0]; p->xmlmode = argv[currentarg + 1][0];
if (strlen(argv[currentarg + 1]) != 1 || strchr(" afhdmyt", p->xmlmode) == NULL) { if (strlen(argv[currentarg + 1]) != 1 || strchr(" afhdmyt", p->xmlmode) == NULL) {
printf("Error: Invalid mode parameter \"% if (!ishelprequest(argv[currentarg + 1]))
s\" for --xml.\n", argv[currentarg + 1]); printf("Error: Invalid mode param
printf(" Valid parameters:\n"); eter \"%s\".\n", argv[currentarg + 1]);
printf(" Valid parameters for --xml:\n");
printf(" a - all (default)\n"); printf(" a - all (default)\n");
printf(" f - only 5 minutes\n"); printf(" f - only 5 minutes\n");
printf(" h - only hours\n"); printf(" h - only hours\n");
printf(" d - only days\n"); printf(" d - only days\n");
printf(" m - only months\n"); printf(" m - only months\n");
printf(" y - only years\n"); printf(" y - only years\n");
printf(" t - only top\n"); printf(" t - only top\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
currentarg++; currentarg++;
skipping to change at line 344 skipping to change at line 334
if (currentarg + 1 < argc && isdigit(argv[currentarg + 1] [0])) { if (currentarg + 1 < argc && isdigit(argv[currentarg + 1] [0])) {
cfg.listjsonxml = atoi(argv[currentarg + 1]); cfg.listjsonxml = atoi(argv[currentarg + 1]);
if (cfg.listjsonxml < 0) { if (cfg.listjsonxml < 0) {
printf("Error: Invalid limit parameter \" %s\" for %s. Only a zero and positive numbers are allowed.\n", argv[currentarg + 1], argv[currentarg]); printf("Error: Invalid limit parameter \" %s\" for %s. Only a zero and positive numbers are allowed.\n", argv[currentarg + 1], argv[currentarg]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
currentarg++; currentarg++;
} }
} else if (strcmp(argv[currentarg], "--json") == 0) { } else if (strcmp(argv[currentarg], "--json") == 0) {
cfg.qmode = 10; cfg.qmode = 10;
if (currentarg + 1 < argc && argv[currentarg + 1][0] != ' -' && !isdigit(argv[currentarg + 1][0])) { if (currentarg + 1 < argc && (strlen(argv[currentarg + 1] ) == 1 || ishelprequest(argv[currentarg + 1]))) {
p->jsonmode = argv[currentarg + 1][0]; p->jsonmode = argv[currentarg + 1][0];
if (strlen(argv[currentarg + 1]) != 1 || strchr(" afhdmyt", p->jsonmode) == NULL) { if (strlen(argv[currentarg + 1]) != 1 || strchr(" afhdmyt", p->jsonmode) == NULL) {
printf("Error: Invalid mode parameter \"% if (!ishelprequest(argv[currentarg + 1]))
s\" for --json.\n", argv[currentarg + 1]); printf("Error: Invalid mode param
printf(" Valid parameters:\n"); eter \"%s\".\n", argv[currentarg + 1]);
printf(" Valid parameters for --json:\n")
;
printf(" a - all (default)\n"); printf(" a - all (default)\n");
printf(" f - only 5 minutes\n"); printf(" f - only 5 minutes\n");
printf(" h - only hours\n"); printf(" h - only hours\n");
printf(" d - only days\n"); printf(" d - only days\n");
printf(" m - only months\n"); printf(" m - only months\n");
printf(" y - only years\n"); printf(" y - only years\n");
printf(" t - only top\n"); printf(" t - only top\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
currentarg++; currentarg++;
} }
if (currentarg + 1 < argc && isdigit(argv[currentarg + 1] [0])) { if (currentarg + 1 < argc && isdigit(argv[currentarg + 1] [0])) {
cfg.listjsonxml = atoi(argv[currentarg + 1]); cfg.listjsonxml = atoi(argv[currentarg + 1]);
if (cfg.listjsonxml < 0) { if (cfg.listjsonxml < 0) {
printf("Error: Invalid limit parameter \" %s\" for %s. Only a zero and positive numbers are allowed.\n", argv[currentarg + 1], argv[currentarg]); printf("Error: Invalid limit parameter \" %s\" for %s. Only a zero and positive numbers are allowed.\n", argv[currentarg + 1], argv[currentarg]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
currentarg++; currentarg++;
} }
} else if ((strcmp(argv[currentarg], "-ru") == 0) || (strcmp(argv [currentarg], "--rateunit")) == 0) { } else if ((strcmp(argv[currentarg], "-ru") == 0) || (strcmp(argv [currentarg], "--rateunit")) == 0) {
if (currentarg + 1 < argc && isdigit(argv[currentarg + 1] if (currentarg + 1 < argc && (strlen(argv[currentarg + 1]
[0])) { ) == 1 || ishelprequest(argv[currentarg + 1]))) {
cfg.rateunit = atoi(argv[currentarg + 1]); if (!isdigit(argv[currentarg + 1][0]) || atoi(arg
if (cfg.rateunit > 1 || cfg.rateunit < 0) { v[currentarg + 1]) > 1 || atoi(argv[currentarg + 1]) < 0) {
printf("Error: Invalid parameter \"%d\" f if (!ishelprequest(argv[currentarg + 1]))
or --rateunit.\n", cfg.rateunit); printf("Error: Invalid parameter
printf(" Valid parameters:\n"); \"%s\".\n", argv[currentarg + 1]);
printf(" Valid parameters for %s:\n", arg
v[currentarg]);
printf(" 0 - bytes\n"); printf(" 0 - bytes\n");
printf(" 1 - bits\n"); printf(" 1 - bits\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
cfg.rateunit = atoi(argv[currentarg + 1]);
if (debug) if (debug)
printf("Rateunit changed: %d\n", cfg.rate unit); printf("Rateunit changed: %d\n", cfg.rate unit);
currentarg++; currentarg++;
} else { } else {
cfg.rateunit = !cfg.rateunit; cfg.rateunit = !cfg.rateunit;
if (debug) if (debug)
printf("Rateunit changed: %d\n", cfg.rate unit); printf("Rateunit changed: %d\n", cfg.rate unit);
} }
} else if ((strcmp(argv[currentarg], "-tr") == 0) || (strcmp(argv [currentarg], "--traffic") == 0)) { } else if ((strcmp(argv[currentarg], "-tr") == 0) || (strcmp(argv [currentarg], "--traffic") == 0)) {
if (currentarg + 1 < argc && isdigit(argv[currentarg + 1] [0])) { if (currentarg + 1 < argc && isdigit(argv[currentarg + 1] [0])) {
cfg.sampletime = atoi(argv[currentarg + 1]); cfg.sampletime = atoi(argv[currentarg + 1]);
currentarg++; currentarg++;
} }
p->traffic = 1; p->traffic = 1;
p->query = 0; p->query = 0;
} else if ((strcmp(argv[currentarg], "-l") == 0) || (strcmp(argv[ currentarg], "--live") == 0)) { } else if ((strcmp(argv[currentarg], "-l") == 0) || (strcmp(argv[ currentarg], "--live") == 0)) {
if (currentarg + 1 < argc && argv[currentarg + 1][0] != ' -') { if (currentarg + 1 < argc && (strlen(argv[currentarg + 1] ) == 1 || ishelprequest(argv[currentarg + 1]))) {
if (!isdigit(argv[currentarg + 1][0]) || atoi(arg v[currentarg + 1]) > 1 || atoi(argv[currentarg + 1]) < 0) { if (!isdigit(argv[currentarg + 1][0]) || atoi(arg v[currentarg + 1]) > 1 || atoi(argv[currentarg + 1]) < 0) {
printf("Error: Invalid mode parameter \"% if (!ishelprequest(argv[currentarg + 1]))
s\" for -l / --live.\n", argv[currentarg + 1]); printf("Error: Invalid mode param
printf(" Valid parameters:\n"); eter \"%s\".\n", argv[currentarg + 1]);
printf(" Valid parameters for %s:\n", arg
v[currentarg]);
printf(" 0 - show packets per second ( default)\n"); printf(" 0 - show packets per second ( default)\n");
printf(" 1 - show transfer counters\n" ); printf(" 1 - show transfer counters\n" );
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
p->livemode = atoi(argv[currentarg + 1]); p->livemode = atoi(argv[currentarg + 1]);
currentarg++; currentarg++;
} }
p->livetraffic = 1; p->livetraffic = 1;
p->query = 0; p->query = 0;
} else if (strcmp(argv[currentarg], "--force") == 0) { } else if (strcmp(argv[currentarg], "--force") == 0) {
skipping to change at line 453 skipping to change at line 446
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
strncpy_nt(p->dataend, argv[currentarg + 1], 18); strncpy_nt(p->dataend, argv[currentarg + 1], 18);
currentarg++; currentarg++;
} else { } else {
printf("Error: Date of format YYYY-MM-DD HH:MM or YYYY-MM-DD for %s missing.\n", argv[currentarg]); printf("Error: Date of format YYYY-MM-DD HH:MM or YYYY-MM-DD for %s missing.\n", argv[currentarg]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} else if (strcmp(argv[currentarg], "--iflist") == 0) { } else if (strcmp(argv[currentarg], "--iflist") == 0) {
p->query = 0; p->query = 0;
if (currentarg + 1 < argc && argv[currentarg + 1][0] != ' -') { if (currentarg + 1 < argc && (strlen(argv[currentarg + 1] ) == 1 || ishelprequest(argv[currentarg + 1]))) {
if (!isdigit(argv[currentarg + 1][0]) || atoi(arg v[currentarg + 1]) > 1 || atoi(argv[currentarg + 1]) < 0) { if (!isdigit(argv[currentarg + 1][0]) || atoi(arg v[currentarg + 1]) > 1 || atoi(argv[currentarg + 1]) < 0) {
printf("Error: Invalid mode parameter \"% if (!ishelprequest(argv[currentarg + 1]))
s\" for --iflist.\n", argv[currentarg + 1]); printf("Error: Invalid mode param
printf(" Valid parameters:\n"); eter \"%s\".\n", argv[currentarg + 1]);
printf(" Valid parameters for --iflist:\n
");
printf(" 0 - show verbose (default)\n" ); printf(" 0 - show verbose (default)\n" );
printf(" 1 - show one interface per li ne\n"); printf(" 1 - show one interface per li ne\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
p->query = atoi(argv[currentarg + 1]); p->query = atoi(argv[currentarg + 1]);
currentarg++; currentarg++;
} }
showiflist(p->query); showiflist(p->query);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} else if (strcmp(argv[currentarg], "--dbiflist") == 0) { } else if (strcmp(argv[currentarg], "--dbiflist") == 0) {
p->query = 0; p->query = 0;
if (currentarg + 1 < argc && argv[currentarg + 1][0] != ' -') { if (currentarg + 1 < argc && (strlen(argv[currentarg + 1] ) == 1 || ishelprequest(argv[currentarg + 1]))) {
if (!isdigit(argv[currentarg + 1][0]) || atoi(arg v[currentarg + 1]) > 1 || atoi(argv[currentarg + 1]) < 0) { if (!isdigit(argv[currentarg + 1][0]) || atoi(arg v[currentarg + 1]) > 1 || atoi(argv[currentarg + 1]) < 0) {
printf("Error: Invalid mode parameter \"% if (!ishelprequest(argv[currentarg + 1]))
s\" for --dbiflist.\n", argv[currentarg + 1]); printf("Error: Invalid mode param
printf(" Valid parameters:\n"); eter \"%s\".\n", argv[currentarg + 1]);
printf(" Valid parameters for --dbiflist:
\n");
printf(" 0 - show verbose (default)\n" ); printf(" 0 - show verbose (default)\n" );
printf(" 1 - show one interface per li ne\n"); printf(" 1 - show one interface per li ne\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
p->query = atoi(argv[currentarg + 1]); p->query = atoi(argv[currentarg + 1]);
currentarg++; currentarg++;
} }
showdbiflist(p->query); showdbiflist(p->query);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} else if (strcmp(argv[currentarg], "--limit") == 0) { } else if (strcmp(argv[currentarg], "--limit") == 0) {
skipping to change at line 497 skipping to change at line 492
} }
currentarg++; currentarg++;
} else { } else {
printf("Error: Invalid or missing parameter for % s.\n", argv[currentarg]); printf("Error: Invalid or missing parameter for % s.\n", argv[currentarg]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} else if ((strcmp(argv[currentarg], "-v") == 0) || (strcmp(argv[ currentarg], "--version") == 0)) { } else if ((strcmp(argv[currentarg], "-v") == 0) || (strcmp(argv[ currentarg], "--version") == 0)) {
printf("vnStat %s by Teemu Toivola <tst at iki dot fi>\n" , getversion()); printf("vnStat %s by Teemu Toivola <tst at iki dot fi>\n" , getversion());
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} else { } else {
printf("Unknown parameter \"%s\". Use --help for help.\n" if (argv[currentarg][0] == '-' || strlen(argv[currentarg]
, argv[currentarg]); ) == 1) {
exit(EXIT_FAILURE); printf("Unknown parameter \"%s\". Use --help for
help.\n", argv[currentarg]);
exit(EXIT_FAILURE);
} else {
if (strlen(argv[currentarg]) > 31) {
printf("Error: Interface name is limited
to 31 characters.\n");
exit(EXIT_FAILURE);
}
strncpy_nt(p->interface, argv[currentarg], 32);
if (strlen(p->interface)) {
p->defaultiface = 0;
} else {
strncpy_nt(p->definterface, p->interface,
32);
}
if (debug)
printf("Used interface: \"%s\"\n", p->int
erface);
}
} }
} }
if (p->limit != -1) { if (p->limit != -1) {
cfg.listfivemins = cfg.listhours = cfg.listdays = cfg.listmonths = cfg.listyears = cfg.listtop = cfg.listjsonxml = p->limit; cfg.listfivemins = cfg.listhours = cfg.listdays = cfg.listmonths = cfg.listyears = cfg.listtop = cfg.listjsonxml = p->limit;
} }
} }
void showstylehelp(void)
{
printf(" Valid parameters for --style.:\n");
printf(" 0 - a more narrow output\n");
printf(" 1 - enable bar column if available\n");
printf(" 2 - average traffic rate in summary output\n");
printf(" 3 - average traffic rate in all outputs if available\n");
printf(" 4 - disable terminal control characters in -l / --live\n");
printf(" and show raw values in --oneline\n");
}
void handleremoveinterface(PARAMS *p) void handleremoveinterface(PARAMS *p)
{ {
if (!p->removeiface) { if (!p->removeiface) {
return; return;
} }
if (p->defaultiface) { if (p->defaultiface) {
printf("Error: Use -i parameter to specify an interface.\n"); printf("Error: Use -i parameter to specify an interface.\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (!db_getinterfacecountbyname(p->interface)) { if (!db_getinterfacecountbyname(p->interface)) {
printf("Error: Interface \"%s\" not found in database.\n", p->int erface); printf("Error: Interface \"%s\" not found in database.\n", p->int erface);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (!p->force) { if (!p->force) {
printf("Warning:\nThe current option would remove all data\nabout printf("Warning:\nThe current option would remove all data about
interface \"%s\" from the database.\n", p->interface); interface \"%s\" from the database. ", p->interface);
printf("Use --force in order to really do that.\n"); printf("Add --force in order to really do that.\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#ifndef CHECK_VNSTAT #ifndef CHECK_VNSTAT
if (!db_close() || !db_open_rw(0)) { if (!db_close() || !db_open_rw(0)) {
printf("Error: Handling database \"%s/%s\" failing: %s\n", cfg.db dir, DATABASEFILE, strerror(errno)); printf("Error: Handling database \"%s/%s\" failing: %s\n", cfg.db dir, DATABASEFILE, strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#endif #endif
if (db_removeinterface(p->interface)) { if (db_removeinterface(p->interface)) {
printf("Interface \"%s\" removed from database.\n", p->interface) ; printf("Interface \"%s\" removed from database.\n", p->interface) ;
printf("The interface will no longer be monitored. Use --add\n"); printf("The interface will no longer be monitored. Use --add if m
printf("if monitoring the interface is again needed.\n"); onitoring the interface is again needed.\n");
#ifndef CHECK_VNSTAT #ifndef CHECK_VNSTAT
db_close(); db_close();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
#endif #endif
} else { } else {
printf("Error: Removing interface \"%s\" from database failed.\n" , p->interface); printf("Error: Removing interface \"%s\" from database failed.\n" , p->interface);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
skipping to change at line 577 skipping to change at line 597
printf("Error: Interface \"%s\" not found in database.\n", p->int erface); printf("Error: Interface \"%s\" not found in database.\n", p->int erface);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (db_getinterfacecountbyname(p->newifname)) { if (db_getinterfacecountbyname(p->newifname)) {
printf("Error: Interface \"%s\" already exists in database.\n", p ->newifname); printf("Error: Interface \"%s\" already exists in database.\n", p ->newifname);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (!p->force) { if (!p->force) {
printf("Warning:\nThe current option would rename\ninterface \"%s printf("Warning:\nThe current option would rename interface \"%s\
\" -> \"%s\" in the database.\n", p->interface, p->newifname); " -> \"%s\" in the database. ", p->interface, p->newifname);
printf("Use --force in order to really do that.\n"); printf("Add --force in order to really do that.\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#ifndef CHECK_VNSTAT #ifndef CHECK_VNSTAT
if (!db_close() || !db_open_rw(0)) { if (!db_close() || !db_open_rw(0)) {
printf("Error: Handling database \"%s/%s\" failing: %s\n", cfg.db dir, DATABASEFILE, strerror(errno)); printf("Error: Handling database \"%s/%s\" failing: %s\n", cfg.db dir, DATABASEFILE, strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#endif #endif
skipping to change at line 641 skipping to change at line 661
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#ifndef CHECK_VNSTAT #ifndef CHECK_VNSTAT
if (!db_close() || !db_open_rw(0)) { if (!db_close() || !db_open_rw(0)) {
printf("Error: Handling database \"%s/%s\" failing: %s\n", cfg.db dir, DATABASEFILE, strerror(errno)); printf("Error: Handling database \"%s/%s\" failing: %s\n", cfg.db dir, DATABASEFILE, strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#endif #endif
printf("Adding interface \"%s\" for monitoring to database...\n", p->inte rface); printf("Adding interface \"%s\" to database for monitoring.\n", p->interf ace);
if (db_addinterface(p->interface)) { if (db_addinterface(p->interface)) {
printf("\nRestart the vnStat daemon if it is currently running in if (cfg.rescanonsave) {
order to start monitoring \"%s\".\n", p->interface); printf("vnStat daemon will automatically start monitoring
\"%s\" within %d minutes if the daemon process is currently running.\n", p->int
erface, cfg.saveinterval);
} else {
printf("Restart vnStat daemon if it is currently running
in order to start monitoring \"%s\".\n", p->interface);
}
handlesetalias(p); handlesetalias(p);
#ifndef CHECK_VNSTAT #ifndef CHECK_VNSTAT
db_close(); db_close();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
#endif #endif
} else { } else {
printf("Error: Adding interface \"%s\" to database failed.\n", p- >interface); printf("Error: Adding interface \"%s\" to database failed.\n", p- >interface);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
skipping to change at line 812 skipping to change at line 836
} }
p->defaultiface = 0; p->defaultiface = 0;
printf("using \"%s\" instead.\n", p->interface); printf("using \"%s\" instead.\n", p->interface);
} }
if (!isifavailable(p->interface)) { if (!isifavailable(p->interface)) {
getifliststring(&p->ifacelist, 0); getifliststring(&p->ifacelist, 0);
if (p->defaultiface) { if (p->defaultiface) {
printf("Error: Configured default interface \"%s\" isn't available.\n\n", p->interface); printf("Error: Configured default interface \"%s\" isn't available.\n\n", p->interface);
if (strlen(cfg.cfgfile)) { if (strlen(cfg.cfgfile)) {
printf("Update \"Interface\" keyword value in \"% printf("Update \"Interface\" keyword value in con
s\" to change\n", cfg.cfgfile); figuration file \"%s\" to change ", cfg.cfgfile);
printf("the default interface or give an alternat printf("the default interface or give an alternat
ive interface\nusing the -i parameter.\n\n"); ive interface using the -i parameter.\n\n");
} else { } else {
printf("An alternative interface can be given usi ng the -i parameter.\n\n"); printf("An alternative interface can be given usi ng the -i parameter.\n\n");
} }
printf("The following interfaces are currently available: \n %s\n", p->ifacelist); printf("The following interfaces are currently available: \n %s\n", p->ifacelist);
} else { } else {
printf("Error: Unable to get interface \"%s\" statistics. \n\n", p->interface); printf("Error: Unable to get interface \"%s\" statistics. \n\n", p->interface);
printf("The following interfaces are currently available: \n %s\n", p->ifacelist); printf("The following interfaces are currently available: \n %s\n", p->ifacelist);
} }
free(p->ifacelist); free(p->ifacelist);
 End of changes. 25 change blocks. 
76 lines changed or deleted 104 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)