[svn-commits] junky: branch junky/cli-tls r201782 - /team/junky/cli-tls/main/pbx.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 18 14:59:08 CDT 2009


Author: junky
Date: Thu Jun 18 14:59:05 2009
New Revision: 201782

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=201782
Log:
stop using logger_channel since its related for the logger channel name
CLI cmds for list,add,remove cli filters works (using channel and not string)




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

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=201782&r1=201781&r2=201782
==============================================================================
--- team/junky/cli-tls/main/pbx.c (original)
+++ team/junky/cli-tls/main/pbx.c Thu Jun 18 14:59:05 2009
@@ -775,11 +775,11 @@
 struct ast_app;
 
 static struct ast_taskprocessor *device_state_tps;
-static void logger_channel_cleanup(void *data);
+static void filter_channel_cleanup(void *data);
 
 AST_THREADSTORAGE(switch_data);
 AST_THREADSTORAGE(extensionstate_buf);
-AST_THREADSTORAGE_CUSTOM(logger_channel, NULL, logger_channel_cleanup);
+AST_THREADSTORAGE_CUSTOM(filter_channels, NULL, filter_channel_cleanup);
 
 /* List of channels used for filtering */
 //AST_LIST_HEAD_NOLOCK(ast_channels, ast_channel);
@@ -792,14 +792,8 @@
        AST_LIST_ENTRY(logger_filter_list_item) next;
 };
 
-
+/* List used to store all cli filters entered by the user */
 AST_LIST_HEAD_NOLOCK_STATIC(ast_cli_filters, ast_channel);
-
-/*
-struct ast_logger_channels {
-        struct ast_channels list;
-};
-*/
 
 
 /*!
@@ -3149,7 +3143,6 @@
 {
 	struct ast_channel *c;
         int count = 0;
-	//struct ast_logger_channels *channels = NULL;
 
         switch (cmd) {
         case CLI_INIT:
@@ -3169,8 +3162,7 @@
         ast_cli(a->fd, "Active CLI Filters:\n---------------------------------------------------------------------\n");
 
         AST_LIST_TRAVERSE(&ast_cli_filters, c, chan_list) {
-	//AST_LIST_TRAVERSE(&channels->list, c, chan_list) {
-        	ast_cli(a->fd, "AYYY name=%s\n", c->name);
+        	ast_cli(a->fd, "%s\n", c->name);
 		count++;
         }
 
@@ -3181,12 +3173,7 @@
 
 static char *handle_add_filter(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	char *str = "SIP/10";	
-
-	struct ast_channel *c = ast_channel_alloc(0, 0, 0, 0, "", "", "", 0, "%s", str);
-	if ( c ) {
-		ast_log(LOG_WARNING, "new chan created. name=[%s]", c->name);
-	}
+	struct ast_channel *c = NULL;
 
         switch (cmd) {
         case CLI_INIT:
@@ -3203,9 +3190,16 @@
                 return CLI_SHOWUSAGE;
         }
 
+	c = ast_channel_alloc(0, 0, 0, 0, "", "", "", 0, "%s", a->argv[3]);
+	if ( !c ) {
+		ast_log(LOG_WARNING, "cant allocate enough memory\n");
+		return CLI_FAILURE;
+	}
+
+	/* TODO search it that filter already exists */
 	AST_RWLIST_INSERT_HEAD(&ast_cli_filters, c, chan_list);
 
-        ast_cli(a->fd, "%s sucessfully added to CLI filters.\n", str);
+        ast_cli(a->fd, "%s sucessfully added to CLI filters.\n", a->argv[3]);
 
         return CLI_SUCCESS;
 }
@@ -3214,7 +3208,6 @@
 static char *handle_remove_filter(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
         struct ast_channel *c;
-	char *str = "SIP/10";
 
         switch (cmd) {
         case CLI_INIT:
@@ -3231,22 +3224,22 @@
                 return CLI_SHOWUSAGE;
         }
 
-
-	if (!(c = ast_channel_get_by_name(str))) {
-		ast_cli(a->fd, "%s is not an active CLI filter\n", str);
+	if (!(c = ast_channel_get_by_name(a->argv[3]))) {
+		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", str);
+		ast_cli(a->fd, "ive to remove %s from the list\n", a->argv[3]);
 	                AST_LIST_TRAVERSE_SAFE_BEGIN(&ast_cli_filters, c, chan_list) {
-                        	if (!strcmp(c->name, str)) {
+                        	if (!strcmp(c->name, a->argv[3])) {
                                 	AST_LIST_REMOVE_CURRENT(chan_list);
+					ast_cli(a->fd, "%s has been sucessfully removed from CLI filter list.\n", a->argv[3]);
                                 	break;
                         	}
 			AST_LIST_TRAVERSE_SAFE_END;
+			ast_cli(a->fd,"%s cant be removed.", a->argv[3]);
                 }
 
 	}
-
 
         return CLI_SUCCESS;
 }
@@ -5008,18 +5001,27 @@
 	   PBX has finished running on the channel
 	 */
 	struct ast_channel *c = data;
-	//struct ast_logger_channels *channels;
-	
+	struct logger_filter_list_item *filter;
+	/*
+	if ( !ast_malloc(sizeof(*filter)) ) {
+		ast_log(LOG_ERROR, "Not enough memory to create the filter");
+	}
+	*/
 	ast_log(LOG_WARNING, "New thread started. (channel name=%s)\n", c->name);
-	/*
-	if ((channels = ast_threadstorage_get(&logger_channel, sizeof(*c)))) {
+
+
+	filter = ast_malloc(sizeof(*filter));
+
+	filter->channel = c;
+	ast_log(LOG_WARNING, "filter channel name is:%s\n", filter->channel->name);	
+
+	if ((filter = ast_threadstorage_get(&filter_channels, sizeof(*c)))) {
 		ast_log(LOG_WARNING, "Adding channel(%s) to channels_list\n", c->name);
 		//AST_LIST_INSERT_HEAD(&channels->list, c, chan_list);
 		//AST_RWLIST_INSERT_HEAD(&ast_channels, c, chan_list);	
 	} else {
 		ast_log(LOG_WARNING, "obj already exists\n");
 	}
-	*/
 
 	__ast_pbx_run(c, NULL);
 	decrease_call_count();
@@ -10035,9 +10037,9 @@
 	return ret;
 }
 
-static void logger_channel_cleanup(void *data)
-{
-	ast_log(LOG_WARNING, "logger_channel_cleanup is called.\n");
-}
-
-
+static void filter_channel_cleanup(void *data)
+{
+	ast_log(LOG_WARNING, "%s is called.\n", __PRETTY_FUNCTION__);
+}
+
+




More information about the svn-commits mailing list