[asterisk-commits] mvanbaak: branch mvanbaak/cli-command-audit r102502 - /team/mvanbaak/cli-comm...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Feb 5 15:11:07 CST 2008
Author: mvanbaak
Date: Tue Feb 5 15:11:06 2008
New Revision: 102502
URL: http://svn.digium.com/view/asterisk?view=rev&rev=102502
Log:
agi dumphtml -> agi dump html
Modified:
team/mvanbaak/cli-command-audit/res/res_agi.c
Modified: team/mvanbaak/cli-command-audit/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/team/mvanbaak/cli-command-audit/res/res_agi.c?view=diff&rev=102502&r1=102501&r2=102502
==============================================================================
--- team/mvanbaak/cli-command-audit/res/res_agi.c (original)
+++ team/mvanbaak/cli-command-audit/res/res_agi.c Tue Feb 5 15:11:06 2008
@@ -2785,12 +2785,56 @@
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;
+ 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");
+ fprintf(htmlfile, "<TABLE BORDER=\"0\" CELLSPACING=\"10\">\n");
+
+ AST_RWLIST_RDLOCK(&agi_commands);
+ AST_RWLIST_TRAVERSE(&agi_commands, command, list) {
+ char *stringp, *tempstr;
+
+ if (!command->cmda[0]) /* end ? */
+ break;
+ /* Hide commands that start with '_' */
+ if ((command->cmda[0])[0] == '_')
+ continue;
+ ast_join(fullcmd, sizeof(fullcmd), command->cmda);
+
+ fprintf(htmlfile, "<TR><TD><TABLE BORDER=\"1\" CELLPADDING=\"5\" WIDTH=\"100%%\">\n");
+ fprintf(htmlfile, "<TR><TH ALIGN=\"CENTER\"><B>%s - %s</B></TH></TR>\n", fullcmd, command->summary);
+
+ stringp = command->usage;
+ tempstr = strsep(&stringp, "\n");
+
+ fprintf(htmlfile, "<TR><TD ALIGN=\"CENTER\">");
+ write_html_escaped(htmlfile, tempstr);
+ fprintf(htmlfile, "</TD></TR>\n");
+ fprintf(htmlfile, "<TR><TD ALIGN=\"CENTER\">\n");
+
+ while ((tempstr = strsep(&stringp, "\n")) != NULL) {
+ write_html_escaped(htmlfile, tempstr);
+ fprintf(htmlfile, "<BR>\n");
+ }
+ fprintf(htmlfile, "</TD></TR>\n");
+ fprintf(htmlfile, "</TABLE></TD></TR>\n\n");
+ }
+ 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";
@@ -2805,48 +2849,35 @@
if (a->argc < e->args + 1)
return CLI_SHOWUSAGE;
- if (!(htmlfile = fopen(a->argv[2], "wt"))) {
+ if (write_htmldump(a->argv[2]) < 0) {
ast_cli(a->fd, "Could not create file '%s'\n", a->argv[2]);
return CLI_SHOWUSAGE;
}
-
- 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");
- fprintf(htmlfile, "<TABLE BORDER=\"0\" CELLSPACING=\"10\">\n");
-
- AST_RWLIST_RDLOCK(&agi_commands);
- AST_RWLIST_TRAVERSE(&agi_commands, command, list) {
- char *stringp, *tempstr;
-
- if (!command->cmda[0]) /* end ? */
- break;
- /* Hide commands that start with '_' */
- if ((command->cmda[0])[0] == '_')
- continue;
- ast_join(fullcmd, sizeof(fullcmd), command->cmda);
-
- fprintf(htmlfile, "<TR><TD><TABLE BORDER=\"1\" CELLPADDING=\"5\" WIDTH=\"100%%\">\n");
- fprintf(htmlfile, "<TR><TH ALIGN=\"CENTER\"><B>%s - %s</B></TH></TR>\n", fullcmd, command->summary);
-
- stringp = command->usage;
- tempstr = strsep(&stringp, "\n");
-
- fprintf(htmlfile, "<TR><TD ALIGN=\"CENTER\">");
- write_html_escaped(htmlfile, tempstr);
- fprintf(htmlfile, "</TD></TR>\n");
- fprintf(htmlfile, "<TR><TD ALIGN=\"CENTER\">\n");
-
- while ((tempstr = strsep(&stringp, "\n")) != NULL) {
- write_html_escaped(htmlfile, tempstr);
- fprintf(htmlfile, "<BR>\n");
- }
- fprintf(htmlfile, "</TD></TR>\n");
- fprintf(htmlfile, "</TABLE></TD></TR>\n\n");
- }
- AST_RWLIST_UNLOCK(&agi_commands);
- fprintf(htmlfile, "</TABLE>\n</BODY>\n</HTML>\n");
- fclose(htmlfile);
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;
}
@@ -2959,11 +2990,13 @@
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)
More information about the asterisk-commits
mailing list