Newer
Older
ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", chan->name);
if(chan->cdr) { /* update the cdr */
/* here we update the status of the call, which sould be busy.
* if that fails then we set the status to failed */
if(ast_cdr_disposition(chan->cdr, chan->hangupcause))
ast_cdr_failed(chan->cdr);
}
if(res < 0) { /* the call failed for some reason */
if(*reason == 0) { /* if the call failed (not busy or no answer)
* update the cdr with the failed message */
cdr_res = ast_pbx_outgoing_cdr_failed();
if(cdr_res != 0)
return cdr_res;
}
}
} else {
as = malloc(sizeof(struct async_stat));
if (!as)
return -1;
memset(as, 0, sizeof(struct async_stat));
chan = ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name);
if (!chan) {
free(as);
return -1;
}
if (account)
ast_cdr_setaccount(chan, account);
as->chan = chan;
strncpy(as->app, app, sizeof(as->app) - 1);
if (appdata)
strncpy(as->appdata, appdata, sizeof(as->appdata) - 1);
as->timeout = timeout;
vartmp = ast_strdupa(variable);
for (var = strtok_r(vartmp, "|", &vartmp); var; var = strtok_r(NULL, "|", &vartmp))
pbx_builtin_setvar( chan, var );
/* Start a new thread, and get something handling this channel. */
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (locked_channel)
ast_mutex_lock(&chan->lock);
if (ast_pthread_create(&as->p, &attr, async_wait, as)) {
ast_log(LOG_WARNING, "Failed to start async wait\n");
free(as);
if (locked_channel)
ast_mutex_unlock(&chan->lock);
} else {
if (locked_channel)
*locked_channel = chan;
}
res = 0;
}
return res;
}
static void destroy_exten(struct ast_exten *e)
{
if (e->priority == PRIORITY_HINT)
ast_remove_hint(e);
if (e->datad)
e->datad(e->data);
free(e);
}
void __ast_context_destroy(struct ast_context *con, const char *registrar)
struct ast_exten *e, *el, *en;
Mark Spencer
committed
ast_mutex_lock(&conlock);
if (((tmp->name && con && con->name && !strcasecmp(tmp->name, con->name)) || !con) &&
(!registrar || !strcasecmp(registrar, tmp->registrar))) {
/* Okay, let's lock the structure to be sure nobody else
is searching through it. */
if (ast_mutex_lock(&tmp->lock)) {
ast_log(LOG_WARNING, "Unable to lock context lock\n");
return;
}
if (tmpl)
tmpl->next = tmp->next;
else
contexts = tmp->next;
/* Okay, now we're safe to let it go -- in a sense, we were
ready to let it go as soon as we locked it. */
ast_mutex_unlock(&tmp->lock);
for (tmpi = tmp->includes; tmpi; ) {
/* Free includes */
tmpil = tmpi;
tmpi = tmpi->next;
free(tmpil);
ipl = ipi;
ipi = ipi->next;
free(ipl);
swl = sw;
sw = sw->next;
free(swl);
swl = sw;
}
for (e = tmp->root; e;) {
for (en = e->peer; en;) {
el = en;
en = en->peer;
destroy_exten(el);
}
el = e;
e = e->next;
destroy_exten(el);
}
Mark Spencer
committed
ast_mutex_destroy(&tmp->lock);
if (!con) {
/* Might need to get another one -- restart */
tmp = contexts;
tmpl = NULL;
tmpil = NULL;
continue;
}
Mark Spencer
committed
ast_mutex_unlock(&conlock);
return;
}
tmpl = tmp;
tmp = tmp->next;
}
Mark Spencer
committed
ast_mutex_unlock(&conlock);
void ast_context_destroy(struct ast_context *con, const char *registrar)
Mark Spencer
committed
__ast_context_destroy(con,registrar);
static void wait_for_hangup(struct ast_channel *chan, void *data)
int waittime;
if (!data || !strlen(data) || (sscanf(data, "%i", &waittime) != 1) || (waittime < 0))
waittime = -1;
if (waittime > -1) {
ast_safe_sleep(chan, waittime * 1000);
} else do {
res = ast_waitfor(chan, -1);
if (res < 0)
return;
f = ast_read(chan);
if (f)
ast_frfree(f);
} while(f);
}
static int pbx_builtin_progress(struct ast_channel *chan, void *data)
{
ast_indicate(chan, AST_CONTROL_PROGRESS);
return 0;
}
static int pbx_builtin_ringing(struct ast_channel *chan, void *data)
{
ast_indicate(chan, AST_CONTROL_RINGING);
return 0;
}
static int pbx_builtin_busy(struct ast_channel *chan, void *data)
{
ast_indicate(chan, AST_CONTROL_BUSY);
wait_for_hangup(chan, data);
return -1;
}
static int pbx_builtin_congestion(struct ast_channel *chan, void *data)
{
ast_indicate(chan, AST_CONTROL_CONGESTION);
wait_for_hangup(chan, data);
return -1;
}
static int pbx_builtin_answer(struct ast_channel *chan, void *data)
int delay = atoi(data);
int res;
if (chan->_state == AST_STATE_UP)
delay = 0;
res = ast_answer(chan);
if (res)
return res;
if (delay)
res = ast_safe_sleep(chan, delay);
return res;
static int pbx_builtin_setlanguage(struct ast_channel *chan, void *data)
James Golovich
committed
if (data)
strncpy(chan->language, (char *)data, sizeof(chan->language)-1);
static int pbx_builtin_resetcdr(struct ast_channel *chan, void *data)
{
/* Reset the CDR as specified */
if(data) {
if(strchr((char *)data, 'w'))
flags |= AST_CDR_FLAG_POSTED;
if(strchr((char *)data, 'a'))
flags |= AST_CDR_FLAG_LOCKED;
if(strchr((char *)data, 'v'))
flags |= AST_CDR_FLAG_KEEP_VARS;
Mark Spencer
committed
static int pbx_builtin_setaccount(struct ast_channel *chan, void *data)
{
/* Copy the account code as specified */
Mark Spencer
committed
if (data)
ast_cdr_setaccount(chan, (char *)data);
else
ast_cdr_setaccount(chan, "");
return 0;
}
static int pbx_builtin_setamaflags(struct ast_channel *chan, void *data)
{
/* Copy the AMA Flags as specified */
if (data)
ast_cdr_setamaflags(chan, (char *)data);
else
ast_cdr_setamaflags(chan, "");
return 0;
}
static int pbx_builtin_hangup(struct ast_channel *chan, void *data)
{
/* Just return non-zero and it will hang up */
return -1;
}
static int pbx_builtin_stripmsd(struct ast_channel *chan, void *data)
if (!data || !atoi(data)) {
ast_log(LOG_DEBUG, "Ignoring, since number of digits to strip is 0\n");
return 0;
}
if (strlen(chan->exten) > atoi(data)) {
strncpy(newexten, chan->exten + atoi(data), sizeof(newexten)-1);
strncpy(chan->exten, newexten, sizeof(chan->exten)-1);
static int pbx_builtin_prefix(struct ast_channel *chan, void *data)
if (!data || ast_strlen_zero(data)) {
ast_log(LOG_DEBUG, "Ignoring, since there is no prefix to add\n");
return 0;
}
snprintf(newexten, sizeof(newexten), "%s%s", (char *)data, chan->exten);
strncpy(chan->exten, newexten, sizeof(chan->exten)-1);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Prepended prefix, new extension is %s\n", chan->exten);
static int pbx_builtin_suffix(struct ast_channel *chan, void *data)
{
char newexten[AST_MAX_EXTENSION] = "";
if (!data || ast_strlen_zero(data)) {
ast_log(LOG_DEBUG, "Ignoring, since there is no suffix to add\n");
return 0;
}
snprintf(newexten, sizeof(newexten), "%s%s", chan->exten, (char *)data);
strncpy(chan->exten, newexten, sizeof(chan->exten)-1);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Appended suffix, new extension is %s\n", chan->exten);
return 0;
}
static int pbx_builtin_gotoiftime(struct ast_channel *chan, void *data)
{
int res=0;
char *s, *ts;
if (!data || ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "GotoIfTime requires an argument:\n <time range>|<days of week>|<days of month>|<months>?[[context|]extension|]priority\n");
return -1;
}
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
if ((s = ast_strdupa((char *) data))) {
ts = s;
/* Separate the Goto path */
strsep(&ts,"?");
/* struct ast_include include contained garbage here, fixed by zeroing it on get_timerange */
if (ast_build_timing(&timing, s) && ast_check_timing(&timing))
res = pbx_builtin_goto(chan, (void *)ts);
} else {
ast_log(LOG_ERROR, "Memory Error!\n");
}
return res;
}
static int pbx_builtin_execiftime(struct ast_channel *chan, void *data)
{
int res = 0;
char *ptr1, *ptr2;
struct ast_timing timing;
const char *usage = "ExecIfTime requires an argument:\n <time range>|<days of week>|<days of month>|<months>?<appname>[|<ptr1>]";
if (!data || ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "%s\n", usage);
return -1;
}
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
if ((ptr1 = ast_strdupa((char *) data))) {
ptr2 = ptr1;
/* Separate the Application data ptr1 is the time spec ptr2 is the app|data*/
strsep(&ptr2,"?");
if (ast_build_timing(&timing, ptr1) && ast_check_timing(&timing)) {
if (ptr2) {
/* ptr2 is now the app name
we're done with ptr1 now so recycle it and use it to point to the app args*/
struct ast_app *app;
if((ptr1 = strchr(ptr2, '|'))) {
*ptr1 = '\0';
ptr1++;
}
if ((app = pbx_findapp(ptr2))) {
pbx_exec(chan, app, ptr1 ? ptr1 : "", 1);
} else {
ast_log(LOG_WARNING, "Cannot locate application %s\n", ptr2);
}
} else {
ast_log(LOG_WARNING, "%s\n", usage);
}
} else {
ast_log(LOG_WARNING, "Invalid Time Spec: %s\n%s\n", ptr1, usage);
}
} else {
ast_log(LOG_ERROR, "Memory Error!\n");
}
static int pbx_builtin_wait(struct ast_channel *chan, void *data)
if (data && atof((char *)data)) {
ms = atof((char *)data) * 1000;
static int pbx_builtin_waitexten(struct ast_channel *chan, void *data)
{
int ms;
else if (chan->pbx)
ms = chan->pbx->rtimeout * 1000;
else
ms = 10000;
res = ast_waitfordigit(chan, ms);
if (!res) {
Mark Spencer
committed
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 1, chan->cid.cid_num)) {
Mark Spencer
committed
ast_verbose(VERBOSE_PREFIX_3 "Timeout on %s, continuing...\n", chan->name);
} else if (ast_exists_extension(chan, chan->context, "t", 1, chan->cid.cid_num)) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Timeout on %s, going to 't'\n", chan->name);
strncpy(chan->exten, "t", sizeof(chan->exten));
chan->priority = 0;
} else {
ast_log(LOG_WARNING, "Timeout but no rule 't' in context '%s'\n", chan->context);
res = -1;
}
static int pbx_builtin_background(struct ast_channel *chan, void *data)
int res = 0;
int option_skip = 0;
int option_noanswer = 0;
char* stringp;
char* options;
char *lang = NULL;
char *front = NULL, *back = NULL;
if (!data || ast_strlen_zero(data) || !(filename = ast_strdupa(data))) {
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
ast_log(LOG_WARNING, "Background requires an argument(filename)\n");
return -1;
}
stringp = filename;
strsep(&stringp, "|");
options = strsep(&stringp, "|");
if (options)
lang = strsep(&stringp, "|");
if (!lang)
lang = chan->language;
if (options && !strcasecmp(options, "skip"))
option_skip = 1;
if (options && !strcasecmp(options, "noanswer"))
option_noanswer = 1;
/* Answer if need be */
if (chan->_state != AST_STATE_UP) {
if (option_skip) {
return 0;
} else if (!option_noanswer) {
res = ast_answer(chan);
}
}
if (!res) {
/* Stop anything playing */
ast_stopstream(chan);
/* Stream a file */
front = filename;
while(!res && front) {
if((back = strchr(front, '&'))) {
*back = '\0';
back++;
}
res = ast_streamfile(chan, front, lang);
if (!res) {
res = ast_waitstream(chan, AST_DIGIT_ANY);
ast_stopstream(chan);
} else {
ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char*)data);
res = 0;
break;
}
front = back;
static int pbx_builtin_atimeout(struct ast_channel *chan, void *data)
{
int x = atoi((char *) data);
/* Set the absolute maximum time how long a call can be connected */
ast_channel_setwhentohangup(chan,x);
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "Set Absolute Timeout to %d\n", x);
return 0;
}
static int pbx_builtin_rtimeout(struct ast_channel *chan, void *data)
{
/* Set the timeout for how long to wait between digits */
chan->pbx->rtimeout = atoi((char *)data);
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "Set Response Timeout to %d\n", chan->pbx->rtimeout);
return 0;
}
static int pbx_builtin_dtimeout(struct ast_channel *chan, void *data)
{
/* Set the timeout for how long to wait between digits */
chan->pbx->dtimeout = atoi((char *)data);
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "Set Digit Timeout to %d\n", chan->pbx->dtimeout);
return 0;
}
static int pbx_builtin_goto(struct ast_channel *chan, void *data)
int res;
res = ast_parseable_goto(chan, (const char *) data);
if (!res && (option_verbose > 2))
ast_verbose( VERBOSE_PREFIX_3 "Goto (%s,%s,%d)\n", chan->context,chan->exten, chan->priority+1);
int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t size)
{
struct ast_var_t *variables;
struct varshead *headp;
char *var=NULL ,*val=NULL;
int total = 0;
memset(buf,0,size);
if (chan) {
headp=&chan->varshead;
AST_LIST_TRAVERSE(headp,variables,entries) {
if(chan && variables && (var=ast_var_name(variables)) && (val=ast_var_value(variables)) && !ast_strlen_zero(var) && !ast_strlen_zero(val)) {
snprintf(buf + strlen(buf), size - strlen(buf), "%s=%s\n", var, val);
if(strlen(buf) >= size) {
ast_log(LOG_ERROR,"Data Buffer Size Exceeded!\n");
break;
}
total++;
}
}
return total;
}
char *pbx_builtin_getvar_helper(struct ast_channel *chan, char *name)
{
struct ast_var_t *variables;
struct varshead *headp;
if (chan)
headp=&chan->varshead;
AST_LIST_TRAVERSE(headp,variables,entries) {
if (!strcmp(name, ast_var_name(variables)))
return ast_var_value(variables);
}
if (headp != &globals) {
/* Check global variables if we haven't already */
headp = &globals;
AST_LIST_TRAVERSE(headp,variables,entries) {
if (!strcmp(name, ast_var_name(variables)))
return ast_var_value(variables);
}
}
}
void pbx_builtin_setvar_helper(struct ast_channel *chan, char *name, char *value)
struct varshead *headp;
headp = &chan->varshead;
if (!strncasecmp(name, "CDR(", 4)) { /* CDR VARS */
char *vtmp, *nt;
int recur = 0;
if ((vtmp = ast_strdupa((char *) name + 4)) && (nt = strchr(vtmp, ')'))) {
*nt = '\0';
if(vtmp[0] == '-') {
vtmp++;
recur = 1;
}
ast_cdr_setvar(chan->cdr, vtmp, value, recur);
} else {
ast_log(LOG_WARNING, "Invalid CDR variable.\n");
}
return;
}
}
headp = &globals;
AST_LIST_TRAVERSE (headp, newvariable, entries) {
if (strcasecmp(ast_var_name(newvariable), name) == 0) {
/* there is already such a variable, delete it */
AST_LIST_REMOVE(headp, newvariable, entries);
ast_var_delete(newvariable);
break;
}
}
if (value) {
if ((option_verbose > 1) && (headp == &globals))
ast_verbose(VERBOSE_PREFIX_3 "Setting global variable '%s' to '%s'\n", name, value);
newvariable = ast_var_assign(name, value);
AST_LIST_INSERT_HEAD(headp, newvariable, entries);
Martin Pycko
committed
int pbx_builtin_setvar(struct ast_channel *chan, void *data)
char *name, *value, *mydata, *next, *fstr = NULL;
struct ast_flags flags = {0};
if (data && !ast_strlen_zero(data) && (mydata = ast_strdupa(data))) {
next = mydata;
while(next) {
name = next;
if ((next = strchr(next, '|'))) {
*next = '\0';
next++;
}
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
if ((value = strchr(name, '='))) {
*value = '\0';
value++;
if( fstr && strchr(fstr, 'g') ) {
pbx_builtin_setvar_helper(NULL, name, value);
}
else {
pbx_builtin_setvar_helper(chan, name, value);
if (ast_test_flag(&flags, AST_CDR_FLAG_SETVAR)) {
ast_cdr_setvar(chan->cdr, name, value, ast_test_flag(&flags, AST_CDR_FLAG_RECUR));
}
}
} else if (!next) {
name++;
if (strchr(name, 'c') ) {
ast_set_flag(&flags, AST_CDR_FLAG_SETVAR);
} else if (strchr(name, 'r') ) {
ast_set_flag(&flags, AST_CDR_FLAG_RECUR | AST_CDR_FLAG_SETVAR);
}
} else
ast_log(LOG_WARNING, "Ignoring entry '%s' with no = (and not last 'options' entry)\n", name);
}
} else {
ast_log(LOG_WARNING, "Ignoring, since there is no variable to set\n");
}
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
int pbx_builtin_importvar(struct ast_channel *chan, void *data)
{
char *name;
char *value;
char *stringp=NULL;
char *channel;
struct ast_channel *chan2=NULL;
char tmp[4096]="";
char *s;
if (!data || ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Ignoring, since there is no variable to set\n");
return 0;
}
stringp = ast_strdupa(data);
name = strsep(&stringp,"=");
channel = strsep(&stringp,"|");
value = strsep(&stringp,"\0");
if (channel && value && name) {
while((chan2 = ast_channel_walk_locked(chan2))) {
if (!strcmp(chan2->name, channel))
break;
ast_mutex_unlock(&chan2->lock);
}
if (chan2) {
s = alloca(strlen(value) + 4);
if (s) {
sprintf(s, "${%s}", value);
pbx_substitute_variables_helper(chan2, s, tmp, sizeof(tmp) - 1);
}
ast_mutex_unlock(&chan2->lock);
}
pbx_builtin_setvar_helper(chan, name, tmp);
}
return(0);
}
static int pbx_builtin_setglobalvar(struct ast_channel *chan, void *data)
{
char *name;
char *value;
char *stringp = NULL;
if (!data || ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Ignoring, since there is no variable to set\n");
return 0;
}
stringp = data;
name = strsep(&stringp, "=");
value = strsep(&stringp, "\0");
pbx_builtin_setvar_helper(NULL, name, value);
return(0);
}
static int pbx_builtin_noop(struct ast_channel *chan, void *data)
{
return 0;
}
void pbx_builtin_clear_globals(void)
{
struct ast_var_t *vardata;
while (!AST_LIST_EMPTY(&globals)) {
vardata = AST_LIST_REMOVE_HEAD(&globals, entries);
ast_var_delete(vardata);
}
}
static int pbx_checkcondition(char *condition)
{
return condition ? atoi(condition) : 0;
}
static int pbx_builtin_gotoif(struct ast_channel *chan, void *data)
{
char *condition,*branch1,*branch2,*branch;
char *s;
int rc;
if (!data || ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Ignoring, since there is no variable to check\n");
stringp=s;
condition=strsep(&stringp,"?");
branch1=strsep(&stringp,":");
branch2=strsep(&stringp,"");
branch = pbx_checkcondition(condition) ? branch1 : branch2;
if ((branch==NULL) || ast_strlen_zero(branch)) {
ast_log(LOG_DEBUG, "Not taking any branch\n");
return(0);
}
rc=pbx_builtin_goto(chan,branch);
static int pbx_builtin_saynumber(struct ast_channel *chan, void *data)
{
int res = 0;
Mark Spencer
committed
char tmp[256];
char *number = (char *) NULL;
char *options = (char *) NULL;
if (!data || ast_strlen_zero((char *)data)) {
Mark Spencer
committed
ast_log(LOG_WARNING, "SayNumber requires an argument (number)\n");
return -1;
}
strncpy(tmp, (char *)data, sizeof(tmp)-1);
number=tmp;
strsep(&number, "|");
options = strsep(&number, "|");
if (options) {
if ( strcasecmp(options, "f") && strcasecmp(options,"m") &&
strcasecmp(options, "c") && strcasecmp(options, "n") ) {
ast_log(LOG_WARNING, "SayNumber gender option is either 'f', 'm', 'c' or 'n'\n");
return -1;
}
}
return res = ast_say_number(chan, atoi((char *) tmp), "", chan->language, options);
}
static int pbx_builtin_saydigits(struct ast_channel *chan, void *data)
{
int res = 0;
if (data)
res = ast_say_digit_str(chan, (char *)data, "", chan->language);
static int pbx_builtin_saycharacters(struct ast_channel *chan, void *data)
{
int res = 0;
if (data)
res = ast_say_character_str(chan, (char *)data, "", chan->language);
return res;
}
static int pbx_builtin_sayphonetic(struct ast_channel *chan, void *data)
{
int res = 0;
if (data)
res = ast_say_phonetic_str(chan, (char *)data, "", chan->language);
return res;
}
/* Initialize the PBX */
if (option_verbose) {
ast_verbose( "Asterisk PBX Core Initializing\n");
ast_verbose( "Registering builtin applications:\n");
}
ast_cli_register(&show_functions_cli);
ast_cli_register(&show_application_cli);
ast_cli_register(&show_dialplan_cli);
ast_cli_register(&show_switches_cli);
ast_custom_function_register(®ex_function);
ast_custom_function_register(&isnull_function);
ast_custom_function_register(&exists_function);
ast_custom_function_register(&if_function);
/* Register builtin applications */
for (x=0; x<sizeof(builtins) / sizeof(struct pbx_builtin); x++) {
if (option_verbose)
ast_verbose( VERBOSE_PREFIX_1 "[%s]\n", builtins[x].name);
if (ast_register_application(builtins[x].name, builtins[x].execute, builtins[x].synopsis, builtins[x].description)) {
ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name);
return -1;
}
}
return 0;
}
/*
* Lock context list functions ...
*/
int ast_lock_contexts()
{
return ast_mutex_lock(&conlock);
return ast_mutex_unlock(&conlock);
}
/*
* Lock context ...
*/
int ast_lock_context(struct ast_context *con)
{
return ast_mutex_lock(&con->lock);
}
int ast_unlock_context(struct ast_context *con)
{
return ast_mutex_unlock(&con->lock);
const char *ast_get_context_name(struct ast_context *con)
{
return con ? con->name : NULL;
}
const char *ast_get_extension_name(struct ast_exten *exten)
{
return exten ? exten->exten : NULL;
}
const char *ast_get_extension_label(struct ast_exten *exten)
{
return exten ? exten->label : NULL;
}
const char *ast_get_include_name(struct ast_include *inc)
{
return inc ? inc->name : NULL;
}
const char *ast_get_ignorepat_name(struct ast_ignorepat *ip)
{
return ip ? ip->pattern : NULL;
}
int ast_get_extension_priority(struct ast_exten *exten)
{
return exten ? exten->priority : -1;
}
/*
* Registrar info functions ...
*/
const char *ast_get_context_registrar(struct ast_context *c)
{
return c ? c->registrar : NULL;
}
const char *ast_get_extension_registrar(struct ast_exten *e)
{
return e ? e->registrar : NULL;
}
const char *ast_get_include_registrar(struct ast_include *i)
{
return i ? i->registrar : NULL;
}
const char *ast_get_ignorepat_registrar(struct ast_ignorepat *ip)
{
return ip ? ip->registrar : NULL;
}
int ast_get_extension_matchcid(struct ast_exten *e)
{
return e ? e->matchcid : 0;
}
const char *ast_get_extension_cidmatch(struct ast_exten *e)
{
return e ? e->cidmatch : NULL;
}
const char *ast_get_extension_app(struct ast_exten *e)
{
return e ? e->app : NULL;
}
void *ast_get_extension_app_data(struct ast_exten *e)
{
return e ? e->data : NULL;
}
const char *ast_get_switch_name(struct ast_sw *sw)
const char *ast_get_switch_data(struct ast_sw *sw)
const char *ast_get_switch_registrar(struct ast_sw *sw)
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
{
return sw ? sw->registrar : NULL;
}
/*
* Walking functions ...
*/
struct ast_context *ast_walk_contexts(struct ast_context *con)
{
if (!con)
return contexts;
else
return con->next;
}
struct ast_exten *ast_walk_context_extensions(struct ast_context *con,
struct ast_exten *exten)
{
if (!exten)
return con ? con->root : NULL;
else
return exten->next;
}
struct ast_sw *ast_walk_context_switches(struct ast_context *con,
struct ast_sw *sw)
{
if (!sw)
return con ? con->alts : NULL;
else
return sw->next;
}
struct ast_exten *ast_walk_extension_priorities(struct ast_exten *exten,
struct ast_exten *priority)