[Freeswitch-svn] [commit] r10347 - freeswitch/trunk/src/mod/applications/mod_commands

FreeSWITCH SVN mikej at freeswitch.org
Wed Nov 12 03:46:44 PST 2008


Author: mikej
Date: Wed Nov 12 06:46:44 2008
New Revision: 10347

Log:
(FSCORE-217) Add support for passing the cause of hangup to the uuid_kill command

Modified:
   freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	Wed Nov 12 06:46:44 2008
@@ -921,26 +921,39 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-#define KILL_SYNTAX "<uuid>"
+#define KILL_SYNTAX "<uuid> [cause]"
 SWITCH_STANDARD_API(kill_function)
 {
 	switch_core_session_t *ksession = NULL;
+	char *mycmd = NULL, *kcause = NULL;
+	switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
 	if (session) {
 		return SWITCH_STATUS_FALSE;
 	}
 
-	if (!cmd) {
+	if (switch_strlen_zero(cmd) || !(mycmd = strdup(cmd))) {
 		stream->write_function(stream, "-USAGE: %s\n", KILL_SYNTAX);
-	} else if ((ksession = switch_core_session_locate(cmd))) {
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	if ((kcause = strchr(mycmd, ' '))) {
+		*kcause++ = '\0';
+	}
+
+	if (switch_strlen_zero(mycmd) || !(ksession = switch_core_session_locate(mycmd))) {
+		stream->write_function(stream, "-ERR No Such Channel!\n");
+	} else {
 		switch_channel_t *channel = switch_core_session_get_channel(ksession);
-		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+		if (!switch_strlen_zero(kcause)){
+			cause = switch_channel_str2cause(kcause);
+		}  
+		switch_channel_hangup(channel, cause);
 		switch_core_session_rwunlock(ksession);
 		stream->write_function(stream, "+OK\n");
-	} else {
-		stream->write_function(stream, "-ERR No Such Channel!\n");
 	}
 
+	switch_safe_free(mycmd);
 	return SWITCH_STATUS_SUCCESS;
 }
 



More information about the Freeswitch-svn mailing list