Author: mikej Date: Mon Nov 12 22:47:07 2007 New Revision: 6234 Modified: freeswitch/trunk/src/include/switch_utils.h freeswitch/trunk/src/switch_ivr_play_say.c freeswitch/trunk/src/switch_utils.c Log: add missing "execute" handler to phrase macro. (not yet tested) Modified: freeswitch/trunk/src/include/switch_utils.h ============================================================================== --- freeswitch/trunk/src/include/switch_utils.h (original) +++ freeswitch/trunk/src/include/switch_utils.h Mon Nov 12 22:47:07 2007 @@ -300,6 +300,7 @@ SWITCH_DECLARE(switch_bool_t) switch_is_number(const char *str); SWITCH_DECLARE(char *) switch_strip_spaces(const char *str); +SWITCH_DECLARE(char *) switch_separate_paren_args(char *str); SWITCH_DECLARE(const char *) switch_stristr(const char *str, const char *instr); SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip); SWITCH_DECLARE(char *) switch_replace_char(char *str, char from, char to, switch_bool_t dup); Modified: freeswitch/trunk/src/switch_ivr_play_say.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_play_say.c (original) +++ freeswitch/trunk/src/switch_ivr_play_say.c Mon Nov 12 22:47:07 2007 @@ -260,7 +260,22 @@ done = 1; break; } else if (!strcasecmp(func, "execute")) { + switch_application_interface_t *app; + char *cmd, *cmd_args; + status = SWITCH_STATUS_FALSE; + cmd = switch_core_session_strdup(session, odata); + cmd_args = switch_separate_paren_args(cmd); + + if (!cmd_args ) { + cmd_args = ""; + } + + if ((app = switch_loadable_module_get_application_interface(cmd)) != NULL) { + status = switch_core_session_exec(session, app, cmd_args); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Application %s\n", cmd); + } } else if (!strcasecmp(func, "say")) { switch_say_interface_t *si; if ((si = switch_loadable_module_get_say_interface(module_name))) { Modified: freeswitch/trunk/src/switch_utils.c ============================================================================== --- freeswitch/trunk/src/switch_utils.c (original) +++ freeswitch/trunk/src/switch_utils.c Mon Nov 12 22:47:07 2007 @@ -288,6 +288,36 @@ return s; } + +SWITCH_DECLARE(char *) switch_separate_paren_args(char *str) +{ + char *e, *args; + switch_size_t br; + + if ((args = strchr(str, '('))) { + e = args - 1; + *args++ = '\0'; + while(*e == ' ') { + *e-- = '\0'; + } + e = args; + br = 1; + while(e && *e) { + if (*e == '(') { + br++; + } else if (br > 1 && *e == ')') { + br--; + } else if (br == 1 && *e == ')') { + *e = '\0'; + break; + } + e++; + } + } + + return args; +} + SWITCH_DECLARE(switch_bool_t) switch_is_number(const char *str) { const char *p;