[svn-commits] junky: branch junky/cli-tls r208225 - /team/junky/cli-tls/main/logger.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jul 23 06:25:51 CDT 2009


Author: junky
Date: Thu Jul 23 06:25:47 2009
New Revision: 208225

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=208225
Log:
improve my cli filtering, by changing the order in the match function
taht function also return 0 if it matches, 1 if no match are found.


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=208225&r1=208224&r2=208225
==============================================================================
--- team/junky/cli-tls/main/logger.c (original)
+++ team/junky/cli-tls/main/logger.c Thu Jul 23 06:25:47 2009
@@ -210,6 +210,10 @@
 
 /* Prototype */
 static void filter_channel_cleanup(void *data);
+#ifdef PRINTF_DEBUG
+void my_printf(const char *msg);
+#endif
+
 
 AST_THREADSTORAGE_CUSTOM(filter_channels, NULL, filter_channel_cleanup);
 
@@ -1202,7 +1206,7 @@
 	   ignore if the string doesnt match these filters
 	*/
 
-	if (is_string_match_cli_filters()) {
+	if (!is_string_match_cli_filters()) {
 		printf("skip!\n");
 		return;
 	} else {
@@ -1364,7 +1368,7 @@
 	/* Set type */
 	logmsg->type = LOGMSG_VERBOSE;
 
-        if (is_string_match_cli_filters()) {
+        if (!is_string_match_cli_filters()) {
                 printf("skip!\n");
                 return;
         } else {
@@ -1587,15 +1591,15 @@
         struct logger_filter_list_item *filter = data;
 
         ast_log(LOG_WARNING, "%s is called. data=%p\n", __PRETTY_FUNCTION__, data );
-	/*
         if (filter ) {
                 ast_log(LOG_WARNING, "filter is there\n");
                 if ( filter->chan) {
-                        ast_log(LOG_WARNING, "chan is there \n");
+                        ast_log(LOG_WARNING, "chan is there [%p]\n",filter->chan);
                 }
+		//ast_free(filter);
         }
-	*/
-        
+       
+	/* 
 	while ((filter = AST_LIST_REMOVE_HEAD(channels, next))) {
                 ast_log(LOG_WARNING, "filter will be removed.\n");
                 if ( filter->chan) {
@@ -1604,40 +1608,41 @@
 		ast_log(LOG_WARNING, "filter[%s] will be removed\n", filter->chan->name);
                 ast_free(filter);
         }
+	*/
 }
 
 int is_string_match_cli_filters(void) {
-	int res = 0;
+	int res = 1;
 	struct logger_filter_list_item *filter;
 	struct ast_cli_filter *c;
-	int count = 0;
-
-	channels = ast_threadstorage_get(&filter_channels, sizeof(*channels));
-	AST_LIST_TRAVERSE(&ast_cli_filters, c, filter_list) {
-		if (channels) {
-			AST_LIST_TRAVERSE_SAFE_BEGIN(channels, filter, next) {
-                        	if (filter->chan) {
-
-					if (strncmp(filter->chan->name, c->name, strlen(c->name))) {
-						printf("Ignore %s, since this is not in filter list\n", filter->chan->name);
-						res=1;
-					} else {
-						printf("%s match my filter, so continue\n", filter->chan->name);
-						res=0;
-						break;
-					}
-				}
-			}
-			AST_LIST_TRAVERSE_SAFE_END;
-		}
-		/* Allow the break the outter loop, since the inner loop asked it */
-		if (!res) {
-			break;
-		} 
-		count++;
-	}
-
-	//printf("I return %d\n",res);
+
+        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);
+                                                res=1;
+                                        //      break; //no break to traverse the list of cli filters
+                                        } else {
+                                                printf("%s match my filter, so continue\n", filter->chan->name);
+                                                res=0;
+                                                break;
+                                        }
+                                }
+                        }
+                }
+                AST_LIST_TRAVERSE_SAFE_END;
+
+        } 
+
+	printf("I return %d\n",res);
 	return res;
 }
 
@@ -1655,3 +1660,10 @@
 	}
 	return NULL;
 }
+
+
+#ifdef PRINTF_DEBUG
+void my_printf(const char *msg) {
+	printf("%s\n",msg);
+}
+#endif




More information about the svn-commits mailing list