diff options
author | LemonBoy <thatlemon@gmail.com> | 2016-01-03 19:49:18 +0100 |
---|---|---|
committer | LemonBoy <thatlemon@gmail.com> | 2016-01-03 19:49:18 +0100 |
commit | 609f3ba6c2db4f04e1e11304459d4fc42babd8ff (patch) | |
tree | 4f443608facdee13362785646d0f48d4b3a908d4 /src/core/ignore.c | |
parent | 787956af3aac001755ec87d52cbb28f7c91800e1 (diff) | |
download | irssi-609f3ba6c2db4f04e1e11304459d4fc42babd8ff.zip |
Clean up the ignore_find API to make it more powerful.
This way we prevent the creation of duplicate ignores since the old code
skipped the ignore_find call when a pattern was specified.
It should also cover all the cases where the ignores would be wrongly
overwritten, such as the case outlined in #78.
Diffstat (limited to 'src/core/ignore.c')
-rw-r--r-- | src/core/ignore.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/core/ignore.c b/src/core/ignore.c index fd3c8a38..ee9e180d 100644 --- a/src/core/ignore.c +++ b/src/core/ignore.c @@ -186,15 +186,8 @@ int ignore_check(SERVER_REC *server, const char *nick, const char *host, return ignore_check_replies(chanrec, text, level); } -IGNORE_REC *ignore_find(const char *servertag, const char *mask, - char **channels) -{ - return ignore_find_noact(servertag, mask, channels, 0); -} - - -IGNORE_REC *ignore_find_noact(const char *servertag, const char *mask, - char **channels, int noact) +IGNORE_REC *ignore_find(const char *servertag, const char *mask, const char *pattern, + char **channels, const int flags) { GSList *tmp; char **chan; @@ -216,18 +209,29 @@ IGNORE_REC *ignore_find_noact(const char *servertag, const char *mask, continue; } - if (noact && (rec->level & MSGLEVEL_NO_ACT) == 0) + if ((flags & IGNORE_FIND_NOACT) && (rec->level & MSGLEVEL_NO_ACT) == 0) continue; - if (!noact && (rec->level & MSGLEVEL_NO_ACT) != 0) + if (!(flags & IGNORE_FIND_NOACT) && (rec->level & MSGLEVEL_NO_ACT) != 0) continue; if ((rec->mask == NULL && mask != NULL) || - (rec->mask != NULL && mask == NULL)) continue; + (rec->mask != NULL && mask == NULL)) + continue; if (rec->mask != NULL && g_ascii_strcasecmp(rec->mask, mask) != 0) continue; + /* match the pattern too if requested */ + if (flags & IGNORE_FIND_PATTERN) { + if ((rec->pattern == NULL && pattern != NULL) || + (rec->pattern != NULL && pattern == NULL)) + continue; + + if (rec->pattern != NULL && g_ascii_strcasecmp(rec->pattern, pattern) != 0) + continue; + } + if ((channels == NULL && rec->channels == NULL)) return rec; /* no channels - ok */ |