[asterisk-commits] junky: branch junky/cli-tls r208539 - in /team/junky/cli-tls: channels/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 23 22:13:00 CDT 2009


Author: junky
Date: Thu Jul 23 22:12:56 2009
New Revision: 208539

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=208539
Log:
continue my work.
is_string_match_cli_filters() returns -1 if no filters are found
0 is theres a match (which means, we should continue the ast_log()
1 if theres no match (which means, we should not continue)

moved everything in my_printf() for debug purpose only.
That function is causing me problems atm, so do not define PRINTF_DEBUG atm or segfault you will get.
junky_printf() is simply a function, since i had too much trouble with the other one.




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

Modified: team/junky/cli-tls/channels/chan_oss.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/junky/cli-tls/channels/chan_oss.c?view=diff&rev=208539&r1=208538&r2=208539
==============================================================================
--- team/junky/cli-tls/channels/chan_oss.c (original)
+++ team/junky/cli-tls/channels/chan_oss.c Thu Jul 23 22:12:56 2009
@@ -62,8 +62,10 @@
 #include "asterisk/causes.h"
 #include "asterisk/musiconhold.h"
 #include "asterisk/app.h"
+#include "asterisk/logger.h"
 
 #include "console_video.h"
+
 
 /*! Global jitterbuffer configuration - by default, jb is disabled */
 static struct ast_jb_conf default_jbconf =
@@ -795,6 +797,9 @@
 	c = ast_channel_alloc(1, state, o->cid_num, o->cid_name, "", ext, ctx, linkedid, 0, "Console/%s", o->device + 5);
 	if (c == NULL)
 		return NULL;
+	/* TODO add that newly created channel to the TLS container
+	tls_add_channel(c);
+	*/
 	c->tech = &oss_tech;
 	if (o->sounddev < 0)
 		setformat(o, O_RDWR);

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=208539&r1=208538&r2=208539
==============================================================================
--- team/junky/cli-tls/main/logger.c (original)
+++ team/junky/cli-tls/main/logger.c Thu Jul 23 22:12:56 2009
@@ -67,6 +67,7 @@
 #else
 #define GETTID() getpid()
 #endif
+
 static char dateformat[256] = "%b %e %T";		/* Original Asterisk Format */
 
 static char queue_log_name[256] = QUEUELOG;
@@ -208,11 +209,12 @@
 
 struct ast_channels *channels;
 
+
 /* Prototype */
 static void filter_channel_cleanup(void *data);
-#ifdef PRINTF_DEBUG
-void my_printf(const char *msg);
-#endif
+void junky_printf(const char *msg);
+static void __attribute__((format(printf, 1,2))) my_printf(const char *str, ...);
+//#define PRINTF_DEBUG 1 /* TODO just for debugging now */
 
 
 AST_THREADSTORAGE_CUSTOM(filter_channels, NULL, filter_channel_cleanup);
@@ -1206,11 +1208,11 @@
 	   ignore if the string doesnt match these filters
 	*/
 
-	if (!is_string_match_cli_filters()) {
-		printf("skip!\n");
-		return;
+	if (is_string_match_cli_filters() <= 0) {
+		junky_printf("No skip!\n");
 	} else {
-		printf("No skip!\n");
+		junky_printf("skip!\n");
+		return;
 	}
 
 	/* Build string */
@@ -1368,11 +1370,11 @@
 	/* Set type */
 	logmsg->type = LOGMSG_VERBOSE;
 
-        if (!is_string_match_cli_filters()) {
-                printf("skip!\n");
+        if (is_string_match_cli_filters()<= 0) {
+                junky_printf("No skip!\n");
+        } else {
+		junky_printf("skip!\n");
                 return;
-        } else {
-                printf("No skip!\n");
         }
 
 	/* Add to the list and poke the thread if possible */
@@ -1547,14 +1549,14 @@
         int res = 0;
 
         if ((channels = ast_threadstorage_get(&filter_channels, sizeof(*channels)))) {
-                ast_log(LOG_WARNING, "Adding channel(%s) to channels_list\n", chan->name);
+                my_printf("Adding channel(%s) to channels_list\n", chan->name);
                 filter = ast_calloc(1, sizeof(*filter));
                 if ( !filter ) {
                         ast_log(LOG_WARNING, "Out of memory\n");
                         return -1;
                 }
                 filter->chan = chan;
-                ast_log(LOG_WARNING, "TLS channel name is:%s\n", filter->chan->name);
+		my_printf("TLS channel name is:%s\n", filter->chan->name);
                 AST_RWLIST_INSERT_HEAD(channels, filter, next);
         } else {
                 ast_log(LOG_WARNING, "Out of memory\n");
@@ -1563,7 +1565,9 @@
         return res;
 }
 
-/* Function used to remove a specific channel from the TLS container */
+/* Function used to remove a specific channel from the TLS container 
+Will be used for different channel driver monitor threads
+*/
 int tls_remove_channel(struct ast_channel *chan){
 	struct logger_filter_list_item *filter;
 	int res = 0;
@@ -1590,11 +1594,11 @@
 {
         struct logger_filter_list_item *filter = data;
 
-        ast_log(LOG_WARNING, "%s is called. data=%p\n", __PRETTY_FUNCTION__, data );
+        my_printf("%s is called. data=%p\n", __PRETTY_FUNCTION__, data );
         if (filter ) {
-                ast_log(LOG_WARNING, "filter is there\n");
+                junky_printf("filter is there\n");
                 if ( filter->chan) {
-                        ast_log(LOG_WARNING, "chan is there [%p]\n",filter->chan);
+                        my_printf("chan is there [%p]\n",filter->chan);
                 }
 		//ast_free(filter);
         }
@@ -1612,26 +1616,25 @@
 }
 
 int is_string_match_cli_filters(void) {
-	int res = 1;
+	int res = -1;
 	struct logger_filter_list_item *filter;
 	struct ast_cli_filter *c;
 
         if ((channels = ast_threadstorage_get(&filter_channels, sizeof(*channels)))) {
-                printf("chan is there!!!!!\n");
+                my_printf("chan is there!!!!!\n");
 
                 AST_LIST_TRAVERSE_SAFE_BEGIN(channels, filter, next) {
-                        printf("filter!!!\n");
+                        junky_printf("filter!!!\n");
                         if (filter->chan) {
-                               printf("chan is %s\n", filter->chan->name);
+                               my_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);
+                                        my_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
+                                                my_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);
+                                                my_printf("%s match my filter, so continue\n", filter->chan->name);
                                                 res=0;
                                                 break;
                                         }
@@ -1640,9 +1643,11 @@
                 }
                 AST_LIST_TRAVERSE_SAFE_END;
 
-        } 
-
-	printf("I return %d\n",res);
+        } else {
+		printf("chan NOT THERE\n");
+	} 
+
+	my_printf("I return %d\n",res);
 	return res;
 }
 
@@ -1661,9 +1666,26 @@
 	return NULL;
 }
 
-
+static void __attribute__((format(printf, 1,2))) my_printf(const char *fmt, ...) {
 #ifdef PRINTF_DEBUG
-void my_printf(const char *msg) {
-	printf("%s\n",msg);
-}
+	va_list ap;
+	char *buf;	
+
+        if (ast_vasprintf(&buf, fmt, ap) < 0) {
+                va_end(ap);
+                return;
+        }
+        va_end(ap);
+
+	//printf("buffer is:%s", buf);
+	//ast_free(buf);
 #endif
+}
+
+
+void junky_printf(const char *msg) {
+#ifdef PRINTF_DEBUG
+	printf("%s",msg);
+#endif
+
+}




More information about the asterisk-commits mailing list