[svn-commits] junky: branch junky/cli-tls r204892 - in /team/junky/cli-tls: include/asteris...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jul 2 20:35:30 CDT 2009


Author: junky
Date: Thu Jul  2 20:35:26 2009
New Revision: 204892

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=204892
Log:
handle_show_filters, handle_add_filter, handle_remove_filter to logger.c since the TLS list is there.
Traverse the filters list in ast_log() to detect that the current output is or not in my list.


Modified:
    team/junky/cli-tls/include/asterisk/logger.h
    team/junky/cli-tls/main/logger.c
    team/junky/cli-tls/main/pbx.c

Modified: team/junky/cli-tls/include/asterisk/logger.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/junky/cli-tls/include/asterisk/logger.h?view=diff&rev=204892&r1=204891&r2=204892
==============================================================================
--- team/junky/cli-tls/include/asterisk/logger.h (original)
+++ team/junky/cli-tls/include/asterisk/logger.h Thu Jul  2 20:35:26 2009
@@ -179,6 +179,7 @@
 #define AST_LOG_DTMF    __LOG_DTMF, _A_
 
 #define NUMLOGLEVELS 6
+
 
 /*!
  * \brief Get the debug level for a file

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=204892&r1=204891&r2=204892
==============================================================================
--- team/junky/cli-tls/main/logger.c (original)
+++ team/junky/cli-tls/main/logger.c Thu Jul  2 20:35:26 2009
@@ -215,10 +215,21 @@
 AST_LIST_HEAD_NOLOCK(ast_channels, logger_filter_list_item);
 
 struct logger_filter_list_item {
-        struct ast_channels list;
         struct ast_channel *chan;
         AST_LIST_ENTRY(logger_filter_list_item) next;
 };
+
+
+/* Structure for the cli filter */
+struct ast_cli_filter {
+        char *name;                                     /*!< Name of the filter */
+        int type;                                       /*!< Type of the filter currently, only 0 is used */
+        AST_LIST_ENTRY(ast_cli_filter) filter_list;     /*!< pointer to the next element */
+};
+/* List used to store all cli filters entered by the user */
+AST_LIST_HEAD_NOLOCK_STATIC(ast_cli_filters, ast_cli_filter);
+
+
 
 static unsigned int make_components(const char *s, int lineno)
 {
@@ -756,6 +767,119 @@
 	return CLI_SUCCESS;
 }
 
+
+static char *handle_show_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 = "core show filters";
+                e->usage =
+                        "Usage: core show filters\n"
+                        "       List All CLI filters\n";
+                return NULL;
+        case CLI_GENERATE:
+                return NULL;
+        }
+
+        if (a->argc != 3) {
+                return CLI_SHOWUSAGE;
+        }
+
+        ast_cli(a->fd, "Active CLI Filters:\n---------------------------------------------------------------------\n");
+
+        AST_LIST_TRAVERSE(&ast_cli_filters, filter, filter_list) {
+                ast_cli(a->fd, "%s\t%d\t\n", filter->name, filter->type);
+                count++;
+        }
+
+        ast_cli(a->fd, "%d active CLI filters.\n", count);
+
+        return CLI_SUCCESS;
+}
+
+static char *handle_add_filter(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+        struct ast_cli_filter *c = NULL;
+
+        switch (cmd) {
+        case CLI_INIT:
+                e->command = "core add filter";
+                e->usage =
+                        "Usage: core add filter\n"
+                        "       Add a new CLI filter\n";
+                return NULL;
+        case CLI_GENERATE:
+                return NULL;
+        }
+
+        if (a->argc != 4) {
+                return CLI_SHOWUSAGE;
+        }
+
+        //TODO use ast_filter_alloc(name,type) instead
+        c = ast_malloc(sizeof(*c));
+        if ( !c ) {
+                ast_log(LOG_WARNING, "cant allocate enough memory\n");
+                return CLI_FAILURE;
+        }
+        c->name = ast_strdup(a->argv[3]);
+        c->type = 1;
+
+        /* TODO search it that filter already exists */
+        AST_LIST_INSERT_HEAD(&ast_cli_filters, c, filter_list);
+
+        ast_cli(a->fd, "%s sucessfully added to CLI filters.\n", c->name);
+
+        return CLI_SUCCESS;
+}
+
+static char *handle_remove_filter(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+        struct ast_cli_filter *c;
+
+        switch (cmd) {
+        case CLI_INIT:
+                e->command = "core remove filter";
+                e->usage =
+                        "Usage: core show filters\n"
+                        "       List All CLI filters\n";
+                return NULL;
+        case CLI_GENERATE:
+                return NULL;
+        }
+
+        if (a->argc != 4) {
+                return CLI_SHOWUSAGE;
+        }
+
+        /* TODO write ast_filter_get_by_name(name )*/
+        if (0) {
+                ast_cli(a->fd, "%s is not an active CLI filter\n", a->argv[3]);
+                return CLI_SUCCESS;
+        } else {
+                ast_cli(a->fd, "ive to remove %s from the list\n", a->argv[3]);
+
+                AST_LIST_TRAVERSE_SAFE_BEGIN(&ast_cli_filters, c, filter_list) {
+                        if (!strcmp(c->name, a->argv[3])) {
+                                AST_LIST_REMOVE_CURRENT(filter_list);
+                                        ast_cli(a->fd, "%s has been sucessfully removed from CLI filter list.\n", a->argv[3]);
+                                        ast_free(c->name); /* since I ast_strdup it */
+                                        ast_free(c);
+                                        break;
+                        }
+                        AST_LIST_TRAVERSE_SAFE_END;
+                }
+        }
+
+        //ast_cli(a->fd,"%s cant be removed.", a->argv[3]);
+        return CLI_SUCCESS;
+}
+
+
+
 struct verb {
 	void (*verboser)(const char *string);
 	AST_LIST_ENTRY(verb) list;
@@ -767,7 +891,11 @@
 	AST_CLI_DEFINE(handle_logger_show_channels, "List configured log channels"),
 	AST_CLI_DEFINE(handle_logger_reload, "Reopens the log files"),
 	AST_CLI_DEFINE(handle_logger_rotate, "Rotates and reopens the log files"),
-	AST_CLI_DEFINE(handle_logger_set_level, "Enables/Disables a specific logging level for this console")
+	AST_CLI_DEFINE(handle_logger_set_level, "Enables/Disables a specific logging level for this console"),
+        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"),
+
 };
 
 static int handle_SIGXFSZ(int sig) 
@@ -1013,7 +1141,10 @@
 	int res = 0;
 	va_list ap;
 	char datestring[256];
-	//struct logger_filter_list_item *filter;
+	struct logger_filter_list_item *filter;
+	struct ast_cli_filter *c;
+	int skip=1;
+
 
 	if (!(buf = ast_str_thread_get(&log_buf, LOG_BUF_INIT_SIZE)))
 		return;
@@ -1051,14 +1182,39 @@
 
 	/* If filters are enabled
 	   ignore if the string doesnt match these filters
+	*/
 	
-        if ((filter = ast_threadstorage_get(&filter_channels, sizeof(*filter)))) {
-		if (filter->chan) {
-			ast_log(LOG_WARNING, "chan is there!\n");
-		}
-	}
-
-	*/
+        if ((channels = ast_threadstorage_get(&filter_channels, sizeof(*channels)))) {
+		printf("chan is there!!!!!\n");
+
+		AST_LIST_TRAVERSE_SAFE_BEGIN(channels, filter, next) {
+                        printf("filter!!!\n");
+                        if (filter->chan) {
+                               printf("chan is %s\n", filter->chan->name);
+				AST_LIST_TRAVERSE(&ast_cli_filters, c, filter_list) {
+					printf("active cli filter:%s\n",c->name);
+
+					if (strncmp(filter->chan->name, c->name, strlen(c->name))) {	
+						printf("Ignore %s, since this is not in filter list\n", filter->chan->name);
+					//	break; //no break to traverse the list of cli filters 
+					} else {
+						printf("%s match my filter, so continue\n", filter->chan->name);
+						skip=0;
+						break;
+					}
+				}
+                        }
+                }
+                AST_LIST_TRAVERSE_SAFE_END;
+
+	}
+
+	if (skip) {
+		//return;	
+		printf("skip!\n");
+	} else {
+		printf("No skip!\n");
+	}
 
 	/* Build string */
 	va_start(ap, fmt);
@@ -1437,7 +1593,7 @@
         */
 
         while ((filter = AST_LIST_REMOVE_HEAD(channels, next))) {
-                ast_log(LOG_WARNING, "filter has been removed.\n");
+                ast_log(LOG_WARNING, "filter will be removed.\n");
                 if ( filter->chan) {
                         ast_log(LOG_WARNING, "chan is there(%s) \n", filter->chan->name);
                 }

Modified: team/junky/cli-tls/main/pbx.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/junky/cli-tls/main/pbx.c?view=diff&rev=204892&r1=204891&r2=204892
==============================================================================
--- team/junky/cli-tls/main/pbx.c (original)
+++ team/junky/cli-tls/main/pbx.c Thu Jul  2 20:35:26 2009
@@ -779,17 +779,6 @@
 AST_THREADSTORAGE(switch_data);
 AST_THREADSTORAGE(extensionstate_buf);
 
-/* Structure for the cli filter */
-struct ast_cli_filter {
-        char *name;                                     /*!< Name of the filter */
-        int type;                                       /*!< Type of the filter currently, only 0 is used */
-        AST_LIST_ENTRY(ast_cli_filter) filter_list;     /*!< pointer to the next element */
-};
-/* List used to store all cli filters entered by the user */
-AST_LIST_HEAD_NOLOCK_STATIC(ast_cli_filters, ast_cli_filter);
-
-
-
 /*!
    \brief ast_exten: An extension
 	The dialplan is saved as a linked list with each context
@@ -3186,120 +3175,6 @@
 }
 
 
-
-static char *handle_show_filters(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	struct ast_cli_filter *c;
-	int count = 0;
-
-	switch (cmd) {
-	case CLI_INIT:
-		e->command = "core show filters";
-		e->usage =
-			"Usage: core show filters\n"
-			"       List All CLI filters\n";
-		return NULL;
-	case CLI_GENERATE:
-		return NULL;
-	}
-
-	if (a->argc != 3) {
-		return CLI_SHOWUSAGE;
-	}
-
-	ast_cli(a->fd, "Active CLI Filters:\n---------------------------------------------------------------------\n");
-
-	AST_LIST_TRAVERSE(&ast_cli_filters, c, filter_list) {
-		ast_cli(a->fd, "%s\t%d\t\n", c->name, c->type);
-		count++;
-	}
-
-	ast_cli(a->fd, "%d active CLI filters.\n", count);
-
-	return CLI_SUCCESS;
-}
-
-static char *handle_add_filter(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	struct ast_cli_filter *c = NULL;
-
-	switch (cmd) {
-	case CLI_INIT:
-		e->command = "core add filter";
-		e->usage =
-			"Usage: core add filter\n"
-			"       Add a new CLI filter\n";
-		return NULL;
-	case CLI_GENERATE:
-		return NULL;
-	}
-
-	if (a->argc != 4) {
-		return CLI_SHOWUSAGE;
-	}
-
-	//TODO use ast_filter_alloc(name,type) instead
-	c = ast_malloc(sizeof(*c));
-	if ( !c ) {
-		ast_log(LOG_WARNING, "cant allocate enough memory\n");
-		return CLI_FAILURE;
-	}
-	c->name = ast_strdup(a->argv[3]);
-	c->type = 1;
-
-	/* TODO search it that filter already exists */
-	AST_LIST_INSERT_HEAD(&ast_cli_filters, c, filter_list);
-
-	ast_cli(a->fd, "%s sucessfully added to CLI filters.\n", c->name);
-
-	return CLI_SUCCESS;
-}
-
-
-static char *handle_remove_filter(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	struct ast_cli_filter *c;
-
-	switch (cmd) {
-	case CLI_INIT:
-		e->command = "core remove filter";
-		e->usage =
-			"Usage: core show filters\n"
-			"       List All CLI filters\n";
-		return NULL;
-	case CLI_GENERATE:
-		return NULL;
-	}
-
-	if (a->argc != 4) {
-		return CLI_SHOWUSAGE;
-	}
- 	
-	/* TODO write ast_filter_get_by_name(name )*/
-	if (0) {
-		ast_cli(a->fd, "%s is not an active CLI filter\n", a->argv[3]);
-		return CLI_SUCCESS;
-	} else {
-		ast_cli(a->fd, "ive to remove %s from the list\n", a->argv[3]);
-			
-		AST_LIST_TRAVERSE_SAFE_BEGIN(&ast_cli_filters, c, filter_list) {
-			if (!strcmp(c->name, a->argv[3])) {
-				AST_LIST_REMOVE_CURRENT(filter_list);
-					ast_cli(a->fd, "%s has been sucessfully removed from CLI filter list.\n", a->argv[3]);
-					ast_free(c->name); /* since I ast_strdup it */
-					ast_free(c);
-					break;
-			}
-			AST_LIST_TRAVERSE_SAFE_END;
-                }	
-	}
-
-	//ast_cli(a->fd,"%s cant be removed.", a->argv[3]);
-	return CLI_SUCCESS;
-}
-
-
-
 static char *handle_show_functions(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct ast_custom_function *acf;
@@ -4189,7 +4064,7 @@
 			ast_debug(1, "Launching '%s'\n", app->name);
 			if (VERBOSITY_ATLEAST(3)) {
 				char tmp[80], tmp2[80], tmp3[EXT_DATA_SIZE];
-				ast_verb(3, "Executing [%s@%s:%d] %s(\"%s\", \"%s\") %s\n",
+				ast_verb(3, "2Executing [%s@%s:%d] %s(\"%s\", \"%s\") %s\n",
 					exten, context, priority,
 					term_color(tmp, app->name, COLOR_BRCYAN, 0, sizeof(tmp)),
 					term_color(tmp2, c->name, COLOR_BRMAGENTA, 0, sizeof(tmp2)),
@@ -6821,9 +6696,6 @@
 	AST_CLI_DEFINE(handle_debug_dialplan, "Show fast extension pattern matching data structures"),
 	AST_CLI_DEFINE(handle_unset_extenpatternmatchnew, "Use the Old extension pattern matching algorithm."),
 	AST_CLI_DEFINE(handle_set_extenpatternmatchnew, "Use the New extension pattern matching algorithm."),
-	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_ts_show_channels, "List all TLS channels"),
 };
 




More information about the svn-commits mailing list