[asterisk-commits] oej: trunk r242919 - in /trunk: include/asterisk/pbx.h main/manager.c main/pbx.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jan 25 15:13:23 CST 2010
Author: oej
Date: Mon Jan 25 15:13:20 2010
New Revision: 242919
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=242919
Log:
Change api for pbx_builtin_setvar to actually return error code if a function can't be written to.
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.
Modified:
trunk/include/asterisk/pbx.h
trunk/main/manager.c
trunk/main/pbx.c
Modified: trunk/include/asterisk/pbx.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/pbx.h?view=diff&rev=242919&r1=242918&r2=242919
==============================================================================
--- trunk/include/asterisk/pbx.h (original)
+++ trunk/include/asterisk/pbx.h Mon Jan 25 15:13:20 2010
@@ -990,8 +990,10 @@
* \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
- */
-void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value);
+ * \return -1 if the dialplan function fails to be set
+ * \version 1.8 changed the function to return an error code
+ */
+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.
Modified: trunk/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager.c?view=diff&rev=242919&r1=242918&r2=242919
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Mon Jan 25 15:13:20 2010
@@ -2813,12 +2813,8 @@
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);
Modified: trunk/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/pbx.c?view=diff&rev=242919&r1=242918&r2=242919
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Mon Jan 25 15:13:20 2010
@@ -9407,7 +9407,7 @@
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;
@@ -9416,8 +9416,7 @@
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) {
@@ -9462,6 +9461,7 @@
ast_channel_unlock(chan);
else
ast_rwlock_unlock(&globalslock);
+ return 0;
}
int pbx_builtin_setvar(struct ast_channel *chan, const char *data)
More information about the asterisk-commits
mailing list