mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-05-05 15:47:51 +00:00
change dialplan a little
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5938 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
c53d6f7eff
commit
7c8b72b9fe
@ -50,7 +50,8 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
|
|||||||
switch_channel_t *channel;
|
switch_channel_t *channel;
|
||||||
char *exten_name = (char *) switch_xml_attr_soft(xexten, "name");
|
char *exten_name = (char *) switch_xml_attr_soft(xexten, "name");
|
||||||
int proceed = 0;
|
int proceed = 0;
|
||||||
switch_stream_handle_t stream = { 0 };
|
char *expression_expanded = NULL, *field_expanded = NULL;
|
||||||
|
|
||||||
|
|
||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
|
|
||||||
@ -63,10 +64,19 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
|
|||||||
int ovector[30];
|
int ovector[30];
|
||||||
break_t do_break_i = BREAK_ON_FALSE;
|
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");
|
field = (char *) switch_xml_attr(xcond, "field");
|
||||||
|
|
||||||
expression = (char *) switch_xml_attr_soft(xcond, "expression");
|
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 ((do_break_a = (char *) switch_xml_attr(xcond, "break"))) {
|
||||||
if (!strcasecmp(do_break_a, "on-true")) {
|
if (!strcasecmp(do_break_a, "on-true")) {
|
||||||
do_break_i = BREAK_ON_TRUE;
|
do_break_i = BREAK_ON_TRUE;
|
||||||
@ -80,32 +90,12 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (field) {
|
if (field) {
|
||||||
if (*field == '$') {
|
if (strchr(field, '$')) {
|
||||||
char *cmd = switch_core_session_strdup(session, field + 1);
|
if ((field_expanded = switch_channel_expand_variables(channel, field)) == field) {
|
||||||
char *e, *arg;
|
field_expanded = NULL;
|
||||||
field = cmd;
|
field_data = field;
|
||||||
field_data = "";
|
|
||||||
|
|
||||||
if (*field == '{') {
|
|
||||||
field++;
|
|
||||||
if ((e = strchr(field, '}'))) {
|
|
||||||
*e = '\0';
|
|
||||||
field_data = switch_channel_get_variable(channel, field);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
switch_safe_free(stream.data);
|
field_data = field_expanded;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
field_data = switch_caller_get_field_by_name(caller_profile, field);
|
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:
|
done:
|
||||||
switch_safe_free(stream.data);
|
switch_safe_free(field_expanded);
|
||||||
|
switch_safe_free(expression_expanded);
|
||||||
return proceed;
|
return proceed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1295,10 +1295,14 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*p == '$' && !nv) {
|
if (*p == '$' && !nv) {
|
||||||
|
if (*(p+1)) {
|
||||||
vtype = 1;
|
vtype = 1;
|
||||||
if (*(p + 1) != '{') {
|
if (*(p + 1) != '{') {
|
||||||
vtype = 2;
|
vtype = 2;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
nv = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nv) {
|
if (nv) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user