Index: apps/app_while.c =================================================================== --- apps/app_while.c (revision 21306) +++ apps/app_while.c (working copy) @@ -52,7 +52,7 @@ "Usage: ExecIF (||)\n" "If is true, execute and return the result of ().\n" "If is true, but is not found, then the application\n" -"will return a non-zero value."; +"will return a non-zero value.\n"; static char *exec_synopsis = "Conditional exec"; static char *start_app = "While"; @@ -61,16 +61,22 @@ "Start a While Loop. Execution will return to this point when\n" "EndWhile is called until expr is no longer true.\n"; -static char *start_synopsis = "Start A While Loop"; +static char *start_synopsis = "Start a While loop"; static char *stop_app = "EndWhile"; static char *stop_desc = "Usage: EndWhile()\n" -"Return to the previous called While\n\n"; +"Return to the previous called While\n"; -static char *stop_synopsis = "End A While Loop"; +static char *stop_synopsis = "End a While loop"; +static char *exit_app = "ExitWhile"; +static char *exit_desc = +"Usage: ExitWhile()\n" +"Exits a While loop, whether or not the conditional has been satisfied.\n"; +static char *exit_synopsis = "End a While loop"; + static char *tdesc = "While Loops and Conditional Execution"; LOCAL_USER_DECL; @@ -265,7 +271,7 @@ } - if (!end && !ast_true(condition)) { + if ((!end && !ast_true(condition)) || (end == 2)) { /* Condition Met (clean up helper vars) */ const char *goto_str; pbx_builtin_setvar_helper(chan, varname, NULL); @@ -324,6 +330,9 @@ return _while_exec(chan, data, 1); } +static int while_exit_exec(struct ast_channel *chan, void *data) { + return _while_exec(chan, data, 2); +} static int unload_module(void *mod) { @@ -332,6 +341,7 @@ res = ast_unregister_application(start_app); res |= ast_unregister_application(exec_app); res |= ast_unregister_application(stop_app); + res |= ast_unregister_application(exit_app); STANDARD_HANGUP_LOCALUSERS; @@ -345,6 +355,7 @@ res = ast_register_application(start_app, while_start_exec, start_synopsis, start_desc); res |= ast_register_application(exec_app, execif_exec, exec_synopsis, exec_desc); res |= ast_register_application(stop_app, while_end_exec, stop_synopsis, stop_desc); + res |= ast_register_application(exit_app, while_exit_exec, exit_synopsis, exit_desc); return res; }