diff options
author | Terry Wilson <twilson@digium.com> | 2012-02-13 17:27:06 +0000 |
---|---|---|
committer | Terry Wilson <twilson@digium.com> | 2012-02-13 17:27:06 +0000 |
commit | 34c55e8e7c87a92181fca3e0101dc456eef2475b (patch) | |
tree | ad27fca98a7df582348e14b0aaa42f0065cdef99 /main | |
parent | a955a4770fcdd7874e1337e7df694bcd293e020e (diff) |
Opaquify char * and char[] in ast_channel
Review: https://reviewboard.asterisk.org/r/1733/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@354968 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r-- | main/ccss.c | 14 | ||||
-rw-r--r-- | main/cdr.c | 8 | ||||
-rw-r--r-- | main/cel.c | 18 | ||||
-rw-r--r-- | main/channel.c | 34 | ||||
-rw-r--r-- | main/channel_internal_api.c | 73 | ||||
-rw-r--r-- | main/cli.c | 26 | ||||
-rw-r--r-- | main/dial.c | 6 | ||||
-rw-r--r-- | main/features.c | 98 | ||||
-rw-r--r-- | main/file.c | 2 | ||||
-rw-r--r-- | main/manager.c | 8 | ||||
-rw-r--r-- | main/pbx.c | 154 |
11 files changed, 247 insertions, 194 deletions
diff --git a/main/ccss.c b/main/ccss.c index 39fca0e15..e0925ab0a 100644 --- a/main/ccss.c +++ b/main/ccss.c @@ -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); diff --git a/main/cdr.c b/main/cdr.c index 823f74d85..0c50a13d8 100644 --- a/main/cdr.c +++ b/main/cdr.c @@ -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)); } } diff --git a/main/cel.c b/main/cel.c index f7e28f0ef..feb67ed24 100644 --- a/main/cel.c +++ b/main/cel.c @@ -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), diff --git a/main/channel.c b/main/channel.c index a37f33ac2..bd560f50c 100644 --- a/main/channel.c +++ b/main/channel.c @@ -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; } diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c index 92e2d7e42..6fc116a31 100644 --- a/main/channel_internal_api.c +++ b/main/channel_internal_api.c @@ -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)); +} diff --git a/main/cli.c b/main/cli.c index 69521e1cd..dd4ccf9b9 100644 --- a/main/cli.c +++ b/main/cli.c @@ -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)); diff --git a/main/dial.c b/main/dial.c index a18e06505..528aa18bc 100644 --- a/main/dial.c +++ b/main/dial.c @@ -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: diff --git a/main/features.c b/main/features.c index b95b33db2..bf5282ca8 100644 --- a/main/features.c +++ b/main/features.c @@ -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) { diff --git a/main/file.c b/main/file.c index ee2139c05..3befcaedf 100644 --- a/main/file.c +++ b/main/file.c @@ -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); } diff --git a/main/manager.c b/main/manager.c index 583aafb3f..020ea913f 100644 --- a/main/manager.c +++ b/main/manager.c @@ -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, ""), diff --git a/main/pbx.c b/main/pbx.c index 50224e4de..dfb9e827b 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -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); |