]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Report error when writing to functions returns error in AMI setvar action
authorOlle Johansson <oej@edvina.net>
Mon, 25 Jan 2010 20:03:38 +0000 (20:03 +0000)
committerOlle Johansson <oej@edvina.net>
Mon, 25 Jan 2010 20:03:38 +0000 (20:03 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@242850 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/manager.c

index ade1500c56f386a41003190b35cc4b0e36442c1f..bdd679c3499d2a9f004a148551b7cf2a56ee3317 100644 (file)
@@ -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;
 }