summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2002-05-13 18:16:17 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2002-05-13 18:16:17 +0000
commita5f4fd43cc088380291ab275aae0e7f67ee2d12b (patch)
tree8e7515b9b9c090352523a34f76026e517fe6daff /src/irc
parent2adba92338ce4acc6c52300ba76907686ec42284 (diff)
downloadirssi-a5f4fd43cc088380291ab275aae0e7f67ee2d12b.zip
don't add same ban more than once to banlist.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2790 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/core/mode-lists.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/irc/core/mode-lists.c b/src/irc/core/mode-lists.c
index 8d0a9eab..d7fef183 100644
--- a/src/irc/core/mode-lists.c
+++ b/src/irc/core/mode-lists.c
@@ -44,6 +44,22 @@ void banlist_free(GSList *banlist)
ban_free(&banlist, banlist->data);
}
+static BAN_REC *banlist_find(GSList *list, const char *ban)
+{
+ GSList *tmp;
+
+ g_return_val_if_fail(ban != NULL, NULL);
+
+ for (tmp = list; tmp != NULL; tmp = tmp->next) {
+ BAN_REC *rec = tmp->data;
+
+ if (g_strcasecmp(rec->ban, ban) == 0)
+ return rec;
+ }
+
+ return NULL;
+}
+
BAN_REC *banlist_add(IRC_CHANNEL_REC *channel, const char *ban,
const char *nick, time_t time)
{
@@ -52,6 +68,14 @@ BAN_REC *banlist_add(IRC_CHANNEL_REC *channel, const char *ban,
g_return_val_if_fail(channel != NULL, NULL);
g_return_val_if_fail(ban != NULL, NULL);
+ rec = banlist_find(channel->banlist, ban);
+ if (rec != NULL) {
+ /* duplicate - ignore. some servers send duplicates
+ for non-ops because they just replace the hostname with
+ eg. "localhost"... */
+ return NULL;
+ }
+
rec = g_new(BAN_REC, 1);
rec->ban = g_strdup(ban);
rec->setby = nick == NULL || *nick == '\0' ? NULL :
@@ -64,22 +88,6 @@ BAN_REC *banlist_add(IRC_CHANNEL_REC *channel, const char *ban,
return rec;
}
-static BAN_REC *banlist_find(GSList *list, const char *ban)
-{
- GSList *tmp;
-
- g_return_val_if_fail(ban != NULL, NULL);
-
- for (tmp = list; tmp != NULL; tmp = tmp->next) {
- BAN_REC *rec = tmp->data;
-
- if (g_strcasecmp(rec->ban, ban) == 0)
- return rec;
- }
-
- return NULL;
-}
-
void banlist_remove(IRC_CHANNEL_REC *channel, const char *ban)
{
BAN_REC *rec;