[asterisk-commits] junky: branch junky/cli-tls r207635 - in /team/junky/cli-tls: include/asteris...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jul 20 20:31:48 CDT 2009
Author: junky
Date: Mon Jul 20 20:31:44 2009
New Revision: 207635
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=207635
Log:
added the tabs-completion for the core remove filter <filter_name>
moved prototypes to logger.h
Modified:
team/junky/cli-tls/include/asterisk/logger.h
team/junky/cli-tls/main/logger.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=207635&r1=207634&r2=207635
==============================================================================
--- team/junky/cli-tls/include/asterisk/logger.h (original)
+++ team/junky/cli-tls/include/asterisk/logger.h Mon Jul 20 20:31:44 2009
@@ -214,6 +214,12 @@
/* To add a channel to a TLS object */
int tls_add_channel(struct ast_channel *chan);
+
+int tls_remove_channel(struct ast_channel *chan);
+
+int is_string_match_cli_filters(void);
+struct ast_cli_filter *ast_filter_get_by_name(const char *name);
+
/*!
* \brief Send a log message to a dynamically registered log level
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=207635&r1=207634&r2=207635
==============================================================================
--- team/junky/cli-tls/main/logger.c (original)
+++ team/junky/cli-tls/main/logger.c Mon Jul 20 20:31:44 2009
@@ -210,8 +210,6 @@
/* Prototype */
static void filter_channel_cleanup(void *data);
-int is_string_match_cli_filters(void);
-struct ast_cli_filter *ast_filter_get_by_name(const char *name);
AST_THREADSTORAGE_CUSTOM(filter_channels, NULL, filter_channel_cleanup);
@@ -851,16 +849,29 @@
{
struct ast_cli_filter *filter;
struct ast_cli_filter *tmp;
+ char *ret = NULL;
+ int which = 0;
+ int wordlen;
switch (cmd) {
case CLI_INIT:
e->command = "core remove filter";
e->usage =
- "Usage: core show filters\n"
- " List All CLI filters\n";
+ "Usage: core remove filter <filter_name>\n"
+ " Remove a specific filter_name\n";
return NULL;
case CLI_GENERATE:
- return NULL;
+ wordlen = strlen(a->word);
+ /* Since filter name are case sensitive, we use strcasecmp and not strncasecmp */
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&ast_cli_filters, filter, filter_list) {
+ if (!strncasecmp(a->word, filter->name, wordlen) && ++which > a->n) {
+ ret = ast_strdup(filter->name);
+ break;
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+ }
+
+ return ret;
}
if (a->argc != 4) {
@@ -1526,6 +1537,7 @@
}
//http://pastebin.ca/1474652
+/* Function used to add a specific channel to the TLS container */
int tls_add_channel(struct ast_channel *chan){
struct logger_filter_list_item *filter;
int res = 0;
@@ -1547,23 +1559,49 @@
return res;
}
+/* Function used to remove a specific channel from the TLS container */
+int tls_remove_channel(struct ast_channel *chan){
+ struct logger_filter_list_item *filter;
+ int res = 0;
+
+ channels = ast_threadstorage_get(&filter_channels, sizeof(*channels));
+ if (channels) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(channels, filter, next) {
+ if (!strcmp(filter->chan->name, chan->name)) {
+ AST_LIST_REMOVE_CURRENT(next);
+ ast_log(LOG_WARNING, "%s has been sucessfully removed from CLI filter list.\n", chan->name);
+ ast_free(filter);
+ res=1;
+ break;
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+ }
+ }
+ return res;
+}
+
+
+
static void filter_channel_cleanup(void *data)
{
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");
}
}
+ */
while ((filter = AST_LIST_REMOVE_HEAD(channels, next))) {
ast_log(LOG_WARNING, "filter will be removed.\n");
if ( filter->chan) {
ast_log(LOG_WARNING, "chan is there(%s) \n", filter->chan->name);
}
+ ast_log(LOG_WARNING, "filter[%s] will be removed\n", filter->chan->name);
ast_free(filter);
}
}
More information about the asterisk-commits
mailing list