[Asterisk-cvs] asterisk/cdr cdr_odbc.c,1.23,1.24

markster at lists.digium.com markster at lists.digium.com
Thu Feb 3 23:51:43 CST 2005


Update of /usr/cvsroot/asterisk/cdr
In directory mongoose.digium.com:/tmp/cvs-serv9929/cdr

Modified Files:
	cdr_odbc.c 
Log Message:
Optionally store CDR's in GM time (bug #3500, with mods)


Index: cdr_odbc.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cdr/cdr_odbc.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- cdr_odbc.c	25 Jan 2005 06:10:19 -0000	1.23
+++ cdr_odbc.c	4 Feb 2005 05:52:45 -0000	1.24
@@ -39,6 +39,7 @@
 static char *dsn = NULL, *username = NULL, *password = NULL, *table = NULL;
 static int dsn_alloc = 0, username_alloc = 0, password_alloc = 0, table_alloc = 0;
 static int loguniqueid = 0;
+static int usegmtime = 0;
 static int dispositionstring = 0;
 static int connected = 0;
 
@@ -53,7 +54,7 @@
 
 static int odbc_log(struct ast_cdr *cdr)
 {
-	long int ODBC_err;
+	SQLINTEGER ODBC_err;
 	short int ODBC_mlen;
 	int ODBC_res;
 	char ODBC_msg[200], ODBC_stat[10];
@@ -61,7 +62,10 @@
 	int res = 0;
 	struct tm tm;
 
-	localtime_r(&cdr->start.tv_sec,&tm);
+	if (usegmtime) 
+		gmtime_r(&cdr->start.tv_sec,&tm);
+	else
+		localtime_r(&cdr->start.tv_sec,&tm);
 
 	ast_mutex_lock(&odbc_lock);
 	strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
@@ -215,6 +219,7 @@
 		table_alloc = 0;
 	}
 	loguniqueid = 0;
+	usegmtime = 0;
 	dispositionstring = 0;
 
 	ast_cdr_unregister(name);
@@ -305,15 +310,28 @@
 	if (tmp) {
 		loguniqueid = ast_true(tmp);
 		if (loguniqueid) {
-			ast_log(LOG_NOTICE,"cdr_odbc: Logging uniqueid\n");
+			ast_log(LOG_DEBUG,"cdr_odbc: Logging uniqueid\n");
 		} else {
-			ast_log(LOG_ERROR,"cdr_odbc: Not logging uniqueid\n");
+			ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
 		}
 	} else {
-		ast_log(LOG_WARNING,"cdr_odbc: Not logging uniqueid\n");
+		ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
 		loguniqueid = 0;
 	}
 
+	tmp = ast_variable_retrieve(cfg,"global","usegmtime");
+	if (tmp) {
+		usegmtime = ast_true(tmp);
+		if (usegmtime) {
+			ast_log(LOG_DEBUG,"cdr_odbc: Logging in GMT\n");
+		} else {
+			ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
+		}
+	} else {
+		ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
+		usegmtime = 0;
+	}
+
 	tmp = ast_variable_retrieve(cfg,"global","table");
 	if (tmp) {
 		table = malloc(strlen(tmp) + 1);
@@ -357,7 +375,7 @@
 
 static int odbc_do_query(void)
 {
-	long int ODBC_err;
+	SQLINTEGER ODBC_err;
 	int ODBC_res;
 	short int ODBC_mlen;
 	char ODBC_msg[200], ODBC_stat[10];
@@ -381,7 +399,7 @@
 
 static int odbc_init(void)
 {
-	long int ODBC_err;
+	SQLINTEGER ODBC_err;
 	short int ODBC_mlen;
 	int ODBC_res;
 	char ODBC_msg[200], ODBC_stat[10];




More information about the svn-commits mailing list