mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-30 07:41:39 +00:00 
			
		
		
		
	issue #5598
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6980 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		| @@ -5,6 +5,7 @@ | |||||||
| 	* sounds.txt: Add missing words from the description of the vm-opts prompt | 	* sounds.txt: Add missing words from the description of the vm-opts prompt | ||||||
| 	* apps/app_externalivr.c: Add a space that fixes building on older versions of gcc | 	* apps/app_externalivr.c: Add a space that fixes building on older versions of gcc | ||||||
| 	* many files: Add doxygen updates to categorize modules into groups. Convert a lot of comments over to doxygen style. Add some text giving a basic overview of channels. | 	* many files: Add doxygen updates to categorize modules into groups. Convert a lot of comments over to doxygen style. Add some text giving a basic overview of channels. | ||||||
|  | 	* apps/app_chanisavail.c: Make priority jumping optional | ||||||
|  |  | ||||||
| 2005-11-05  Kevin P. Fleming  <kpfleming@digium.com> | 2005-11-05  Kevin P. Fleming  <kpfleming@digium.com> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -42,6 +42,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") | |||||||
| #include "asterisk/module.h" | #include "asterisk/module.h" | ||||||
| #include "asterisk/app.h" | #include "asterisk/app.h" | ||||||
| #include "asterisk/devicestate.h" | #include "asterisk/devicestate.h" | ||||||
|  | #include "asterisk/options.h" | ||||||
|  |  | ||||||
| static char *tdesc = "Check if channel is available"; | static char *tdesc = "Check if channel is available"; | ||||||
|  |  | ||||||
| @@ -51,17 +52,16 @@ static char *synopsis = "Check if channel is available"; | |||||||
|  |  | ||||||
| static char *descrip =  | static char *descrip =  | ||||||
| "  ChanIsAvail(Technology/resource[&Technology2/resource2...][|option]): \n" | "  ChanIsAvail(Technology/resource[&Technology2/resource2...][|option]): \n" | ||||||
| "Checks is any of the requested channels are available.  If none\n" | "Checks is any of the requested channels are available.  \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" |  | ||||||
| "If any of the requested channels are available, the next priority will be n+1,\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" | "the channel variable ${AVAILCHAN} will be set to the name of the available channel\n" | ||||||
| "and the ChanIsAvail app will return 0.\n" | "and the ChanIsAvail app will return 0.\n" | ||||||
| "${AVAILORIGCHAN} is the canonical channel name that was used to create the channel.\n" | "${AVAILORIGCHAN} is the canonical channel name that was used to create the channel.\n" | ||||||
| "${AVAILSTATUS} is the status code for the channel.\n" | "${AVAILSTATUS} is the status code for the channel.\n" | ||||||
| "If the option 's' is specified (state), will consider channel unavailable\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; | STANDARD_LOCAL_USER; | ||||||
|  |  | ||||||
| @@ -69,7 +69,7 @@ LOCAL_USER_DECL; | |||||||
|  |  | ||||||
| static int chanavail_exec(struct ast_channel *chan, void *data) | 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; | 	int status; | ||||||
| 	struct localuser *u; | 	struct localuser *u; | ||||||
| 	char *info, tmp[512], trychan[512], *peers, *tech, *number, *rest, *cur, *options, *stringp; | 	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; | 	stringp = info; | ||||||
| 	strsep(&stringp, "|"); | 	strsep(&stringp, "|"); | ||||||
| 	options = strsep(&stringp, "|"); | 	options = strsep(&stringp, "|"); | ||||||
| 	if (options && *options == 's') | 	if (options) { | ||||||
|  | 		if (strchr(options, 's')) | ||||||
| 			option_state = 1; | 			option_state = 1; | ||||||
|  | 		if (strchr(options, 'j')) | ||||||
|  | 			priority_jump = 1; | ||||||
|  | 	} | ||||||
| 	peers = info; | 	peers = info; | ||||||
| 	if (peers) { | 	if (peers) { | ||||||
| 		cur = peers; | 		cur = peers; | ||||||
| @@ -137,11 +141,13 @@ static int chanavail_exec(struct ast_channel *chan, void *data) | |||||||
| 	if (res < 1) { | 	if (res < 1) { | ||||||
| 		pbx_builtin_setvar_helper(chan, "AVAILCHAN", ""); | 		pbx_builtin_setvar_helper(chan, "AVAILCHAN", ""); | ||||||
| 		pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", ""); | 		pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", ""); | ||||||
|  | 		if (priority_jump || option_priority_jumping) { | ||||||
| 			if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) { | 			if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) { | ||||||
| 				LOCAL_USER_REMOVE(u); | 				LOCAL_USER_REMOVE(u); | ||||||
| 				return -1; | 				return -1; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	LOCAL_USER_REMOVE(u); | 	LOCAL_USER_REMOVE(u); | ||||||
| 	return 0; | 	return 0; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user