[svn-commits] murf: branch group/newcdr r163719 - in /team/group/newcdr: cel/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Dec 12 14:14:07 CST 2008


Author: murf
Date: Fri Dec 12 14:14:06 2008
New Revision: 163719

URL: http://svn.digium.com/view/asterisk?view=rev&rev=163719
Log:
cleaned up the cel backends; they should report registration or a problem loading. Got rid of the debug msgs.

Modified:
    team/group/newcdr/cel/cel_csv.c
    team/group/newcdr/cel/cel_custom.c
    team/group/newcdr/cel/cel_manager.c
    team/group/newcdr/cel/cel_odbc.c
    team/group/newcdr/cel/cel_pgsql.c
    team/group/newcdr/cel/cel_radius.c
    team/group/newcdr/cel/cel_sqlite3_custom.c
    team/group/newcdr/cel/cel_tds.c
    team/group/newcdr/main/cel.c
    team/group/newcdr/main/features.c
    team/group/newcdr/main/taskprocessor.c

Modified: team/group/newcdr/cel/cel_csv.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_csv.c?view=diff&rev=163719&r1=163718&r2=163719
==============================================================================
--- team/group/newcdr/cel/cel_csv.c (original)
+++ team/group/newcdr/cel/cel_csv.c Fri Dec 12 14:14:06 2008
@@ -109,9 +109,9 @@
 	if (!cfg) {
 		ast_log(LOG_WARNING, "unable to load config: %s\n", config);
 		return 0;
-	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
 		return 0;
-	
+	}
 
 	var = ast_variable_browse(cfg, "csv");
 	if (!var) {
@@ -156,8 +156,9 @@
 	int spos = 0;
 	int error = -1;
 
-	if (pos >= bufsize - 4)
+	if (pos >= bufsize - 4) {
 		return -1;
+	}
 
 	buf[pos++] = '\"';
 
@@ -198,9 +199,10 @@
 	char tmp[80] = "";
 	struct ast_tm tm;
 
-	if (strlen(buf) > bufsize - 3)
+	if (strlen(buf) > bufsize - 3) {
 		return -1;
-
+	}
+	
 	if (ast_tvzero(tv)) {
 		strncat(buf, ",", bufsize - strlen(buf) - 1);
 		return 0;
@@ -225,10 +227,11 @@
 	/* Event Time */
 	append_date(buf, eventtime, bufsize);
 	/* EventType */
-	if (eventtype==CEL_USER_DEFINED)
+	if (eventtype==CEL_USER_DEFINED) {
 		append_string(buf, (char*)userdefname, bufsize);
-	else
+	} else {
 		append_string(buf, ast_cel_eventtype2str(eventtype), bufsize);
+	}
 	/* Account code */
 	append_string(buf, accountcode, bufsize);
 	/* CID number */
@@ -307,7 +310,6 @@
 	const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
 	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *userfield, *peer, *linkedid;
 	unsigned int amaflag;
-	ast_log(LOG_NOTICE,"CEL csv logging\n");
 	eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
 	eventtime.tv_sec = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
 	eventtime.tv_usec = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC);
@@ -329,7 +331,6 @@
 	amaflag = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_AMAFLAGS);
 	userfield = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USERFIELD);
 	peer = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_PEER);
-	ast_log(LOG_NOTICE,"About to output CSV record\n");
 	
 	snprintf(csvmaster, sizeof(csvmaster),"%s/%s/%s", ast_config_AST_LOG_DIR, CSV_LOG_DIR, CSV_MASTER);
 	if (build_csv_record(buf, sizeof(buf), eventtype, eventtime,userdefname, 
@@ -340,9 +341,7 @@
 		/* because of the absolutely unconditional need for the
 		   highest reliability possible in writing billing records,
 		   we open write and close the log file each time */
-		ast_log(LOG_NOTICE,"About to get mf lock\n");
 		ast_mutex_lock(&mf_lock);
-		ast_log(LOG_NOTICE,"Got mf lock\n");
 		mf = fopen(csvmaster, "a");
 		if (!mf) {
 			ast_log(LOG_ERROR, "Unable to re-open master file %s : %s\n", csvmaster, strerror(errno));
@@ -353,16 +352,11 @@
 			mf = NULL;
 		}
 		ast_mutex_unlock(&mf_lock);
-		ast_log(LOG_NOTICE,"released mf lock\n");
 		if (!ast_strlen_zero(accountcode)) {
-			ast_log(LOG_NOTICE,"About to write the accountcode=%s\n", accountcode);
 			if (writefile(buf, accountcode))
 				ast_log(LOG_WARNING, "Unable to write CSV record to account file '%s' : %s\n", accountcode, strerror(errno));
-			ast_log(LOG_NOTICE,"wrote the accountcode=%s\n", accountcode);
-		}
-	}
-	ast_log(LOG_NOTICE,"Returning!\n");
-	
+		}
+	}
 	return;
 }
 
@@ -373,8 +367,10 @@
 		mf = NULL;
 	}
 	
-	if (event_sub)
+	if (event_sub) {
 		ast_event_unsubscribe(event_sub);
+	}
+	
 	event_sub = 0;
 	loaded = 0;
 	return 0;
@@ -382,19 +378,22 @@
 
 static int load_module(void)
 {
-	if(!load_config(0))
+	if(!load_config(0)) {
+		ast_log(LOG_NOTICE,"Something is Missing, Declining CEL CSV load\n");
 		return AST_MODULE_LOAD_DECLINE;
+	}
 
 	event_sub = ast_event_subscribe(AST_EVENT_CEL, csv_log, "CSV Event Logging", NULL, AST_EVENT_IE_END);
 	
 	if (!event_sub) {
-		ast_log(LOG_ERROR, "Unable to register CSV CEL handling\n");
+		ast_log(LOG_ERROR, "Unable to register CSV CEL handling.\n");
 		if (mf) {
 			mf = NULL;
 			fclose(mf);
 			loaded = 0;
 		}
 	} else {
+		ast_log(LOG_NOTICE, "Subscribed to CSV CEL handling\n");
 		loaded = 1;
 	}
 	
@@ -407,7 +406,7 @@
 		loaded = 1;
 	} else {
 		loaded = 0;
-		ast_log(LOG_WARNING, "No [csv] section in cel.conf.\n");
+		ast_log(LOG_WARNING, "No [csv] section in cel.conf. Declining load.\n");
 	}
 	
 	return 0;

Modified: team/group/newcdr/cel/cel_custom.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_custom.c?view=diff&rev=163719&r1=163718&r2=163719
==============================================================================
--- team/group/newcdr/cel/cel_custom.c (original)
+++ team/group/newcdr/cel/cel_custom.c Fri Dec 12 14:14:06 2008
@@ -84,24 +84,28 @@
 		var = ast_variable_browse(cfg, "mappings");
 		while(var) {
 			if (!ast_strlen_zero(var->name) && !ast_strlen_zero(var->value)) {
-				if (strlen(var->value) > (sizeof(format) - 1))
+				if (strlen(var->value) > (sizeof(format) - 1)) {
 					ast_log(LOG_WARNING, "Format string too long, will be truncated, at line %d\n", var->lineno);
+				}
 				ast_copy_string(format, var->value, sizeof(format) - 1);
 				strcat(format,"\n");
 				snprintf(master, sizeof(master),"%s/%s/%s", ast_config_AST_LOG_DIR, name, var->name);
-			} else
+			} else {
 				ast_log(LOG_NOTICE, "Mapping must have both filename and format at line %d\n", var->lineno);
-			if (var->next)
+			}
+			if (var->next) {
 				ast_log(LOG_NOTICE, "Sorry, only one mapping is supported at this time, mapping '%s' will be ignored at line %d.\n", var->next->name, var->next->lineno); 
+			}
 			var = var->next;
 		}
 		ast_config_destroy(cfg);
 		res = 0;
 	} else {
-		if (reload)
+		if (reload) {
 			ast_log(LOG_WARNING, "Failed to reload configuration file.\n");
-		else
+		} else {
 			ast_log(LOG_WARNING, "Failed to load configuration file. Module not activated.\n");
+		}
 	}
 	ast_mutex_unlock(&lock);
 	
@@ -114,9 +118,8 @@
 	struct ast_channel *tchan;
 
 	/* Abort if no master file is specified */
-	ast_log(LOG_NOTICE,"Logging event to custom interface\n");
 	if (ast_strlen_zero(master)) {
-		ast_log(LOG_NOTICE,"master not defined. Logging aborted.\n");
+		ast_log(LOG_WARNING,"master not defined. Logging aborted.\n");
 		return;
 	}
 
@@ -125,21 +128,16 @@
 		ast_log(LOG_ERROR, "Unable to fabricate channel from CEL event\n");
 		return;
 	}
-	ast_log(LOG_NOTICE,"fabricated\n");
 
 	memset(buf, 0 , sizeof(buf));
 	pbx_substitute_variables_helper(tchan, format, buf, sizeof(buf) - 1);
-	ast_log(LOG_NOTICE,"vars substituted => %s\n", buf);
 
 	ast_dummy_channel_free(tchan);
-	ast_log(LOG_NOTICE,"dummy channel freed\n");
 
 	/* because of the absolutely unconditional need for the
 	   highest reliability possible in writing billing records,
 	   we open write and close the log file each time */
-	ast_log(LOG_NOTICE,"about to get lock\n");
 	ast_mutex_lock(&mf_lock);
-	ast_log(LOG_NOTICE,"got lock\n");
 	mf = fopen(master, "a");
 	if (!mf) {
 		ast_log(LOG_ERROR, "Unable to re-open master file %s : %s\n", master, strerror(errno));
@@ -150,7 +148,6 @@
 		mf = NULL;
 	}
 	ast_mutex_unlock(&mf_lock);
-	ast_log(LOG_NOTICE,"released lock-- returning\n");
 	return;
 }
 
@@ -160,10 +157,11 @@
 		fclose(mf);
 		mf = NULL;
 	}
-	if (event_sub)
+	if (event_sub) {
 		ast_event_unsubscribe(event_sub);
+	}
 	event_sub = 0;
-	return 0;
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static int load_module(void)
@@ -181,17 +179,22 @@
 			ast_log(LOG_ERROR, "Unable to register custom CEL handling\n");
 			return AST_MODULE_LOAD_DECLINE;
 		} else {
-			ast_log(LOG_NOTICE, "Subscribed to CEL events\n");
-		}
-		
-		return 0;
-	} else 
+			ast_log(LOG_NOTICE, "Subscribed to Custom-CSV CEL events\n");
+		}
+		return AST_MODULE_LOAD_SUCCESS;
+	} else {
 		return AST_MODULE_LOAD_DECLINE;
+	}
 }
 
 static int reload(void)
 {
-	return load_config(1);
+	if (load_config(1)) {
+		return AST_MODULE_LOAD_DECLINE;
+	} else {
+		return AST_MODULE_LOAD_SUCCESS;
+	}
+	
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Customizable Comma Separated Values CEL Backend",

Modified: team/group/newcdr/cel/cel_manager.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_manager.c?view=diff&rev=163719&r1=163718&r2=163719
==============================================================================
--- team/group/newcdr/cel/cel_manager.c (original)
+++ team/group/newcdr/cel/cel_manager.c Fri Dec 12 14:14:06 2008
@@ -65,8 +65,10 @@
 	int newenablecel = 0;
 	
 	cfg = ast_config_load(CONF_FILE, config_flags);
-	if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+	if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
+		ast_log(LOG_NOTICE,"CEL manager backend: config file has not changed.\n");
 		return 0;
+	}
 	
 	if (reload && customfields) {
 		ast_free(customfields);
@@ -74,12 +76,19 @@
 	customfields = NULL;
 	
 	if (!cfg) {
-		ast_log(LOG_WARNING, "Failed to load configuration file. Module not activated.\n");
+		ast_log(LOG_WARNING, "Failed to load configuration file. CEL manager Module not activated.\n");
 		/* Standard configuration */
 		enablecel = 0;
 		return 0;
 	}
 	
+	if (!ast_variable_browse(cfg, "general")) {
+		/* nothing configured */
+		ast_config_destroy(cfg);
+		ast_log(LOG_NOTICE, "cel_manager has no [general] category, nothing to configure.\n");
+		return 0;
+	}
+
 	while ( (cat = ast_category_browse(cfg, cat)) ) {
 		if (!strcasecmp(cat, "general")) {
 			v = ast_variable_browse(cfg, cat);
@@ -87,10 +96,8 @@
 				if (!strcasecmp(v->name, "enabled")) {
 					newenablecel = ast_true(v->value);
 				}
-				
 				v = v->next;
 			}
-			
 		} else if (!strcasecmp(cat, "mappings")) {
 			customfields = ast_str_create(CUSTOM_FIELDS_BUF_SIZE);
 			v = ast_variable_browse(cfg, cat);
@@ -112,14 +119,18 @@
 	ast_config_destroy(cfg);
 
 	if (enablecel && !newenablecel) {
-		if (event_sub)
+		if (event_sub) {
 			ast_event_unsubscribe(event_sub);
+		}
 		event_sub = 0;
 	} else if (!enablecel && newenablecel) {
 		event_sub = ast_event_subscribe(AST_EVENT_CEL, manager_log, "Manager Event Logging", NULL, AST_EVENT_IE_END);
 		if (!event_sub) {
 			ast_log(LOG_ERROR, "Unable to register Asterisk Call Manager CEL handling\n");
+		} else {
+			ast_log(LOG_NOTICE, "Registered Asterisk Call Manager CEL handling\n");
 		}
+		
 	}
 	enablecel = newenablecel;
 	
@@ -138,16 +149,17 @@
 	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *linkedid, *userfield, *peer;
 	unsigned int amaflag;
 
-	if (!enablecel)
+	if (!enablecel) {
 		return;
+	}
 	ast_log(LOG_NOTICE,"Logging event to manager interface\n");
 
 	eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
 	eventtime.tv_sec = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
 	eventtime.tv_usec = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC);
-	if (eventtype == CEL_USER_DEFINED)
+	if (eventtype == CEL_USER_DEFINED) {
 		userdefname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME);
-
+	}
 	cid_name = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNAME);
 	cid_num = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNUM);
 	cid_ani = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDANI);
@@ -190,17 +202,18 @@
 	    "Peer: %s\r\n",
 				  (eventtype==CEL_USER_DEFINED?userdefname:ast_cel_eventtype2str(eventtype)),
 				  accountcode, cid_num, cid_name, cid_ani, cid_rdnis, cid_dnid, 
-				  exten, context, channame,
-				  appname, appdata, strStartTime,
+				  exten, context, channame, appname, appdata, strStartTime,
 				  ast_cel_flags2str(amaflag), uniqueid, linkedid, userfield, peer);
 }
 
 static int unload_module(void)
 {
-	if (event_sub)
+	if (event_sub) {
 		ast_event_unsubscribe(event_sub);
-	if (customfields)
+	}
+	if (customfields) {
 		ast_free(customfields);
+	}
 	customfields = NULL;
 	event_sub = 0;
 	return 0;
@@ -209,9 +222,9 @@
 static int load_module(void)
 {
 	/* Configuration file */
-	if (!load_config(0))
+	if (!load_config(0)) {
 		return AST_MODULE_LOAD_DECLINE;
-	
+	}
 	return AST_MODULE_LOAD_SUCCESS;
 }
 

Modified: team/group/newcdr/cel/cel_odbc.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_odbc.c?view=diff&rev=163719&r1=163718&r2=163719
==============================================================================
--- team/group/newcdr/cel/cel_odbc.c (original)
+++ team/group/newcdr/cel/cel_odbc.c Fri Dec 12 14:14:06 2008
@@ -98,11 +98,11 @@
 	eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
 	eventtime.tv_sec = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
 	eventtime.tv_usec = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC);
-	if (eventtype == CEL_USER_DEFINED)
+	if (eventtype == CEL_USER_DEFINED) {
 		userdefname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME);
-	else
+	} else {
 		userdefname = ast_cel_eventtype2str(eventtype);
-	
+	}
 	cid_name = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNAME);
 	cid_num = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNUM);
 	cid_ani = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDANI);
@@ -172,7 +172,6 @@
 		SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 		return NULL;
 	}
-
 	return stmt;
 }
 
@@ -191,10 +190,12 @@
 		SQLRowCount(stmt, &rows);
 		SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 		
-		if (rows == 0)
+		if (rows == 0) {
 			ast_log(LOG_WARNING, "CEL successfully ran, but inserted 0 rows?\n");
-	} else
+		}
+	} else {
 		ast_log(LOG_ERROR, "CEL direct execute failed\n");
+	}
 	ast_odbc_release_obj(obj);
 }
 
@@ -202,44 +203,46 @@
 static int odbc_unload_module(void)
 {
 	if (dsn) {
-		if (option_verbose > 10)
+		if (option_verbose > 10) {
 			ast_verbose( VERBOSE_PREFIX_4 "cel_odbc: free dsn\n");
+		}
 		free(dsn);
 	}
 	if (table) {
-		if (option_verbose > 10)
+		if (option_verbose > 10) {
 			ast_verbose( VERBOSE_PREFIX_4 "cel_odbc: free table\n");
+		}
 		free(table);
 	}
-
-	if (event_sub)
+	if (event_sub) {
 		ast_event_unsubscribe(event_sub);
+	}
 	event_sub = 0;
 	return 0;
 }
 
 static int odbc_load_module(int reload)
 {
-	int res = 0;
+	int res = AST_MODULE_LOAD_SUCCESS;
 	struct ast_config *cfg;
 	struct ast_variable *var;
 	const char *tmp;
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 
-	do 
-	{
-		
+	do {
 		cfg = ast_config_load(config_file, config_flags);
 		if (!cfg) {
 			ast_log(LOG_WARNING, "cel_odbc: Unable to load config for ODBC CEL's: %s\n", config_file);
 			res = AST_MODULE_LOAD_DECLINE;
 			break;
-		} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
-			break;
+		} else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
+			break;
+		}
 		
 		var = ast_variable_browse(cfg, "global");
 		if (!var) {
 			/* nothing configured */
+			res = AST_MODULE_LOAD_DECLINE;
 			break;
 		}
 		
@@ -248,12 +251,13 @@
 			ast_log(LOG_WARNING,"cel_odbc: dsn not specified.  Assuming asteriskdb\n");
 			tmp = "asteriskdb";
 		}
-		if (dsn)
+		if (dsn) {
 			ast_free(dsn);
+		}
 		dsn = strdup(tmp);
 		if (dsn == NULL) {
 			ast_log(LOG_ERROR,"cel_odbc: Out of memory error.\n");
-			res = -1;
+			res = AST_MODULE_LOAD_DECLINE;
 			break;
 		}
 		
@@ -287,12 +291,13 @@
 			ast_log(LOG_WARNING,"cel_odbc: table not specified.  Assuming cel\n");
 			tmp = "cel";
 		}
-		if (table)
+		if (table) {
 			ast_free(table);
+		}
 		table = strdup(tmp);
 		if (table == NULL) {
 			ast_log(LOG_ERROR,"cel_odbc: Out of memory error.\n");
-			res = -1;
+			res = AST_MODULE_LOAD_DECLINE;
 			break;
 		}
 		
@@ -305,8 +310,9 @@
 		}
 	} while(0);
 	
-	if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED)
+	if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED) {
 		ast_config_destroy(cfg);
+	}
 	return res;
 }
 

Modified: team/group/newcdr/cel/cel_pgsql.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_pgsql.c?view=diff&rev=163719&r1=163718&r2=163719
==============================================================================
--- team/group/newcdr/cel/cel_pgsql.c (original)
+++ team/group/newcdr/cel/cel_pgsql.c Fri Dec 12 14:14:06 2008
@@ -90,8 +90,9 @@
 	eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
 	eventtime.tv_sec = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
 	eventtime.tv_usec = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC);
-	if (eventtype == CEL_USER_DEFINED)
+	if (eventtype == CEL_USER_DEFINED) {
 		userdefname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME);
+	}
 	cid_name = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNAME);
 	cid_num = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNUM);
 	cid_ani = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDANI);
@@ -125,41 +126,53 @@
                         ast_log(LOG_ERROR, "cel_pgsql: Reason: %s\n", pgerror);
 		}
 	}
-
 	if (connected) {
 		char *cidname_esc=NULL, *exten_esc=NULL, *context_esc=NULL, *channel_esc=NULL, *app_esc=NULL, *appdata_esc=NULL, *linkedid_esc=NULL;
 		char *uniqueid_esc=NULL, *cidnum_esc=NULL, *cidani_esc=NULL, *cidrdnis_esc=NULL, *ciddnid_esc=NULL, *accountcode_esc, *userfield_esc, *peer_esc;
 
 		/* Maximum space needed would be if all characters needed to be escaped, plus a trailing NULL */
-		if ((cidname_esc = alloca(strlen(cid_name) * 2 + 1)) != NULL)
+		if ((cidname_esc = alloca(strlen(cid_name) * 2 + 1)) != NULL) {
 			PQescapeString(cidname_esc, cid_name, strlen(cid_name));
-		if ((cidnum_esc = alloca(strlen(cid_num) * 2 + 1)) != NULL)
+		}
+		if ((cidnum_esc = alloca(strlen(cid_num) * 2 + 1)) != NULL) {
 			PQescapeString(cidnum_esc, cid_num, strlen(cid_num));
-		if ((cidani_esc = alloca(strlen(cid_ani) * 2 + 1)) != NULL)
+		}
+		if ((cidani_esc = alloca(strlen(cid_ani) * 2 + 1)) != NULL) {
 			PQescapeString(cidani_esc, cid_ani, strlen(cid_ani));
-		if ((cidrdnis_esc = alloca(strlen(cid_rdnis) * 2 + 1)) != NULL)
+		}
+		if ((cidrdnis_esc = alloca(strlen(cid_rdnis) * 2 + 1)) != NULL) {
 			PQescapeString(cidrdnis_esc, cid_rdnis, strlen(cid_rdnis));
-		if ((ciddnid_esc = alloca(strlen(cid_dnid) * 2 + 1)) != NULL)
+		}
+		if ((ciddnid_esc = alloca(strlen(cid_dnid) * 2 + 1)) != NULL) {
 			PQescapeString(ciddnid_esc, cid_dnid, strlen(cid_dnid));
-		if ((context_esc = alloca(strlen(context) * 2 + 1)) != NULL)
+		}
+		if ((context_esc = alloca(strlen(context) * 2 + 1)) != NULL) {
 			PQescapeString(context_esc, context, strlen(context));
-		if ((channel_esc = alloca(strlen(channame) * 2 + 1)) != NULL)
+		}
+		if ((channel_esc = alloca(strlen(channame) * 2 + 1)) != NULL) {
 			PQescapeString(channel_esc, channame, strlen(channame));
-		if ((app_esc = alloca(strlen(appname) * 2 + 1)) != NULL)
+		}
+		if ((app_esc = alloca(strlen(appname) * 2 + 1)) != NULL) {
 			PQescapeString(app_esc, appname, strlen(appname));
-		if ((appdata_esc = alloca(strlen(appdata) * 2 + 1)) != NULL)
+		}
+		if ((appdata_esc = alloca(strlen(appdata) * 2 + 1)) != NULL) {
 			PQescapeString(appdata_esc, appdata, strlen(appdata));
-		if ((uniqueid_esc = alloca(strlen(uniqueid) * 2 + 1)) != NULL)
+		}
+		if ((uniqueid_esc = alloca(strlen(uniqueid) * 2 + 1)) != NULL) {
 			PQescapeString(uniqueid_esc, uniqueid, strlen(uniqueid));
-		if ((linkedid_esc = alloca(strlen(linkedid) * 2 + 1)) != NULL)
+		}
+		if ((linkedid_esc = alloca(strlen(linkedid) * 2 + 1)) != NULL) {
 			PQescapeString(linkedid_esc, linkedid, strlen(linkedid));
-		if ((accountcode_esc = alloca(strlen(accountcode) * 2 + 1)) != NULL)
+		}
+		if ((accountcode_esc = alloca(strlen(accountcode) * 2 + 1)) != NULL) {
 			PQescapeString(accountcode_esc, accountcode, strlen(accountcode));
-		if ((userfield_esc = alloca(strlen(userfield) * 2 + 1)) != NULL)
+		}
+		if ((userfield_esc = alloca(strlen(userfield) * 2 + 1)) != NULL) {
 			PQescapeString(userfield_esc, userfield, strlen(userfield));
-		if ((peer_esc = alloca(strlen(peer) * 2 + 1)) != NULL)
+		}
+		if ((peer_esc = alloca(strlen(peer) * 2 + 1)) != NULL) {
 			PQescapeString(peer_esc, peer, strlen(peer));
-
+		}
 		/* Check for all alloca failures above at once */
 		if ((!cidname_esc) || (!context_esc) || (!channel_esc) || (!app_esc) || (!appdata_esc) || (!uniqueid_esc) || (!linkedid_esc)
 			|| (!ciddnid_esc) || (!cidrdnis_esc) || (!cidani_esc) || (!cidnum_esc)) {
@@ -167,7 +180,6 @@
 			ast_mutex_unlock(&pgsql_lock);
 			return;
 		}
-
 		if (option_debug > 1)
 			ast_log(LOG_DEBUG, "cel_pgsql: inserting a CEL record.\n");
 
@@ -229,22 +241,30 @@
 
 static int my_unload_module(void)
 { 
-	if (conn)
+	if (conn) {
 		PQfinish(conn);
-	if (pghostname)
+	}
+	if (pghostname) {
 		free(pghostname);
-	if (pgdbname)
+	}
+	if (pgdbname) {
 		free(pgdbname);
-	if (pgdbuser)
+	}
+	if (pgdbuser) {
 		free(pgdbuser);
-	if (pgpassword)
+	}
+	if (pgpassword) {
 		free(pgpassword);
-	if (pgdbport)
+	}
+	if (pgdbport) {
 		free(pgdbport);
-	if (table)
+	}
+	if (table) {
 		free(table);
-	if (event_sub)
+	}
+	if (event_sub) {
 		ast_event_unsubscribe(event_sub);
+	}
 	event_sub = 0;
 	return 0;
 }
@@ -255,62 +275,62 @@
         char *pgerror;
 	const char *tmp;
 
-	if (!(var = ast_variable_browse(cfg, "global")))
-		return 0;
-
+	if (!(var = ast_variable_browse(cfg, "global"))) {
+		ast_log(LOG_WARNING,"CEL pgsql config file missing global section.\n");
+		return AST_MODULE_LOAD_DECLINE;
+	}
 	if (!(tmp = ast_variable_retrieve(cfg,"global","hostname"))) {
 		ast_log(LOG_WARNING,"PostgreSQL server hostname not specified.  Assuming unix socket connection\n");
 		tmp = "";	/* connect via UNIX-socket by default */
 	}
-	
-	if (!(pghostname = ast_strdup(tmp)))
-		return -1;
-
+	if (!(pghostname = ast_strdup(tmp))) {
+		ast_log(LOG_WARNING,"PostgreSQL Ran out of memory copying host info\n");
+		return AST_MODULE_LOAD_DECLINE;
+	}
 	if (!(tmp = ast_variable_retrieve(cfg, "global", "dbname"))) {
 		ast_log(LOG_WARNING,"PostgreSQL database not specified.  Assuming asterisk\n");
 		tmp = "asteriskceldb";
 	}
-
-	if (!(pgdbname = ast_strdup(tmp)))
-		return -1;
-
+	if (!(pgdbname = ast_strdup(tmp))) {
+		ast_log(LOG_WARNING,"PostgreSQL Ran out of memory copying dbname info\n");
+		return AST_MODULE_LOAD_DECLINE;
+	}
 	if (!(tmp = ast_variable_retrieve(cfg, "global", "user"))) {
 		ast_log(LOG_WARNING,"PostgreSQL database user not specified.  Assuming asterisk\n");
 		tmp = "asterisk";
 	}
-
-	if (!(pgdbuser = ast_strdup(tmp)))
-		return -1;
-
+	if (!(pgdbuser = ast_strdup(tmp))) {
+		ast_log(LOG_WARNING,"PostgreSQL Ran out of memory copying user info\n");
+		return AST_MODULE_LOAD_DECLINE;
+	}
 	if (!(tmp = ast_variable_retrieve(cfg, "global", "password"))) {
-		ast_log(LOG_WARNING,"PostgreSQL database password not specified.  Assuming blank\n");
 		tmp = "";
 	}
-
-	if (!(pgpassword = ast_strdup(tmp)))
-		return -1;
-
+	if (!(pgpassword = ast_strdup(tmp))) {
+		ast_log(LOG_WARNING,"PostgreSQL Ran out of memory copying password info\n");
+		return AST_MODULE_LOAD_DECLINE;
+	}
 	if (!(tmp = ast_variable_retrieve(cfg,"global","port"))) {
 		ast_log(LOG_WARNING,"PostgreSQL database port not specified.  Using default 5432.\n");
 		tmp = "5432";
 	}
-
-	if (!(pgdbport = ast_strdup(tmp)))
-		return -1;
-
+	if (!(pgdbport = ast_strdup(tmp))) {
+		ast_log(LOG_WARNING,"PostgreSQL Ran out of memory copying port info\n");
+		return AST_MODULE_LOAD_DECLINE;
+	}
 	if (!(tmp = ast_variable_retrieve(cfg, "global", "table"))) {
 		ast_log(LOG_WARNING,"CEL table not specified.  Assuming cel\n");
 		tmp = "cel";
 	}
-
-	if (!(table = ast_strdup(tmp)))
-		return -1;
-
+	if (!(table = ast_strdup(tmp))) {
+		return AST_MODULE_LOAD_DECLINE;
+	}
 	if (option_debug) {
-	    	if (ast_strlen_zero(pghostname))
+		if (ast_strlen_zero(pghostname)) {
 			ast_log(LOG_DEBUG, "cel_pgsql: using default unix socket\n");
-		else
+		} else {
 			ast_log(LOG_DEBUG, "cel_pgsql: got hostname of %s\n", pghostname);
+		}
 		ast_log(LOG_DEBUG, "cel_pgsql: got port of %s\n", pgdbport);
 		ast_log(LOG_DEBUG, "cel_pgsql: got user of %s\n", pgdbuser);
 		ast_log(LOG_DEBUG, "cel_pgsql: got dbname of %s\n", pgdbname);
@@ -320,22 +340,25 @@
 	
 	conn = PQsetdbLogin(pghostname, pgdbport, NULL, NULL, pgdbname, pgdbuser, pgpassword);
 	if (PQstatus(conn) != CONNECTION_BAD) {
-		if (option_debug)
+		if (option_debug) {
 			ast_log(LOG_DEBUG, "Successfully connected to PostgreSQL database.\n");
+		}
 		connected = 1;
 	} else {
-                pgerror = PQerrorMessage(conn);
+		pgerror = PQerrorMessage(conn);
 		ast_log(LOG_ERROR, "cel_pgsql: Unable to connect to database server %s.  CALLS WILL NOT BE LOGGED!!\n", pghostname);
-                ast_log(LOG_ERROR, "cel_pgsql: Reason: %s\n", pgerror);
+		ast_log(LOG_ERROR, "cel_pgsql: Reason: %s\n", pgerror);
 		connected = 0;
 	}
-
 	event_sub = ast_event_subscribe(AST_EVENT_CEL, pgsql_log, "CEL PGSQL backend", NULL, AST_EVENT_IE_END);
 
-	if (!event_sub)
-		return AST_MODULE_LOAD_DECLINE;
-	else
-		return 0;
+	if (!event_sub) {
+		ast_log(LOG_WARNING, "Unable to subscribe to CEL events for pgsql\n");
+		return AST_MODULE_LOAD_DECLINE;
+	} else {
+		ast_log(LOG_NOTICE, "Subscribed to CEL events for pgsql\n");
+		return AST_MODULE_LOAD_SUCCESS;
+	}
 }
 
 static int my_load_module(int reload)
@@ -348,7 +371,6 @@
 		ast_log(LOG_WARNING, "Unable to load config for PostgreSQL CEL's: %s\n", config);
 		return AST_MODULE_LOAD_DECLINE;
 	}
-
 	res = process_my_load_module(cfg);
 	ast_config_destroy(cfg);
 

Modified: team/group/newcdr/cel/cel_radius.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_radius.c?view=diff&rev=163719&r1=163718&r2=163719
==============================================================================
--- team/group/newcdr/cel/cel_radius.c (original)
+++ team/group/newcdr/cel/cel_radius.c Fri Dec 12 14:14:06 2008
@@ -105,88 +105,79 @@
 	char timestr[128];
 	char *tmp;
 
-	if (!rc_avpair_add(rh, send, PW_ACCT_STATUS_TYPE, &recordtype, 0, 0))
-		return -1;
-
+	if (!rc_avpair_add(rh, send, PW_ACCT_STATUS_TYPE, &recordtype, 0, 0)) {
+		return -1;
+	}
 	/* Account code */
-	if (!rc_avpair_add(rh, send, PW_AST_ACCT_CODE, (char**)&accountcode, strlen(accountcode), VENDOR_CODE))
-		return -1;
-
+	if (!rc_avpair_add(rh, send, PW_AST_ACCT_CODE, (char**)&accountcode, strlen(accountcode), VENDOR_CODE)) {
+		return -1;
+	}
  	/* Source */
-	if (!rc_avpair_add(rh, send, PW_AST_CIDNUM, &cid_num, strlen(cid_num), VENDOR_CODE))
-		return -1;
-
+	if (!rc_avpair_add(rh, send, PW_AST_CIDNUM, &cid_num, strlen(cid_num), VENDOR_CODE)) {
+		return -1;
+	}
  	/* Destination */
-	if (!rc_avpair_add(rh, send, PW_AST_EXTEN, &exten, strlen(exten), VENDOR_CODE))
-		return -1;
-
+	if (!rc_avpair_add(rh, send, PW_AST_EXTEN, &exten, strlen(exten), VENDOR_CODE)) {
+		return -1;
+	}
  	/* Destination context */
-	if (!rc_avpair_add(rh, send, PW_AST_CONTEXT, &context, strlen(context), VENDOR_CODE))
-		return -1;
-
+	if (!rc_avpair_add(rh, send, PW_AST_CONTEXT, &context, strlen(context), VENDOR_CODE)) {
+		return -1;
+	}
 	/* Caller ID */
-	if (!rc_avpair_add(rh, send, PW_AST_CIDNAME, &cid_name, strlen(cid_name), VENDOR_CODE))
-		return -1;
-
+	if (!rc_avpair_add(rh, send, PW_AST_CIDNAME, &cid_name, strlen(cid_name), VENDOR_CODE)) {
+		return -1;
+	}
 	/* Caller ID ani */
-	if (!rc_avpair_add(rh, send, PW_AST_CIDANI, &cid_ani, strlen(cid_ani), VENDOR_CODE))
-		return -1;
-
+	if (!rc_avpair_add(rh, send, PW_AST_CIDANI, &cid_ani, strlen(cid_ani), VENDOR_CODE)) {
+		return -1;
+	}
 	/* Caller ID rdnis */
-	if (!rc_avpair_add(rh, send, PW_AST_CIDRDNIS, &cid_rdnis, strlen(cid_rdnis), VENDOR_CODE))
-		return -1;
-
+	if (!rc_avpair_add(rh, send, PW_AST_CIDRDNIS, &cid_rdnis, strlen(cid_rdnis), VENDOR_CODE)) {
+		return -1;
+	}
 	/* Caller ID dnid */
-	if (!rc_avpair_add(rh, send, PW_AST_CIDDNID, &cid_dnid, strlen(cid_dnid), VENDOR_CODE))
-		return -1;
-
+	if (!rc_avpair_add(rh, send, PW_AST_CIDDNID, &cid_dnid, strlen(cid_dnid), VENDOR_CODE)) {
+		return -1;
+	}
 	/* Channel */
-	if (!rc_avpair_add(rh, send, PW_AST_CHANNAME, (char**)&channame, strlen(channame), VENDOR_CODE))
-		return -1;
-
+	if (!rc_avpair_add(rh, send, PW_AST_CHANNAME, (char**)&channame, strlen(channame), VENDOR_CODE)) {
+		return -1;
+	}
 	/* Last Application */
-	if (!rc_avpair_add(rh, send, PW_AST_APPNAME, &appname, strlen(appname), VENDOR_CODE))
-		return -1;
-
+	if (!rc_avpair_add(rh, send, PW_AST_APPNAME, &appname, strlen(appname), VENDOR_CODE)) {
+		return -1;
+	}
 	/* Last Data */
-	if (!rc_avpair_add(rh, send, PW_AST_APPDATA, &appdata, strlen(appdata), VENDOR_CODE))
-		return -1;
-
-
+	if (!rc_avpair_add(rh, send, PW_AST_APPDATA, &appdata, strlen(appdata), VENDOR_CODE)) {
+		return -1;
+	}
 	/* Event Time */
 	ast_localtime(&eventtime, &tm, ast_test_flag(&global_flags, RADIUS_FLAG_USEGMTIME) ? "GMT" : NULL);
 	ast_strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
-	if (!rc_avpair_add(rh, send, PW_AST_EVENT_TIME, timestr, strlen(timestr), VENDOR_CODE))
-		return -1;
-
+	if (!rc_avpair_add(rh, send, PW_AST_EVENT_TIME, timestr, strlen(timestr), VENDOR_CODE)) {
+		return -1;
+	}
 	/* AMA Flags */
 	tmp = ast_cel_flags2str(amaflag);
-	if (!rc_avpair_add(rh, send, PW_AST_AMA_FLAGS, tmp, strlen(tmp), VENDOR_CODE))
-		return -1;
-
+	if (!rc_avpair_add(rh, send, PW_AST_AMA_FLAGS, tmp, strlen(tmp), VENDOR_CODE)) {
+		return -1;
+	}
 	if (ast_test_flag(&global_flags, RADIUS_FLAG_LOGUNIQUEID)) {
 		/* Unique ID */
 		if (!rc_avpair_add(rh, send, PW_AST_UNIQUE_ID, (char**)&uniqueid, strlen(uniqueid), VENDOR_CODE))
 			return -1;
 	}
-	
 	/* LinkedID */
-	if (!rc_avpair_add(rh, send, PW_AST_LINKED_ID, &linkedid, strlen(linkedid), VENDOR_CODE))
-		return -1;
-
-
+	if (!rc_avpair_add(rh, send, PW_AST_LINKED_ID, &linkedid, strlen(linkedid), VENDOR_CODE)) {
+		return -1;
+	}
 	/* Setting Acct-Session-Id & User-Name attributes for proper generation
 	   of Acct-Unique-Session-Id on server side */ 
 	/* Channel */
-	if (!rc_avpair_add(rh, send, PW_USER_NAME, (char**)&channame, strlen(channame), 0))
-		return -1;
-
-#ifdef WHY_CANT_SESSIONID_BE_FOUND
-	/* Unique ID */
-	if (!rc_avpair_add(rh, send, PW_ACCT_SESSIONID, (char**)&uniqueid, strlen(uniqueid), 0))
-		return -1;
-#endif
-
+	if (!rc_avpair_add(rh, send, PW_USER_NAME, (char**)&channame, strlen(channame), 0)) {
+		return -1;
+	}
 	return 0;
 }
 
@@ -225,24 +216,26 @@
 	if (build_radius_record(&send, eventtype, eventtime, userdefname, cid_name, cid_num, 
 							cid_ani, cid_rdnis, cid_dnid, exten, context, channame, 
 							appname, appdata, accountcode, uniqueid, amaflag, linkedid)) {
-		if (option_debug)
+		if (option_debug) {
 			ast_log(LOG_DEBUG, "Unable to create RADIUS record. CEL not recorded!\n");
+		}
 		return;
 	}
 	
 	result = rc_acct(rh, 0, send);
-	if (result != OK_RC)
+	if (result != OK_RC) {
 		ast_log(LOG_ERROR, "Failed to record Radius CEL record!\n");
-
+	}
 	return;
 }
 
 static int unload_module(void)
 {
-	if (event_sub)
+	if (event_sub) {
 		ast_event_unsubscribe(event_sub);
+	}
 	event_sub = 0;
-	return 0;
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static int load_module(void)
@@ -258,8 +251,9 @@
 		if ((tmp = ast_variable_retrieve(cfg, "radius", "radiuscfg")))
 			ast_copy_string(radiuscfg, tmp, sizeof(radiuscfg));
 		ast_config_destroy(cfg);
-	} else 
-		return AST_MODULE_LOAD_DECLINE;
+	} else {
+		return AST_MODULE_LOAD_DECLINE;
+	}
 	
 	/* start logging */
 	rc_openlog("asterisk");
@@ -278,11 +272,11 @@
 	
 	event_sub = ast_event_subscribe(AST_EVENT_CEL, radius_log, "CEL Radius Logging", NULL, AST_EVENT_IE_END);
 	
-	if (!event_sub)
-		return AST_MODULE_LOAD_DECLINE;
-	else
+	if (!event_sub) {
+		return AST_MODULE_LOAD_DECLINE;
+	} else {
 		return AST_MODULE_LOAD_SUCCESS;
-	
+	}
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "RADIUS CEL Backend");

Modified: team/group/newcdr/cel/cel_sqlite3_custom.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_sqlite3_custom.c?view=diff&rev=163719&r1=163718&r2=163719
==============================================================================
--- team/group/newcdr/cel/cel_sqlite3_custom.c (original)
+++ team/group/newcdr/cel/cel_sqlite3_custom.c Fri Dec 12 14:14:06 2008
@@ -83,9 +83,9 @@
 	const char *tmp;
 
 	if (!(cfg = ast_config_load(config_file, config_flags))) {
-		if (reload)
+		if (reload) {
 			ast_log(LOG_WARNING, "%s: Failed to reload configuration file.\n", name);
-		else {
+		} else {
 			ast_log(LOG_WARNING,
 					"%s: Failed to load configuration file. Module not activated.\n",
 					name);
@@ -93,8 +93,9 @@
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
-	if (!reload)
+	if (!reload) {
 		ast_mutex_lock(&lock);
+	}
 
 	if (!(mappingvar = ast_variable_browse(cfg, "master"))) {
 		/* nothing configured */
@@ -105,17 +106,17 @@
 	
 	/* Mapping must have a table name */
 	tmp = ast_variable_retrieve(cfg, "master", "table");
-	if (!ast_strlen_zero(tmp))
+	if (!ast_strlen_zero(tmp)) {
 		ast_copy_string(table, tmp, sizeof(table));
-	else {
+	} else {
 		ast_log(LOG_WARNING, "%s: Table name not specified.  Assuming cel.\n", name);
 		strcpy(table, "cel");
 	}
 
 	tmp = ast_variable_retrieve(cfg, "master", "columns");
-	if (!ast_strlen_zero(tmp))
+	if (!ast_strlen_zero(tmp)) {
 		ast_copy_string(columns, tmp, sizeof(columns));
-	else {
+	} else {
 		ast_log(LOG_WARNING, "%s: Column names not specified. Module not loaded.\n",
 				name);
 		ast_config_destroy(cfg);
@@ -123,9 +124,9 @@
 	}
 
 	tmp = ast_variable_retrieve(cfg, "master", "values");
-	if (!ast_strlen_zero(tmp))
+	if (!ast_strlen_zero(tmp)) {
 		ast_copy_string(values, tmp, sizeof(values));
-	else {
+	} else {
 		ast_log(LOG_WARNING, "%s: Values not specified. Module not loaded.\n", name);
 		ast_config_destroy(cfg);
 		return AST_MODULE_LOAD_DECLINE;
@@ -220,6 +221,7 @@
 	char *sql_cmd;
 
 	if (load_config(0) != AST_MODULE_LOAD_SUCCESS) {
+		ast_log(LOG_NOTICE,"CEL sqlite3 declining to load, config problem.\n");
 		return AST_MODULE_LOAD_DECLINE;
 	}
 	

Modified: team/group/newcdr/cel/cel_tds.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_tds.c?view=diff&rev=163719&r1=163718&r2=163719
==============================================================================
--- team/group/newcdr/cel/cel_tds.c (original)
+++ team/group/newcdr/cel/cel_tds.c Fri Dec 12 14:14:06 2008
@@ -130,8 +130,9 @@
 	eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
 	eventtime.tv_sec = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
 	eventtime.tv_usec = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC);
-	if (eventtype == CEL_USER_DEFINED)
+	if (eventtype == CEL_USER_DEFINED) {
 		userdefname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME);
+	}
 	cid_name = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNAME);
 	cid_num = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNUM);
 	cid_ani = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDANI);
@@ -151,10 +152,11 @@
 
 	ast_mutex_lock(&tds_lock);
 
-	if (eventtype == CEL_USER_DEFINED)
+	if (eventtype == CEL_USER_DEFINED) {
 		eventname = userdefname;
-	else
+	} else {
 		eventname = ast_cel_eventtype2str(eventtype);
+	}
 
 	accountcode_ai = anti_injection(accountcode, 20);
 	clidnum_ai = anti_injection(cid_num, 80);
@@ -315,7 +317,6 @@
 			memmove(srh_ptr, srh_ptr + strlen(known_bad[idx]), strlen(srh_ptr + strlen(known_bad[idx])) + 1);
 		}
 	}
-
 	return buf;
 }
 
@@ -368,7 +369,6 @@
 		dbclose(settings->dbproc);
 		settings->dbproc = NULL;
 	}
-
 	settings->connected = 0;
 
 	return 0;
@@ -427,8 +427,9 @@
 
 static int tds_unload_module(void)
 {
-	if (event_sub)
+	if (event_sub) {
 		ast_event_unsubscribe(event_sub);
+	}
 	event_sub = 0;
 
 	if (settings) {
@@ -474,12 +475,15 @@
 	if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
 		ast_log(LOG_NOTICE, "Unable to load TDS config for CELs: %s\n", config);
 		return 0;
-	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
+		ast_log(LOG_NOTICE, "cel_tds not changed, no need to reload: %s\n", config);
 		return 0;
+	}
 
 	if (!ast_variable_browse(cfg, "global")) {
 		/* nothing configured */
 		ast_config_destroy(cfg);
+		ast_log(LOG_NOTICE, "cel_tds has no global category, nothing to configure.\n");
 		return 0;
 	}
 
@@ -592,19 +596,21 @@
 		ast_free(settings);
 		settings = NULL;
 		dbexit();
+		ast_log(LOG_WARNING,"cel_tds module had config problems; declining load\n");
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
 	/* Register MSSQL CEL handler */
 	event_sub = ast_event_subscribe(AST_EVENT_CEL, tds_log, "CEL TDS logging backend", NULL, AST_EVENT_IE_END);
-	if (!event_sub)
-	{
+	if (!event_sub) {
 		ast_log(LOG_ERROR, "Unable to register MSSQL CEL handling\n");
 		ast_string_field_free_memory(settings);
 		ast_free(settings);
 		settings = NULL;
 		dbexit();
 		return AST_MODULE_LOAD_DECLINE;
+	} else {
+		ast_log(LOG_NOTICE, "Registered MSSQL TDS for CEL handling\n");
 	}
 
 	return AST_MODULE_LOAD_SUCCESS;

Modified: team/group/newcdr/main/cel.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/main/cel.c?view=diff&rev=163719&r1=163718&r2=163719
==============================================================================
--- team/group/newcdr/main/cel.c (original)
+++ team/group/newcdr/main/cel.c Fri Dec 12 14:14:06 2008
@@ -64,21 +64,20 @@
 static char *handle_cli_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct ast_event_sub *sub = 0;
-
+	
 	switch (cmd) {
-        case CLI_INIT:
-                e->command = "cel show status";
-                e->usage =
-                        "Usage: cel show status\n"
-                        "       Displays the Channel Event Logging system status.\n";
-                return NULL;
-        case CLI_GENERATE:
-                return NULL;
-        }
-
-	if (a->argc > 3)
+	case CLI_INIT:
+		e->command = "cel show status";
+		e->usage =
+			"Usage: cel show status\n"
+			"       Displays the Channel Event Logging system status.\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+	if (a->argc > 3) {
 		return CLI_SHOWUSAGE;
-
+	}
 	ast_cli(a->fd, "CEL logging: %s\n", cel_enabled ? "enabled" : "disabled");
 	
 	if (cel_enabled) {
@@ -88,7 +87,6 @@
 		}
 		ast_event_unlock_subscribers(AST_EVENT_CEL);
 	}
-
 	return CLI_SUCCESS;
 }
 
@@ -96,60 +94,61 @@
 
 static enum ast_cel_eventtype configevent2eventtype(char *eventname)
 {
-	if (strcasecmp(eventname,"ALL")==0)
+	if (strcasecmp(eventname,"ALL")==0) {
 		return 0;
-	else if (strcasecmp(eventname,"CHAN_START")==0)
+	} else if (strcasecmp(eventname,"CHAN_START")==0) {
 		return CEL_CHANNEL_START;
-	else if (strcasecmp(eventname,"CHAN_END")==0)
+	} else if (strcasecmp(eventname,"CHAN_END")==0) {
 		return CEL_CHANNEL_END;
-	else if (strcasecmp(eventname,"ANSWER")==0)
+	} else if (strcasecmp(eventname,"ANSWER")==0) {
 		return CEL_ANSWER;
-	else if (strcasecmp(eventname,"HANGUP")==0)
+	} else if (strcasecmp(eventname,"HANGUP")==0) {
 		return CEL_HANGUP;
-	else if (strcasecmp(eventname,"APP_START")==0)
+	} else if (strcasecmp(eventname,"APP_START")==0) {
 		return CEL_APP_START;
-	else if (strcasecmp(eventname,"APP_END")==0)
+	} else if (strcasecmp(eventname,"APP_END")==0) {
 		return CEL_APP_END;
-	else if (strcasecmp(eventname,"BRIDGE_START")==0)

[... 381 lines stripped ...]



More information about the svn-commits mailing list