mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Add incremental/decremental priorities (bug #2906)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4292 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
16
pbx.c
16
pbx.c
@@ -4939,6 +4939,7 @@ static int pbx_builtin_goto(struct ast_channel *chan, void *data)
|
||||
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 @@ static int pbx_builtin_goto(struct ast_channel *chan, void *data)
|
||||
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)
|
||||
|
Reference in New Issue
Block a user