summaryrefslogtreecommitdiff
path: root/channel.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2005-01-08 17:23:29 +0000
committerMark Spencer <markster@digium.com>2005-01-08 17:23:29 +0000
commit51cab9e7cc4f901c5e18558e5fa64d70057ed5b5 (patch)
tree1ab5994592eeb5873de159707ed5e2f649dd3f3f /channel.c
parentc5aedb3086e5d348be0486823cedb7c4ced9ca8e (diff)
Make queue support channel variable inheritance (bug #3274)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4709 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channel.c')
-rwxr-xr-xchannel.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/channel.c b/channel.c
index efd6486a1..bc54a8bc5 100755
--- a/channel.c
+++ b/channel.c
@@ -2243,6 +2243,49 @@ void ast_change_name(struct ast_channel *chan, char *newname)
manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", tmp, chan->name, chan->uniqueid);
}
+void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child)
+{
+ struct ast_var_t *current, *newvar;
+ char *varname;
+
+ AST_LIST_TRAVERSE(&parent->varshead, current, entries) {
+ int vartype = 0;
+
+ varname = ast_var_full_name(current);
+ if (!varname)
+ continue;
+
+ if (varname[0] == '_') {
+ vartype = 1;
+ if (varname[1] == '_')
+ vartype = 2;
+ }
+
+ switch (vartype) {
+ case 1:
+ newvar = ast_var_assign(&varname[1], ast_var_value(current));
+ if (newvar) {
+ AST_LIST_INSERT_HEAD(&child->varshead, newvar, entries);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Copying soft-transferable variable %s.\n", ast_var_name(newvar));
+ }
+ break;
+ case 2:
+ newvar = ast_var_assign(ast_var_full_name(current), ast_var_value(current));
+ if (newvar) {
+ AST_LIST_INSERT_HEAD(&child->varshead, newvar, entries);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Copying hard-transferable variable %s.\n", ast_var_name(newvar));
+ }
+ break;
+ default:
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Not copying variable %s.\n", ast_var_name(current));
+ break;
+ }
+ }
+}
+
/* Clone channel variables from 'clone' channel into 'original' channel
All variables except those related to app_groupcount are cloned
Variables are actually _removed_ from 'clone' channel, presumably