Newer
Older
{
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)
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
{
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)
{
if (!priority)
return exten;
else
return priority->peer;
}
struct ast_include *ast_walk_context_includes(struct ast_context *con,
struct ast_include *inc)
{
if (!inc)
return con ? con->includes : NULL;
else
return inc->next;
}
struct ast_ignorepat *ast_walk_context_ignorepats(struct ast_context *con,
struct ast_ignorepat *ip)
{
if (!ip)
return con ? con->ignorepats : NULL;
else
return ip->next;
}
int ast_context_verify_includes(struct ast_context *con)
{
struct ast_include *inc;
int res = 0;
for (inc = ast_walk_context_includes(con, NULL); inc; inc = ast_walk_context_includes(con, inc))
if (!ast_context_find(inc->rname)) {
res = -1;
ast_log(LOG_WARNING, "Context '%s' tries includes non-existant context '%s'\n",
ast_get_context_name(con), inc->rname);
}
return res;
}
static int __ast_goto_if_exists(struct ast_channel *chan, char* context, char *exten, int priority, int async)
int (*goto_func)(struct ast_channel *chan, const char *context, const char *exten, int priority) = NULL;
if (async) {
goto_func = ast_async_goto;
} else {
goto_func = ast_explicit_goto;
priority--;
if(priority < 0)
priority = 0;
}
if (ast_exists_extension(chan,
context ? context : chan->context,
exten ? exten : chan->exten,
priority,
chan->cid.cid_num)) {
return goto_func(chan,
context ? context : chan->context,
exten ? exten : chan->exten,
priority);
} else
return -3;
}
return -2;
}
int ast_goto_if_exists(struct ast_channel *chan, char* context, char *exten, int priority) {
return __ast_goto_if_exists(chan, context, exten, priority, 0);
}
int ast_async_goto_if_exists(struct ast_channel *chan, char* context, char *exten, int priority) {
return __ast_goto_if_exists(chan, context, exten, priority, 1);
}
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
int ast_parseable_goto(struct ast_channel *chan, const char *goto_string)
{
char *s;
char *exten, *pri, *context;
char *stringp=NULL;
int ipri;
int mode = 0;
if (!goto_string || ast_strlen_zero(goto_string)) {
ast_log(LOG_WARNING, "Goto requires an argument (optional context|optional extension|priority)\n");
return -1;
}
s = ast_strdupa(goto_string);
stringp=s;
context = strsep(&stringp, "|");
exten = strsep(&stringp, "|");
if (!exten) {
/* Only a priority in this one */
pri = context;
exten = NULL;
context = NULL;
} else {
pri = strsep(&stringp, "|");
if (!pri) {
/* Only an extension and priority in this one */
pri = exten;
exten = context;
context = NULL;
}
}
if (*pri == '+') {
mode = 1;
pri++;
} else if (*pri == '-') {
mode = -1;
pri++;
}
if (sscanf(pri, "%i", &ipri) != 1) {
if ((ipri = ast_findlabel_extension(chan, context ? context : chan->context, (exten && strcasecmp(exten, "BYEXTENSION")) ? exten : chan->exten,
pri, chan->cid.cid_num)) < 1) {
ast_log(LOG_WARNING, "Priority '%s' must be a number > 0, or valid label\n", pri);
return -1;
} else
mode = 0;
}
/* At this point we have a priority and maybe an extension and a context */
if (exten && !strcasecmp(exten, "BYEXTENSION"))
exten = NULL;
if (mode)
ipri = chan->priority + (ipri * mode);
/* This channel is currently in the PBX */
ast_explicit_goto(chan, context, exten, ipri - 1);
ast_cdr_update(chan);
return 0;
}