[asterisk-commits] file: trunk r70731 - /trunk/res/res_agi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 21 10:58:06 CDT 2007


Author: file
Date: Thu Jun 21 10:58:05 2007
New Revision: 70731

URL: http://svn.digium.com/view/asterisk?view=rev&rev=70731
Log:
Expand AGISTATUS variable to include NOTFOUND which is set when the AGI file could not be found. (issue #9285 reported by srdjan)

Modified:
    trunk/res/res_agi.c

Modified: trunk/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_agi.c?view=diff&rev=70731&r1=70730&r2=70731
==============================================================================
--- trunk/res/res_agi.c (original)
+++ trunk/res/res_agi.c Thu Jun 21 10:58:05 2007
@@ -98,7 +98,7 @@
 "  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 @@
 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 @@
 		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 @@
 	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;




More information about the asterisk-commits mailing list