]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add missing "execute" handler to phrase macro. (not yet tested)
authorMichael Jerris <mike@jerris.com>
Tue, 13 Nov 2007 03:47:07 +0000 (03:47 +0000)
committerMichael Jerris <mike@jerris.com>
Tue, 13 Nov 2007 03:47:07 +0000 (03:47 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6234 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_utils.h
src/switch_ivr_play_say.c
src/switch_utils.c

index 94fa05005e9f86da9fa14a272e018c7877a1f423..b60ef2171c1601b6958afb27446acc8ec83897ab 100644 (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);
index a01eb37dde730df39170ac638173e03796275893..df884060fdbd395e9207c4fbeea5fafda62adee2 100644 (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))) {
index 95534d2eb440dcc123cc6e49738aa496b4ed7fd1..64ccc5e1b3a9b9c1380bfc42a9e93a9879a746e5 100644 (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;