From: Russell Bryant Date: Mon, 2 Jul 2007 16:42:47 +0000 (+0000) Subject: change the "core dump appdocs" CLI command to use the new API for creating X-Git-Tag: 1.6.0-beta1~3^2~2185 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1468915c74056394f733d394b5df177ae34d255;p=thirdparty%2Fasterisk.git change the "core dump appdocs" CLI command to use the new API for creating CLI commands git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@72921 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/pbx.c b/main/pbx.c index 471c1c3d25..6d36fb66ae 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 },