[asterisk-commits] russell: trunk r72931 - /trunk/res/res_agi.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jul 2 14:29:51 CDT 2007
Author: russell
Date: Mon Jul 2 14:29:50 2007
New Revision: 72931
URL: http://svn.digium.com/view/asterisk?view=rev&rev=72931
Log:
Add a CLI command to export the AGI command docs
Modified:
trunk/res/res_agi.c
Modified: trunk/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_agi.c?view=diff&rev=72931&r1=72930&r2=72931
==============================================================================
--- trunk/res/res_agi.c (original)
+++ trunk/res/res_agi.c Mon Jul 2 14:29:50 2007
@@ -1673,6 +1673,71 @@
return 0;
}
+#ifdef AST_DEVMODE
+static char *handle_agi_dump_commanddocs(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ FILE *f;
+ char *command_name = NULL;
+ const char *fn = "/tmp/ast_agi_commands.tex";
+ int i;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "agi dump commanddocs";
+ e->usage =
+ "Usage: agi dump commanddocs [command]\n"
+ " Dump manager action documentation to /tmp/ast_agi_commands.tex.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc == e->args + 1)
+ command_name = a->argv[e->args];
+ else if (a->argc != e->args)
+ return CLI_SHOWUSAGE;
+
+ if (!(f = fopen(fn, "w+"))) {
+ ast_cli(a->fd, "Unable to open %s for writing!\n", fn);
+ return CLI_FAILURE;
+ }
+
+ fprintf(f, "%% This file is automatically generated by the \"manager dump actiondocs\" CLI command. Any manual edits will be lost.\n");
+
+ /* XXX Not thread safe :( */
+ for (i = 0; i < ARRAY_LEN(commands); i++) {
+ struct agi_command *command;
+ char fullcmd[80];
+
+ command = &commands[i];
+ ast_join(fullcmd, sizeof(fullcmd), command->cmda);
+
+ if (command_name && strcasecmp(fullcmd, command_name))
+ continue;
+
+ fprintf(f, "\\section{%s}\n"
+ "\\subsection{Summary}\n"
+ "\\begin{verbatim}\n"
+ "%s\n"
+ "\\end{verbatim}\n"
+ "\\subsection{Usage}\n"
+ "\\begin{verbatim}\n"
+ "%s\n"
+ "\\end{verbatim}\n\n\n",
+ fullcmd, command->summary, command->usage);
+
+ if (command_name)
+ break;
+ }
+
+ fclose(f);
+
+ ast_cli(a->fd, "Documentation has been dumped to %s\n", fn);
+
+ return CLI_SUCCESS;
+}
+#endif /* AST_DEVMODE */
+
int ast_agi_register(agi_command *agi)
{
int x;
@@ -2164,6 +2229,10 @@
{ { "agi", "dumphtml", NULL },
handle_agidumphtml, "Dumps a list of agi commands in html format",
dumpagihtml_help },
+
+#ifdef AST_DEVMODE
+ NEW_CLI(handle_agi_dump_commanddocs, "Dump agi command documentation in LaTeX format"),
+#endif
};
static int unload_module(void)
More information about the asterisk-commits
mailing list