diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-11-06 18:11:13 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-11-06 18:11:13 +0000 |
commit | b39d1e60ffe75a5fb52a6117542e92e912698ea0 (patch) | |
tree | db9f547fad3d9bc38fc7f2f25ba29b4ac68724f5 /apps/app_chanisavail.c | |
parent | d3ddc001a22ebbbea8ff3601fe8698edff8e7f05 (diff) |
issue #5598
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6980 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_chanisavail.c')
-rwxr-xr-x | apps/app_chanisavail.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/apps/app_chanisavail.c b/apps/app_chanisavail.c index be18f1a43..957f4125a 100755 --- a/apps/app_chanisavail.c +++ b/apps/app_chanisavail.c @@ -42,6 +42,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/module.h" #include "asterisk/app.h" #include "asterisk/devicestate.h" +#include "asterisk/options.h" static char *tdesc = "Check if channel is available"; @@ -51,17 +52,16 @@ static char *synopsis = "Check if channel is available"; static char *descrip = " ChanIsAvail(Technology/resource[&Technology2/resource2...][|option]): \n" -"Checks is any of the requested channels are available. If none\n" -"of the requested channels are available the new priority will be\n" -"n+101 (unless such a priority does not exist or on error, in which\n" -"case ChanIsAvail will return -1).\n" +"Checks is any of the requested channels are available. \n" "If any of the requested channels are available, the next priority will be n+1,\n" "the channel variable ${AVAILCHAN} will be set to the name of the available channel\n" "and the ChanIsAvail app will return 0.\n" "${AVAILORIGCHAN} is the canonical channel name that was used to create the channel.\n" "${AVAILSTATUS} is the status code for the channel.\n" "If the option 's' is specified (state), will consider channel unavailable\n" -"when the channel is in use at all, even if it can take another call.\n"; +"when the channel is in use at all, even if it can take another call.\n" +"If the option 'j' is specified (jump), the application will jump to n+101 \n" +"(unless such a priority does not exist, in which case ChanIsAvail will return -1)\n"; STANDARD_LOCAL_USER; @@ -69,7 +69,7 @@ LOCAL_USER_DECL; static int chanavail_exec(struct ast_channel *chan, void *data) { - int res=-1, inuse=-1, option_state=0; + int res=-1, inuse=-1, option_state=0, priority_jump=0; int status; struct localuser *u; char *info, tmp[512], trychan[512], *peers, *tech, *number, *rest, *cur, *options, *stringp; @@ -86,8 +86,12 @@ static int chanavail_exec(struct ast_channel *chan, void *data) stringp = info; strsep(&stringp, "|"); options = strsep(&stringp, "|"); - if (options && *options == 's') - option_state = 1; + if (options) { + if (strchr(options, 's')) + option_state = 1; + if (strchr(options, 'j')) + priority_jump = 1; + } peers = info; if (peers) { cur = peers; @@ -137,9 +141,11 @@ static int chanavail_exec(struct ast_channel *chan, void *data) if (res < 1) { pbx_builtin_setvar_helper(chan, "AVAILCHAN", ""); pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", ""); - if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) { - LOCAL_USER_REMOVE(u); - return -1; + if (priority_jump || option_priority_jumping) { + if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) { + LOCAL_USER_REMOVE(u); + return -1; + } } } |