From 4d84d67e5713cd0de5761fe6485aa4fcf57c2704 Mon Sep 17 00:00:00 2001 From: Matthew Jordan Date: Thu, 2 May 2013 20:59:20 +0000 Subject: Migrate AMI VarSet events raised by GoSub local variables This patch moves VarSet events for local variables raised by GoSub over to Stasis-Core. It also tweaks up the post-processing documentation scripts to not combine parameters if both parameters are already documented. (issue ASTERISK-21462) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@387519 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_stack.c | 49 ++++++++++++++++++++++--------- build_tools/post_process_documentation.py | 4 +-- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/apps/app_stack.c b/apps/app_stack.c index 73731be6b..9260f2ad0 100644 --- a/apps/app_stack.c +++ b/apps/app_stack.c @@ -40,6 +40,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/manager.h" #include "asterisk/channel.h" #include "asterisk/agi.h" +#include "asterisk/stasis_channels.h" /*** DOCUMENTATION @@ -202,7 +203,32 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") Cause the channel to execute the specified dialplan subroutine, returning to the dialplan with execution of a Return(). + + GoSub + + + + Raised when a variable local to the gosub stack frame is set due to a subroutine call. + + + + The LOCAL variable being set. + The variable name will always be enclosed with + LOCAL() + + + The new value of the variable. + + + + GoSub + gosub + LOCAL + LOCAL_PEEK + + + ***/ static const char app_gosub[] = "Gosub"; @@ -235,6 +261,8 @@ static int frame_set_var(struct ast_channel *chan, struct gosub_stack_frame *fra { struct ast_var_t *variables; int found = 0; + int len; + RAII_VAR(char *, local_buffer, NULL, ast_free); /* Does this variable already exist? */ AST_LIST_TRAVERSE(&frame->varshead, variables, entries) { @@ -252,20 +280,13 @@ static int frame_set_var(struct ast_channel *chan, struct gosub_stack_frame *fra pbx_builtin_setvar_helper(chan, var, value); } - /*** DOCUMENTATION - - Raised when a LOCAL channel variable is set due to a subroutine call. - - GoSub - - - ***/ - manager_event(EVENT_FLAG_DIALPLAN, "VarSet", - "Channel: %s\r\n" - "Variable: LOCAL(%s)\r\n" - "Value: %s\r\n" - "Uniqueid: %s\r\n", - ast_channel_name(chan), var, value, ast_channel_uniqueid(chan)); + len = 8 + strlen(var); /* LOCAL() + var */ + local_buffer = ast_malloc(len); + if (!local_buffer) { + return 0; + } + sprintf(local_buffer, "LOCAL(%s)", var); + ast_channel_publish_varset(chan, local_buffer, value); return 0; } diff --git a/build_tools/post_process_documentation.py b/build_tools/post_process_documentation.py index b2d9e5e72..678328dd3 100644 --- a/build_tools/post_process_documentation.py +++ b/build_tools/post_process_documentation.py @@ -22,9 +22,9 @@ def merge_parameter_information(managerEvent): def __swap_parameter_documentation(one, two): # See who has the better documentation and use it - if (one.hasChildNodes()): + if (one.hasChildNodes() and not two.hasChildNodes()): two.parentNode.replaceChild(one.cloneNode(True), two) - elif (two.hasChildNodes()): + elif (two.hasChildNodes() and not one.hasChildNodes()): one.parentNode.replaceChild(two.cloneNode(True), one) def __merge_parameter(param, other_instances): -- cgit v1.2.3