[asterisk-commits] tilghman: trunk r241012 - in /trunk: CHANGES funcs/func_strings.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 18 13:26:11 CST 2010


Author: tilghman
Date: Mon Jan 18 13:26:07 2010
New Revision: 241012

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=241012
Log:
Make HASHes inheritable across channel creation.

Modified:
    trunk/CHANGES
    trunk/funcs/func_strings.c

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=241012&r1=241011&r2=241012
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Mon Jan 18 13:26:07 2010
@@ -183,6 +183,9 @@
  * Added PASSTHRU, which literally passes the same argument back as its return
    value.  The intent is to be able to use a literal string argument to
    functions that currently require a variable name as an argument.
+ * HASH-associated variables now can be inherited across channel creation, by
+   prefixing the name of the hash at assignment with the appropriate number of
+   underscores, just like variables.
 
 Dialplan Variables
 ------------------

Modified: trunk/funcs/func_strings.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_strings.c?view=diff&rev=241012&r1=241011&r2=241012
==============================================================================
--- trunk/funcs/func_strings.c (original)
+++ trunk/funcs/func_strings.c Mon Jan 18 13:26:07 2010
@@ -831,7 +831,16 @@
 				arg2.val[i]);
 		if (i < arg2.argc) {
 			if (ishash) {
-				snprintf(varname, sizeof(varname), HASH_FORMAT, origvar, arg1.var[i]);
+				if (origvar[0] == '_') {
+					if (origvar[1] == '_') {
+						snprintf(varname, sizeof(varname), "__" HASH_FORMAT, origvar + 2, arg1.var[i]);
+					} else {
+						snprintf(varname, sizeof(varname), "_" HASH_FORMAT, origvar + 1, arg1.var[i]);
+					}
+				} else {
+					snprintf(varname, sizeof(varname), HASH_FORMAT, origvar, arg1.var[i]);
+				}
+
 				pbx_builtin_setvar_helper(chan, varname, arg2.val[i]);
 			} else {
 				pbx_builtin_setvar_helper(chan, arg1.var[i], arg2.val[i]);
@@ -909,7 +918,15 @@
 	}
 
 	AST_STANDARD_APP_ARGS(arg, var);
-	snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg.hashkey);
+	if (arg.hashname[0] == '_') {
+		if (arg.hashname[1] == '_') {
+			snprintf(varname, sizeof(varname), "__" HASH_FORMAT, arg.hashname + 2, arg.hashkey);
+		} else {
+			snprintf(varname, sizeof(varname), "_" HASH_FORMAT, arg.hashname + 1, arg.hashkey);
+		}
+	} else {
+		snprintf(varname, sizeof(varname), HASH_FORMAT, arg.hashname, arg.hashkey);
+	}
 	pbx_builtin_setvar_helper(chan, varname, value);
 
 	return 0;




More information about the asterisk-commits mailing list