aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_agi.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-09-25 14:22:27 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-09-25 14:22:27 +0000
commitdd430e42f72393c654eaeb4eb365b0446eeaed46 (patch)
treed8a798b0062eca833e4caf5b0a86c08acd44a8a9 /res/res_agi.c
parent0df2499ae3a9b647bbe97c3ef0982a23f8c2b9c3 (diff)
Make holdtime announcement say "less than 2 minutes" instead of "1 minutes" (bug #2500)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3834 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_agi.c')
-rwxr-xr-xres/res_agi.c63
1 files changed, 61 insertions, 2 deletions
diff --git a/res/res_agi.c b/res/res_agi.c
index 2a58a5bf5..b50470817 100755
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -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 @@ static char *descrip =
"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 @@ LOCAL_USER_DECL;
#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 @@ static int handle_dbdeltree(struct ast_channel *chan, AGI *agi, int argc, char *
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 @@ static int run_agi(struct ast_channel *chan, char *request, AGI *agi, int pid, i
/* 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 @@ int unload_module(void)
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 @@ int load_module(void)
{
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);