aboutsummaryrefslogtreecommitdiffstats
path: root/funcs
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-02-08 21:26:32 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-02-08 21:26:32 +0000
commite9d6c2ff9b22167c463b055b65e8351dc0a4cc0c (patch)
tree425b3dafd75451669e2311d091127fe03d3c9693 /funcs
parent381f0dce1439f8c5344300a846760ea930987ed3 (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: http://svn.digium.com/svn/asterisk/trunk@103171 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-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 = {