Make HASHes inheritable across channel creation.
authorTilghman Lesher <tilghman@meg.abyt.es>
Mon, 18 Jan 2010 19:26:07 +0000 (19:26 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Mon, 18 Jan 2010 19:26:07 +0000 (19:26 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@241012 65c4cc65-6c06-0410-ace0-fbb531ad65f3

CHANGES
funcs/func_strings.c

diff --git a/CHANGES b/CHANGES
index ee85f6f..00b1d19 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -183,6 +183,9 @@ Dialplan Functions
  * 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
 ------------------
index 5dbd83a..afabb0f 100644 (file)
@@ -831,7 +831,16 @@ static int array(struct ast_channel *chan, const char *cmd, char *var,
                                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 @@ static int hash_write(struct ast_channel *chan, const char *cmd, char *var, cons
        }
 
        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;