mirror of
https://github.com/irssi/irssi.git
synced 2026-08-10 12:23:37 +02:00
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.
This commit is contained in:
parent
787956af3a
commit
609f3ba6c2
4 changed files with 28 additions and 19 deletions
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,13 @@ 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);
|
||||
IGNORE_REC *ignore_find_noact(const char *servertag, const char *mask, char **channels, int noact);
|
||||
enum {
|
||||
IGNORE_FIND_PATTERN = 0x01, // Match the pattern
|
||||
IGNORE_FIND_NOACT = 0x02, // Exclude the targets with NOACT level
|
||||
};
|
||||
|
||||
IGNORE_REC *ignore_find(const char *servertag, const char *mask, const char *pattern,
|
||||
char **channels, const int flags);
|
||||
|
||||
void ignore_add_rec(IGNORE_REC *rec);
|
||||
void ignore_update_rec(IGNORE_REC *rec);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue