[Asterisk-cvs] asterisk/res res_agi.c,1.5,1.6
markster at lists.digium.com
markster at lists.digium.com
Sat Sep 25 10:19:40 CDT 2004
Update of /usr/cvsroot/asterisk/res
In directory mongoose.digium.com:/tmp/cvs-serv7360/res
Modified Files:
res_agi.c
Log Message:
Make holdtime announcement say "less than 2 minutes" instead of "1 minutes" (bug #2500)
Index: res_agi.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_agi.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- res_agi.c 23 Sep 2004 18:10:46 -0000 1.5
+++ res_agi.c 25 Sep 2004 14:22:27 -0000 1.6
@@ -38,6 +38,7 @@
#include <asterisk/app.h>
#include <asterisk/dsp.h>
#include <asterisk/musiconhold.h>
+#include <asterisk/manager.h>
#include <asterisk/utils.h>
#include <asterisk/lock.h>
#include <asterisk/agi.h>
@@ -48,7 +49,7 @@
#define MAX_COMMANDS 128
/* Recycle some stuff from the CLI interface */
-#define fdprintf ast_cli
+#define fdprintf agi_debug_cli
static char *tdesc = "Asterisk Gateway Interface (AGI)";
@@ -74,6 +75,8 @@
"on file descriptor 3\n\n"
"Use the CLI command 'show agi' to list available agi commands\n";
+static int agidebug = 0;
+
STANDARD_LOCAL_USER;
LOCAL_USER_DECL;
@@ -86,6 +89,25 @@
#define AGI_PORT 4573
+static void agi_debug_cli(int fd, char *fmt, ...)
+{
+ char *stuff;
+ int res = 0;
+
+ va_list ap;
+ va_start(ap, fmt);
+ res = vasprintf(&stuff, fmt, ap);
+ va_end(ap);
+ if (res == -1) {
+ ast_log(LOG_ERROR, "Out of memory\n");
+ } else {
+ if (agidebug)
+ ast_verbose("AGI Tx >> %s", stuff);
+ ast_carefulwrite(fd, stuff, strlen(stuff), 100);
+ free(stuff);
+ }
+}
+
static int launch_netscript(char *agiurl, char *argv[], int *fds, int *efd, int *opid)
{
int s;
@@ -961,6 +983,38 @@
return RESULT_SUCCESS;
}
+static char debug_usage[] =
+"Usage: agi debug\n"
+" Enables dumping of AGI transactions for debugging purposes\n";
+
+static char no_debug_usage[] =
+"Usage: agi no debug\n"
+" Disables dumping of AGI transactions for debugging purposes\n";
+
+static int agi_do_debug(int fd, int argc, char *argv[])
+{
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+ agidebug = 1;
+ ast_cli(fd, "AGI Debugging Enabled\n");
+ return RESULT_SUCCESS;
+}
+
+static int agi_no_debug(int fd, int argc, char *argv[])
+{
+ if (argc != 3)
+ return RESULT_SHOWUSAGE;
+ agidebug = 0;
+ ast_cli(fd, "AGI Debugging Disabled\n");
+ return RESULT_SUCCESS;
+}
+
+static struct ast_cli_entry cli_debug =
+ { { "agi", "debug", NULL }, agi_do_debug, "Enable AGI debugging", debug_usage };
+
+static struct ast_cli_entry cli_no_debug =
+ { { "agi", "no", "debug", NULL }, agi_no_debug, "Disable AGI debugging", no_debug_usage };
+
static int handle_noop(struct ast_channel *chan, AGI *agi, int arg, char *argv[])
{
fdprintf(agi->fd, "200 result=0\n");
@@ -1469,7 +1523,8 @@
/* get rid of trailing newline, if any */
if (*buf && buf[strlen(buf) - 1] == '\n')
buf[strlen(buf) - 1] = 0;
-
+ if (agidebug)
+ ast_verbose("AGI Rx << %s\n", buf);
returnstatus |= agi_handle_command(chan, agi, buf);
/* If the handle_command returns -1, we need to stop */
if ((returnstatus < 0) || (returnstatus == AST_PBX_KEEPALIVE)) {
@@ -1672,6 +1727,8 @@
STANDARD_HANGUP_LOCALUSERS;
ast_cli_unregister(&showagi);
ast_cli_unregister(&dumpagihtml);
+ ast_cli_unregister(&cli_debug);
+ ast_cli_unregister(&cli_no_debug);
ast_unregister_application(eapp);
ast_unregister_application(deadapp);
return ast_unregister_application(app);
@@ -1681,6 +1738,8 @@
{
ast_cli_register(&showagi);
ast_cli_register(&dumpagihtml);
+ ast_cli_register(&cli_debug);
+ ast_cli_register(&cli_no_debug);
ast_register_application(deadapp, deadagi_exec, deadsynopsis, descrip);
ast_register_application(eapp, eagi_exec, esynopsis, descrip);
return ast_register_application(app, agi_exec, synopsis, descrip);
More information about the svn-commits
mailing list