Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv21759

Modified Files:
        manager.c 
Log Message:
allow manager getvar action to retrieve global variables as well as
channel variables (issue #5429)


Index: manager.c
===================================================================
RCS file: /usr/cvsroot/asterisk/manager.c,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -d -r1.124 -r1.125
--- manager.c   5 Oct 2005 21:12:57 -0000       1.124
+++ manager.c   13 Oct 2005 20:30:39 -0000      1.125
@@ -689,9 +689,9 @@
 }
 
 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 @@
        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 @@
                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))

_______________________________________________
Asterisk-Cvs mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-cvs

Reply via email to