return -1;
}
- strcpy(chan->exten, "sms");
+ ast_channel_exten_set(chan, "sms");
pbx_builtin_setvar_helper(chan, "SMSSRC", from_number);
pbx_builtin_setvar_helper(chan, "SMSTXT", text);
ast_channel_set_fd(chan, 0, pvt->sco_socket);
- ast_copy_string(chan->exten, "s", AST_MAX_EXTENSION);
+ ast_channel_exten_set(chan, "s");
if (ast_pbx_start(chan)) {
ast_log(LOG_ERROR, "[%s] unable to start pbx on incoming call\n", pvt->id);
ast_hangup(chan);
/* Notify the module monitors that use count for resource has changed*/
ast_update_use_count();
- ast_copy_string(ch->context, i->context, sizeof(ch->context));
- ast_copy_string(ch->exten, i->exten, sizeof(ch->exten));
+ ast_channel_context_set(ch, i->context);
+ ast_channel_exten_set(ch, i->exten);
ch->priority = 1;
p->faxdetected = 1;
ooRequestChangeMode(p->callToken, 1);
} else if ((dfr->subclass.integer == 'f') && !p->faxdetected) {
- const char *target_context = S_OR(p->owner->macrocontext, p->owner->context);
- if ((strcmp(p->owner->exten, "fax")) &&
+ const char *target_context = S_OR(ast_channel_macrocontext(p->owner), ast_channel_context(p->owner));
+ if ((strcmp(ast_channel_exten(p->owner), "fax")) &&
(ast_exists_extension(p->owner, target_context, "fax", 1,
S_COR(p->owner->caller.id.number.valid, p->owner->caller.id.number.str, NULL)))) {
ast_verb(2, "Redirecting '%s' to fax extension due to CNG detection\n", ast_channel_name(p->owner));
- pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", p->owner->exten);
+ pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", ast_channel_exten(p->owner));
if (ast_async_goto(p->owner, target_context, "fax", 1)) {
ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(p->owner),target_context);
}
if ((p->faxdetect & FAXDETECT_T38) && !p->faxdetected) {
const char *target_context;
ast_debug(1, "* Detected T.38 Request\n");
- target_context = S_OR(p->owner->macrocontext, p->owner->context);
- if ((strcmp(p->owner->exten, "fax")) &&
+ target_context = S_OR(ast_channel_macrocontext(p->owner), ast_channel_context(p->owner));
+ if ((strcmp(ast_channel_exten(p->owner), "fax")) &&
(ast_exists_extension(p->owner, target_context, "fax", 1,
S_COR(p->owner->caller.id.number.valid, p->owner->caller.id.number.str, NULL)))) {
ast_verb(2, "Redirecting '%s' to fax extension due to CNG detection\n", ast_channel_name(p->owner));
- pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", p->owner->exten);
+ pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", ast_channel_exten(p->owner));
if (ast_async_goto(p->owner, target_context, "fax", 1)) {
ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(p->owner),target_context);
}
ast_channel_lock(chan);
if ((c = pbx_builtin_getvar_helper(chan, "SPY_EXIT_CONTEXT"))) {
ast_copy_string(exitcontext, c, sizeof(exitcontext));
- } else if (!ast_strlen_zero(chan->macrocontext)) {
- ast_copy_string(exitcontext, chan->macrocontext, sizeof(exitcontext));
+ } else if (!ast_strlen_zero(ast_channel_macrocontext(chan))) {
+ ast_copy_string(exitcontext, ast_channel_macrocontext(chan), sizeof(exitcontext));
} else {
- ast_copy_string(exitcontext, chan->context, sizeof(exitcontext));
+ ast_copy_string(exitcontext, ast_channel_context(chan), sizeof(exitcontext));
}
ast_channel_unlock(chan);
}
args.context = ptr;
}
if (ast_strlen_zero(args.context))
- args.context = ast_strdupa(chan->context);
+ args.context = ast_strdupa(ast_channel_context(chan));
if (args.options) {
char *opts[OPT_ARG_ARRAY_SIZE];
ast_channel_lock(bridge_channel->chan);
/*save off*/
- exten = ast_strdupa(bridge_channel->chan->exten);
- context = ast_strdupa(bridge_channel->chan->context);
+ exten = ast_strdupa(ast_channel_exten(bridge_channel->chan));
+ context = ast_strdupa(ast_channel_context(bridge_channel->chan));
priority = bridge_channel->chan->priority;
pbx = bridge_channel->chan->pbx;
bridge_channel->chan->pbx = NULL;
/*set new*/
- ast_copy_string(bridge_channel->chan->exten, menu_action->data.dialplan_args.exten, sizeof(bridge_channel->chan->exten));
- ast_copy_string(bridge_channel->chan->context, menu_action->data.dialplan_args.context, sizeof(bridge_channel->chan->context));
+ ast_channel_exten_set(bridge_channel->chan, menu_action->data.dialplan_args.exten);
+ ast_channel_context_set(bridge_channel->chan, menu_action->data.dialplan_args.context);
bridge_channel->chan->priority = menu_action->data.dialplan_args.priority;
ast_channel_unlock(bridge_channel->chan);
/*restore*/
ast_channel_lock(bridge_channel->chan);
- ast_copy_string(bridge_channel->chan->exten, exten, sizeof(bridge_channel->chan->exten));
- ast_copy_string(bridge_channel->chan->context, context, sizeof(bridge_channel->chan->context));
+ ast_channel_exten_set(bridge_channel->chan, exten);
+ ast_channel_context_set(bridge_channel->chan, context);
bridge_channel->chan->priority = priority;
bridge_channel->chan->pbx = pbx;
if (!ast_goto_if_exists(chan, context, rexten, pri))
return 1;
} else {
- if (!ast_goto_if_exists(chan, chan->context, rexten, pri))
+ if (!ast_goto_if_exists(chan, ast_channel_context(chan), rexten, pri))
return 1;
- else if (!ast_strlen_zero(chan->macrocontext)) {
- if (!ast_goto_if_exists(chan, chan->macrocontext, rexten, pri))
+ else if (!ast_strlen_zero(ast_channel_macrocontext(chan))) {
+ if (!ast_goto_if_exists(chan, ast_channel_macrocontext(chan), rexten, pri))
return 1;
}
}
const char *exten;
ast_channel_lock(chan);
- context = ast_strdupa(S_OR(chan->macrocontext, chan->context));
- exten = ast_strdupa(S_OR(chan->macroexten, chan->exten));
+ context = ast_strdupa(S_OR(ast_channel_macrocontext(chan), ast_channel_context(chan)));
+ exten = ast_strdupa(S_OR(ast_channel_macroexten(chan), ast_channel_exten(chan)));
ast_channel_unlock(chan);
return ast_get_hint(NULL, 0, name, namelen, chan, context, exten) ? name : "";
if (ast_strlen_zero(forward_context)) {
forward_context = NULL;
}
- snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(c), forward_context ? forward_context : c->context);
+ snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(c), forward_context ? forward_context : ast_channel_context(c));
ast_channel_unlock(c);
stuff = tmpchan;
tech = "Local";
ast_party_number_init(&c->redirecting.from.number);
c->redirecting.from.number.valid = 1;
c->redirecting.from.number.str =
- ast_strdup(S_OR(in->macroexten, in->exten));
+ ast_strdup(S_OR(ast_channel_macroexten(in), ast_channel_exten(in)));
}
c->dialed.transit_network_select = in->dialed.transit_network_select;
ast_channel_accountcode_set(c, ast_channel_accountcode(in));
- c->appl = "AppDial";
- c->data = "(Outgoing Line)";
+ ast_channel_appl_set(c, "AppDial");
+ ast_channel_data_set(c, "(Outgoing Line)");
/*
* We must unlock c before calling ast_channel_redirecting_macro, because
* we put c into autoservice there. That is pretty much a guaranteed
OPT_CALLEE_MIXMONITOR | OPT_CALLER_MIXMONITOR |
DIAL_NOFORWARDHTML);
ast_channel_dialcontext_set(c, "");
- ast_copy_string(c->exten, "", sizeof(c->exten));
+ ast_channel_exten_set(c, "");
}
continue;
}
OPT_CALLEE_MIXMONITOR | OPT_CALLER_MIXMONITOR |
DIAL_NOFORWARDHTML);
ast_channel_dialcontext_set(c, "");
- ast_copy_string(c->exten, "", sizeof(c->exten));
+ ast_channel_exten_set(c, "");
if (CAN_EARLY_BRIDGE(peerflags, in, peer))
/* Setup early bridge if appropriate */
ast_channel_early_bridge(in, peer);
}
ast_verb(3, "Privacy-- callerid is empty\n");
- snprintf(callerid, sizeof(callerid), "NOCALLERID_%s%s", chan->exten, tnam);
+ snprintf(callerid, sizeof(callerid), "NOCALLERID_%s%s", ast_channel_exten(chan), tnam);
l = callerid;
pa->privdb_val = AST_PRIVACY_UNKNOWN;
}
if (ast_test_flag64(&opts, OPT_FORCECLID)) {
if (ast_strlen_zero(opt_args[OPT_ARG_FORCECLID])) {
ast_channel_lock(chan);
- forced_clid.number.str = ast_strdupa(S_OR(chan->macroexten, chan->exten));
+ forced_clid.number.str = ast_strdupa(S_OR(ast_channel_macroexten(chan), ast_channel_exten(chan)));
ast_channel_unlock(chan);
forced_clid_name[0] = '\0';
forced_clid.name.str = (char *) get_cid_name(forced_clid_name,
stored_clid.name.valid = 1;
}
ast_channel_lock(chan);
- stored_clid.number.str = ast_strdupa(S_OR(chan->macroexten, chan->exten));
+ stored_clid.number.str = ast_strdupa(S_OR(ast_channel_macroexten(chan), ast_channel_exten(chan)));
stored_clid.number.valid = 1;
ast_channel_unlock(chan);
}
if (ast_test_flag64(&opts, OPT_RESETCDR) && chan->cdr)
ast_cdr_reset(chan->cdr, NULL);
if (ast_test_flag64(&opts, OPT_PRIVACY) && ast_strlen_zero(opt_args[OPT_ARG_PRIVACY]))
- opt_args[OPT_ARG_PRIVACY] = ast_strdupa(chan->exten);
+ opt_args[OPT_ARG_PRIVACY] = ast_strdupa(ast_channel_exten(chan));
if (ast_test_flag64(&opts, OPT_PRIVACY) || ast_test_flag64(&opts, OPT_SCREENING)) {
res = setup_privacy_args(&pa, &opts, opt_args, chan);
ast_channel_inherit_variables(chan, tc);
ast_channel_datastore_inherit(chan, tc);
- tc->appl = "AppDial";
- tc->data = "(Outgoing Line)";
+ ast_channel_appl_set(tc, "AppDial");
+ ast_channel_data_set(tc, "(Outgoing Line)");
memset(&tc->whentohangup, 0, sizeof(tc->whentohangup));
/* Determine CallerID to store in outgoing channel. */
/* Inherit context and extension */
- ast_channel_dialcontext_set(tc, ast_strlen_zero(chan->macrocontext) ? chan->context : chan->macrocontext);
- if (!ast_strlen_zero(chan->macroexten))
- ast_copy_string(tc->exten, chan->macroexten, sizeof(tc->exten));
+ ast_channel_dialcontext_set(tc, ast_strlen_zero(ast_channel_macrocontext(chan)) ? ast_channel_context(chan) : ast_channel_macrocontext(chan));
+ if (!ast_strlen_zero(ast_channel_macroexten(chan)))
+ ast_channel_exten_set(tc, ast_channel_macroexten(chan));
else
- ast_copy_string(tc->exten, chan->exten, sizeof(tc->exten));
+ ast_channel_exten_set(tc, ast_channel_exten(chan));
ast_channel_unlock(tc);
ast_channel_unlock(chan);
replace_macro_delimiter(opt_args[OPT_ARG_GOTO]);
ast_parseable_goto(chan, opt_args[OPT_ARG_GOTO]);
/* peer goes to the same context and extension as chan, so just copy info from chan*/
- ast_copy_string(peer->context, chan->context, sizeof(peer->context));
- ast_copy_string(peer->exten, chan->exten, sizeof(peer->exten));
+ ast_channel_context_set(peer, ast_channel_context(chan));
+ ast_channel_exten_set(peer, ast_channel_exten(chan));
peer->priority = chan->priority + 2;
ast_pbx_start(peer);
hanguptree(outgoing, NULL, ast_test_flag64(&opts, OPT_CANCEL_ELSEWHERE) ? 1 : 0);
if (theapp && !res) { /* XXX why check res here ? */
/* Set peer->exten and peer->context so that MACRO_EXTEN and MACRO_CONTEXT get set */
- ast_copy_string(peer->context, chan->context, sizeof(peer->context));
- ast_copy_string(peer->exten, chan->exten, sizeof(peer->exten));
+ ast_channel_context_set(peer, ast_channel_context(chan));
+ ast_channel_exten_set(peer, ast_channel_exten(chan));
replace_macro_delimiter(opt_args[OPT_ARG_CALLEE_MACRO]);
res = pbx_exec(peer, theapp, opt_args[OPT_ARG_CALLEE_MACRO]);
replace_macro_delimiter(opt_args[OPT_ARG_CALLEE_GOSUB]);
/* Set where we came from */
- ast_copy_string(peer->context, "app_dial_gosub_virtual_context", sizeof(peer->context));
- ast_copy_string(peer->exten, "s", sizeof(peer->exten));
+ ast_channel_context_set(peer, "app_dial_gosub_virtual_context");
+ ast_channel_exten_set(peer, "s");
peer->priority = 0;
gosub_argstart = strchr(opt_args[OPT_ARG_CALLEE_GOSUB], ',');
res = ast_bridge_call(chan, peer, &config);
}
- strcpy(peer->context, chan->context);
+ ast_channel_context_set(peer, ast_channel_context(chan));
if (ast_test_flag64(&opts, OPT_PEER_H)
- && ast_exists_extension(peer, peer->context, "h", 1,
+ && ast_exists_extension(peer, ast_channel_context(peer), "h", 1,
S_COR(peer->caller.id.number.valid, peer->caller.id.number.str, NULL))) {
int autoloopflag;
int found;
int res9;
- strcpy(peer->exten, "h");
+ ast_channel_exten_set(peer, "h");
peer->priority = 1;
autoloopflag = ast_test_flag(peer, AST_FLAG_IN_AUTOLOOP); /* save value to restore at the end */
ast_set_flag(peer, AST_FLAG_IN_AUTOLOOP);
- while ((res9 = ast_spawn_extension(peer, peer->context, peer->exten,
+ while ((res9 = ast_spawn_extension(peer, ast_channel_context(peer), ast_channel_exten(peer),
peer->priority,
S_COR(peer->caller.id.number.valid, peer->caller.id.number.str, NULL),
&found, 1)) == 0) {
if (found && res9) {
/* Something bad happened, or a hangup has been requested. */
- ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", peer->context, peer->exten, peer->priority, ast_channel_name(peer));
- ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", peer->context, peer->exten, peer->priority, ast_channel_name(peer));
+ ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(peer), ast_channel_exten(peer), peer->priority, ast_channel_name(peer));
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(peer), ast_channel_exten(peer), peer->priority, ast_channel_name(peer));
}
ast_set2_flag(peer, autoloopflag, AST_FLAG_IN_AUTOLOOP); /* set it back the way it was */
}
ast_parseable_goto(peer, opt_args[OPT_ARG_CALLEE_GO_ON]);
} else { /* F() */
int res;
- res = ast_goto_if_exists(peer, chan->context, chan->exten, (chan->priority) + 1);
+ res = ast_goto_if_exists(peer, ast_channel_context(chan), ast_channel_exten(chan), (chan->priority) + 1);
if (res == AST_PBX_GOTO_FAILED) {
ast_hangup(peer);
goto out;
while (loops) {
int continue_exec;
- chan->data = "Retrying";
+ ast_channel_data_set(chan, "Retrying");
if (ast_test_flag(chan, AST_FLAG_MOH))
ast_moh_stop(chan);
return -1;
}
} else {
- if (!pickup_by_exten(chan, exten, !ast_strlen_zero(context) ? context : chan->context)) {
+ if (!pickup_by_exten(chan, exten, !ast_strlen_zero(context) ? context : ast_channel_context(chan))) {
/* Pickup successful. Stop the dialplan this channel is a zombie. */
return -1;
}
static int goto_exten(struct ast_channel *chan, const char *dialcontext, char *ext)
{
- if (!ast_goto_if_exists(chan, S_OR(dialcontext, chan->context), ext, 1) ||
- (!ast_strlen_zero(chan->macrocontext) &&
- !ast_goto_if_exists(chan, chan->macrocontext, ext, 1))) {
+ if (!ast_goto_if_exists(chan, S_OR(dialcontext, ast_channel_context(chan)), ext, 1) ||
+ (!ast_strlen_zero(ast_channel_macrocontext(chan)) &&
+ !ast_goto_if_exists(chan, ast_channel_macrocontext(chan), ext, 1))) {
return 0;
} else {
ast_log(LOG_WARNING, "Can't find extension '%s' in current context. "
if (ast_test_flag(flags, OPT_FROMVOICEMAIL)) {
/* We still want to set the exten though */
- ast_copy_string(chan->exten, item->exten, sizeof(chan->exten));
+ ast_channel_exten_set(chan, item->exten);
} else if (ast_goto_if_exists(chan, S_OR(dialcontext, item->context), item->exten, 1)) {
ast_log(LOG_WARNING,
"Can't find extension '%s' in context '%s'. "
sec,
c->_bridge ? ast_channel_name(c->_bridge) : "<none>",
ast_bridged_channel(c) ? ast_channel_name(ast_bridged_channel(c)) : "<none>",
- c->context,
- c->exten,
+ ast_channel_context(c),
+ ast_channel_exten(c),
c->priority,
ast_print_group(cgrp, sizeof(cgrp), c->callgroup),
ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup),
- c->appl ? c->appl : "(N/A)",
- c->data ? S_OR(c->data, "(Empty)") : "(None)",
- (ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
+ ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)",
+ ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)") : "(None)",
+ (ast_test_flag(c, AST_FLAG_BLOCKING) ? ast_channel_blockproc(c) : "(Not Blocking)"));
return 0;
}
"TransferRate: %d\r\n"
"FileName: %s\r\n",
ast_channel_name(s->chan),
- s->chan->exten,
+ ast_channel_exten(s->chan),
S_COR(s->chan->caller.id.number.valid, s->chan->caller.id.number.str, ""),
S_COR(s->chan->caller.id.name.valid, s->chan->caller.id.name.str, ""),
S_COR(s->chan->connected.id.number.valid, s->chan->connected.id.number.str, ""),
}
/* Used for detecting whether to return when a Macro is called from another Macro after hangup */
- if (strcmp(chan->exten, "h") == 0)
+ if (strcmp(ast_channel_exten(chan), "h") == 0)
pbx_builtin_setvar_helper(chan, "MACRO_IN_HANGUP", "1");
if ((inhangupc = pbx_builtin_getvar_helper(chan, "MACRO_IN_HANGUP"))) {
if (!ast_exists_extension(chan, fullmacro, "s", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
if (!ast_context_find(fullmacro))
- ast_log(LOG_WARNING, "No such context '%s' for macro '%s'. Was called by %s@%s\n", fullmacro, macro, chan->exten, chan->context);
+ ast_log(LOG_WARNING, "No such context '%s' for macro '%s'. Was called by %s@%s\n", fullmacro, macro, ast_channel_exten(chan), ast_channel_context(chan));
else
ast_log(LOG_WARNING, "Context '%s' for macro '%s' lacks 's' extension, priority 1\n", fullmacro, macro);
return 0;
/* Save old info */
oldpriority = chan->priority;
- ast_copy_string(oldexten, chan->exten, sizeof(oldexten));
- ast_copy_string(oldcontext, chan->context, sizeof(oldcontext));
- if (ast_strlen_zero(chan->macrocontext)) {
- ast_copy_string(chan->macrocontext, chan->context, sizeof(chan->macrocontext));
- ast_copy_string(chan->macroexten, chan->exten, sizeof(chan->macroexten));
+ ast_copy_string(oldexten, ast_channel_exten(chan), sizeof(oldexten));
+ ast_copy_string(oldcontext, ast_channel_context(chan), sizeof(oldcontext));
+ if (ast_strlen_zero(ast_channel_macrocontext(chan))) {
+ ast_channel_macrocontext_set(chan, ast_channel_context(chan));
+ ast_channel_macroexten_set(chan, ast_channel_exten(chan));
chan->macropriority = chan->priority;
setmacrocontext=1;
}
pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc);
/* Setup environment for new run */
- chan->exten[0] = 's';
- chan->exten[1] = '\0';
- ast_copy_string(chan->context, fullmacro, sizeof(chan->context));
+ ast_channel_exten_set(chan, "s");
+ ast_channel_context_set(chan, fullmacro);
chan->priority = 1;
ast_channel_lock(chan);
ast_channel_unlock(chan);
autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP);
ast_set_flag(chan, AST_FLAG_IN_AUTOLOOP);
- while (ast_exists_extension(chan, chan->context, chan->exten, chan->priority,
+ while (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
struct ast_context *c;
struct ast_exten *e;
ast_log(LOG_WARNING, "Failed to lock contexts list\n");
} else {
for (c = ast_walk_contexts(NULL), e = NULL; c; c = ast_walk_contexts(c)) {
- if (!strcmp(ast_get_context_name(c), chan->context)) {
+ if (!strcmp(ast_get_context_name(c), ast_channel_context(chan))) {
if (ast_rdlock_context(c)) {
ast_log(LOG_WARNING, "Unable to lock context?\n");
} else {
- e = find_matching_priority(c, chan->exten, chan->priority,
+ e = find_matching_priority(c, ast_channel_exten(chan), chan->priority,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
if (e) { /* This will only be undefined for pbx_realtime, which is majorly broken. */
ast_copy_string(runningapp, ast_get_extension_app(e), sizeof(runningapp));
/* Reset the macro depth, if it was changed in the last iteration */
pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc);
- res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority,
+ res = ast_spawn_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
&foundx, 1);
if (res) {
res = 0;
goto out;
default:
- ast_debug(2, "Spawn extension (%s,%s,%d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, ast_channel_name(chan), macro);
- ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, ast_channel_name(chan), macro);
+ ast_debug(2, "Spawn extension (%s,%s,%d) exited non-zero on '%s' in macro '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), chan->priority, ast_channel_name(chan), macro);
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s' in macro '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), chan->priority, ast_channel_name(chan), macro);
goto out;
}
}
}
}
- if (gosub_level == 0 && strcasecmp(chan->context, fullmacro)) {
+ if (gosub_level == 0 && strcasecmp(ast_channel_context(chan), fullmacro)) {
ast_verb(2, "Channel '%s' jumping out of macro '%s'\n", ast_channel_name(chan), macro);
break;
}
/* don't stop executing extensions when we're in "h" */
if (ast_check_hangup(chan) && !inhangup) {
- ast_debug(1, "Extension %s, macroexten %s, priority %d returned normally even though call was hung up\n", chan->exten, chan->macroexten, chan->priority);
+ ast_debug(1, "Extension %s, macroexten %s, priority %d returned normally even though call was hung up\n", ast_channel_exten(chan), ast_channel_macroexten(chan), chan->priority);
goto out;
}
chan->priority++;
ast_free(save_macro_priority);
if (setmacrocontext) {
- chan->macrocontext[0] = '\0';
- chan->macroexten[0] = '\0';
+ ast_channel_macrocontext_set(chan, "");
+ ast_channel_macroexten_set(chan, "");
chan->macropriority = 0;
}
- if (!strcasecmp(chan->context, fullmacro)) {
+ if (!strcasecmp(ast_channel_context(chan), fullmacro)) {
const char *offsets;
/* If we're leaving the macro normally, restore original information */
chan->priority = oldpriority;
- ast_copy_string(chan->context, oldcontext, sizeof(chan->context));
- ast_copy_string(chan->exten, oldexten, sizeof(chan->exten));
+ ast_channel_context_set(chan, oldcontext);
+ ast_channel_exten_set(chan, oldexten);
if ((offsets = pbx_builtin_getvar_helper(chan, "MACRO_OFFSET"))) {
/* Handle macro offset if it's set by checking the availability of step n + offset + 1, otherwise continue
normally if there is any problem */
if (sscanf(offsets, "%30d", &offset) == 1) {
- if (ast_exists_extension(chan, chan->context, chan->exten,
+ if (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan),
chan->priority + offset + 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
chan->priority += offset;
ast_channel_lock(chan);
if ((tmpvar = pbx_builtin_getvar_helper(chan, "MEETME_EXIT_CONTEXT"))) {
ast_copy_string(exitcontext, tmpvar, sizeof(exitcontext));
- } else if (!ast_strlen_zero(chan->macrocontext)) {
- ast_copy_string(exitcontext, chan->macrocontext, sizeof(exitcontext));
+ } else if (!ast_strlen_zero(ast_channel_macrocontext(chan))) {
+ ast_copy_string(exitcontext, ast_channel_macrocontext(chan), sizeof(exitcontext));
} else {
- ast_copy_string(exitcontext, chan->context, sizeof(exitcontext));
+ ast_copy_string(exitcontext, ast_channel_context(chan), sizeof(exitcontext));
}
ast_channel_unlock(chan);
}
/* "Mailbox:domain:macrocontext:exten:priority:callerchan:callerid:origdate:origtime:duration:durationstatus:accountcode" */
"%s:%s:%s:%s:%d:%s:%s:%s:%s:%d:%s:%s\n",
username,
- chan->context,
- chan->macrocontext,
- chan->exten,
+ ast_channel_context(chan),
+ ast_channel_macrocontext(chan),
+ ast_channel_exten(chan),
chan->priority,
ast_channel_name(chan),
callerid,
strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
ouseexten = 1;
}
- } else if (ast_exists_extension(chan, chan->context, "o", 1,
+ } else if (ast_exists_extension(chan, ast_channel_context(chan), "o", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
ouseexten = 1;
}
- else if (!ast_strlen_zero(chan->macrocontext)
- && ast_exists_extension(chan, chan->macrocontext, "o", 1,
+ else if (!ast_strlen_zero(ast_channel_macrocontext(chan))
+ && ast_exists_extension(chan, ast_channel_macrocontext(chan), "o", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
ousemacro = 1;
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
}
- } else if (ast_exists_extension(chan, chan->context, "a", 1,
+ } else if (ast_exists_extension(chan, ast_channel_context(chan), "a", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
- } else if (!ast_strlen_zero(chan->macrocontext)
- && ast_exists_extension(chan, chan->macrocontext, "a", 1,
+ } else if (!ast_strlen_zero(ast_channel_macrocontext(chan))
+ && ast_exists_extension(chan, ast_channel_macrocontext(chan), "a", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
ausemacro = 1;
/* Check for a '*' here in case the caller wants to escape from voicemail to something
other than the operator -- an automated attendant or mailbox login for example */
if (res == '*') {
- chan->exten[0] = 'a';
- chan->exten[1] = '\0';
+ ast_channel_exten_set(chan, "a");
if (!ast_strlen_zero(vmu->exit)) {
- ast_copy_string(chan->context, vmu->exit, sizeof(chan->context));
- } else if (ausemacro && !ast_strlen_zero(chan->macrocontext)) {
- ast_copy_string(chan->context, chan->macrocontext, sizeof(chan->context));
+ ast_channel_context_set(chan, vmu->exit);
+ } else if (ausemacro && !ast_strlen_zero(ast_channel_macrocontext(chan))) {
+ ast_channel_context_set(chan, ast_channel_macrocontext(chan));
}
chan->priority = 0;
pbx_builtin_setvar_helper(chan, "MVM_GREET_STATUS", "USEREXIT");
res = 0;
} else if (res == '0') { /* Check for a '0' here */
if(ouseexten || ousemacro) {
- chan->exten[0] = 'o';
- chan->exten[1] = '\0';
+ ast_channel_exten_set(chan, "o");
if (!ast_strlen_zero(vmu->exit)) {
- ast_copy_string(chan->context, vmu->exit, sizeof(chan->context));
- } else if (ousemacro && !ast_strlen_zero(chan->macrocontext)) {
- ast_copy_string(chan->context, chan->macrocontext, sizeof(chan->context));
+ ast_channel_context_set(chan, vmu->exit);
+ } else if (ousemacro && !ast_strlen_zero(ast_channel_macrocontext(chan))) {
+ ast_channel_context_set(chan, ast_channel_macrocontext(chan));
}
ast_play_and_wait(chan, "transfer");
chan->priority = 0;
res = osp_auth(provider, &handle, source,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
- chan->exten, token, &timelimit);
+ ast_channel_exten(chan), token, &timelimit);
if (res > 0) {
status = AST_OSP_SUCCESS;
} else {
ast_parseable_goto(chan, args.return_context);
}
- ast_verb(3, "Return Context: (%s,%s,%d) ID: %s\n", chan->context, chan->exten,
+ ast_verb(3, "Return Context: (%s,%s,%d) ID: %s\n", ast_channel_context(chan), ast_channel_exten(chan),
chan->priority,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""));
- if (!ast_exists_extension(chan, chan->context, chan->exten, chan->priority,
+ if (!ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
ast_verb(3, "Warning: Return Context Invalid, call will return to default|s\n");
}
if (qe->cancel_answered_elsewhere) {
ast_set_flag(tmp->chan, AST_FLAG_ANSWERED_ELSEWHERE);
}
- tmp->chan->appl = "AppQueue";
- tmp->chan->data = "(Outgoing Line)";
+ ast_channel_appl_set(tmp->chan, "AppQueue");
+ ast_channel_data_set(tmp->chan, "(Outgoing Line)");
memset(&tmp->chan->whentohangup, 0, sizeof(tmp->chan->whentohangup));
/* If the new channel has no callerid, try to guess what it should be */
ast_channel_set_caller_event(tmp->chan, &caller, NULL);
} else if (!ast_strlen_zero(qe->chan->dialed.number.str)) {
ast_set_callerid(tmp->chan, qe->chan->dialed.number.str, NULL, NULL);
- } else if (!ast_strlen_zero(S_OR(qe->chan->macroexten, qe->chan->exten))) {
- ast_set_callerid(tmp->chan, S_OR(qe->chan->macroexten, qe->chan->exten), NULL, NULL);
+ } else if (!ast_strlen_zero(S_OR(ast_channel_macroexten(qe->chan), ast_channel_exten(qe->chan)))) {
+ ast_set_callerid(tmp->chan, S_OR(ast_channel_macroexten(qe->chan), ast_channel_exten(qe->chan)), NULL, NULL);
}
tmp->dial_callerid_absent = 1;
}
/* Inherit context and extension */
macrocontext = pbx_builtin_getvar_helper(qe->chan, "MACRO_CONTEXT");
- ast_channel_dialcontext_set(tmp->chan, ast_strlen_zero(macrocontext) ? qe->chan->context : macrocontext);
+ ast_channel_dialcontext_set(tmp->chan, ast_strlen_zero(macrocontext) ? ast_channel_context(qe->chan) : macrocontext);
macroexten = pbx_builtin_getvar_helper(qe->chan, "MACRO_EXTEN");
if (!ast_strlen_zero(macroexten))
- ast_copy_string(tmp->chan->exten, macroexten, sizeof(tmp->chan->exten));
+ ast_channel_exten_set(tmp->chan, macroexten);
else
- ast_copy_string(tmp->chan->exten, qe->chan->exten, sizeof(tmp->chan->exten));
+ ast_channel_exten_set(tmp->chan, ast_channel_exten(qe->chan));
if (ast_cdr_isset_unanswered()) {
/* they want to see the unanswered dial attempts! */
/* set up the CDR fields on all the CDRs to give sensical information */
strcpy(tmp->chan->cdr->clid, qe->chan->cdr->clid);
strcpy(tmp->chan->cdr->channel, qe->chan->cdr->channel);
strcpy(tmp->chan->cdr->src, qe->chan->cdr->src);
- strcpy(tmp->chan->cdr->dst, qe->chan->exten);
- strcpy(tmp->chan->cdr->dcontext, qe->chan->context);
+ strcpy(tmp->chan->cdr->dst, ast_channel_exten(qe->chan));
+ strcpy(tmp->chan->cdr->dcontext, ast_channel_context(qe->chan));
strcpy(tmp->chan->cdr->lastapp, qe->chan->cdr->lastapp);
strcpy(tmp->chan->cdr->lastdata, qe->chan->cdr->lastdata);
tmp->chan->cdr->amaflags = qe->chan->cdr->amaflags;
S_COR(qe->chan->caller.id.name.valid, qe->chan->caller.id.name.str, "unknown"),
S_COR(qe->chan->connected.id.number.valid, qe->chan->connected.id.number.str, "unknown"),
S_COR(qe->chan->connected.id.name.valid, qe->chan->connected.id.name.str, "unknown"),
- qe->chan->context, qe->chan->exten, qe->chan->priority, ast_channel_uniqueid(qe->chan),
+ ast_channel_context(qe->chan), ast_channel_exten(qe->chan), qe->chan->priority, ast_channel_uniqueid(qe->chan),
qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
ast_channel_unlock(tmp->chan);
*stuff++ = '\0';
tech = tmpchan;
} else {
- snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(o->chan), o->chan->context);
+ snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(o->chan), ast_channel_context(o->chan));
stuff = tmpchan;
tech = "Local";
}
ast_party_number_init(&o->chan->redirecting.from.number);
o->chan->redirecting.from.number.valid = 1;
o->chan->redirecting.from.number.str =
- ast_strdup(S_OR(in->macroexten, in->exten));
+ ast_strdup(S_OR(ast_channel_macroexten(in), ast_channel_exten(in)));
}
o->chan->dialed.transit_network_select = in->dialed.transit_network_select;
struct ast_datastore *datastore;
ast_queue_log(qe->parent->name, ast_channel_uniqueid(qe->chan), member->membername, "TRANSFER", "%s|%s|%ld|%ld|%d",
- new_chan->exten, new_chan->context, (long) (callstart - qe->start),
+ ast_channel_exten(new_chan), ast_channel_context(new_chan), (long) (callstart - qe->start),
(long) (time(NULL) - callstart), qe->opos);
update_queue(qe->parent, member, callcompletedinsl, (time(NULL) - callstart));
char *gosub_args, *gosub_argstart;
/* Set where we came from */
- ast_copy_string(peer->context, "app_queue_gosub_virtual_context", sizeof(peer->context));
- ast_copy_string(peer->exten, "s", sizeof(peer->exten));
+ ast_channel_context_set(peer, "app_queue_gosub_virtual_context");
+ ast_channel_exten_set(peer, "s");
peer->priority = 0;
gosub_argstart = strchr(gosubexec, ',');
queuename, ast_channel_uniqueid(qe->chan), ast_channel_name(peer), member->interface, member->membername,
(long) time(NULL) - qe->start, ast_channel_uniqueid(peer), (long)(orig - to > 0 ? (orig - to) / 1000 : 0),
qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
- ast_copy_string(oldcontext, qe->chan->context, sizeof(oldcontext));
- ast_copy_string(oldexten, qe->chan->exten, sizeof(oldexten));
+ ast_copy_string(oldcontext, ast_channel_context(qe->chan), sizeof(oldcontext));
+ ast_copy_string(oldexten, ast_channel_exten(qe->chan), sizeof(oldexten));
if ((queue_end_bridge = ao2_alloc(sizeof(*queue_end_bridge), NULL))) {
queue_end_bridge->q = qe->parent;
struct ast_datastore *tds;
/* detect a blind transfer */
- if (!(qe->chan->_softhangup | peer->_softhangup) && (strcasecmp(oldcontext, qe->chan->context) || strcasecmp(oldexten, qe->chan->exten))) {
+ if (!(qe->chan->_softhangup | peer->_softhangup) && (strcasecmp(oldcontext, ast_channel_context(qe->chan)) || strcasecmp(oldexten, ast_channel_exten(qe->chan)))) {
ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "TRANSFER", "%s|%s|%ld|%ld|%d",
- qe->chan->exten, qe->chan->context, (long) (callstart - qe->start),
+ ast_channel_exten(qe->chan), ast_channel_context(qe->chan), (long) (callstart - qe->start),
(long) (time(NULL) - callstart), qe->opos);
send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), TRANSFER);
} else if (ast_check_hangup(qe->chan)) {
AST_APP_ARG(options);
AST_APP_ARG(timeout);
);
-
+
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "ReadExten requires at least one argument\n");
pbx_builtin_setvar_helper(chan, "READEXTENSTATUS", "ERROR");
return 0;
}
- if (ast_strlen_zero(arglist.filename))
+ if (ast_strlen_zero(arglist.filename)) {
arglist.filename = NULL;
+ }
- if (ast_strlen_zero(arglist.context))
- arglist.context = chan->context;
+ if (ast_strlen_zero(arglist.context)) {
+ arglist.context = ast_strdupa(ast_channel_context(chan));
+ }
- if (!ast_strlen_zero(arglist.options))
+ if (!ast_strlen_zero(arglist.options)) {
ast_app_parse_options(readexten_app_options, &flags, NULL, arglist.options);
+ }
if (!ast_strlen_zero(arglist.timeout)) {
timeout = atoi(arglist.timeout);
int res=0;
// if (ast_test_flag(&flags,OPT_JUMP) && ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101) == 0){
- if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101) == 0){
+ if (ast_goto_if_exists(chan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority + 101) == 0){
res = 0;
} else {
res = -1;
}
}
- ast_copy_string(mychannel->exten, myrpt->exten, sizeof(mychannel->exten) - 1);
- ast_copy_string(mychannel->context, myrpt->patchcontext, sizeof(mychannel->context) - 1);
+ ast_channel_exten_set(mychannel, myrpt->exten);
+ ast_channel_context_set(mychannel, myrpt->patchcontext);
if (myrpt->p.acctcode)
ast_cdr_setaccount(mychannel,myrpt->p.acctcode);
#ifndef NEW_ASTERISK
l->chan->whentohangup = 0;
#endif
- l->chan->appl = "Apprpt";
- l->chan->data = "(Remote Rx)";
+ ast_channel_appl_set(l->chan, "Apprpt");
+ ast_channel_data_set(l->chan, "(Remote Rx)");
if (debug > 3)
ast_log(LOG_NOTICE, "rpt (remote) initiating call to %s/%s on %s\n",
deststr, tele, ast_channel_name(l->chan));
#ifndef NEW_ASTERISK
l->chan->whentohangup = 0;
#endif
- l->chan->appl = "Apprpt";
- l->chan->data = "(Remote Rx)";
+ ast_channel_appl_set(l->chan, "Apprpt");
+ ast_channel_data_set(l->chan, "(Remote Rx)");
ast_verb(3, "rpt (attempt_reconnect) initiating call to %s/%s on %s\n",
deststr, tele, ast_channel_name(l->chan));
l->chan->caller.id.number.valid = 1;
#else
if(exten)
#endif
- strncpy(chan->exten, exten, sizeof(chan->exten)-1);
+ ast_channel_exten_set(chan, exten);
if(context)
- strncpy(chan->context, context, sizeof(chan->context)-1);
+ ast_channel_context_set(chan, context);
} else { /* increment the priority by default*/
chan->priority++;
}
ast_verb(3, "Return Context: (%s,%s,%d) ID: %s\n",
- chan->context, chan->exten, chan->priority,
+ ast_channel_context(chan), ast_channel_exten(chan), chan->priority,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""));
- if (!ast_exists_extension(chan, chan->context, chan->exten, chan->priority,
+ if (!ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
ast_verb(3, "Warning: Return Context Invalid, call will return to default|s\n");
}
#ifndef NEW_ASTERISK
myrpt->rxchannel->whentohangup = 0;
#endif
- myrpt->rxchannel->appl = "Apprpt";
- myrpt->rxchannel->data = "(Link Rx)";
+ ast_channel_appl_set(myrpt->rxchannel, "Apprpt");
+ ast_channel_data_set(myrpt->rxchannel, "(Link Rx)");
ast_verb(3, "rpt (Rx) initiating call to %s/%s on %s\n",
myrpt->rxchanname,tele,ast_channel_name(myrpt->rxchannel));
rpt_mutex_unlock(&myrpt->lock);
#ifndef NEW_ASTERISK
myrpt->txchannel->whentohangup = 0;
#endif
- myrpt->txchannel->appl = "Apprpt";
- myrpt->txchannel->data = "(Link Tx)";
+ ast_channel_appl_set(myrpt->txchannel, "Apprpt");
+ ast_channel_data_set(myrpt->txchannel, "(Link Tx)");
ast_verb(3, "rpt (Tx) initiating call to %s/%s on %s\n",
myrpt->txchanname,tele,ast_channel_name(myrpt->txchannel));
rpt_mutex_unlock(&myrpt->lock);
}
/* Create the return address, but don't save it until we know that the Gosub destination exists */
- newframe = gosub_allocate_frame(chan->context, chan->exten, chan->priority + 1, max_argc);
+ newframe = gosub_allocate_frame(ast_channel_context(chan), ast_channel_exten(chan), chan->priority + 1, max_argc);
if (!newframe) {
return -1;
return -1;
}
- if (!ast_exists_extension(chan, chan->context, chan->exten,
+ if (!ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan),
ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP) ? chan->priority + 1 : chan->priority,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
ast_log(LOG_ERROR, "Attempt to reach a non-existent destination for gosub: (Context:%s, Extension:%s, Priority:%d)\n",
- chan->context, chan->exten, ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP) ? chan->priority + 1 : chan->priority);
- ast_copy_string(chan->context, newframe->context, sizeof(chan->context));
- ast_copy_string(chan->exten, newframe->extension, sizeof(chan->exten));
+ ast_channel_context(chan), ast_channel_exten(chan), ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP) ? chan->priority + 1 : chan->priority);
+ ast_channel_context_set(chan, newframe->context);
+ ast_channel_exten_set(chan, newframe->extension);
chan->priority = newframe->priority;
ast_free(newframe);
return -1;
}
/* Save previous location, since we're going to change it */
- ast_copy_string(old_context, chan->context, sizeof(old_context));
- ast_copy_string(old_extension, chan->exten, sizeof(old_extension));
+ ast_copy_string(old_context, ast_channel_context(chan), sizeof(old_context));
+ ast_copy_string(old_extension, ast_channel_exten(chan), sizeof(old_extension));
old_priority = chan->priority;
if (!(theapp = pbx_findapp("Gosub"))) {
}
/* Restore previous location */
- ast_copy_string(chan->context, old_context, sizeof(chan->context));
- ast_copy_string(chan->exten, old_extension, sizeof(chan->exten));
+ ast_channel_context_set(chan, old_context);
+ ast_channel_exten_set(chan, old_extension);
chan->priority = old_priority;
return RESULT_SUCCESS;
char t[2];
t[0] = fr->subclass.integer;
t[1] = '\0';
- if (ast_canmatch_extension(chan, chan->context, t, 1,
+ if (ast_canmatch_extension(chan, ast_channel_context(chan), t, 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
/* They entered a valid extension, or might be anyhow */
res = fr->subclass.integer;
snprintf(ms_str, sizeof(ms_str), "%d", ms);
pbx_builtin_setvar_helper(chan, "TALK_DETECTED", ms_str);
- ast_goto_if_exists(chan, chan->context, "talk", 1);
+ ast_goto_if_exists(chan, ast_channel_context(chan), "talk", 1);
res = 0;
ast_frfree(fr);
break;
}
if (lnum > -1) {
- snprintf(context, sizeof(context), "@ %s", chan->context);
- snprintf(extension, sizeof(extension), "Ext. %s", chan->exten);
+ snprintf(context, sizeof(context), "@ %s", ast_channel_context(chan));
+ snprintf(extension, sizeof(extension), "Ext. %s", ast_channel_exten(chan));
ast_log(lnum, extension, chan->priority, context, "%s\n", args.msg);
}
strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
ouseexten = 1;
}
- } else if (ast_exists_extension(chan, chan->context, "o", 1,
+ } else if (ast_exists_extension(chan, ast_channel_context(chan), "o", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
ouseexten = 1;
- } else if (!ast_strlen_zero(chan->macrocontext)
- && ast_exists_extension(chan, chan->macrocontext, "o", 1,
+ } else if (!ast_strlen_zero(ast_channel_macrocontext(chan))
+ && ast_exists_extension(chan, ast_channel_macrocontext(chan), "o", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
ousemacro = 1;
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
}
- } else if (ast_exists_extension(chan, chan->context, "a", 1,
+ } else if (ast_exists_extension(chan, ast_channel_context(chan), "a", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
- } else if (!ast_strlen_zero(chan->macrocontext)
- && ast_exists_extension(chan, chan->macrocontext, "a", 1,
+ } else if (!ast_strlen_zero(ast_channel_macrocontext(chan))
+ && ast_exists_extension(chan, ast_channel_macrocontext(chan), "a", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
ausemacro = 1;
char e[2] = "";
e[0] = *code;
if (strchr(ecodes, e[0]) == NULL
- && ast_canmatch_extension(chan, chan->context, e, 1,
+ && ast_canmatch_extension(chan, ast_channel_context(chan), e, 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
strncat(ecodes, e, sizeof(ecodes) - strlen(ecodes) - 1);
}
/* Check for a '*' here in case the caller wants to escape from voicemail to something
other than the operator -- an automated attendant or mailbox login for example */
if (res == '*') {
- chan->exten[0] = 'a';
- chan->exten[1] = '\0';
+ ast_channel_exten_set(chan, "a");
if (!ast_strlen_zero(vmu->exit)) {
- ast_copy_string(chan->context, vmu->exit, sizeof(chan->context));
- } else if (ausemacro && !ast_strlen_zero(chan->macrocontext)) {
- ast_copy_string(chan->context, chan->macrocontext, sizeof(chan->context));
+ ast_channel_context_set(chan, vmu->exit);
+ } else if (ausemacro && !ast_strlen_zero(ast_channel_macrocontext(chan))) {
+ ast_channel_context_set(chan, ast_channel_macrocontext(chan));
}
chan->priority = 0;
free_user(vmu);
if (ast_test_flag(vmu, VM_OPERATOR) && res == '0') {
transfer:
if (ouseexten || ousemacro) {
- chan->exten[0] = 'o';
- chan->exten[1] = '\0';
+ ast_channel_exten_set(chan, "o");
if (!ast_strlen_zero(vmu->exit)) {
- ast_copy_string(chan->context, vmu->exit, sizeof(chan->context));
- } else if (ousemacro && !ast_strlen_zero(chan->macrocontext)) {
- ast_copy_string(chan->context, chan->macrocontext, sizeof(chan->context));
+ ast_channel_context_set(chan, vmu->exit);
+ } else if (ousemacro && !ast_strlen_zero(ast_channel_macrocontext(chan))) {
+ ast_channel_context_set(chan, ast_channel_macrocontext(chan));
}
ast_play_and_wait(chan, "transfer");
chan->priority = 0;
/* Allow all other digits to exit Voicemail and return to the dialplan */
if (ast_test_flag(options, OPT_DTMFEXIT) && res > 0) {
if (!ast_strlen_zero(options->exitcontext))
- ast_copy_string(chan->context, options->exitcontext, sizeof(chan->context));
+ ast_channel_context_set(chan, options->exitcontext);
free_user(vmu);
pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT");
ast_free(tmp);
"Unknown");
ast_store_realtime("voicemail_data",
"origmailbox", ext,
- "context", chan->context,
- "macrocontext", chan->macrocontext,
- "exten", chan->exten,
+ "context", ast_channel_context(chan),
+ "macrocontext", ast_channel_macrocontext(chan),
+ "exten", ast_channel_exten(chan),
"priority", priority,
"callerchan", ast_channel_name(chan),
"callerid", callerid,
"origtime=%ld\n"
"category=%s\n",
ext,
- chan->context,
- chan->macrocontext,
- chan->exten,
+ ast_channel_context(chan),
+ ast_channel_macrocontext(chan),
+ ast_channel_exten(chan),
S_COR(chan->redirecting.from.number.valid,
chan->redirecting.from.number.str, "unknown"),
chan->priority,
if (cmd < 0 || cmd == 't')
break;
}
-
+
if (use_directory) {
/* use app_directory */
-
- char old_context[sizeof(chan->context)];
- char old_exten[sizeof(chan->exten)];
- int old_priority;
+
struct ast_app* directory_app;
directory_app = pbx_findapp("Directory");
if (directory_app) {
char vmcontext[256];
+ char *old_context;
+ char *old_exten;
+ int old_priority;
/* make backup copies */
- memcpy(old_context, chan->context, sizeof(chan->context));
- memcpy(old_exten, chan->exten, sizeof(chan->exten));
+ old_context = ast_strdupa(ast_channel_context(chan));
+ old_exten = ast_strdupa(ast_channel_exten(chan));
old_priority = chan->priority;
-
+
/* call the the Directory, changes the channel */
snprintf(vmcontext, sizeof(vmcontext), "%s,,v", context ? context : "default");
res = pbx_exec(chan, directory_app, vmcontext);
-
- ast_copy_string(username, chan->exten, sizeof(username));
-
+
+ ast_copy_string(username, ast_channel_exten(chan), sizeof(username));
+
/* restore the old context, exten, and priority */
- memcpy(chan->context, old_context, sizeof(chan->context));
- memcpy(chan->exten, old_exten, sizeof(chan->exten));
+ ast_channel_context_set(chan, old_context);
+ ast_channel_exten_set(chan, old_exten);
chan->priority = old_priority;
} else {
ast_log(AST_LOG_WARNING, "Could not find the Directory application, disabling directory_forward\n");
} else if (mailbox[0] == '*') {
/* user entered '*' */
ast_verb(4, "Mailbox begins with '*', attempting jump to extension 'a'\n");
- if (ast_exists_extension(chan, chan->context, "a", 1,
+ if (ast_exists_extension(chan, ast_channel_context(chan), "a", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
return -1;
}
} else if (password[0] == '*') {
/* user entered '*' */
ast_verb(4, "Password begins with '*', attempting jump to extension 'a'\n");
- if (ast_exists_extension(chan, chan->context, "a", 1,
+ if (ast_exists_extension(chan, ast_channel_context(chan), "a", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
mailbox[0] = '*';
return -1;
ast_debug(1, "After vm_authenticate\n");
if (vms.username[0] == '*') {
- ast_debug(1, "user pressed * in context '%s'\n", chan->context);
+ ast_debug(1, "user pressed * in context '%s'\n", ast_channel_context(chan));
/* user entered '*' */
- if (!ast_goto_if_exists(chan, chan->context, "a", 1)) {
+ if (!ast_goto_if_exists(chan, ast_channel_context(chan), "a", 1)) {
ast_test_suite_event_notify("REDIRECT", "Message: redirecting user to 'a' extension");
res = 0; /* prevent hangup */
goto out;
res = 0;
} else if (mailbox[0] == '*') {
/* user entered '*' */
- if (!ast_goto_if_exists(chan, chan->context, "a", 1)) {
+ if (!ast_goto_if_exists(chan, ast_channel_context(chan), "a", 1)) {
res = 0; /* prevent hangup */
}
}
if (!ast_strlen_zero(destination)) {
if (destination[strlen(destination) -1 ] == '*')
return 0;
- ast_verb(3, "Placing outgoing call to extension '%s' in context '%s' from context '%s'\n", destination, outgoing_context, chan->context);
- ast_copy_string(chan->exten, destination, sizeof(chan->exten));
- ast_copy_string(chan->context, outgoing_context, sizeof(chan->context));
+ ast_verb(3, "Placing outgoing call to extension '%s' in context '%s' from context '%s'\n", destination, outgoing_context, ast_channel_context(chan));
+ ast_channel_exten_set(chan, destination);
+ ast_channel_context_set(chan, outgoing_context);
chan->priority = 0;
return 9;
}
struct ast_exten *e;
if (!ast_rdlock_context(c)) {
- if (!strcmp(ast_get_context_name(c), chan->context)) {
+ if (!strcmp(ast_get_context_name(c), ast_channel_context(chan))) {
/* This is the matching context we want */
int cur_priority = chan->priority + 1, level=1;
- for (e = find_matching_priority(c, chan->exten, cur_priority,
+ for (e = find_matching_priority(c, ast_channel_exten(chan), cur_priority,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
e;
- e = find_matching_priority(c, chan->exten, ++cur_priority,
+ e = find_matching_priority(c, ast_channel_exten(chan), ++cur_priority,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
if (!strcasecmp(ast_get_extension_app(e), "WHILE")) {
level++;
if (!end)
condition = ast_strdupa(data);
- size = strlen(chan->context) + strlen(chan->exten) + 32;
+ size = strlen(ast_channel_context(chan)) + strlen(ast_channel_exten(chan)) + 32;
my_name = alloca(size);
memset(my_name, 0, size);
- snprintf(my_name, size, "%s_%s_%d", chan->context, chan->exten, chan->priority);
+ snprintf(my_name, size, "%s_%s_%d", ast_channel_context(chan), ast_channel_exten(chan), chan->priority);
ast_channel_lock(chan);
if (end) {
ast_verb(3, "Jumping to priority %d\n", pri);
chan->priority = pri;
} else {
- ast_log(LOG_WARNING, "Couldn't find matching EndWhile? (While at %s@%s priority %d)\n", chan->context, chan->exten, chan->priority);
+ ast_log(LOG_WARNING, "Couldn't find matching EndWhile? (While at %s@%s priority %d)\n", ast_channel_context(chan), ast_channel_exten(chan), chan->priority);
}
}
ast_channel_unlock(chan);
if (!end && !while_pri) {
char *goto_str;
- size = strlen(chan->context) + strlen(chan->exten) + 32;
+ size = strlen(ast_channel_context(chan)) + strlen(ast_channel_exten(chan)) + 32;
goto_str = alloca(size);
memset(goto_str, 0, size);
- snprintf(goto_str, size, "%s,%s,%d", chan->context, chan->exten, chan->priority);
+ snprintf(goto_str, size, "%s,%s,%d", ast_channel_context(chan), ast_channel_exten(chan), chan->priority);
pbx_builtin_setvar_helper(chan, varname, goto_str);
}
snprintf(end_varname, VAR_SIZE, "END_%s", varname);
if (! pbx_builtin_getvar_helper(chan, end_varname)) {
char *goto_str;
- size = strlen(chan->context) + strlen(chan->exten) + 32;
+ size = strlen(ast_channel_context(chan)) + strlen(ast_channel_exten(chan)) + 32;
goto_str = alloca(size);
memset(goto_str, 0, size);
- snprintf(goto_str, size, "%s,%s,%d", chan->context, chan->exten, chan->priority+1);
+ snprintf(goto_str, size, "%s,%s,%d", ast_channel_context(chan), ast_channel_exten(chan), chan->priority+1);
pbx_builtin_setvar_helper(chan, end_varname, goto_str);
}
ast_parseable_goto(chan, while_pri);
char exten[AST_MAX_EXTENSION] = "";
struct ast_channel *chan = NULL;
struct ast_bridge_features_blind_transfer *blind_transfer = hook_pvt;
- const char *context = (blind_transfer && !ast_strlen_zero(blind_transfer->context) ? blind_transfer->context : bridge_channel->chan->context);
+ const char *context = (blind_transfer && !ast_strlen_zero(blind_transfer->context) ? blind_transfer->context : ast_channel_context(bridge_channel->chan));
/* Grab the extension to transfer to */
if (!grab_transfer(bridge_channel->chan, exten, sizeof(exten), context)) {
struct ast_bridge_features caller_features, called_features;
enum ast_bridge_channel_state attended_bridge_result;
struct ast_bridge_features_attended_transfer *attended_transfer = hook_pvt;
- const char *context = (attended_transfer && !ast_strlen_zero(attended_transfer->context) ? attended_transfer->context : bridge_channel->chan->context);
+ const char *context = (attended_transfer && !ast_strlen_zero(attended_transfer->context) ? attended_transfer->context : ast_channel_context(bridge_channel->chan));
/* Grab the extension to transfer to */
if (!grab_transfer(bridge_channel->chan, exten, sizeof(exten), context)) {
}
#endif
if (p->pending)
- tmp = ast_channel_alloc(0, state, 0, 0, "", p->chan ? p->chan->exten:"", p->chan ? p->chan->context:"", linkedid, 0, "Agent/P%s-%d", p->agent, (int) ast_random() & 0xffff);
+ tmp = ast_channel_alloc(0, state, 0, 0, "", p->chan ? ast_channel_exten(p->chan):"", p->chan ? ast_channel_context(p->chan):"", linkedid, 0, "Agent/P%s-%d", p->agent, (int) ast_random() & 0xffff);
else
- tmp = ast_channel_alloc(0, state, 0, 0, "", p->chan ? p->chan->exten:"", p->chan ? p->chan->context:"", linkedid, 0, "Agent/%s", p->agent);
+ tmp = ast_channel_alloc(0, state, 0, 0, "", p->chan ? ast_channel_exten(p->chan):"", p->chan ? ast_channel_context(p->chan):"", linkedid, 0, "Agent/%s", p->agent);
if (!tmp) {
ast_log(LOG_WARNING, "Unable to allocate agent channel structure\n");
return NULL;
ast_format_copy(&tmp->readformat, &p->chan->readformat);
ast_format_copy(&tmp->rawreadformat, &p->chan->readformat);
ast_channel_language_set(tmp, ast_channel_language(p->chan));
- ast_copy_string(tmp->context, p->chan->context, sizeof(tmp->context));
- ast_copy_string(tmp->exten, p->chan->exten, sizeof(tmp->exten));
+ ast_channel_context_set(tmp, ast_channel_context(p->chan));
+ ast_channel_exten_set(tmp, ast_channel_exten(p->chan));
/* XXX Is this really all we copy form the originating channel?? */
} else {
ast_format_set(&tmp->writeformat, AST_FORMAT_SLINEAR, 0);
/* Safe -- agent lock already held */
ast_setstate(parent, AST_STATE_UP);
ast_setstate(chan, AST_STATE_UP);
- ast_copy_string(parent->context, chan->context, sizeof(parent->context));
+ ast_channel_context_set(parent, ast_channel_context(chan));
ast_channel_masquerade(parent, chan);
ast_hangup(chan);
p->abouttograb = 0;
tmp->tech_pvt = p;
if (!ast_strlen_zero(p->context))
- ast_copy_string(tmp->context, p->context, sizeof(tmp->context));
+ ast_channel_context_set(tmp, p->context);
if (!ast_strlen_zero(p->exten))
- ast_copy_string(tmp->exten, p->exten, sizeof(tmp->exten));
+ ast_channel_exten_set(tmp, p->exten);
if (!ast_strlen_zero(language))
ast_channel_language_set(tmp, language);
p->owner = tmp;
/* Check to see if context is what it should be, if not set to be. */
else if (strcmp(p->context,p->defcontext) != 0) {
ast_copy_string(p->context, p->defcontext, sizeof(p->context));
- ast_copy_string(chan->context,p->defcontext,sizeof(chan->context));
+ ast_channel_context_set(chan, p->defcontext);
}
for (;;) {
if (distMatches == 3) {
/* The ring matches, set the context to whatever is for distinctive ring.. */
ast_copy_string(p->context, S_OR(p->drings.ringContext[counter].contextData, p->defcontext), sizeof(p->context));
- ast_copy_string(chan->context, S_OR(p->drings.ringContext[counter].contextData, p->defcontext), sizeof(chan->context));
+ ast_channel_context_set(chan, S_OR(p->drings.ringContext[counter].contextData, p->defcontext));
ast_verb(3, "Distinctive Ring matched context %s\n",p->context);
break;
}
ast_dsp_set_features(p->dsp, p->dsp_features);
ast_debug(1, "Disabling FAX tone detection on %s after tone received\n", ast_channel_name(ast));
}
- if (strcmp(ast->exten, "fax")) {
- const char *target_context = S_OR(ast->macrocontext, ast->context);
+ if (strcmp(ast_channel_exten(ast), "fax")) {
+ const char *target_context = S_OR(ast_channel_macrocontext(ast), ast_channel_context(ast));
/* We need to unlock 'ast' here because ast_exists_extension has the
* potential to start autoservice on the channel. Such action is prone
ast_mutex_lock(&p->lock);
ast_verb(3, "Redirecting %s to fax extension\n", ast_channel_name(ast));
/* Save the DID/DNIS when we transfer the fax call to a "fax" extension */
- pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast->exten);
+ pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast_channel_exten(ast));
if (ast_async_goto(ast, target_context, "fax", 1))
ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(ast), target_context);
} else {
ast_dsp_set_features(p->dsp, p->dsp_features);
ast_debug(1, "Disabling FAX tone detection on %s after tone received\n", ast_channel_name(ast));
}
- if (strcmp(ast->exten, "fax")) {
- const char *target_context = S_OR(ast->macrocontext, ast->context);
+ if (strcmp(ast_channel_exten(ast), "fax")) {
+ const char *target_context = S_OR(ast_channel_macrocontext(ast), ast_channel_context(ast));
/* We need to unlock 'ast' here because ast_exists_extension has the
* potential to start autoservice on the channel. Such action is prone
ast_mutex_lock(&p->lock);
ast_verb(3, "Redirecting %s to fax extension\n", ast_channel_name(ast));
/* Save the DID/DNIS when we transfer the fax call to a "fax" extension */
- pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast->exten);
+ pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast_channel_exten(ast));
if (ast_async_goto(ast, target_context, "fax", 1))
ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(ast), target_context);
} else {
if (i->amaflags)
tmp->amaflags = i->amaflags;
i->subs[idx].owner = tmp;
- ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
+ ast_channel_context_set(tmp, i->context);
if (!analog_lib_handles(i->sig, i->radio, i->oprmode)) {
ast_channel_call_forward_set(tmp, i->call_forward);
}
if (!i->adsi)
tmp->adsicpe = AST_ADSI_UNAVAILABLE;
if (!ast_strlen_zero(i->exten))
- ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
+ ast_channel_exten_set(tmp, i->exten);
if (!ast_strlen_zero(i->rdnis)) {
tmp->redirecting.from.number.valid = 1;
tmp->redirecting.from.number.str = ast_strdup(i->rdnis);
/* If we got the first digit, get the rest */
len = 1;
dtmfbuf[len] = '\0';
- while ((len < AST_MAX_EXTENSION-1) && ast_matchmore_extension(chan, chan->context, dtmfbuf, 1, p->cid_num)) {
- if (ast_exists_extension(chan, chan->context, dtmfbuf, 1, p->cid_num)) {
+ while ((len < AST_MAX_EXTENSION-1) && ast_matchmore_extension(chan, ast_channel_context(chan), dtmfbuf, 1, p->cid_num)) {
+ if (ast_exists_extension(chan, ast_channel_context(chan), dtmfbuf, 1, p->cid_num)) {
timeout = matchdigittimeout;
} else {
timeout = gendigittimeout;
}
}
- if (ast_exists_extension(chan, chan->context, exten, 1,
+ if (ast_exists_extension(chan, ast_channel_context(chan), exten, 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
- ast_copy_string(chan->exten, exten, sizeof(chan->exten));
+ ast_channel_exten_set(chan, exten);
if (p->dsp) ast_dsp_digitreset(p->dsp);
res = ast_pbx_run(chan);
if (res) {
}
goto quit;
} else {
- ast_verb(2, "Unknown extension '%s' in context '%s' requested\n", exten, chan->context);
+ ast_verb(2, "Unknown extension '%s' in context '%s' requested\n", exten, ast_channel_context(chan));
sleep(2);
res = tone_zone_play_tone(p->subs[idx].dfd, DAHDI_TONE_INFO);
if (res < 0)
exten[len++]=res;
exten[len] = '\0';
}
- if (!ast_ignore_pattern(chan->context, exten))
+ if (!ast_ignore_pattern(ast_channel_context(chan), exten))
tone_zone_play_tone(p->subs[idx].dfd, -1);
else
tone_zone_play_tone(p->subs[idx].dfd, DAHDI_TONE_DIALTONE);
- if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num) && !ast_parking_ext_valid(exten, chan, chan->context)) {
- if (!res || !ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
+ if (ast_exists_extension(chan, ast_channel_context(chan), exten, 1, p->cid_num) && !ast_parking_ext_valid(exten, chan, ast_channel_context(chan))) {
+ if (!res || !ast_matchmore_extension(chan, ast_channel_context(chan), exten, 1, p->cid_num)) {
if (getforward) {
/* Record this as the forwarding extension */
ast_copy_string(p->call_forward, exten, sizeof(p->call_forward));
getforward = 0;
} else {
res = tone_zone_play_tone(p->subs[idx].dfd, -1);
- ast_copy_string(chan->exten, exten, sizeof(chan->exten));
+ ast_channel_exten_set(chan, exten);
if (!ast_strlen_zero(p->cid_num)) {
if (!p->hidecallerid)
ast_set_callerid(chan, p->cid_num, NULL, p->cid_num);
getforward = 0;
memset(exten, 0, sizeof(exten));
len = 0;
- } else if ((p->transfer || p->canpark) && ast_parking_ext_valid(exten, chan, chan->context) &&
+ } else if ((p->transfer || p->canpark) && ast_parking_ext_valid(exten, chan, ast_channel_context(chan)) &&
p->subs[SUB_THREEWAY].owner &&
ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) {
/* This is a three way call, the main call being a real channel,
and we're parking the first call. */
ast_masq_park_call_exten(ast_bridged_channel(p->subs[SUB_THREEWAY].owner),
- chan, exten, chan->context, 0, NULL);
+ chan, exten, ast_channel_context(chan), 0, NULL);
ast_verb(3, "Parking call to '%s'\n", ast_channel_name(chan));
break;
} else if (p->hidecallerid && !strcmp(exten, "*82")) {
ast_hangup(chan);
goto quit;
}
- } else if (!ast_canmatch_extension(chan, chan->context, exten, 1,
+ } else if (!ast_canmatch_extension(chan, ast_channel_context(chan), exten, 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))
&& !canmatch_featurecode(exten)) {
ast_debug(1, "Can't match %s from '%s' in context %s\n", exten,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, "<Unknown Caller>"),
- chan->context);
+ ast_channel_context(chan));
break;
}
if (!timeout)
timeout = gendigittimeout;
- if (len && !ast_ignore_pattern(chan->context, exten))
+ if (len && !ast_ignore_pattern(ast_channel_context(chan), exten))
tone_zone_play_tone(p->subs[idx].dfd, -1);
}
break;
smdi_msg = ast_smdi_md_message_wait(p->smdi_iface, SMDI_MD_WAIT_TIMEOUT);
if (smdi_msg != NULL) {
- ast_copy_string(chan->exten, smdi_msg->fwd_st, sizeof(chan->exten));
+ ast_channel_exten_set(chan, smdi_msg->fwd_st);
if (smdi_msg->type == 'B')
pbx_builtin_setvar_helper(chan, "_SMDI_VM_TYPE", "b");
/* Check to see if context is what it should be, if not set to be. */
if (strcmp(p->context,p->defcontext) != 0) {
ast_copy_string(p->context, p->defcontext, sizeof(p->context));
- ast_copy_string(chan->context,p->defcontext,sizeof(chan->context));
+ ast_channel_context_set(chan, p->defcontext);
}
for (;;) {
if (distMatches == 3) {
/* The ring matches, set the context to whatever is for distinctive ring.. */
ast_copy_string(p->context, S_OR(p->drings.ringContext[counter].contextData, p->defcontext), sizeof(p->context));
- ast_copy_string(chan->context, S_OR(p->drings.ringContext[counter].contextData, p->defcontext), sizeof(chan->context));
+ ast_channel_context_set(chan, S_OR(p->drings.ringContext[counter].contextData, p->defcontext));
ast_verb(3, "Distinctive Ring matched context %s\n",p->context);
break;
}
/* Check to see if context is what it should be, if not set to be. */
if (strcmp(p->context,p->defcontext) != 0) {
ast_copy_string(p->context, p->defcontext, sizeof(p->context));
- ast_copy_string(chan->context,p->defcontext,sizeof(chan->context));
+ ast_channel_context_set(chan, p->defcontext);
}
/* Take out of linear mode for Caller*ID processing */
if (distMatches == 3) {
/* The ring matches, set the context to whatever is for distinctive ring.. */
ast_copy_string(p->context, S_OR(p->drings.ringContext[counter].contextData, p->defcontext), sizeof(p->context));
- ast_copy_string(chan->context, S_OR(p->drings.ringContext[counter].contextData, p->defcontext), sizeof(chan->context));
+ ast_channel_context_set(chan, S_OR(p->drings.ringContext[counter].contextData, p->defcontext));
ast_verb(3, "Distinctive Ring matched context %s\n",p->context);
break;
}
ast_channel_parkinglot_set(tmp, client->parkinglot);
i->owner = tmp;
ast_module_ref(ast_module_info->self);
- ast_copy_string(tmp->context, client->context, sizeof(tmp->context));
- ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
+ ast_channel_context_set(tmp, client->context);
+ ast_channel_exten_set(tmp, i->exten);
if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s")) {
tmp->dialed.number.str = ast_strdup(i->exten);
/* Set the owner of this channel */
pvt->owner = ch;
- ast_copy_string(ch->context, pvt->context, sizeof(ch->context));
- ast_copy_string(ch->exten, pvt->exten, sizeof(ch->exten));
+ ast_channel_context_set(ch, pvt->context);
+ ast_channel_exten_set(ch, pvt->exten);
ch->priority = 1;
if (!ast_strlen_zero(pvt->accountcode)) {
ast_channel_accountcode_set(ch, pvt->accountcode);
pds.context = cai.peercontext;
/* Keep track of the context for outgoing calls too */
- ast_copy_string(c->context, cai.context, sizeof(c->context));
+ ast_channel_context_set(c, cai.context);
if (pds.port)
sin.sin_port = htons(atoi(pds.port));
ast_mutex_lock(&iaxsl[callno]);
- if (!ast_strlen_zero(c->context))
- ast_string_field_set(iaxs[callno], context, c->context);
+ if (!ast_strlen_zero(ast_channel_context(c)))
+ ast_string_field_set(iaxs[callno], context, ast_channel_context(c));
if (pds.username)
ast_string_field_set(iaxs[callno], username, pds.username);
ast_channel_accountcode_set(tmp, i->accountcode);
if (i->amaflags)
tmp->amaflags = i->amaflags;
- ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
- ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
+ ast_channel_context_set(tmp, i->context);
+ ast_channel_exten_set(tmp, i->exten);
if (i->adsi)
tmp->adsicpe = i->peeradsicpe;
else
struct ast_channel *chan1m, *chan2m;/* Chan2m: The transferer, chan1m: The transferee */
pthread_t th;
- chan1m = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan2), chan1->exten, chan1->context, ast_channel_linkedid(chan1), chan1->amaflags, "Parking/%s", ast_channel_name(chan1));
- chan2m = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan2), chan2->exten, chan2->context, ast_channel_linkedid(chan2), chan2->amaflags, "IAXPeer/%s", ast_channel_name(chan2));
+ chan1m = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan2), ast_channel_exten(chan1), ast_channel_context(chan1), ast_channel_linkedid(chan1), chan1->amaflags, "Parking/%s", ast_channel_name(chan1));
+ chan2m = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan2), ast_channel_exten(chan2), ast_channel_context(chan2), ast_channel_linkedid(chan2), chan2->amaflags, "IAXPeer/%s", ast_channel_name(chan2));
d = ast_calloc(1, sizeof(*d));
if (!chan1m || !chan2m || !d) {
if (chan1m) {
}
/* Setup the extensions and such */
- ast_copy_string(chan1m->context, chan1->context, sizeof(chan1m->context));
- ast_copy_string(chan1m->exten, chan1->exten, sizeof(chan1m->exten));
+ ast_channel_context_set(chan1m, ast_channel_context(chan1));
+ ast_channel_exten_set(chan1m, ast_channel_exten(chan1));
chan1m->priority = chan1->priority;
ast_do_masquerade(chan1m);
}
/* Setup the extensions and such */
- ast_copy_string(chan2m->context, chan2->context, sizeof(chan2m->context));
- ast_copy_string(chan2m->exten, chan2->exten, sizeof(chan2m->exten));
+ ast_channel_context_set(chan2m, ast_channel_context(chan2));
+ ast_channel_exten_set(chan2m, ast_channel_exten(chan2));
chan2m->priority = chan2->priority;
ast_do_masquerade(chan2m);
if (!ast_strlen_zero(client->musicclass))
ast_channel_musicclass_set(tmp, client->musicclass);
i->owner = tmp;
- ast_copy_string(tmp->context, client->context, sizeof(tmp->context));
- ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
+ ast_channel_context_set(tmp, client->context);
+ ast_channel_exten_set(tmp, i->exten);
/* Don't use ast_set_callerid() here because it will
* generate an unnecessary NewCallerID event */
if (!ast_strlen_zero(i->cid_num)) {
}
ast_set_cc_interfaces_chanvar(chan, reduced_dest);
- exten = ast_strdupa(chan->exten);
- context = ast_strdupa(chan->context);
+ exten = ast_strdupa(ast_channel_exten(chan));
+ context = ast_strdupa(ast_channel_context(chan));
ao2_unlock(p);
pvt_locked = 0;
p->u_owner = ast_module_user_add(p->owner);
p->u_chan = ast_module_user_add(p->chan);
- ast_copy_string(tmp->context, p->context, sizeof(tmp->context));
- ast_copy_string(tmp2->context, p->context, sizeof(tmp2->context));
- ast_copy_string(tmp2->exten, p->exten, sizeof(tmp->exten));
+ ast_channel_context_set(tmp, p->context);
+ ast_channel_context_set(tmp2, p->context);
+ ast_channel_exten_set(tmp2, p->exten);
tmp->priority = 1;
tmp2->priority = 1;
tmp->callgroup = i->callgroup;
tmp->pickupgroup = i->pickupgroup;
ast_channel_call_forward_set(tmp, i->call_forward);
- ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
- ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
+ ast_channel_context_set(tmp, i->context);
+ ast_channel_exten_set(tmp, i->exten);
/* Don't use ast_set_callerid() here because it will
* generate a needless NewCallerID event */
timeout = 0;
len = strlen(p->dtmf_buf);
- if (!ast_ignore_pattern(chan->context, p->dtmf_buf)) {
+ if (!ast_ignore_pattern(ast_channel_context(chan), p->dtmf_buf)) {
/*res = tone_zone_play_tone(p->subs[index].zfd, -1);*/
ast_indicate(chan, -1);
} else {
/*tone_zone_play_tone(p->subs[index].zfd, DAHDI_TONE_DIALTONE);*/
transmit_notify_request(sub, "L/dl");
}
- if (ast_exists_extension(chan, chan->context, p->dtmf_buf, 1, p->cid_num)) {
- if (!res || !ast_matchmore_extension(chan, chan->context, p->dtmf_buf, 1, p->cid_num)) {
+ if (ast_exists_extension(chan, ast_channel_context(chan), p->dtmf_buf, 1, p->cid_num)) {
+ if (!res || !ast_matchmore_extension(chan, ast_channel_context(chan), p->dtmf_buf, 1, p->cid_num)) {
if (getforward) {
/* Record this as the forwarding extension */
ast_copy_string(p->call_forward, p->dtmf_buf, sizeof(p->call_forward));
} else {
/*res = tone_zone_play_tone(p->subs[index].zfd, -1);*/
ast_indicate(chan, -1);
- ast_copy_string(chan->exten, p->dtmf_buf, sizeof(chan->exten));
+ ast_channel_exten_set(chan, p->dtmf_buf);
chan->dialed.number.str = ast_strdup(p->dtmf_buf);
memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
ast_set_callerid(chan,
getforward = 0;
memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
len = 0;
- } else if (ast_parking_ext_valid(p->dtmf_buf, chan, chan->context) &&
+ } else if (ast_parking_ext_valid(p->dtmf_buf, chan, ast_channel_context(chan)) &&
sub->next->owner && ast_bridged_channel(sub->next->owner)) {
/* This is a three way call, the main call being a real channel,
and we're parking the first call. */
ast_masq_park_call_exten(ast_bridged_channel(sub->next->owner), chan,
- p->dtmf_buf, chan->context, 0, NULL);
+ p->dtmf_buf, ast_channel_context(chan), 0, NULL);
ast_verb(3, "Parking call to '%s'\n", ast_channel_name(chan));
break;
} else if (!ast_strlen_zero(p->lastcallerid) && !strcmp(p->dtmf_buf, "*60")) {
len = 0;
memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
timeout = firstdigittimeout;
- } else if (!ast_canmatch_extension(chan, chan->context, p->dtmf_buf, 1,
+ } else if (!ast_canmatch_extension(chan, ast_channel_context(chan), p->dtmf_buf, 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))
&& ((p->dtmf_buf[0] != '*') || (strlen(p->dtmf_buf) > 2))) {
ast_debug(1, "Can't match %s from '%s' in context %s\n", p->dtmf_buf,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, "<Unknown Caller>"),
- chan->context);
+ ast_channel_context(chan));
break;
}
if (!timeout)
timeout = gendigittimeout;
- if (len && !ast_ignore_pattern(chan->context, p->dtmf_buf))
+ if (len && !ast_ignore_pattern(ast_channel_context(chan), p->dtmf_buf))
/*tone_zone_play_tone(p->subs[index].zfd, -1);*/
ast_indicate(chan, -1);
}
if (ast_strlen_zero(ch->bc->dialed.number)) {
dad = "s";
- strcpy(ch->ast->exten, dad);
+ ast_channel_exten_set(ch->ast, dad);
} else {
dad = ch->bc->dialed.number;
}
bc->channel,
bc->nt ? "NT" : "TE",
help->originator == ORG_AST ? "*" : "I",
- ast ? ast->exten : "",
+ ast ? ast_channel_exten(ast) : "",
(ast && ast->caller.id.name.valid && ast->caller.id.name.str)
? ast->caller.id.name.str : "",
(ast && ast->caller.id.number.valid && ast->caller.id.number.str)
bc->redirecting.from.number,
bc->redirecting.to.name,
bc->redirecting.to.number,
- ast ? ast->context : "",
+ ast ? ast_channel_context(ast) : "",
misdn_get_ch_state(help));
if (misdn_debug[bc->port] > 0) {
ast_cli(fd,
" --> hold_port: %d\n"
" --> hold_channel: %d\n",
help->l3id,
- ast->exten,
+ ast_channel_exten(ast),
S_COR(ast->caller.id.name.valid, ast->caller.id.name.str, ""),
S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, ""),
help->hold.port,
);
} else {
ast_cli(a->fd, "* Channel in unknown STATE !!! Exten:%s, Callerid:%s\n",
- ast->exten,
+ ast_channel_exten(ast),
S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, ""));
}
}
misdn_cfg_get(bc->port, MISDN_CFG_CONTEXT, ch->context, sizeof(ch->context));
- ast_copy_string(ast->context, ch->context, sizeof(ast->context));
+ ast_channel_context_set(ast, ch->context);
#ifdef MISDN_1_2
update_pipeline_config(bc);
/* Add configured prefix to dialed.number */
misdn_add_number_prefix(bc->port, bc->dialed.number_type, bc->dialed.number, sizeof(bc->dialed.number));
- ast_copy_string(ast->exten, bc->dialed.number, sizeof(ast->exten));
+ ast_channel_exten_set(ast, bc->dialed.number);
misdn_cfg_get(bc->port, MISDN_CFG_OVERLAP_DIAL, &ch->overlap_dial, sizeof(ch->overlap_dial));
ast_mutex_init(&ch->overlap_tv_lock);
} else {
int match; /* TRUE if the dialed number matches the redirecting to number */
- match = (strcmp(ast->exten, bc->redirecting.to.number) == 0) ? 1 : 0;
+ match = (strcmp(ast_channel_exten(ast), bc->redirecting.to.number) == 0) ? 1 : 0;
if (!bc->div_leg_3_tx_pending
|| !match) {
/* Send DivertingLegInformation1 */
}
AST_LIST_UNLOCK(&misdn_cc_records_db);
- ast_copy_string(ast->exten, newbc->dialed.number, sizeof(ast->exten));
+ ast_channel_exten_set(ast, newbc->dialed.number);
chan_misdn_log(1, port, "* Call completion to: %s\n", newbc->dialed.number);
- chan_misdn_log(2, port, " --> * tech:%s context:%s\n", ast_channel_name(ast), ast->context);
+ chan_misdn_log(2, port, " --> * tech:%s context:%s\n", ast_channel_name(ast), ast_channel_context(ast));
} else
#endif /* defined(AST_MISDN_ENHANCEMENTS) */
{
}
chan_misdn_log(1, port, "* CALL: %s\n", dest);
- chan_misdn_log(2, port, " --> * dialed:%s tech:%s context:%s\n", args.ext, ast_channel_name(ast), ast->context);
+ chan_misdn_log(2, port, " --> * dialed:%s tech:%s context:%s\n", args.ext, ast_channel_name(ast), ast_channel_context(ast));
- ast_copy_string(ast->exten, args.ext, sizeof(ast->exten));
+ ast_channel_exten_set(ast, args.ext);
ast_copy_string(newbc->dialed.number, args.ext, sizeof(newbc->dialed.number));
if (ast_strlen_zero(newbc->caller.name)
if (strlen(bc->dialed.number) < sizeof(bc->dialed.number) - 1) {
strncat(bc->dialed.number, buf, sizeof(bc->dialed.number) - strlen(bc->dialed.number) - 1);
}
- ast_copy_string(p->ast->exten, bc->dialed.number, sizeof(p->ast->exten));
+ ast_channel_exten_set(p->ast, bc->dialed.number);
misdn_lib_send_event(bc, EVENT_INFORMATION);
break;
default:
chan_misdn_log(1, bc->port,
"* IND : HANGUP\tpid:%d context:%s dialed:%s caller:\"%s\" <%s> State:%s\n",
bc->pid,
- ast->context,
- ast->exten,
+ ast_channel_context(ast),
+ ast_channel_exten(ast),
(ast->caller.id.name.valid && ast->caller.id.name.str)
? ast->caller.id.name.str : "",
(ast->caller.id.number.valid && ast->caller.id.number.str)
isdn_lib_stop_dtmf(tmp->bc);
switch (tmp->faxdetect) {
case 1:
- if (strcmp(ast->exten, "fax")) {
+ if (strcmp(ast_channel_exten(ast), "fax")) {
char *context;
char context_tmp[BUFFERSIZE];
misdn_cfg_get(tmp->bc->port, MISDN_CFG_FAXDETECT_CONTEXT, &context_tmp, sizeof(context_tmp));
- context = ast_strlen_zero(context_tmp) ? (ast_strlen_zero(ast->macrocontext) ? ast->context : ast->macrocontext) : context_tmp;
+ context = ast_strlen_zero(context_tmp) ? (ast_strlen_zero(ast_channel_macrocontext(ast)) ? ast_channel_context(ast) : ast_channel_macrocontext(ast)) : context_tmp;
if (ast_exists_extension(ast, context, "fax", 1,
S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, NULL))) {
ast_verb(3, "Redirecting %s to fax extension (context:%s)\n", ast_channel_name(ast), context);
/* Save the DID/DNIS when we transfer the fax call to a "fax" extension */
- pbx_builtin_setvar_helper(ast,"FAXEXTEN",ast->exten);
+ pbx_builtin_setvar_helper(ast,"FAXEXTEN",ast_channel_exten(ast));
if (ast_async_goto(ast, context, "fax", 1)) {
ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(ast), context);
}
} else {
- ast_log(LOG_NOTICE, "Fax detected but no fax extension, context:%s exten:%s\n", context, ast->exten);
+ ast_log(LOG_NOTICE, "Fax detected but no fax extension, context:%s exten:%s\n", context, ast_channel_exten(ast));
}
} else {
ast_debug(1, "Already in a fax extension, not redirecting\n");
if (!ch->dropped_frame_cnt) {
chan_misdn_log(5, ch->bc->port,
"BC not active (nor bridged) dropping: %d frames addr:%x exten:%s cid:%s ch->state:%s bc_state:%d l3id:%x\n",
- frame->samples, ch->bc->addr, ast->exten,
+ frame->samples, ch->bc->addr, ast_channel_exten(ast),
S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, ""),
misdn_get_ch_state(ch), ch->bc->bc_state, ch->bc->l3_id);
}
}
if (f->frametype == AST_FRAME_DTMF) {
- chan_misdn_log(1, 0, "Read DTMF %d from %s\n", f->subclass.integer, who->exten);
+ chan_misdn_log(1, 0, "Read DTMF %d from %s\n", f->subclass.integer, ast_channel_exten(who));
*fo = f;
*rc = who;
tmp->priority = 1;
if (exten) {
- ast_copy_string(tmp->exten, exten, sizeof(tmp->exten));
+ ast_channel_exten_set(tmp, exten);
} else {
chan_misdn_log(1, 0, "misdn_new: no exten given.\n");
}
chan_misdn_log(1, bc->port,
"* RELEASING CHANNEL pid:%d context:%s dialed:%s caller:\"%s\" <%s>\n",
bc->pid,
- ast->context,
- ast->exten,
+ ast_channel_context(ast),
+ ast_channel_exten(ast),
S_COR(ast->caller.id.name.valid, ast->caller.id.name.str, ""),
S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, ""));
char *predial;
struct ast_frame fr;
- predial = ast_strdupa(ast->exten);
+ predial = ast_strdupa(ast_channel_exten(ast));
ch->state = MISDN_DIALING;
chan_misdn_log(1, bc->port,
"* Starting Ast context:%s dialed:%s caller:\"%s\" <%s> with 's' extension\n",
- ast->context,
- ast->exten,
+ ast_channel_context(ast),
+ ast_channel_exten(ast),
(ast->caller.id.name.valid && ast->caller.id.name.str)
? ast->caller.id.name.str : "",
(ast->caller.id.number.valid && ast->caller.id.number.str)
? ast->caller.id.number.str : "");
- strcpy(ast->exten, "s");
+ ast_channel_exten_set(ast, "s");
- if (!ast_canmatch_extension(ast, ast->context, ast->exten, 1, bc->caller.number) || pbx_start_chan(ch) < 0) {
+ if (!ast_canmatch_extension(ast, ast_channel_context(ast), ast_channel_exten(ast), 1, bc->caller.number) || pbx_start_chan(ch) < 0) {
ast = NULL;
bc->out_cause = AST_CAUSE_UNALLOCATED;
hangup_chan(ch, bc);
}
strncat(bc->dialed.number, bc->info_dad, sizeof(bc->dialed.number) - strlen(bc->dialed.number) - 1);
- ast_copy_string(ch->ast->exten, bc->dialed.number, sizeof(ch->ast->exten));
+ ast_channel_exten_set(ch->ast, bc->dialed.number);
/* Check for Pickup Request first */
- if (!strcmp(ch->ast->exten, ast_pickup_ext())) {
+ if (!strcmp(ast_channel_exten(ch->ast), ast_pickup_ext())) {
if (ast_pickup_call(ch->ast)) {
hangup_chan(ch, bc);
} else {
ast_log(LOG_WARNING,
"Extension '%s@%s' can never match. Jumping to 'i' extension. port:%d\n",
bc->dialed.number, ch->context, bc->port);
- strcpy(ch->ast->exten, "i");
+ ast_channel_exten_set(ch->ast, "i");
ch->state = MISDN_DIALING;
start_pbx(ch, bc, ch->ast);
if (ch->state != MISDN_CONNECTED) {
if (digits) {
strncat(bc->dialed.number, bc->info_dad, sizeof(bc->dialed.number) - strlen(bc->dialed.number) - 1);
- ast_copy_string(ch->ast->exten, bc->dialed.number, sizeof(ch->ast->exten));
+ ast_channel_exten_set(ch->ast, bc->dialed.number);
ast_cdr_update(ch->ast);
}
}
/* Check for Pickup Request first */
- if (!strcmp(chan->exten, ast_pickup_ext())) {
+ if (!strcmp(ast_channel_exten(chan), ast_pickup_ext())) {
if (!ch->noautorespond_on_setup) {
/* Sending SETUP_ACK */
misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE);
ast_log(LOG_WARNING,
"Extension '%s@%s' can never match. Jumping to 'i' extension. port:%d\n",
bc->dialed.number, ch->context, bc->port);
- strcpy(ch->ast->exten, "i");
+ ast_channel_exten_set(ch->ast, "i");
misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE);
ch->state = MISDN_DIALING;
start_pbx(ch, bc, chan);
if (!ch->ast) {
break;
}
- ast_copy_string(ch->ast->exten, bc->dialed.number, sizeof(ch->ast->exten));
+ ast_channel_exten_set(ch->ast, bc->dialed.number);
ast_copy_string(bc->info_dad, bc->infos_pending, sizeof(bc->info_dad));
ast_copy_string(bc->infos_pending, "", sizeof(bc->infos_pending));
if (state == AST_STATE_RING)
tmp->rings = 1;
tmp->tech_pvt = i;
- ast_copy_string(tmp->context, context, sizeof(tmp->context));
- ast_copy_string(tmp->exten, "s", sizeof(tmp->exten));
+ ast_channel_context_set(tmp, context);
+ ast_channel_exten_set(tmp, "s");
ast_channel_language_set(tmp, "");
i->owner = tmp;
i->u = ast_module_user_add(tmp);
tmp = ast_ext_ctx(a->argv[2], &ext, &ctx);
if (ctx == NULL) /* supply default context if needed */
- ctx = o->owner->context;
+ ctx = ast_strdupa(ast_channel_context(o->owner));
if (!ast_exists_extension(b, ctx, ext, 1,
S_COR(b->caller.id.number.valid, b->caller.id.number.str, NULL))) {
ast_cli(a->fd, "No such extension exists\n");
if (state == AST_STATE_RING)
tmp->rings = 1;
tmp->tech_pvt = i;
- ast_copy_string(tmp->context, cntx, sizeof(tmp->context));
+ ast_channel_context_set(tmp, cntx);
if (!ast_strlen_zero(i->ext))
- ast_copy_string(tmp->exten, i->ext, sizeof(tmp->exten));
+ ast_channel_exten_set(tmp, i->ext);
else
- strcpy(tmp->exten, "s");
+ ast_channel_exten_set(tmp, "s");
if (!ast_strlen_zero(i->language))
ast_channel_language_set(tmp, i->language);
}
i->owner = tmp;
ast_module_ref(ast_module_info->self);
- ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
+ ast_channel_context_set(tmp, i->context);
/*Since it is valid to have extensions in the dialplan that have unescaped characters in them
* we should decode the uri before storing it in the channel, but leave it encoded in the sip_pvt
* structure so that there aren't issues when forming URI's
}
ast_channel_lock(tmp);
sip_pvt_lock(i);
- ast_copy_string(tmp->exten, exten, sizeof(tmp->exten));
+ ast_channel_exten_set(tmp, exten);
/* Don't use ast_set_callerid() here because it will
* generate an unnecessary NewCallerID event */
/* If we detect a CNG tone and fax detection is enabled then send us off to the fax extension */
if (faxdetected && ast_test_flag(&p->flags[1], SIP_PAGE2_FAX_DETECT_CNG)) {
- if (strcmp(ast->exten, "fax")) {
- const char *target_context = S_OR(ast->macrocontext, ast->context);
+ if (strcmp(ast_channel_exten(ast), "fax")) {
+ const char *target_context = S_OR(ast_channel_macrocontext(ast), ast_channel_context(ast));
/* We need to unlock 'ast' here because
* ast_exists_extension has the potential to start and
* stop an autoservice on the channel. Such action is
ast_channel_lock(ast);
sip_pvt_lock(p);
ast_verb(2, "Redirecting '%s' to fax extension due to CNG detection\n", ast_channel_name(ast));
- pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast->exten);
+ pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast_channel_exten(ast));
if (ast_async_goto(ast, target_context, "fax", 1)) {
ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(ast), target_context);
}
/* If fax detection is enabled then send us off to the fax extension */
if (ast_test_flag(&p->flags[1], SIP_PAGE2_FAX_DETECT_T38)) {
ast_channel_lock(p->owner);
- if (strcmp(p->owner->exten, "fax")) {
- const char *target_context = S_OR(p->owner->macrocontext, p->owner->context);
+ if (strcmp(ast_channel_exten(p->owner), "fax")) {
+ const char *target_context = S_OR(ast_channel_macrocontext(p->owner), ast_channel_context(p->owner));
ast_channel_unlock(p->owner);
if (ast_exists_extension(p->owner, target_context, "fax", 1,
S_COR(p->owner->caller.id.number.valid, p->owner->caller.id.number.str, NULL))) {
ast_verb(2, "Redirecting '%s' to fax extension due to peer T.38 re-INVITE\n", ast_channel_name(p->owner));
- pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", p->owner->exten);
+ pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", ast_channel_exten(p->owner));
if (ast_async_goto(p->owner, target_context, "fax", 1)) {
ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(p->owner), target_context);
}
ast_channel_lock(c);
res = (c->pbx &&
- (!strcasecmp(c->macroexten, p->exten) || !strcasecmp(c->exten, p->exten)) &&
- (sip_cfg.notifycid == IGNORE_CONTEXT || !strcasecmp(c->context, p->context)));
+ (!strcasecmp(ast_channel_macroexten(c), p->exten) || !strcasecmp(ast_channel_exten(c), p->exten)) &&
+ (sip_cfg.notifycid == IGNORE_CONTEXT || !strcasecmp(ast_channel_context(c), p->context)));
ast_channel_unlock(c);
/* By default, use the context in the channel sending the REFER */
if (ast_strlen_zero(transfer_context)) {
- transfer_context = S_OR(transferer->owner->macrocontext,
+ transfer_context = S_OR(ast_channel_macrocontext(transferer->owner),
S_OR(transferer->context, sip_cfg.default_context));
}
/* By default, use the context in the channel sending the REFER */
if (ast_strlen_zero(transfer_context)) {
- transfer_context = S_OR(p->owner->macrocontext,
+ transfer_context = S_OR(ast_channel_macrocontext(p->owner),
S_OR(p->context, sip_cfg.default_context));
}
if (ast_exists_extension(NULL, transfer_context, c, 1, NULL)) {
struct ast_channel *transferee, *transferer;
pthread_t th;
- transferee = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan1), chan1->exten, chan1->context, ast_channel_linkedid(chan1), chan1->amaflags, "Parking/%s", ast_channel_name(chan1));
- transferer = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan2), chan2->exten, chan2->context, ast_channel_linkedid(chan2), chan2->amaflags, "SIPPeer/%s", ast_channel_name(chan2));
+ transferee = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan1), ast_channel_exten(chan1), ast_channel_context(chan1), ast_channel_linkedid(chan1), chan1->amaflags, "Parking/%s", ast_channel_name(chan1));
+ transferer = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan2), ast_channel_exten(chan2), ast_channel_context(chan2), ast_channel_linkedid(chan2), chan2->amaflags, "SIPPeer/%s", ast_channel_name(chan2));
d = ast_calloc(1, sizeof(*d));
if (!transferee || !transferer || !d) {
if (transferee) {
}
/* Setup the extensions and such */
- ast_copy_string(transferee->context, chan1->context, sizeof(transferee->context));
- ast_copy_string(transferee->exten, chan1->exten, sizeof(transferee->exten));
+ ast_channel_context_set(transferee, ast_channel_context(chan1));
+ ast_channel_exten_set(transferee, ast_channel_exten(chan1));
transferee->priority = chan1->priority;
ast_do_masquerade(transferee);
}
/* Setup the extensions and such */
- ast_copy_string(transferer->context, chan2->context, sizeof(transferer->context));
- ast_copy_string(transferer->exten, chan2->exten, sizeof(transferer->exten));
+ ast_channel_context_set(transferer, ast_channel_context(chan2));
+ ast_channel_exten_set(transferer, ast_channel_exten(chan2));
transferer->priority = chan2->priority;
ast_do_masquerade(transferer);
sip_pvt_unlock(p);
/* Parking a call. DO NOT hold any locks while calling ast_parking_ext_valid() */
- if (localtransfer && ast_parking_ext_valid(refer_to, current.chan1, current.chan1->context)) {
+ if (localtransfer && ast_parking_ext_valid(refer_to, current.chan1, ast_channel_context(current.chan1))) {
sip_pvt_lock(p);
ast_clear_flag(&p->flags[0], SIP_GOTREFER);
p->refer->status = REFER_200OK;
}
/* DO NOT hold any locks while calling sip_park */
- if (sip_park(current.chan2, current.chan1, req, seqno, refer_to, current.chan1->context)) {
+ if (sip_park(current.chan2, current.chan1, req, seqno, refer_to, ast_channel_context(current.chan1))) {
sip_pvt_lock(p);
transmit_notify_with_sipfrag(p, seqno, "500 Internal Server Error", TRUE);
} else {
ast_party_number_free(&c->connected.id.number);
ast_party_number_init(&c->connected.id.number);
c->connected.id.number.valid = 1;
- c->connected.id.number.str = ast_strdup(c->exten);
+ c->connected.id.number.str = ast_strdup(ast_channel_exten(c));
ast_party_name_free(&c->connected.id.name);
ast_party_name_init(&c->connected.id.name);
#endif
if (!sub->rtp) {
start_rtp(sub);
}
- ast_verb(3, "Sub %d - Calling %s@%s\n", sub->callid, c->exten, c->context);
+ ast_verb(3, "Sub %d - Calling %s@%s\n", sub->callid, ast_channel_exten(c), ast_channel_context(c));
res = ast_pbx_run(c);
if (res) {
ast_log(LOG_WARNING, "PBX exited non-zero\n");
timeout = 0;
len = strlen(sub->exten);
- if (!ast_ignore_pattern(c->context, sub->exten)) {
+ if (!ast_ignore_pattern(ast_channel_context(c), sub->exten)) {
transmit_stop_tone(d, l->instance, sub->callid);
}
- if (ast_exists_extension(c, c->context, sub->exten, 1, l->cid_num)) {
- if (!res || !ast_matchmore_extension(c, c->context, sub->exten, 1, l->cid_num)) {
+ if (ast_exists_extension(c, ast_channel_context(c), sub->exten, 1, l->cid_num)) {
+ if (!res || !ast_matchmore_extension(c, ast_channel_context(c), sub->exten, 1, l->cid_num)) {
if (l->getforward) {
/* Record this as the forwarding extension */
set_callforwards(l, sub->exten, l->getforward);
ast_hangup(c);
}
return NULL;
- } else if (!ast_canmatch_extension(c, c->context, sub->exten, 1,
+ } else if (!ast_canmatch_extension(c, ast_channel_context(c), sub->exten, 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))
&& ((sub->exten[0] != '*') || (!ast_strlen_zero(sub->exten) > 2))) {
ast_log(LOG_WARNING, "Can't match [%s] from '%s' in context %s\n", sub->exten,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, "<Unknown Caller>"),
- c->context);
+ ast_channel_context(c));
if (d->hookstate == SKINNY_OFFHOOK) {
transmit_start_tone(d, SKINNY_REORDER, l->instance, sub->callid);
/* hang out for 3 seconds to let congestion play */
if (!timeout) {
timeout = gendigittimeout;
}
- if (len && !ast_ignore_pattern(c->context, sub->exten)) {
+ if (len && !ast_ignore_pattern(ast_channel_context(c), sub->exten)) {
ast_indicate(c, -1);
}
}
}
if (subline) {
- ast_copy_string(tmp->context, subline->context, sizeof(tmp->context));
+ ast_channel_context_set(tmp, subline->context);
} else {
- ast_copy_string(tmp->context, l->context, sizeof(tmp->context));
+ ast_channel_context_set(tmp, l->context);
}
- ast_copy_string(tmp->exten, l->exten, sizeof(tmp->exten));
+ ast_channel_exten_set(tmp, l->exten);
/* Don't use ast_set_callerid() here because it will
* generate a needless NewCallerID event */
}
break;
case SUBSTATE_DIALING:
- if (ast_strlen_zero(sub->exten) || !ast_exists_extension(c, c->context, sub->exten, 1, l->cid_num)) {
- ast_log(LOG_WARNING, "Exten (%s)@(%s) does not exist, unable to set substate DIALING on sub %d\n", sub->exten, c->context, sub->callid);
+ if (ast_strlen_zero(sub->exten) || !ast_exists_extension(c, ast_channel_context(c), sub->exten, 1, l->cid_num)) {
+ ast_log(LOG_WARNING, "Exten (%s)@(%s) does not exist, unable to set substate DIALING on sub %d\n", sub->exten, ast_channel_context(c), sub->callid);
return;
}
if (AST_LIST_FIRST(&l->sublines)) {
if (subline) {
- ast_copy_string(c->exten, subline->exten, sizeof(c->exten));
- ast_copy_string(c->context, "sla_stations", sizeof(c->context));
+ ast_channel_exten_set(c, subline->exten);
+ ast_channel_context_set(c, "sla_stations");
} else {
pbx_builtin_setvar_helper(c, "_DESTEXTEN", sub->exten);
- pbx_builtin_setvar_helper(c, "_DESTCONTEXT", c->context);
- ast_copy_string(c->exten, l->dialoutexten, sizeof(c->exten));
- ast_copy_string(c->context, l->dialoutcontext, sizeof(c->context));
+ pbx_builtin_setvar_helper(c, "_DESTCONTEXT", ast_channel_context(c));
+ ast_channel_exten_set(c, l->dialoutexten);
+ ast_channel_context_set(c, l->dialoutcontext);
ast_copy_string(l->lastnumberdialed, sub->exten, sizeof(l->lastnumberdialed));
}
} else {
- ast_copy_string(c->exten, sub->exten, sizeof(c->exten));
+ ast_channel_exten_set(c, sub->exten);
ast_copy_string(l->lastnumberdialed, sub->exten, sizeof(l->lastnumberdialed));
}
int res;
ast_verb(3, "Starting switch on '%s@%s-%d' to %s\n", l->name, l->parent->name, sub->subtype, s->device->phone_number);
- ast_copy_string(chan->exten, s->device->phone_number, sizeof(chan->exten));
+ ast_channel_exten_set(chan, s->device->phone_number);
ast_copy_string(s->device->redial_number, s->device->phone_number,
sizeof(s->device->redial_number));
ast_setstate(chan, AST_STATE_RING);
}
} else if (e->data == VPB_FAX) {
if (!p->faxhandled) {
- if (strcmp(p->owner->exten, "fax")) {
- const char *target_context = S_OR(p->owner->macrocontext, p->owner->context);
+ if (strcmp(ast_channel_exten(p->owner), "fax")) {
+ const char *target_context = S_OR(ast_channel_macrocontext(p->owner), ast_channel_context(p->owner));
if (ast_exists_extension(p->owner, target_context, "fax", 1,
S_COR(p->owner->caller.id.number.valid, p->owner->caller.id.number.str, NULL))) {
ast_verb(3, "Redirecting %s to fax extension\n", ast_channel_name(p->owner));
/* Save the DID/DNIS when we transfer the fax call to a "fax" extension */
- pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", p->owner->exten);
+ pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", ast_channel_exten(p->owner));
if (ast_async_goto(p->owner, target_context, "fax", 1)) {
ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(p->owner), target_context);
}
}
tmp->tech_pvt = me;
- ast_copy_string(tmp->context, context, sizeof(tmp->context));
+ ast_channel_context_set(tmp, context);
if (!ast_strlen_zero(me->ext))
- ast_copy_string(tmp->exten, me->ext, sizeof(tmp->exten));
+ ast_channel_exten_set(tmp, me->ext);
else
- strcpy(tmp->exten, "s");
+ ast_channel_exten_set(tmp, "s");
if (!ast_strlen_zero(me->language))
ast_channel_language_set(tmp, me->language);
/* If we got the first digit, get the rest */
len = 1;
dtmfbuf[len] = '\0';
- while ((len < AST_MAX_EXTENSION-1) && ast_matchmore_extension(chan, chan->context, dtmfbuf, 1, p->cid_num)) {
- if (ast_exists_extension(chan, chan->context, dtmfbuf, 1, p->cid_num)) {
+ while ((len < AST_MAX_EXTENSION-1) && ast_matchmore_extension(chan, ast_channel_context(chan), dtmfbuf, 1, p->cid_num)) {
+ if (ast_exists_extension(chan, ast_channel_context(chan), dtmfbuf, 1, p->cid_num)) {
timeout = analog_matchdigittimeout;
} else {
timeout = analog_gendigittimeout;
analog_dsp_set_digitmode(p, ANALOG_DIGITMODE_DTMF);
- if (ast_exists_extension(chan, chan->context, exten, 1,
+ if (ast_exists_extension(chan, ast_channel_context(chan), exten, 1,
chan->caller.id.number.valid ? chan->caller.id.number.str : NULL)) {
- ast_copy_string(chan->exten, exten, sizeof(chan->exten));
+ ast_channel_exten_set(chan, exten);
analog_dsp_reset_and_flush_digits(p);
res = ast_pbx_run(chan);
if (res) {
}
goto quit;
} else {
- ast_verb(3, "Unknown extension '%s' in context '%s' requested\n", exten, chan->context);
+ ast_verb(3, "Unknown extension '%s' in context '%s' requested\n", exten, ast_channel_context(chan));
sleep(2);
res = analog_play_tone(p, idx, ANALOG_TONE_INFO);
if (res < 0) {
exten[len++]=res;
exten[len] = '\0';
}
- if (!ast_ignore_pattern(chan->context, exten)) {
+ if (!ast_ignore_pattern(ast_channel_context(chan), exten)) {
analog_play_tone(p, idx, -1);
} else {
analog_play_tone(p, idx, ANALOG_TONE_DIALTONE);
}
- if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num) && !ast_parking_ext_valid(exten, chan, chan->context)) {
- if (!res || !ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
+ if (ast_exists_extension(chan, ast_channel_context(chan), exten, 1, p->cid_num) && !ast_parking_ext_valid(exten, chan, ast_channel_context(chan))) {
+ if (!res || !ast_matchmore_extension(chan, ast_channel_context(chan), exten, 1, p->cid_num)) {
if (getforward) {
/* Record this as the forwarding extension */
ast_copy_string(p->call_forward, exten, sizeof(p->call_forward));
getforward = 0;
} else {
res = analog_play_tone(p, idx, -1);
- ast_copy_string(chan->exten, exten, sizeof(chan->exten));
+ ast_channel_exten_set(chan, exten);
if (!ast_strlen_zero(p->cid_num)) {
if (!p->hidecallerid) {
ast_set_callerid(chan, p->cid_num, NULL, p->cid_num);
getforward = 0;
memset(exten, 0, sizeof(exten));
len = 0;
- } else if ((p->transfer || p->canpark) && ast_parking_ext_valid(exten, chan, chan->context) &&
+ } else if ((p->transfer || p->canpark) && ast_parking_ext_valid(exten, chan, ast_channel_context(chan)) &&
p->subs[ANALOG_SUB_THREEWAY].owner &&
ast_bridged_channel(p->subs[ANALOG_SUB_THREEWAY].owner)) {
/* This is a three way call, the main call being a real channel,
and we're parking the first call. */
ast_masq_park_call_exten(
ast_bridged_channel(p->subs[ANALOG_SUB_THREEWAY].owner), chan, exten,
- chan->context, 0, NULL);
+ ast_channel_context(chan), 0, NULL);
ast_verb(3, "Parking call to '%s'\n", ast_channel_name(chan));
break;
} else if (!ast_strlen_zero(p->lastcid_num) && !strcmp(exten, "*60")) {
ast_hangup(chan);
goto quit;
}
- } else if (!ast_canmatch_extension(chan, chan->context, exten, 1,
+ } else if (!ast_canmatch_extension(chan, ast_channel_context(chan), exten, 1,
chan->caller.id.number.valid ? chan->caller.id.number.str : NULL)
&& !analog_canmatch_featurecode(exten)) {
ast_debug(1, "Can't match %s from '%s' in context %s\n", exten,
chan->caller.id.number.valid && chan->caller.id.number.str
? chan->caller.id.number.str : "<Unknown Caller>",
- chan->context);
+ ast_channel_context(chan));
break;
}
if (!timeout) {
timeout = analog_gendigittimeout;
}
- if (len && !ast_ignore_pattern(chan->context, exten)) {
+ if (len && !ast_ignore_pattern(ast_channel_context(chan), exten)) {
analog_play_tone(p, idx, -1);
}
}
if (p->use_smdi && p->smdi_iface) {
smdi_msg = ast_smdi_md_message_wait(p->smdi_iface, ANALOG_SMDI_MD_WAIT_TIMEOUT);
if (smdi_msg != NULL) {
- ast_copy_string(chan->exten, smdi_msg->fwd_st, sizeof(chan->exten));
+ ast_channel_exten_set(chan, smdi_msg->fwd_st);
if (smdi_msg->type == 'B')
pbx_builtin_setvar_helper(chan, "_SMDI_VM_TYPE", "b");
switch (f->subclass.integer) {
case AST_CONTROL_ANSWER:
/* Launch the PBX */
- ast_copy_string(chan->exten, pvt->pri->idleext, sizeof(chan->exten));
- ast_copy_string(chan->context, pvt->pri->idlecontext, sizeof(chan->context));
+ ast_channel_exten_set(chan, pvt->pri->idleext);
+ ast_channel_context_set(chan, pvt->pri->idlecontext);
chan->priority = 1;
- ast_verb(4, "Idle channel '%s' answered, sending to %s@%s\n", ast_channel_name(chan), chan->exten, chan->context);
+ ast_verb(4, "Idle channel '%s' answered, sending to %s@%s\n", ast_channel_name(chan), ast_channel_exten(chan), ast_channel_context(chan));
ast_pbx_run(chan);
/* It's already hungup, return immediately */
return NULL;
ast_copy_string(exten, p->exten, sizeof(exten));
len = strlen(exten);
res = 0;
- while ((len < AST_MAX_EXTENSION-1) && ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
- if (len && !ast_ignore_pattern(chan->context, exten))
+ while ((len < AST_MAX_EXTENSION-1) && ast_matchmore_extension(chan, ast_channel_context(chan), exten, 1, p->cid_num)) {
+ if (len && !ast_ignore_pattern(ast_channel_context(chan), exten))
sig_pri_play_tone(p, -1);
else
sig_pri_play_tone(p, SIG_PRI_TONE_DIALTONE);
- if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num))
+ if (ast_exists_extension(chan, ast_channel_context(chan), exten, 1, p->cid_num))
timeout = pri_matchdigittimeout;
else
timeout = pri_gendigittimeout;
}
}
sig_pri_play_tone(p, -1);
- if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num)) {
+ if (ast_exists_extension(chan, ast_channel_context(chan), exten, 1, p->cid_num)) {
/* Start the real PBX */
- ast_copy_string(chan->exten, exten, sizeof(chan->exten));
+ ast_channel_exten_set(chan, exten);
sig_pri_dsp_reset_and_flush_digits(p);
#if defined(ISSUE_16789)
/*
* early on non-dial through extensions.
*/
if ((p->pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING)
- && !ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
+ && !ast_matchmore_extension(chan, ast_channel_context(chan), exten, 1, p->cid_num)) {
sig_pri_lock_private(p);
if (p->pri->pri) {
pri_grab(p, p->pri);
ast_log(LOG_WARNING, "PBX exited non-zero!\n");
}
} else {
- ast_debug(1, "No such possible extension '%s' in context '%s'\n", exten, chan->context);
+ ast_debug(1, "No such possible extension '%s' in context '%s'\n", exten, ast_channel_context(chan));
chan->hangupcause = AST_CAUSE_UNALLOCATED;
ast_hangup(chan);
p->exten[0] = '\0';
locked_copy_string(chan, buf, ast_channel_peeraccount(chan), len);
else if (!strcasecmp(data, "hangupsource"))
locked_copy_string(chan, buf, ast_channel_hangupsource(chan), len);
- else if (!strcasecmp(data, "appname") && chan->appl)
- locked_copy_string(chan, buf, chan->appl, len);
- else if (!strcasecmp(data, "appdata") && chan->data)
- locked_copy_string(chan, buf, chan->data, len);
- else if (!strcasecmp(data, "exten") && chan->data)
- locked_copy_string(chan, buf, chan->exten, len);
- else if (!strcasecmp(data, "context") && chan->data)
- locked_copy_string(chan, buf, chan->context, len);
- else if (!strcasecmp(data, "userfield") && chan->data)
+ else if (!strcasecmp(data, "appname") && ast_channel_appl(chan))
+ locked_copy_string(chan, buf, ast_channel_appl(chan), len);
+ else if (!strcasecmp(data, "appdata") && ast_channel_data(chan))
+ locked_copy_string(chan, buf, ast_channel_data(chan), len);
+ else if (!strcasecmp(data, "exten") && ast_channel_data(chan))
+ locked_copy_string(chan, buf, ast_channel_exten(chan), len);
+ else if (!strcasecmp(data, "context") && ast_channel_data(chan))
+ locked_copy_string(chan, buf, ast_channel_context(chan), len);
+ else if (!strcasecmp(data, "userfield") && ast_channel_data(chan))
locked_copy_string(chan, buf, ast_channel_userfield(chan), len);
- else if (!strcasecmp(data, "channame") && chan->data)
+ else if (!strcasecmp(data, "channame") && ast_channel_data(chan))
locked_copy_string(chan, buf, ast_channel_name(chan), len);
else if (!strcasecmp(data, "linkedid")) {
ast_channel_lock(chan);
AST_STANDARD_APP_ARGS(args, parse);
if (ast_strlen_zero(args.context)) {
- args.context = chan->context;
+ args.context = ast_strdupa(ast_channel_context(chan));
}
if (ast_strlen_zero(args.extension)) {
* Do not access directly, use ast_bridged_channel(chan) */
struct ast_channel *masq; /*!< Channel that will masquerade as us */
struct ast_channel *masqr; /*!< Who we are masquerading as */
- const char *blockproc; /*!< Procedure causing blocking */
- const char *appl; /*!< Current application */
- const char *data; /*!< Data passed to current application */
+ const char *__do_not_use_blockproc; /*!< Procedure causing blocking */
+ const char *__do_not_use_appl; /*!< Current application */
+ const char *__do_not_use_data; /*!< Data passed to current application */
struct ast_sched_context *sched; /*!< Schedule context */
struct ast_filestream *stream; /*!< Stream itself. */
struct ast_filestream *vstream; /*!< Video Stream itself. */
struct ast_bridge *bridge; /*!< Bridge this channel is participating in */
struct ast_timer *timer; /*!< timer object that provided timingfd */
- char context[AST_MAX_CONTEXT]; /*!< Dialplan: Current extension context */
- char exten[AST_MAX_EXTENSION]; /*!< Dialplan: Current extension number */
- char macrocontext[AST_MAX_CONTEXT]; /*!< Macro: Current non-macro context. See app_macro.c */
- char macroexten[AST_MAX_EXTENSION]; /*!< Macro: Current non-macro extension. See app_macro.c */
+ char __do_not_use_context[AST_MAX_CONTEXT]; /*!< Dialplan: Current extension context */
+ char __do_not_use_exten[AST_MAX_EXTENSION]; /*!< Dialplan: Current extension number */
+ char __do_not_use_macrocontext[AST_MAX_CONTEXT]; /*!< Macro: Current non-macro context. See app_macro.c */
+ char __do_not_use_macroexten[AST_MAX_EXTENSION]; /*!< Macro: Current non-macro extension. See app_macro.c */
char emulate_dtmf_digit; /*!< Digit being emulated */
};
#define CHECK_BLOCKING(c) do { \
if (ast_test_flag(c, AST_FLAG_BLOCKING)) {\
- ast_debug(1, "Thread %ld Blocking '%s', already blocked by thread %ld in procedure %s\n", (long) pthread_self(), ast_channel_name(c), (long) (c)->blocker, (c)->blockproc); \
+ ast_debug(1, "Thread %ld Blocking '%s', already blocked by thread %ld in procedure %s\n", (long) pthread_self(), ast_channel_name(c), (long) (c)->blocker, ast_channel_blockproc(c)); \
} else { \
(c)->blocker = pthread_self(); \
- (c)->blockproc = __PRETTY_FUNCTION__; \
+ ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \
ast_set_flag(c, AST_FLAG_BLOCKING); \
} } while (0)
const char *ast_channel_hangupsource(const struct ast_channel *chan);
const char *ast_channel_dialcontext(const struct ast_channel *chan);
+const char *ast_channel_appl(const struct ast_channel *chan);
+void ast_channel_appl_set(struct ast_channel *chan, const char *value);
+const char *ast_channel_blockproc(const struct ast_channel *chan);
+void ast_channel_blockproc_set(struct ast_channel *chan, const char *value);
+const char *ast_channel_data(const struct ast_channel *chan);
+void ast_channel_data_set(struct ast_channel *chan, const char *value);
+
+const char *ast_channel_context(const struct ast_channel *chan);
+void ast_channel_context_set(struct ast_channel *chan, const char *value);
+const char *ast_channel_exten(const struct ast_channel *chan);
+void ast_channel_exten_set(struct ast_channel *chan, const char *value);
+const char *ast_channel_macrocontext(const struct ast_channel *chan);
+void ast_channel_macrocontext_set(struct ast_channel *chan, const char *value);
+const char *ast_channel_macroexten(const struct ast_channel *chan);
+void ast_channel_macroexten_set(struct ast_channel *chan, const char *value);
#endif /* _ASTERISK_CHANNEL_H */
return -1;
}
- if (!(monitor = cc_extension_monitor_init(S_OR(chan->macroexten, chan->exten), S_OR(chan->macrocontext, chan->context), 0))) {
+ if (!(monitor = cc_extension_monitor_init(S_OR(ast_channel_macroexten(chan), ast_channel_exten(chan)), S_OR(ast_channel_macrocontext(chan), ast_channel_context(chan)), 0))) {
ast_free(interfaces);
return -1;
}
}
/* Situation 2 has occurred */
- if (!(monitor = cc_extension_monitor_init(S_OR(chan->macroexten, chan->exten),
- S_OR(chan->macrocontext, chan->context), interfaces->dial_parent_id))) {
+ if (!(monitor = cc_extension_monitor_init(S_OR(ast_channel_macroexten(chan), ast_channel_exten(chan)),
+ S_OR(ast_channel_macrocontext(chan), ast_channel_context(chan)), interfaces->dial_parent_id))) {
return -1;
}
monitor->core_id = interfaces->core_id;
if (chan->caller.id.name.valid && chan->caller.id.name.str) {
ast_copy_string(generic_pvt->cid_name, chan->caller.id.name.str, sizeof(generic_pvt->cid_name));
}
- ast_copy_string(generic_pvt->exten, S_OR(chan->macroexten, chan->exten), sizeof(generic_pvt->exten));
- ast_copy_string(generic_pvt->context, S_OR(chan->macrocontext, chan->context), sizeof(generic_pvt->context));
+ ast_copy_string(generic_pvt->exten, S_OR(ast_channel_macroexten(chan), ast_channel_exten(chan)), sizeof(generic_pvt->exten));
+ ast_copy_string(generic_pvt->context, S_OR(ast_channel_macrocontext(chan), ast_channel_context(chan)), sizeof(generic_pvt->context));
agent->private_data = generic_pvt;
ast_set_flag(agent, AST_CC_AGENT_SKIP_OFFER);
return 0;
ast_setup_cc_recall_datastore(chan, agent->core_id);
ast_cc_agent_set_interfaces_chanvar(chan);
- ast_copy_string(chan->exten, generic_pvt->exten, sizeof(chan->exten));
- ast_copy_string(chan->context, generic_pvt->context, sizeof(chan->context));
+ ast_channel_exten_set(chan, generic_pvt->exten);
+ ast_channel_context_set(chan, generic_pvt->context);
chan->priority = 1;
pbx_builtin_setvar_helper(chan, "CC_EXTEN", generic_pvt->exten);
ast_copy_string(cdr->accountcode, ast_channel_accountcode(c), sizeof(cdr->accountcode));
ast_copy_string(cdr->peeraccount, ast_channel_peeraccount(c), sizeof(cdr->peeraccount));
/* Destination information */
- ast_copy_string(cdr->dst, S_OR(c->macroexten,c->exten), sizeof(cdr->dst));
- ast_copy_string(cdr->dcontext, S_OR(c->macrocontext,c->context), sizeof(cdr->dcontext));
+ ast_copy_string(cdr->dst, S_OR(ast_channel_macroexten(c),ast_channel_exten(c)), sizeof(cdr->dst));
+ ast_copy_string(cdr->dcontext, S_OR(ast_channel_macrocontext(c),ast_channel_context(c)), sizeof(cdr->dcontext));
/* Unique call identifier */
ast_copy_string(cdr->uniqueid, ast_channel_uniqueid(c), sizeof(cdr->uniqueid));
/* Linked call identifier */
ast_copy_string(cdr->linkedid, ast_channel_linkedid(c), sizeof(cdr->linkedid));
/* Destination information */ /* XXX privilege macro* ? */
- ast_copy_string(cdr->dst, S_OR(c->macroexten, c->exten), sizeof(cdr->dst));
- ast_copy_string(cdr->dcontext, S_OR(c->macrocontext, c->context), sizeof(cdr->dcontext));
+ ast_copy_string(cdr->dst, S_OR(ast_channel_macroexten(c), ast_channel_exten(c)), sizeof(cdr->dst));
+ ast_copy_string(cdr->dcontext, S_OR(ast_channel_macrocontext(c), ast_channel_context(c)), sizeof(cdr->dcontext));
}
}
tchan->redirecting.from.number.str = ast_strdup(record.caller_id_rdnis);
tchan->dialed.number.str = ast_strdup(record.caller_id_dnid);
- ast_copy_string(tchan->exten, record.extension, sizeof(tchan->exten));
- ast_copy_string(tchan->context, record.context, sizeof(tchan->context));
+ ast_channel_exten_set(tchan, record.extension);
+ ast_channel_context_set(tchan, record.context);
ast_channel_name_set(tchan, record.channel_name);
ast_channel_uniqueid_set(tchan, record.unique_id);
ast_channel_linkedid_set(tchan, record.linked_id);
AST_LIST_INSERT_HEAD(headp, newvariable, entries);
}
- tchan->appl = ast_strdup(record.application_name);
- tchan->data = ast_strdup(record.application_data);
+ ast_channel_appl_set(tchan, ast_strdup(record.application_name));
+ ast_channel_data_set(tchan, ast_strdup(record.application_data));
tchan->amaflags = record.amaflag;
return tchan;
if (event_type == AST_CEL_APP_START || event_type == AST_CEL_APP_END) {
char *app;
- if (!(app = ao2_find(appset, (char *) chan->appl, OBJ_POINTER))) {
+ if (!(app = ao2_find(appset, (char *) ast_channel_appl(chan), OBJ_POINTER))) {
ast_mutex_unlock(&reload_lock);
if (peer) {
ast_channel_unref(peer);
S_COR(chan->redirecting.from.number.valid, chan->redirecting.from.number.str, ""),
AST_EVENT_IE_CEL_CIDDNID, AST_EVENT_IE_PLTYPE_STR,
S_OR(chan->dialed.number.str, ""),
- AST_EVENT_IE_CEL_EXTEN, AST_EVENT_IE_PLTYPE_STR, chan->exten,
- AST_EVENT_IE_CEL_CONTEXT, AST_EVENT_IE_PLTYPE_STR, chan->context,
+ AST_EVENT_IE_CEL_EXTEN, AST_EVENT_IE_PLTYPE_STR, ast_channel_exten(chan),
+ AST_EVENT_IE_CEL_CONTEXT, AST_EVENT_IE_PLTYPE_STR, ast_channel_context(chan),
AST_EVENT_IE_CEL_CHANNAME, AST_EVENT_IE_PLTYPE_STR, ast_channel_name(chan),
- AST_EVENT_IE_CEL_APPNAME, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->appl, ""),
- AST_EVENT_IE_CEL_APPDATA, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->data, ""),
+ AST_EVENT_IE_CEL_APPNAME, AST_EVENT_IE_PLTYPE_STR, S_OR(ast_channel_appl(chan), ""),
+ AST_EVENT_IE_CEL_APPDATA, AST_EVENT_IE_PLTYPE_STR, S_OR(ast_channel_data(chan), ""),
AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, chan->amaflags,
AST_EVENT_IE_CEL_ACCTCODE, AST_EVENT_IE_PLTYPE_STR, ast_channel_accountcode(chan),
AST_EVENT_IE_CEL_PEERACCT, AST_EVENT_IE_PLTYPE_STR, ast_channel_peeraccount(chan),
return 0;
/* If the last saved context does not match the current one
OR we have not saved any context so far, then save the current context */
- if ((!AST_LIST_EMPTY(&traced->trace) && strcasecmp(AST_LIST_FIRST(&traced->trace)->context, chan->context)) ||
+ if ((!AST_LIST_EMPTY(&traced->trace) && strcasecmp(AST_LIST_FIRST(&traced->trace)->context, ast_channel_context(chan))) ||
(AST_LIST_EMPTY(&traced->trace))) {
/* Just do some debug logging */
if (AST_LIST_EMPTY(&traced->trace))
- ast_debug(1, "Setting initial trace context to %s\n", chan->context);
+ ast_debug(1, "Setting initial trace context to %s\n", ast_channel_context(chan));
else
- ast_debug(1, "Changing trace context from %s to %s\n", AST_LIST_FIRST(&traced->trace)->context, chan->context);
+ ast_debug(1, "Changing trace context from %s to %s\n", AST_LIST_FIRST(&traced->trace)->context, ast_channel_context(chan));
/* alloc or bail out */
trace = ast_malloc(sizeof(*trace));
if (!trace)
return -1;
/* save the current location and store it in the trace list */
- ast_copy_string(trace->context, chan->context, sizeof(trace->context));
- ast_copy_string(trace->exten, chan->exten, sizeof(trace->exten));
+ ast_copy_string(trace->context, ast_channel_context(chan), sizeof(trace->context));
+ ast_copy_string(trace->exten, ast_channel_exten(chan), sizeof(trace->exten));
trace->priority = chan->priority;
AST_LIST_INSERT_HEAD(&traced->trace, trace, entry);
}
else
ast_channel_accountcode_set(tmp, ast_default_accountcode);
- if (!ast_strlen_zero(context))
- ast_copy_string(tmp->context, context, sizeof(tmp->context));
- else
- strcpy(tmp->context, "default");
-
- if (!ast_strlen_zero(exten))
- ast_copy_string(tmp->exten, exten, sizeof(tmp->exten));
- else
- strcpy(tmp->exten, "s");
-
+ ast_channel_context_set(tmp, S_OR(context, "default"));
+ ast_channel_exten_set(tmp, S_OR(exten, "s"));
tmp->priority = 1;
tmp->cdr = ast_cdr_alloc();
}
ast_channel_lock(chan);
- if (strcasecmp(chan->context, context) && strcasecmp(chan->macrocontext, context)) {
+ if (strcasecmp(ast_channel_context(chan), context) && strcasecmp(ast_channel_macrocontext(chan), context)) {
ret = 0; /* Context match failed, continue */
- } else if (strcasecmp(chan->exten, exten) && strcasecmp(chan->macroexten, exten)) {
+ } else if (strcasecmp(ast_channel_exten(chan), exten) && strcasecmp(ast_channel_macroexten(chan), exten)) {
ret = 0; /* Extension match failed, continue */
}
ast_channel_unlock(chan);
if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd "
"is blocked by thread %ld in procedure %s! Expect a failure\n",
- (long) pthread_self(), ast_channel_name(chan), (long)chan->blocker, chan->blockproc);
+ (long) pthread_self(), ast_channel_name(chan), (long)chan->blocker, ast_channel_blockproc(chan));
ast_assert(ast_test_flag(chan, AST_FLAG_BLOCKING) == 0);
}
if (!was_zombie) {
const char *forward_context;
ast_channel_lock(orig);
forward_context = pbx_builtin_getvar_helper(orig, "FORWARD_CONTEXT");
- snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(orig), S_OR(forward_context, orig->context));
+ snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(orig), S_OR(forward_context, ast_channel_context(orig)));
ast_channel_unlock(orig);
data = tmpchan;
type = "Local";
/* Final fixups */
if (oh) {
if (!ast_strlen_zero(oh->context))
- ast_copy_string(chan->context, oh->context, sizeof(chan->context));
+ ast_channel_context_set(chan, oh->context);
if (!ast_strlen_zero(oh->exten))
- ast_copy_string(chan->exten, oh->exten, sizeof(chan->exten));
+ ast_channel_exten_set(chan, oh->exten);
if (oh->priority)
chan->priority = oh->priority;
}
#endif
#define DATA_EXPORT_CHANNEL(MEMBER) \
- MEMBER(ast_channel, blockproc, AST_DATA_STRING) \
- MEMBER(ast_channel, appl, AST_DATA_STRING) \
- MEMBER(ast_channel, data, AST_DATA_STRING) \
+ MEMBER(ast_channel, __do_not_use_blockproc, AST_DATA_STRING) \
+ MEMBER(ast_channel, __do_not_use_appl, AST_DATA_STRING) \
+ MEMBER(ast_channel, __do_not_use_data, AST_DATA_STRING) \
MEMBER(ast_channel, __do_not_use_name, AST_DATA_STRING) \
MEMBER(ast_channel, __do_not_use_language, AST_DATA_STRING) \
MEMBER(ast_channel, __do_not_use_musicclass, AST_DATA_STRING) \
MEMBER(ast_channel, fout, AST_DATA_UNSIGNED_INTEGER) \
MEMBER(ast_channel, emulate_dtmf_duration, AST_DATA_UNSIGNED_INTEGER) \
MEMBER(ast_channel, visible_indication, AST_DATA_INTEGER) \
- MEMBER(ast_channel, context, AST_DATA_STRING) \
- MEMBER(ast_channel, exten, AST_DATA_STRING) \
- MEMBER(ast_channel, macrocontext, AST_DATA_STRING) \
- MEMBER(ast_channel, macroexten, AST_DATA_STRING)
+ MEMBER(ast_channel, __do_not_use_context, AST_DATA_STRING) \
+ MEMBER(ast_channel, __do_not_use_exten, AST_DATA_STRING) \
+ MEMBER(ast_channel, __do_not_use_macrocontext, AST_DATA_STRING) \
+ MEMBER(ast_channel, __do_not_use_macroexten, AST_DATA_STRING)
AST_DATA_STRUCTURE(ast_channel, DATA_EXPORT_CHANNEL);
DEFINE_STRINGFIELD_GETTER_FOR(parkinglot)
DEFINE_STRINGFIELD_GETTER_FOR(hangupsource)
DEFINE_STRINGFIELD_GETTER_FOR(dialcontext)
+
+const char *ast_channel_appl(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_appl;
+}
+void ast_channel_appl_set(struct ast_channel *chan, const char *value)
+{
+ chan->__do_not_use_appl = value;
+}
+const char *ast_channel_blockproc(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_blockproc;
+}
+void ast_channel_blockproc_set(struct ast_channel *chan, const char *value)
+{
+ chan->__do_not_use_blockproc = value;
+}
+const char *ast_channel_data(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_data;
+}
+void ast_channel_data_set(struct ast_channel *chan, const char *value)
+{
+ chan->__do_not_use_data = value;
+}
+
+
+const char *ast_channel_context(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_context;
+}
+void ast_channel_context_set(struct ast_channel *chan, const char *value)
+{
+ ast_copy_string(chan->__do_not_use_context, value, sizeof(chan->__do_not_use_context));
+}
+const char *ast_channel_exten(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_exten;
+}
+void ast_channel_exten_set(struct ast_channel *chan, const char *value)
+{
+ ast_copy_string(chan->__do_not_use_exten, value, sizeof(chan->__do_not_use_exten));
+}
+const char *ast_channel_macrocontext(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_macrocontext;
+}
+void ast_channel_macrocontext_set(struct ast_channel *chan, const char *value)
+{
+ ast_copy_string(chan->__do_not_use_macrocontext, value, sizeof(chan->__do_not_use_macrocontext));
+}
+const char *ast_channel_macroexten(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_macroexten;
+}
+void ast_channel_macroexten_set(struct ast_channel *chan, const char *value)
+{
+ ast_copy_string(chan->__do_not_use_macroexten, value, sizeof(chan->__do_not_use_macroexten));
+}
}
}
if (concise) {
- ast_cli(a->fd, CONCISE_FORMAT_STRING, ast_channel_name(c), c->context, c->exten, c->priority, ast_state2str(c->_state),
- c->appl ? c->appl : "(None)",
- S_OR(c->data, ""), /* XXX different from verbose ? */
+ ast_cli(a->fd, CONCISE_FORMAT_STRING, ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), c->priority, ast_state2str(c->_state),
+ ast_channel_appl(c) ? ast_channel_appl(c) : "(None)",
+ S_OR(ast_channel_data(c), ""), /* XXX different from verbose ? */
S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""),
S_OR(ast_channel_accountcode(c), ""),
S_OR(ast_channel_peeraccount(c), ""),
bc ? ast_channel_name(bc) : "(None)",
ast_channel_uniqueid(c));
} else if (verbose) {
- ast_cli(a->fd, VERBOSE_FORMAT_STRING, ast_channel_name(c), c->context, c->exten, c->priority, ast_state2str(c->_state),
- c->appl ? c->appl : "(None)",
- c->data ? S_OR(c->data, "(Empty)" ): "(None)",
+ ast_cli(a->fd, VERBOSE_FORMAT_STRING, ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), c->priority, ast_state2str(c->_state),
+ ast_channel_appl(c) ? ast_channel_appl(c) : "(None)",
+ ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)" ): "(None)",
S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""),
durbuf,
S_OR(ast_channel_accountcode(c), ""),
char locbuf[40] = "(None)";
char appdata[40] = "(None)";
- if (!ast_strlen_zero(c->context) && !ast_strlen_zero(c->exten))
- snprintf(locbuf, sizeof(locbuf), "%s@%s:%d", c->exten, c->context, c->priority);
- if (c->appl)
- snprintf(appdata, sizeof(appdata), "%s(%s)", c->appl, S_OR(c->data, ""));
+ if (!ast_strlen_zero(ast_channel_context(c)) && !ast_strlen_zero(ast_channel_exten(c)))
+ snprintf(locbuf, sizeof(locbuf), "%s@%s:%d", ast_channel_exten(c), ast_channel_context(c), c->priority);
+ if (ast_channel_appl(c))
+ snprintf(appdata, sizeof(appdata), "%s(%s)", ast_channel_appl(c), S_OR(ast_channel_data(c), ""));
ast_cli(a->fd, FORMAT_STRING, ast_channel_name(c), locbuf, ast_state2str(c->_state), appdata);
}
}
c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
(long)c->whentohangup.tv_sec,
cdrtime, c->_bridge ? ast_channel_name(c->_bridge) : "<none>", ast_bridged_channel(c) ? ast_channel_name(ast_bridged_channel(c)) : "<none>",
- c->context, c->exten, c->priority, c->callgroup, c->pickupgroup, ( c->appl ? c->appl : "(N/A)" ),
- ( c-> data ? S_OR(c->data, "(Empty)") : "(None)"),
- (ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
+ ast_channel_context(c), ast_channel_exten(c), c->priority, c->callgroup, c->pickupgroup, (ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)" ),
+ (ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)") : "(None)"),
+ (ast_test_flag(c, AST_FLAG_BLOCKING) ? ast_channel_blockproc(c) : "(Not Blocking)"));
if (pbx_builtin_serialize_variables(c, &obuf)) {
ast_str_append(&output, 0, " Variables:\n%s\n", ast_str_buffer(obuf));
cap_request = NULL;
cap_all_audio = ast_format_cap_destroy(cap_all_audio);
- channel->owner->appl = "AppDial2";
- channel->owner->data = "(Outgoing Line)";
+ ast_channel_appl_set(channel->owner, "AppDial2");
+ ast_channel_data_set(channel->owner, "(Outgoing Line)");
memset(&channel->owner->whentohangup, 0, sizeof(channel->owner->whentohangup));
/* Inherit everything from he who spawned this dial */
channel->owner = NULL;
break;
case AST_CONTROL_INCOMPLETE:
- ast_verb(3, "%s dialed Incomplete extension %s\n", ast_channel_name(channel->owner), channel->owner->exten);
+ ast_verb(3, "%s dialed Incomplete extension %s\n", ast_channel_name(channel->owner), ast_channel_exten(channel->owner));
ast_indicate(chan, AST_CONTROL_INCOMPLETE);
break;
case AST_CONTROL_RINGING:
*/
static void set_c_e_p(struct ast_channel *chan, const char *context, const char *ext, int pri)
{
- ast_copy_string(chan->context, context, sizeof(chan->context));
- ast_copy_string(chan->exten, ext, sizeof(chan->exten));
+ ast_channel_context_set(chan, context);
+ ast_channel_exten_set(chan, ext);
chan->priority = pri;
}
struct ast_bridge_thread_obj *tobj = data;
int res;
- tobj->chan->appl = !tobj->return_to_pbx ? "Transferred Call" : "ManagerBridge";
- tobj->chan->data = ast_channel_name(tobj->peer);
- tobj->peer->appl = !tobj->return_to_pbx ? "Transferred Call" : "ManagerBridge";
- tobj->peer->data = ast_channel_name(tobj->chan);
+ ast_channel_appl_set(tobj->chan, !tobj->return_to_pbx ? "Transferred Call" : "ManagerBridge");
+ ast_channel_data_set(tobj->chan, ast_channel_name(tobj->peer));
+ ast_channel_appl_set(tobj->peer, !tobj->return_to_pbx ? "Transferred Call" : "ManagerBridge");
+ ast_channel_data_set(tobj->peer, ast_channel_name(tobj->chan));
ast_bridge_call(tobj->peer, tobj->chan, &tobj->bconfig);
}
}
- chan->appl = "Parked Call";
- chan->data = NULL;
+ ast_channel_appl_set(chan, "Parked Call");
+ ast_channel_data_set(chan, NULL);
pu->chan = chan;
* we set a flag
*/
ast_copy_string(pu->context,
- S_OR(args->return_con, S_OR(chan->macrocontext, chan->context)),
+ S_OR(args->return_con, S_OR(ast_channel_macrocontext(chan), ast_channel_context(chan))),
sizeof(pu->context));
ast_copy_string(pu->exten,
- S_OR(args->return_ext, S_OR(chan->macroexten, chan->exten)),
+ S_OR(args->return_ext, S_OR(ast_channel_macroexten(chan), ast_channel_exten(chan))),
sizeof(pu->exten));
pu->priority = args->return_pri ? args->return_pri :
(chan->macropriority ? chan->macropriority : chan->priority);
struct ast_channel *chan;
/* Make a new, channel that we'll use to masquerade in the real one */
- chan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(rchan), rchan->exten,
- rchan->context, ast_channel_linkedid(rchan), rchan->amaflags, "Parked/%s", ast_channel_name(rchan));
+ chan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(rchan), ast_channel_exten(rchan),
+ ast_channel_context(rchan), ast_channel_linkedid(rchan), rchan->amaflags, "Parked/%s", ast_channel_name(rchan));
if (!chan) {
ast_log(LOG_WARNING, "Unable to create parked channel\n");
if (!ast_test_flag(args, AST_PARK_OPT_SILENCE)) {
}
/* Setup the extensions and such */
- set_c_e_p(chan, rchan->context, rchan->exten, rchan->priority);
+ set_c_e_p(chan, ast_channel_context(rchan), ast_channel_exten(rchan), rchan->priority);
/* Setup the macro extension and such */
- ast_copy_string(chan->macrocontext,rchan->macrocontext,sizeof(chan->macrocontext));
- ast_copy_string(chan->macroexten,rchan->macroexten,sizeof(chan->macroexten));
+ ast_channel_macrocontext_set(chan, ast_channel_macrocontext(rchan));
+ ast_channel_macroexten_set(chan, ast_channel_macroexten(rchan));
chan->macropriority = rchan->macropriority;
/* Manually do the masquerade to make sure it is complete. */
s = pbx_builtin_getvar_helper(transferee, "TRANSFER_CONTEXT");
}
if (ast_strlen_zero(s)) { /* Use the non-macro context to transfer the call XXX ? */
- s = transferer->macrocontext;
+ s = ast_channel_macrocontext(transferer);
}
if (ast_strlen_zero(s)) {
- s = transferer->context;
+ s = ast_channel_context(transferer);
}
return s;
}
xferchan->writeformat = transferee->writeformat;
ast_channel_masquerade(xferchan, transferee);
- ast_explicit_goto(xferchan, transferee->context, transferee->exten, transferee->priority);
+ ast_explicit_goto(xferchan, ast_channel_context(transferee), ast_channel_exten(transferee), transferee->priority);
xferchan->_state = AST_STATE_UP;
ast_clear_flag(xferchan, AST_FLAGS_ALL);
ast_frfree(f);
break;
} else if (f->subclass.integer == AST_CONTROL_INCOMPLETE) {
- ast_verb(3, "%s dialed incomplete extension %s; ignoring\n", ast_channel_name(chan), chan->exten);
+ ast_verb(3, "%s dialed incomplete extension %s; ignoring\n", ast_channel_name(chan), ast_channel_exten(chan));
} else if (f->subclass.integer == AST_CONTROL_CONGESTION) {
state = f->subclass.integer;
ast_verb(3, "%s is congested\n", ast_channel_name(chan));
{
ast_log(LOG_NOTICE, "______ %s (%lx)______\n", title, (unsigned long) chan);
ast_log(LOG_NOTICE, "CHAN: name: %s; appl: %s; data: %s; contxt: %s; exten: %s; pri: %d;\n",
- ast_channel_name(chan), chan->appl, chan->data, chan->context, chan->exten, chan->priority);
+ ast_channel_name(chan), ast_channel_appl(chan), ast_channel_data(chan), ast_channel_context(chan), ast_channel_exten(chan), chan->priority);
ast_log(LOG_NOTICE, "CHAN: acctcode: %s; dialcontext: %s; amaflags: %x; maccontxt: %s; macexten: %s; macpri: %d;\n",
- ast_channel_accountcode(chan), ast_channel_dialcontext(chan), chan->amaflags, chan->macrocontext, chan->macroexten, chan->macropriority);
+ ast_channel_accountcode(chan), ast_channel_dialcontext(chan), chan->amaflags, ast_channel_macrocontext(chan), ast_channel_macroexten(chan), chan->macropriority);
ast_log(LOG_NOTICE, "CHAN: masq: %p; masqr: %p; _bridge: %p; uniqueID: %s; linkedID:%s\n",
chan->masq, chan->masqr,
chan->_bridge, ast_channel_uniqueid(chan), ast_channel_linkedid(chan));
* them to the bridge_cdr instead */
bridge_cdr->next = chan_cdr->next;
chan_cdr->next = NULL;
- ast_copy_string(bridge_cdr->lastapp, S_OR(chan->appl, ""), sizeof(bridge_cdr->lastapp));
- ast_copy_string(bridge_cdr->lastdata, S_OR(chan->data, ""), sizeof(bridge_cdr->lastdata));
+ ast_copy_string(bridge_cdr->lastapp, S_OR(ast_channel_appl(chan), ""), sizeof(bridge_cdr->lastapp));
+ ast_copy_string(bridge_cdr->lastdata, S_OR(ast_channel_data(chan), ""), sizeof(bridge_cdr->lastdata));
if (peer_cdr && !ast_strlen_zero(peer_cdr->userfield)) {
ast_copy_string(bridge_cdr->userfield, peer_cdr->userfield, sizeof(bridge_cdr->userfield));
}
ast_copy_string(bridge_cdr->channel, ast_channel_name(chan), sizeof(bridge_cdr->channel));
ast_copy_string(bridge_cdr->dstchannel, ast_channel_name(peer), sizeof(bridge_cdr->dstchannel));
ast_copy_string(bridge_cdr->uniqueid, ast_channel_uniqueid(chan), sizeof(bridge_cdr->uniqueid));
- ast_copy_string(bridge_cdr->lastapp, S_OR(chan->appl, ""), sizeof(bridge_cdr->lastapp));
- ast_copy_string(bridge_cdr->lastdata, S_OR(chan->data, ""), sizeof(bridge_cdr->lastdata));
+ ast_copy_string(bridge_cdr->lastapp, S_OR(ast_channel_appl(chan), ""), sizeof(bridge_cdr->lastapp));
+ ast_copy_string(bridge_cdr->lastdata, S_OR(ast_channel_data(chan), ""), sizeof(bridge_cdr->lastdata));
ast_cdr_setcid(bridge_cdr, chan);
bridge_cdr->disposition = (chan->_state == AST_STATE_UP) ? AST_CDR_ANSWERED : AST_CDR_NULL;
bridge_cdr->amaflags = chan->amaflags ? chan->amaflags : ast_default_amaflags;
ast_copy_string(bridge_cdr->accountcode, ast_channel_accountcode(chan), sizeof(bridge_cdr->accountcode));
/* Destination information */
- ast_copy_string(bridge_cdr->dst, chan->exten, sizeof(bridge_cdr->dst));
- ast_copy_string(bridge_cdr->dcontext, chan->context, sizeof(bridge_cdr->dcontext));
+ ast_copy_string(bridge_cdr->dst, ast_channel_exten(chan), sizeof(bridge_cdr->dst));
+ ast_copy_string(bridge_cdr->dcontext, ast_channel_context(chan), sizeof(bridge_cdr->dcontext));
if (peer_cdr) {
bridge_cdr->start = peer_cdr->start;
ast_copy_string(bridge_cdr->userfield, peer_cdr->userfield, sizeof(bridge_cdr->userfield));
*/
if (ast_test_flag(&config->features_caller, AST_FEATURE_NO_H_EXTEN)) {
h_context = NULL;
- } else if (ast_exists_extension(chan, chan->context, "h", 1,
+ } else if (ast_exists_extension(chan, ast_channel_context(chan), "h", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
- h_context = chan->context;
- } else if (!ast_strlen_zero(chan->macrocontext)
- && ast_exists_extension(chan, chan->macrocontext, "h", 1,
+ h_context = ast_channel_context(chan);
+ } else if (!ast_strlen_zero(ast_channel_macrocontext(chan))
+ && ast_exists_extension(chan, ast_channel_macrocontext(chan), "h", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
- h_context = chan->macrocontext;
+ h_context = ast_channel_macrocontext(chan);
} else {
h_context = NULL;
}
ast_copy_string(savelastdata, bridge_cdr->lastdata, sizeof(bridge_cdr->lastdata));
chan->cdr = bridge_cdr;
}
- ast_copy_string(save_context, chan->context, sizeof(save_context));
- ast_copy_string(save_exten, chan->exten, sizeof(save_exten));
+ ast_copy_string(save_context, ast_channel_context(chan), sizeof(save_context));
+ ast_copy_string(save_exten, ast_channel_exten(chan), sizeof(save_exten));
save_prio = chan->priority;
- if (h_context != chan->context) {
- ast_copy_string(chan->context, h_context, sizeof(chan->context));
+ if (h_context != ast_channel_context(chan)) {
+ ast_channel_context_set(chan, h_context);
}
- ast_copy_string(chan->exten, "h", sizeof(chan->exten));
+ ast_channel_exten_set(chan, "h");
chan->priority = 1;
ast_channel_unlock(chan);
- while ((spawn_error = ast_spawn_extension(chan, chan->context, chan->exten,
+ while ((spawn_error = ast_spawn_extension(chan, ast_channel_context(chan), ast_channel_exten(chan),
chan->priority,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
&found, 1)) == 0) {
}
if (found && spawn_error) {
/* Something bad happened, or a hangup has been requested. */
- ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", chan->context, chan->exten, chan->priority, ast_channel_name(chan));
- ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", chan->context, chan->exten, chan->priority, ast_channel_name(chan));
+ ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), chan->priority, ast_channel_name(chan));
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), chan->priority, ast_channel_name(chan));
}
/* swap it back */
ast_channel_lock(chan);
- ast_copy_string(chan->context, save_context, sizeof(chan->context));
- ast_copy_string(chan->exten, save_exten, sizeof(chan->exten));
+ ast_channel_context_set(chan, save_context);
+ ast_channel_exten_set(chan, save_exten);
chan->priority = save_prio;
if (bridge_cdr) {
if (chan->cdr == bridge_cdr) {
ast_cel_report_event(pu->chan, AST_CEL_PARK_END, NULL, "ParkedCallTimeOut", NULL);
ast_verb(2, "Timeout for %s parked on %d (%s). Returning to %s,%s,%d\n",
- ast_channel_name(pu->chan), pu->parkingnum, pu->parkinglot->name, pu->chan->context,
- pu->chan->exten, pu->chan->priority);
+ ast_channel_name(pu->chan), pu->parkingnum, pu->parkinglot->name, ast_channel_context(pu->chan),
+ ast_channel_exten(pu->chan), pu->chan->priority);
/* Start up the PBX, or hang them up */
if (ast_pbx_start(chan)) {
* Setup the exten/priority to be s/1 since we don't know where
* this call should return.
*/
- ast_copy_string(orig_exten, chan->exten, sizeof(orig_exten));
+ ast_copy_string(orig_exten, ast_channel_exten(chan), sizeof(orig_exten));
orig_priority = chan->priority;
- strcpy(chan->exten, "s");
+ ast_channel_exten_set(chan, "s");
chan->priority = 1;
/* Park the call */
}
if (res) {
/* Park failed, try to continue in the dialplan. */
- ast_copy_string(chan->exten, orig_exten, sizeof(chan->exten));
+ ast_channel_exten_set(chan, orig_exten);
chan->priority = orig_priority;
res = 0;
} else {
ast_do_masquerade(tmpchan);
/* when returning from bridge, the channel will continue at the next priority */
- ast_explicit_goto(tmpchan, chan->context, chan->exten, chan->priority + 1);
+ ast_explicit_goto(tmpchan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority + 1);
}
/*!
pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "SUCCESS");
if (!ast_check_hangup(final_dest_chan) && !ast_test_flag(&opts, OPT_CALLEE_KILL)) {
ast_debug(1, "starting new PBX in %s,%s,%d for chan %s\n",
- final_dest_chan->context, final_dest_chan->exten,
+ ast_channel_context(final_dest_chan), ast_channel_exten(final_dest_chan),
final_dest_chan->priority, ast_channel_name(final_dest_chan));
if (ast_pbx_start(final_dest_chan) != AST_PBX_SUCCESS) {
/* in the current or specified context being pressed */
if (!context)
- context = c->context;
+ context = ast_channel_context(c);
return waitstream_core(c, NULL, NULL, NULL, 0,
-1, -1, context);
}
S_COR(c->connected.id.name.valid, c->connected.id.name.str, "<unknown>"),
ast_channel_accountcode(c),
c->_state,
- ast_state2str(c->_state), c->context,
- c->exten, c->priority, (long)elapsed_seconds, bridge, ast_channel_uniqueid(c), ast_str_buffer(str), idText);
+ ast_state2str(c->_state), ast_channel_context(c),
+ ast_channel_exten(c), c->priority, (long)elapsed_seconds, bridge, ast_channel_uniqueid(c), ast_str_buffer(str), idText);
} else {
astman_append(s,
"Event: Status\r\n"
"AccountCode: %s\r\n"
"BridgedChannel: %s\r\n"
"BridgedUniqueID: %s\r\n"
- "\r\n", idText, ast_channel_name(c), ast_channel_uniqueid(c), c->context, c->exten, c->priority, c->_state,
- ast_state2str(c->_state), c->appl ? c->appl : "", c->data ? S_OR(c->data, "") : "",
+ "\r\n", idText, ast_channel_name(c), ast_channel_uniqueid(c), ast_channel_context(c), ast_channel_exten(c), c->priority, c->_state,
+ ast_state2str(c->_state), ast_channel_appl(c) ? ast_channel_appl(c) : "", ast_channel_data(c) ? S_OR(ast_channel_data(c), "") : "",
S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""),
S_COR(c->caller.id.name.valid, c->caller.id.name.str, ""),
S_COR(c->connected.id.number.valid, c->connected.id.number.str, ""),
ast_cdr_setapp(c->cdr, app->name, data);
/* save channel values */
- saved_c_appl= c->appl;
- saved_c_data= c->data;
+ saved_c_appl= ast_channel_appl(c);
+ saved_c_data= ast_channel_data(c);
- c->appl = app->name;
- c->data = data;
+ ast_channel_appl_set(c, app->name);
+ ast_channel_data_set(c, data);
ast_cel_report_event(c, AST_CEL_APP_START, NULL, NULL, NULL);
if (app->module)
__ast_module_user_remove(app->module, u);
ast_cel_report_event(c, AST_CEL_APP_END, NULL, NULL, NULL);
/* restore channel values */
- c->appl = saved_c_appl;
- c->data = saved_c_data;
+ ast_channel_appl_set(c, saved_c_appl);
+ ast_channel_data_set(c, saved_c_data);
return res;
}
}
}
} else if (!strcmp(var, "HINT")) {
- s = ast_str_get_hint(str, maxlen, NULL, 0, c, c->context, c->exten) ? ast_str_buffer(*str) : NULL;
+ s = ast_str_get_hint(str, maxlen, NULL, 0, c, ast_channel_context(c), ast_channel_exten(c)) ? ast_str_buffer(*str) : NULL;
} else if (!strcmp(var, "HINTNAME")) {
- s = ast_str_get_hint(NULL, 0, str, maxlen, c, c->context, c->exten) ? ast_str_buffer(*str) : NULL;
+ s = ast_str_get_hint(NULL, 0, str, maxlen, c, ast_channel_context(c), ast_channel_exten(c)) ? ast_str_buffer(*str) : NULL;
} else if (!strcmp(var, "EXTEN")) {
- s = c->exten;
+ s = ast_channel_exten(c);
} else if (!strcmp(var, "CONTEXT")) {
- s = c->context;
+ s = ast_channel_context(c);
} else if (!strcmp(var, "PRIORITY")) {
ast_str_set(str, maxlen, "%d", c->priority);
s = ast_str_buffer(*str);
exception = ds->data;
ast_string_field_set(exception, reason, reason);
- ast_string_field_set(exception, context, chan->context);
- ast_string_field_set(exception, exten, chan->exten);
+ ast_string_field_set(exception, context, ast_channel_context(chan));
+ ast_string_field_set(exception, exten, ast_channel_exten(chan));
exception->priority = chan->priority;
set_ext_pri(chan, "e", priority);
return 0;
ast_log(LOG_WARNING, "No application '%s' for extension (%s, %s, %d)\n", e->app, context, exten, priority);
return -1;
}
- if (c->context != context)
- ast_copy_string(c->context, context, sizeof(c->context));
- if (c->exten != exten)
- ast_copy_string(c->exten, exten, sizeof(c->exten));
+ if (ast_channel_context(c) != context)
+ ast_channel_context_set(c, context);
+ if (ast_channel_exten(c) != exten)
+ ast_channel_exten_set(c, exten);
c->priority = priority;
pbx_substitute_variables(passdata, sizeof(passdata), c, e);
#ifdef CHANNEL_TRACE
"Application: %s\r\n"
"AppData: %s\r\n"
"Uniqueid: %s\r\n",
- ast_channel_name(c), c->context, c->exten, c->priority, app->name, passdata, ast_channel_uniqueid(c));
+ ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), c->priority, app->name, passdata, ast_channel_uniqueid(c));
return pbx_exec(c, app, passdata); /* 0 on success, -1 on failure */
}
} else if (q.swo) { /* not found here, but in another switch */
static void set_ext_pri(struct ast_channel *c, const char *exten, int pri)
{
ast_channel_lock(c);
- ast_copy_string(c->exten, exten, sizeof(c->exten));
+ ast_channel_exten_set(c, exten);
c->priority = pri;
ast_channel_unlock(c);
}
int digit;
buf[pos] = '\0'; /* make sure it is properly terminated */
- while (ast_matchmore_extension(c, c->context, buf, 1,
+ while (ast_matchmore_extension(c, ast_channel_context(c), buf, 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
/* As long as we're willing to wait, and as long as it's not defined,
keep reading digits until we can't possibly get a right answer anymore. */
autoloopflag = ast_test_flag(c, AST_FLAG_IN_AUTOLOOP); /* save value to restore at the end */
ast_set_flag(c, AST_FLAG_IN_AUTOLOOP);
- if (ast_strlen_zero(c->exten)) {
+ if (ast_strlen_zero(ast_channel_exten(c))) {
/* If not successful fall back to 's' - but only if there is no given exten */
- ast_verb(2, "Starting %s at %s,%s,%d failed so falling back to exten 's'\n", ast_channel_name(c), c->context, c->exten, c->priority);
+ ast_verb(2, "Starting %s at %s,%s,%d failed so falling back to exten 's'\n", ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), c->priority);
/* XXX the original code used the existing priority in the call to
* ast_exists_extension(), and reset it to 1 afterwards.
* I believe the correct thing is to set it to 1 immediately.
int timeout = 0;
/* loop on priorities in this context/exten */
- while (!(res = ast_spawn_extension(c, c->context, c->exten, c->priority,
+ while (!(res = ast_spawn_extension(c, ast_channel_context(c), ast_channel_exten(c), c->priority,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL),
&found, 1))) {
if (!ast_check_hangup(c)) {
continue;
}
if (c->_softhangup & AST_SOFTHANGUP_TIMEOUT) {
- if (ast_exists_extension(c, c->context, "T", 1,
+ if (ast_exists_extension(c, ast_channel_context(c), "T", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
set_ext_pri(c, "T", 1);
/* If the AbsoluteTimeout is not reset to 0, we'll get an infinite loop */
memset(&c->whentohangup, 0, sizeof(c->whentohangup));
ast_channel_clear_softhangup(c, AST_SOFTHANGUP_TIMEOUT);
continue;
- } else if (ast_exists_extension(c, c->context, "e", 1,
+ } else if (ast_exists_extension(c, ast_channel_context(c), "e", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
raise_exception(c, "ABSOLUTETIMEOUT", 1);
/* If the AbsoluteTimeout is not reset to 0, we'll get an infinite loop */
break;
}
ast_debug(1, "Extension %s, priority %d returned normally even though call was hung up\n",
- c->exten, c->priority);
+ ast_channel_exten(c), c->priority);
error = 1;
break;
} /* end while - from here on we can use 'break' to go out */
dst_exten[pos++] = digit = res;
dst_exten[pos] = '\0';
} else if (res == AST_PBX_INCOMPLETE) {
- ast_debug(1, "Spawn extension (%s,%s,%d) exited INCOMPLETE on '%s'\n", c->context, c->exten, c->priority, ast_channel_name(c));
- ast_verb(2, "Spawn extension (%s, %s, %d) exited INCOMPLETE on '%s'\n", c->context, c->exten, c->priority, ast_channel_name(c));
+ ast_debug(1, "Spawn extension (%s,%s,%d) exited INCOMPLETE on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited INCOMPLETE on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
/* Don't cycle on incomplete - this will happen if the only extension that matches is our "incomplete" extension */
- if (!ast_matchmore_extension(c, c->context, c->exten, 1,
+ if (!ast_matchmore_extension(c, ast_channel_context(c), ast_channel_exten(c), 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
invalid = 1;
} else {
- ast_copy_string(dst_exten, c->exten, sizeof(dst_exten));
+ ast_copy_string(dst_exten, ast_channel_exten(c), sizeof(dst_exten));
digit = 1;
pos = strlen(dst_exten);
}
} else {
- ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, ast_channel_name(c));
- ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, ast_channel_name(c));
+ ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
if ((res == AST_PBX_ERROR)
- && ast_exists_extension(c, c->context, "e", 1,
+ && ast_exists_extension(c, ast_channel_context(c), "e", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
/* if we are already on the 'e' exten, don't jump to it again */
- if (!strcmp(c->exten, "e")) {
- ast_verb(2, "Spawn extension (%s, %s, %d) exited ERROR while already on 'e' exten on '%s'\n", c->context, c->exten, c->priority, ast_channel_name(c));
+ if (!strcmp(ast_channel_exten(c), "e")) {
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited ERROR while already on 'e' exten on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
error = 1;
} else {
raise_exception(c, "ERROR", 1);
continue;
}
if (c->_softhangup & AST_SOFTHANGUP_TIMEOUT) {
- if (ast_exists_extension(c, c->context, "T", 1,
+ if (ast_exists_extension(c, ast_channel_context(c), "T", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
set_ext_pri(c, "T", 1);
/* If the AbsoluteTimeout is not reset to 0, we'll get an infinite loop */
memset(&c->whentohangup, 0, sizeof(c->whentohangup));
ast_channel_clear_softhangup(c, AST_SOFTHANGUP_TIMEOUT);
continue;
- } else if (ast_exists_extension(c, c->context, "e", 1,
+ } else if (ast_exists_extension(c, ast_channel_context(c), "e", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
raise_exception(c, "ABSOLUTETIMEOUT", 1);
/* If the AbsoluteTimeout is not reset to 0, we'll get an infinite loop */
* and continue, or we can drop out entirely. */
if (invalid
- || !ast_exists_extension(c, c->context, c->exten, 1,
+ || !ast_exists_extension(c, ast_channel_context(c), ast_channel_exten(c), 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
/*!\note
* If there is no match at priority 1, it is not a valid extension anymore.
* Try to continue at "i" (for invalid) or "e" (for exception) or exit if
* neither exist.
*/
- if (ast_exists_extension(c, c->context, "i", 1,
+ if (ast_exists_extension(c, ast_channel_context(c), "i", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
- ast_verb(3, "Sent into invalid extension '%s' in context '%s' on %s\n", c->exten, c->context, ast_channel_name(c));
- pbx_builtin_setvar_helper(c, "INVALID_EXTEN", c->exten);
+ ast_verb(3, "Sent into invalid extension '%s' in context '%s' on %s\n", ast_channel_exten(c), ast_channel_context(c), ast_channel_name(c));
+ pbx_builtin_setvar_helper(c, "INVALID_EXTEN", ast_channel_exten(c));
set_ext_pri(c, "i", 1);
- } else if (ast_exists_extension(c, c->context, "e", 1,
+ } else if (ast_exists_extension(c, ast_channel_context(c), "e", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
raise_exception(c, "INVALID", 1);
} else {
ast_log(LOG_WARNING, "Channel '%s' sent into invalid extension '%s' in context '%s', but no invalid handler\n",
- ast_channel_name(c), c->exten, c->context);
+ ast_channel_name(c), ast_channel_exten(c), ast_channel_context(c));
error = 1; /* we know what to do with it */
break;
}
if (res == AST_PBX_INCOMPLETE && ast_strlen_zero(&dst_exten[pos]))
timeout = 1;
if (!timeout
- && ast_exists_extension(c, c->context, dst_exten, 1,
+ && ast_exists_extension(c, ast_channel_context(c), dst_exten, 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) { /* Prepare the next cycle */
set_ext_pri(c, dst_exten, 1);
} else {
/* No such extension */
if (!timeout && !ast_strlen_zero(dst_exten)) {
/* An invalid extension */
- if (ast_exists_extension(c, c->context, "i", 1,
+ if (ast_exists_extension(c, ast_channel_context(c), "i", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
- ast_verb(3, "Invalid extension '%s' in context '%s' on %s\n", dst_exten, c->context, ast_channel_name(c));
+ ast_verb(3, "Invalid extension '%s' in context '%s' on %s\n", dst_exten, ast_channel_context(c), ast_channel_name(c));
pbx_builtin_setvar_helper(c, "INVALID_EXTEN", dst_exten);
set_ext_pri(c, "i", 1);
- } else if (ast_exists_extension(c, c->context, "e", 1,
+ } else if (ast_exists_extension(c, ast_channel_context(c), "e", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
raise_exception(c, "INVALID", 1);
} else {
ast_log(LOG_WARNING,
"Invalid extension '%s', but no rule 'i' or 'e' in context '%s'\n",
- dst_exten, c->context);
+ dst_exten, ast_channel_context(c));
found = 1; /* XXX disable message */
break;
}
} else {
/* A simple timeout */
- if (ast_exists_extension(c, c->context, "t", 1,
+ if (ast_exists_extension(c, ast_channel_context(c), "t", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
ast_verb(3, "Timeout on %s\n", ast_channel_name(c));
set_ext_pri(c, "t", 1);
- } else if (ast_exists_extension(c, c->context, "e", 1,
+ } else if (ast_exists_extension(c, ast_channel_context(c), "e", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
raise_exception(c, "RESPONSETIMEOUT", 1);
} else {
ast_log(LOG_WARNING,
"Timeout, but no rule 't' or 'e' in context '%s'\n",
- c->context);
+ ast_channel_context(c));
found = 1; /* XXX disable message */
break;
}
if ((!args || !args->no_hangup_chan)
&& !ast_test_flag(c, AST_FLAG_BRIDGE_HANGUP_RUN)
- && ast_exists_extension(c, c->context, "h", 1,
+ && ast_exists_extension(c, ast_channel_context(c), "h", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
set_ext_pri(c, "h", 1);
if (c->cdr && ast_opt_end_cdr_before_h_exten) {
ast_cdr_end(c->cdr);
}
- while ((res = ast_spawn_extension(c, c->context, c->exten, c->priority,
+ while ((res = ast_spawn_extension(c, ast_channel_context(c), ast_channel_exten(c), c->priority,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL),
&found, 1)) == 0) {
c->priority++;
}
if (found && res) {
/* Something bad happened, or a hangup has been requested. */
- ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, ast_channel_name(c));
- ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, ast_channel_name(c));
+ ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
}
}
ast_set2_flag(c, autoloopflag, AST_FLAG_IN_AUTOLOOP);
ast_channel_lock(chan);
if (!ast_strlen_zero(context))
- ast_copy_string(chan->context, context, sizeof(chan->context));
+ ast_channel_context_set(chan, context);
if (!ast_strlen_zero(exten))
- ast_copy_string(chan->exten, exten, sizeof(chan->exten));
+ ast_channel_exten_set(chan, exten);
if (priority > -1) {
chan->priority = priority;
/* see flag description in channel.h for explanation */
* the PBX, we have to make a new channel, masquerade, and start the PBX
* at the new location */
tmpvars.accountcode = ast_strdupa(ast_channel_accountcode(chan));
- tmpvars.exten = ast_strdupa(chan->exten);
- tmpvars.context = ast_strdupa(chan->context);
+ tmpvars.exten = ast_strdupa(ast_channel_exten(chan));
+ tmpvars.context = ast_strdupa(ast_channel_context(chan));
tmpvars.linkedid = ast_strdupa(ast_channel_linkedid(chan));
tmpvars.name = ast_strdupa(ast_channel_name(chan));
tmpvars.amaflags = chan->amaflags;
struct ast_channel *c = ast_dummy_channel_alloc();
if (c) {
- ast_copy_string(c->exten, extension, sizeof(c->exten));
- ast_copy_string(c->context, con->name, sizeof(c->context));
+ ast_channel_exten_set(c, extension);
+ ast_channel_context_set(c, con->name);
}
pbx_substitute_variables_helper(c, application, expand_buf, sizeof(expand_buf));
application = expand_buf;
ast_log(LOG_WARNING, "No such application '%s'\n", as->app);
} else {
if (!ast_strlen_zero(as->context))
- ast_copy_string(chan->context, as->context, sizeof(chan->context));
+ ast_channel_context_set(chan, as->context);
if (!ast_strlen_zero(as->exten))
- ast_copy_string(chan->exten, as->exten, sizeof(chan->exten));
+ ast_channel_exten_set(chan, as->exten);
if (as->priority > 0)
chan->priority = as->priority;
/* Run the PBX */
if (chan) {
char failed_reason[4] = "";
if (!ast_strlen_zero(context))
- ast_copy_string(chan->context, context, sizeof(chan->context));
+ ast_channel_context_set(chan, context);
set_ext_pri(chan, "failed", 1);
ast_set_variables(chan, vars);
snprintf(failed_reason, sizeof(failed_reason), "%d", *reason);
if (ast_check_hangup(chan)) {
/* Call is hungup for some reason. */
res = -1;
- } else if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 1,
+ } else if (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority + 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
ast_verb(3, "Timeout on %s, continuing...\n", ast_channel_name(chan));
- } else if (ast_exists_extension(chan, chan->context, "t", 1,
+ } else if (ast_exists_extension(chan, ast_channel_context(chan), "t", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
ast_verb(3, "Timeout on %s, going to 't'\n", ast_channel_name(chan));
set_ext_pri(chan, "t", 0); /* 0 will become 1, next time through the loop */
- } else if (ast_exists_extension(chan, chan->context, "e", 1,
+ } else if (ast_exists_extension(chan, ast_channel_context(chan), "e", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
raise_exception(chan, "RESPONSETIMEOUT", 0); /* 0 will become 1, next time through the loop */
} else {
ast_log(LOG_WARNING, "Timeout but no rule 't' or 'e' in context '%s'\n",
- chan->context);
+ ast_channel_context(chan));
res = -1;
}
}
if ((context = pbx_builtin_getvar_helper(chan, "MACRO_CONTEXT"))) {
args.context = ast_strdupa(context);
} else {
- args.context = chan->context;
+ args.context = ast_strdupa(ast_channel_context(chan));
}
ast_channel_unlock(chan);
}
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))
&& !ast_matchmore_extension(chan, args.context, exten, 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
- snprintf(chan->exten, sizeof(chan->exten), "%c", res);
- ast_copy_string(chan->context, args.context, sizeof(chan->context));
+ char buf[2] = { 0, };
+ snprintf(buf, sizeof(buf), "%c", res);
+ ast_channel_exten_set(chan, buf);
+ ast_channel_context_set(chan, args.context);
chan->priority = 0;
res = 0;
}
{
int res = ast_parseable_goto(chan, data);
if (!res)
- ast_verb(3, "Goto (%s,%s,%d)\n", chan->context, chan->exten, chan->priority + 1);
+ ast_verb(3, "Goto (%s,%s,%d)\n", ast_channel_context(chan), ast_channel_exten(chan), chan->priority + 1);
return res;
}
} else if (!chan) {
ast_log(LOG_WARNING, "MSet: ignoring entry '%s' with no '='\n", pair.name);
} else {
- ast_log(LOG_WARNING, "MSet: ignoring entry '%s' with no '=' (in %s@%s:%d\n", pair.name, chan->exten, chan->context, chan->priority);
+ ast_log(LOG_WARNING, "MSet: ignoring entry '%s' with no '=' (in %s@%s:%d\n", pair.name, ast_channel_exten(chan), ast_channel_context(chan), chan->priority);
}
}
return -2;
if (context == NULL)
- context = chan->context;
+ context = ast_channel_context(chan);
if (exten == NULL)
- exten = chan->exten;
+ exten = ast_channel_exten(chan);
goto_func = (async) ? ast_async_goto : ast_explicit_goto;
if (ast_exists_extension(chan, context, exten, priority,
pri++;
}
if (sscanf(pri, "%30d", &ipri) != 1) {
- ipri = ast_findlabel_extension(chan, context ? context : chan->context,
- exten ? exten : chan->exten, pri,
+ ipri = ast_findlabel_extension(chan, context ? context : ast_channel_context(chan),
+ exten ? exten : ast_channel_exten(chan), pri,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
if (ipri < 1) {
ast_log(LOG_WARNING, "Priority '%s' must be a number > 0, or valid label\n", pri);
if (!strcasecmp(exten, "s")) {
exten = pbx_builtin_getvar_helper(chan, "ARG1");
if (ast_strlen_zero(exten))
- exten = chan->macroexten;
+ exten = ast_channel_macroexten(chan);
if (ast_strlen_zero(exten))
- exten = chan->exten;
+ exten = ast_channel_exten(chan);
if (ast_strlen_zero(exten)) {
ast_log(LOG_WARNING, "Called in Macro mode with no ARG1 or MACRO_EXTEN?\n");
return -1;
if (!strcasecmp(exten, "s")) {
exten = pbx_builtin_getvar_helper(chan, "ARG1");
if (ast_strlen_zero(exten))
- exten = chan->macroexten;
+ exten = ast_channel_macroexten(chan);
if (ast_strlen_zero(exten))
- exten = chan->exten;
+ exten = ast_channel_exten(chan);
if (ast_strlen_zero(exten)) {
ast_log(LOG_WARNING, "Called in Macro mode with no ARG1 or MACRO_EXTEN?\n");
return -1;
chan = lua_touserdata(L, -1);
lua_pop(L, 1);
- context = ast_strdupa(chan->context);
- exten = ast_strdupa(chan->exten);
+ context = ast_strdupa(ast_channel_context(chan));
+ exten = ast_strdupa(ast_channel_exten(chan));
priority = chan->priority;
lua_concat_args(L, 2, nargs);
return lua_error(L);
}
- if (strcmp(context, chan->context)) {
+ if (strcmp(context, ast_channel_context(chan))) {
lua_pushstring(L, context);
- lua_pushstring(L, chan->context);
+ lua_pushstring(L, ast_channel_context(chan));
lua_pushliteral(L, "context");
- } else if (strcmp(exten, chan->exten)) {
+ } else if (strcmp(exten, ast_channel_exten(chan))) {
lua_pushstring(L, exten);
- lua_pushstring(L, chan->exten);
+ lua_pushstring(L, ast_channel_exten(chan));
lua_pushliteral(L, "exten");
} else if (priority != chan->priority) {
lua_pushinteger(L, priority);
if(!ast_strlen_zero(tmp))
pbx_substitute_variables_helper(chan, tmp, appdata, sizeof(appdata) - 1);
ast_verb(3, "Executing [%s@%s:%d] %s(\"%s\", \"%s\")\n",
- chan->exten, chan->context, chan->priority,
+ ast_channel_exten(chan), ast_channel_context(chan), chan->priority,
term_color(tmp1, app, COLOR_BRCYAN, 0, sizeof(tmp1)),
term_color(tmp2, ast_channel_name(chan), COLOR_BRMAGENTA, 0, sizeof(tmp2)),
term_color(tmp3, S_OR(appdata, ""), COLOR_BRMAGENTA, 0, sizeof(tmp3)));
"Application: %s\r\n"
"AppData: %s\r\n"
"Uniqueid: %s\r\n",
- ast_channel_name(chan), chan->context, chan->exten, chan->priority, app, !ast_strlen_zero(appdata) ? appdata : "(NULL)", ast_channel_uniqueid(chan));
+ ast_channel_name(chan), ast_channel_context(chan), ast_channel_exten(chan), chan->priority, app, !ast_strlen_zero(appdata) ? appdata : "(NULL)", ast_channel_uniqueid(chan));
res = pbx_exec(chan, a, appdata);
} else
S_COR(chan->redirecting.from.number.valid, chan->redirecting.from.number.str, "unknown"));
/* Context information */
- ast_agi_send(fd, chan, "agi_context: %s\n", chan->context);
- ast_agi_send(fd, chan, "agi_extension: %s\n", chan->exten);
+ ast_agi_send(fd, chan, "agi_context: %s\n", ast_channel_context(chan));
+ ast_agi_send(fd, chan, "agi_extension: %s\n", ast_channel_exten(chan));
ast_agi_send(fd, chan, "agi_priority: %d\n", chan->priority);
ast_agi_send(fd, chan, "agi_enhanced: %s\n", enhanced ? "1.0" : "0.0");
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_copy_string(chan->context, argv[2], sizeof(chan->context));
+ ast_channel_context_set(chan, argv[2]);
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
{
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_copy_string(chan->exten, argv[2], sizeof(chan->exten));
+ ast_channel_exten_set(chan, argv[2]);
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
return RESULT_SHOWUSAGE;
if (sscanf(argv[2], "%30d", &pri) != 1) {
- pri = ast_findlabel_extension(chan, chan->context, chan->exten, argv[2],
+ pri = ast_findlabel_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), argv[2],
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
if (pri < 1)
return RESULT_SHOWUSAGE;
if (argv[2])
sscanf(argv[2], "%30d", &level);
- ast_verb(level, "%s: %s\n", chan->data, argv[1]);
+ ast_verb(level, "%s: %s\n", ast_channel_data(chan), argv[1]);
ast_agi_send(agi->fd, chan, "200 result=1\n");
answered = ast_dial_answered_steal(dial);
if (ast_strlen_zero(event->owner->notify_app)) {
- ast_copy_string(answered->context, event->owner->notify_context, sizeof(answered->context));
- ast_copy_string(answered->exten, event->owner->notify_extension, sizeof(answered->exten));
+ ast_channel_context_set(answered, event->owner->notify_context);
+ ast_channel_exten_set(answered, event->owner->notify_extension);
answered->priority = 1;
ast_pbx_run(answered);
}
}
if (result) {
- const char *target_context = S_OR(chan->macrocontext, chan->context);
+ const char *target_context = S_OR(ast_channel_macrocontext(chan), ast_channel_context(chan));
switch (result) {
case 'f':
case 't':
ast_channel_lock(chan);
ast_verb(2, "Redirecting '%s' to fax extension due to %s detection\n",
ast_channel_name(chan), (result == 'f') ? "CNG" : "T38");
- pbx_builtin_setvar_helper(chan, "FAXEXTEN", chan->exten);
+ pbx_builtin_setvar_helper(chan, "FAXEXTEN", ast_channel_exten(chan));
if (ast_async_goto(chan, target_context, "fax", 1)) {
ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(chan), target_context);
}
}
break;
case ASTCHANAPP:
- if (chan->appl) {
- strncpy(string_ret, chan->appl, sizeof(string_ret));
+ if (ast_channel_appl(chan)) {
+ strncpy(string_ret, ast_channel_appl(chan), sizeof(string_ret));
string_ret[sizeof(string_ret) - 1] = '\0';
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
break;
case ASTCHANDATA:
- if (chan->data) {
- strncpy(string_ret, chan->data, sizeof(string_ret));
+ if (ast_channel_data(chan)) {
+ strncpy(string_ret, ast_channel_data(chan), sizeof(string_ret));
string_ret[sizeof(string_ret) - 1] = '\0';
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
break;
case ASTCHANCONTEXT:
- strncpy(string_ret, chan->context, sizeof(string_ret));
+ strncpy(string_ret, ast_channel_context(chan), sizeof(string_ret));
string_ret[sizeof(string_ret) - 1] = '\0';
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
break;
case ASTCHANMACROCONTEXT:
- strncpy(string_ret, chan->macrocontext, sizeof(string_ret));
+ strncpy(string_ret, ast_channel_macrocontext(chan), sizeof(string_ret));
string_ret[sizeof(string_ret) - 1] = '\0';
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
break;
case ASTCHANMACROEXTEN:
- strncpy(string_ret, chan->macroexten, sizeof(string_ret));
+ strncpy(string_ret, ast_channel_macroexten(chan), sizeof(string_ret));
string_ret[sizeof(string_ret) - 1] = '\0';
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
ret = (u_char *)&long_ret;
break;
case ASTCHANEXTEN:
- strncpy(string_ret, chan->exten, sizeof(string_ret));
+ strncpy(string_ret, ast_channel_exten(chan), sizeof(string_ret));
string_ret[sizeof(string_ret) - 1] = '\0';
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
static enum ast_test_result_state test_chan_string(struct ast_test *test,
- struct ast_channel *c, char *cfield, size_t cfieldsize,
- const char *expression)
+ struct ast_channel *c, void (*setter)(struct ast_channel *, const char *),
+ const char *(*getter)(const struct ast_channel *), const char *expression)
{
const char *values[] = { "one", "three", "reallylongdinosaursoundingthingwithwordsinit" };
int i, okay = 1;
struct ast_str *str = ast_str_create(16);
for (i = 0; i < ARRAY_LEN(values); i++) {
- ast_copy_string(cfield, values[i], cfieldsize);
+ setter(c, values[i]);
ast_str_substitute_variables(&str, 0, c, expression);
pbx_substitute_variables_helper(c, expression, workspace, sizeof(workspace));
ast_test_status_update(test, "Testing '%s' . . . . . %s\n",
expression, okay ? "passed" : "FAILED");
- if (strcmp(cfield, ast_str_buffer(str)) != 0 || strcmp(cfield, workspace) != 0) {
- ast_test_status_update(test, "%s != %s != %s\n", cfield, ast_str_buffer(str), workspace);
+ if (strcmp(getter(c), ast_str_buffer(str)) != 0 || strcmp(getter(c), workspace) != 0) {
+ ast_test_status_update(test, "%s != %s != %s\n", getter(c), ast_str_buffer(str), workspace);
okay = 0;
}
}
TEST(test_chan_integer(test, c, &c->dialed.transit_network_select, "${CALLINGTNS}"));
TEST(test_chan_integer(test, c, &c->hangupcause, "${HANGUPCAUSE}"));
TEST(test_chan_integer(test, c, &c->priority, "${PRIORITY}"));
- TEST(test_chan_string(test, c, c->context, sizeof(c->context), "${CONTEXT}"));
- TEST(test_chan_string(test, c, c->exten, sizeof(c->exten), "${EXTEN}"));
+ TEST(test_chan_string(test, c, ast_channel_context_set, ast_channel_context, "${CONTEXT}"));
+ TEST(test_chan_string(test, c, ast_channel_exten_set, ast_channel_exten, "${EXTEN}"));
TEST(test_chan_variable(test, c, "CHANNEL(language)"));
TEST(test_chan_variable(test, c, "CHANNEL(musicclass)"));
TEST(test_chan_variable(test, c, "CHANNEL(parkinglot)"));