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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 13 22:11:52 CST 2008


Author: russell
Date: Wed Feb 13 22:11:52 2008
New Revision: 103667

URL: http://svn.digium.com/view/asterisk?view=rev&rev=103667
Log:
add an eval function which evaluates a literal variable string

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=103667&r1=103666&r2=103667
==============================================================================
--- team/russell/bindings/bindings/ast_channel.i (original)
+++ team/russell/bindings/bindings/ast_channel.i Wed Feb 13 22:11:52 2008
@@ -14,6 +14,9 @@
 
 AST_THREADSTORAGE(ast_channel_read_digit_buf);
 #define READ_DIGIT_BUF_LEN 2
+
+AST_THREADSTORAGE(ast_channel_eval_buf);
+#define EVAL_BUF_LEN 4096
 %}
 
 struct ast_channel {
@@ -116,6 +119,20 @@
         return var_val;
     }
 
+    const char *eval(const char *str)
+    {
+        char *buf;
+
+        if (!(buf = ast_threadstorage_get(&ast_channel_eval_buf, EVAL_BUF_LEN)))
+            return "";
+       
+        *buf = '\0';
+
+        pbx_substitute_variables_helper($self, str, buf, EVAL_BUF_LEN - 1);
+
+        return buf;
+    }
+
     const char *wait_for_digit(int timeout = 3000)
     {
         char *buf;

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=103667&r1=103666&r2=103667
==============================================================================
--- team/russell/bindings/bindings/examples/ast_channel_test.py (original)
+++ team/russell/bindings/bindings/examples/ast_channel_test.py Wed Feb 13 22:11:52 2008
@@ -15,6 +15,8 @@
 
 	print 'variable FOO is: ' + chan.get_var('FOO')
 
+	print 'evaluating literal variable string ${FOO} - ' + chan.eval('${FOO}')
+
 	print 'playing a beep and then waiting 3 seconds for a digit ...'
 	digit = chan.wait_for_digit(3000)
 	if len(digit) != 0:




More information about the asterisk-commits mailing list