diff options
author | Terry Wilson <twilson@digium.com> | 2012-02-29 16:52:47 +0000 |
---|---|---|
committer | Terry Wilson <twilson@digium.com> | 2012-02-29 16:52:47 +0000 |
commit | a9d607a35764d93790172cab1f630e14fb8e043c (patch) | |
tree | dadea55813cfc525898844c51eec824d468455cb /funcs | |
parent | 0b988da21c1ec856b7b8bad2434bf93498d17cfd (diff) |
Opaquify ast_channel structs and lists
Review: https://reviewboard.asterisk.org/r/1773/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@357542 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs')
-rw-r--r-- | funcs/func_blacklist.c | 8 | ||||
-rw-r--r-- | funcs/func_callerid.c | 66 | ||||
-rw-r--r-- | funcs/func_dialplan.c | 8 | ||||
-rw-r--r-- | funcs/func_strings.c | 12 | ||||
-rw-r--r-- | funcs/func_timeout.c | 6 |
5 files changed, 50 insertions, 50 deletions
diff --git a/funcs/func_blacklist.c b/funcs/func_blacklist.c index be3bbc5fb..928d5d728 100644 --- a/funcs/func_blacklist.c +++ b/funcs/func_blacklist.c @@ -61,12 +61,12 @@ static int blacklist_read(struct ast_channel *chan, const char *cmd, char *data, char blacklist[1]; int bl = 0; - if (chan->caller.id.number.valid && chan->caller.id.number.str) { - if (!ast_db_get("blacklist", chan->caller.id.number.str, blacklist, sizeof (blacklist))) + if (ast_channel_caller(chan)->id.number.valid && ast_channel_caller(chan)->id.number.str) { + if (!ast_db_get("blacklist", ast_channel_caller(chan)->id.number.str, blacklist, sizeof (blacklist))) bl = 1; } - if (chan->caller.id.name.valid && chan->caller.id.name.str) { - if (!ast_db_get("blacklist", chan->caller.id.name.str, blacklist, sizeof (blacklist))) + if (ast_channel_caller(chan)->id.name.valid && ast_channel_caller(chan)->id.name.str) { + if (!ast_db_get("blacklist", ast_channel_caller(chan)->id.name.str, blacklist, sizeof (blacklist))) bl = 1; } diff --git a/funcs/func_callerid.c b/funcs/func_callerid.c index bd6d8aef2..8e8335221 100644 --- a/funcs/func_callerid.c +++ b/funcs/func_callerid.c @@ -818,7 +818,7 @@ static int callerpres_read(struct ast_channel *chan, const char *cmd, char *data " Use CALLERID(name-pres) or CALLERID(num-pres) instead.\n"); } ast_copy_string(buf, - ast_named_caller_presentation(ast_party_id_presentation(&chan->caller.id)), len); + ast_named_caller_presentation(ast_party_id_presentation(&ast_channel_caller(chan)->id)), len); return 0; } @@ -848,8 +848,8 @@ static int callerpres_write(struct ast_channel *chan, const char *cmd, char *dat if (pres < 0) { ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show function CALLERPRES')\n", value); } else { - chan->caller.id.name.presentation = pres; - chan->caller.id.number.presentation = pres; + ast_channel_caller(chan)->id.name.presentation = pres; + ast_channel_caller(chan)->id.number.presentation = pres; } return 0; } @@ -917,9 +917,9 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data, ast_channel_lock(chan); if (member.argc == 1 && !strcasecmp("rdnis", member.argv[0])) { - if (chan->redirecting.from.number.valid - && chan->redirecting.from.number.str) { - ast_copy_string(buf, chan->redirecting.from.number.str, len); + if (ast_channel_redirecting(chan)->from.number.valid + && ast_channel_redirecting(chan)->from.number.str) { + ast_copy_string(buf, ast_channel_redirecting(chan)->from.number.str, len); } } else if (!strcasecmp("dnid", member.argv[0])) { if (member.argc == 1) { @@ -934,12 +934,12 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data, */ if (member.argc == 2) { /* dnid-num */ - if (chan->dialed.number.str) { - ast_copy_string(buf, chan->dialed.number.str, len); + if (ast_channel_dialed(chan)->number.str) { + ast_copy_string(buf, ast_channel_dialed(chan)->number.str, len); } } else if (member.argc == 3 && !strcasecmp("plan", member.argv[2])) { /* dnid-num-plan */ - snprintf(buf, len, "%d", chan->dialed.number.plan); + snprintf(buf, len, "%d", ast_channel_dialed(chan)->number.plan); } else { ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data); } @@ -949,7 +949,7 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data, * dnid-subaddr... */ status = party_subaddress_read(buf, len, member.argc - 2, member.argv + 2, - &chan->dialed.subaddress); + &ast_channel_dialed(chan)->subaddress); switch (status) { case ID_FIELD_VALID: case ID_FIELD_INVALID: @@ -962,7 +962,7 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data, ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data); } } else if (member.argc == 1 && !strcasecmp("ani2", member.argv[0])) { - snprintf(buf, len, "%d", chan->caller.ani2); + snprintf(buf, len, "%d", ast_channel_caller(chan)->ani2); } else if (!strcasecmp("ani", member.argv[0])) { if (member.argc == 1) { /* Setup as if user had given ani-num instead. */ @@ -970,7 +970,7 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data, member.argv[1] = "num"; } status = party_id_read(buf, len, member.argc - 1, member.argv + 1, - &chan->caller.ani); + &ast_channel_caller(chan)->ani); switch (status) { case ID_FIELD_VALID: case ID_FIELD_INVALID: @@ -980,7 +980,7 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data, break; } } else { - status = party_id_read(buf, len, member.argc, member.argv, &chan->caller.id); + status = party_id_read(buf, len, member.argc, member.argv, &ast_channel_caller(chan)->id); switch (status) { case ID_FIELD_VALID: case ID_FIELD_INVALID: @@ -1040,14 +1040,14 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data, ast_channel_lock(chan); if (member.argc == 1 && !strcasecmp("rdnis", member.argv[0])) { - chan->redirecting.from.number.valid = 1; - ast_free(chan->redirecting.from.number.str); - chan->redirecting.from.number.str = ast_strdup(value); + ast_channel_redirecting(chan)->from.number.valid = 1; + ast_free(ast_channel_redirecting(chan)->from.number.str); + ast_channel_redirecting(chan)->from.number.str = ast_strdup(value); 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); + ast_party_dialed_set_init(&dialed, ast_channel_dialed(chan)); if (member.argc == 1) { /* Setup as if user had given dnid-num instead. */ member.argc = 2; @@ -1062,7 +1062,7 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data, /* dnid-num */ dialed.number.str = ast_strdup(value); ast_trim_blanks(dialed.number.str); - ast_party_dialed_set(&chan->dialed, &dialed); + ast_party_dialed_set(ast_channel_dialed(chan), &dialed); if (ast_channel_cdr(chan)) { ast_cdr_setcid(ast_channel_cdr(chan), chan); } @@ -1072,7 +1072,7 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data, ast_trim_blanks(val); if (('0' <= val[0]) && (val[0] <= '9')) { - chan->dialed.number.plan = atoi(val); + ast_channel_dialed(chan)->number.plan = atoi(val); if (ast_channel_cdr(chan)) { ast_cdr_setcid(ast_channel_cdr(chan), chan); } @@ -1092,7 +1092,7 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data, member.argv + 2, value); switch (status) { case ID_FIELD_VALID: - ast_party_dialed_set(&chan->dialed, &dialed); + ast_party_dialed_set(ast_channel_dialed(chan), &dialed); if (ast_channel_cdr(chan)) { ast_cdr_setcid(ast_channel_cdr(chan), chan); } @@ -1112,7 +1112,7 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data, ast_trim_blanks(val); if (('0' <= val[0]) && (val[0] <= '9')) { - chan->caller.ani2 = atoi(val); + ast_channel_caller(chan)->ani2 = atoi(val); if (ast_channel_cdr(chan)) { ast_cdr_setcid(ast_channel_cdr(chan), chan); } @@ -1120,7 +1120,7 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data, ast_log(LOG_ERROR, "Unknown callerid ani2 '%s', value unchanged\n", val); } } else if (!strcasecmp("ani", member.argv[0])) { - ast_party_caller_set_init(&caller, &chan->caller); + ast_party_caller_set_init(&caller, ast_channel_caller(chan)); if (member.argc == 1) { /* Setup as if user had given ani-num instead. */ member.argc = 2; @@ -1129,7 +1129,7 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data, status = party_id_write(&caller.ani, member.argc - 1, member.argv + 1, value); switch (status) { case ID_FIELD_VALID: - ast_party_caller_set(&chan->caller, &caller, NULL); + ast_party_caller_set(ast_channel_caller(chan), &caller, NULL); if (ast_channel_cdr(chan)) { ast_cdr_setcid(ast_channel_cdr(chan), chan); } @@ -1142,7 +1142,7 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data, } ast_party_caller_free(&caller); } else { - ast_party_caller_set_init(&caller, &chan->caller); + ast_party_caller_set_init(&caller, ast_channel_caller(chan)); status = party_id_write(&caller.id, member.argc, member.argv, value); switch (status) { case ID_FIELD_VALID: @@ -1200,9 +1200,9 @@ static int connectedline_read(struct ast_channel *chan, const char *cmd, char *d ast_channel_lock(chan); if (member.argc == 1 && !strcasecmp("source", member.argv[0])) { - ast_copy_string(buf, ast_connected_line_source_name(chan->connected.source), len); + ast_copy_string(buf, ast_connected_line_source_name(ast_channel_connected(chan)->source), len); } else { - status = party_id_read(buf, len, member.argc, member.argv, &chan->connected.id); + status = party_id_read(buf, len, member.argc, member.argv, &ast_channel_connected(chan)->id); switch (status) { case ID_FIELD_VALID: case ID_FIELD_INVALID: @@ -1272,7 +1272,7 @@ static int connectedline_write(struct ast_channel *chan, const char *cmd, char * } ast_channel_lock(chan); - ast_party_connected_line_set_init(&connected, &chan->connected); + ast_party_connected_line_set_init(&connected, ast_channel_connected(chan)); ast_channel_unlock(chan); value = ast_skip_blanks(value); @@ -1350,7 +1350,7 @@ static int redirecting_read(struct ast_channel *chan, const char *cmd, char *dat if (!strcasecmp("from", member.argv[0])) { status = party_id_read(buf, len, member.argc - 1, member.argv + 1, - &chan->redirecting.from); + &ast_channel_redirecting(chan)->from); switch (status) { case ID_FIELD_VALID: case ID_FIELD_INVALID: @@ -1361,7 +1361,7 @@ static int redirecting_read(struct ast_channel *chan, const char *cmd, char *dat } } else if (!strcasecmp("to", member.argv[0])) { status = party_id_read(buf, len, member.argc - 1, member.argv + 1, - &chan->redirecting.to); + &ast_channel_redirecting(chan)->to); switch (status) { case ID_FIELD_VALID: case ID_FIELD_INVALID: @@ -1377,11 +1377,11 @@ static int redirecting_read(struct ast_channel *chan, const char *cmd, char *dat */ ast_copy_string(buf, ast_named_caller_presentation( - ast_party_id_presentation(&chan->redirecting.from)), len); + ast_party_id_presentation(&ast_channel_redirecting(chan)->from)), len); } else if (member.argc == 1 && !strcasecmp("reason", member.argv[0])) { - ast_copy_string(buf, ast_redirecting_reason_name(chan->redirecting.reason), len); + ast_copy_string(buf, ast_redirecting_reason_name(ast_channel_redirecting(chan)->reason), len); } else if (member.argc == 1 && !strcasecmp("count", member.argv[0])) { - snprintf(buf, len, "%d", chan->redirecting.count); + snprintf(buf, len, "%d", ast_channel_redirecting(chan)->count); } else { ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data); } @@ -1445,7 +1445,7 @@ static int redirecting_write(struct ast_channel *chan, const char *cmd, char *da } ast_channel_lock(chan); - ast_party_redirecting_set_init(&redirecting, &chan->redirecting); + ast_party_redirecting_set_init(&redirecting, ast_channel_redirecting(chan)); ast_channel_unlock(chan); value = ast_skip_blanks(value); diff --git a/funcs/func_dialplan.c b/funcs/func_dialplan.c index 904eede29..0c2e8c707 100644 --- a/funcs/func_dialplan.c +++ b/funcs/func_dialplan.c @@ -97,20 +97,20 @@ static int isexten_function_read(struct ast_channel *chan, const char *cmd, char if (sscanf(args.priority, "%30d", &priority_num) == 1 && priority_num > 0) { int res; res = ast_exists_extension(chan, args.context, args.exten, priority_num, - S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL)); + S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL)); if (res) strcpy(buf, "1"); } else { int res; res = ast_findlabel_extension(chan, args.context, args.exten, args.priority, - S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL)); + S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL)); if (res > 0) strcpy(buf, "1"); } } else if (!ast_strlen_zero(args.exten)) { int res; res = ast_exists_extension(chan, args.context, args.exten, 1, - S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL)); + S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL)); if (res) strcpy(buf, "1"); } else if (!ast_strlen_zero(args.context)) { @@ -151,7 +151,7 @@ static int acf_isexten_exec(struct ast_channel *chan, const char *cmd, char *par } if (ast_exists_extension(chan, args.context, args.extension, priority_int, - S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) { + S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { ast_copy_string(buffer, "1", buflen); } else { ast_copy_string(buffer, "0", buflen); diff --git a/funcs/func_strings.c b/funcs/func_strings.c index ff04be827..18de20226 100644 --- a/funcs/func_strings.c +++ b/funcs/func_strings.c @@ -997,7 +997,7 @@ static void clearvar_prefix(struct ast_channel *chan, const char *prefix) { struct ast_var_t *var; int len = strlen(prefix); - AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->varshead, var, entries) { + AST_LIST_TRAVERSE_SAFE_BEGIN(ast_channel_varshead(chan), var, entries) { if (strncasecmp(prefix, ast_var_name(var), len) == 0) { AST_LIST_REMOVE_CURRENT(entries); ast_free(var); @@ -1096,7 +1096,7 @@ static int hashkeys_read(struct ast_channel *chan, const char *cmd, char *data, ast_str_set(&prefix, -1, HASH_PREFIX, data); memset(buf, 0, len); - AST_LIST_TRAVERSE(&chan->varshead, newvar, entries) { + AST_LIST_TRAVERSE(ast_channel_varshead(chan), newvar, entries) { if (strncasecmp(ast_str_buffer(prefix), ast_var_name(newvar), ast_str_strlen(prefix)) == 0) { /* Copy everything after the prefix */ strncat(buf, ast_var_name(newvar) + ast_str_strlen(prefix), len - strlen(buf) - 1); @@ -1117,7 +1117,7 @@ static int hashkeys_read2(struct ast_channel *chan, const char *cmd, char *data, ast_str_set(&prefix, -1, HASH_PREFIX, data); - AST_LIST_TRAVERSE(&chan->varshead, newvar, entries) { + AST_LIST_TRAVERSE(ast_channel_varshead(chan), newvar, entries) { if (strncasecmp(ast_str_buffer(prefix), ast_var_name(newvar), ast_str_strlen(prefix)) == 0) { /* Copy everything after the prefix */ ast_str_append(buf, len, "%s", ast_var_name(newvar) + ast_str_strlen(prefix)); @@ -1693,12 +1693,12 @@ AST_TEST_DEFINE(test_FIELDNUM) for (i = 0; i < ARRAY_LEN(test_args); i++) { struct ast_var_t *var = ast_var_assign("FIELDS", test_args[i].fields); - AST_LIST_INSERT_HEAD(&chan->varshead, var, entries); + AST_LIST_INSERT_HEAD(ast_channel_varshead(chan), var, entries); snprintf(expression, sizeof(expression), "${FIELDNUM(%s,%s,%s)}", var->name, test_args[i].delim, test_args[i].field); ast_str_substitute_variables(&str, 0, chan, expression); - AST_LIST_REMOVE(&chan->varshead, var, entries); + AST_LIST_REMOVE(ast_channel_varshead(chan), var, entries); ast_var_delete(var); if (strcasecmp(ast_str_buffer(str), test_args[i].expected)) { @@ -1795,7 +1795,7 @@ AST_TEST_DEFINE(test_STRREPLACE) char tmp[512], tmp2[512] = ""; struct ast_var_t *var = ast_var_assign("test_string", test_strings[i][0]); - AST_LIST_INSERT_HEAD(&chan->varshead, var, entries); + AST_LIST_INSERT_HEAD(ast_channel_varshead(chan), var, entries); if (test_strings[i][3]) { snprintf(tmp, sizeof(tmp), "${STRREPLACE(%s,%s,%s,%s)}", "test_string", test_strings[i][1], test_strings[i][2], test_strings[i][3]); diff --git a/funcs/func_timeout.c b/funcs/func_timeout.c index aef0a4033..3c2810fd5 100644 --- a/funcs/func_timeout.c +++ b/funcs/func_timeout.c @@ -90,11 +90,11 @@ static int timeout_read(struct ast_channel *chan, const char *cmd, char *data, switch (*data) { case 'a': case 'A': - if (ast_tvzero(chan->whentohangup)) { + if (ast_tvzero(*ast_channel_whentohangup(chan))) { ast_copy_string(buf, "0", len); } else { myt = ast_tvnow(); - snprintf(buf, len, "%.3f", ast_tvdiff_ms(chan->whentohangup, myt) / 1000.0); + snprintf(buf, len, "%.3f", ast_tvdiff_ms(*ast_channel_whentohangup(chan), myt) / 1000.0); } break; @@ -156,7 +156,7 @@ static int timeout_write(struct ast_channel *chan, const char *cmd, char *data, case 'a': case 'A': ast_channel_setwhentohangup_tv(chan, when); - if (!ast_tvzero(chan->whentohangup)) { + if (!ast_tvzero(*ast_channel_whentohangup(chan))) { when = ast_tvadd(when, ast_tvnow()); ast_strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S.%3q %Z", ast_localtime(&when, &myt, NULL)); |