[asterisk-commits] russell: branch russell/bindings r103327 - in /team/russell/bindings/bindings...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 11 17:15:33 CST 2008


Author: russell
Date: Mon Feb 11 17:15:32 2008
New Revision: 103327

URL: http://svn.digium.com/view/asterisk?view=rev&rev=103327
Log:
expose get_var/set_var

Modified:
    team/russell/bindings/bindings/ast_channel.i
    team/russell/bindings/bindings/examples/ast_channel_test.py

Modified: team/russell/bindings/bindings/ast_channel.i
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/bindings/ast_channel.i?view=diff&rev=103327&r1=103326&r2=103327
==============================================================================
--- team/russell/bindings/bindings/ast_channel.i (original)
+++ team/russell/bindings/bindings/ast_channel.i Mon Feb 11 17:15:32 2008
@@ -82,4 +82,24 @@
     {
         return ast_softhangup($self, AST_SOFTHANGUP_EXPLICIT);
     }
+
+    void set_var(const char *var_name, const char *var_value)
+    {
+        pbx_builtin_setvar_helper($self, var_name, var_value);
+    }
+
+    const char *get_var(const char *var_name)
+    {
+        static __thread char workspace[1024];
+        char *var_val = NULL;
+
+        if (var_name[strlen(var_name) - 1] == ')') {
+            ast_func_read($self, var_name, workspace, sizeof(workspace));
+            var_val = workspace;
+        } else {
+            pbx_retrieve_variable($self, var_name, &var_val, workspace, sizeof(workspace), NULL);
+        }
+
+        return var_val;
+    }
 };

Modified: team/russell/bindings/bindings/examples/ast_channel_test.py
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/bindings/examples/ast_channel_test.py?view=diff&rev=103327&r1=103326&r2=103327
==============================================================================
--- team/russell/bindings/bindings/examples/ast_channel_test.py (original)
+++ team/russell/bindings/bindings/examples/ast_channel_test.py Mon Feb 11 17:15:32 2008
@@ -7,5 +7,8 @@
 	chan.answer()
 	print 'Executing Playback of tt-weasels ...'
 	chan.exec_app('Playback', 'tt-weasels')
+	print 'setting FOO to BAR ...'
+	chan.set_var('FOO', 'BAR')
+	print 'variable FOO is: ' + chan.get_var('FOO')
 	print 'Hanging up ...'
 	chan.hangup()




More information about the asterisk-commits mailing list