static int get_wildcard_nicks(GString *output, const char *mask, IRC_CHANNEL_REC *channel, int op, int voice) { GSList *nicks, *tmp; int count; g_return_val_if_fail(output != NULL, 0); g_return_val_if_fail(mask != NULL, 0); g_return_val_if_fail(IS_IRC_CHANNEL(channel), 0); count = 0; nicks = nicklist_find_multiple(CHANNEL(channel), mask); for (tmp = nicks; tmp != NULL; tmp = tmp->next) { NICK_REC *rec = tmp->data; if ((op == 1 && !rec->op) || (op == 0 && rec->op) || (voice == 1 && !rec->voice) || (voice == 0 && rec->voice)) continue; if (g_strcasecmp(rec->nick, channel->server->nick) == 0) continue; g_string_sprintfa(output, "%s ", rec->nick); count++; } g_slist_free(nicks); return count; }
/* 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) { 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 (irc_nick_match(nick->nick, text)) return TRUE; } g_slist_free(nicks); return FALSE; }
/* check if `text' contains ignored nick at the start of the line. */ static int ignore_check_replies_rec(IGNORE_REC *rec, CHANNEL_REC *channel, const char *text) { GSList *nicks, *tmp; nicks = nicklist_find_multiple(channel, rec->mask); if (nicks == NULL) return FALSE; for (tmp = nicks; tmp != NULL; tmp = tmp->next) { NICK_REC *nick = tmp->data; if (nick_match_msg(channel, text, nick->nick)) return TRUE; } g_slist_free(nicks); return FALSE; }
static char *get_nicks(IRC_CHANNEL_REC *channel, const char *data, int op, int voice) { GString *str; GSList *nicks, *tmp; char **matches, **match, *ret; g_return_val_if_fail(channel != NULL, NULL); g_return_val_if_fail(data != NULL, NULL); if (*data == '\0') return NULL; str = g_string_new(NULL); matches = g_strsplit(data, " ", -1); for (match = matches; *match != NULL; match++) { if (strchr(*match, '*') == NULL && strchr(*match, '?') == NULL) { /* no wildcards */ g_string_sprintfa(str, "%s ", *match); continue; } /* wildcards */ nicks = nicklist_find_multiple(CHANNEL(channel), data); for (tmp = nicks; tmp != NULL; tmp = tmp->next) { NICK_REC *rec = tmp->data; if ((op == 1 && !rec->op) || (op == 0 && rec->op) || (voice == 1 && !rec->voice) || (voice == 0 && rec->voice)) continue; if (g_strcasecmp(rec->nick, channel->server->nick) == 0) continue; g_string_sprintfa(str, "%s ", rec->nick); } g_slist_free(nicks); } if (str->len > 0) g_string_truncate(str, str->len-1); ret = str->str; g_string_free(str, FALSE); return ret; }