Index: main/pbx.c =================================================================== --- main/pbx.c (Revision 355447) +++ main/pbx.c (Arbeitskopie) @@ -5902,6 +5902,9 @@ } } else { /* easy, we are not first priority in extension */ previous_peer->peer = peer->peer; +#define FORMAT_STRING " %20s@%-20.20s: %-20.20s State:%-15.15s Watchers %2d\n" +#define CONCISE_FORMAT_STRING "%s!%s!%s!%s!%d\n" + } /* now, free whole priority extension */ @@ -6211,22 +6214,35 @@ /*! \brief handle_show_hints: CLI support for listing registered dial plan hints */ static char *handle_show_hints(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { +#define FORMAT_STRING " %20s@%-20.20s: %-20.20s State:%-15.15s Watchers %2d\n" +#define CONCISE_FORMAT_STRING "%s!%s!%s!%s!%d\n" struct ast_hint *hint; - int num = 0; + int num = 0, concise = 0; int watchers; struct ao2_iterator i; switch (cmd) { case CLI_INIT: - e->command = "core show hints"; + e->command = "core show hints [concise]"; e->usage = - "Usage: core show hints\n" - " List registered hints\n"; + "Usage: core show hints [concise]\n" + " List registered hints. If 'concise' is specified,\n" + " the format is abridged and in a more easily machine\n" + " parsable format.\n"; return NULL; case CLI_GENERATE: return NULL; } + + if (a->argc == e->args) { + if (!strcasecmp(a->argv[e->args-1],"concise")) + concise = 1; + else + return CLI_SHOWUSAGE; + } else if (a->argc != e->args - 1) + return CLI_SHOWUSAGE; + if (ao2_container_count(hints) == 0) { ast_cli(a->fd, "There are no registered dialplan hints\n"); return CLI_SUCCESS; @@ -6243,11 +6259,19 @@ continue; } watchers = ao2_container_count(hint->callbacks); - ast_cli(a->fd, " %20s@%-20.20s: %-20.20s State:%-15.15s Watchers %2d\n", - ast_get_extension_name(hint->exten), - ast_get_context_name(ast_get_extension_context(hint->exten)), - ast_get_extension_app(hint->exten), - ast_extension_state2str(hint->laststate), watchers); + if (concise) { + ast_cli(a->fd, CONCISE_FORMAT_STRING, + ast_get_extension_name(hint->exten), + ast_get_context_name(ast_get_extension_context(hint->exten)), + ast_get_extension_app(hint->exten), + ast_extension_state2str(hint->laststate), watchers); + } else { + ast_cli(a->fd, FORMAT_STRING, + ast_get_extension_name(hint->exten), + ast_get_context_name(ast_get_extension_context(hint->exten)), + ast_get_extension_app(hint->exten), + ast_extension_state2str(hint->laststate), watchers); + } ao2_unlock(hint); num++; } @@ -6256,6 +6280,8 @@ ast_cli(a->fd, "----------------\n"); ast_cli(a->fd, "- %d hints registered\n", num); return CLI_SUCCESS; +#undef FORMAT_STRING +#undef CONCISE_FORMAT_STRING } /*! \brief autocomplete for CLI command 'core show hint' */