automerge commit

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2-netsec@63518 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Automerge Script
2007-05-08 23:17:50 +00:00
parent e567c36080
commit ff4fd44751

View File

@@ -140,6 +140,7 @@ static int macro_exec(struct ast_channel *chan, void *data)
char *macro; char *macro;
char fullmacro[80]; char fullmacro[80];
char varname[80]; char varname[80];
char runningapp[80], runningdata[1024];
char *oldargs[MAX_ARGS + 1] = { NULL, }; char *oldargs[MAX_ARGS + 1] = { NULL, };
int argc, x; int argc, x;
int res=0; int res=0;
@@ -158,9 +159,6 @@ static int macro_exec(struct ast_channel *chan, void *data)
char *save_macro_offset; char *save_macro_offset;
struct localuser *u; struct localuser *u;
struct ast_context *c;
struct ast_exten *e;
if (ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Macro() requires arguments. See \"show application macro\" for help.\n"); ast_log(LOG_WARNING, "Macro() requires arguments. See \"show application macro\" for help.\n");
return -1; return -1;
@@ -266,13 +264,31 @@ static int macro_exec(struct ast_channel *chan, void *data)
autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP); autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP);
ast_set_flag(chan, AST_FLAG_IN_AUTOLOOP); ast_set_flag(chan, AST_FLAG_IN_AUTOLOOP);
while(ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) { while(ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) {
struct ast_context *c;
struct ast_exten *e;
/* What application will execute? */ /* What application will execute? */
for (c = ast_walk_contexts(NULL), e = NULL; c; c = ast_walk_contexts(c)) { if (ast_lock_contexts()) {
if (!strcmp(ast_get_context_name(c), chan->context)) { ast_log(LOG_WARNING, "Failed to lock contexts list\n");
e = find_matching_priority(c, chan->exten, chan->priority, chan->cid.cid_num); e = NULL;
break; } else {
for (c = ast_walk_contexts(NULL), e = NULL; c; c = ast_walk_contexts(c)) {
if (!strcmp(ast_get_context_name(c), chan->context)) {
if (ast_lock_context(c)) {
ast_log(LOG_WARNING, "Unable to lock context?\n");
runningapp[0] = '\0';
runningdata[0] = '\0';
} else {
e = find_matching_priority(c, chan->exten, chan->priority, chan->cid.cid_num);
ast_copy_string(runningapp, ast_get_extension_app(e), sizeof(runningapp));
ast_copy_string(runningdata, ast_get_extension_app_data(e), sizeof(runningdata));
ast_unlock_context(c);
}
break;
}
} }
} }
ast_unlock_contexts();
/* Reset the macro depth, if it was changed in the last iteration */ /* Reset the macro depth, if it was changed in the last iteration */
pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc); pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc);
@@ -306,15 +322,14 @@ static int macro_exec(struct ast_channel *chan, void *data)
} }
} }
ast_log(LOG_DEBUG, "Executed application: %s\n", ast_get_extension_app(e)); ast_log(LOG_DEBUG, "Executed application: %s\n", runningapp);
if (e && !strcasecmp(ast_get_extension_app(e), "GOSUB")) { if (!strcasecmp(runningapp, "GOSUB")) {
gosub_level++; gosub_level++;
ast_log(LOG_DEBUG, "Incrementing gosub_level\n"); ast_log(LOG_DEBUG, "Incrementing gosub_level\n");
} else if (e && !strcasecmp(ast_get_extension_app(e), "GOSUBIF")) { } else if (!strcasecmp(runningapp, "GOSUBIF")) {
const char *tmp = ast_get_extension_app_data(e);
char tmp2[1024] = "", *cond, *app, *app2 = tmp2; char tmp2[1024] = "", *cond, *app, *app2 = tmp2;
pbx_substitute_variables_helper(chan, tmp, tmp2, sizeof(tmp2) - 1); pbx_substitute_variables_helper(chan, runningdata, tmp2, sizeof(tmp2) - 1);
cond = strsep(&app2, "?"); cond = strsep(&app2, "?");
app = strsep(&app2, ":"); app = strsep(&app2, ":");
if (pbx_checkcondition(cond)) { if (pbx_checkcondition(cond)) {
@@ -328,18 +343,17 @@ static int macro_exec(struct ast_channel *chan, void *data)
ast_log(LOG_DEBUG, "Incrementing gosub_level\n"); ast_log(LOG_DEBUG, "Incrementing gosub_level\n");
} }
} }
} else if (e && !strcasecmp(ast_get_extension_app(e), "RETURN")) { } else if (!strcasecmp(runningapp, "RETURN")) {
gosub_level--; gosub_level--;
ast_log(LOG_DEBUG, "Decrementing gosub_level\n"); ast_log(LOG_DEBUG, "Decrementing gosub_level\n");
} else if (e && !strcasecmp(ast_get_extension_app(e), "STACKPOP")) { } else if (!strcasecmp(runningapp, "STACKPOP")) {
gosub_level--; gosub_level--;
ast_log(LOG_DEBUG, "Decrementing gosub_level\n"); ast_log(LOG_DEBUG, "Decrementing gosub_level\n");
} else if (e && !strncasecmp(ast_get_extension_app(e), "EXEC", 4)) { } else if (!strncasecmp(runningapp, "EXEC", 4)) {
/* Must evaluate args to find actual app */ /* Must evaluate args to find actual app */
const char *tmp = ast_get_extension_app_data(e);
char tmp2[1024] = "", *tmp3 = NULL; char tmp2[1024] = "", *tmp3 = NULL;
pbx_substitute_variables_helper(chan, tmp, tmp2, sizeof(tmp2) - 1); pbx_substitute_variables_helper(chan, runningdata, tmp2, sizeof(tmp2) - 1);
if (!strcasecmp(ast_get_extension_app(e), "EXECIF")) { if (!strcasecmp(runningapp, "EXECIF")) {
tmp3 = strchr(tmp2, '|'); tmp3 = strchr(tmp2, '|');
if (tmp3) if (tmp3)
*tmp3++ = '\0'; *tmp3++ = '\0';