[svn-commits] mnicholson: branch group/newcdr r202746 - /team/group/newcdr/main/cel.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jun 23 13:02:47 CDT 2009


Author: mnicholson
Date: Tue Jun 23 13:02:43 2009
New Revision: 202746

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=202746
Log:
Use ast_cel_fill_record() in ast_cel_fabricate_channel_from_event().

Modified:
    team/group/newcdr/main/cel.c

Modified: team/group/newcdr/main/cel.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/main/cel.c?view=diff&rev=202746&r1=202745&r2=202746
==============================================================================
--- team/group/newcdr/main/cel.c (original)
+++ team/group/newcdr/main/cel.c Tue Jun 23 13:02:43 2009
@@ -377,15 +377,13 @@
 {
 	enum ast_cel_event_type event_type;
 	struct timeval eventtime;
-	const char *userdefname = NULL;
 	struct varshead *headp;
 	struct ast_var_t *newvariable;
 	char timebuf[30];
 	struct ast_channel *tchan;
-	const char *cid_ani, *cid_rdnis, *cid_name, *cid_num, *cid_dnid;
-	const char *exten, *context, *channame, *appname, *appdata, *accountcode,
-			*peeraccount, *uniqueid, *linkedid, *peer, *userfield, *extra;
-	unsigned int amaflag;
+	struct ast_cel_event_record record = {
+		.version = AST_CEL_EVENT_RECORD_VERSION,
+	};
 
 	/* do not call ast_channel_alloc because this is not really a real channel */
 	if (!(tchan = ast_dummy_channel_alloc())) {
@@ -395,46 +393,26 @@
 	headp = &tchan->varshead;
 
 	/* first, get the variables from the event */
-	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_PEERACCT);
-	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);
-	extra = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_EXTRA);
-	peer = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_PEER);
+	if (ast_cel_fill_record(event, &record)) {
+		ast_channel_release(tchan);
+		return NULL;
+	}
 
 	/* next, fill the channel with their data */
-	if (event_type == AST_CEL_USER_DEFINED) {
-		newvariable = ast_var_assign("eventtype", userdefname);
+	if (record.event_type == AST_CEL_USER_DEFINED) {
+		newvariable = ast_var_assign("eventtype", record.user_defined_name);
 	} else {
-		newvariable = ast_var_assign("eventtype", ast_cel_get_type_name(event_type));
+		newvariable = ast_var_assign("eventtype", ast_cel_get_type_name(record.event_type));
 	}
 	if (newvariable) {
 		AST_LIST_INSERT_HEAD(headp, newvariable, entries);
 	}
 
 	if (ast_strlen_zero(cel_dateformat)) {
-		snprintf(timebuf, sizeof(timebuf), "%ld.%06ld", eventtime.tv_sec, eventtime.tv_usec);
+		snprintf(timebuf, sizeof(timebuf), "%ld.%06ld", record.event_time.tv_sec, record.event_time.tv_usec);
 	} else {
 		struct ast_tm tm;
-		ast_localtime(&eventtime, &tm, NULL);
+		ast_localtime(&record.event_time, &tm, NULL);
 		ast_strftime(timebuf, sizeof(timebuf), cel_dateformat, &tm);
 	}
 
@@ -442,30 +420,30 @@
 		AST_LIST_INSERT_HEAD(headp, newvariable, entries);
 	}
 
-	if ((newvariable = ast_var_assign("eventextra", extra))) {
+	if ((newvariable = ast_var_assign("eventextra", record.extra))) {
 		AST_LIST_INSERT_HEAD(headp, newvariable, entries);
 	}
 
-	tchan->cid.cid_name = ast_strdup(cid_name);
-	tchan->cid.cid_num = ast_strdup(cid_num);
-	tchan->cid.cid_ani = ast_strdup(cid_ani);
-	tchan->cid.cid_rdnis = ast_strdup(cid_rdnis);
-	tchan->cid.cid_dnid = ast_strdup(cid_dnid);
-
-	ast_copy_string(tchan->exten, exten, sizeof(tchan->exten));
-	ast_copy_string(tchan->context, context, sizeof(tchan->context));
-	ast_string_field_set(tchan, name, S_OR(channame, ""));
-	ast_string_field_set(tchan, uniqueid, S_OR(uniqueid, ""));
-	ast_string_field_set(tchan, linkedid, S_OR(linkedid, ""));
-	ast_string_field_set(tchan, accountcode, S_OR(accountcode, ""));
-	ast_string_field_set(tchan, peeraccount, S_OR(peeraccount, ""));
-	ast_string_field_set(tchan, userfield, S_OR(userfield, ""));
-
-	pbx_builtin_setvar_helper(tchan, "BRIDGEPEER", peer);
-
-	tchan->appl = ast_strdup(appname);
-	tchan->data = ast_strdup(appdata);
-	tchan->amaflags = amaflag;
+	tchan->cid.cid_name = ast_strdup(record.caller_id_name);
+	tchan->cid.cid_num = ast_strdup(record.caller_id_num);
+	tchan->cid.cid_ani = ast_strdup(record.caller_id_ani);
+	tchan->cid.cid_rdnis = ast_strdup(record.caller_id_rdnis);
+	tchan->cid.cid_dnid = ast_strdup(record.caller_id_dnid);
+
+	ast_copy_string(tchan->exten, record.extension, sizeof(tchan->exten));
+	ast_copy_string(tchan->context, record.context, sizeof(tchan->context));
+	ast_string_field_set(tchan, name, record.channel_name);
+	ast_string_field_set(tchan, uniqueid, record.unique_id);
+	ast_string_field_set(tchan, linkedid, record.linked_id);
+	ast_string_field_set(tchan, accountcode, record.account_code);
+	ast_string_field_set(tchan, peeraccount, record.peer_account);
+	ast_string_field_set(tchan, userfield, record.user_field);
+
+	pbx_builtin_setvar_helper(tchan, "BRIDGEPEER", record.peer);
+
+	tchan->appl = ast_strdup(record.application_name);
+	tchan->data = ast_strdup(record.application_data);
+	tchan->amaflags = record.amaflag;
 
 	return tchan;
 }




More information about the svn-commits mailing list