[Asterisk-cvs] asterisk pbx.c,1.172,1.173

markster at lists.digium.com markster at lists.digium.com
Fri Nov 19 00:17:52 CST 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv868

Modified Files:
	pbx.c 
Log Message:
Add incremental/decremental priorities (bug #2906)


Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.172
retrieving revision 1.173
diff -u -d -r1.172 -r1.173
--- pbx.c	17 Nov 2004 04:48:58 -0000	1.172
+++ pbx.c	19 Nov 2004 05:18:10 -0000	1.173
@@ -4939,6 +4939,7 @@
 	char *exten, *pri, *context;
 	char *stringp=NULL;
 	int ipri;
+	int mode = 0;
 
 	if (!data || ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "Goto requires an argument (optional context|optional extension|priority)\n");
@@ -4962,15 +4963,26 @@
 			context = NULL;
 		}
 	}
+	if (*pri == '+') {
+		mode = 1;
+		pri++;
+	} else if (*pri == '-') {
+		mode = -1;
+		pri++;
+	}
 	if (sscanf(pri, "%i", &ipri) != 1) {
 		if ((ipri = ast_findlabel_extension(chan, context ? context : chan->context, (exten && strcasecmp(exten, "BYEXTENSION")) ? exten : chan->exten, 
 			pri, chan->cid.cid_num)) < 1) {
 			ast_log(LOG_WARNING, "Priority '%s' must be a number > 0, or valid label\n", pri);
 			return -1;
-		}
+		} else
+			mode = 0;
 	} 
 	/* At this point we have a priority and maybe an extension and a context */
-	chan->priority = ipri - 1;
+	if (mode)
+		chan->priority += mode * ipri - 1;
+	else
+		chan->priority = ipri - 1;
 	if (exten && strcasecmp(exten, "BYEXTENSION"))
 		strncpy(chan->exten, exten, sizeof(chan->exten)-1);
 	if (context)




More information about the svn-commits mailing list