diff options
Diffstat (limited to 'res')
-rw-r--r-- | res/res_agi.c | 95 | ||||
-rw-r--r-- | res/res_jabber.c | 99 |
2 files changed, 127 insertions, 67 deletions
diff --git a/res/res_agi.c b/res/res_agi.c index 0fea962fc..70df02c62 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -1655,9 +1655,9 @@ static char *handle_cli_agi_debug(struct ast_cli_entry *e, int cmd, struct ast_c { switch (cmd) { case CLI_INIT: - e->command = "agi debug [off]"; + e->command = "agi set debug [on|off]"; e->usage = - "Usage: agi debug [off]\n" + "Usage: agi set debug [on|off]\n" " Enables/disables dumping of AGI transactions for\n" " debugging purposes.\n"; return NULL; @@ -1665,16 +1665,16 @@ static char *handle_cli_agi_debug(struct ast_cli_entry *e, int cmd, struct ast_c case CLI_GENERATE: return NULL; } - if (a->argc < e->args - 1 || a->argc > e->args ) + + if (a->argc != e->args) return CLI_SHOWUSAGE; - if (a->argc == e->args - 1) { + + if (strncasecmp(a->argv[3], "off", 3) == 0) { + agidebug = 0; + } else if (strncasecmp(a->argv[3], "on", 2) == 0) { agidebug = 1; } else { - if (strncasecmp(a->argv[e->args - 1], "off", 3) == 0) { - agidebug = 0; - } else { - return CLI_SHOWUSAGE; - } + return CLI_SHOWUSAGE; } ast_cli(a->fd, "AGI Debugging %sabled\n", agidebug ? "En" : "Dis"); return CLI_SUCCESS; @@ -2767,30 +2767,14 @@ static void write_html_escaped(FILE *htmlfile, char *str) return; } -static char *handle_cli_agi_dumphtml(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static int write_htmldump(char *filename) { struct agi_command *command; char fullcmd[80]; FILE *htmlfile; - switch (cmd) { - case CLI_INIT: - e->command = "agi dumphtml"; - e->usage = - "Usage: agi dumphtml <filename>\n" - " Dumps the AGI command list in HTML format to the given\n" - " file.\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - if (a->argc < e->args + 1) - return CLI_SHOWUSAGE; - - if (!(htmlfile = fopen(a->argv[2], "wt"))) { - ast_cli(a->fd, "Could not create file '%s'\n", a->argv[2]); - return CLI_SHOWUSAGE; - } + if (!(htmlfile = fopen(filename, "wt"))) + return -1; fprintf(htmlfile, "<HTML>\n<HEAD>\n<TITLE>AGI Commands</TITLE>\n</HEAD>\n"); fprintf(htmlfile, "<BODY>\n<CENTER><B><H1>AGI Commands</H1></B></CENTER>\n\n"); @@ -2828,10 +2812,57 @@ static char *handle_cli_agi_dumphtml(struct ast_cli_entry *e, int cmd, struct as AST_RWLIST_UNLOCK(&agi_commands); fprintf(htmlfile, "</TABLE>\n</BODY>\n</HTML>\n"); fclose(htmlfile); + return 0; +} + +static char *handle_cli_agi_dumphtml_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + switch (cmd) { + case CLI_INIT: + e->command = "agi dumphtml"; + e->usage = + "Usage: agi dumphtml <filename>\n" + " Dumps the AGI command list in HTML format to the given\n" + " file.\n"; + return NULL; + case CLI_GENERATE: + return NULL; + } + if (a->argc < e->args + 1) + return CLI_SHOWUSAGE; + + if (write_htmldump(a->argv[2]) < 0) { + ast_cli(a->fd, "Could not create file '%s'\n", a->argv[2]); + return CLI_SHOWUSAGE; + } ast_cli(a->fd, "AGI HTML commands dumped to: %s\n", a->argv[2]); return CLI_SUCCESS; } +static char *handle_cli_agi_dump_html(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + switch (cmd) { + case CLI_INIT: + e->command = "agi dump html"; + e->usage = + "Usage: agi dump html <filename>\n" + " Dumps the AGI command list in HTML format to the given\n" + " file.\n"; + return NULL; + case CLI_GENERATE: + return NULL; + } + if (a->argc != e->args + 1) + return CLI_SHOWUSAGE; + + if (write_htmldump(a->argv[e->args]) < 0) { + ast_cli(a->fd, "Could not create file '%s'\n", a->argv[e->args]); + return CLI_SHOWUSAGE; + } + ast_cli(a->fd, "AGI HTML commands dumped to: %s\n", a->argv[e->args]); + return CLI_SUCCESS; +} + static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int dead) { enum agi_result res; @@ -2941,11 +2972,13 @@ static int deadagi_exec(struct ast_channel *chan, void *data) return agi_exec(chan, data); } +static struct ast_cli_entry cli_agi_dumphtml_deprecated = AST_CLI_DEFINE(handle_cli_agi_dumphtml_deprecated, "Dumps a list of AGI commands in HTML format"); + static struct ast_cli_entry cli_agi[] = { AST_CLI_DEFINE(handle_cli_agi_add_cmd, "Add AGI command to a channel in Async AGI"), - AST_CLI_DEFINE(handle_cli_agi_debug, "Enable/Disable AGI debugging"), - AST_CLI_DEFINE(handle_cli_agi_show, "List AGI commands or specific help"), - AST_CLI_DEFINE(handle_cli_agi_dumphtml, "Dumps a list of AGI commands in HTML format") + AST_CLI_DEFINE(handle_cli_agi_debug, "Enable/Disable AGI debugging"), + AST_CLI_DEFINE(handle_cli_agi_show, "List AGI commands or specific help"), + AST_CLI_DEFINE(handle_cli_agi_dump_html, "Dumps a list of AGI commands in HTML format", .deprecate_cmd = &cli_agi_dumphtml_deprecated) }; static int unload_module(void) diff --git a/res/res_jabber.c b/res/res_jabber.c index 8e7a3d2af..4b7dcdd4a 100644 --- a/res/res_jabber.c +++ b/res/res_jabber.c @@ -87,9 +87,9 @@ static void *aji_recv_loop(void *data); static int aji_initialize(struct aji_client *client); static int aji_client_connect(void *data, ikspak *pak); static void aji_set_presence(struct aji_client *client, char *to, char *from, int level, char *desc); -static char *aji_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); +static char *aji_do_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); +static char *aji_do_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *aji_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); -static char *aji_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *aji_show_clients(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *aji_show_buddies(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *aji_test(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); @@ -114,9 +114,9 @@ static int aji_register_transport(void *data, ikspak *pak); static int aji_register_transport2(void *data, ikspak *pak); */ +static struct ast_cli_entry cli_aji_do_debug_deprecated = AST_CLI_DEFINE(aji_do_debug_deprecated, "Enable/disable jabber debugging"); static struct ast_cli_entry aji_cli[] = { - AST_CLI_DEFINE(aji_do_debug, "Enable jabber debugging"), - AST_CLI_DEFINE(aji_no_debug, "Disable Jabber debug"), + AST_CLI_DEFINE(aji_do_set_debug, "Enable/Disable Jabber debug", .deprecate_cmd = &cli_aji_do_debug_deprecated), AST_CLI_DEFINE(aji_do_reload, "Reload Jabber configuration"), AST_CLI_DEFINE(aji_show_clients, "Show state of clients and components"), AST_CLI_DEFINE(aji_show_buddies, "Show buddy lists of our clients"), @@ -2330,77 +2330,104 @@ static void aji_set_presence(struct aji_client *client, char *to, char *from, in } /*! - * \brief Turn on console debugging. + * \brief Turn on/off console debugging. * \return CLI_SUCCESS. */ -static char *aji_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *aji_do_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { - switch (cmd) { case CLI_INIT: - e->command = "jabber debug"; + e->command = "jabber set debug {on|off}"; e->usage = - "Usage: jabber debug\n" - " Enables dumping of Jabber packets for debugging purposes.\n"; + "Usage: jabber set debug {on|off}\n" + " Enables/disables dumping of Jabber packets for debugging purposes.\n"; return NULL; case CLI_GENERATE: return NULL; } - ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { - ASTOBJ_RDLOCK(iterator); - iterator->debug = 1; - ASTOBJ_UNLOCK(iterator); - }); - ast_cli(a->fd, "Jabber Debugging Enabled.\n"); - return CLI_SUCCESS; + if (a->argc != e->args) + return CLI_SHOWUSAGE; + + if (!strncasecmp(a->argv[e->args - 1], "on", 2)) { + ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { + ASTOBJ_RDLOCK(iterator); + iterator->debug = 1; + ASTOBJ_UNLOCK(iterator); + }); + ast_cli(a->fd, "Jabber Debugging Enabled.\n"); + return CLI_SUCCESS; + } else if (!strncasecmp(a->argv[e->args - 1], "off", 3)) { + ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { + ASTOBJ_RDLOCK(iterator); + iterator->debug = 0; + ASTOBJ_UNLOCK(iterator); + }); + ast_cli(a->fd, "Jabber Debugging Disabled.\n"); + return CLI_SUCCESS; + } + return CLI_SHOWUSAGE; /* defaults to invalid */ } /*! - * \brief Reload jabber module. + * \brief Turn on/off console debugging (deprecated, use aji_do_set_debug). * \return CLI_SUCCESS. */ -static char *aji_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *aji_do_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { + switch (cmd) { case CLI_INIT: - e->command = "jabber reload"; + e->command = "jabber debug [off]"; e->usage = - "Usage: jabber reload\n" - " Reloads the Jabber module.\n"; + "Usage: jabber debug [off]\n" + " Enables/disables dumping of Jabber packets for debugging purposes.\n"; return NULL; case CLI_GENERATE: return NULL; } - aji_reload(1); - ast_cli(a->fd, "Jabber Reloaded.\n"); - return CLI_SUCCESS; + if (a->argc == 2) { + ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { + ASTOBJ_RDLOCK(iterator); + iterator->debug = 1; + ASTOBJ_UNLOCK(iterator); + }); + ast_cli(a->fd, "Jabber Debugging Enabled.\n"); + return CLI_SUCCESS; + } else if (a->argc == 3) { + if (!strncasecmp(a->argv[2], "off", 3)) { + ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { + ASTOBJ_RDLOCK(iterator); + iterator->debug = 0; + ASTOBJ_UNLOCK(iterator); + }); + ast_cli(a->fd, "Jabber Debugging Disabled.\n"); + return CLI_SUCCESS; + } + } + return CLI_SHOWUSAGE; /* defaults to invalid */ } /*! - * \brief Turn off console debugging. + * \brief Reload jabber module. * \return CLI_SUCCESS. */ -static char *aji_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *aji_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: - e->command = "jabber debug off"; + e->command = "jabber reload"; e->usage = - "Usage: jabber debug off\n" - " Disables dumping of Jabber packets for debugging purposes.\n"; + "Usage: jabber reload\n" + " Reloads the Jabber module.\n"; return NULL; case CLI_GENERATE: return NULL; } - ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { - ASTOBJ_RDLOCK(iterator); - iterator->debug = 0; - ASTOBJ_UNLOCK(iterator); - }); - ast_cli(a->fd, "Jabber Debugging Disabled.\n"); + aji_reload(1); + ast_cli(a->fd, "Jabber Reloaded.\n"); return CLI_SUCCESS; } |