summaryrefslogtreecommitdiff
path: root/src/process.c
diff options
context:
space:
mode:
authorgeniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b <geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2008-09-14 16:32:24 +0000
committergeniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b <geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2008-09-14 16:32:24 +0000
commit2923c21db77d5bbf51830ff6505281f81fdac920 (patch)
treed69163616dbe5ff5504cf020c62345085f11ebd3 /src/process.c
parent521ce2e0f7f95f5abeff464a56426e5b74368f61 (diff)
BUILD : 1.7.22 (1440) BUGS : NOTES : Anope 1.7.22 release
git-svn-id: svn://svn.anope.org/anope/trunk@1440 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1155 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c348
1 files changed, 173 insertions, 175 deletions
diff --git a/src/process.c b/src/process.c
index a8efaec94..627c94f04 100644
--- a/src/process.c
+++ b/src/process.c
@@ -35,54 +35,56 @@ void add_ignore(const char *nick, time_t delta)
{
IgnoreData *ign;
char tmp[BUFSIZE];
- char *mask, *user, *host;
- time_t now = time(NULL);
-
- if (!nick)
- return;
-
- /* Determine whether we get a nick or a mask. */
- if ((host = strchr(nick, '@'))) {
- /* Check whether we have a nick too.. */
- if ((user = strchr(nick, '!'))) {
- /* this should never happen */
- if (user > host)
- return;
- mask = sstrdup(nick);
- } else {
- /* We have user@host. Add nick wildcard. */
- snprintf(tmp, sizeof(tmp), "*!%s", nick);
- mask = sstrdup(tmp);
- }
- } else {
- /* We only got a nick.. */
- snprintf(tmp, sizeof(tmp), "%s!*@*", nick);
- mask = sstrdup(tmp);
- }
-
- /* Check if we already got an identical entry. */
- for (ign = ignore; ign; ign = ign->next)
+ char *mask, *user, *host;
+ time_t now = time(NULL);
+ if (!nick)
+ return;
+
+ /* Determine whether we get a nick or a mask. */
+ if ((host = strchr(nick, '@'))) {
+ /* Check whether we have a nick too.. */
+ if ((user = strchr(nick, '!'))) {
+
+ /* this should never happen */
+ if (user > host)
+ return;
+ mask = sstrdup(nick);
+ } else {
+
+ /* We have user@host. Add nick wildcard. */
+ snprintf(tmp, sizeof(tmp), "*!%s", nick);
+ mask = sstrdup(tmp);
+ }
+ } else {
+
+ /* We only got a nick.. */
+ snprintf(tmp, sizeof(tmp), "%s!*@*", nick);
+ mask = sstrdup(tmp);
+ }
+
+ /* Check if we already got an identical entry. */
+ for (ign = ignore; ign; ign = ign->next)
if (stricmp(ign->mask, mask) == 0)
break;
- /* Found one.. */
- if (ign) {
+ /* Found one.. */
+ if (ign) {
if (ign->time < now + delta)
- ign->time = now + delta;
- /* Create new entry.. */
+ ign->time = now + delta;
+
+ /* Create new entry.. */
} else {
ign = scalloc(sizeof(*ign), 1);
ign->mask = mask;
ign->time = now + delta;
- ign->prev = NULL;
- ign->next = ignore;
- if (ignore)
- ignore->prev = ign;
- ignore = ign;
-
- if (debug)
- alog("debug: Added new ignore entry for %s", mask);
- }
+ ign->prev = NULL;
+ ign->next = ignore;
+ if (ignore)
+ ignore->prev = ign;
+ ignore = ign;
+ if (debug)
+ alog("debug: Added new ignore entry for %s", mask);
+ }
}
/*************************************************************************/
@@ -97,160 +99,157 @@ void add_ignore(const char *nick, time_t delta)
IgnoreData *get_ignore(const char *nick)
{
IgnoreData *ign;
- char tmp[BUFSIZE];
- char *user, *host;
- time_t now = time(NULL);
+ char tmp[BUFSIZE];
+ char *user, *host;
+ time_t now = time(NULL);
User *u = finduser(nick);
-
- if (!nick)
- return NULL;
-
- /* User has disabled the IGNORE system */
- if (!allow_ignore)
+ if (!nick)
+ return NULL;
+
+ /* User has disabled the IGNORE system */
+ if (!allow_ignore)
return NULL;
-
- /* If we found a real user, match his mask against the ignorelist. */
- if (u) {
- /* Opers are not ignored, even if a matching entry may be present. */
- if (is_oper(u))
- return NULL;
-
- for (ign = ignore; ign; ign = ign->next)
+
+ /* If we found a real user, match his mask against the ignorelist. */
+ if (u) {
+
+ /* Opers are not ignored, even if a matching entry may be present. */
+ if (is_oper(u))
+ return NULL;
+ for (ign = ignore; ign; ign = ign->next)
if (match_usermask(ign->mask, u))
break;
} else {
- /* We didn't get a user.. generate a valid mask. */
- if ((host = strchr(nick, '@'))) {
- if ((user = strchr(nick, '!'))) {
- /* this should never happen */
- if (user > host)
- return NULL;
- snprintf(tmp, sizeof(tmp), "%s", nick);
- } else {
- /* We have user@host. Add nick wildcard. */
- snprintf(tmp, sizeof(tmp), "*!%s", nick);
- }
- } else {
- /* We only got a nick.. */
- snprintf(tmp, sizeof(tmp), "%s!*@*", nick);
- }
+ /* We didn't get a user.. generate a valid mask. */
+ if ((host = strchr(nick, '@'))) {
+ if ((user = strchr(nick, '!'))) {
+
+ /* this should never happen */
+ if (user > host)
+ return NULL;
+ snprintf(tmp, sizeof(tmp), "%s", nick);
+ } else {
+
+ /* We have user@host. Add nick wildcard. */
+ snprintf(tmp, sizeof(tmp), "*!%s", nick);
+ }
+ } else {
+
+ /* We only got a nick.. */
+ snprintf(tmp, sizeof(tmp), "%s!*@*", nick);
+ }
+ for (ign = ignore; ign; ign = ign->next)
+ if (match_wild_nocase(ign->mask, tmp))
+ break;
+ }
+
+ /* Check whether the entry has timed out */
+ if (ign && ign->time <= now) {
+ if (debug)
+ alog("debug: Expiring ignore entry %s", ign->mask);
+ if (ign->prev)
+ ign->prev->next = ign->next;
- for (ign = ignore; ign; ign = ign->next)
- if (match_wild_nocase(ign->mask, tmp))
- break;
- }
-
- /* Check whether the entry has timed out */
- if (ign && ign->time <= now) {
- if (debug)
- alog("debug: Expiring ignore entry %s", ign->mask);
-
- if (ign->prev)
- ign->prev->next = ign->next;
- else if (ignore == ign)
- ignore = ign->next;
- if (ign->next)
- ign->next->prev = ign->prev;
-
- free(ign->mask);
+ else if (ignore == ign)
+ ignore = ign->next;
+ if (ign->next)
+ ign->next->prev = ign->prev;
+ free(ign->mask);
free(ign);
ign = NULL;
}
-
- if (ign && debug)
- alog("debug: Found ignore entry (%s) for %s", ign->mask, nick);
-
- return ign;
+ if (ign && debug)
+ alog("debug: Found ignore entry (%s) for %s", ign->mask, nick);
+ return ign;
}
+
-/*************************************************************************/
-
+/*************************************************************************/
+
/**
* Deletes a given nick/mask from the ignorelist.
* @param nick Nick or (nick!)user@host to delete from the ignorelist.
* @return Returns 1 on success, 0 if no entry is found.
- */
-int delete_ignore(const char *nick)
-{
- IgnoreData *ign;
- char tmp[BUFSIZE];
- char *user, *host;
-
- if (!nick)
- return 0;
-
- /* Determine whether we get a nick or a mask. */
- if ((host = strchr(nick, '@'))) {
- /* Check whether we have a nick too.. */
- if ((user = strchr(nick, '!'))) {
- /* this should never happen */
- if (user > host)
- return 0;
- snprintf(tmp, sizeof(tmp), "%s", nick);
- } else {
- /* We have user@host. Add nick wildcard. */
- snprintf(tmp, sizeof(tmp), "*!%s", nick);
- }
- } else {
- /* We only got a nick.. */
- snprintf(tmp, sizeof(tmp), "%s!*@*", nick);
- }
-
- for (ign = ignore; ign; ign = ign->next)
- if (stricmp(ign->mask, tmp) == 0)
- break;
-
- /* No matching ignore found. */
- if (!ign)
- return 0;
-
- if (debug)
- alog("Deleting ignore entry %s", ign->mask);
-
- /* Delete the entry and all references to it. */
- if (ign->prev)
- ign->prev->next = ign->next;
- else if (ignore == ign)
- ignore = ign->next;
- if (ign->next)
- ign->next->prev = ign->prev;
- free(ign->mask);
- free(ign);
- ign = NULL;
- return 1;
-}
-
-/*************************************************************************/
-
+ */
+int delete_ignore(const char *nick)
+{
+ IgnoreData * ign;
+ char tmp[BUFSIZE];
+ char *user, *host;
+ if (!nick)
+ return 0;
+
+ /* Determine whether we get a nick or a mask. */
+ if ((host = strchr(nick, '@'))) {
+
+ /* Check whether we have a nick too.. */
+ if ((user = strchr(nick, '!'))) {
+
+ /* this should never happen */
+ if (user > host)
+ return 0;
+ snprintf(tmp, sizeof(tmp), "%s", nick);
+ } else {
+
+ /* We have user@host. Add nick wildcard. */
+ snprintf(tmp, sizeof(tmp), "*!%s", nick);
+ }
+ } else {
+
+ /* We only got a nick.. */
+ snprintf(tmp, sizeof(tmp), "%s!*@*", nick);
+ }
+ for (ign = ignore; ign; ign = ign->next)
+ if (stricmp(ign->mask, tmp) == 0)
+ break;
+
+ /* No matching ignore found. */
+ if (!ign)
+ return 0;
+ if (debug)
+ alog("Deleting ignore entry %s", ign->mask);
+
+ /* Delete the entry and all references to it. */
+ if (ign->prev)
+ ign->prev->next = ign->next;
+
+ else if (ignore == ign)
+ ignore = ign->next;
+ if (ign->next)
+ ign->next->prev = ign->prev;
+ free(ign->mask);
+ free(ign);
+ ign = NULL;
+ return 1;
+ }
+
+
+/*************************************************************************/
+
/**
* Clear the ignorelist.
* @return The number of entries deleted.
- */
-int clear_ignores()
-{
- IgnoreData *ign, *next;
- int i = 0;
-
- if (!ignore)
- return 0;
-
- for (ign = ignore; ign; ign = next) {
- next = ign->next;
-
- if (debug)
- alog("Deleting ignore entry %s", ign->mask);
-
- free(ign->mask);
- free(ign);
- i++;
- }
- ignore = NULL;
-
- return i;
-}
+ */
+int clear_ignores()
+{
+ IgnoreData * ign, *next;
+ int i = 0;
+ if (!ignore)
+ return 0;
+ for (ign = ignore; ign; ign = next) {
+ next = ign->next;
+ if (debug)
+ alog("Deleting ignore entry %s", ign->mask);
+ free(ign->mask);
+ free(ign);
+ i++;
+ }
+ ignore = NULL;
+ return i;
+ }
+
/*************************************************************************/
-
/* split_buf: Split a buffer into arguments and store the arguments in an
* argument vector pointed to by argv (which will be malloc'd
* as necessary); return the argument count. If colon_special
@@ -258,7 +257,6 @@ int clear_ignores()
* the last parameter of the line, per the IRC RFC. Destroys
* the buffer by side effect.
*/
-
int split_buf(char *buf, char ***argv, int colon_special)
{
int argvsize = 8;