SWITCH_DECLARE(switch_status_t) switch_ivr_create_message_reply(switch_event_t **reply, switch_event_t *message, const char *new_proto);
SWITCH_DECLARE(char *) switch_ivr_check_presence_mapping(const char *exten_name, const char *domain_name);
+SWITCH_DECLARE(switch_status_t) switch_ivr_kill_uuid(const char *uuid, switch_call_cause_t cause);
/** @} */
#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 ((kcause = strchr(mycmd, ' '))) {
*kcause++ = '\0';
+ if (!zstr(kcause)) {
+ cause = switch_channel_str2cause(kcause);
+ }
}
- if (zstr(mycmd) || !(ksession = switch_core_session_locate(mycmd))) {
+ if (switch_ivr_kill_uuid(mycmd, cause) != SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "-ERR No Such Channel!\n");
} else {
- switch_channel_t *channel = switch_core_session_get_channel(ksession);
- if (!zstr(kcause)) {
- cause = switch_channel_str2cause(kcause);
- }
- switch_channel_hangup(channel, cause);
- switch_core_session_rwunlock(ksession);
stream->write_function(stream, "+OK\n");
}
}
+SWITCH_DECLARE(switch_status_t) switch_ivr_kill_uuid(const char *uuid, switch_call_cause_t cause)
+{
+ switch_core_session_t *session;
+
+ if (zstr(uuid) || !(session = switch_core_session_locate(uuid))) {
+ return SWITCH_STATUS_FALSE;
+ } else {
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_channel_hangup(channel, cause);
+ switch_core_session_rwunlock(session);
+ return SWITCH_STATUS_SUCCESS;
+ }
+}
+
/* For Emacs:
* Local Variables: