From 19cfa5ca6c9d693aae8f51480f9b8c3978527924 Mon Sep 17 00:00:00 2001 From: markster Date: Tue, 29 Mar 2005 06:18:58 +0000 Subject: Make sure ExecIf stuff returns properly (bug #3864) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5297 f38db490-d61c-443f-a65b-d21fe96a405b --- apps/app_exec.c | 4 ++-- apps/app_while.c | 13 ++++++++++--- pbx.c | 14 +++++++++----- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/apps/app_exec.c b/apps/app_exec.c index 8a46c0797..f4e156927 100755 --- a/apps/app_exec.c +++ b/apps/app_exec.c @@ -37,7 +37,7 @@ static char *exec_descrip = "Exec(appname(arguments))\n" " Allows an arbitrary application to be invoked even when not\n" "hardcoded into the dialplan. Returns whatever value the\n" -"app returns or -2 when the app cannot be found.\n"; +"app returns or a non-zero value when the app cannot be found.\n"; STANDARD_LOCAL_USER; @@ -71,7 +71,7 @@ static int exec_exec(struct ast_channel *chan, void *data) res = pbx_exec(chan, app, args, 1); } else { ast_log(LOG_WARNING, "Could not find application (%s)\n", appname); - res = -2; + res = -1; } } } else { diff --git a/apps/app_while.c b/apps/app_while.c index e33bae52f..5822c2ff5 100755 --- a/apps/app_while.c +++ b/apps/app_while.c @@ -29,7 +29,9 @@ static char *exec_app = "ExecIf"; static char *exec_desc = " ExecIF (||)\n" -"If is true, execute and return the result of ()\n\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."; static char *exec_synopsis = "ExecIF (||)"; static char *start_app = "While"; @@ -73,8 +75,13 @@ static int execif_exec(struct ast_channel *chan, void *data) { } else mydata = ""; - if(ast_true(expr) && (app = pbx_findapp(myapp))) { - res = pbx_exec(chan, app, mydata, 1); + if (ast_true(expr)) { + if ((app = pbx_findapp(myapp))) { + res = pbx_exec(chan, app, mydata, 1); + } else { + ast_log(LOG_WARNING, "Count not find application! (%s)\n", myapp); + res = -1; + } } } else { ast_log(LOG_ERROR,"Invalid Syntax.\n"); diff --git a/pbx.c b/pbx.c index d2f1699d6..dd9e98feb 100755 --- a/pbx.c +++ b/pbx.c @@ -300,7 +300,8 @@ static struct pbx_builtin { " ExecIfTime(|||?[|]):\n" "If the current time matches the specified time, then execute the specified\n" "application. Each of the elements may be specified either as '*' (for always)\n" - "or as a range. See the 'include' syntax for details." + "or as a range. See the 'include' syntax for details. It will return whatever\n" + " returns, or a non-zero value if the application is not found.\n" }, { "Hangup", pbx_builtin_hangup, @@ -5372,10 +5373,10 @@ static int pbx_builtin_execiftime(struct ast_channel *chan, void *data) int res = 0; char *ptr1, *ptr2; struct ast_timing timing; - const char *usage = "ExecIfTime requires an argument:\n