Opaquify char * and char[] in ast_channel
authorTerry Wilson <twilson@digium.com>
Mon, 13 Feb 2012 17:27:06 +0000 (17:27 +0000)
committerTerry Wilson <twilson@digium.com>
Mon, 13 Feb 2012 17:27:06 +0000 (17:27 +0000)
Review: https://reviewboard.asterisk.org/r/1733/

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@354968 65c4cc65-6c06-0410-ace0-fbb531ad65f3

64 files changed:
addons/chan_mobile.c
addons/chan_ooh323.c
apps/app_chanspy.c
apps/app_confbridge.c
apps/app_dial.c
apps/app_directed_pickup.c
apps/app_directory.c
apps/app_dumpchan.c
apps/app_fax.c
apps/app_macro.c
apps/app_meetme.c
apps/app_minivm.c
apps/app_osplookup.c
apps/app_parkandannounce.c
apps/app_queue.c
apps/app_readexten.c
apps/app_rpt.c
apps/app_stack.c
apps/app_talkdetect.c
apps/app_verbose.c
apps/app_voicemail.c
apps/app_while.c
bridges/bridge_builtin_features.c
channels/chan_agent.c
channels/chan_alsa.c
channels/chan_dahdi.c
channels/chan_gtalk.c
channels/chan_h323.c
channels/chan_iax2.c
channels/chan_jingle.c
channels/chan_local.c
channels/chan_mgcp.c
channels/chan_misdn.c
channels/chan_nbs.c
channels/chan_oss.c
channels/chan_phone.c
channels/chan_sip.c
channels/chan_skinny.c
channels/chan_unistim.c
channels/chan_vpb.cc
channels/sig_analog.c
channels/sig_pri.c
funcs/func_channel.c
funcs/func_dialplan.c
include/asterisk/channel.h
main/ccss.c
main/cdr.c
main/cel.c
main/channel.c
main/channel_internal_api.c
main/cli.c
main/dial.c
main/features.c
main/file.c
main/manager.c
main/pbx.c
pbx/pbx_dundi.c
pbx/pbx_lua.c
pbx/pbx_realtime.c
res/res_agi.c
res/res_calendar.c
res/res_fax.c
res/snmp/agent.c
tests/test_substitution.c

index 90b059e..3f849d1 100644 (file)
@@ -3586,7 +3586,7 @@ static int handle_response_cmgr(struct mbl_pvt *pvt, char *buf)
                        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);
 
@@ -3970,7 +3970,7 @@ static void *do_monitor_headset(void *data)
 
                                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);
index e6f45f3..9e550fe 100644 (file)
@@ -436,8 +436,8 @@ static struct ast_channel *ooh323_new(struct ooh323_pvt *i, int state,
                /* 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;
 
@@ -4640,12 +4640,12 @@ struct ast_frame *ooh323_rtp_read(struct ast_channel *ast, struct ooh323_pvt *p)
                        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);
                                }
@@ -4718,12 +4718,12 @@ void onModeChanged(ooCallData *call, int t38mode) {
                        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);
                                        }
index ab78877..b56672d 100644 (file)
@@ -779,10 +779,10 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
                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);
        }
@@ -1186,7 +1186,7 @@ static int extenspy_exec(struct ast_channel *chan, const char *data)
                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];
index 96d1d51..8c03509 100644 (file)
@@ -1727,15 +1727,15 @@ static int action_dialplan_exec(struct ast_bridge_channel *bridge_channel, struc
        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);
@@ -1746,8 +1746,8 @@ static int action_dialplan_exec(struct ast_bridge_channel *bridge_channel, struc
        /*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;
 
index d900f4f..7543bd2 100644 (file)
@@ -763,10 +763,10 @@ static int onedigit_goto(struct ast_channel *chan, const char *context, char ext
                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;
                }
        }
@@ -780,8 +780,8 @@ static const char *get_cid_name(char *name, int namelen, struct ast_channel *cha
        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 : "";
@@ -852,7 +852,7 @@ static void do_forward(struct chanlist *o,
                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";
@@ -912,7 +912,7 @@ static void do_forward(struct chanlist *o,
                        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;
@@ -945,8 +945,8 @@ static void do_forward(struct chanlist *o,
 
                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
@@ -1134,7 +1134,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
                                                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;
                        }
@@ -1208,7 +1208,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
                                                        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);
@@ -1729,7 +1729,7 @@ static int setup_privacy_args(struct privacy_args *pa,
                }
                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;
        }
@@ -1999,7 +1999,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
        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,
@@ -2076,7 +2076,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                        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);
        }
@@ -2084,7 +2084,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
        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);
@@ -2246,8 +2246,8 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                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. */
@@ -2328,11 +2328,11 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
 
 
                /* 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);
@@ -2561,8 +2561,8 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                        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);
@@ -2586,8 +2586,8 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
 
                        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]);
@@ -2657,8 +2657,8 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                                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], ',');
@@ -2828,21 +2828,21 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                        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) {
@@ -2851,8 +2851,8 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
 
                        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 */
                }
@@ -2862,7 +2862,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                                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;
@@ -2976,7 +2976,7 @@ static int retrydial_exec(struct ast_channel *chan, const char *data)
        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);
 
index 4fda832..acdb572 100644 (file)
@@ -288,7 +288,7 @@ static int pickup_exec(struct ast_channel *chan, const char *data)
                                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;
                        }
index a4ec93e..4db404c 100644 (file)
@@ -248,9 +248,9 @@ static int compare(const char *text, const char *template)
 
 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.  "
@@ -292,7 +292,7 @@ static int select_entry(struct ast_channel *chan, const char *dialcontext, const
 
        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'.  "
index c59d32e..8e9c749 100644 (file)
@@ -160,14 +160,14 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
                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;
 }
index e4cf44f..3183a56 100644 (file)
@@ -266,7 +266,7 @@ static void phase_e_handler(t30_state_t *f, void *user_data, int result)
                "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, ""),
index 86017e6..e2b9c92 100644 (file)
@@ -280,7 +280,7 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
        }
        
        /* 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"))) {
@@ -306,7 +306,7 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
        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;
@@ -330,11 +330,11 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
 
        /* 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;
        }
@@ -356,9 +356,8 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
        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);
@@ -376,7 +375,7 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
        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;
@@ -389,11 +388,11 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
                        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));
@@ -410,7 +409,7 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
                /* 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) {
@@ -426,8 +425,8 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
                                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;
                        }
                }
@@ -493,14 +492,14 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
                        }
                }
 
-               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++;
@@ -538,23 +537,23 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
                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;
index 3367068..3c8b73f 100644 (file)
@@ -2592,10 +2592,10 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
                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);
        }
index 3ffe061..9c87a74 100644 (file)
@@ -1942,9 +1942,9 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav
                        /* "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,
@@ -2308,13 +2308,13 @@ static int minivm_greet_exec(struct ast_channel *chan, const char *data)
                                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;
@@ -2326,11 +2326,11 @@ static int minivm_greet_exec(struct ast_channel *chan, const char *data)
                        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;
@@ -2371,24 +2371,22 @@ static int minivm_greet_exec(struct ast_channel *chan, const char *data)
        /* 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;
index 4ce2846..a74d1b5 100644 (file)
@@ -2296,7 +2296,7 @@ static int ospauth_exec(
 
        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 {
index aecd7ce..4b779bd 100644 (file)
@@ -141,10 +141,10 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
                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");
        }
index 12bdb45..2a8b513 100644 (file)
@@ -3173,8 +3173,8 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
        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 */
@@ -3188,8 +3188,8 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
                        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;
        }
@@ -3209,12 +3209,12 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
 
        /* 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 */
@@ -3222,8 +3222,8 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
                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;
@@ -3268,7 +3268,7 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
                        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);
@@ -3689,7 +3689,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
                                                *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";
                                        }
@@ -3726,7 +3726,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
                                                        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;
@@ -4313,7 +4313,7 @@ static void queue_transfer_fixup(void *data, struct ast_channel *old_chan, struc
        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));
@@ -5037,8 +5037,8 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                                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, ',');
@@ -5143,8 +5143,8 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                                        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;
@@ -5172,9 +5172,9 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                        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)) {
index dc2e482..5e6f3ed 100644 (file)
@@ -129,7 +129,7 @@ static int readexten_exec(struct ast_channel *chan, const char *data)
                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");
@@ -145,14 +145,17 @@ static int readexten_exec(struct ast_channel *chan, const char *data)
                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);
index 4dc196e..51fd0fc 100644 (file)
@@ -1380,7 +1380,7 @@ static int priority_jump(struct rpt *myrpt, struct ast_channel *chan)
        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;
@@ -5487,8 +5487,8 @@ struct ast_format_cap *cap = NULL;
                }
        }
 
-       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);
@@ -5825,8 +5825,8 @@ static int connect_link(struct rpt *myrpt, char* node, int mode, int perma)
 #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));
@@ -10408,8 +10408,8 @@ static int attempt_reconnect(struct rpt *myrpt, struct rpt_link *l)
 #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;
@@ -13435,17 +13435,17 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
 #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");
                }
@@ -13824,8 +13824,8 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
 #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);
@@ -13866,8 +13866,8 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
 #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);
index 720ca55..f45c078 100644 (file)
@@ -402,7 +402,7 @@ static int gosub_exec(struct ast_channel *chan, const char *data)
        }
 
        /* 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;
@@ -414,13 +414,13 @@ static int gosub_exec(struct ast_channel *chan, const char *data)
                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;
@@ -605,8 +605,8 @@ static int handle_gosub(struct ast_channel *chan, AGI *agi, int argc, const char
        }
 
        /* 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"))) {
@@ -667,8 +667,8 @@ static int handle_gosub(struct ast_channel *chan, AGI *agi, int argc, const char
        }
 
        /* 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;
index 5259d6f..5c0ee33 100644 (file)
@@ -180,7 +180,7 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
                                        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;
@@ -207,7 +207,7 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
                                                                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;
index c8c6461..14ff2fb 100644 (file)
@@ -155,8 +155,8 @@ static int log_exec(struct ast_channel *chan, const char *data)
        }
 
        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);
        }
index 2b518a2..484f449 100644 (file)
@@ -5800,12 +5800,12 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
                                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;
@@ -5817,11 +5817,11 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
                        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;
@@ -5832,7 +5832,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
                        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);
                        }
@@ -5891,12 +5891,11 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
        /* 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);
@@ -5909,12 +5908,11 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
        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;
@@ -5928,7 +5926,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
        /* 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);
@@ -6020,9 +6018,9 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
                                "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,
@@ -6058,9 +6056,9 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
                                "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,
@@ -7306,32 +7304,32 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
                        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");
@@ -9874,7 +9872,7 @@ static int vm_authenticate(struct ast_channel *chan, char *mailbox, int mailbox_
                } 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;
                        }
@@ -9909,7 +9907,7 @@ static int vm_authenticate(struct ast_channel *chan, char *mailbox, int mailbox_
                        } 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;
@@ -10088,10 +10086,10 @@ static int vm_execmain(struct ast_channel *chan, const char *data)
        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;
@@ -11250,7 +11248,7 @@ static int vmauthenticate(struct ast_channel *chan, const char *data)
                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 */
                }
        }
@@ -13445,9 +13443,9 @@ static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num,
        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;
        }
index 45bd655..25d7c43 100644 (file)
@@ -163,14 +163,14 @@ static int find_matching_endwhile(struct ast_channel *chan)
                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++;
@@ -235,10 +235,10 @@ static int _while_exec(struct ast_channel *chan, const char *data, int end)
        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) {
@@ -271,7 +271,7 @@ static int _while_exec(struct ast_channel *chan, const char *data, int 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);
@@ -280,10 +280,10 @@ static int _while_exec(struct ast_channel *chan, const char *data, int end)
 
        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);
        }
 
@@ -292,10 +292,10 @@ static int _while_exec(struct ast_channel *chan, const char *data, int end)
                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);
index 9da02f1..98a11ca 100644 (file)
@@ -106,7 +106,7 @@ static int feature_blind_transfer(struct ast_bridge *bridge, struct ast_bridge_c
        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)) {
@@ -171,7 +171,7 @@ static int feature_attended_transfer(struct ast_bridge *bridge, struct ast_bridg
        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)) {
index ca9a9ed..a0fd09a 100644 (file)
@@ -1103,9 +1103,9 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state, const char
        }
 #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;
@@ -1119,8 +1119,8 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state, const char
                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);
@@ -1353,7 +1353,7 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
                                /* 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;
index 62d8e52..38ef917 100644 (file)
@@ -578,9 +578,9 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state, const ch
 
        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;
index e6457b1..560fb02 100644 (file)
@@ -1813,7 +1813,7 @@ static int my_distinctive_ring(struct ast_channel *chan, void *pvt, int idx, int
                /* 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 (;;) {
@@ -1889,7 +1889,7 @@ static int my_distinctive_ring(struct ast_channel *chan, void *pvt, int idx, int
                        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;
                        }
@@ -2087,8 +2087,8 @@ static void my_handle_dtmf(void *pvt, struct ast_channel *ast, enum analog_sub a
                                        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
@@ -2102,7 +2102,7 @@ static void my_handle_dtmf(void *pvt, struct ast_channel *ast, enum analog_sub a
                                                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 {
@@ -7840,8 +7840,8 @@ static void dahdi_handle_dtmf(struct ast_channel *ast, int idx, struct ast_frame
                                        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
@@ -7855,7 +7855,7 @@ static void dahdi_handle_dtmf(struct ast_channel *ast, int idx, struct ast_frame
                                                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 {
@@ -9742,7 +9742,7 @@ static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpb
        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);
        }
@@ -9750,7 +9750,7 @@ static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpb
        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);
@@ -10064,8 +10064,8 @@ static void *analog_ss_thread(void *data)
                                /* 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;
@@ -10206,9 +10206,9 @@ static void *analog_ss_thread(void *data)
                        }
                }
 
-               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) {
@@ -10217,7 +10217,7 @@ static void *analog_ss_thread(void *data)
                        }
                        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)
@@ -10259,12 +10259,12 @@ static void *analog_ss_thread(void *data)
                                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));
@@ -10281,7 +10281,7 @@ static void *analog_ss_thread(void *data)
                                                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);
@@ -10399,13 +10399,13 @@ static void *analog_ss_thread(void *data)
                                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")) {
@@ -10457,17 +10457,17 @@ static void *analog_ss_thread(void *data)
                                        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;
@@ -10479,7 +10479,7 @@ static void *analog_ss_thread(void *data)
                        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");
@@ -10670,7 +10670,7 @@ static void *analog_ss_thread(void *data)
                                                /* 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 (;;) {
@@ -10741,7 +10741,7 @@ static void *analog_ss_thread(void *data)
                                                        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;
                                                        }
@@ -10825,7 +10825,7 @@ static void *analog_ss_thread(void *data)
                                        /* 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 */
@@ -10984,7 +10984,7 @@ static void *analog_ss_thread(void *data)
                                                        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;
                                                        }
index 9c1034f..9b41ab1 100644 (file)
@@ -1192,8 +1192,8 @@ static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i,
                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);
index 9aaa85a..388c17c 100644 (file)
@@ -1094,8 +1094,8 @@ static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const c
                /* 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);
index 5789e43..17cc0bb 100644 (file)
@@ -5134,7 +5134,7 @@ static int iax2_call(struct ast_channel *c, const char *dest, int timeout)
                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));
@@ -5199,8 +5199,8 @@ static int iax2_call(struct ast_channel *c, const char *dest, int timeout)
 
        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);
@@ -5850,8 +5850,8 @@ static struct ast_channel *ast_iax2_new(int callno, int state, iax2_format capab
                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
@@ -9389,8 +9389,8 @@ static int iax_park(struct ast_channel *chan1, struct ast_channel *chan2, const
        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) {
@@ -9428,8 +9428,8 @@ static int iax_park(struct ast_channel *chan1, struct ast_channel *chan2, const
        }
 
        /* 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);
@@ -9453,8 +9453,8 @@ static int iax_park(struct ast_channel *chan1, struct ast_channel *chan2, const
        }
 
        /* 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);
index 0278238..9825f73 100644 (file)
@@ -901,8 +901,8 @@ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *
        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)) {
index 27caa38..ba116d0 100644 (file)
@@ -893,8 +893,8 @@ static int local_call(struct ast_channel *ast, const char *dest, int timeout)
        }
        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;
@@ -1173,9 +1173,9 @@ static struct ast_channel *local_new(struct local_pvt *p, int state, const char
        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;
 
index 3005ccb..3b544f6 100644 (file)
@@ -1534,8 +1534,8 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state, cons
                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 */
@@ -2990,7 +2990,7 @@ static void *mgcp_ss(void *data)
                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 {
@@ -2998,8 +2998,8 @@ static void *mgcp_ss(void *data)
                        /*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));
@@ -3021,7 +3021,7 @@ static void *mgcp_ss(void *data)
                                } 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,
@@ -3129,12 +3129,12 @@ static void *mgcp_ss(void *data)
                        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")) {
@@ -3156,17 +3156,17 @@ static void *mgcp_ss(void *data)
                        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);
        }
index 6017ee8..1402c83 100644 (file)
@@ -3626,7 +3626,7 @@ static int misdn_overlap_dial_task(const void *data)
 
        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;
        }
@@ -4149,7 +4149,7 @@ static void print_bc_info(int fd, struct chan_list *help, struct misdn_bchannel
                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)
@@ -4158,7 +4158,7 @@ static void print_bc_info(int fd, struct chan_list *help, struct misdn_bchannel
                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,
@@ -4251,7 +4251,7 @@ static char *handle_cli_misdn_show_channels(struct ast_cli_entry *e, int cmd, st
                                        " --> 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,
@@ -4259,7 +4259,7 @@ static char *handle_cli_misdn_show_channels(struct ast_cli_entry *e, int cmd, st
                                        );
                        } 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, ""));
                        }
                }
@@ -5965,7 +5965,7 @@ static int read_config(struct chan_list *ch)
 
        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);
@@ -6037,7 +6037,7 @@ static int read_config(struct chan_list *ch)
                /* 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);
@@ -6452,7 +6452,7 @@ static void misdn_update_redirecting(struct ast_channel *ast, struct misdn_bchan
        } 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 */
@@ -6569,10 +6569,10 @@ static int misdn_call(struct ast_channel *ast, const char *dest, int timeout)
                }
                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) */
        {
@@ -6591,9 +6591,9 @@ static int misdn_call(struct ast_channel *ast, const char *dest, int timeout)
                }
 
                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)
@@ -6872,7 +6872,7 @@ static int misdn_digit_end(struct ast_channel *ast, char digit, unsigned int dur
                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:
@@ -7139,8 +7139,8 @@ static int misdn_hangup(struct ast_channel *ast)
        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)
@@ -7279,21 +7279,21 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame
                        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");
@@ -7480,7 +7480,7 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame)
                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);
                }
@@ -7594,7 +7594,7 @@ static enum ast_bridge_result misdn_bridge(struct ast_channel *c0,
                }
 
                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;
@@ -8152,7 +8152,7 @@ static struct ast_channel *misdn_new(struct chan_list *chlist, int state,  char
                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");
                }
@@ -8449,8 +8449,8 @@ static void release_chan(struct chan_list *ch, struct misdn_bchannel *bc)
                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, ""));
 
@@ -8617,7 +8617,7 @@ static void do_immediate_setup(struct misdn_bchannel *bc, struct chan_list *ch,
        char *predial;
        struct ast_frame fr;
 
-       predial = ast_strdupa(ast->exten);
+       predial = ast_strdupa(ast_channel_exten(ast));
 
        ch->state = MISDN_DIALING;
 
@@ -8637,16 +8637,16 @@ static void do_immediate_setup(struct misdn_bchannel *bc, struct chan_list *ch,
 
        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);
@@ -10012,10 +10012,10 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                        }
 
                        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 {
@@ -10031,7 +10031,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                                        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);
@@ -10088,7 +10088,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                        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);
                                }
 
@@ -10251,7 +10251,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                }
 
                /* 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);
@@ -10291,7 +10291,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                                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);
@@ -10409,7 +10409,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                        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));
 
index 50a6397..4bb88e6 100644 (file)
@@ -234,8 +234,8 @@ static struct ast_channel *nbs_new(struct nbs_pvt *i, int state, const char *lin
                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);
index 7b75ac4..dc35329 100644 (file)
@@ -1193,7 +1193,7 @@ static char *console_transfer(struct ast_cli_entry *e, int cmd, struct ast_cli_a
 
        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");
index 99dc01c..55f43f3 100644 (file)
@@ -874,11 +874,11 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *cntx,
                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);
 
index 8d6703f..f42a13a 100644 (file)
@@ -7263,7 +7263,7 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
        }
        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
@@ -7276,7 +7276,7 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
        }
        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  */
@@ -7616,8 +7616,8 @@ static struct ast_frame *sip_read(struct ast_channel *ast)
 
        /* 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
@@ -7630,7 +7630,7 @@ static struct ast_frame *sip_read(struct ast_channel *ast)
                                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);
                                }
@@ -9599,13 +9599,13 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
                                /* 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);
                                                        }
@@ -12946,8 +12946,8 @@ static int find_calling_channel(void *obj, void *arg, void *data, int flags)
        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);
 
@@ -16196,7 +16196,7 @@ static int get_refer_info(struct sip_pvt *transferer, struct sip_request *outgoi
 
        /* 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));
        }
 
@@ -16256,7 +16256,7 @@ static int get_also_info(struct sip_pvt *p, struct sip_request *oreq)
 
        /* 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)) {
@@ -22251,8 +22251,8 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
        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) {
@@ -22290,8 +22290,8 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
        }
 
        /* 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);
@@ -22314,8 +22314,8 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
        }
 
        /* 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);
@@ -24362,7 +24362,7 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
        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;
@@ -24391,7 +24391,7 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
                }
 
                /* 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 {
index 69773dc..0bfce4d 100644 (file)
@@ -4235,7 +4235,7 @@ static void *skinny_newcall(void *data)
        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
@@ -4243,7 +4243,7 @@ static void *skinny_newcall(void *data)
        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");
@@ -4286,11 +4286,11 @@ static void *skinny_ss(void *data)
                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);
@@ -4331,12 +4331,12 @@ static void *skinny_ss(void *data)
                                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 */
@@ -4347,7 +4347,7 @@ static void *skinny_ss(void *data)
                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);
                }
        }
@@ -4928,11 +4928,11 @@ static struct ast_channel *skinny_new(struct skinny_line *l, struct skinny_subli
                }
 
                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 */
@@ -5201,8 +5201,8 @@ static void setsubstate(struct skinny_subchannel *sub, int state)
                }
                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;
                }
 
@@ -5222,17 +5222,17 @@ static void setsubstate(struct skinny_subchannel *sub, int state)
 
                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));
                }
                
index 563d1f1..6eca792 100644 (file)
@@ -2056,7 +2056,7 @@ static void *unistim_ss(void *data)
        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);
index cd9d434..9a5a126 100644 (file)
@@ -896,14 +896,14 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
                        }
                } 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);
                                                }
@@ -2469,11 +2469,11 @@ static struct ast_channel *vpb_new(struct vpb_pvt *me, enum ast_channel_state st
                }
                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);
 
index 67ed694..ecb62b9 100644 (file)
@@ -1908,8 +1908,8 @@ static void *__analog_ss_thread(void *data)
                                /* 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;
@@ -2059,9 +2059,9 @@ static void *__analog_ss_thread(void *data)
 
                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) {
@@ -2070,7 +2070,7 @@ static void *__analog_ss_thread(void *data)
                        }
                        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) {
@@ -2116,13 +2116,13 @@ static void *__analog_ss_thread(void *data)
                                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));
@@ -2140,7 +2140,7 @@ static void *__analog_ss_thread(void *data)
                                                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);
@@ -2265,14 +2265,14 @@ static void *__analog_ss_thread(void *data)
                                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")) {
@@ -2332,19 +2332,19 @@ static void *__analog_ss_thread(void *data)
                                        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);
                        }
                }
@@ -2356,7 +2356,7 @@ static void *__analog_ss_thread(void *data)
                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");
index bfdcb10..28a6406 100644 (file)
@@ -1829,10 +1829,10 @@ static void *do_idle_thread(void *v_pvt)
                        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;
@@ -1884,12 +1884,12 @@ static void *pri_ss_thread(void *data)
        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;
@@ -1925,9 +1925,9 @@ static void *pri_ss_thread(void *data)
                }
        }
        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)
                /*
@@ -1943,7 +1943,7 @@ static void *pri_ss_thread(void *data)
                 * 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);
@@ -1964,7 +1964,7 @@ static void *pri_ss_thread(void *data)
                        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';
index c45a012..a792b89 100644 (file)
@@ -350,17 +350,17 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
                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);
index 06ba583..904eede 100644 (file)
@@ -136,7 +136,7 @@ static int acf_isexten_exec(struct ast_channel *chan, const char *cmd, char *par
        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)) {
index ca41856..34b2b3c 100644 (file)
@@ -785,9 +785,9 @@ struct ast_channel {
                                                         *   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. */
@@ -900,10 +900,10 @@ struct ast_channel {
        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 */
 };
 
@@ -2471,10 +2471,10 @@ static inline enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *c
 
 #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)
 
@@ -3630,4 +3630,19 @@ const char *ast_channel_parkinglot(const struct ast_channel *chan);
 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 */
index 39fca0e..e0925ab 100644 (file)
@@ -1981,7 +1981,7 @@ static int cc_interfaces_datastore_init(struct ast_channel *chan) {
                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;
        }
@@ -2298,8 +2298,8 @@ int ast_cc_call_init(struct ast_channel *chan, int *ignore_cc)
        }
 
        /* 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;
@@ -2514,8 +2514,8 @@ static int cc_generic_agent_init(struct ast_cc_agent *agent, struct ast_channel
        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;
@@ -2684,8 +2684,8 @@ static void *generic_recall(void *data)
        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);
index 823f74d..0c50a13 100644 (file)
@@ -935,8 +935,8 @@ int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *c)
                        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 */
@@ -1124,8 +1124,8 @@ int ast_cdr_update(struct ast_channel *c)
                        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));
                }
        }
 
index f7e28f0..feb67ed 100644 (file)
@@ -462,8 +462,8 @@ struct ast_channel *ast_cel_fabricate_channel_from_event(const struct ast_event
        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);
@@ -475,8 +475,8 @@ struct ast_channel *ast_cel_fabricate_channel_from_event(const struct ast_event
                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;
@@ -512,7 +512,7 @@ int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event
 
        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);
@@ -561,11 +561,11 @@ int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event
                        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),
index a37f33a..bd560f5 100644 (file)
@@ -517,20 +517,20 @@ static int ast_channel_trace_data_update(struct ast_channel *chan, struct ast_ch
                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);
        }
@@ -1088,16 +1088,8 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
        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();
@@ -1452,9 +1444,9 @@ static int ast_channel_by_exten_cb(void *obj, void *arg, void *data, int flags)
        }
 
        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);
@@ -2662,7 +2654,7 @@ int ast_hangup(struct ast_channel *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) {
@@ -5245,7 +5237,7 @@ struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_chan
                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";
@@ -5444,9 +5436,9 @@ struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_c
        /* 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;
        }
index 92e2d7e..6fc116a 100644 (file)
@@ -52,9 +52,9 @@ AST_DATA_STRUCTURE(ast_callerid, DATA_EXPORT_CALLERID);
 #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)                   \
@@ -75,10 +75,10 @@ AST_DATA_STRUCTURE(ast_callerid, DATA_EXPORT_CALLERID);
        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);
 
@@ -293,3 +293,62 @@ DEFINE_STRINGFIELD_GETTER_FOR(linkedid)
 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));
+}
index 69521e1..dd4ccf9 100644 (file)
@@ -914,9 +914,9 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
                                }                               
                        }
                        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), ""),
@@ -925,9 +925,9 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
                                        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), ""),
@@ -937,10 +937,10 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
                                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);
                        }
                }
@@ -1495,9 +1495,9 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
                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));
index a18e065..528aa18 100644 (file)
@@ -270,8 +270,8 @@ static int begin_dial_channel(struct ast_dial_channel *channel, struct ast_chann
        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 */
@@ -413,7 +413,7 @@ static void handle_frame(struct ast_dial *dial, struct ast_dial_channel *channel
                        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:
index b95b33d..bf5282c 100644 (file)
@@ -837,8 +837,8 @@ static int parkinglot_cmp_cb(void *obj, void *arg, int flags)
  */
 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;
 }
 
@@ -918,10 +918,10 @@ static void *bridge_call_thread(void *data)
        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);
 
@@ -1398,8 +1398,8 @@ static int park_call_full(struct ast_channel *chan, struct ast_channel *peer, st
                }
        }
 
-       chan->appl = "Parked Call";
-       chan->data = NULL;
+       ast_channel_appl_set(chan, "Parked Call");
+       ast_channel_data_set(chan, NULL);
 
        pu->chan = chan;
 
@@ -1466,10 +1466,10 @@ static int park_call_full(struct ast_channel *chan, struct ast_channel *peer, st
         * 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);
@@ -1635,8 +1635,8 @@ static int masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, s
        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)) {
@@ -1687,11 +1687,11 @@ static int masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, s
        }
 
        /* 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. */
@@ -2231,10 +2231,10 @@ static const char *real_ctx(struct ast_channel *transferer, struct ast_channel *
                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;  
 }
@@ -2725,7 +2725,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
        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);
 
@@ -3582,7 +3582,7 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller,
                                        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));
@@ -3699,9 +3699,9 @@ void ast_channel_log(char *title, struct ast_channel *chan) /* for debug, this i
 {
        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));
@@ -3950,8 +3950,8 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
                         * 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));
                        }
@@ -3962,15 +3962,15 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
                        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));
@@ -4305,13 +4305,13 @@ before_you_go:
         */
        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;
        }
@@ -4346,17 +4346,17 @@ before_you_go:
                        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) {
@@ -4364,14 +4364,14 @@ before_you_go:
                }
                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) {
@@ -4686,8 +4686,8 @@ static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds,
                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))  {
@@ -4977,9 +4977,9 @@ static int park_call_exec(struct ast_channel *chan, const char *data)
         * 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 */
@@ -5009,7 +5009,7 @@ static int park_call_exec(struct ast_channel *chan, const char *data)
        }
        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 {
@@ -6823,7 +6823,7 @@ static void do_bridge_masquerade(struct ast_channel *chan, struct ast_channel *t
        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);
 }
 
 /*!
@@ -7636,7 +7636,7 @@ static int bridge_exec(struct ast_channel *chan, const char *data)
        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) {
index ee2139c..3befcae 100644 (file)
@@ -1410,7 +1410,7 @@ int ast_waitstream_exten(struct ast_channel *c, const char *context)
        /* 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);
 }
index 583aafb..020ea91 100644 (file)
@@ -3357,8 +3357,8 @@ static int action_status(struct mansession *s, const struct message *m)
                        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"
@@ -4605,8 +4605,8 @@ static int action_coreshowchannels(struct mansession *s, const struct message *m
                        "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, ""),
index 50224e4..dfb9e82 100644 (file)
@@ -1533,11 +1533,11 @@ int pbx_exec(struct ast_channel *c,     /*!< Channel */
                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)
@@ -1553,8 +1553,8 @@ int pbx_exec(struct ast_channel *c,       /*!< Channel */
                __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;
 }
 
@@ -3306,13 +3306,13 @@ const char *ast_str_retrieve_variable(struct ast_str **str, ssize_t maxlen, stru
                                }
                        }
                } 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);
@@ -3436,8 +3436,8 @@ static int raise_exception(struct ast_channel *chan, const char *reason, int pri
                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;
@@ -4359,10 +4359,10 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
                                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
@@ -4386,7 +4386,7 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
                                        "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 */
@@ -5057,7 +5057,7 @@ int ast_spawn_extension(struct ast_channel *c, const char *context, const char *
 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);
 }
@@ -5074,7 +5074,7 @@ static int collect_digits(struct ast_channel *c, int waittime, char *buf, int bu
        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.  */
@@ -5119,9 +5119,9 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
        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.
@@ -5143,7 +5143,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
                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)) {
@@ -5157,14 +5157,14 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *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 */
@@ -5178,7 +5178,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
                                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 */
@@ -5190,28 +5190,28 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
                                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);
@@ -5224,14 +5224,14 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *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 */
@@ -5259,24 +5259,24 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
                 * 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;
                        }
@@ -5309,41 +5309,41 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
                        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;
                                        }
@@ -5368,21 +5368,21 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
 
        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);
@@ -8293,9 +8293,9 @@ int ast_explicit_goto(struct ast_channel *chan, const char *context, const char
        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 */
@@ -8337,8 +8337,8 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
         * 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;
@@ -8660,8 +8660,8 @@ static int ast_add_extension2_lockopt(struct ast_context *con,
                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;
@@ -8884,9 +8884,9 @@ static void *async_wait(void *data)
                                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 */
@@ -9022,7 +9022,7 @@ int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, const c
                                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);
@@ -9849,19 +9849,19 @@ static int pbx_builtin_waitexten(struct ast_channel *chan, const char *data)
                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;
                }
        }
@@ -9908,7 +9908,7 @@ static int pbx_builtin_background(struct ast_channel *chan, const char *data)
                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);
        }
@@ -9979,8 +9979,10 @@ static int pbx_builtin_background(struct ast_channel *chan, const char *data)
                        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;
        }
@@ -9996,7 +9998,7 @@ static int pbx_builtin_goto(struct ast_channel *chan, const char *data)
 {
        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;
 }
 
@@ -10221,7 +10223,7 @@ int pbx_builtin_setvar_multiple(struct ast_channel *chan, const char *vdata)
                } 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);
                }
        }
 
@@ -10687,9 +10689,9 @@ static int __ast_goto_if_exists(struct ast_channel *chan, const char *context, c
                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,
@@ -10742,8 +10744,8 @@ static int pbx_parseable_goto(struct ast_channel *chan, const char *goto_string,
                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);
index 2b7f71d..1a7f15c 100644 (file)
@@ -4541,9 +4541,9 @@ static int dundi_helper(struct ast_channel *chan, const char *context, const cha
                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;
@@ -4593,9 +4593,9 @@ static int dundi_exec(struct ast_channel *chan, const char *context, const char
                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;
index 7ddebbb..276e4f5 100644 (file)
@@ -212,8 +212,8 @@ static int lua_pbx_exec(lua_State *L)
        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);
@@ -246,13 +246,13 @@ static int lua_pbx_exec(lua_State *L)
                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);
index 83fe85e..0ec850c 100644 (file)
@@ -352,7 +352,7 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch
                                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)));
@@ -364,7 +364,7 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch
                                                          "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
index 2ad1023..511f440 100644 (file)
@@ -1742,8 +1742,8 @@ static void setup_env(struct ast_channel *chan, char *request, int fd, int enhan
                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");
 
@@ -2207,7 +2207,7 @@ static int handle_setcontext(struct ast_channel *chan, AGI *agi, int argc, const
 
        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;
 }
@@ -2216,7 +2216,7 @@ static int handle_setextension(struct ast_channel *chan, AGI *agi, int argc, con
 {
        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;
 }
@@ -2229,7 +2229,7 @@ static int handle_setpriority(struct ast_channel *chan, AGI *agi, int argc, cons
                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;
@@ -2632,7 +2632,7 @@ static int handle_verbose(struct ast_channel *chan, AGI *agi, int argc, const ch
        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");
 
index 14846d3..382d34e 100644 (file)
@@ -791,8 +791,8 @@ static void *do_notify(void *data)
 
                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);
                }
index 35c03f3..28b46a3 100644 (file)
@@ -3357,7 +3357,7 @@ static struct ast_frame *fax_detect_framehook(struct ast_channel *chan, struct a
        }
 
        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':
@@ -3367,7 +3367,7 @@ static struct ast_frame *fax_detect_framehook(struct ast_channel *chan, struct a
                                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);
                                }
index 71f0213..9d02a7a 100644 (file)
@@ -329,35 +329,35 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le
                }
                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;
@@ -367,7 +367,7 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le
                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;
index 8faf3d3..645d69d 100644 (file)
@@ -70,8 +70,8 @@ static enum ast_test_result_state test_chan_integer(struct ast_test *test,
 }
 
 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;
@@ -79,13 +79,13 @@ static enum ast_test_result_state test_chan_string(struct ast_test *test,
        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;
                }
        }
@@ -234,8 +234,8 @@ AST_TEST_DEFINE(test_substitution)
        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)"));