[asterisk-commits] murf: branch group/newcdr r165879 - in /team/group/newcdr: cel/ configs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 18 19:29:06 CST 2008


Author: murf
Date: Thu Dec 18 19:29:05 2008
New Revision: 165879

URL: http://svn.digium.com/view/asterisk?view=rev&rev=165879
Log:
spruce up the cel backends

Modified:
    team/group/newcdr/cel/cel_csv.c
    team/group/newcdr/cel/cel_custom.c
    team/group/newcdr/cel/cel_pgsql.c
    team/group/newcdr/cel/cel_radius.c
    team/group/newcdr/cel/cel_sqlite.c
    team/group/newcdr/cel/cel_sqlite3_custom.c
    team/group/newcdr/configs/cel.conf.sample
    team/group/newcdr/configs/cel_odbc.conf.sample

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=165879&r1=165878&r2=165879
==============================================================================
--- team/group/newcdr/cel/cel_csv.c (original)
+++ team/group/newcdr/cel/cel_csv.c Thu Dec 18 19:29:05 2008
@@ -57,8 +57,6 @@
 #define DATE_FORMAT "%Y-%m-%d %T"
 
 static int usegmtime = 0;
-static int loguniqueid = 0;
-static int loguserfield = 0;
 static int loaded = 0;
 static char *config = "cel.conf";
 static struct ast_event_sub *event_sub = 0;
@@ -101,8 +99,6 @@
 	const char *tmp;
 
 	usegmtime = 0;
-	loguniqueid = 0;
-	loguserfield = 0;
 	
 	cfg = ast_config_load(config,config_flags);
 	
@@ -123,26 +119,9 @@
 	if (tmp) {
 		usegmtime = ast_true(tmp);
 		if (usegmtime) {
-			if (option_debug)
+			if (option_debug) {
 				ast_log(LOG_DEBUG, "logging time in GMT\n");
-		}
-	}
-
-	tmp = ast_variable_retrieve(cfg, "csv", "loguniqueid");
-	if (tmp) {
-		loguniqueid = ast_true(tmp);
-		if (loguniqueid) {
-			if (option_debug)
-				ast_log(LOG_DEBUG, "logging CDR field UNIQUEID\n");
-		}
-	}
-
-	tmp = ast_variable_retrieve(cfg, "csv", "loguserfield");
-	if (tmp) {
-		loguserfield = ast_true(tmp);
-		if (loguserfield) {
-			if (option_debug)
-				ast_log(LOG_DEBUG, "logging CDR user-defined field\n");
+			}
 		}
 	}
 
@@ -167,8 +146,9 @@
 			error = 0;
 			break;
 		}
-		if (s[spos] == '\"')
+		if (s[spos] == '\"') {
 			buf[pos++] = '\"';
+		}
 		buf[pos++] = s[spos];
 		spos++;
 	}
@@ -185,8 +165,8 @@
 	char tmp[32];
 	int pos = strlen(buf);
 	snprintf(tmp, sizeof(tmp), "%d", s);
-	if (pos + strlen(tmp) > bufsize - 3)
-		return -1;
+	if (pos + strlen(tmp) > bufsize - 3) {
+		return -1;}
 	strncat(buf, tmp, bufsize - strlen(buf) - 1);
 	pos = strlen(buf);
 	buf[pos++] = ',';
@@ -251,8 +231,7 @@
 	/* AMA Flags */
 	append_string(buf, ast_cel_flags2str(amaflag), bufsize);
 	/* Unique ID */
-	if (loguniqueid)
-		append_string(buf, uniqueid, bufsize);
+	append_string(buf, uniqueid, bufsize);
 	append_string(buf, linkedid, bufsize);
 	/* Userfield */
 	append_string(buf, userfield, bufsize);
@@ -313,8 +292,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);
@@ -353,8 +333,9 @@
 		}
 		ast_mutex_unlock(&mf_lock);
 		if (!ast_strlen_zero(accountcode)) {
-			if (writefile(buf, accountcode))
+			if (writefile(buf, accountcode)) {
 				ast_log(LOG_WARNING, "Unable to write CSV record to account file '%s' : %s\n", accountcode, strerror(errno));
+			}
 		}
 	}
 	return;
@@ -378,7 +359,7 @@
 
 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;
 	}

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=165879&r1=165878&r2=165879
==============================================================================
--- team/group/newcdr/cel/cel_custom.c (original)
+++ team/group/newcdr/cel/cel_custom.c Thu Dec 18 19:29:05 2008
@@ -73,9 +73,9 @@
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 	int res = -1;
 
-	if ((cfg = ast_config_load("cel_custom.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+	if ((cfg = ast_config_load("cel_custom.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
 		return 0;
-	
+	}
 	strcpy(format, "");
 	strcpy(master, "");
 	ast_mutex_lock(&lock);

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=165879&r1=165878&r2=165879
==============================================================================
--- team/group/newcdr/cel/cel_pgsql.c (original)
+++ team/group/newcdr/cel/cel_pgsql.c Thu Dec 18 19:29:05 2008
@@ -180,9 +180,9 @@
 			ast_mutex_unlock(&pgsql_lock);
 			return;
 		}
-		if (option_debug > 1)
+		if (option_debug > 1) {
 			ast_log(LOG_DEBUG, "cel_pgsql: inserting a CEL record.\n");
-
+		}
 		snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s (eventtime,cidname,cidnum,cidani,cidrdnis,ciddnid,exten,context,channel,"
 				 "app,appdata,amaflags,accountcode,uniqueid,userfield,peer,linkedid) VALUES"
 				 " ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d,'%s','%s','%s','%s','%s')",
@@ -190,9 +190,9 @@
 				 exten_esc, context_esc,channel_esc, app_esc, appdata_esc,
 				 amaflag, accountcode_esc, uniqueid_esc, userfield_esc, peer_esc,linkedid_esc);
 		
-		if (option_debug > 2)
+		if (option_debug > 2) {
 			ast_log(LOG_DEBUG, "cel_pgsql: SQL command executed:  %s\n",sqlcmd);
-		
+		}
 		/* Test to be sure we're still connected... */
 		/* If we're connected, and connection is working, good. */
 		/* Otherwise, attempt reconnect.  If it fails... sorry... */
@@ -224,8 +224,7 @@
 				ast_log(LOG_ERROR, "cel_pgsql: Connection reestablished.\n");
 				connected = 1;
 				result = PQexec(conn, sqlcmd);
-				if ( PQresultStatus(result) != PGRES_COMMAND_OK)
-				{
+				if ( PQresultStatus(result) != PGRES_COMMAND_OK) {
 					pgerror = PQresultErrorMessage(result);
 					ast_log(LOG_ERROR,"cel_pgsql: HARD ERROR!  Attempted reconnection failed.  DROPPING CALL RECORD!\n");
 					ast_log(LOG_ERROR,"cel_pgsql: Reason: %s\n", pgerror);

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=165879&r1=165878&r2=165879
==============================================================================
--- team/group/newcdr/cel/cel_radius.c (original)
+++ team/group/newcdr/cel/cel_radius.c Thu Dec 18 19:29:05 2008
@@ -196,8 +196,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);
@@ -246,10 +247,9 @@
 
 	if ((cfg = ast_config_load(cel_config, config_flags))) {
 		ast_set2_flag(&global_flags, ast_true(ast_variable_retrieve(cfg, "radius", "usegmtime")), RADIUS_FLAG_USEGMTIME);
-		ast_set2_flag(&global_flags, ast_true(ast_variable_retrieve(cfg, "radius", "loguniqueid")), RADIUS_FLAG_LOGUNIQUEID);
-		ast_set2_flag(&global_flags, ast_true(ast_variable_retrieve(cfg, "radius", "loguserfield")), RADIUS_FLAG_LOGUSERFIELD);
-		if ((tmp = ast_variable_retrieve(cfg, "radius", "radiuscfg")))
+		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;

Modified: team/group/newcdr/cel/cel_sqlite.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_sqlite.c?view=diff&rev=165879&r1=165878&r2=165879
==============================================================================
--- team/group/newcdr/cel/cel_sqlite.c (original)
+++ team/group/newcdr/cel/cel_sqlite.c Thu Dec 18 19:29:05 2008
@@ -114,8 +114,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);
@@ -172,8 +173,9 @@
 				,uniqueid
 #				endif
 			);
-		if (res != SQLITE_BUSY && res != SQLITE_LOCKED)
+		if (res != SQLITE_BUSY && res != SQLITE_LOCKED) {
 			break;
+		}
 		usleep(200);
 	}
 	
@@ -188,10 +190,12 @@
 
 static int unload_module(void)
 {
-	if (db)
+	if (db) {
 		sqlite_close(db);
-	if (event_sub)
+	}
+	if (event_sub) {
 		ast_event_unsubscribe(event_sub);
+	}
 	event_sub = 0;
 	return 0;
 }
@@ -241,8 +245,9 @@
 	return AST_MODULE_LOAD_SUCCESS;
 
 err:
-	if (db)
+	if (db) {
 		sqlite_close(db);
+	}
 	return AST_MODULE_LOAD_DECLINE;
 }
 

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=165879&r1=165878&r2=165879
==============================================================================
--- team/group/newcdr/cel/cel_sqlite3_custom.c (original)
+++ team/group/newcdr/cel/cel_sqlite3_custom.c Thu Dec 18 19:29:05 2008
@@ -132,9 +132,9 @@
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
-	if (!reload)
+	if (!reload) {
 		ast_mutex_unlock(&lock);
-
+	}
 	ast_config_destroy(cfg);
 
 	return AST_MODULE_LOAD_SUCCESS;
@@ -146,8 +146,9 @@
 	char *out = to;
 
 	for (; *from; from++) {
-		if (*from == '\'' || *from == '\\')
+		if (*from == '\'' || *from == '\\') {
 			*out++ = *from;
+		}
 		*out++ = *from;
 	}
 	*out = '\0';
@@ -186,8 +187,9 @@
 
 	for (count = 0; count < 5; count++) {
 		res = sqlite3_exec(db, sql_cmd, NULL, NULL, &zErr);
-		if (res != SQLITE_BUSY && res != SQLITE_LOCKED)
+		if (res != SQLITE_BUSY && res != SQLITE_LOCKED) {
 			break;
+		}
 		usleep(200);
 	}
 
@@ -203,11 +205,13 @@
 
 static int unload_module(void)
 {
-	if (db)
+	if (db) {
 		sqlite3_close(db);
-
-	if (event_sub)
+	}
+
+	if (event_sub) {
 		ast_event_unsubscribe(event_sub);
+	}
 	event_sub = 0;
 
 	return 0;
@@ -251,8 +255,9 @@
 		if (res) {
 			ast_log(LOG_ERROR, "%s: Unable to create table '%s': %s.\n", name, table, zErr);
 			sqlite3_free(zErr);
-			if (db)
+			if (db) {
 				sqlite3_close(db);
+			}
 			return AST_MODULE_LOAD_DECLINE;
 		}
 	}

Modified: team/group/newcdr/configs/cel.conf.sample
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/configs/cel.conf.sample?view=diff&rev=165879&r1=165878&r2=165879
==============================================================================
--- team/group/newcdr/configs/cel.conf.sample (original)
+++ team/group/newcdr/configs/cel.conf.sample Thu Dec 18 19:29:05 2008
@@ -57,4 +57,3 @@
 
 [csv]
 usegmtime=yes ;log date/time in GMT
-loguniqueid=yes ;log uniqueid

Modified: team/group/newcdr/configs/cel_odbc.conf.sample
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/configs/cel_odbc.conf.sample?view=diff&rev=165879&r1=165878&r2=165879
==============================================================================
--- team/group/newcdr/configs/cel_odbc.conf.sample (original)
+++ team/group/newcdr/configs/cel_odbc.conf.sample Thu Dec 18 19:29:05 2008
@@ -6,7 +6,6 @@
 ;dsn=MySQL-test
 ;username=username
 ;password=password
-;loguniqueid=yes
 ;dispositionstring=yes
 ;table=cel		;"cel" is default table name
 ;usegmtime=no             ; set to "yes" to log in GMT




More information about the asterisk-commits mailing list