mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-29 18:19:30 +00:00
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
This commit is contained in:
41
main/pbx.c
41
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];
|
||||
|
||||
if (!(f = fopen(fn, "w+"))) {
|
||||
ast_cli(fd, "Unable to open %s for writing!\n", fn);
|
||||
return RESULT_FAILURE;
|
||||
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;
|
||||
}
|
||||
|
||||
fprintf(f, "%% This file is automatically generated. Any manual edits will be lost.\n");
|
||||
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(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 @@ 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 },
|
||||
|
Reference in New Issue
Block a user