[asterisk-commits] murf: trunk r45426 - /trunk/res/res_agi.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Oct 17 16:06:14 MST 2006
Author: murf
Date: Tue Oct 17 18:06:13 2006
New Revision: 45426
URL: http://svn.digium.com/view/asterisk?rev=45426&view=rev
Log:
As per bug 6779, this patch is now applied to trunk; while I was at it, I corrected a reference to a CLI command, to follow the new regime.
Modified:
trunk/res/res_agi.c
Modified: trunk/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_agi.c?rev=45426&r1=45425&r2=45426&view=diff
==============================================================================
--- trunk/res/res_agi.c (original)
+++ trunk/res/res_agi.c Tue Oct 17 18:06:13 2006
@@ -95,7 +95,7 @@
"variable to \"no\" before executing the AGI application.\n"
" Using 'EAGI' provides enhanced AGI, with incoming audio available out of band\n"
"on file descriptor 3\n\n"
-" Use the CLI command 'show agi' to list available agi commands\n"
+" Use the CLI command 'agi list' 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";
@@ -220,6 +220,7 @@
}
/* If we have a script parameter, relay it to the fastagi server */
+ /* Script parameters take the form of: AGI(agi://my.example.com/?extension=${EXTEN}) */
if (!ast_strlen_zero(script))
fdprintf(s, "agi_network_script: %s\n", script);
@@ -326,6 +327,7 @@
close(x);
/* Execute script */
+ /* XXX argv should be deprecated in favor of passing agi_argX paramaters */
execv(script, argv);
/* Can't use ast_log since FD's are closed */
fprintf(stdout, "verbose \"Failed to execute '%s': %s\" 2\n", script, strerror(errno));
@@ -351,8 +353,10 @@
}
-static void setup_env(struct ast_channel *chan, char *request, int fd, int enhanced)
-{
+static void setup_env(struct ast_channel *chan, char *request, int fd, int enhanced, int argc, char *argv[])
+{
+ int count;
+
/* Print initial environment, with agi_request always being the first
thing */
fdprintf(fd, "agi_request: %s\n", request);
@@ -380,6 +384,11 @@
/* User information */
fdprintf(fd, "agi_accountcode: %s\n", chan->accountcode ? chan->accountcode : "");
+ /* Send any parameters to the fastagi server that have been passed via the agi application */
+ /* Agi application paramaters take the form of: AGI(/path/to/example/script|${EXTEN}) */
+ for(count = 1; count < argc; count++)
+ fdprintf(fd, "agi_arg_%d: %s\n", count, argv[count]);
+
/* End with empty return */
fdprintf(fd, "\n");
}
@@ -1810,7 +1819,7 @@
return 0;
}
#define RETRY 3
-static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi, int pid, int *status, int dead)
+static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi, int pid, int *status, int dead, int argc, char *argv[])
{
struct ast_channel *c;
int outfd;
@@ -1831,7 +1840,7 @@
return AGI_RESULT_FAILURE;
}
setlinebuf(readf);
- setup_env(chan, request, agi->fd, (agi->audio > -1));
+ setup_env(chan, request, agi->fd, (agi->audio > -1), argc, argv);
for (;;) {
ms = -1;
c = ast_waitfor_nandfds(&chan, dead ? 0 : 1, &agi->ctrl, 1, NULL, &outfd, &ms);
@@ -2014,7 +2023,7 @@
agi.fd = fds[1];
agi.ctrl = fds[0];
agi.audio = efd;
- res = run_agi(chan, argv[0], &agi, pid, &status, dead);
+ res = run_agi(chan, argv[0], &agi, pid, &status, dead, argc, argv);
/* If the fork'd process returns non-zero, set AGISTATUS to FAILURE */
if (res == AGI_RESULT_SUCCESS && status)
res = AGI_RESULT_FAILURE;
More information about the asterisk-commits
mailing list