summaryrefslogtreecommitdiff
path: root/res/res_agi.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2007-06-21 15:58:05 +0000
committerJoshua Colp <jcolp@digium.com>2007-06-21 15:58:05 +0000
commitfd9057423adc690063d5507051a18e5edb583fc2 (patch)
treeb480c170fc308e1152961777a6e4a414f52d3f29 /res/res_agi.c
parent80cdeaef55bce0588ebe221fb2d28d5d162fc9e1 (diff)
Expand AGISTATUS variable to include NOTFOUND which is set when the AGI file could not be found. (issue #9285 reported by srdjan)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@70731 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_agi.c')
-rw-r--r--res/res_agi.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/res/res_agi.c b/res/res_agi.c
index 1fef67a59..22c15f661 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -98,7 +98,7 @@ static char *descrip =
" Use the CLI command 'agi show' to list available agi commands\n"
" This application sets the following channel variable upon completion:\n"
" AGISTATUS The status of the attempt to the run the AGI script\n"
-" text string, one of SUCCESS | FAILED | HANGUP\n";
+" text string, one of SUCCESS | FAILED | NOTFOUND | HANGUP\n";
static int agidebug = 0;
@@ -112,7 +112,8 @@ static int agidebug = 0;
enum agi_result {
AGI_RESULT_SUCCESS,
AGI_RESULT_FAILURE,
- AGI_RESULT_HANGUP
+ AGI_RESULT_NOTFOUND,
+ AGI_RESULT_HANGUP,
};
static void agi_debug_cli(int fd, char *fmt, ...)
@@ -249,6 +250,13 @@ static enum agi_result launch_script(char *script, char *argv[], int *fds, int *
snprintf(tmp, sizeof(tmp), "%s/%s", ast_config_AST_AGI_DIR, script);
script = tmp;
}
+
+ /* Before even trying let's see if the file actually exists */
+ if (!ast_fileexists(script, NULL, NULL)) {
+ ast_log(LOG_WARNING, "Failed to execute '%s': File does not exist.\n", script);
+ return AGI_RESULT_NOTFOUND;
+ }
+
if (pipe(toast)) {
ast_log(LOG_WARNING, "Unable to create toast pipe: %s\n",strerror(errno));
return AGI_RESULT_FAILURE;
@@ -2086,6 +2094,9 @@ static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int
case AGI_RESULT_FAILURE:
pbx_builtin_setvar_helper(chan, "AGISTATUS", "FAILURE");
break;
+ case AGI_RESULT_NOTFOUND:
+ pbx_builtin_setvar_helper(chan, "AGISTATUS", "NOTFOUND");
+ break;
case AGI_RESULT_HANGUP:
pbx_builtin_setvar_helper(chan, "AGISTATUS", "HANGUP");
return -1;