Fix AGI to know about "builtin" variables, too (bug #2737)
authorMark Spencer <markster@digium.com>
Thu, 23 Dec 2004 02:47:01 +0000 (02:47 +0000)
committerMark Spencer <markster@digium.com>
Thu, 23 Dec 2004 02:47:01 +0000 (02:47 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4538 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/pbx.h
pbx.c
res/res_agi.c

index aebf7ab..33aa1b5 100755 (executable)
@@ -567,6 +567,7 @@ struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw
 int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t size);
 extern char *pbx_builtin_getvar_helper(struct ast_channel *chan, char *name);
 extern void pbx_builtin_setvar_helper(struct ast_channel *chan, char *name, char *value);
+extern void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp);
 extern void pbx_builtin_clear_globals(void);
 extern int pbx_builtin_setvar(struct ast_channel *chan, void *data);
 extern void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);
diff --git a/pbx.c b/pbx.c
index 999a765..95b661b 100755 (executable)
--- a/pbx.c
+++ b/pbx.c
@@ -795,7 +795,7 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan, struct ast
        return NULL;
 }
 
-static void pbx_substitute_variables_temp(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp)
+void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp)
 {
        char *first,*second;
        char tmpvar[80] = "";
@@ -827,7 +827,7 @@ static void pbx_substitute_variables_temp(struct ast_channel *c, const char *var
                if (!first)
                        first = tmpvar + strlen(tmpvar);
                *first='\0';
-               pbx_substitute_variables_temp(c,tmpvar,ret,workspace,workspacelen - 1, headp);
+               pbx_retrieve_variable(c,tmpvar,ret,workspace,workspacelen - 1, headp);
                if (!(*ret)) return;
                offset=atoi(first+1);
                if ((second=strchr(first+1,':'))) {
@@ -1103,7 +1103,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, const ch
                        
                        /* Retrieve variable value */
                        workspace[0] = '\0';
-                       pbx_substitute_variables_temp(c,vars,&cp4, workspace, sizeof(workspace), headp);
+                       pbx_retrieve_variable(c,vars,&cp4, workspace, sizeof(workspace), headp);
                        if (cp4) {
                                length = strlen(cp4);
                                if (length > count)
index e7bced2..0572f0b 100755 (executable)
@@ -983,11 +983,13 @@ static int handle_setvariable(struct ast_channel *chan, AGI *agi, int argc, char
 
 static int handle_getvariable(struct ast_channel *chan, AGI *agi, int argc, char **argv)
 {
-       char *tempstr;
+       char *ret;
+       char tempstr[1024];
        if (argc != 3)
                return RESULT_SHOWUSAGE;
-       if ((tempstr = pbx_builtin_getvar_helper(chan, argv[2]))) 
-               fdprintf(agi->fd, "200 result=1 (%s)\n", tempstr);
+       pbx_retrieve_variable(chan, argv[2], &ret, tempstr, sizeof(tempstr), NULL);
+       if (ret)
+               fdprintf(agi->fd, "200 result=1 (%s)\n", ret);
        else
                fdprintf(agi->fd, "200 result=0\n");