diff options
author | geniusdex 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 |
---|---|---|
committer | geniusdex 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 |
commit | 2923c21db77d5bbf51830ff6505281f81fdac920 (patch) | |
tree | d69163616dbe5ff5504cf020c62345085f11ebd3 /src | |
parent | 521ce2e0f7f95f5abeff464a56426e5b74368f61 (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')
-rw-r--r-- | src/actions.c | 2 | ||||
-rw-r--r-- | src/botserv.c | 6 | ||||
-rw-r--r-- | src/channels.c | 66 | ||||
-rw-r--r-- | src/process.c | 348 |
4 files changed, 217 insertions, 205 deletions
diff --git a/src/actions.c b/src/actions.c index acf945420..46617643b 100644 --- a/src/actions.c +++ b/src/actions.c @@ -181,7 +181,7 @@ void common_unban(ChannelInfo * ci, char *nick) for (ban = ci->c->bans->entries; ban; ban = next) { next = ban->next; if (entry_match(ban, u->nick, u->username, u->host, ip) || - entry_match(ban, u->nick, u->username, u->vhost, ip)) { + entry_match(ban, u->nick, u->username, u->vhost, ip)) { anope_cmd_mode(whosends(ci), ci->name, "-b %s", ban->mask); if (ircdcap->tsmode) av[3] = ban->mask; diff --git a/src/botserv.c b/src/botserv.c index f8eea632e..ed5af558d 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -782,8 +782,10 @@ void bot_join(ChannelInfo * ci) for (ban = ci->c->bans->entries; ban; ban = next) { next = ban->next; - if (entry_match(ban, ci->bi->nick, ci->bi->user, ci->bi->host, 0)) { - anope_cmd_mode(whosends(ci), ci->name, "-b %s", ban->mask); + if (entry_match + (ban, ci->bi->nick, ci->bi->user, ci->bi->host, 0)) { + anope_cmd_mode(whosends(ci), ci->name, "-b %s", + ban->mask); if (ircdcap->tsmode) av[3] = ban->mask; else diff --git a/src/channels.c b/src/channels.c index 8f1df877d..cac56d479 100644 --- a/src/channels.c +++ b/src/channels.c @@ -1698,7 +1698,8 @@ void del_ban(Channel * chan, char *mask) entry_delete(chan->bans, ban); if (debug) - alog("debug: Deleted ban %s from channel %s", mask, chan->name); + alog("debug: Deleted ban %s from channel %s", mask, + chan->name); } if (chan->ci && (akick = is_stuck(chan->ci, mask))) @@ -1712,7 +1713,7 @@ void del_exception(Channel * chan, char *mask) Entry *exception; /* Sanity check as it seems some IRCD will just send -e without a mask */ - if (!mask|| !chan->excepts || (chan->excepts->count == 0)) + if (!mask || !chan->excepts || (chan->excepts->count == 0)) return; exception = elist_find_mask(chan->excepts, mask); @@ -1721,7 +1722,8 @@ void del_exception(Channel * chan, char *mask) entry_delete(chan->excepts, exception); if (debug) - alog("debug: Deleted except %s to channel %s", mask, chan->name); + alog("debug: Deleted except %s to channel %s", mask, + chan->name); } } @@ -1742,7 +1744,8 @@ void del_invite(Channel * chan, char *mask) entry_delete(chan->invites, invite); if (debug) - alog("debug: Deleted invite %s to channel %s", mask, chan->name); + alog("debug: Deleted invite %s to channel %s", mask, + chan->name); } } @@ -2008,7 +2011,7 @@ Entry *entry_create(char *mask) * @param mask The mask to parse and add to the list * @return Pointer to newly added entry. NULL if it fails. */ -Entry *entry_add(EList *list, char *mask) +Entry *entry_add(EList * list, char *mask) { Entry *e; char *hostmask; @@ -2036,7 +2039,7 @@ Entry *entry_add(EList *list, char *mask) * @param list Linked list from which entry needs to be removed. * @param e The entry to be deleted, must be member of list. */ -void entry_delete(EList *list, Entry *e) +void entry_delete(EList * list, Entry * e) { if (!list || !e) return; @@ -2066,7 +2069,8 @@ void entry_delete(EList *list, Entry *e) * Create and initialize a new entrylist * @return Pointer to the created EList object **/ -EList *list_create() { +EList *list_create() +{ EList *list; list = scalloc(1, sizeof(EList)); @@ -2086,26 +2090,32 @@ EList *list_create() { * @param ip IP to match against, set to 0 to not match this * @return 1 for a match, 0 for no match */ -int entry_match(Entry *e, char *nick, char *user, char *host, uint32 ip) +int entry_match(Entry * e, char *nick, char *user, char *host, uint32 ip) { - /* If we don't get an entry, or it s an invalid one, no match ~ Viper*/ + /* If we don't get an entry, or it s an invalid one, no match ~ Viper */ if (!e || e->type == ENTRYTYPE_NONE) return 0; if (ircd->cidrchanbei && (e->type & ENTRYTYPE_CIDR4) && - (!ip || (ip && ((ip & e->cidr_mask) != e->cidr_ip)))) + (!ip || (ip && ((ip & e->cidr_mask) != e->cidr_ip)))) return 0; - if ((e->type & ENTRYTYPE_NICK) && (!nick || stricmp(e->nick, nick) != 0)) + if ((e->type & ENTRYTYPE_NICK) + && (!nick || stricmp(e->nick, nick) != 0)) return 0; - if ((e->type & ENTRYTYPE_USER) && (!user || stricmp(e->user, user) != 0)) + if ((e->type & ENTRYTYPE_USER) + && (!user || stricmp(e->user, user) != 0)) return 0; - if ((e->type & ENTRYTYPE_HOST) && (!user || stricmp(e->host, host) != 0)) + if ((e->type & ENTRYTYPE_HOST) + && (!user || stricmp(e->host, host) != 0)) return 0; - if ((e->type & ENTRYTYPE_NICK_WILD) && !match_wild_nocase(e->nick, nick)) + if ((e->type & ENTRYTYPE_NICK_WILD) + && !match_wild_nocase(e->nick, nick)) return 0; - if ((e->type & ENTRYTYPE_USER_WILD) && !match_wild_nocase(e->user, user)) + if ((e->type & ENTRYTYPE_USER_WILD) + && !match_wild_nocase(e->user, user)) return 0; - if ((e->type & ENTRYTYPE_HOST_WILD) && !match_wild_nocase(e->host, host)) + if ((e->type & ENTRYTYPE_HOST_WILD) + && !match_wild_nocase(e->host, host)) return 0; return 1; @@ -2118,7 +2128,7 @@ int entry_match(Entry *e, char *nick, char *user, char *host, uint32 ip) * @param ip IP to match against, set to 0 to not match this * @return 1 for a match, 0 for no match */ -int entry_match_mask(Entry *e, char *mask, uint32 ip) +int entry_match_mask(Entry * e, char *mask, uint32 ip) { char *hostmask, *nick, *user, *host; int res; @@ -2132,7 +2142,7 @@ int entry_match_mask(Entry *e, char *mask, uint32 ip) if (user) { *user++ = '\0'; nick = hostmask; - } else { + } else { nick = NULL; user = hostmask; } @@ -2159,7 +2169,8 @@ int entry_match_mask(Entry *e, char *mask, uint32 ip) * @param ip The ip to match * @return Returns the first matching entry, if none, NULL is returned. */ -Entry *elist_match(EList *list, char *nick, char *user, char *host, uint32 ip) +Entry *elist_match(EList * list, char *nick, char *user, char *host, + uint32 ip) { Entry *e; @@ -2182,7 +2193,7 @@ Entry *elist_match(EList *list, char *nick, char *user, char *host, uint32 ip) * @param ip The ip to match * @return Returns the first matching entry, if none, NULL is returned. */ -Entry *elist_match_mask(EList *list, char *mask, uint32 ip) +Entry *elist_match_mask(EList * list, char *mask, uint32 ip) { char *hostmask, *nick, *user, *host; Entry *res; @@ -2199,7 +2210,7 @@ Entry *elist_match_mask(EList *list, char *mask, uint32 ip) if (user) { *user++ = '\0'; nick = hostmask; - } else { + } else { nick = NULL; user = hostmask; } @@ -2223,7 +2234,7 @@ Entry *elist_match_mask(EList *list, char *mask, uint32 ip) * @param user The user to match against the entries * @return Returns the first matching entry, if none, NULL is returned. */ -Entry *elist_match_user(EList *list, User *u) +Entry *elist_match_user(EList * list, User * u) { Entry *res; char *host; @@ -2264,16 +2275,16 @@ Entry *elist_match_user(EList *list, User *u) * @param mask The *!*@* mask to match * @return Returns the first matching entry, if none, NULL is returned. */ -Entry *elist_find_mask(EList *list, char *mask) +Entry *elist_find_mask(EList * list, char *mask) { Entry *e; if (!list || !list->entries || !mask) return NULL; - for (e = list->entries; e; e = e->next) { - if (!stricmp(e->mask, mask)) - return e; + for (e = list->entries; e; e = e->next) { + if (!stricmp(e->mask, mask)) + return e; } return NULL; @@ -2284,7 +2295,8 @@ Entry *elist_find_mask(EList *list, char *mask) * @param list The list we should estimate the mem use of. * @return Returns the memory useage of the given list. */ -long get_memuse(EList *list) { +long get_memuse(EList * list) +{ Entry *e; long mem = 0; 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; |