int ignore_check(SERVER_REC *server, const char *nick, const char *host, const char *channel, const char *text, int level) { CHANNEL_REC *chanrec; NICK_REC *nickrec; IGNORE_REC *rec; GSList *tmp; char *nickmask; int len, best_mask, best_match, best_patt; if (nick == NULL) nick = ""; chanrec = server == NULL || channel == NULL ? NULL : channel_find(server, channel); if (chanrec != NULL && nick != NULL && (nickrec = nicklist_find(chanrec, nick)) != NULL) { /* nick found - check only ignores in nickmatch cache */ if (nickrec->host == NULL) nicklist_set_host(chanrec, nickrec, host); tmp = nickmatch_find(nickmatch, nickrec); nickmask = NULL; } else { tmp = ignores; nickmask = g_strconcat(nick, "!", host, NULL); } best_mask = best_patt = -1; best_match = FALSE; for (; tmp != NULL; tmp = tmp->next) { int match = 1; rec = tmp->data; if (nickmask != NULL) match = ignore_match_server(rec, server) && ignore_match_channel(rec, channel) && ignore_match_nickmask(rec, nick, nickmask); if (match && ignore_match_level(rec, level) && ignore_match_pattern(rec, text)) { len = rec->mask == NULL ? 0 : strlen(rec->mask); if (len > best_mask) { best_mask = len; best_match = !rec->exception; } else if (len == best_mask) { len = rec->pattern == NULL ? 0 : strlen(rec->pattern); if (len > best_patt) { best_patt = len; best_match = !rec->exception; } else if (len == best_patt && rec->exception) best_match = 0; } } } g_free(nickmask); if (best_match || (level & MSGLEVEL_PUBLIC) == 0) return best_match; return ignore_check_replies(chanrec, text, level); }
HILIGHT_REC *hilight_match(SERVER_REC *server, const char *channel, const char *nick, const char *address, int level, const char *str, int *match_beg, int *match_end) { GSList *tmp; CHANNEL_REC *chanrec; NICK_REC *nickrec; g_return_val_if_fail(str != NULL, NULL); if ((never_hilight_level & level) == level) return NULL; if (nick != NULL) { /* check nick mask hilights */ chanrec = channel_find(server, channel); nickrec = chanrec == NULL ? NULL : nicklist_find(chanrec, nick); if (nickrec != NULL) { HILIGHT_REC *rec; if (nickrec->host == NULL) nicklist_set_host(chanrec, nickrec, address); rec = nickmatch_find(nickmatch, nickrec); if (rec != NULL && hilight_match_level(rec, level)) return rec; } } for (tmp = hilights; tmp != NULL; tmp = tmp->next) { HILIGHT_REC *rec = tmp->data; if (!rec->nickmask && hilight_match_level(rec, level) && hilight_match_channel(rec, channel) && (rec->servertag == NULL || (server != NULL && g_ascii_strcasecmp(rec->servertag, server->tag) == 0)) && hilight_match_text(rec, str, match_beg, match_end)) return rec; } return NULL; }