diff options
author | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-21 15:58:05 +0000 |
---|---|---|
committer | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-21 15:58:05 +0000 |
commit | 9277a2a3fc82568c400bccb80974f24a69684574 (patch) | |
tree | b480c170fc308e1152961777a6e4a414f52d3f29 /res/res_agi.c | |
parent | 1034354f3486dadcd88a0b66489fc7a895853ccc (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: http://svn.digium.com/svn/asterisk/trunk@70731 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_agi.c')
-rw-r--r-- | res/res_agi.c | 15 |
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; |