[svn-commits] russell: trunk r72921 - /trunk/main/pbx.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Jul 2 11:42:47 CDT 2007
Author: russell
Date: Mon Jul 2 11:42:47 2007
New Revision: 72921
URL: http://svn.digium.com/view/asterisk?view=rev&rev=72921
Log:
change the "core dump appdocs" CLI command to use the new API for creating
CLI commands
Modified:
trunk/main/pbx.c
Modified: trunk/main/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/main/pbx.c?view=diff&rev=72921&r1=72920&r2=72921
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Mon Jul 2 11:42:47 2007
@@ -3154,26 +3154,35 @@
}
#ifdef AST_DEVMODE
-static char core_dumpappdocs_help[] =
-"Usage: core dump appdocs [application]\n"
-" Dump Application documentation to /tmp/ast_appdocs.tex.\n";
-
-static int handle_core_dumpappdocs(int fd, int argc, char *argv[])
+static char *handle_core_dumpappdocs(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ast_app *app;
FILE *f;
char *appname = NULL;
const char *fn = "/tmp/ast_appdocs.tex";
- if (argc > 3)
- appname = argv[3];
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "core dump appdocs";
+ e->usage =
+ "Usage: core dump appdocs [application]\n"
+ " Dump Application documentation to /tmp/ast_appdocs.tex.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc == e->args + 1)
+ appname = a->argv[e->args];
+ else if (a->argc != e->args)
+ return CLI_SHOWUSAGE;
if (!(f = fopen(fn, "w+"))) {
- ast_cli(fd, "Unable to open %s for writing!\n", fn);
- return RESULT_FAILURE;
- }
-
- fprintf(f, "%% This file is automatically generated. Any manual edits will be lost.\n");
+ ast_cli(a->fd, "Unable to open %s for writing!\n", fn);
+ return CLI_FAILURE;
+ }
+
+ fprintf(f, "%% This file is automatically generated by the \"core dump appdocs\" CLI command. Any manual edits will be lost.\n");
AST_RWLIST_RDLOCK(&apps);
AST_RWLIST_TRAVERSE(&apps, app, list) {
@@ -3197,9 +3206,9 @@
fclose(f);
- ast_cli(fd, "Documentation has been dumped to %s\n", fn);
-
- return RESULT_SUCCESS;
+ ast_cli(a->fd, "Documentation has been dumped to %s\n", fn);
+
+ return CLI_SUCCESS;
}
#endif
@@ -3870,9 +3879,7 @@
show_application_help, complete_show_application },
#ifdef AST_DEVMODE
- { { "core", "dump", "appdocs", NULL },
- handle_core_dumpappdocs, "Dump application documentation in LaTeX format",
- core_dumpappdocs_help, NULL },
+ NEW_CLI(handle_core_dumpappdocs, "Dump application documentation in LaTeX format"),
#endif
{ { "core", "set", "global", NULL },
More information about the svn-commits
mailing list