[Asterisk-cvs] asterisk/cdr cdr_odbc.c,1.1,1.2

markster at lists.digium.com markster at lists.digium.com
Sun Dec 7 00:52:04 CST 2003


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

Modified Files:
	cdr_odbc.c 
Log Message:
More renaming updates


Index: cdr_odbc.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cdr/cdr_odbc.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cdr_odbc.c	6 Dec 2003 23:19:22 -0000	1.1
+++ cdr_odbc.c	7 Dec 2003 06:43:30 -0000	1.2
@@ -1,13 +1,15 @@
 /*
  * Asterisk -- A telephony toolkit for Linux.
  *
- * unixODBC CDR Backend
+ * ODBC CDR Backend
  * 
  * Brian K. West <brian at bkw.org>
  *
  * This program is free software, distributed under the terms of
  * the GNU General Public License.
  *
+ * Copyright (c) 2003 Digium, Inc.
+ *
  */
 
 #include <sys/types.h>
@@ -32,24 +34,24 @@
 
 #define DATE_FORMAT "%Y-%m-%d %T"
 
-static char *desc = "unixODBC CDR Backend";
-static char *name = "unixODBC";
-static char *config = "cdr_unixodbc.conf";
+static char *desc = "ODBC CDR Backend";
+static char *name = "ODBC";
+static char *config = "cdr_odbc.conf";
 static char *dsn = NULL, *username = NULL, *password = NULL, *loguniqueid = NULL;
 static int dsn_alloc = 0, username_alloc = 0, password_alloc = 0;
 static int connected = 0;
 
-static ast_mutex_t unixodbc_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t odbc_lock = AST_MUTEX_INITIALIZER;
 
-extern int unixodbc_do_query(char *sqlcmd);
-extern int unixodbc_init(void);
+extern int odbc_do_query(char *sqlcmd);
+extern int odbc_init(void);
 
 static SQLHENV	ODBC_env = SQL_NULL_HANDLE;	/* global ODBC Environment */
 static int 	ODBC_res;			/* global ODBC Result of Functions */
 static SQLHDBC	ODBC_con;			/* global ODBC Connection Handle */
 static SQLHSTMT	ODBC_stmt;			/* global ODBC Statement Handle */
 
-static int unixodbc_log(struct ast_cdr *cdr)
+static int odbc_log(struct ast_cdr *cdr)
 {
 	int res;
 	/*
@@ -62,7 +64,7 @@
 	time_t t;
 	char sqlcmd[2048], timestr[128];
 	
-	ast_mutex_lock(&unixodbc_lock);
+	ast_mutex_lock(&odbc_lock);
 
 	gettimeofday(&tv,NULL);
 	t = tv.tv_sec;
@@ -82,29 +84,29 @@
 
 	if(connected)
 	{
-		res = unixodbc_do_query(sqlcmd);
+		res = odbc_do_query(sqlcmd);
 		if(res < 0)
 		{
 			if(option_verbose > 3)		
-				ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Query FAILED Call not logged!\n");
-			res = unixodbc_init();
+				ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Query FAILED Call not logged!\n");
+			res = odbc_init();
 			if(option_verbose > 3)
-				ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Reconnecting to dsn %s\n", dsn);
+				ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Reconnecting to dsn %s\n", dsn);
 			if(res < 0)
 			{
 				if(option_verbose > 3)
-					ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: %s has gone away!\n", dsn);
+					ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: %s has gone away!\n", dsn);
 				connected = 0;
 			}
 			else
 			{
 				if(option_verbose > 3)
-					ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Trying Query again!\n");
-				res = unixodbc_do_query(sqlcmd);
+					ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Trying Query again!\n");
+				res = odbc_do_query(sqlcmd);
 				if(res < 0)
 				{
 					if(option_verbose > 3)
-						ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Query FAILED Call not logged!\n");
+						ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Query FAILED Call not logged!\n");
 				}
 			}
 		}
@@ -112,29 +114,29 @@
 	else
 	{
 		if(option_verbose > 3)
-			 ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Reconnecting to dsn %s\n", dsn);
-		res = unixodbc_init();
+			 ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Reconnecting to dsn %s\n", dsn);
+		res = odbc_init();
 		if(res < 0)
 		{
 			if(option_verbose > 3)
 			{
-				ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: %s has gone away!\n", dsn);
-				ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Call not logged!\n");
+				ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: %s has gone away!\n", dsn);
+				ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Call not logged!\n");
 			}
 		}
 		else
 		{
 			if(option_verbose > 3)
-				ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Trying Query again!\n");
-			res = unixodbc_do_query(sqlcmd);
+				ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Trying Query again!\n");
+			res = odbc_do_query(sqlcmd);
 			if(res < 0)
 			{
 				if(option_verbose > 3)
-					ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Query FAILED Call not logged!\n");
+					ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Query FAILED Call not logged!\n");
 			}
 		}
 	}
-	ast_mutex_unlock(&unixodbc_lock);
+	ast_mutex_unlock(&odbc_lock);
 	return 0;
 }
 
@@ -143,12 +145,12 @@
 	return desc;
 }
 
-static int unixodbc_unload_module(void)
+static int odbc_unload_module(void)
 {
 	if (connected)
 	{
 		if(option_verbose > 3)
-			ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Disconnecting from %s\n", dsn);
+			ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Disconnecting from %s\n", dsn);
 		SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt);
 		SQLDisconnect(ODBC_con);
 		SQLFreeHandle(SQL_HANDLE_DBC, ODBC_con);
@@ -158,7 +160,7 @@
 	if (dsn && dsn_alloc)
 	{
 		if(option_verbose > 3)
-			ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: free dsn\n");
+			ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: free dsn\n");
 		free(dsn);
 		dsn = NULL;
 		dsn_alloc = 0;
@@ -166,7 +168,7 @@
 	if (username && username_alloc)
 	{
 		if(option_verbose > 3)
-			ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: free username\n");
+			ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: free username\n");
 		free(username);
 		username = NULL;
 		username_alloc = 0;
@@ -174,7 +176,7 @@
 	if (password && password_alloc)
 	{
 		if(option_verbose > 3)
-			ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: free password\n");
+			ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: free password\n");
 		free(password);
 		password = NULL;
 		password_alloc = 0;
@@ -183,7 +185,7 @@
 	return 0;
 }
 
-static int unixodbc_load_module(void)
+static int odbc_load_module(void)
 {
 	int res;
 	struct ast_config *cfg;
@@ -193,7 +195,7 @@
 	cfg = ast_load(config);
 	if (!cfg)
 	{
-		ast_log(LOG_WARNING, "cdr_unixodbc: Unable to load config for unixODBC CDR's: %s\n", config);
+		ast_log(LOG_WARNING, "cdr_odbc: Unable to load config for ODBC CDR's: %s\n", config);
 		return 0;
 	}
 	
@@ -214,13 +216,13 @@
 		}
 		else
 		{
-			ast_log(LOG_ERROR,"cdr_unixodbc: Out of memory error.\n");
+			ast_log(LOG_ERROR,"cdr_odbc: Out of memory error.\n");
 			return -1;
 		}
 	}
 	else
 	{
-		ast_log(LOG_WARNING,"cdr_unixodbc: dsn not specified.  Assuming asteriskdb\n");
+		ast_log(LOG_WARNING,"cdr_odbc: dsn not specified.  Assuming asteriskdb\n");
 		dsn = "asteriskdb";
 	}
 
@@ -235,13 +237,13 @@
 		}
 		else
 		{
-			ast_log(LOG_ERROR,"cdr_unixodbc: Out of memory error.\n");
+			ast_log(LOG_ERROR,"cdr_odbc: Out of memory error.\n");
 			return -1;
 		}
 	}
 	else
 	{
-		ast_log(LOG_WARNING,"cdr_unixodbc: username not specified.  Assuming root\n");
+		ast_log(LOG_WARNING,"cdr_odbc: username not specified.  Assuming root\n");
 		username = "root";
 	}
 
@@ -256,13 +258,13 @@
 		}
 		else
 		{
-			ast_log(LOG_ERROR,"cdr_unixodbc: Out of memory error.\n");
+			ast_log(LOG_ERROR,"cdr_odbc: Out of memory error.\n");
 			return -1;
 		}
 	}
 	else
 	{
-		ast_log(LOG_WARNING,"cdr_unixodbc: database password not specified.  Assuming blank\n");
+		ast_log(LOG_WARNING,"cdr_odbc: database password not specified.  Assuming blank\n");
 		password = "";
 	}
 
@@ -273,44 +275,44 @@
 		if (loguniqueid != NULL)
 		{
 			strcpy(loguniqueid,tmp);
-			ast_log(LOG_WARNING,"cdr_unixodbc: Logging uniqueid\n");
+			ast_log(LOG_WARNING,"cdr_odbc: Logging uniqueid\n");
 		}
 		else
 		{
-			ast_log(LOG_ERROR,"cdr_unixodbc: Not logging uniqueid\n");
+			ast_log(LOG_ERROR,"cdr_odbc: Not logging uniqueid\n");
 		}
 	}
 	else
 	{
-		ast_log(LOG_WARNING,"cdr_unixodbc: Not logging uniqueid\n");
+		ast_log(LOG_WARNING,"cdr_odbc: Not logging uniqueid\n");
 		loguniqueid = NULL;
 	}
 
 	ast_destroy(cfg);
 	if(option_verbose > 3)
 	{
-		ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: dsn is %s\n",dsn);
-		ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: username is %s\n",username);
-		ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: password is [secret]\n");
+		ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: dsn is %s\n",dsn);
+		ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: username is %s\n",username);
+		ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: password is [secret]\n");
 
 	}
 	
-	res = unixodbc_init();
+	res = odbc_init();
 	if(res < 0)
 	{
-		ast_log(LOG_ERROR, "cdr_unixodbc: Unable to connect to datasource: %s\n", dsn);
-		ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Unable to connect to datasource: %s\n", dsn);
+		ast_log(LOG_ERROR, "cdr_odbc: Unable to connect to datasource: %s\n", dsn);
+		ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Unable to connect to datasource: %s\n", dsn);
 	}
 
-	res = ast_cdr_register(name, desc, unixodbc_log);
+	res = ast_cdr_register(name, desc, odbc_log);
 	if (res)
 	{
-		ast_log(LOG_ERROR, "cdr_unixodbc: Unable to register unixODBC CDR handling\n");
+		ast_log(LOG_ERROR, "cdr_odbc: Unable to register ODBC CDR handling\n");
 	}
 	return res;
 }
 
-int unixodbc_do_query(char *sqlcmd)
+int odbc_do_query(char *sqlcmd)
 {
         long int ODBC_err;
         short int ODBC_mlen;
@@ -321,7 +323,7 @@
 	if((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
 	{
 		if(option_verbose > 3)
-			ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Failure in AllocStatement %d\n", ODBC_res);
+			ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Failure in AllocStatement %d\n", ODBC_res);
 		SQLGetDiagRec(SQL_HANDLE_DBC, ODBC_con, 1, ODBC_stat, &ODBC_err, ODBC_msg, 100, &ODBC_mlen);
 		SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt);	
 		connected = 0;
@@ -333,7 +335,7 @@
 	if((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
 	{
 		if(option_verbose > 3)
-			ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Error in PREPARE %d\n", ODBC_res);
+			ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Error in PREPARE %d\n", ODBC_res);
 		SQLGetDiagRec(SQL_HANDLE_DBC, ODBC_con, 1, ODBC_stat, &ODBC_err, ODBC_msg, 100, &ODBC_mlen);
 		SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt);
 		return -1;
@@ -344,7 +346,7 @@
 	if((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
 	{
 		if(option_verbose > 3)
-			ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Error in Query %d\n", ODBC_res);
+			ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Error in Query %d\n", ODBC_res);
 		SQLGetDiagRec(SQL_HANDLE_DBC, ODBC_con, 1, ODBC_stat, &ODBC_err, ODBC_msg, 100, &ODBC_mlen);
 		SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt);
 		connected = 0;
@@ -353,13 +355,13 @@
 	else
 	{
 		if(option_verbose > 3)
-			ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Query Successful!\n");
+			ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Query Successful!\n");
 		connected = 1;
 	}
 	return 0;
 }
 
-int unixodbc_init()
+int odbc_init()
 {
 	long int ODBC_err;
 	short int ODBC_mlen;
@@ -372,7 +374,7 @@
 		if((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
 		{
 			if(option_verbose > 3)
-				ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Error AllocHandle\n");
+				ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Error AllocHandle\n");
 			connected = 0;
 			return -1;
 		}
@@ -382,7 +384,7 @@
 		if((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
 		{
 			if(option_verbose > 3)
-				ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Error SetEnv\n");
+				ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Error SetEnv\n");
 			SQLFreeHandle(SQL_HANDLE_ENV, ODBC_env);
 			connected = 0;
 			return -1;
@@ -393,7 +395,7 @@
 		if((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
 		{
 			if(option_verbose > 3)
-				ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Error AllocHDB %d\n", ODBC_res);
+				ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Error AllocHDB %d\n", ODBC_res);
 			SQLFreeHandle(SQL_HANDLE_ENV, ODBC_env);
 			connected = 0;
 			return -1;
@@ -407,7 +409,7 @@
 	if((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
 	{
 		if(option_verbose > 3)
-			ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Error SQLConnect %d\n", ODBC_res);
+			ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Error SQLConnect %d\n", ODBC_res);
 		SQLGetDiagRec(SQL_HANDLE_DBC, ODBC_con, 1, ODBC_stat, &ODBC_err, ODBC_msg, 100, &ODBC_mlen);
 		SQLFreeHandle(SQL_HANDLE_ENV, ODBC_env);
 		connected = 0;
@@ -416,7 +418,7 @@
 	else
 	{
 		if(option_verbose > 3)
-			ast_verbose( VERBOSE_PREFIX_4 "cdr_unixodbc: Connected to %s\n", dsn);
+			ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Connected to %s\n", dsn);
 		connected = 1;
 	}
 
@@ -425,18 +427,18 @@
 
 int load_module(void)
 {
-	return unixodbc_load_module();
+	return odbc_load_module();
 }
 
 int unload_module(void)
 {
-	return unixodbc_unload_module();
+	return odbc_unload_module();
 }
 
 int reload(void)
 {
-	unixodbc_unload_module();
-	return unixodbc_load_module();
+	odbc_unload_module();
+	return odbc_load_module();
 }
 
 int usecount(void)




More information about the svn-commits mailing list