From 79b7a8c5ad5d4de6fc69d71585625b8a74198c47 Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Sun, 7 Oct 2012 16:08:38 +0200 Subject: sqlite: Added SQL function to convert datetime timestamps from UTC/GMT to localtime All CURRENT_TIMESTAMP calls are returned in UTC/GMT, and this value is stored in the database. When using eurephiadm to look at these datetime fields the UTC/GMT value is used, and needs to be taken in consideration when looking at the reports. This patch is the first step to handle the local time zone better. This patch also fixes the 'debug' program in sqlite.c, making use of the eurephia_log_init() and eurephia_log_close() calls for log preparations. Signed-off-by: David Sommerseth --- database/sqlite/edb-sqlite.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'database/sqlite/edb-sqlite.c') diff --git a/database/sqlite/edb-sqlite.c b/database/sqlite/edb-sqlite.c index 4c15a5a..724e095 100644 --- a/database/sqlite/edb-sqlite.c +++ b/database/sqlite/edb-sqlite.c @@ -164,6 +164,13 @@ int eDBconnect(eurephiaCTX *ctx, const int argc, const char **argv) dbc->config = NULL; ctx->dbc = dbc; + if( sqlite_init_functions(ctx) != dbSUCCESS ) { + sqlite3_close((sqlite3 *) dbc->dbhandle); + free_nullsafe(ctx, dbc->dbname); + dbc->dbhandle = NULL; + return 0; + } + // Load configuration parameters into memory eurephia_log(ctx, LOG_INFO, 1, "Reading config from database (openvpn_config)"); res = sqlite_query(ctx, "SELECT datakey, dataval FROM openvpn_config"); -- cgit