From 3c78d956140966dd44abad9def84e6a812562bd0 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 9 Oct 2000 23:40:18 +0000 Subject: Moved ignore to core. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@725 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/Makefile.am | 2 + src/core/core.c | 3 + src/core/ignore.c | 345 ++++++++++++++++++++++++++++++++++++++++++ src/core/ignore.h | 34 +++++ src/irc/core/Makefile.am | 2 - src/irc/core/channels-query.c | 3 +- src/irc/core/ctcp.c | 4 +- src/irc/core/ignore.c | 343 ----------------------------------------- src/irc/core/ignore.h | 34 ----- src/irc/core/irc-core.c | 3 - src/irc/flood/flood.c | 6 +- 11 files changed, 391 insertions(+), 388 deletions(-) create mode 100644 src/core/ignore.c create mode 100644 src/core/ignore.h delete mode 100644 src/irc/core/ignore.c delete mode 100644 src/irc/core/ignore.h (limited to 'src') diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 1cc943eb..f4b08ae7 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -22,6 +22,7 @@ libcore_a_SOURCES = \ chat-protocols.c \ chatnets.c \ core.c \ + ignore.c \ levels.c \ line-split.c \ log.c \ @@ -62,6 +63,7 @@ noinst_HEADERS = \ chat-protocols.h \ chatnets.h \ core.h \ + ignore.h \ levels.h \ line-split.h \ log.h \ diff --git a/src/core/core.c b/src/core/core.c index 7ec453d1..a2a928db 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -33,6 +33,7 @@ #include "commands.h" #include "log.h" #include "rawlog.h" +#include "ignore.h" #include "special-vars.h" #include "channels.h" @@ -57,6 +58,7 @@ void core_init(void) chat_protocols_init(); chatnets_init(); + ignore_init(); servers_init(); log_init(); rawlog_init(); @@ -84,6 +86,7 @@ void core_deinit(void) rawlog_deinit(); log_deinit(); servers_deinit(); + ignore_deinit(); chatnets_deinit(); chat_protocols_deinit(); diff --git a/src/core/ignore.c b/src/core/ignore.c new file mode 100644 index 00000000..5c37fe45 --- /dev/null +++ b/src/core/ignore.c @@ -0,0 +1,345 @@ +/* + ignore.c : irssi + + Copyright (C) 1999-2000 Timo Sirainen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "module.h" +#include "signals.h" +#include "misc.h" +#include "levels.h" +#include "lib-config/iconfig.h" +#include "settings.h" + +#include "masks.h" +#include "servers.h" +#include "channels.h" +#include "nicklist.h" + +#include "ignore.h" + +GSList *ignores; + +/* check if `text' contains ignored nick at the start of the line. */ +static int ignore_check_replies(IGNORE_REC *rec, SERVER_REC *server, + const char *channel, const char *text) +{ + CHANNEL_REC *chanrec; + GSList *nicks, *tmp; + + g_return_val_if_fail(rec != NULL, FALSE); + g_return_val_if_fail(server != NULL, FALSE); + g_return_val_if_fail(channel != NULL, FALSE); + g_return_val_if_fail(text != NULL, FALSE); + + chanrec = channel_find(server, channel); + if (chanrec == NULL) return FALSE; + + nicks = nicklist_find_multiple(chanrec, rec->mask); + if (nicks == NULL) return FALSE; + + for (tmp = nicks; tmp != NULL; tmp = tmp->next) { + NICK_REC *nick = tmp->data; + + if (nick_match_msg(server, text, nick->nick)) + return TRUE; + } + g_slist_free(nicks); + + return FALSE; +} + +int ignore_check(SERVER_REC *server, const char *nick, const char *host, + const char *channel, const char *text, int level) +{ + GSList *tmp; + int ok, mask_len, patt_len; + int best_mask, best_patt, best_ignore; + + g_return_val_if_fail(server != NULL, 0); + + best_mask = 0; best_patt = 0; best_ignore = FALSE; + for (tmp = ignores; tmp != NULL; tmp = tmp->next) { + IGNORE_REC *rec = tmp->data; + + if ((level & (rec->level|rec->except_level)) == 0) + continue; + + /* server */ + if (rec->servertag != NULL && g_strcasecmp(server->tag, rec->servertag) != 0) + continue; + + /* channel list */ + if (rec->channels != NULL) { + if (channel == NULL || !server->ischannel(*channel)) + continue; + if (strarray_find(rec->channels, channel) == -1) + continue; + } + + /* nick mask */ + mask_len = 0; + if (rec->mask != NULL) { + if (nick == NULL) + continue; + + mask_len = strlen(rec->mask); + if (mask_len <= best_mask) continue; + + ok = ((host == NULL || *host == '\0')) ? + match_wildcards(rec->mask, nick) : + mask_match_address(server, rec->mask, nick, host); + if (!ok) { + /* nick didn't match, but maybe this is a reply to nick? */ + if (!rec->replies || channel == NULL || text == NULL || + !ignore_check_replies(rec, server, channel, text)) + continue; + } + } + + /* pattern */ + patt_len = 0; + if (rec->pattern != NULL) { + if (text == NULL) + continue; + + if (!mask_len && !best_mask) { + patt_len = strlen(rec->pattern); + if (patt_len <= best_patt) continue; + } + + ok = rec->regexp ? regexp_match(text, rec->pattern) : + rec->fullword ? stristr_full(text, rec->pattern) != NULL : + stristr(text, rec->pattern) != NULL; + if (!ok) continue; + } + + if (mask_len || best_mask) + best_mask = mask_len; + else if (patt_len) + best_patt = patt_len; + + best_ignore = (rec->level & level) != 0; + } + + return best_ignore; +} + +IGNORE_REC *ignore_find(const char *servertag, const char *mask, char **channels) +{ + GSList *tmp; + char **chan; + int ignore_servertag; + + if (mask != NULL && *mask == '\0') mask = NULL; + + ignore_servertag = servertag != NULL && strcmp(servertag, "*") == 0; + for (tmp = ignores; tmp != NULL; tmp = tmp->next) { + IGNORE_REC *rec = tmp->data; + + if (!ignore_servertag) { + if ((servertag == NULL && rec->servertag != NULL) || + (servertag != NULL && rec->servertag == NULL)) + continue; + + if (servertag != NULL && g_strcasecmp(servertag, rec->servertag) != 0) + continue; + } + + if ((rec->mask == NULL && mask != NULL) || + (rec->mask != NULL && mask == NULL)) continue; + + if (rec->mask != NULL && g_strcasecmp(rec->mask, mask) != 0) + continue; + + if ((channels == NULL && rec->channels == NULL)) + return rec; /* no channels - ok */ + + if (channels != NULL && strcmp(*channels, "*") == 0) + return rec; /* ignore channels */ + + if (channels == NULL || rec->channels == NULL) + continue; /* other doesn't have channels */ + + if (strarray_length(channels) != strarray_length(rec->channels)) + continue; /* different amount of channels */ + + /* check that channels match */ + for (chan = channels; *chan != NULL; chan++) { + if (strarray_find(rec->channels, *chan) == -1) + break; + } + + if (*chan == NULL) + return rec; /* channels ok */ + } + + return NULL; +} + +static void ignore_set_config(IGNORE_REC *rec) +{ + CONFIG_NODE *node; + char *levelstr; + + if (rec->level == 0 && rec->except_level == 0) + return; + + if (rec->time > 0) + return; + + node = iconfig_node_traverse("(ignores", TRUE); + node = config_node_section(node, NULL, NODE_TYPE_BLOCK); + + if (rec->mask != NULL) iconfig_node_set_str(node, "mask", rec->mask); + if (rec->level) { + levelstr = bits2level(rec->level); + iconfig_node_set_str(node, "level", levelstr); + g_free(levelstr); + } + if (rec->except_level) { + levelstr = bits2level(rec->except_level); + iconfig_node_set_str(node, "except_level", levelstr); + g_free(levelstr); + } + iconfig_node_set_str(node, "pattern", rec->pattern); + if (rec->regexp) config_node_set_bool(node, "regexp", TRUE); + if (rec->fullword) config_node_set_bool(node, "fullword", TRUE); + if (rec->replies) config_node_set_bool(node, "replies", TRUE); + + if (rec->channels != NULL && *rec->channels != NULL) { + node = config_node_section(node, "channels", NODE_TYPE_LIST); + config_node_add_list(node, rec->channels); + } +} + +static int ignore_index(IGNORE_REC *find) +{ + GSList *tmp; + int index; + + index = 0; + for (tmp = ignores; tmp != NULL; tmp = tmp->next) { + IGNORE_REC *rec = tmp->data; + + if (rec->servertag != NULL) + continue; + + if (rec == find) + return index; + index++; + } + + return -1; +} + +static void ignore_remove_config(IGNORE_REC *rec) +{ + CONFIG_NODE *node; + + node = iconfig_node_traverse("ignores", FALSE); + if (node != NULL) iconfig_node_list_remove(node, ignore_index(rec)); +} + +void ignore_add_rec(IGNORE_REC *rec) +{ + ignores = g_slist_append(ignores, rec); + ignore_set_config(rec); + + signal_emit("ignore created", 1, rec); +} + +static void ignore_destroy(IGNORE_REC *rec) +{ + ignores = g_slist_remove(ignores, rec); + signal_emit("ignore destroyed", 1, rec); + + if (rec->time_tag > 0) g_source_remove(rec->time_tag); + if (rec->channels != NULL) g_strfreev(rec->channels); + g_free_not_null(rec->mask); + g_free_not_null(rec->servertag); + g_free_not_null(rec->pattern); + g_free(rec); +} + +void ignore_update_rec(IGNORE_REC *rec) +{ + if (rec->level == 0 && rec->except_level == 0) { + /* unignored everything */ + ignore_remove_config(rec); + ignore_destroy(rec); + } else { + /* unignore just some levels.. */ + ignore_remove_config(rec); + ignores = g_slist_remove(ignores, rec); + + ignores = g_slist_append(ignores, rec); + ignore_set_config(rec); + + signal_emit("ignore changed", 1, rec); + } +} + +static void read_ignores(void) +{ + IGNORE_REC *rec; + CONFIG_NODE *node; + GSList *tmp; + + while (ignores != NULL) + ignore_destroy(ignores->data); + + node = iconfig_node_traverse("ignores", FALSE); + if (node == NULL) return; + + for (tmp = node->value; tmp != NULL; tmp = tmp->next) { + node = tmp->data; + + if (node->type != NODE_TYPE_BLOCK) + continue; + + rec = g_new0(IGNORE_REC, 1); + ignores = g_slist_append(ignores, rec); + + rec->mask = g_strdup(config_node_get_str(node, "mask", NULL)); + rec->pattern = g_strdup(config_node_get_str(node, "pattern", NULL)); + rec->level = level2bits(config_node_get_str(node, "level", "")); + rec->except_level = level2bits(config_node_get_str(node, "except_level", "")); + rec->regexp = config_node_get_bool(node, "regexp", FALSE); + rec->fullword = config_node_get_bool(node, "fullword", FALSE); + rec->replies = config_node_get_bool(node, "replies", FALSE); + + node = config_node_section(node, "channels", -1); + if (node != NULL) rec->channels = config_node_get_list(node); + } +} + +void ignore_init(void) +{ + ignores = NULL; + + read_ignores(); + signal_add("setup reread", (SIGNAL_FUNC) read_ignores); +} + +void ignore_deinit(void) +{ + while (ignores != NULL) + ignore_destroy(ignores->data); + + signal_remove("setup reread", (SIGNAL_FUNC) read_ignores); +} diff --git a/src/core/ignore.h b/src/core/ignore.h new file mode 100644 index 00000000..e4355f52 --- /dev/null +++ b/src/core/ignore.h @@ -0,0 +1,34 @@ +#ifndef __IGNORE_H +#define __IGNORE_H + +typedef struct { + char *mask; /* nick mask */ + char *servertag; /* this is for autoignoring */ + char **channels; /* ignore only in these channels */ + char *pattern; /* text body must match this pattern */ + + int level; /* ignore these levels */ + int except_level; /* don't ignore these levels */ + + int time; /* time in sec for temp ignores */ + int time_tag; + + int regexp:1; + int fullword:1; + int replies:1; /* ignore replies to nick in channel */ +} IGNORE_REC; + +extern GSList *ignores; + +int ignore_check(SERVER_REC *server, const char *nick, const char *host, + const char *channel, const char *text, int level); + +IGNORE_REC *ignore_find(const char *servertag, const char *mask, char **channels); + +void ignore_add_rec(IGNORE_REC *rec); +void ignore_update_rec(IGNORE_REC *rec); + +void ignore_init(void); +void ignore_deinit(void); + +#endif diff --git a/src/irc/core/Makefile.am b/src/irc/core/Makefile.am index 99f72229..e6748792 100644 --- a/src/irc/core/Makefile.am +++ b/src/irc/core/Makefile.am @@ -11,7 +11,6 @@ libirc_core_a_SOURCES = \ channels-query.c \ channel-events.c \ channel-rejoin.c \ - ignore.c \ irc.c \ irc-core.c \ irc-channels.c \ @@ -37,7 +36,6 @@ libirc_core_a_SOURCES = \ noinst_HEADERS = \ bans.h \ ctcp.h \ - ignore.h \ irc.h \ irc-channels.h \ irc-chatnets.h \ diff --git a/src/irc/core/channels-query.c b/src/irc/core/channels-query.c index ae6c4f71..96f17f4d 100644 --- a/src/irc/core/channels-query.c +++ b/src/irc/core/channels-query.c @@ -128,7 +128,8 @@ static void sig_channel_destroyed(IRC_CHANNEL_REC *channel) { g_return_if_fail(channel != NULL); - if (channel->server != NULL && !channel->synced) + if (IS_IRC_CHANNEL(channel) && channel->server != NULL && + !channel->synced) channel_query_remove_all(channel); } diff --git a/src/irc/core/ctcp.c b/src/irc/core/ctcp.c index 8bcd4684..a1d1f2df 100644 --- a/src/irc/core/ctcp.c +++ b/src/irc/core/ctcp.c @@ -120,7 +120,7 @@ static void ctcp_msg(const char *data, IRC_SERVER_REC *server, { char *args, *str; - if (ignore_check(server, nick, addr, target, data, MSGLEVEL_CTCPS)) + if (ignore_check(SERVER(server), nick, addr, target, data, MSGLEVEL_CTCPS)) return; str = g_strconcat("ctcp msg ", data, NULL); @@ -140,7 +140,7 @@ static void ctcp_reply(const char *data, IRC_SERVER_REC *server, { char *args, *str; - if (ignore_check(server, nick, addr, target, data, MSGLEVEL_CTCPS)) + if (ignore_check(SERVER(server), nick, addr, target, data, MSGLEVEL_CTCPS)) return; str = g_strconcat("ctcp reply ", data, NULL); diff --git a/src/irc/core/ignore.c b/src/irc/core/ignore.c deleted file mode 100644 index 7ec3122e..00000000 --- a/src/irc/core/ignore.c +++ /dev/null @@ -1,343 +0,0 @@ -/* - ignore.c : irssi - - Copyright (C) 1999-2000 Timo Sirainen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "module.h" -#include "signals.h" -#include "misc.h" -#include "levels.h" -#include "lib-config/iconfig.h" -#include "settings.h" - -#include "irc.h" -#include "irc-masks.h" -#include "irc-servers.h" -#include "irc-channels.h" -#include "irc-nicklist.h" - -#include "ignore.h" - -GSList *ignores; - -/* check if `text' contains ignored nick at the start of the line. */ -static int ignore_check_replies(IGNORE_REC *rec, IRC_SERVER_REC *server, - const char *channel, const char *text) -{ - IRC_CHANNEL_REC *chanrec; - GSList *nicks, *tmp; - - g_return_val_if_fail(rec != NULL, FALSE); - g_return_val_if_fail(server != NULL, FALSE); - g_return_val_if_fail(channel != NULL, FALSE); - g_return_val_if_fail(text != NULL, FALSE); - - chanrec = irc_channel_find(server, channel); - if (chanrec == NULL) return FALSE; - - nicks = nicklist_find_multiple(CHANNEL(chanrec), rec->mask); - if (nicks == NULL) return FALSE; - - for (tmp = nicks; tmp != NULL; tmp = tmp->next) { - NICK_REC *nick = tmp->data; - - if (nick_match_msg(SERVER(server), text, nick->nick)) - return TRUE; - } - g_slist_free(nicks); - - return FALSE; -} - -int ignore_check(IRC_SERVER_REC *server, const char *nick, const char *host, - const char *channel, const char *text, int level) -{ - GSList *tmp; - int ok, mask_len, patt_len; - int best_mask, best_patt, best_ignore; - - g_return_val_if_fail(server != NULL, 0); - - best_mask = 0; best_patt = 0; best_ignore = FALSE; - for (tmp = ignores; tmp != NULL; tmp = tmp->next) { - IGNORE_REC *rec = tmp->data; - - if ((level & (rec->level|rec->except_level)) == 0) - continue; - - /* server */ - if (rec->servertag != NULL && g_strcasecmp(server->tag, rec->servertag) != 0) - continue; - - /* channel list */ - if (rec->channels != NULL) { - if (channel == NULL || !ischannel(*channel)) - continue; - if (strarray_find(rec->channels, channel) == -1) - continue; - } - - /* nick mask */ - mask_len = 0; - if (rec->mask != NULL) { - if (nick == NULL) - continue; - - mask_len = strlen(rec->mask); - if (mask_len <= best_mask) continue; - - ok = ((host == NULL || *host == '\0')) ? - match_wildcards(rec->mask, nick) : - mask_match_address(SERVER(server), rec->mask, nick, host); - if (!ok) { - /* nick didn't match, but maybe this is a reply to nick? */ - if (!rec->replies || channel == NULL || text == NULL || - !ignore_check_replies(rec, server, channel, text)) - continue; - } - } - - /* pattern */ - patt_len = 0; - if (rec->pattern != NULL && text != NULL) { - if (!mask_len && !best_mask) { - patt_len = strlen(rec->pattern); - if (patt_len <= best_patt) continue; - } - - ok = rec->regexp ? regexp_match(text, rec->pattern) : - rec->fullword ? stristr_full(text, rec->pattern) != NULL : - stristr(text, rec->pattern) != NULL; - if (!ok) continue; - } - - if (mask_len || best_mask) - best_mask = mask_len; - else if (patt_len) - best_patt = patt_len; - - best_ignore = (rec->level & level) != 0; - } - - return best_ignore; -} - -IGNORE_REC *ignore_find(const char *servertag, const char *mask, char **channels) -{ - GSList *tmp; - char **chan; - int ignore_servertag; - - if (mask != NULL && *mask == '\0') mask = NULL; - - ignore_servertag = servertag != NULL && strcmp(servertag, "*") == 0; - for (tmp = ignores; tmp != NULL; tmp = tmp->next) { - IGNORE_REC *rec = tmp->data; - - if (!ignore_servertag) { - if ((servertag == NULL && rec->servertag != NULL) || - (servertag != NULL && rec->servertag == NULL)) - continue; - - if (servertag != NULL && g_strcasecmp(servertag, rec->servertag) != 0) - continue; - } - - if ((rec->mask == NULL && mask != NULL) || - (rec->mask != NULL && mask == NULL)) continue; - - if (rec->mask != NULL && g_strcasecmp(rec->mask, mask) != 0) - continue; - - if ((channels == NULL && rec->channels == NULL)) - return rec; /* no channels - ok */ - - if (channels != NULL && strcmp(*channels, "*") == 0) - return rec; /* ignore channels */ - - if (channels == NULL || rec->channels == NULL) - continue; /* other doesn't have channels */ - - if (strarray_length(channels) != strarray_length(rec->channels)) - continue; /* different amount of channels */ - - /* check that channels match */ - for (chan = channels; *chan != NULL; chan++) { - if (strarray_find(rec->channels, *chan) == -1) - break; - } - - if (*chan == NULL) - return rec; /* channels ok */ - } - - return NULL; -} - -static void ignore_set_config(IGNORE_REC *rec) -{ - CONFIG_NODE *node; - char *levelstr; - - if (rec->level == 0 && rec->except_level == 0) - return; - - if (rec->time > 0) - return; - - node = iconfig_node_traverse("(ignores", TRUE); - node = config_node_section(node, NULL, NODE_TYPE_BLOCK); - - if (rec->mask != NULL) iconfig_node_set_str(node, "mask", rec->mask); - if (rec->level) { - levelstr = bits2level(rec->level); - iconfig_node_set_str(node, "level", levelstr); - g_free(levelstr); - } - if (rec->except_level) { - levelstr = bits2level(rec->except_level); - iconfig_node_set_str(node, "except_level", levelstr); - g_free(levelstr); - } - iconfig_node_set_str(node, "pattern", rec->pattern); - if (rec->regexp) config_node_set_bool(node, "regexp", TRUE); - if (rec->fullword) config_node_set_bool(node, "fullword", TRUE); - if (rec->replies) config_node_set_bool(node, "replies", TRUE); - - if (rec->channels != NULL && *rec->channels != NULL) { - node = config_node_section(node, "channels", NODE_TYPE_LIST); - config_node_add_list(node, rec->channels); - } -} - -static int ignore_index(IGNORE_REC *find) -{ - GSList *tmp; - int index; - - index = 0; - for (tmp = ignores; tmp != NULL; tmp = tmp->next) { - IGNORE_REC *rec = tmp->data; - - if (rec->servertag != NULL) - continue; - - if (rec == find) - return index; - index++; - } - - return -1; -} - -static void ignore_remove_config(IGNORE_REC *rec) -{ - CONFIG_NODE *node; - - node = iconfig_node_traverse("ignores", FALSE); - if (node != NULL) iconfig_node_list_remove(node, ignore_index(rec)); -} - -void ignore_add_rec(IGNORE_REC *rec) -{ - ignores = g_slist_append(ignores, rec); - ignore_set_config(rec); - - signal_emit("ignore created", 1, rec); -} - -static void ignore_destroy(IGNORE_REC *rec) -{ - ignores = g_slist_remove(ignores, rec); - signal_emit("ignore destroyed", 1, rec); - - if (rec->time_tag > 0) g_source_remove(rec->time_tag); - if (rec->channels != NULL) g_strfreev(rec->channels); - g_free_not_null(rec->mask); - g_free_not_null(rec->servertag); - g_free_not_null(rec->pattern); - g_free(rec); -} - -void ignore_update_rec(IGNORE_REC *rec) -{ - if (rec->level == 0 && rec->except_level == 0) { - /* unignored everything */ - ignore_remove_config(rec); - ignore_destroy(rec); - } else { - /* unignore just some levels.. */ - ignore_remove_config(rec); - ignores = g_slist_remove(ignores, rec); - - ignores = g_slist_append(ignores, rec); - ignore_set_config(rec); - - signal_emit("ignore changed", 1, rec); - } -} - -static void read_ignores(void) -{ - IGNORE_REC *rec; - CONFIG_NODE *node; - GSList *tmp; - - while (ignores != NULL) - ignore_destroy(ignores->data); - - node = iconfig_node_traverse("ignores", FALSE); - if (node == NULL) return; - - for (tmp = node->value; tmp != NULL; tmp = tmp->next) { - node = tmp->data; - - if (node->type != NODE_TYPE_BLOCK) - continue; - - rec = g_new0(IGNORE_REC, 1); - ignores = g_slist_append(ignores, rec); - - rec->mask = g_strdup(config_node_get_str(node, "mask", NULL)); - rec->pattern = g_strdup(config_node_get_str(node, "pattern", NULL)); - rec->level = level2bits(config_node_get_str(node, "level", "")); - rec->except_level = level2bits(config_node_get_str(node, "except_level", "")); - rec->regexp = config_node_get_bool(node, "regexp", FALSE); - rec->fullword = config_node_get_bool(node, "fullword", FALSE); - rec->replies = config_node_get_bool(node, "replies", FALSE); - - node = config_node_section(node, "channels", -1); - if (node != NULL) rec->channels = config_node_get_list(node); - } -} - -void ignore_init(void) -{ - ignores = NULL; - - read_ignores(); - signal_add("setup reread", (SIGNAL_FUNC) read_ignores); -} - -void ignore_deinit(void) -{ - while (ignores != NULL) - ignore_destroy(ignores->data); - - signal_remove("setup reread", (SIGNAL_FUNC) read_ignores); -} diff --git a/src/irc/core/ignore.h b/src/irc/core/ignore.h deleted file mode 100644 index bac02047..00000000 --- a/src/irc/core/ignore.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef __IGNORE_H -#define __IGNORE_H - -typedef struct { - char *mask; /* nick mask */ - char *servertag; /* this is for autoignoring */ - char **channels; /* ignore only in these channels */ - char *pattern; /* text body must match this pattern */ - - int level; /* ignore these levels */ - int except_level; /* don't ignore these levels */ - - int time; /* time in sec for temp ignores */ - int time_tag; - - int regexp:1; - int fullword:1; - int replies:1; /* ignore replies to nick in channel */ -} IGNORE_REC; - -extern GSList *ignores; - -int ignore_check(IRC_SERVER_REC *server, const char *nick, const char *host, - const char *channel, const char *text, int level); - -IGNORE_REC *ignore_find(const char *servertag, const char *mask, char **channels); - -void ignore_add_rec(IGNORE_REC *rec); -void ignore_update_rec(IGNORE_REC *rec); - -void ignore_init(void); -void ignore_deinit(void); - -#endif diff --git a/src/irc/core/irc-core.c b/src/irc/core/irc-core.c index 104fc403..7eb70bb1 100644 --- a/src/irc/core/irc-core.c +++ b/src/irc/core/irc-core.c @@ -27,7 +27,6 @@ #include "irc-queries.h" #include "ctcp.h" -#include "ignore.h" #include "irc.h" #include "netsplit.h" @@ -71,7 +70,6 @@ void irc_core_init(void) irc_irc_init(); lag_init(); netsplit_init(); - ignore_init(); irc_rawlog_init(); irc_special_vars_init(); irc_log_init(); @@ -82,7 +80,6 @@ void irc_core_deinit(void) irc_log_deinit(); irc_special_vars_deinit(); irc_rawlog_deinit(); - ignore_deinit(); netsplit_deinit(); lag_deinit(); irc_commands_deinit(); diff --git a/src/irc/flood/flood.c b/src/irc/flood/flood.c index 456bc21f..08fe9bf0 100644 --- a/src/irc/flood/flood.c +++ b/src/irc/flood/flood.c @@ -211,7 +211,7 @@ static void flood_privmsg(const char *data, IRC_SERVER_REC *server, const char * params = event_get_params(data, 2, &target, &text); level = ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS; - if (addr != NULL && !ignore_check(server, nick, addr, target, text, level)) + if (addr != NULL && !ignore_check(SERVER(server), nick, addr, target, text, level)) flood_newmsg(server, level, nick, addr, target); g_free(params); @@ -228,7 +228,7 @@ static void flood_notice(const char *data, IRC_SERVER_REC *server, const char *n return; params = event_get_params(data, 2, &target, &text); - if (!ignore_check(server, nick, addr, target, text, MSGLEVEL_NOTICES)) + if (!ignore_check(SERVER(server), nick, addr, target, text, MSGLEVEL_NOTICES)) flood_newmsg(server, MSGLEVEL_NOTICES, nick, addr, target); g_free(params); @@ -246,7 +246,7 @@ static void flood_ctcp(const char *data, IRC_SERVER_REC *server, const char *nic level = g_strncasecmp(data, "ACTION ", 7) != 0 ? MSGLEVEL_CTCPS : (ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS); - if (!ignore_check(server, nick, addr, target, data, level)) + if (!ignore_check(SERVER(server), nick, addr, target, data, level)) flood_newmsg(server, level, nick, addr, target); } -- cgit v1.2.3