diff options
author | Jason Parker <jparker@digium.com> | 2013-07-08 14:46:20 +0000 |
---|---|---|
committer | Jason Parker <jparker@digium.com> | 2013-07-08 14:46:20 +0000 |
commit | 87973eecffbf400da98b67eca1dbed038af40439 (patch) | |
tree | 792c79b81749434c8ead92c5e66708ef8897d87b /res/stasis | |
parent | 7422581b6d4921cebfcf177fc63b2ef852fdef58 (diff) |
ARI: Add support for getting/setting channel and global variables.
This allows for reading and writing of functions on channels.
(closes issue ASTERISK-21868)
Review: https://reviewboard.asterisk.org/r/2641/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393806 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/stasis')
-rw-r--r-- | res/stasis/control.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/res/stasis/control.c b/res/stasis/control.c index 2bba842ed..6a7a9ba4d 100644 --- a/res/stasis/control.c +++ b/res/stasis/control.c @@ -207,6 +207,34 @@ int stasis_app_control_continue(struct stasis_app_control *control, const char * return 0; } +char *stasis_app_control_get_channel_var(struct stasis_app_control *control, const char *variable) +{ + SCOPED_CHANNELLOCK(lockvar, control->channel); + + RAII_VAR(struct ast_str *, tmp, ast_str_create(32), ast_free); + + if (!tmp) { + return NULL; + } + + if (variable[strlen(variable) - 1] == ')') { + if (ast_func_read2(control->channel, variable, &tmp, 0)) { + return NULL; + } + } else { + if (!ast_str_retrieve_variable(&tmp, 0, control->channel, NULL, variable)) { + return NULL; + } + } + + return ast_strdup(ast_str_buffer(tmp)); +} + +int stasis_app_control_set_channel_var(struct stasis_app_control *control, const char *variable, const char *value) +{ + return pbx_builtin_setvar_helper(control->channel, variable, value); +} + static void *app_control_hold(struct stasis_app_control *control, struct ast_channel *chan, void *data) { |