"Fossies" - the Fresh Open Source Software Archive  

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

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

dbsql.c  (vnstat-2.8):dbsql.c  (vnstat-2.9)
skipping to change at line 527 skipping to change at line 527
sqlite3_finalize(sqlstmt); sqlite3_finalize(sqlstmt);
} else { } else {
db_errcode = rc; db_errcode = rc;
snprintf(errorstring, 1024, "Failed to get interface id from data base (%d): %s", rc, sqlite3_errmsg(db)); snprintf(errorstring, 1024, "Failed to get interface id from data base (%d): %s", rc, sqlite3_errmsg(db));
printe(PT_Error); printe(PT_Error);
} }
return result; return result;
} }
int db_setinterfacebyalias(char *iface, const char *alias, const int matchmethod
)
{
int rc;
char sql[256];
sqlite3_stmt *sqlstmt;
switch (matchmethod) {
// case sensitive
case 1:
sqlite3_snprintf(256, sql, "select name from interface wh
ere alias='%q' order by rxtotal+txtotal desc", alias);
break;
// case insensitive
case 2:
sqlite3_snprintf(256, sql, "select name from interface wh
ere alias='%q' collate nocase order by rxtotal+txtotal desc", alias);
break;
// case insensitive prefix
case 3:
sqlite3_snprintf(256, sql, "select name from interface wh
ere alias like '%q%%' collate nocase order by rxtotal+txtotal desc", alias);
break;
default:
return 0;
}
rc = sqlite3_prepare_v2(db, sql, -1, &sqlstmt, NULL);
if (rc != SQLITE_OK) {
db_errcode = rc;
snprintf(errorstring, 1024, "Failed to get interface alias from d
atabase (%d): %s", rc, sqlite3_errmsg(db));
printe(PT_Error);
return 0;
}
if (sqlite3_column_count(sqlstmt) != 1) {
return 0;
}
rc = 0;
if (sqlite3_step(sqlstmt) == SQLITE_ROW) {
if (sqlite3_column_text(sqlstmt, 0) != NULL) {
strncpy_nt(iface, (const char *)sqlite3_column_text(sqlst
mt, 0), 32);
rc++;
}
}
sqlite3_finalize(sqlstmt);
return rc;
}
int db_setactive(const char *iface, const int active) int db_setactive(const char *iface, const int active)
{ {
char sql[64]; char sql[64];
sqlite3_int64 ifaceid = 0; sqlite3_int64 ifaceid = 0;
ifaceid = db_getinterfaceid(iface, 0); ifaceid = db_getinterfaceid(iface, 0);
if (ifaceid == 0) { if (ifaceid == 0) {
return 0; return 0;
} }
skipping to change at line 1174 skipping to change at line 1221
int db_getdata(dbdatalist **dbdata, dbdatalistinfo *listinfo, const char *iface, const char *table, const uint32_t resultlimit) int db_getdata(dbdatalist **dbdata, dbdatalistinfo *listinfo, const char *iface, const char *table, const uint32_t resultlimit)
{ {
return db_getdata_range(dbdata, listinfo, iface, table, resultlimit, "", ""); return db_getdata_range(dbdata, listinfo, iface, table, resultlimit, "", "");
} }
int db_getdata_range(dbdatalist **dbdata, dbdatalistinfo *listinfo, const char * iface, const char *table, const uint32_t resultlimit, const char *databegin, con st char *dataend) int db_getdata_range(dbdatalist **dbdata, dbdatalistinfo *listinfo, const char * iface, const char *table, const uint32_t resultlimit, const char *databegin, con st char *dataend)
{ {
int ret, i, rc; int ret, i, rc;
const char *datatables[] = {"fiveminute", "hour", "day", "month", "year", "top"}; const char *datatables[] = {"fiveminute", "hour", "day", "month", "year", "top"};
char sql[512], limit[64], dbegin[32], dend[44], *ifaceidin = NULL; char sql[512], limit[64], dbegin[37], dend[44], *ifaceidin = NULL;
sqlite3_stmt *sqlstmt; sqlite3_stmt *sqlstmt;
time_t timestamp; time_t timestamp;
int64_t rowid; int64_t rowid;
uint64_t rx, tx; uint64_t rx, tx;
listinfo->count = 0; listinfo->count = 0;
ret = 0; ret = 0;
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
if (strcmp(table, datatables[i]) == 0) { if (strcmp(table, datatables[i]) == 0) {
skipping to change at line 1200 skipping to change at line 1247
return 0; return 0;
} }
ifaceidin = db_getinterfaceidin(iface); ifaceidin = db_getinterfaceidin(iface);
if (ifaceidin == NULL) { if (ifaceidin == NULL) {
return 0; return 0;
} }
dbegin[0] = '\0'; dbegin[0] = '\0';
if (strlen(databegin)) { if (strlen(databegin)) {
snprintf(dbegin, 32, "and date >= '%s'", databegin); if (strcmp(databegin, "today") == 0) {
snprintf(dbegin, 37, "and date >= date('now'%s)", cfg.dbt
zmodifier);
} else {
snprintf(dbegin, 37, "and date >= '%s'", databegin);
}
} }
dend[0] = '\0'; dend[0] = '\0';
if (strlen(dataend)) { if (strlen(dataend)) {
if (strchr(dataend, ':')) { if (strchr(dataend, ':')) {
snprintf(dend, 44, "and date <= datetime('%s')", dataend) ; snprintf(dend, 44, "and date <= datetime('%s')", dataend) ;
} else { } else {
snprintf(dend, 44, "and date <= datetime('%s 23:59:59')", dataend); snprintf(dend, 44, "and date <= datetime('%s 23:59:59')", dataend);
} }
} }
 End of changes. 3 change blocks. 
2 lines changed or deleted 60 lines changed or added

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