int ignore_add (char *mask, int type, gboolean overwrite) { struct ignore *ig = NULL; int change_only = FALSE; /* first check if it's already ignored */ ig = ignore_exists (mask); if (ig) change_only = TRUE; if (!change_only) ig = g_new (struct ignore, 1); ig->mask = g_strdup (mask); if (!overwrite && change_only) ig->type |= type; else ig->type = type; if (!change_only) ignore_list = g_slist_prepend (ignore_list, ig); fe_ignore_update (1); if (change_only) return 2; return 1; }
int ignore_del (char *mask, struct ignore *ig) { if (!ig) { GSList *list = ignore_list; while (list) { ig = (struct ignore *) list->data; if (!rfc_casecmp (ig->mask, mask)) break; list = list->next; ig = 0; } } if (ig) { ignore_list = g_slist_remove (ignore_list, ig); g_free (ig->mask); g_free (ig); fe_ignore_update (1); return TRUE; } return FALSE; }
int ignore_check (char *host, int priv, int noti, int chan, int ctcp, int invi) { struct ignore *ig; GSList *list = ignore_list; /* check if there's an UNIGNORE first, they take precendance. */ while (list) { ig = (struct ignore *) list->data; if (ig->unignore) { if ( (ig->priv && priv) || (ig->noti && noti) || (ig->chan && chan) || (ig->ctcp && ctcp) || (ig->invi && invi)) { if (match (ig->mask, host)) return FALSE; } } list = list->next; } list = ignore_list; while (list) { ig = (struct ignore *) list->data; if ( (ig->priv && priv) || (ig->noti && noti) || (ig->chan && chan) || (ig->ctcp && ctcp) || (ig->invi && invi)) { if (match (ig->mask, host)) { ignored_total++; if (priv) ignored_priv++; if (noti) ignored_noti++; if (chan) ignored_chan++; if (ctcp) ignored_ctcp++; if (invi) ignored_invi++; fe_ignore_update (2); return TRUE; } } list = list->next; } return FALSE; }
int ignore_check (char *host, int type) { struct ignore *ig; GSList *list = ignore_list; /* check if there's an UNIGNORE first, they take precendance. */ while (list) { ig = (struct ignore *) list->data; if (ig->type & IG_UNIG) { if (ig->type & type) { if (match (ig->mask, host)) return FALSE; } } list = list->next; } list = ignore_list; while (list) { ig = (struct ignore *) list->data; if (ig->type & type) { if (match (ig->mask, host)) { ignored_total++; if (type & IG_PRIV) ignored_priv++; if (type & IG_NOTI) ignored_noti++; if (type & IG_CHAN) ignored_chan++; if (type & IG_CTCP) ignored_ctcp++; if (type & IG_INVI) ignored_invi++; fe_ignore_update (2); return TRUE; } } list = list->next; } return FALSE; }
int ignore_add (char *mask, int priv, int noti, int chan, int ctcp, int invi, int unignore, int no_save) { struct ignore *ig = 0; GSList *list; int change_only = FALSE; /* first check if it's already ignored */ list = ignore_list; while (list) { ig = (struct ignore *) list->data; if (!strcasecmp (ig->mask, mask)) { /* already ignored, change the flags */ change_only = TRUE; break; } list = list->next; } if (!change_only) ig = malloc (sizeof (struct ignore)); if (!ig) return 0; ig->mask = strdup (mask); ig->priv = priv; ig->noti = noti; ig->chan = chan; ig->ctcp = ctcp; ig->invi = invi; ig->unignore = unignore; ig->no_save = no_save; if (!change_only) ignore_list = g_slist_prepend (ignore_list, ig); fe_ignore_update (1); if (change_only) return 2; return 1; }