From 6f549bc3245e94b8e6d4ee4d5f2364761ba93980 Mon Sep 17 00:00:00 2001
From: Jason Parker <jparker@digium.com>
Date: Tue, 22 Apr 2008 18:14:09 +0000
Subject: [PATCH] Allow setqueuevar=yes (et al) to work, after changes to
 pbx_builtin_setvar()

(closes issue #12490)
Reported by: bcnit
Patches:
      12490-queuevars-3.diff uploaded by qwell (license 4)
Tested by: qwell


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@114540 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 apps/app_queue.c       | 16 ++++++++--------
 include/asterisk/pbx.h |  1 +
 main/pbx.c             |  4 ++--
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/apps/app_queue.c b/apps/app_queue.c
index 9842111c89..ae43243e85 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -588,11 +588,11 @@ static void set_queue_variables(struct queue_ent *qe)
 			sl = 100 * ((float) qe->parent->callscompletedinsl / (float) qe->parent->callscompleted);
 
 		snprintf(interfacevar, sizeof(interfacevar),
-			"QUEUENAME=%s|QUEUEMAX=%d|QUEUESTRATEGY=%s|QUEUECALLS=%d|QUEUEHOLDTIME=%d|QUEUECOMPLETED=%d|QUEUEABANDONED=%d|QUEUESRVLEVEL=%d|QUEUESRVLEVELPERF=%2.1f",
+			"QUEUENAME=%s,QUEUEMAX=%d,QUEUESTRATEGY=%s,QUEUECALLS=%d,QUEUEHOLDTIME=%d,QUEUECOMPLETED=%d,QUEUEABANDONED=%d,QUEUESRVLEVEL=%d,QUEUESRVLEVELPERF=%2.1f",
 			qe->parent->name, qe->parent->maxlen, int2strat(qe->parent->strategy), qe->parent->count, qe->parent->holdtime, qe->parent->callscompleted,
 			qe->parent->callsabandoned,  qe->parent->servicelevel, sl);
 	
-		pbx_builtin_setvar(qe->chan, interfacevar); 
+		pbx_builtin_setvar_multiple(qe->chan, interfacevar); 
 	}
 }
 
@@ -3395,17 +3395,17 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
 		/* if setinterfacevar is defined, make member variables available to the channel */
 		/* use  pbx_builtin_setvar to set a load of variables with one call */
 		if (qe->parent->setinterfacevar) {
-			snprintf(interfacevar, sizeof(interfacevar), "MEMBERINTERFACE=%s|MEMBERNAME=%s|MEMBERCALLS=%d|MEMBERLASTCALL=%ld|MEMBERPENALTY=%d|MEMBERDYNAMIC=%d|MEMBERREALTIME=%d",
+			snprintf(interfacevar, sizeof(interfacevar), "MEMBERINTERFACE=%s,MEMBERNAME=%s,MEMBERCALLS=%d,MEMBERLASTCALL=%ld,MEMBERPENALTY=%d,MEMBERDYNAMIC=%d,MEMBERREALTIME=%d",
 				member->interface, member->membername, member->calls, (long)member->lastcall, member->penalty, member->dynamic, member->realtime);
-		 	pbx_builtin_setvar(qe->chan, interfacevar);
+		 	pbx_builtin_setvar_multiple(qe->chan, interfacevar);
 		}
 		
 		/* if setqueueentryvar is defined, make queue entry (i.e. the caller) variables available to the channel */
 		/* use  pbx_builtin_setvar to set a load of variables with one call */
 		if (qe->parent->setqueueentryvar) {
-			snprintf(interfacevar, sizeof(interfacevar), "QEHOLDTIME=%ld|QEORIGINALPOS=%d",
+			snprintf(interfacevar, sizeof(interfacevar), "QEHOLDTIME=%ld,QEORIGINALPOS=%d",
 				(long) time(NULL) - qe->start, qe->opos);
-			pbx_builtin_setvar(qe->chan, interfacevar);
+			pbx_builtin_setvar_multiple(qe->chan, interfacevar);
 		}
 	
 		/* try to set queue variables if configured to do so*/
@@ -4659,10 +4659,10 @@ static int queue_function_var(struct ast_channel *chan, const char *cmd, char *d
 		                sl = 100 * ((float) q->callscompletedinsl / (float) q->callscompleted);
 
 		        snprintf(interfacevar, sizeof(interfacevar),
-                		"QUEUEMAX=%d|QUEUESTRATEGY=%s|QUEUECALLS=%d|QUEUEHOLDTIME=%d|QUEUECOMPLETED=%d|QUEUEABANDONED=%d|QUEUESRVLEVEL=%d|QUEUESRVLEVELPERF=%2.1f",
+                		"QUEUEMAX=%d,QUEUESTRATEGY=%s,QUEUECALLS=%d,QUEUEHOLDTIME=%d,QUEUECOMPLETED=%d,QUEUEABANDONED=%d,QUEUESRVLEVEL=%d,QUEUESRVLEVELPERF=%2.1f",
 		                q->maxlen, int2strat(q->strategy), q->count, q->holdtime, q->callscompleted, q->callsabandoned,  q->servicelevel, sl);
 
-		        pbx_builtin_setvar(chan, interfacevar);
+		        pbx_builtin_setvar_multiple(chan, interfacevar);
 	        }
 
 		ao2_unlock(q);
diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h
index 56bd83fa56..fa0ceb0d26 100644
--- a/include/asterisk/pbx.h
+++ b/include/asterisk/pbx.h
@@ -837,6 +837,7 @@ void pbx_builtin_clear_globals(void);
  * \note Will lock the channel.
  */
 int pbx_builtin_setvar(struct ast_channel *chan, void *data);
+int pbx_builtin_setvar_multiple(struct ast_channel *chan, void *data);
 
 int pbx_builtin_raise_exception(struct ast_channel *chan, void *data);
 
diff --git a/main/pbx.c b/main/pbx.c
index 7a8923f8e3..1aecee7c9e 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -320,7 +320,7 @@ static int pbx_builtin_sayphonetic(struct ast_channel *, void *);
 static int matchcid(const char *cidpattern, const char *callerid);
 int pbx_builtin_setvar(struct ast_channel *, void *);
 void log_match_char_tree(struct match_char *node, char *prefix); /* for use anywhere */
-static int pbx_builtin_setvar_multiple(struct ast_channel *, void *);
+int pbx_builtin_setvar_multiple(struct ast_channel *, void *);
 static int pbx_builtin_importvar(struct ast_channel *, void *);
 static void set_ext_pri(struct ast_channel *c, const char *exten, int pri); 
 static void new_find_extension(const char *str, struct scoreboard *score, struct match_char *tree, int length, int spec, const char *callerid, enum ext_match_t action);
@@ -7869,7 +7869,7 @@ int pbx_builtin_setvar(struct ast_channel *chan, void *data)
 	return(0);
 }
 
-static int pbx_builtin_setvar_multiple(struct ast_channel *chan, void *vdata)
+int pbx_builtin_setvar_multiple(struct ast_channel *chan, void *vdata)
 {
 	char *data;
 	int x;
-- 
GitLab