summaryrefslogtreecommitdiff
path: root/manager.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2005-10-13 20:30:39 +0000
committerRussell Bryant <russell@russellbryant.com>2005-10-13 20:30:39 +0000
commitdee30a519eed8206e9d81002b34fb703d7f78eda (patch)
tree935fef4616ceea80f4bd16e409867f509569e8bc /manager.c
parent1f2943fc0ab6116a833b827eb25a071acebd48a0 (diff)
allow manager getvar action to retrieve global variables as well as
channel variables (issue #5429) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6763 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'manager.c')
-rwxr-xr-xmanager.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/manager.c b/manager.c
index 75ebbe157..bc02a7be4 100755
--- a/manager.c
+++ b/manager.c
@@ -689,9 +689,9 @@ static int action_setvar(struct mansession *s, struct message *m)
}
static char mandescr_getvar[] =
-"Description: Get the value of a local channel variable.\n"
+"Description: Get the value of a global or local channel variable.\n"
"Variables: (Names marked with * are required)\n"
-" *Channel: Channel to read variable from\n"
+" Channel: Channel to read variable from\n"
" *Variable: Variable name\n"
" ActionID: Optional Action id for message matching.\n";
@@ -704,19 +704,17 @@ static int action_getvar(struct mansession *s, struct message *m)
char *varval;
char *varval2=NULL;
- if (!strlen(name)) {
- astman_send_error(s, m, "No channel specified");
- return 0;
- }
if (!strlen(varname)) {
astman_send_error(s, m, "No variable specified");
return 0;
}
- c = ast_get_channel_by_name_locked(name);
- if (!c) {
- astman_send_error(s, m, "No such channel");
- return 0;
+ if (strlen(name)) {
+ c = ast_get_channel_by_name_locked(name);
+ if (!c) {
+ astman_send_error(s, m, "No such channel");
+ return 0;
+ }
}
varval=pbx_builtin_getvar_helper(c,varname);
@@ -724,7 +722,8 @@ static int action_getvar(struct mansession *s, struct message *m)
varval2 = ast_strdupa(varval);
if (!varval2)
varval2 = "";
- ast_mutex_unlock(&c->lock);
+ if (c)
+ ast_mutex_unlock(&c->lock);
ast_cli(s->fd, "Response: Success\r\n"
"Variable: %s\r\nValue: %s\r\n" ,varname,varval2);
if (id && !ast_strlen_zero(id))