ast_channel opaquification of pointers and integral types

Review: https://reviewboard.asterisk.org/r/1753/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@356042 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Terry Wilson
2012-02-20 23:43:27 +00:00
parent 25e5eb3b96
commit 57f42bd74f
123 changed files with 2902 additions and 2423 deletions

View File

@@ -1043,8 +1043,8 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
chan->redirecting.from.number.valid = 1;
ast_free(chan->redirecting.from.number.str);
chan->redirecting.from.number.str = ast_strdup(value);
if (chan->cdr) {
ast_cdr_setcid(chan->cdr, chan);
if (ast_channel_cdr(chan)) {
ast_cdr_setcid(ast_channel_cdr(chan), chan);
}
} else if (!strcasecmp("dnid", member.argv[0])) {
ast_party_dialed_set_init(&dialed, &chan->dialed);
@@ -1063,8 +1063,8 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
dialed.number.str = ast_strdup(value);
ast_trim_blanks(dialed.number.str);
ast_party_dialed_set(&chan->dialed, &dialed);
if (chan->cdr) {
ast_cdr_setcid(chan->cdr, chan);
if (ast_channel_cdr(chan)) {
ast_cdr_setcid(ast_channel_cdr(chan), chan);
}
} else if (member.argc == 3 && !strcasecmp("plan", member.argv[2])) {
/* dnid-num-plan */
@@ -1073,8 +1073,8 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
if (('0' <= val[0]) && (val[0] <= '9')) {
chan->dialed.number.plan = atoi(val);
if (chan->cdr) {
ast_cdr_setcid(chan->cdr, chan);
if (ast_channel_cdr(chan)) {
ast_cdr_setcid(ast_channel_cdr(chan), chan);
}
} else {
ast_log(LOG_ERROR,
@@ -1093,8 +1093,8 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
switch (status) {
case ID_FIELD_VALID:
ast_party_dialed_set(&chan->dialed, &dialed);
if (chan->cdr) {
ast_cdr_setcid(chan->cdr, chan);
if (ast_channel_cdr(chan)) {
ast_cdr_setcid(ast_channel_cdr(chan), chan);
}
break;
case ID_FIELD_INVALID:
@@ -1113,8 +1113,8 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
if (('0' <= val[0]) && (val[0] <= '9')) {
chan->caller.ani2 = atoi(val);
if (chan->cdr) {
ast_cdr_setcid(chan->cdr, chan);
if (ast_channel_cdr(chan)) {
ast_cdr_setcid(ast_channel_cdr(chan), chan);
}
} else {
ast_log(LOG_ERROR, "Unknown callerid ani2 '%s', value unchanged\n", val);
@@ -1130,8 +1130,8 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
switch (status) {
case ID_FIELD_VALID:
ast_party_caller_set(&chan->caller, &caller, NULL);
if (chan->cdr) {
ast_cdr_setcid(chan->cdr, chan);
if (ast_channel_cdr(chan)) {
ast_cdr_setcid(ast_channel_cdr(chan), chan);
}
break;
case ID_FIELD_INVALID:
@@ -1147,8 +1147,8 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
switch (status) {
case ID_FIELD_VALID:
ast_channel_set_caller_event(chan, &caller, NULL);
if (chan->cdr) {
ast_cdr_setcid(chan->cdr, chan);
if (ast_channel_cdr(chan)) {
ast_cdr_setcid(ast_channel_cdr(chan), chan);
}
break;
case ID_FIELD_INVALID:

View File

@@ -209,7 +209,7 @@ static int cdr_read(struct ast_channel *chan, const char *cmd, char *parse,
return -1;
ast_channel_lock(chan);
cdr = chan->cdr;
cdr = ast_channel_cdr(chan);
if (!cdr) {
ast_channel_unlock(chan);
return -1;
@@ -279,7 +279,7 @@ static int cdr_write(struct ast_channel *chan, const char *cmd, char *parse,
return -1;
ast_channel_lock(chan);
cdr = chan->cdr;
cdr = ast_channel_cdr(chan);
if (!cdr) {
ast_channel_unlock(chan);
return -1;

View File

@@ -307,12 +307,12 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
struct ast_format_cap *tmpcap;
if (!strcasecmp(data, "audionativeformat")) {
if ((tmpcap = ast_format_cap_get_type(chan->nativeformats, AST_FORMAT_TYPE_AUDIO))) {
if ((tmpcap = ast_format_cap_get_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_AUDIO))) {
ast_copy_string(buf, ast_getformatname_multiple(tmp, sizeof(tmp), tmpcap), len);
tmpcap = ast_format_cap_destroy(tmpcap);
}
} else if (!strcasecmp(data, "videonativeformat")) {
if ((tmpcap = ast_format_cap_get_type(chan->nativeformats, AST_FORMAT_TYPE_VIDEO))) {
if ((tmpcap = ast_format_cap_get_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_VIDEO))) {
ast_copy_string(buf, ast_getformatname_multiple(tmp, sizeof(tmp), tmpcap), len);
tmpcap = ast_format_cap_destroy(tmpcap);
}
@@ -326,8 +326,8 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
ast_copy_string(buf, ast_channel_trace_is_enabled(chan) ? "1" : "0", len);
ast_channel_unlock(chan);
#endif
} else if (!strcasecmp(data, "tonezone") && chan->zone)
locked_copy_string(chan, buf, chan->zone->country, len);
} else if (!strcasecmp(data, "tonezone") && ast_channel_zone(chan))
locked_copy_string(chan, buf, ast_channel_zone(chan)->country, len);
else if (!strcasecmp(data, "language"))
locked_copy_string(chan, buf, ast_channel_language(chan), len);
else if (!strcasecmp(data, "musicclass"))
@@ -337,9 +337,9 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
} else if (!strcasecmp(data, "parkinglot"))
locked_copy_string(chan, buf, ast_channel_parkinglot(chan), len);
else if (!strcasecmp(data, "state"))
locked_copy_string(chan, buf, ast_state2str(chan->_state), len);
locked_copy_string(chan, buf, ast_state2str(ast_channel_state(chan)), len);
else if (!strcasecmp(data, "channeltype"))
locked_copy_string(chan, buf, chan->tech->type, len);
locked_copy_string(chan, buf, ast_channel_tech(chan)->type, len);
else if (!strcasecmp(data, "accountcode"))
locked_copy_string(chan, buf, ast_channel_accountcode(chan), len);
else if (!strcasecmp(data, "checkhangup")) {
@@ -376,7 +376,7 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
struct ast_channel *p;
ast_channel_lock(chan);
p = ast_bridged_channel(chan);
if (p || chan->tech || chan->cdr) /* dummy channel? if so, we hid the peer name in the language */
if (p || ast_channel_tech(chan) || ast_channel_cdr(chan)) /* dummy channel? if so, we hid the peer name in the language */
ast_copy_string(buf, (p ? ast_channel_name(p) : ""), len);
else {
/* a dummy channel can still pass along bridged peer info via
@@ -391,7 +391,7 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
} else if (!strcasecmp(data, "uniqueid")) {
locked_copy_string(chan, buf, ast_channel_uniqueid(chan), len);
} else if (!strcasecmp(data, "transfercapability")) {
locked_copy_string(chan, buf, transfercapability_table[chan->transfercapability & 0x1f], len);
locked_copy_string(chan, buf, transfercapability_table[ast_channel_transfercapability(chan) & 0x1f], len);
} else if (!strcasecmp(data, "callgroup")) {
char groupbuf[256];
locked_copy_string(chan, buf, ast_print_group(groupbuf, sizeof(groupbuf), chan->callgroup), len);
@@ -400,7 +400,7 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
locked_copy_string(chan, buf, ast_print_group(groupbuf, sizeof(groupbuf), chan->pickupgroup), len);
} else if (!strcasecmp(data, "amaflags")) {
char amabuf[256];
snprintf(amabuf,sizeof(amabuf), "%d", chan->amaflags);
snprintf(amabuf,sizeof(amabuf), "%d", ast_channel_amaflags(chan));
locked_copy_string(chan, buf, amabuf, len);
} else if (!strncasecmp(data, "secure_bridge_", 14)) {
struct ast_datastore *ds;
@@ -414,7 +414,7 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
}
}
ast_channel_unlock(chan);
} else if (!chan->tech || !chan->tech->func_channel_read || chan->tech->func_channel_read(chan, function, data, buf, len)) {
} else if (!ast_channel_tech(chan) || !ast_channel_tech(chan)->func_channel_read || ast_channel_tech(chan)->func_channel_read(chan, function, data, buf, len)) {
ast_log(LOG_WARNING, "Unknown or unavailable item requested: '%s'\n", data);
ret = -1;
}
@@ -441,13 +441,15 @@ static int func_channel_write_real(struct ast_channel *chan, const char *functio
else if (!strcasecmp(data, "amaflags")) {
ast_channel_lock(chan);
if(isdigit(*value)) {
sscanf(value, "%30d", &chan->amaflags);
int amaflags;
sscanf(value, "%30d", &amaflags);
ast_channel_amaflags_set(chan, amaflags);
} else if (!strcasecmp(value,"OMIT")){
chan->amaflags = 1;
ast_channel_amaflags_set(chan, 1);
} else if (!strcasecmp(value,"BILLING")){
chan->amaflags = 2;
ast_channel_amaflags_set(chan, 2);
} else if (!strcasecmp(value,"DOCUMENTATION")){
chan->amaflags = 3;
ast_channel_amaflags_set(chan, 3);
}
ast_channel_unlock(chan);
} else if (!strcasecmp(data, "peeraccount"))
@@ -476,10 +478,10 @@ static int func_channel_write_real(struct ast_channel *chan, const char *functio
ret = -1;
} else {
ast_channel_lock(chan);
if (chan->zone) {
chan->zone = ast_tone_zone_unref(chan->zone);
if (ast_channel_zone(chan)) {
ast_channel_zone_set(chan, ast_tone_zone_unref(ast_channel_zone(chan)));
}
chan->zone = ast_tone_zone_ref(new_zone);
ast_channel_zone_set(chan, ast_tone_zone_ref(new_zone));
ast_channel_unlock(chan);
new_zone = ast_tone_zone_unref(new_zone);
}
@@ -497,7 +499,7 @@ static int func_channel_write_real(struct ast_channel *chan, const char *functio
unsigned short i;
for (i = 0; i < 0x20; i++) {
if (!strcasecmp(transfercapability_table[i], value) && strcmp(value, "UNK")) {
chan->transfercapability = i;
ast_channel_transfercapability_set(chan, i);
break;
}
}
@@ -532,8 +534,8 @@ static int func_channel_write_real(struct ast_channel *chan, const char *functio
} else if (!strcasecmp(data, "secure_bridge_media")) {
store->media = ast_true(value) ? 1 : 0;
}
} else if (!chan->tech->func_channel_write
|| chan->tech->func_channel_write(chan, function, data, value)) {
} else if (!ast_channel_tech(chan)->func_channel_write
|| ast_channel_tech(chan)->func_channel_write(chan, function, data, value)) {
ast_log(LOG_WARNING, "Unknown or unavailable item requested: '%s'\n",
data);
ret = -1;

View File

@@ -218,7 +218,7 @@ static struct ast_frame *hook_event_cb(struct ast_channel *chan, struct ast_fram
return frame;
}
if (chan->fdno == AST_JITTERBUFFER_FD && framedata->timer) {
if (ast_channel_fdno(chan) == AST_JITTERBUFFER_FD && framedata->timer) {
ast_timer_ack(framedata->timer, 1);
}

View File

@@ -100,15 +100,15 @@ static int timeout_read(struct ast_channel *chan, const char *cmd, char *data,
case 'r':
case 'R':
if (chan->pbx) {
snprintf(buf, len, "%.3f", chan->pbx->rtimeoutms / 1000.0);
if (ast_channel_pbx(chan)) {
snprintf(buf, len, "%.3f", ast_channel_pbx(chan)->rtimeoutms / 1000.0);
}
break;
case 'd':
case 'D':
if (chan->pbx) {
snprintf(buf, len, "%.3f", chan->pbx->dtimeoutms / 1000.0);
if (ast_channel_pbx(chan)) {
snprintf(buf, len, "%.3f", ast_channel_pbx(chan)->dtimeoutms / 1000.0);
}
break;
@@ -168,17 +168,17 @@ static int timeout_write(struct ast_channel *chan, const char *cmd, char *data,
case 'r':
case 'R':
if (chan->pbx) {
chan->pbx->rtimeoutms = when.tv_sec * 1000 + when.tv_usec / 1000;
ast_verb(3, "Response timeout set to %.3f\n", chan->pbx->rtimeoutms / 1000.0);
if (ast_channel_pbx(chan)) {
ast_channel_pbx(chan)->rtimeoutms = when.tv_sec * 1000 + when.tv_usec / 1000;
ast_verb(3, "Response timeout set to %.3f\n", ast_channel_pbx(chan)->rtimeoutms / 1000.0);
}
break;
case 'd':
case 'D':
if (chan->pbx) {
chan->pbx->dtimeoutms = when.tv_sec * 1000 + when.tv_usec / 1000;
ast_verb(3, "Digit timeout set to %.3f\n", chan->pbx->dtimeoutms / 1000.0);
if (ast_channel_pbx(chan)) {
ast_channel_pbx(chan)->dtimeoutms = when.tv_sec * 1000 + when.tv_usec / 1000;
ast_verb(3, "Digit timeout set to %.3f\n", ast_channel_pbx(chan)->dtimeoutms / 1000.0);
}
break;