summaryrefslogtreecommitdiff
path: root/funcs/func_devstate.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2008-02-08 21:26:32 +0000
committerRussell Bryant <russell@russellbryant.com>2008-02-08 21:26:32 +0000
commit1ec8cb41a8170201f45ff0efe65e96aa97e0b8d3 (patch)
tree425b3dafd75451669e2311d091127fe03d3c9693 /funcs/func_devstate.c
parent52595c5d30f311b4e8d1c089577b8679adde232e (diff)
Merge changes from team/mvanbaak/cli-command-audit
(closes issue #8925) About a year ago, as Leif Madsen and Jim van Meggelen were going over the CLI commands in Asterisk 1.4 for the next version of their book, they documented a lot of inconsistencies. This set of changes addresses all of these issues and has been reviewed by Leif. While this does introduce even more changes to the CLI command structure, it makes everything consistent, which is the most important thing. Thanks to all that helped with this one! git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@103171 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs/func_devstate.c')
-rw-r--r--funcs/func_devstate.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/funcs/func_devstate.c b/funcs/func_devstate.c
index 950208be5..220fd50c3 100644
--- a/funcs/func_devstate.c
+++ b/funcs/func_devstate.c
@@ -127,7 +127,7 @@ static enum ast_device_state custom_devstate_callback(const char *data)
return ast_devstate_val(buf);
}
-static char *cli_funcdevstate_list(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *handle_cli_funcdevstate_list(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ast_db_entry *db_entry, *db_tree;
@@ -171,8 +171,53 @@ static char *cli_funcdevstate_list(struct ast_cli_entry *e, int cmd, struct ast_
return CLI_SUCCESS;
}
+static char *handle_cli_devstate_list(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ struct ast_db_entry *db_entry, *db_tree;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "devstate list";
+ e->usage =
+ "Usage: devstate list\n"
+ " List all custom device states that have been set by using\n"
+ " the DEVICE_STATE dialplan function.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != e->args)
+ return CLI_SHOWUSAGE;
+
+ ast_cli(a->fd, "\n"
+ "---------------------------------------------------------------------\n"
+ "--- Custom Device States --------------------------------------------\n"
+ "---------------------------------------------------------------------\n"
+ "---\n");
+
+ db_entry = db_tree = ast_db_gettree(astdb_family, NULL);
+ for (; db_entry; db_entry = db_entry->next) {
+ const char *dev_name = strrchr(db_entry->key, '/') + 1;
+ if (dev_name <= (const char *) 1)
+ continue;
+ ast_cli(a->fd, "--- Name: 'Custom:%s' State: '%s'\n"
+ "---\n", dev_name, db_entry->data);
+ }
+ ast_db_freetree(db_tree);
+ db_tree = NULL;
+
+ ast_cli(a->fd,
+ "---------------------------------------------------------------------\n"
+ "---------------------------------------------------------------------\n"
+ "\n");
+
+ return CLI_SUCCESS;
+}
+
+static struct ast_cli_entry cli_funcdevstate_list_deprecated = AST_CLI_DEFINE(handle_cli_funcdevstate_list, "List currently known custom device states");
static struct ast_cli_entry cli_funcdevstate[] = {
- AST_CLI_DEFINE(cli_funcdevstate_list, "List currently known custom device states"),
+ AST_CLI_DEFINE(handle_cli_devstate_list, "List currently known custom device states", .deprecate_cmd = &cli_funcdevstate_list_deprecated),
};
static struct ast_custom_function devstate_function = {