[asterisk-commits] junky: branch junky/cli-tls r210698 - /team/junky/cli-tls/main/logger.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 5 17:58:32 CDT 2009


Author: junky
Date: Wed Aug  5 17:58:28 2009
New Revision: 210698

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=210698
Log:
switch all core * CLI commands to cli commands as pointed by corydon.
Write CLI command: cli reset filters
This commands is to quickly remove all CLI filters



Modified:
    team/junky/cli-tls/main/logger.c

Modified: team/junky/cli-tls/main/logger.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/junky/cli-tls/main/logger.c?view=diff&rev=210698&r1=210697&r2=210698
==============================================================================
--- team/junky/cli-tls/main/logger.c (original)
+++ team/junky/cli-tls/main/logger.c Wed Aug  5 17:58:28 2009
@@ -783,9 +783,9 @@
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "core show filters";
+		e->command = "cli show filters";
 		e->usage =
-			"Usage: core show filters\n"
+			"Usage: cli show filters\n"
 			"       List All CLI filters\n";
 		return NULL;
 	case CLI_GENERATE:
@@ -816,9 +816,9 @@
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "core add filter [name|cid_num|accountcode]";
+		e->command = "cli add filter [name|cid_num|accountcode]";
 		e->usage =
-			"Usage: core add filter <keyword> <name>\n"
+			"Usage: cli add filter <keyword> <name>\n"
 			"       Add a new CLI filter\n"
 			"keywords are: name, cid_num and accountcode\n";
 		return NULL;
@@ -881,9 +881,9 @@
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "core remove filter";
+		e->command = "cli remove filter";
 		e->usage =
-			"Usage: core remove filter <filter_name>\n"
+			"Usage: cli remove filter <filter_name>\n"
 			"       Remove a specific filter_name\n";
 		return NULL;
 	case CLI_GENERATE:
@@ -926,6 +926,37 @@
 	return CLI_SUCCESS;
 }
 
+static char *handle_reset_filters(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+        struct ast_cli_filter *filter;
+	int count = 0;
+
+        switch (cmd) {
+        case CLI_INIT:
+                e->command = "cli reset filters";
+                e->usage =
+                        "Usage: cli reset filters\n"
+                        "       Remove all CLI filters and switch back to normal mode.\n";
+                return NULL;
+        case CLI_GENERATE:
+                return NULL;
+        }
+
+        if (a->argc != 3) {
+                return CLI_SHOWUSAGE;
+        }
+
+                AST_LIST_TRAVERSE_SAFE_BEGIN(&ast_cli_filters, filter, filter_list) {
+                	AST_LIST_REMOVE_CURRENT(filter_list);
+                        ast_free(filter->name); /* since I ast_strdup it */
+                        ast_free(filter);
+			count++;
+                AST_LIST_TRAVERSE_SAFE_END;
+                }
+                ast_cli(a->fd, "%d CLI filters has been sucessfully removed.\n", count);
+		
+        return CLI_SUCCESS;
+}
 
 
 struct verb {
@@ -943,6 +974,7 @@
         AST_CLI_DEFINE(handle_show_filters, "Show CLI filters"),
         AST_CLI_DEFINE(handle_add_filter, "Add CLI filter"),
         AST_CLI_DEFINE(handle_remove_filter, "Remove CLI filter"),
+        AST_CLI_DEFINE(handle_reset_filters, "Remove all CLI filters"),
 
 };
 




More information about the asterisk-commits mailing list