summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorOlle Johansson <oej@edvina.net>2007-12-04 15:07:53 +0000
committerOlle Johansson <oej@edvina.net>2007-12-04 15:07:53 +0000
commit25cbb792b911b19e26ce81a5a74b445d5a40432a (patch)
tree9a7b6042d283b2ab306cb6f050d2bf07658d3dd0 /main
parentd5c7e96526c5e70d0c1d56d3556602ed59a3d7ca (diff)
(closes issue #11422)
Reported by: eliel Patches: core.show.hint.patch uploaded by eliel (license 64) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@90853 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/pbx.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/main/pbx.c b/main/pbx.c
index b575f3bd9..734e0f466 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -4201,6 +4201,83 @@ static char *handle_show_hints(struct ast_cli_entry *e, int cmd, struct ast_cli_
return CLI_SUCCESS;
}
+/*! \brief autocomplete for CLI command 'core show hint' */
+static char *complete_core_show_hint(const char *line, const char *word, int pos, int state)
+{
+ struct ast_hint *hint;
+ char *ret = NULL;
+ int which = 0;
+ int wordlen;
+
+ if (pos != 3)
+ return NULL;
+
+ wordlen = strlen(word);
+
+ AST_RWLIST_RDLOCK(&hints);
+ /* walk through all hints */
+ AST_RWLIST_TRAVERSE(&hints, hint, list) {
+ if (!strncasecmp(word, ast_get_extension_name(hint->exten), wordlen) && ++which > state) {
+ ret = ast_strdup(ast_get_extension_name(hint->exten));
+ break;
+ }
+ }
+ AST_RWLIST_UNLOCK(&hints);
+
+ return ret;
+}
+
+/*! \brief handle_show_hint: CLI support for listing registered dial plan hint */
+static char *handle_show_hint(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ struct ast_hint *hint;
+ int watchers;
+ int num = 0, extenlen;
+ struct ast_state_cb *watcher;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "core show hint";
+ e->usage =
+ "Usage: core show hint <exten>\n"
+ " List registered hint\n";
+ return NULL;
+ case CLI_GENERATE:
+ return complete_core_show_hint(a->line, a->word, a->pos, a->n);
+ }
+
+ if (a->argc < 4)
+ return CLI_SHOWUSAGE;
+
+ AST_RWLIST_RDLOCK(&hints);
+ if (AST_RWLIST_EMPTY(&hints)) {
+ ast_cli(a->fd, "There are no registered dialplan hints\n");
+ AST_RWLIST_UNLOCK(&hints);
+ return CLI_SUCCESS;
+ }
+ extenlen = strlen(a->argv[3]);
+ AST_RWLIST_TRAVERSE(&hints, hint, list) {
+ if (!strncasecmp(ast_get_extension_name(hint->exten), a->argv[3], extenlen)) {
+ watchers = 0;
+ for (watcher = hint->callbacks; watcher; watcher = watcher->next)
+ watchers++;
+ 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);
+ num++;
+ }
+ }
+ AST_RWLIST_UNLOCK(&hints);
+ if (!num)
+ ast_cli(a->fd, "No hints matching extension %s\n", a->argv[3]);
+ else
+ ast_cli(a->fd, "%d hint%s matching extension %s\n", num, (num!=1 ? "s":""), a->argv[3]);
+ return CLI_SUCCESS;
+}
+
+
/*! \brief handle_show_switches: CLI support for listing registered dial plan switches */
static char *handle_show_switches(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
@@ -4929,6 +5006,7 @@ static struct ast_cli_entry pbx_cli[] = {
AST_CLI_DEFINE(handle_show_functions, "Shows registered dialplan functions"),
AST_CLI_DEFINE(handle_show_switches, "Show alternative switches"),
AST_CLI_DEFINE(handle_show_hints, "Show dialplan hints"),
+ AST_CLI_DEFINE(handle_show_hint, "Show dialplan hint"),
AST_CLI_DEFINE(handle_show_globals, "Show global dialplan variables"),
AST_CLI_DEFINE(handle_show_function, "Describe a specific dialplan function"),
AST_CLI_DEFINE(handle_show_application, "Describe a specific dialplan application"),