aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-02 16:42:47 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-02 16:42:47 +0000
commitcf783d670fae753465cfef41ba947c1774e7a55d (patch)
tree901707071fe8f6d95ce8f64bd922ba61feb2d70e /main
parent68f7b88d24ca87465dd30bd85e2ca83103e2e5a0 (diff)
change the "core dump appdocs" CLI command to use the new API for creating
CLI commands git-svn-id: http://svn.digium.com/svn/asterisk/trunk@72921 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/pbx.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/main/pbx.c b/main/pbx.c
index 471c1c3d2..6d36fb66a 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -3154,26 +3154,35 @@ static int handle_show_application(int fd, int argc, char *argv[])
}
#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;
+ ast_cli(a->fd, "Unable to open %s for writing!\n", fn);
+ return CLI_FAILURE;
}
- fprintf(f, "%% This file is automatically generated. Any manual edits will be lost.\n");
+ 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 @@ static int handle_core_dumpappdocs(int fd, int argc, char *argv[])
fclose(f);
- ast_cli(fd, "Documentation has been dumped to %s\n", fn);
+ ast_cli(a->fd, "Documentation has been dumped to %s\n", fn);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
#endif
@@ -3870,9 +3879,7 @@ static struct ast_cli_entry pbx_cli[] = {
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 },