dect
/
asterisk
Archived
13
0
Fork 0

Add GET FULL VARIABLE AGI command

git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4270 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
markster 2004-11-17 04:02:56 +00:00
parent e1e7f61edb
commit 12bf011f97
1 changed files with 37 additions and 1 deletions

View File

@ -967,7 +967,8 @@ 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;
if (argc != 3)
return RESULT_SHOWUSAGE;
if ((tempstr = pbx_builtin_getvar_helper(chan, argv[2])))
fdprintf(agi->fd, "200 result=1 (%s)\n", tempstr);
else
@ -976,6 +977,33 @@ static int handle_getvariable(struct ast_channel *chan, AGI *agi, int argc, char
return RESULT_SUCCESS;
}
static int handle_getvariablefull(struct ast_channel *chan, AGI *agi, int argc, char **argv)
{
char tmp[4096];
struct ast_channel *chan2=NULL;
if ((argc != 4) && (argc != 5))
return RESULT_SHOWUSAGE;
if (argc == 5) {
while((chan2 = ast_channel_walk_locked(chan2))) {
if (!strcmp(chan2->name, argv[4]))
break;
ast_mutex_unlock(&chan2->lock);
chan2 = ast_channel_walk_locked(chan2);
}
} else {
chan2 = chan;
}
if (chan) {
pbx_substitute_variables_helper(chan2, argv[3], tmp, sizeof(tmp) - 1);
fdprintf(agi->fd, "200 result=1 (%s)\n", tmp);
} else {
fdprintf(agi->fd, "200 result=0\n");
}
if (chan2 && (chan2 != chan))
ast_mutex_unlock(&chan2->lock);
return RESULT_SUCCESS;
}
static int handle_verbose(struct ast_channel *chan, AGI *agi, int argc, char **argv)
{
int level = 0;
@ -1168,6 +1196,13 @@ static char usage_getvariable[] =
" is set and returns the variable in parenthesis\n"
" example return code: 200 result=1 (testvariable)\n";
static char usage_getvariablefull[] =
" Usage: GET FULL VARIABLE <variablename> [<channel name>]\n"
" Returns 0 if <variablename> is not set or channel does not exist. Returns 1\n"
"if <variablename> is set and returns the variable in parenthesis. Understands\n"
"complex variable names and builtin variables, unlike GET VARIABLE.\n"
" example return code: 200 result=1 (testvariable)\n";
static char usage_setvariable[] =
" Usage: SET VARIABLE <variablename> <value>\n";
@ -1347,6 +1382,7 @@ static agi_command commands[MAX_COMMANDS] = {
{ { "channel", "status", NULL }, handle_channelstatus, "Returns status of the connected channel", usage_channelstatus },
{ { "set", "variable", NULL }, handle_setvariable, "Sets a channel variable", usage_setvariable },
{ { "get", "variable", NULL }, handle_getvariable, "Gets a channel variable", usage_getvariable },
{ { "get", "full", "variable", NULL }, handle_getvariablefull, "Evaluates a channel expression", usage_getvariablefull },
{ { "verbose", NULL }, handle_verbose, "Logs a message to the asterisk verbose log", usage_verbose },
{ { "database", "get", NULL }, handle_dbget, "Gets database value", usage_dbget },
{ { "database", "put", NULL }, handle_dbput, "Adds/updates database value", usage_dbput },