mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
Fix AGI to know about "builtin" variables, too (bug #2737)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4538 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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);
|
||||
|
6
pbx.c
6
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)
|
||||
|
@@ -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");
|
||||
|
||||
|
Reference in New Issue
Block a user