36 #include <sys/ioctl.h>
46 static const char app[] =
"ChanIsAvail";
102 static int chanavail_exec(
struct ast_channel *chan,
const char *data)
105 int option_state = 0;
106 int string_compare = 0;
107 int option_all_avail = 0;
114 struct ast_str *tmp_availchan = ast_str_alloca(2048);
115 struct ast_str *tmp_availorig = ast_str_alloca(2048);
116 struct ast_str *tmp_availstat = ast_str_alloca(2048);
117 struct ast_str *tmp_availcause = ast_str_alloca(2048);
131 caps =
ao2_bump(ast_channel_nativeformats(chan));
135 if (strchr(args.options,
'a')) {
136 option_all_avail = 1;
138 if (strchr(args.options,
's')) {
141 if (strchr(args.options,
't')) {
146 rest = args.reqchans;
150 while ((tech = strsep(&rest,
"&"))) {
153 number = strchr(tech,
'/');
155 if (!ast_strlen_zero(tech)) {
156 ast_log(LOG_WARNING,
"Invalid ChanIsAvail technology/resource argument: '%s'\n",
168 if (string_compare) {
172 snprintf(trychan,
sizeof(trychan),
"%s/%s", tech, number);
174 }
else if (option_state) {
179 snprintf(trychan,
sizeof(trychan),
"%s/%s", tech, number);
185 && (tempchan =
ast_request(tech, caps, NULL, chan, number, &status))) {
188 ast_str_strlen(tmp_availchan) ?
"&" :
"", ast_channel_name(tempchan));
204 if (!option_all_avail) {
222 static int unload_module(
void)
227 static int load_module(
void)
233 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,
"Check channel availability",
234 .support_level = AST_MODULE_SUPPORT_EXTENDED,
236 .unload = unload_module,
237 .optional_modules =
"func_cdr"
Main Channel structure associated with a channel.
ast_device_state
Device States.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
enum ast_device_state ast_parse_device_state(const char *device)
Search the Channels by Name.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
int ast_unregister_application(const char *app)
Unregister an application.
struct ast_channel * ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
Requests a channel.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
General Asterisk PBX channel definitions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
Data structure associated with a custom dialplan function.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Core PBX routines and definitions.
Support for dynamic strings.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Module has failed to load, may be in an inconsistent state.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
int ast_func_write(struct ast_channel *chan, const char *function, const char *value)
executes a write operation on a function
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define AST_APP_ARG(name)
Define an application argument.