[asterisk-commits] seanbright: branch group/newcdr r202102 - in /team/group/newcdr: cel/ include...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 19 17:55:51 CDT 2009


Author: seanbright
Date: Fri Jun 19 17:55:48 2009
New Revision: 202102

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=202102
Log:
Extract a big chunk of common code into ast_cel_fill_record to simplify backends

Modified:
    team/group/newcdr/cel/cel_adaptive_odbc.c
    team/group/newcdr/cel/cel_manager.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_tds.c
    team/group/newcdr/include/asterisk/cel.h
    team/group/newcdr/main/cel.c

Modified: team/group/newcdr/cel/cel_adaptive_odbc.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/cel/cel_adaptive_odbc.c?view=diff&rev=202102&r1=202101&r2=202102
==============================================================================
--- team/group/newcdr/cel/cel_adaptive_odbc.c (original)
+++ team/group/newcdr/cel/cel_adaptive_odbc.c Fri Jun 19 17:55:48 2009
@@ -352,48 +352,23 @@
 	char colbuf[1024], *colptr;
 	SQLHSTMT stmt = NULL;
 	SQLLEN rows = 0;
-	enum ast_cel_event_type eventtype;
-	const char *userdefname = "";
-	struct timeval eventtime = {0};
-	const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
-	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *peeraccount, *uniqueid, *linkedid, *userfield, *peer;
-	unsigned int amaflag;
-
-	if (!sql || !sql2) {
+	struct ast_cel_event_record *record = ast_cel_fill_record(event);
+
+	if (!sql || !sql2 || !record) {
 		if (sql)
 			ast_free(sql);
 		if (sql2)
 			ast_free(sql2);
+		if (record)
+			ast_free(record);
 		return;
 	}
-	eventtype = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
-	eventtime.tv_sec = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
-	eventtime.tv_usec = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC);
-	if (eventtype == AST_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);
-	cid_rdnis = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDRDNIS);
-	cid_dnid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDDNID);
-	exten = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_EXTEN);
-	context = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CONTEXT);
-	channame = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CHANNAME);
-	appname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPNAME);
-	appdata = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPDATA);
-	accountcode = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
-	peeraccount = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
-	uniqueid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_UNIQUEID);
-	linkedid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_LINKEDID);
-	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);
 
 	if (AST_RWLIST_RDLOCK(&odbc_tables)) {
 		ast_log(LOG_ERROR, "Unable to lock table list.  Insert CEL(s) failed.\n");
 		ast_free(sql);
 		ast_free(sql2);
+		ast_free(record);
 		return;
 	}
 
@@ -418,48 +393,48 @@
 			if (entry->staticvalue) {
 				colptr = ast_strdupa(entry->staticvalue);
 			} else if (datefield) {
-				struct timeval date_tv = eventtime;
+				struct timeval date_tv = record->event_time;
 				struct ast_tm tm = { 0, };
 				ast_localtime(&date_tv, &tm, tableptr->usegmtime ? "UTC" : NULL);
 				ast_strftime(colbuf, sizeof(colbuf), "%Y-%m-%d %H:%M:%S", &tm);
 				colptr = colbuf;
 			} else {
 				if (strcmp(entry->celname, "userdeftype") == 0) {
-					strncpy(colbuf, userdefname, sizeof(colbuf));
+					strncpy(colbuf, record->user_defined_name, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "cid_name") == 0) {
-					strncpy(colbuf, cid_name, sizeof(colbuf));
+					strncpy(colbuf, record->caller_id_name, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "cid_num") == 0) {
-					strncpy(colbuf, cid_num, sizeof(colbuf));
+					strncpy(colbuf, record->caller_id_num, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "cid_ani") == 0) {
-					strncpy(colbuf, cid_ani, sizeof(colbuf));
+					strncpy(colbuf, record->caller_id_ani, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "cid_rdnis") == 0) {
-					strncpy(colbuf, cid_rdnis, sizeof(colbuf));
+					strncpy(colbuf, record->caller_id_rdnis, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "cid_dnid") == 0) {
-					strncpy(colbuf, cid_dnid, sizeof(colbuf));
+					strncpy(colbuf, record->caller_id_dnid, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "exten") == 0) {
-					strncpy(colbuf, exten, sizeof(colbuf));
+					strncpy(colbuf, record->extension, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "context") == 0) {
-					strncpy(colbuf, context, sizeof(colbuf));
+					strncpy(colbuf, record->context, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "channame") == 0) {
-					strncpy(colbuf, channame, sizeof(colbuf));
+					strncpy(colbuf, record->channel_name, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "appname") == 0) {
-					strncpy(colbuf, appname, sizeof(colbuf));
+					strncpy(colbuf, record->application_name, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "appdata") == 0) {
-					strncpy(colbuf, appdata, sizeof(colbuf));
+					strncpy(colbuf, record->application_data, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "accountcode") == 0) {
-					strncpy(colbuf, accountcode, sizeof(colbuf));
+					strncpy(colbuf, record->account_code, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "peeraccount") == 0) {
-					strncpy(colbuf, peeraccount, sizeof(colbuf));
+					strncpy(colbuf, record->peer_account, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "uniqueid") == 0) {
-					strncpy(colbuf, uniqueid, sizeof(colbuf));
+					strncpy(colbuf, record->unique_id, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "linkedid") == 0) {
-					strncpy(colbuf, linkedid, sizeof(colbuf));
+					strncpy(colbuf, record->linked_id, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "userfield") == 0) {
-					strncpy(colbuf, userfield, sizeof(colbuf));
+					strncpy(colbuf, record->user_field, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "peer") == 0) {
-					strncpy(colbuf, peer, sizeof(colbuf));
+					strncpy(colbuf, record->peer, sizeof(colbuf));
 				} else if (strcmp(entry->celname, "amaflags") == 0) {
-					snprintf(colbuf, sizeof(colbuf), "%d", amaflag);
+					snprintf(colbuf, sizeof(colbuf), "%d", record->amaflag);
 				} else {
 					colbuf[0] = 0;
 				}
@@ -496,7 +471,7 @@
 					 * form (but only when we're dealing with a character-based field).
 					 */
 					if (strcasecmp(entry->name, "eventtype") == 0) {
-						snprintf(colbuf, sizeof(colbuf), "%s", ast_cel_get_type_name(eventtype));
+						snprintf(colbuf, sizeof(colbuf), "%s", record->event_name);
 					}
 
 					/* Truncate too-long fields */
@@ -591,7 +566,7 @@
 					{
 						int integer = 0;
 						if (strcasecmp(entry->name, "eventtype") == 0) {
-							integer = (int)eventtype;
+							integer = (int) record->event_type;
 						} else if (sscanf(colptr, "%d", &integer) != 1) {
 							ast_log(LOG_WARNING, "CEL variable %s is not an integer.\n", entry->name);
 							continue;
@@ -606,7 +581,7 @@
 					{
 						long long integer = 0;
 						if (strcasecmp(entry->name, "eventtype") == 0) {
-							integer = (long long)eventtype;
+							integer = (long long) record->event_type;
 						} else if (sscanf(colptr, "%lld", &integer) != 1) {
 							ast_log(LOG_WARNING, "CEL variable %s is not an integer.\n", entry->name);
 							continue;
@@ -621,7 +596,7 @@
 					{
 						short integer = 0;
 						if (strcasecmp(entry->name, "eventtype") == 0) {
-							integer = (short)eventtype;
+							integer = (short) record->event_type;
 						} else if (sscanf(colptr, "%hd", &integer) != 1) {
 							ast_log(LOG_WARNING, "CEL variable %s is not an integer.\n", entry->name);
 							continue;
@@ -636,7 +611,7 @@
 					{
 						char integer = 0;
 						if (strcasecmp(entry->name, "eventtype") == 0) {
-							integer = (char)eventtype;
+							integer = (char) record->event_type;
 						} else if (sscanf(colptr, "%hhd", &integer) != 1) {
 							ast_log(LOG_WARNING, "CEL variable %s is not an integer.\n", entry->name);
 							continue;
@@ -651,7 +626,7 @@
 					{
 						char integer = 0;
 						if (strcasecmp(entry->name, "eventtype") == 0) {
-							integer = (char)eventtype;
+							integer = (char) record->event_type;
 						} else if (sscanf(colptr, "%hhd", &integer) != 1) {
 							ast_log(LOG_WARNING, "CEL variable %s is not an integer.\n", entry->name);
 							continue;
@@ -669,7 +644,7 @@
 					{
 						double number = 0.0;
 						if (strcasecmp(entry->name, "eventtype") == 0) {
-							number = (double)eventtype;
+							number = (double)record->event_type;
 						} else if (sscanf(colptr, "%lf", &number) != 1) {
 							ast_log(LOG_WARNING, "CEL variable %s is not an numeric type.\n", entry->name);
 							continue;
@@ -686,7 +661,7 @@
 					{
 						double number = 0.0;
 						if (strcasecmp(entry->name, "eventtype") == 0) {
-							number = (double)eventtype;
+							number = (double)record->event_type;
 						} else if (sscanf(colptr, "%lf", &number) != 1) {
 							ast_log(LOG_WARNING, "CEL variable %s is not an numeric type.\n", entry->name);
 							continue;
@@ -736,6 +711,7 @@
 
 	ast_free(sql);
 	ast_free(sql2);
+	ast_free(record);
 	return;
 }
 

Modified: team/group/newcdr/cel/cel_manager.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/cel/cel_manager.c?view=diff&rev=202102&r1=202101&r2=202102
==============================================================================
--- team/group/newcdr/cel/cel_manager.c (original)
+++ team/group/newcdr/cel/cel_manager.c Fri Jun 19 17:55:48 2009
@@ -137,47 +137,21 @@
 
 static void manager_log(const struct ast_event *event, void *userdata)
 {
-	struct timeval t;
 	struct ast_tm timeresult;
-	char strStartTime[80] = "";
-	enum ast_cel_event_type event_type;
-	const char *userdefname = 0;
-	struct timeval eventtime = {0};
-	const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
-	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *linkedid, *userfield, *peer;
-	unsigned int amaflag;
-
-	if (!enablecel) {
+	char start_time[80] = "";
+	struct ast_cel_event_record *record = ast_cel_fill_record(event);
+
+	if (!enablecel || !record) {
+		if (record) {
+			ast_free(record);
+		}
 		return;
 	}
-	ast_log(LOG_NOTICE,"Logging event to manager interface\n");
-
-	event_type = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
-	eventtime.tv_sec = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
-	eventtime.tv_usec = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC);
-	if (event_type == AST_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);
-	cid_rdnis = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDRDNIS);
-	cid_dnid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDDNID);
-	exten = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_EXTEN);
-	context = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CONTEXT);
-	channame = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CHANNAME);
-	appname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPNAME);
-	appdata = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPDATA);
-	accountcode = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
-	uniqueid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_UNIQUEID);
-	linkedid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_LINKEDID);
-	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);
-
-	t = eventtime;
-	ast_localtime(&t, &timeresult, NULL);
-	ast_strftime(strStartTime, sizeof(strStartTime), DATE_FORMAT, &timeresult);
+
+	ast_log(LOG_NOTICE, "Logging event to manager interface\n");
+
+	ast_localtime(&record->event_time, &timeresult, NULL);
+	ast_strftime(start_time, sizeof(start_time), DATE_FORMAT, &timeresult);
 
 	manager_event(EVENT_FLAG_CALL, "CEL",
         "EventName: %s\r\n"
@@ -198,10 +172,16 @@
 	    "LinkedID: %s\r\n"
 	    "Userfield: %s\r\n"
 	    "Peer: %s\r\n",
-				  (event_type == AST_CEL_USER_DEFINED ? userdefname : ast_cel_get_type_name(event_type)),
-				  accountcode, cid_num, cid_name, cid_ani, cid_rdnis, cid_dnid,
-				  exten, context, channame, appname, appdata, strStartTime,
-				  ast_cel_flags2str(amaflag), uniqueid, linkedid, userfield, peer);
+		record->event_name, record->account_code, record->caller_id_num,
+		record->caller_id_name, record->caller_id_ani, record->caller_id_rdnis,
+		record->caller_id_dnid, record->extension, record->context, record->channel_name,
+		record->application_name, record->application_data, start_time,
+		ast_cel_flags2str(record->amaflag), record->unique_id, record->linked_id,
+		record->user_field, record->peer);
+
+	ast_free(record);
+
+	return;
 }
 
 static int unload_module(void)

Modified: team/group/newcdr/cel/cel_pgsql.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/cel/cel_pgsql.c?view=diff&rev=202102&r1=202101&r2=202102
==============================================================================
--- team/group/newcdr/cel/cel_pgsql.c (original)
+++ team/group/newcdr/cel/cel_pgsql.c Fri Jun 19 17:55:48 2009
@@ -118,40 +118,11 @@
 	struct ast_tm tm;
 	char timestr[128];
 	char *pgerror;
-	enum ast_cel_event_type event_type;
-	const char *userdefname = 0;
-	struct timeval eventtime = {0};
-	const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
-	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *peeraccount, *uniqueid, *linkedid, *userfield, *peer;
-	unsigned int amaflag;
-
-	event_type = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
-	eventtime.tv_sec = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
-	eventtime.tv_usec = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC);
-	if (event_type == AST_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);
-	cid_rdnis = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDRDNIS);
-	cid_dnid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDDNID);
-	exten = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_EXTEN);
-	context = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CONTEXT);
-	channame = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CHANNAME);
-	appname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPNAME);
-	appdata = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPDATA);
-	accountcode = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
-	peeraccount = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
-	uniqueid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_UNIQUEID);
-	linkedid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_LINKEDID);
-	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);
+	struct ast_cel_event_record *record = ast_cel_fill_record(event);
 
 	ast_mutex_lock(&pgsql_lock);
 
-	ast_localtime(&eventtime,&tm,NULL);
+	ast_localtime(&record->event_time, &tm, NULL);
 	ast_strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
 
 	if ((!connected) && pghostname && pgdbuser && pgpassword && pgdbname) {
@@ -186,6 +157,8 @@
 		ast_str_set(&sql, 0, "INSERT INTO %s (", table);
 		ast_str_set(&sql2, 0, " VALUES (");
 
+#define SEP (first ? "" : ",")
+
 		AST_RWLIST_RDLOCK(&psql_columns);
 		AST_RWLIST_TRAVERSE(&psql_columns, cur, list) {
 			LENGTHEN_BUF1(strlen(cur->name) + 2);
@@ -194,77 +167,79 @@
 			if (strcmp(cur->name, "eventtime") == 0) {
 				if (strncmp(cur->type, "int", 3) == 0) {
 					LENGTHEN_BUF2(13);
-					ast_str_append(&sql2, 0, "%s%ld", first ? "" : ",", eventtime.tv_sec);
+					ast_str_append(&sql2, 0, "%s%ld", SEP, record->event_time.tv_sec);
 				} else if (strncmp(cur->type, "float", 5) == 0) {
 					LENGTHEN_BUF2(31);
-					ast_str_append(&sql2, 0, "%s%f", first ? "" : ",", (double)eventtime.tv_sec + (double)eventtime.tv_usec / 1000000.0);
+					ast_str_append(&sql2, 0, "%s%f",
+						SEP,
+						(double) record->event_time.tv_sec +
+						(double) record->event_time.tv_usec / 1000000.0);
 				} else {
 					/* char, hopefully */
 					LENGTHEN_BUF2(31);
-					ast_localtime(&eventtime, &tm, NULL);
+					ast_localtime(&record->event_time, &tm, NULL);
 					ast_strftime(buf, sizeof(buf), DATE_FORMAT, &tm);
-					ast_str_append(&sql2, 0, "%s'%s'", first ? "" : ",", buf);
+					ast_str_append(&sql2, 0, "%s'%s'", SEP, buf);
 				}
 			} else if (strcmp(cur->name, "eventtype") == 0) {
 				if (cur->type[0] == 'i') {
 					/* Get integer, no need to escape anything */
 					LENGTHEN_BUF2(5);
-					ast_str_append(&sql2, 0, "%s%d", first ? "" : ",", (int)event_type);
+					ast_str_append(&sql2, 0, "%s%d", SEP, (int) record->event_type);
 				} else if (strncmp(cur->type, "float", 5) == 0) {
 					LENGTHEN_BUF2(31);
-					ast_str_append(&sql2, 0, "%s%f", first ? "" : ",", (double)event_type);
+					ast_str_append(&sql2, 0, "%s%f", SEP, (double) record->event_type);
 				} else {
 					/* Char field, probably */
-					const char *t2 = ast_cel_get_type_name(event_type);
-					LENGTHEN_BUF2(strlen(t2)+1);
-					ast_str_append(&sql2, 0, "%s'%s'", first ? "" : ",", t2);
+					LENGTHEN_BUF2(strlen(record->event_name) + 1);
+					ast_str_append(&sql2, 0, "%s'%s'", SEP, record->event_name);
 				}
 			} else if (strcmp(cur->name, "amaflags") == 0) {
 				if (strncmp(cur->type, "int", 3) == 0) {
 					/* Integer, no need to escape anything */
 					LENGTHEN_BUF2(13);
-					ast_str_append(&sql2, 0, "%s%d", first ? "" : ",", amaflag);
+					ast_str_append(&sql2, 0, "%s%d", SEP, record->amaflag);
 				} else {
 					/* Although this is a char field, there are no special characters in the values for these fields */
 					LENGTHEN_BUF2(31);
-					ast_str_append(&sql2, 0, "%s'%d'", first ? "" : ",", amaflag);
+					ast_str_append(&sql2, 0, "%s'%d'", SEP, record->amaflag);
 				}
 			} else {
 				/* Arbitrary field, could be anything */
 				if (strcmp(cur->name, "userdeftype") == 0) {
-					value = userdefname;
+					value = record->user_defined_name;
 				} else if (strcmp(cur->name, "cid_name") == 0) {
-					value = cid_name;
+					value = record->caller_id_name;
 				} else if (strcmp(cur->name, "cid_num") == 0) {
-					value = cid_num;
+					value = record->caller_id_num;
 				} else if (strcmp(cur->name, "cid_ani") == 0) {
-					value = cid_ani;
+					value = record->caller_id_ani;
 				} else if (strcmp(cur->name, "cid_rdnis") == 0) {
-					value = cid_rdnis;
+					value = record->caller_id_rdnis;
 				} else if (strcmp(cur->name, "cid_dnid") == 0) {
-					value = cid_dnid;
+					value = record->caller_id_dnid;
 				} else if (strcmp(cur->name, "exten") == 0) {
-					value = exten;
+					value = record->extension;
 				} else if (strcmp(cur->name, "context") == 0) {
-					value = context;
+					value = record->context;
 				} else if (strcmp(cur->name, "channame") == 0) {
-					value = channame;
+					value = record->channel_name;
 				} else if (strcmp(cur->name, "appname") == 0) {
-					value = appname;
+					value = record->application_name;
 				} else if (strcmp(cur->name, "appdata") == 0) {
-					value = appdata;
+					value = record->application_data;
 				} else if (strcmp(cur->name, "accountcode") == 0) {
-					value = accountcode;
+					value = record->account_code;
 				} else if (strcmp(cur->name, "peeraccount") == 0) {
-					value = peeraccount;
+					value = record->peer_account;
 				} else if (strcmp(cur->name, "uniqueid") == 0) {
-					value = uniqueid;
+					value = record->unique_id;
 				} else if (strcmp(cur->name, "linkedid") == 0) {
-					value = linkedid;
+					value = record->linked_id;
 				} else if (strcmp(cur->name, "userfield") == 0) {
-					value = userfield;
+					value = record->user_field;
 				} else if (strcmp(cur->name, "peer") == 0) {
-					value = peer;
+					value = record->peer;
 				} else {
 					value = "";
 				}
@@ -272,19 +247,19 @@
 					long long whatever;
 					if (value && sscanf(value, "%lld", &whatever) == 1) {
 						LENGTHEN_BUF2(26);
-						ast_str_append(&sql2, 0, "%s%lld", first ? "" : ",", whatever);
+						ast_str_append(&sql2, 0, "%s%lld", SEP, whatever);
 					} else {
 						LENGTHEN_BUF2(2);
-						ast_str_append(&sql2, 0, "%s0", first ? "" : ",");
+						ast_str_append(&sql2, 0, "%s0", SEP);
 					}
 				} else if (strncmp(cur->type, "float", 5) == 0) {
 					long double whatever;
 					if (value && sscanf(value, "%Lf", &whatever) == 1) {
 						LENGTHEN_BUF2(51);
-						ast_str_append(&sql2, 0, "%s%30Lf", first ? "" : ",", whatever);
+						ast_str_append(&sql2, 0, "%s%30Lf", SEP, whatever);
 					} else {
 						LENGTHEN_BUF2(2);
-						ast_str_append(&sql2, 0, "%s0", first ? "" : ",");
+						ast_str_append(&sql2, 0, "%s0", SEP);
 					}
 					/* XXX Might want to handle dates, times, and other misc fields here XXX */
 				} else {
@@ -294,7 +269,7 @@
 						escapebuf[0] = '\0';
 					}
 					LENGTHEN_BUF2(strlen(escapebuf) + 3);
-					ast_str_append(&sql2, 0, "%s'%s'", first ? "" : ",", escapebuf);
+					ast_str_append(&sql2, 0, "%s'%s'", SEP, escapebuf);
 				}
 			}
 			first = 0;

Modified: team/group/newcdr/cel/cel_radius.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/cel/cel_radius.c?view=diff&rev=202102&r1=202101&r2=202102
==============================================================================
--- team/group/newcdr/cel/cel_radius.c (original)
+++ team/group/newcdr/cel/cel_radius.c Fri Jun 19 17:55:48 2009
@@ -92,13 +92,9 @@
 static rc_handle *rh = NULL;
 static struct ast_event_sub *event_sub = 0;
 
-static int build_radius_record(VALUE_PAIR **send, enum ast_cel_event_type event_type,
-							   struct timeval eventtime, const char *userdefname, const char *cid_name,
-							   const char *cid_num, const char *cid_ani,
-							   const char *cid_rdnis, const char *cid_dnid, const char *exten,
-							   const char *context, const char *channame, const char *appname,
-							   const char *appdata, const char *accountcode,
-							   const char *uniqueid, unsigned int amaflag, const char *linkedid)
+#define ADD_VENDOR_CODE(x,y) (rc_avpair_add(rh, send, x, &y, strlen(y), VENDOR_CODE))
+
+static int build_radius_record(VALUE_PAIR **send, struct ast_cel_event_record *record)
 {
 	int recordtype = PW_STATUS_STOP;
 	struct ast_tm tm;
@@ -109,73 +105,76 @@
 		return -1;
 	}
 	/* Account code */
-	if (!rc_avpair_add(rh, send, PW_AST_ACCT_CODE, (char**)&accountcode, strlen(accountcode), VENDOR_CODE)) {
+	if (!ADD_VENDOR_CODE(PW_AST_ACCT_CODE, record->account_code)) {
 		return -1;
 	}
 	/* Source */
-	if (!rc_avpair_add(rh, send, PW_AST_CIDNUM, &cid_num, strlen(cid_num), VENDOR_CODE)) {
+	if (!ADD_VENDOR_CODE(PW_AST_CIDNUM, record->caller_id_num)) {
 		return -1;
 	}
 	/* Destination */
-	if (!rc_avpair_add(rh, send, PW_AST_EXTEN, &exten, strlen(exten), VENDOR_CODE)) {
+	if (!ADD_VENDOR_CODE(PW_AST_EXTEN, record->extension)) {
 		return -1;
 	}
 	/* Destination context */
-	if (!rc_avpair_add(rh, send, PW_AST_CONTEXT, &context, strlen(context), VENDOR_CODE)) {
+	if (!ADD_VENDOR_CODE(PW_AST_CONTEXT, record->context)) {
 		return -1;
 	}
 	/* Caller ID */
-	if (!rc_avpair_add(rh, send, PW_AST_CIDNAME, &cid_name, strlen(cid_name), VENDOR_CODE)) {
+	if (!ADD_VENDOR_CODE(PW_AST_CIDNAME, record->caller_id_name)) {
 		return -1;
 	}
 	/* Caller ID ani */
-	if (!rc_avpair_add(rh, send, PW_AST_CIDANI, &cid_ani, strlen(cid_ani), VENDOR_CODE)) {
+	if (!ADD_VENDOR_CODE(PW_AST_CIDANI, record->caller_id_ani)) {
 		return -1;
 	}
 	/* Caller ID rdnis */
-	if (!rc_avpair_add(rh, send, PW_AST_CIDRDNIS, &cid_rdnis, strlen(cid_rdnis), VENDOR_CODE)) {
+	if (!ADD_VENDOR_CODE(PW_AST_CIDRDNIS, record->caller_id_rdnis)) {
 		return -1;
 	}
 	/* Caller ID dnid */
-	if (!rc_avpair_add(rh, send, PW_AST_CIDDNID, &cid_dnid, strlen(cid_dnid), VENDOR_CODE)) {
+	if (!ADD_VENDOR_CODE(PW_AST_CIDDNID, record->caller_id_dnid)) {
 		return -1;
 	}
 	/* Channel */
-	if (!rc_avpair_add(rh, send, PW_AST_CHANNAME, (char**)&channame, strlen(channame), VENDOR_CODE)) {
+	if (!ADD_VENDOR_CODE(PW_AST_CHANNAME, record->channel_name)) {
 		return -1;
 	}
 	/* Last Application */
-	if (!rc_avpair_add(rh, send, PW_AST_APPNAME, &appname, strlen(appname), VENDOR_CODE)) {
+	if (!ADD_VENDOR_CODE(PW_AST_APPNAME, record->application_name)) {
 		return -1;
 	}
 	/* Last Data */
-	if (!rc_avpair_add(rh, send, PW_AST_APPDATA, &appdata, strlen(appdata), VENDOR_CODE)) {
+	if (!ADD_VENDOR_CODE(PW_AST_APPDATA, record->application_data)) {
 		return -1;
 	}
 	/* Event Time */
-	ast_localtime(&eventtime, &tm, ast_test_flag(&global_flags, RADIUS_FLAG_USEGMTIME) ? "GMT" : NULL);
+	ast_localtime(&record->event_time, &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;
 	}
 	/* AMA Flags */
-	amaflags = ast_strdupa(ast_cel_flags2str(amaflag));
+	amaflags = ast_strdupa(ast_cel_flags2str(record->amaflag));
 	if (!rc_avpair_add(rh, send, PW_AST_AMA_FLAGS, amaflags, strlen(amaflags), 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))
+		if (!ADD_VENDOR_CODE(PW_AST_UNIQUE_ID, record->unique_id)) {
 			return -1;
+		}
 	}
 	/* LinkedID */
-	if (!rc_avpair_add(rh, send, PW_AST_LINKED_ID, &linkedid, strlen(linkedid), VENDOR_CODE)) {
+	if (!ADD_VENDOR_CODE(PW_AST_LINKED_ID, record->linked_id)) {
 		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)) {
+	if (!rc_avpair_add(rh, send, PW_USER_NAME, &record->channel_name,
+			strlen(record->channel_name), 0)) {
 		return -1;
 	}
 	return 0;
@@ -185,37 +184,13 @@
 {
 	int result = ERROR_RC;
 	VALUE_PAIR *send = NULL;
-	enum ast_cel_event_type event_type;
-	const char *userdefname = 0;
-	struct timeval eventtime = {0};
-	const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
-	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *linkedid;
-	unsigned int amaflag;
-
-	event_type = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
-	eventtime.tv_sec = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
-	eventtime.tv_usec = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC);
-	if (event_type == AST_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);
-	cid_rdnis = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDRDNIS);
-	cid_dnid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDDNID);
-	exten = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_EXTEN);
-	context = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CONTEXT);
-	channame = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CHANNAME);
-	appname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPNAME);
-	appdata = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPDATA);
-	accountcode = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
-	uniqueid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_UNIQUEID);
-	linkedid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_LINKEDID);
-	amaflag = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_AMAFLAGS);
-
-	if (build_radius_record(&send, event_type, eventtime, userdefname, cid_name, cid_num,
-							cid_ani, cid_rdnis, cid_dnid, exten, context, channame,
-							appname, appdata, accountcode, uniqueid, amaflag, linkedid)) {
+	struct ast_cel_event_record *record = ast_cel_fill_record(event);
+
+	if (!record) {
+		return;
+	}
+
+	if (build_radius_record(&send, record)) {
 		if (option_debug) {
 			ast_log(LOG_DEBUG, "Unable to create RADIUS record. CEL not recorded!\n");
 		}
@@ -231,6 +206,7 @@
 	if (send) {
 		rc_avpair_free(send);
 	}
+	ast_free(record);
 }
 
 static int unload_module(void)

Modified: team/group/newcdr/cel/cel_sqlite.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/cel/cel_sqlite.c?view=diff&rev=202102&r1=202101&r2=202102
==============================================================================
--- team/group/newcdr/cel/cel_sqlite.c (original)
+++ team/group/newcdr/cel/cel_sqlite.c Fri Jun 19 17:55:48 2009
@@ -100,78 +100,51 @@
 	int res = 0;
 	char *zErr = 0;
 	struct ast_tm tm;
-	struct timeval t;
 	char startstr[80];
 	int count;
-	enum ast_cel_event_type event_type;
-	const char *userdefname = 0;
-	struct timeval eventtime = {0};
-	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;
+	struct ast_cel_event_record *record = ast_cel_fill_record(event);
+
+	if (!record) {
+		return;
+	}
 
 	ast_log(LOG_NOTICE,"Logging event to sqlite interface\n");
-	event_type = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
-	eventtime.tv_sec = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
-	eventtime.tv_usec = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC);
-	if (event_type == AST_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);
-	cid_rdnis = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDRDNIS);
-	cid_dnid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDDNID);
-	exten = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_EXTEN);
-	context = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CONTEXT);
-	channame = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CHANNAME);
-	appname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPNAME);
-	appdata = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPDATA);
-	accountcode = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
-	uniqueid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_UNIQUEID);
-	linkedid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_LINKEDID);
-	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_mutex_lock(&sqlite_lock);
 
-	t = eventtime;
-	ast_localtime(&t, &tm, NULL);
+	ast_localtime(&record->event_time, &tm, NULL);
 	ast_strftime(startstr, sizeof(startstr), DATE_FORMAT, &tm);
 
-	for(count=0; count<5; count++) {
+	for (count = 0; count < 5; count++) {
 		res = sqlite_exec_printf(db,
 			"INSERT INTO cel ("
-				"cidname,cidnum,cidani,cidrdnis,ciddnid,exten,context,"
-				"channelname,appname,appdata, "
-				"eventtime,"
-				"amaflags,"
-				"accountcode,"
-				"userfield,"
-				"peer,"
-				"linkedid"
-#				if LOG_UNIQUEID
-				",uniqueid"
-#				endif
+			"cidname,cidnum,cidani,cidrdnis,ciddnid,exten,context,"
+			"channelname,appname,appdata, "
+			"eventtime,"
+			"amaflags,"
+			"accountcode,"
+			"userfield,"
+			"peer,"
+			"linkedid"
+#if LOG_UNIQUEID
+			",uniqueid"
+#endif
 			") VALUES ("
-				"'%q', '%q', '%q', '%q', '%q', '%q', '%q', "
-				"'%q', '%q', '%q', "
-				"'%q', %d, '%q', '%q'"
-#				if LOG_UNIQUEID
-				", '%q'"
-#				endif
+			"'%q', '%q', '%q', '%q', '%q', '%q', '%q', "
+			"'%q', '%q', '%q', "
+			"'%q', %d, '%q', '%q'"
+#if LOG_UNIQUEID
+			", '%q'"
+#endif
             ")", NULL, NULL, &zErr,
-                cid_name, cid_num, cid_ani, cid_rdnis, cid_dnid, exten, context,
-				channame, appname, appdata,
-				startstr,
-				amaflag,
-				accountcode,
-				userfield,
-				peer, linkedid
-#				if LOG_UNIQUEID
-				,uniqueid
-#				endif
+			record->caller_id_name, record->caller_id_num, record->caller_id_ani,
+			record->caller_id_rdnis, record->caller_id_dnid, record->extension, record->context,
+			record->channel_name, record->application_name, record->application_data,
+			startstr, record->amaflag, record->account_code, record->user_field, record->peer,
+			record->linked_id
+#if LOG_UNIQUEID
+			, record->unique_id
+#endif
 			);
 		if (res != SQLITE_BUSY && res != SQLITE_LOCKED) {
 			break;
@@ -185,6 +158,7 @@
 	}
 
 	ast_mutex_unlock(&sqlite_lock);
+	ast_free(record);
 	return;
 }
 

Modified: team/group/newcdr/cel/cel_tds.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/cel/cel_tds.c?view=diff&rev=202102&r1=202101&r2=202102
==============================================================================
--- team/group/newcdr/cel/cel_tds.c (original)
+++ team/group/newcdr/cel/cel_tds.c Fri Jun 19 17:55:48 2009
@@ -118,63 +118,31 @@
 	char *accountcode_ai, *clidnum_ai, *exten_ai, *context_ai, *clid_ai, *channel_ai, *app_ai, *appdata_ai, *uniqueid_ai, *linkedid_ai, *cidani_ai, *cidrdnis_ai, *ciddnid_ai, *peer_ai, *userfield_ai;
 	RETCODE erc;
 	int attempt = 1;
-	enum ast_cel_event_type event_type;
-	const char *userdefname = 0;
-	struct timeval eventtime = {0};
-	const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
-	const char *exten, *context, *channame, *appname, *appdata, *accountcode, *uniqueid, *linkedid, *userfield, *peer;
-	const char *eventname;
-	unsigned int amaflag;
-
-	event_type = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
-	eventtime.tv_sec = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
-	eventtime.tv_usec = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC);
-	if (event_type == AST_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);
-	cid_rdnis = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDRDNIS);
-	cid_dnid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDDNID);
-	exten = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_EXTEN);
-	context = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CONTEXT);
-	channame = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CHANNAME);
-	appname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPNAME);
-	appdata = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_APPDATA);
-	accountcode = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_ACCTCODE);
-	uniqueid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_UNIQUEID);
-	linkedid = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_LINKEDID);
-	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);
+	struct ast_cel_event_record *record = ast_cel_fill_record(event);
+
+	if (!record) {
+		return;
+	}
 
 	ast_mutex_lock(&tds_lock);
 
-	if (event_type == AST_CEL_USER_DEFINED) {
-		eventname = userdefname;
-	} else {
-		eventname = ast_cel_get_type_name(event_type);
-	}
-
-	accountcode_ai = anti_injection(accountcode, 20);
-	clidnum_ai = anti_injection(cid_num, 80);
-	clid_ai = anti_injection(cid_name, 80);
-	cidani_ai = anti_injection(cid_ani, 80);
-	cidrdnis_ai = anti_injection(cid_rdnis, 80);
-	ciddnid_ai = anti_injection(cid_dnid, 80);
-	exten_ai = anti_injection(exten, 80);
-	context_ai = anti_injection(context, 80);
-	channel_ai = anti_injection(channame, 80);
-	app_ai = anti_injection(appname, 80);
-	appdata_ai = anti_injection(appdata, 80);
-	uniqueid_ai = anti_injection(uniqueid, 32);
-	linkedid_ai = anti_injection(linkedid, 32);
-	userfield_ai = anti_injection(userfield, 32);
-	peer_ai = anti_injection(peer, 32);
-
-	get_date(start, sizeof(start), eventtime);
-
+	accountcode_ai = anti_injection(record->account_code, 20);
+	clidnum_ai     = anti_injection(record->caller_id_num, 80);
+	clid_ai        = anti_injection(record->caller_id_name, 80);
+	cidani_ai      = anti_injection(record->caller_id_ani, 80);
+	cidrdnis_ai    = anti_injection(record->caller_id_rdnis, 80);
+	ciddnid_ai     = anti_injection(record->caller_id_dnid, 80);
+	exten_ai       = anti_injection(record->extension, 80);
+	context_ai     = anti_injection(record->context, 80);
+	channel_ai     = anti_injection(record->channel_name, 80);
+	app_ai         = anti_injection(record->application_name, 80);
+	appdata_ai     = anti_injection(record->application_data, 80);
+	uniqueid_ai    = anti_injection(record->unique_id, 32);
+	linkedid_ai    = anti_injection(record->linked_id, 32);
+	userfield_ai   = anti_injection(record->user_field, 32);
+	peer_ai        = anti_injection(record->peer, 32);
+
+	get_date(start, sizeof(start), record->event_time);
 
 retry:
 	/* Ensure that we are connected */
@@ -231,10 +199,10 @@
 			"'%s', "	/* userfield */
 			"'%s'"		/* peer */
 				 ")",
-		settings->table, accountcode_ai, clidnum_ai, clid_ai, cidani_ai, cidrdnis_ai, ciddnid_ai,
-		exten_ai, context_ai, channel_ai, app_ai, appdata_ai, start, eventname,
-		ast_cel_flags2str(amaflag), uniqueid_ai, linkedid_ai, userfield_ai, peer_ai
-		);
+		settings->table, accountcode_ai, clidnum_ai, clid_ai, cidani_ai, cidrdnis_ai,
+		ciddnid_ai, exten_ai, context_ai, channel_ai, app_ai, appdata_ai, start,
+		record->event_name, ast_cel_flags2str(record->amaflag), uniqueid_ai, linkedid_ai,
+		userfield_ai, peer_ai);
 
 	if (erc == FAIL) {
 		if (attempt++ < 3) {
@@ -282,6 +250,7 @@
 	free(linkedid_ai);
 	free(userfield_ai);
 	free(peer_ai);
+	free(record);
 
 	return;
 }

Modified: team/group/newcdr/include/asterisk/cel.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/include/asterisk/cel.h?view=diff&rev=202102&r1=202101&r2=202102
==============================================================================
--- team/group/newcdr/include/asterisk/cel.h (original)
+++ team/group/newcdr/include/asterisk/cel.h Fri Jun 19 17:55:48 2009
@@ -169,6 +169,35 @@
 		char *userdefevname, const char *extra,
 		const struct ast_channel *peer2);
 
+#define AST_CEL_RECORD_VERSION 1
+
+struct ast_cel_event_record {
+	uint32_t version;
+	enum ast_cel_event_type event_type;
+	struct timeval event_time;
+	const char *event_name;
+	const char *user_defined_name;
+	const char *caller_id_name;
+	const char *caller_id_num;
+	const char *caller_id_ani;
+	const char *caller_id_rdnis;
+	const char *caller_id_dnid;
+	const char *extension;
+	const char *context;
+	const char *channel_name;
+	const char *application_name;
+	const char *application_data;
+	const char *account_code;
+	const char *peer_account;
+	const char *unique_id;
+	const char *linked_id;

[... 67 lines stripped ...]



More information about the asterisk-commits mailing list