Merged revisions 242904 via svnmerge from

https://origsvn.digium.com/svn/asterisk/trunk

................
r242904 | oej | 2010-01-25 21:27:59 +0100 (Mån, 25 Jan 2010) | 10 lines

Merged revisions 242850 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r242850 | oej | 2010-01-25 21:03:38 +0100 (Mån, 25 Jan 2010) | 2 lines

Report error when writing to functions returns error in AMI setvar action

........

................


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@242916 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Olle Johansson
2010-01-25 20:49:45 +00:00
parent 8269240bd5
commit dbbeff660d
3 changed files with 41 additions and 83 deletions

View File

@@ -1788,7 +1788,8 @@ static int action_setvar(struct mansession *s, const struct message *m)
const char *name = astman_get_header(m, "Channel");
const char *varname = astman_get_header(m, "Variable");
const char *varval = astman_get_header(m, "Value");
int res = 0;
if (ast_strlen_zero(varname)) {
astman_send_error(s, m, "No variable specified");
return 0;
@@ -1801,14 +1802,20 @@ static int action_setvar(struct mansession *s, const struct message *m)
return 0;
}
}
pbx_builtin_setvar_helper(c, varname, S_OR(varval, ""));
if (varname[strlen(varname)-1] == ')') {
char *function = ast_strdupa(varname);
res = ast_func_write(c, function, varval);
} else {
pbx_builtin_setvar_helper(c, varname, S_OR(varval, ""));
}
if (c)
ast_channel_unlock(c);
astman_send_ack(s, m, "Variable Set");
if (res == 0) {
astman_send_ack(s, m, "Variable Set");
} else {
astman_send_error(s, m, "Variable not set");
}
return 0;
}