[asterisk-commits] seanbright: branch group/asterisk-cpp r169200 - /team/group/asterisk-cpp/cdr/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jan 18 12:49:43 CST 2009


Author: seanbright
Date: Sun Jan 18 12:49:42 2009
New Revision: 169200

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=169200
Log:
Get a few of the cdr modules to compile.

Modified:
    team/group/asterisk-cpp/cdr/cdr_adaptive_odbc.c
    team/group/asterisk-cpp/cdr/cdr_csv.c
    team/group/asterisk-cpp/cdr/cdr_custom.c
    team/group/asterisk-cpp/cdr/cdr_manager.c
    team/group/asterisk-cpp/cdr/cdr_odbc.c
    team/group/asterisk-cpp/cdr/cdr_tds.c

Modified: team/group/asterisk-cpp/cdr/cdr_adaptive_odbc.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/cdr/cdr_adaptive_odbc.c?view=diff&rev=169200&r1=169199&r2=169200
==============================================================================
--- team/group/asterisk-cpp/cdr/cdr_adaptive_odbc.c (original)
+++ team/group/asterisk-cpp/cdr/cdr_adaptive_odbc.c Sun Jan 18 12:49:42 2009
@@ -50,7 +50,7 @@
 
 #define	CONFIG	"cdr_adaptive_odbc.conf"
 
-static char *name = "Adaptive ODBC";
+static const char *name = "Adaptive ODBC";
 /* Optimization to reduce number of memory allocations */
 static int maxsize = 512, maxsize2 = 512;
 
@@ -145,7 +145,7 @@
 			continue;
 		}
 
-		tableptr = ast_calloc(sizeof(char), sizeof(*tableptr) + lenconnection + 1 + lentable + 1);
+		tableptr = (struct tables *) ast_calloc(sizeof(char), sizeof(*tableptr) + lenconnection + 1 + lentable + 1);
 		if (!tableptr) {
 			ast_log(LOG_ERROR, "Out of memory creating entry for table '%s' on connection '%s'\n", table, connection);
 			ast_odbc_release_obj(obj);
@@ -168,7 +168,7 @@
 				cdrvar = ast_strip(cdrvar);
 				ast_verb(3, "Found filter %s for cdr variable %s in %s@%s\n", var->value, cdrvar, tableptr->table, tableptr->connection);
 
-				entry = ast_calloc(sizeof(char), sizeof(*entry) + strlen(cdrvar) + 1 + strlen(var->value) + 1);
+				entry = (struct columns *) ast_calloc(sizeof(char), sizeof(*entry) + strlen(cdrvar) + 1 + strlen(var->value) + 1);
 				if (!entry) {
 					ast_log(LOG_ERROR, "Out of memory creating filter entry for CDR variable '%s' in table '%s' on connection '%s'\n", cdrvar, table, connection);
 					res = -1;
@@ -187,7 +187,7 @@
 		}
 
 		while ((res = SQLFetch(stmt)) != SQL_NO_DATA && res != SQL_ERROR) {
-			char *cdrvar = "", *staticvalue = "";
+			const char *cdrvar = "", *staticvalue = "";
 
 			SQLGetData(stmt,  4, SQL_C_CHAR, columnname, sizeof(columnname), &sqlptr);
 
@@ -215,7 +215,7 @@
 				}
 			}
 
-			entry = ast_calloc(sizeof(char), sizeof(*entry) + strlen(columnname) + 1 + strlen(cdrvar) + 1 + strlen(staticvalue) + 1);
+			entry = (struct columns *) ast_calloc(sizeof(char), sizeof(*entry) + strlen(columnname) + 1 + strlen(cdrvar) + 1 + strlen(staticvalue) + 1);
 			if (!entry) {
 				ast_log(LOG_ERROR, "Out of memory creating entry for column '%s' in table '%s' on connection '%s'\n", columnname, table, connection);
 				res = -1;
@@ -282,7 +282,7 @@
 static SQLHSTMT generic_prepare(struct odbc_obj *obj, void *data)
 {
 	int res, i;
-	char *sql = data;
+	char *sql = (char *) data;
 	SQLHSTMT stmt;
 	SQLINTEGER nativeerror = 0, numfields = 0;
 	SQLSMALLINT diagbytes = 0;
@@ -437,7 +437,7 @@
 
 					/* Truncate too-long fields */
 					if (entry->type != SQL_GUID) {
-						if (strlen(colptr) > entry->octetlen) {
+						if (strlen(colptr) > (size_t) entry->octetlen) {
 							colptr[entry->octetlen] = '\0';
 						}
 					}
@@ -649,10 +649,10 @@
 	AST_RWLIST_UNLOCK(&odbc_tables);
 
 	/* Next time, just allocate buffers that are that big to start with. */
-	if (ast_str_strlen(sql) > maxsize) {
+	if (ast_str_strlen(sql) > (size_t) maxsize) {
 		maxsize = ast_str_strlen(sql);
 	}
-	if (ast_str_strlen(sql2) > maxsize2) {
+	if (ast_str_strlen(sql2) > (size_t) maxsize2) {
 		maxsize2 = ast_str_strlen(sql2);
 	}
 
@@ -676,17 +676,17 @@
 	return 0;
 }
 
-static int load_module(void)
+static enum ast_module_load_result load_module(void)
 {
 	if (AST_RWLIST_WRLOCK(&odbc_tables)) {
 		ast_log(LOG_ERROR, "Unable to lock column list.  Load failed.\n");
-		return 0;
+		return AST_MODULE_LOAD_FAILURE;
 	}
 
 	load_config();
 	AST_RWLIST_UNLOCK(&odbc_tables);
 	ast_cdr_register(name, ast_module_info->description, odbc_log);
-	return 0;
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static int reload(void)
@@ -703,8 +703,8 @@
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Adaptive ODBC CDR backend",
-	.load = load_module,
-	.unload = unload_module,
-	.reload = reload,
-);
-
+				load_module,
+				unload_module,
+				reload
+	);
+

Modified: team/group/asterisk-cpp/cdr/cdr_csv.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/cdr/cdr_csv.c?view=diff&rev=169200&r1=169199&r2=169200
==============================================================================
--- team/group/asterisk-cpp/cdr/cdr_csv.c (original)
+++ team/group/asterisk-cpp/cdr/cdr_csv.c Sun Jan 18 12:49:42 2009
@@ -51,7 +51,7 @@
 static int loguniqueid = 0;
 static int loguserfield = 0;
 static int loaded = 0;
-static char *config = "cdr.conf";
+static const char *config = "cdr.conf";
 
 /* #define CSV_LOGUNIQUEID 1 */
 /* #define CSV_LOGUSERFIELD 1 */
@@ -84,7 +84,7 @@
   "userfield"		user field set via SetCDRUserField
 ----------------------------------------------------------*/
 
-static char *name = "csv";
+static const char *name = "csv";
 
 AST_MUTEX_DEFINE_STATIC(mf_lock);
 AST_MUTEX_DEFINE_STATIC(acf_lock);
@@ -133,9 +133,10 @@
 	return 1;
 }
 
-static int append_string(char *buf, char *s, size_t bufsize)
-{
-	int pos = strlen(buf), spos = 0, error = -1;
+static int append_string(char *buf, const char *s, size_t bufsize)
+{
+	size_t pos = strlen(buf), spos = 0;
+	int error = -1;
 
 	if (pos >= bufsize - 4)
 		return -1;
@@ -321,19 +322,19 @@
 	return 0;
 }
 
-static int load_module(void)
-{
-	int res;
-
-	if(!load_config(0))
+static enum ast_module_load_result load_module(void)
+{
+	if (!load_config(0))
 		return AST_MODULE_LOAD_DECLINE;
 
-	if ((res = ast_cdr_register(name, ast_module_info->description, csv_log))) {
+	if (ast_cdr_register(name, ast_module_info->description, csv_log)) {
 		ast_log(LOG_ERROR, "Unable to register CSV CDR handling\n");
+		return AST_MODULE_LOAD_DECLINE;
 	} else {
 		loaded = 1;
 	}
-	return res;
+
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static int reload(void)
@@ -350,7 +351,7 @@
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Comma Separated Values CDR Backend",
-		.load = load_module,
-		.unload = unload_module,
-		.reload = reload,
-	       );
+				load_module,
+				unload_module,
+				reload
+	);

Modified: team/group/asterisk-cpp/cdr/cdr_custom.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/cdr/cdr_custom.c?view=diff&rev=169200&r1=169199&r2=169200
==============================================================================
--- team/group/asterisk-cpp/cdr/cdr_custom.c (original)
+++ team/group/asterisk-cpp/cdr/cdr_custom.c Sun Jan 18 12:49:42 2009
@@ -52,7 +52,7 @@
 AST_MUTEX_DEFINE_STATIC(lock);
 AST_MUTEX_DEFINE_STATIC(mf_lock);
 
-static char *name = "cdr-custom";
+static const char *name = "cdr-custom";
 
 static char master[PATH_MAX];
 static char format[1024]="";
@@ -149,15 +149,15 @@
 	return 0;
 }
 
-static int load_module(void)
+static enum ast_module_load_result load_module(void)
 {
-	int res = 0;
-
 	if (!load_config(0)) {
-		res = ast_cdr_register(name, ast_module_info->description, custom_log);
-		if (res)
+		int res = ast_cdr_register(name, ast_module_info->description, custom_log);
+		if (res) {
 			ast_log(LOG_ERROR, "Unable to register custom CDR handling\n");
-		return res;
+			return AST_MODULE_LOAD_DECLINE;
+		}
+		return AST_MODULE_LOAD_SUCCESS;
 	} else
 		return AST_MODULE_LOAD_DECLINE;
 }
@@ -168,8 +168,8 @@
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Customizable Comma Separated Values CDR Backend",
-		.load = load_module,
-		.unload = unload_module,
-		.reload = reload,
-	       );
+				load_module,
+				unload_module,
+				reload
+	);
 

Modified: team/group/asterisk-cpp/cdr/cdr_manager.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/cdr/cdr_manager.c?view=diff&rev=169200&r1=169199&r2=169200
==============================================================================
--- team/group/asterisk-cpp/cdr/cdr_manager.c (original)
+++ team/group/asterisk-cpp/cdr/cdr_manager.c Sun Jan 18 12:49:42 2009
@@ -43,7 +43,7 @@
 #define CONF_FILE	"cdr_manager.conf"
 #define CUSTOM_FIELDS_BUF_SIZE 1024
 
-static char *name = "cdr_manager";
+static const char *name = "cdr_manager";
 
 static int enablecdr = 0;
 struct ast_str *customfields;
@@ -188,7 +188,7 @@
 	return 0;
 }
 
-static int load_module(void)
+static enum ast_module_load_result load_module(void)
 {
 	/* Configuration file */
 	if (!load_config(0))
@@ -203,7 +203,7 @@
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Asterisk Manager Interface CDR Backend",
-		.load = load_module,
-		.unload = unload_module,
-		.reload = reload,
-	       );
+				load_module,
+				unload_module,
+				reload
+	);

Modified: team/group/asterisk-cpp/cdr/cdr_odbc.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/cdr/cdr_odbc.c?view=diff&rev=169200&r1=169199&r2=169200
==============================================================================
--- team/group/asterisk-cpp/cdr/cdr_odbc.c (original)
+++ team/group/asterisk-cpp/cdr/cdr_odbc.c Sun Jan 18 12:49:42 2009
@@ -47,8 +47,8 @@
 
 #define DATE_FORMAT "%Y-%m-%d %T"
 
-static char *name = "ODBC";
-static char *config_file = "cdr_odbc.conf";
+static const char *name = "ODBC";
+static const char *config_file = "cdr_odbc.conf";
 static char *dsn = NULL, *table = NULL;
 
 enum {
@@ -61,7 +61,7 @@
 
 static SQLHSTMT execute_cb(struct odbc_obj *obj, void *data)
 {
-	struct ast_cdr *cdr = data;
+	struct ast_cdr *cdr = (struct ast_cdr *) data;
 	SQLRETURN ODBC_res;
 	char sqlcmd[2048] = "", timestr[128];
 	struct ast_tm tm;
@@ -101,7 +101,7 @@
 	SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->duration, 0, NULL);
 	SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->billsec, 0, NULL);
 	if (ast_test_flag(&config, CONFIG_DISPOSITIONSTRING))
-		SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(ast_cdr_disp2str(cdr->disposition)) + 1, 0, ast_cdr_disp2str(cdr->disposition), 0, NULL);
+		SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(ast_cdr_disp2str(cdr->disposition)) + 1, 0, (void *) ast_cdr_disp2str(cdr->disposition), 0, NULL);
 	else
 		SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->disposition, 0, NULL);
 	SQLBindParameter(stmt, 12, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->amaflags, 0, NULL);
@@ -149,7 +149,7 @@
 	return 0;
 }
 
-static int odbc_load_module(int reload)
+static enum ast_module_load_result odbc_load_module(int reload)
 {
 	int res = 0;
 	struct ast_config *cfg;
@@ -228,10 +228,11 @@
 
 	if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg != CONFIG_STATUS_FILEINVALID)
 		ast_config_destroy(cfg);
-	return res;
-}
-
-static int load_module(void)
+
+	return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
+}
+
+static enum ast_module_load_result load_module(void)
 {
 	return odbc_load_module(0);
 }
@@ -258,7 +259,7 @@
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "ODBC CDR Backend",
-		.load = load_module,
-		.unload = unload_module,
-		.reload = reload,
-	       );
+				load_module,
+				unload_module,
+				reload
+	);

Modified: team/group/asterisk-cpp/cdr/cdr_tds.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/cdr/cdr_tds.c?view=diff&rev=169200&r1=169199&r2=169200
==============================================================================
--- team/group/asterisk-cpp/cdr/cdr_tds.c (original)
+++ team/group/asterisk-cpp/cdr/cdr_tds.c Sun Jan 18 12:49:42 2009
@@ -77,8 +77,8 @@
 
 #define DATE_FORMAT "%Y/%m/%d %T"
 
-static char *name = "FreeTDS (MSSQL)";
-static char *config = "cdr_tds.conf";
+static const char *name = "FreeTDS (MSSQL)";
+static const char *config = "cdr_tds.conf";
 
 struct cdr_tds_config {
 	AST_DECLARE_STRING_FIELDS(
@@ -247,10 +247,10 @@
 	/* Reference to http://www.nextgenss.com/papers/advanced_sql_injection.pdf */
 	char *buf;
 	char *buf_ptr, *srh_ptr;
-	char *known_bad[] = {"select", "insert", "update", "delete", "drop", ";", "--", "\0"};
+	const char *known_bad[] = {"select", "insert", "update", "delete", "drop", ";", "--", "\0"};
 	int idx;
 
-	if (!(buf = ast_calloc(1, len + 1))) {
+	if (!(buf = (char *) ast_calloc(1, len + 1))) {
 		ast_log(LOG_ERROR, "Out of memory\n");
 		return NULL;
 	}
@@ -258,7 +258,7 @@
 	buf_ptr = buf;
 
 	/* Escape single quotes */
-	for (; *str && strlen(buf) < len; str++) {
+	for (; *str && strlen(buf) < (size_t) len; str++) {
 		if (*str == '\'') {
 			*buf_ptr++ = '\'';
 		}
@@ -521,7 +521,7 @@
 	return tds_load_module(1);
 }
 
-static int load_module(void)
+static enum ast_module_load_result load_module(void)
 {
 	if (dbinit() == FAIL) {
 		ast_log(LOG_ERROR, "Failed to initialize FreeTDS db-lib\n");
@@ -531,7 +531,7 @@
 	dberrhandle(tds_error_handler);
 	dbmsghandle(tds_message_handler);
 
-	settings = ast_calloc(1, sizeof(*settings));
+	settings = (struct cdr_tds_config *) ast_calloc(1, sizeof(*settings));
 
 	if (!settings || ast_string_field_init(settings, 256)) {
 		if (settings) {
@@ -561,7 +561,7 @@
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "FreeTDS CDR Backend",
-		.load = load_module,
-		.unload = unload_module,
-		.reload = reload,
-	       );
+				load_module,
+				unload_module,
+				reload
+	);




More information about the asterisk-commits mailing list