mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 10:33:13 +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
|
#ifdef AST_DEVMODE
|
||||||
static char core_dumpappdocs_help[] =
|
static char *handle_core_dumpappdocs(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
||||||
"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[])
|
|
||||||
{
|
{
|
||||||
struct ast_app *app;
|
struct ast_app *app;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char *appname = NULL;
|
char *appname = NULL;
|
||||||
const char *fn = "/tmp/ast_appdocs.tex";
|
const char *fn = "/tmp/ast_appdocs.tex";
|
||||||
|
|
||||||
if (argc > 3)
|
switch (cmd) {
|
||||||
appname = argv[3];
|
case CLI_INIT:
|
||||||
|
e->command = "core dump appdocs";
|
||||||
if (!(f = fopen(fn, "w+"))) {
|
e->usage =
|
||||||
ast_cli(fd, "Unable to open %s for writing!\n", fn);
|
"Usage: core dump appdocs [application]\n"
|
||||||
return RESULT_FAILURE;
|
" 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_RDLOCK(&apps);
|
||||||
AST_RWLIST_TRAVERSE(&apps, app, list) {
|
AST_RWLIST_TRAVERSE(&apps, app, list) {
|
||||||
@@ -3197,9 +3206,9 @@ static int handle_core_dumpappdocs(int fd, int argc, char *argv[])
|
|||||||
|
|
||||||
fclose(f);
|
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
|
#endif
|
||||||
|
|
||||||
@@ -3870,9 +3879,7 @@ static struct ast_cli_entry pbx_cli[] = {
|
|||||||
show_application_help, complete_show_application },
|
show_application_help, complete_show_application },
|
||||||
|
|
||||||
#ifdef AST_DEVMODE
|
#ifdef AST_DEVMODE
|
||||||
{ { "core", "dump", "appdocs", NULL },
|
NEW_CLI(handle_core_dumpappdocs, "Dump application documentation in LaTeX format"),
|
||||||
handle_core_dumpappdocs, "Dump application documentation in LaTeX format",
|
|
||||||
core_dumpappdocs_help, NULL },
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{ { "core", "set", "global", NULL },
|
{ { "core", "set", "global", NULL },
|
||||||
|
Reference in New Issue
Block a user