/* * svsignore.C: Services ignore list management. * Rights to this code are documented in doc/LICENSE. * * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) */ static char const rcsid[] = "$Id"; #include "atheme.h" #include svsignore_vector svs_ignore_list; /* * svsignore_add(char *mask, char *reason) * * Services ignore factory. * * Inputs: * - mask to ignore * - reason for ignore * * Outputs: * - on success, a new svsignore object * * Side Effects: * - a services ignore is added * * Bugs: * - this function does not check for dupes */ svsignore_t * svsignore_add (char *mask, char *reason) { svsignore_t *svsignore; svsignore = static_cast (smalloc (sizeof (svsignore_t))); svs_ignore_list.push_back (svsignore); svsignore->mask = sstrdup (mask); svsignore->settime = NOW; svsignore->reason = sstrdup (reason); cnt.svsignore++; return svsignore; } /* * svsignore_find(user_t *source) * * Finds any services ignores that affect a user. * * Inputs: * - user object to check * * Outputs: * - if any ignores match, the ignore that matches * - if none match, NULL * * Side Effects: * - none */ svsignore_t * svsignore_find (user_t *source) { svsignore_t *svsignore; svsignore_vector::iterator it, it_end; char host[BUFSIZE]; if (!use_svsignore) return NULL; *host = '\0'; strlcpy (host, source->nick, BUFSIZE); strlcat (host, "!", BUFSIZE); strlcat (host, source->user, BUFSIZE); strlcat (host, "@", BUFSIZE); strlcat (host, source->host, BUFSIZE); for (it = svs_ignore_list.begin (), it_end = svs_ignore_list.end (); it != it_end; ++it) { svsignore = *it; if (!match (svsignore->mask, host)) return svsignore; } return NULL; } /* * svsignore_delete(svsignore_t *svsignore) * * Destroys a services ignore. * * Inputs: * - svsignore to destroy * * Outputs: * - nothing * * Side Effects: * - a services ignore is destroyed and removed from the list */ void svsignore_delete (svsignore_t *svsignore) { svs_ignore_list.erase (svsignore); free (svsignore->mask); free (svsignore->reason); free (svsignore); }