]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
change dialplan a little
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 17 Oct 2007 18:26:08 +0000 (18:26 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 17 Oct 2007 18:26:08 +0000 (18:26 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5938 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
src/switch_channel.c

index 551a4510e2bc03bdaa6acf41242d1b87e84e4079..d64222bdbc0e057916ef4efa38cb2c711c7f4842 100644 (file)
@@ -50,7 +50,8 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
        switch_channel_t *channel;
        char *exten_name = (char *) switch_xml_attr_soft(xexten, "name");
        int proceed = 0;
-       switch_stream_handle_t stream = { 0 };
+       char *expression_expanded = NULL, *field_expanded = NULL;
+
 
        channel = switch_core_session_get_channel(session);
 
@@ -63,9 +64,18 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
                int ovector[30];
                break_t do_break_i = BREAK_ON_FALSE;
 
+               switch_safe_free(field_expanded);
+               switch_safe_free(expression_expanded);
+
                field = (char *) switch_xml_attr(xcond, "field");
 
                expression = (char *) switch_xml_attr_soft(xcond, "expression");
+               
+               if ((expression_expanded = switch_channel_expand_variables(channel, expression)) == expression) {
+                       expression_expanded = NULL;
+               } else {
+                       expression = expression_expanded;
+               }
 
                if ((do_break_a = (char *) switch_xml_attr(xcond, "break"))) {
                        if (!strcasecmp(do_break_a, "on-true")) {
@@ -80,32 +90,12 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
                }
 
                if (field) {
-                       if (*field == '$') {
-                               char *cmd = switch_core_session_strdup(session, field + 1);
-                               char *e, *arg;
-                               field = cmd;
-                               field_data = "";
-
-                               if (*field == '{') {
-                                       field++;
-                                       if ((e = strchr(field, '}'))) {
-                                               *e = '\0';
-                                               field_data = switch_channel_get_variable(channel, field);
-                                       }
+                       if (strchr(field, '$')) {
+                               if ((field_expanded = switch_channel_expand_variables(channel, field)) == field) {
+                                       field_expanded = NULL;
+                                       field_data = field;
                                } else {
-                                       switch_safe_free(stream.data);
-                                       memset(&stream, 0, sizeof(stream));
-                                       SWITCH_STANDARD_STREAM(stream);
-
-                                       if ((arg = strchr(cmd, '('))) {
-                                               *arg++ = '\0';
-                                               if ((e = strchr(arg, ')'))) {
-                                                       *e = '\0';
-                                                       if (switch_api_execute(cmd, arg, session, &stream) == SWITCH_STATUS_SUCCESS) {
-                                                               field_data = stream.data;
-                                                       }
-                                               }
-                                       }
+                                       field_data = field_expanded;
                                }
                        } else {
                                field_data = switch_caller_get_field_by_name(caller_profile, field);
@@ -183,7 +173,8 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
        }
 
   done:
-       switch_safe_free(stream.data);
+       switch_safe_free(field_expanded);
+       switch_safe_free(expression_expanded);
        return proceed;
 }
 
index 6788f77eea6e65cef2db8b5f443871fd9c5912bd..c7dd311e42959ee84a71f6d340838937d6ded8bd 100644 (file)
@@ -1295,9 +1295,13 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
                        }
 
                        if (*p == '$' && !nv) {
-                               vtype = 1;
-                               if (*(p + 1) != '{') {
-                                       vtype = 2;
+                               if (*(p+1)) {
+                                       vtype = 1;
+                                       if (*(p + 1) != '{') {
+                                               vtype = 2;
+                                       }
+                               } else {
+                                       nv = 1;
                                }
                        }