"Fossies" - the Fresh Open Source Software Archive

Member "vnstat-2.9/src/dbsql.h" (1 Jan 2022, 3528 Bytes) of package /linux/misc/vnstat-2.9.tar.gz:

As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #ifndef DBSQL_H
    2 #define DBSQL_H
    4 #include <sqlite3.h>
    5 #include "iflist.h"
    7 typedef struct dbdatalist {
    8     time_t timestamp;
    9     int64_t rowid;
   10     uint64_t rx, tx;
   11     struct dbdatalist *next;
   12 } dbdatalist;
   14 typedef struct dbdatalistinfo {
   15     uint32_t count;
   16     time_t maxtime, mintime;
   17     uint64_t minrx, mintx;
   18     uint64_t maxrx, maxtx;
   19     uint64_t min, max;
   20     uint64_t sumrx, sumtx;
   21 } dbdatalistinfo;
   23 typedef struct interfaceinfo {
   24     char name[32], alias[32];
   25     int active;
   26     time_t created, updated;
   27     uint64_t rxcounter, txcounter;
   28     uint64_t rxtotal, txtotal;
   29 } interfaceinfo;
   31 int db_open_ro(void);
   32 int db_open_rw(const int createifnotfound);
   33 int db_open(const int createifnotfound, const int readonly);
   34 int db_validate(const int readonly);
   35 int db_setpragmas(void);
   36 int db_close(void);
   37 int db_exec(const char *sql);
   38 int db_create(void);
   39 int db_addinterface(const char *iface);
   40 int db_removeinterface(const char *iface);
   41 int db_renameinterface(const char *iface, const char *newifname);
   42 uint64_t db_getinterfacecount(void);
   43 uint64_t db_getinterfacecountbyname(const char *iface);
   44 sqlite3_int64 db_getinterfaceid(const char *iface, const int createifnotfound);
   45 char *db_getinterfaceidin(const char *iface);
   46 int db_setinterfacebyalias(char *iface, const char *alias, const int matchmethod);
   47 int db_setactive(const char *iface, const int active);
   48 int db_setupdated(const char *iface, const time_t timestamp);
   49 int db_setcounters(const char *iface, const uint64_t rxcounter, const uint64_t txcounter);
   50 int db_getcounters(const char *iface, uint64_t *rxcounter, uint64_t *txcounter);
   51 int db_getinterfaceinfo(const char *iface, interfaceinfo *info);
   52 int db_setalias(const char *iface, const char *alias);
   53 int db_setinfo(const char *name, const char *value, const int createifnotfound);
   54 char *db_getinfo(const char *name);
   55 int db_getiflist(iflist **ifl);
   56 int db_getiflist_sorted(iflist **ifl, const int orderbytraffic);
   57 char *db_get_date_generator(const int range, const short direct, const char *nowdate);
   58 int db_addtraffic(const char *iface, const uint64_t rx, const uint64_t tx);
   59 int db_addtraffic_dated(const char *iface, const uint64_t rx, const uint64_t tx, const uint64_t timestamp);
   60 int db_setcreation(const char *iface, const time_t timestamp);
   61 int db_settotal(const char *iface, const uint64_t rx, const uint64_t tx);
   62 int db_insertdata(const char *table, const char *iface, const uint64_t rx, const uint64_t tx, const uint64_t timestamp);
   63 int db_removeoldentries(void);
   64 int db_removeoldentries_top(void);
   65 int db_vacuum(void);
   66 int db_begintransaction(void);
   67 int db_committransaction(void);
   68 int db_rollbacktransaction(void);
   69 int db_iserrcodefatal(int errcode);
   70 int db_isdiskfull(int errcode);
   72 void db_walcheckpoint(void);
   73 #endif
   75 int db_getdata(dbdatalist **dbdata, dbdatalistinfo *listinfo, const char *iface, const char *table, const uint32_t resultlimit);
   76 int db_getdata_range(dbdatalist **dbdata, dbdatalistinfo *listinfo, const char *iface, const char *table, const uint32_t resultlimit, const char *databegin, const char *dataend);
   77 void updatelistinfo(dbdatalistinfo *listinfo, const uint64_t rx, const uint64_t tx, const time_t timestamp);
   78 int dbdatalistadd(dbdatalist **dbdata, const uint64_t rx, const uint64_t tx, const time_t timestamp, const int64_t rowid);
   79 void dbdatalistfree(dbdatalist **dbdata);
   81 unsigned int getqueryinterfacecount(const char *input);
   82 char *getifaceinquery(const char *input);
   84 /* global db */
   85 extern sqlite3 *db;
   86 extern int db_errcode;
   87 extern int db_intransaction;
   89 #endif