38 #include <sys/ioctl.h>
48 static const char app[] =
"ChanIsAvail";
104 int inuse=-1, option_state=0, string_compare=0, option_all_avail=0;
106 char *info, tmp[512], trychan[512], *
peers, *tech, *
number, *rest, *cur;
127 if (strchr(
args.options,
'a')) {
128 option_all_avail = 1;
130 if (strchr(
args.options,
's')) {
133 if (strchr(
args.options,
't')) {
137 peers =
args.reqchans;
142 rest = strchr(cur,
'&');
148 number = strchr(tech,
'/');
158 if (string_compare) {
162 snprintf(trychan,
sizeof(trychan),
"%s/%s",cur,number);
164 }
else if (option_state) {
169 snprintf(trychan,
sizeof(trychan),
"%s/%s",cur,number);
172 snprintf(tmp,
sizeof(tmp),
"%d", status);
177 snprintf(tmp,
sizeof(tmp),
"%s/%s", tech, number);
180 snprintf(tmp,
sizeof(tmp),
"%d", status);
186 if (!option_all_avail) {
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Main Channel structure associated with a channel.
ast_device_state
Device States.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static int unload_module(void)
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
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.
#define ast_str_alloca(init_len)
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
static int load_module(void)
int ast_unregister_application(const char *app)
Unregister an application.
General Asterisk PBX channel definitions.
static struct ao2_container * peers
static int chanavail_exec(struct ast_channel *chan, const char *data)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Core PBX routines and definitions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
const ast_string_field name
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
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.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define AST_APP_ARG(name)
Define an application argument.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
struct ast_channel * ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *status)
Requests a channel.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.