[asterisk-commits] mvanbaak: branch mvanbaak/cli-command-audit r102776 - /team/mvanbaak/cli-comm...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 6 13:50:33 CST 2008


Author: mvanbaak
Date: Wed Feb  6 13:50:32 2008
New Revision: 102776

URL: http://svn.digium.com/view/asterisk?view=rev&rev=102776
Log:
funcdevstate list -> devstate list

Modified:
    team/mvanbaak/cli-command-audit/funcs/func_devstate.c

Modified: team/mvanbaak/cli-command-audit/funcs/func_devstate.c
URL: http://svn.digium.com/view/asterisk/team/mvanbaak/cli-command-audit/funcs/func_devstate.c?view=diff&rev=102776&r1=102775&r2=102776
==============================================================================
--- team/mvanbaak/cli-command-audit/funcs/func_devstate.c (original)
+++ team/mvanbaak/cli-command-audit/funcs/func_devstate.c Wed Feb  6 13:50:32 2008
@@ -127,7 +127,7 @@
 	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 @@
 	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 = {




More information about the asterisk-commits mailing list