Modifying the behaviour of the dialplan engine

the 'data' field in action tags may now refer to variables and api functions
to be expanded at runtime.

Syntax:

$varname
${varname}
&func_name(func args)


Exception:
variables that are numeric are still expanded at dialplan compile time based on the regex eg $1 $2 etc

Example:

<extension name="1000">
  <condition field="destination_number" expression="^(1000)$">
    <action appplication="my_route_app" data="$1"/>
    <action appplication="bridge" data="$destination"/>
  </condition>
</extension>

Here the $1 is ecaluated before the call begins setting it to 1000 based on the regex ^(1000)$
$destination is evaluated on the fly in execution once the my_route_app has run and has had a 
chance to set the variable 'destination' to the correct value.



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2994 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2006-10-07 19:54:04 +00:00
parent 4ede7f7593
commit 741b8329b9
6 changed files with 150 additions and 8 deletions

View File

@@ -2435,6 +2435,7 @@ static void switch_core_standard_on_execute(switch_core_session_t *session)
}
while (switch_channel_get_state(session->channel) == CS_EXECUTE && extension->current_application) {
char *expanded;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Execute %s(%s)\n",
extension->current_application->application_name,
extension->current_application->application_data);
@@ -2454,13 +2455,25 @@ static void switch_core_standard_on_execute(switch_core_session_t *session)
return;
}
if ((expanded = switch_channel_expand_variables(session->channel, extension->current_application->application_data)) !=
extension->current_application->application_data) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Expanded String %s(%s)\n",
extension->current_application->application_name,
expanded);
}
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(session->channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application", "%s", extension->current_application->application_name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", "%s", extension->current_application->application_data);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data-Orig", "%s", extension->current_application->application_data);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", "%s", expanded);
switch_event_fire(&event);
}
application_interface->application_function(session, extension->current_application->application_data);
application_interface->application_function(session, expanded);
if (expanded != extension->current_application->application_data) {
free(expanded);
}
extension->current_application = extension->current_application->next;
}