return ret;
}
+#ifdef AST_DEVMODE
+static char *handle_manager_dump_actiondocs(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ struct manager_action *action;
+ FILE *f;
+ char *action_name = NULL;
+ const char *fn = "/tmp/ast_manager_actiondocs.tex";
+ struct ast_str *authority = ast_str_alloca(80);
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "manager dump actiondocs";
+ e->usage =
+ "Usage: manager dump actiondocs [action]\n"
+ " Dump manager action documentation to /tmp/ast_manager_actiondocs.tex.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc == e->args + 1)
+ action_name = 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 \"manager dump actiondocs\" CLI command. Any manual edits will be lost.\n");
+
+ ast_rwlock_rdlock(&actionlock);
+ for (action = first_action; action; action = action->next) {
+ if (action_name && strcasecmp(action->action, action_name))
+ continue;
+
+ fprintf(f, "\\section{%s}\n"
+ "\\subsection{Synopsis}\n"
+ "\\begin{verbatim}\n"
+ "%s\n"
+ "\\end{verbatim}\n"
+ "\\subsection{Authority}\n"
+ "\\begin{verbatim}\n"
+ "%s\n"
+ "\\end{verbatim}\n"
+ "\\subsection{Description}\n"
+ "\\begin{verbatim}\n"
+ "%s\n"
+ "\\end{verbatim}\n\n\n",
+ action->action, action->synopsis,
+ authority_to_str(action->authority, &authority),
+ action->description);
+
+ if (action_name)
+ break;
+ }
+ ast_rwlock_unlock(&actionlock);
+
+ fclose(f);
+
+ ast_cli(a->fd, "Documentation has been dumped to %s\n", fn);
+
+ return CLI_SUCCESS;
+}
+#endif /* AST_DEVMODE */
+
static int handle_showmancmd(int fd, int argc, char *argv[])
{
struct manager_action *cur;
{ { "manager", "debug", NULL },
handle_mandebug, "Show, enable, disable debugging of the manager code",
"Usage: manager debug [on|off]\n Show, enable, disable debugging of the manager code.\n", NULL, NULL },
+
+#ifdef AST_DEVMODE
+ NEW_CLI(handle_manager_dump_actiondocs, "Dump manager action documentation in LaTeX format"),
+#endif
};
/*