diff options
author | oej <oej@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-01-25 21:13:20 +0000 |
---|---|---|
committer | oej <oej@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-01-25 21:13:20 +0000 |
commit | 52cccf60848ec3357459db9b06c14a5b2d6c7fd1 (patch) | |
tree | da4586f2d1121090831e666eeb33869c08409b10 | |
parent | 09b1277fb2d81c6dd9463411712b4525da603de4 (diff) |
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.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@242919 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | include/asterisk/pbx.h | 4 | ||||
-rw-r--r-- | main/manager.c | 8 | ||||
-rw-r--r-- | main/pbx.c | 6 |
3 files changed, 8 insertions, 10 deletions
diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h index 50a18a624..cfbb2754b 100644 --- a/include/asterisk/pbx.h +++ b/include/asterisk/pbx.h @@ -990,8 +990,10 @@ void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, cons * \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. diff --git a/main/manager.c b/main/manager.c index 8f01ea278..2d1fa476d 100644 --- a/main/manager.c +++ b/main/manager.c @@ -2813,12 +2813,8 @@ static int action_setvar(struct mansession *s, const struct message *m) 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); diff --git a/main/pbx.c b/main/pbx.c index 1b6e498f5..c13feffb7 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -9407,7 +9407,7 @@ void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, cons 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 @@ void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const 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 @@ void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const ast_channel_unlock(chan); else ast_rwlock_unlock(&globalslock); + return 0; } int pbx_builtin_setvar(struct ast_channel *chan, const char *data) |