summaryrefslogtreecommitdiff
path: root/apps/app_fax.c
diff options
context:
space:
mode:
authorTerry Wilson <twilson@digium.com>2012-01-09 22:15:50 +0000
committerTerry Wilson <twilson@digium.com>2012-01-09 22:15:50 +0000
commit04da92c3799e546fa4d84bdaeebd499fb64aea7a (patch)
tree9617b8b2d6d06f96ba27c0baefc5b93eb9e3bc5b /apps/app_fax.c
parent64d1b247c407de2af029392a6c32a99bf11c7ded (diff)
Replace direct access to channel name with accessor functions
There are many benefits to making the ast_channel an opaque handle, from increasing maintainability to presenting ways to kill masquerades. This patch kicks things off by taking things a field at a time, renaming the field to '__do_not_use_${fieldname}' and then writing setters/getters and converting the existing code to using them. When all fields are done, we can move ast_channel to a C file from channel.h and lop off the '__do_not_use_'. This patch sets up main/channel_interal_api.c to be the only file that actually accesses the ast_channel's fields directly. The intent would be for any API functions in channel.c to use the accessor functions. No more monkeying around with channel internals. We should use our own APIs. The interesting changes in this patch are the addition of channel_internal_api.c, the moving of the AST_DATA stuff from channel.c to channel_internal_api.c (note: the AST_DATA stuff will have to be reworked to use accessor functions when ast_channel is really opaque), and some re-working of the way channel iterators/callbacks are handled so as to avoid creating fake ast_channels on the stack to pass in matching data by directly accessing fields (since "name" is a stringfield and the fake channel doesn't init the stringfields, you can't use the ast_channel_name_set() function). I went with ast_channel_name(chan) for a getter, and ast_channel_name_set(chan, name) for a setter. The majority of the grunt-work for this change was done by writing a semantic patch using Coccinelle ( http://coccinelle.lip6.fr/ ). Review: https://reviewboard.asterisk.org/r/1655/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@350223 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_fax.c')
-rw-r--r--apps/app_fax.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/apps/app_fax.c b/apps/app_fax.c
index 5285ba833..e4cf44f62 100644
--- a/apps/app_fax.c
+++ b/apps/app_fax.c
@@ -265,7 +265,7 @@ static void phase_e_handler(t30_state_t *f, void *user_data, int result)
"Resolution: %d\r\n"
"TransferRate: %d\r\n"
"FileName: %s\r\n",
- s->chan->name,
+ ast_channel_name(s->chan),
s->chan->exten,
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, ""),
@@ -350,7 +350,7 @@ static int fax_generator_generate(struct ast_channel *chan, void *data, int len,
AST_FRAME_SET_BUFFER(&outf, buffer, AST_FRIENDLY_OFFSET, len * sizeof(int16_t));
if (ast_write(chan, &outf) < 0) {
- ast_log(LOG_WARNING, "Failed to write frame to '%s': %s\n", chan->name, strerror(errno));
+ ast_log(LOG_WARNING, "Failed to write frame to '%s': %s\n", ast_channel_name(chan), strerror(errno));
return -1;
}
}
@@ -408,11 +408,11 @@ static int transmit_audio(fax_session *s)
unsigned int timeout = 5000;
int ms;
- ast_debug(1, "Negotiating T.38 for receive on %s\n", s->chan->name);
+ ast_debug(1, "Negotiating T.38 for receive on %s\n", ast_channel_name(s->chan));
while (timeout > 0) {
ms = ast_waitfor(s->chan, 1000);
if (ms < 0) {
- ast_log(LOG_WARNING, "something bad happened while channel '%s' was polling.\n", s->chan->name);
+ ast_log(LOG_WARNING, "something bad happened while channel '%s' was polling.\n", ast_channel_name(s->chan));
return -1;
}
if (!ms) {
@@ -421,7 +421,7 @@ static int transmit_audio(fax_session *s)
timeout -= 1000;
continue;
} else {
- ast_log(LOG_WARNING, "channel '%s' timed-out during the T.38 negotiation.\n", s->chan->name);
+ ast_log(LOG_WARNING, "channel '%s' timed-out during the T.38 negotiation.\n", ast_channel_name(s->chan));
break;
}
}
@@ -435,14 +435,14 @@ static int transmit_audio(fax_session *s)
switch (parameters->request_response) {
case AST_T38_NEGOTIATED:
- ast_debug(1, "Negotiated T.38 for receive on %s\n", s->chan->name);
+ ast_debug(1, "Negotiated T.38 for receive on %s\n", ast_channel_name(s->chan));
res = 1;
break;
case AST_T38_REFUSED:
- ast_log(LOG_WARNING, "channel '%s' refused to negotiate T.38\n", s->chan->name);
+ ast_log(LOG_WARNING, "channel '%s' refused to negotiate T.38\n", ast_channel_name(s->chan));
break;
default:
- ast_log(LOG_ERROR, "channel '%s' failed to negotiate T.38\n", s->chan->name);
+ ast_log(LOG_ERROR, "channel '%s' failed to negotiate T.38\n", ast_channel_name(s->chan));
break;
}
ast_frfree(inf);
@@ -594,12 +594,12 @@ static int transmit_audio(fax_session *s)
done:
if (original_write_fmt.id != AST_FORMAT_SLINEAR) {
if (ast_set_write_format(s->chan, &original_write_fmt) < 0)
- ast_log(LOG_WARNING, "Unable to restore write format on '%s'\n", s->chan->name);
+ ast_log(LOG_WARNING, "Unable to restore write format on '%s'\n", ast_channel_name(s->chan));
}
if (original_read_fmt.id != AST_FORMAT_SLINEAR) {
if (ast_set_read_format(s->chan, &original_read_fmt) < 0)
- ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", s->chan->name);
+ ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", ast_channel_name(s->chan));
}
return res;
@@ -735,11 +735,11 @@ disable_t38:
unsigned int timeout = 5000;
int ms;
- ast_debug(1, "Shutting down T.38 on %s\n", s->chan->name);
+ ast_debug(1, "Shutting down T.38 on %s\n", ast_channel_name(s->chan));
while (timeout > 0) {
ms = ast_waitfor(s->chan, 1000);
if (ms < 0) {
- ast_log(LOG_WARNING, "something bad happened while channel '%s' was polling.\n", s->chan->name);
+ ast_log(LOG_WARNING, "something bad happened while channel '%s' was polling.\n", ast_channel_name(s->chan));
return -1;
}
if (!ms) {
@@ -748,7 +748,7 @@ disable_t38:
timeout -= 1000;
continue;
} else {
- ast_log(LOG_WARNING, "channel '%s' timed-out during the T.38 shutdown.\n", s->chan->name);
+ ast_log(LOG_WARNING, "channel '%s' timed-out during the T.38 shutdown.\n", ast_channel_name(s->chan));
break;
}
}
@@ -762,13 +762,13 @@ disable_t38:
switch (parameters->request_response) {
case AST_T38_TERMINATED:
- ast_debug(1, "Shut down T.38 on %s\n", s->chan->name);
+ ast_debug(1, "Shut down T.38 on %s\n", ast_channel_name(s->chan));
break;
case AST_T38_REFUSED:
- ast_log(LOG_WARNING, "channel '%s' refused to disable T.38\n", s->chan->name);
+ ast_log(LOG_WARNING, "channel '%s' refused to disable T.38\n", ast_channel_name(s->chan));
break;
default:
- ast_log(LOG_ERROR, "channel '%s' failed to disable T.38\n", s->chan->name);
+ ast_log(LOG_ERROR, "channel '%s' failed to disable T.38\n", ast_channel_name(s->chan));
break;
}
ast_frfree(inf);
@@ -802,7 +802,7 @@ static int transmit(fax_session *s)
* Theoretically asterisk should already have answered before running the app */
res = ast_answer(s->chan);
if (res) {
- ast_log(LOG_WARNING, "Could not answer channel '%s'\n", s->chan->name);
+ ast_log(LOG_WARNING, "Could not answer channel '%s'\n", ast_channel_name(s->chan));
return res;
}
}