aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_while.c
diff options
context:
space:
mode:
authormogorman <mogorman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-26 18:49:07 +0000
committermogorman <mogorman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-26 18:49:07 +0000
commitd4b7fe34ee75fd8ffd3cac35f87850adf8578a0b (patch)
tree1ce17852572ba50b01ca82263410e03187a2144b /apps/app_while.c
parentcc65f7202c4edfc80df2a16aab715ce3f0ddf684 (diff)
adds two new applications, exitwhile, and continuewhile
patch from bug 6994. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@22573 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_while.c')
-rw-r--r--apps/app_while.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/apps/app_while.c b/apps/app_while.c
index 075a5276a..5cdb87db3 100644
--- a/apps/app_while.c
+++ b/apps/app_while.c
@@ -52,7 +52,7 @@ static char *exec_desc =
"Usage: ExecIF (<expr>|<app>|<data>)\n"
"If <expr> is true, execute and return the result of <app>(<data>).\n"
"If <expr> is true, but <app> 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,15 +61,27 @@ static char *start_desc =
"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 *continue_app = "ContinueWhile";
+static char *continue_desc =
+"Usage: ContinueWhile()\n"
+"Returns to the top of the while loop and re-evaluates the conditional.\n";
+static char *continue_synopsis = "Restart a While loop";
static char *tdesc = "While Loops and Conditional Execution";
@@ -265,7 +277,7 @@ static int _while_exec(struct ast_channel *chan, void *data, int end)
}
- 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 +336,28 @@ static int while_end_exec(struct ast_channel *chan, void *data) {
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 while_continue_exec(struct ast_channel *chan, void *data)
+{
+ int x;
+ const char *prefix = "WHILE", *while_pri=NULL;
+
+ for (x = 0; ; x++) {
+ const char *tmp = get_index(chan, prefix, x);
+ if (tmp)
+ while_pri = tmp;
+ else
+ break;
+ }
+
+ if (while_pri)
+ ast_parseable_goto(chan, while_pri);
+
+ return 0;
+}
static int unload_module(void *mod)
{
@@ -332,6 +366,8 @@ static int unload_module(void *mod)
res = ast_unregister_application(start_app);
res |= ast_unregister_application(exec_app);
res |= ast_unregister_application(stop_app);
+ res |= ast_unregister_application(exit_app);
+ res |= ast_unregister_application(continue_app);
STANDARD_HANGUP_LOCALUSERS;
@@ -345,6 +381,8 @@ static int load_module(void *mod)
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);
+ res |= ast_register_application(continue_app, while_continue_exec, continue_synopsis, continue_desc);
return res;
}