From: Olle Johansson Date: Mon, 25 Jan 2010 20:03:38 +0000 (+0000) Subject: Report error when writing to functions returns error in AMI setvar action X-Git-Tag: 1.4.30-rc2~5^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bf13e6d9caf1d8addb018df5f336fe44c9be2ad;p=thirdparty%2Fasterisk.git Report error when writing to functions returns error in AMI setvar action git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@242850 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/manager.c b/main/manager.c index ade1500c56..bdd679c349 100644 --- a/main/manager.c +++ b/main/manager.c @@ -1490,6 +1490,7 @@ 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"); @@ -1503,13 +1504,23 @@ 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); + ast_log(LOG_DEBUG, "---- RESULT of ast_func_write %d \n", res); + } else { + pbx_builtin_setvar_helper(c, varname, S_OR(varval, "")); + } if (c) ast_channel_unlock(c); - astman_send_ack(s, m, "Variable Set"); + ast_log(LOG_DEBUG, "---- RESULT 2 :: ast_func_write %d \n", res); + if (res == 0) { + astman_send_ack(s, m, "Variable Set"); + } else { + astman_send_error(s, m, "Variable not set"); + } return 0; }