This patch removes code that was duplicated from pbx.c to manager.c
in order to prevent API change in released versions of Asterisk.
There are propably also other places that would benefit from reading the
return code and react if a function returns error codes on writing a value into it.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@242919
65c4cc65-6c06-0410-ace0-
fbb531ad65f3
* \brief Add a variable to the channel variable stack, removing the most recently set value for the same name.
* \note Will lock the channel. May also be used to set a channel dialplan function to a particular value.
* \see ast_func_write
+ * \return -1 if the dialplan function fails to be set
+ * \version 1.8 changed the function to return an error code
*/
-void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value);
+int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value);
/*!
* \brief Retrieve the value of a builtin variable or variable from the channel variable stack.
return 0;
}
}
- 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, ""));
- }
+
+ res = pbx_builtin_setvar_helper(c, varname, S_OR(varval, ""));
if (c) {
c = ast_channel_unref(c);
ast_rwlock_unlock(&globalslock);
}
-void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
+int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
{
struct ast_var_t *newvariable;
struct varshead *headp;
if (name[strlen(name) - 1] == ')') {
char *function = ast_strdupa(name);
- ast_func_write(chan, function, value);
- return;
+ return ast_func_write(chan, function, value);
}
if (chan) {
ast_channel_unlock(chan);
else
ast_rwlock_unlock(&globalslock);
+ return 0;
}
int pbx_builtin_setvar(struct ast_channel *chan, const char *data)