[asterisk-commits] rmudgett: branch group/issue8824 r157977 - /team/group/issue8824/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 19 18:23:05 CST 2008


Author: rmudgett
Date: Wed Nov 19 18:23:04 2008
New Revision: 157977

URL: http://svn.digium.com/view/asterisk?view=rev&rev=157977
Log:
Fixes JIRA ABE-1726

The dial extension could be empty if you are using MISDN_KEYPAD
to control ISDN provider features.

Modified:
    team/group/issue8824/channels/chan_misdn.c

Modified: team/group/issue8824/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/chan_misdn.c?view=diff&rev=157977&r1=157976&r2=157977
==============================================================================
--- team/group/issue8824/channels/chan_misdn.c (original)
+++ team/group/issue8824/channels/chan_misdn.c Wed Nov 19 18:23:04 2008
@@ -3008,7 +3008,7 @@
 	int number_type;
 	struct chan_list *ch;
 	struct misdn_bchannel *newbc;
-	char *opts = NULL, *ext, *tokb;
+	char *opts, *ext;
 	char *dest_cp;
 
 	if (!ast) {
@@ -3039,20 +3039,21 @@
 		return -1;
 	}
 
+	/*
+	 * dest is ---v
+	 * Dial(mISDN/g:group_name[/extension[/options]])
+	 * Dial(mISDN/port[:preselected_channel][/extension[/options]])
+	 *
+	 * The dial extension could be empty if you are using MISDN_KEYPAD
+	 * to control ISDN provider features.
+	 */
 	dest_cp = ast_strdupa(dest);
-	ext = strtok_r(dest_cp, "/", &tokb);
-	if (ext) {
-		ext = strtok_r(NULL, "/", &tokb);
-		if (ext) {
-			opts = strtok_r(NULL, "/", &tokb);
-		}
-	}
+	strsep(&dest_cp, "/");/* Discard port/group token */
+	ext = strsep(&dest_cp, "/");
 	if (!ext) {
-		chan_misdn_log(0, 0, "misdn_call: No Extension given!\n");
-		ast->hangupcause = AST_CAUSE_NORMAL_TEMPORARY_FAILURE;
-		ast_setstate(ast, AST_STATE_DOWN);
-		return -1;
-	}
+		ext = "";
+	}
+	opts = dest_cp;
 	
 	port = newbc->port;
 
@@ -4070,22 +4071,29 @@
 	struct ast_channel *tmp = NULL;
 	char group[BUFFERSIZE + 1] = "";
 	char dial_str[128];
-	char *buf2 = ast_strdupa(data), *ext, *port_str;
-	char *tokb = NULL, *p = NULL;
-	int channel = 0, port = 0;
+	char *buf2 = ast_strdupa(data);
+	char *ext;
+	char *port_str;
+	char *p = NULL;
+	int channel = 0;
+	int port = 0;
 	struct misdn_bchannel *newbc = NULL;
 	int dec = 0;
 
 	struct chan_list *cl;
 
-	snprintf(dial_str, sizeof(dial_str), "%s/%s", misdn_type, (char*)data);
-
-	/* 
-	 * Dial(mISDN/g:group_name/extension[/options])
-	 * Dial(mISDN/port[:preselected_channel]/extension[/options])
+	snprintf(dial_str, sizeof(dial_str), "%s/%s", misdn_type, (char *) data);
+
+	/*
+	 * data is ---v
+	 * Dial(mISDN/g:group_name[/extension[/options]])
+	 * Dial(mISDN/port[:preselected_channel][/extension[/options]])
+	 *
+	 * The dial extension could be empty if you are using MISDN_KEYPAD
+	 * to control ISDN provider features.
 	 */
-	port_str = strtok_r(buf2, "/", &tokb);
-	if (port_str) {
+	port_str = strsep(&buf2, "/");
+	if (!ast_strlen_zero(port_str)) {
 		if (port_str[0] == 'g' && port_str[1] == ':' ) {
 			/* We make a group call lets checkout which ports are in my group */
 			port_str += 2;
@@ -4105,10 +4113,9 @@
 		return NULL;
 	}
 
-	ext = strtok_r(NULL, "/", &tokb);
+	ext = strsep(&buf2, "/");
 	if (!ext) {
-		ast_log(LOG_WARNING, " --> ! IND : Dial(%s) WITHOUT extension, check extensions.conf\n", dial_str);
-		return NULL;
+		ext = "";
 	}
 
 	if (misdn_cfg_is_group_method(group, METHOD_STANDARD_DEC)) {
@@ -4691,7 +4698,7 @@
 		ast->cid.cid_name ? ast->cid.cid_name : "",
 		ast->cid.cid_num ? ast->cid.cid_num : "");
   
-	strncpy(ast->exten, "s", 2);
+	strcpy(ast->exten, "s");
   
 	if (pbx_start_chan(ch) < 0) {
 		ast = NULL;
@@ -5172,7 +5179,6 @@
 		ch->addr = bc->addr;
 
 		chan = misdn_new(ch, AST_STATE_RESERVED, bc->dialed.number, bc->caller.number, AST_FORMAT_ALAW, bc->port, bc->channel);
-
 		if (!chan) {
 			misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
 			ast_log(LOG_ERROR, "cb_events: misdn_new failed !\n"); 




More information about the asterisk-commits mailing list