add missing "execute" handler to phrase macro. (not yet tested)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6234 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-11-13 03:47:07 +00:00
parent 8ba3cbce98
commit 69f7a9a955
3 changed files with 46 additions and 0 deletions

View File

@ -300,6 +300,7 @@ SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char
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);

View File

@ -260,7 +260,22 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s
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))) {

View File

@ -288,6 +288,36 @@ SWITCH_DECLARE(char *) switch_strip_spaces(const char *str)
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;