diff options
author | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-02-16 09:17:24 +0000 |
---|---|---|
committer | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-02-16 09:17:24 +0000 |
commit | 010c774bc241f0c3a9c116988bfc3637cf64c5d7 (patch) | |
tree | 65a80fd39dadfa703a484799b338ea1518efbbbf /src | |
parent | 22e8e87a00404725f32f4a53f57809d917876914 (diff) |
Revert "Patch from DukePyrolator to replace all calls to match_wild() and match_wild_nocase() to use Anope::Match() instead. Also changes line-endings on wildcard.cpp to Unix-style, as well as fixes a small compile warning in language.c."
This reverts commit fcab9857f55567f10eaecbd6b26ee96f0f549d65.
This isn't a simple sed operation, the order of arguments changed, so this would break everything using it.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2081 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.c | 2 | ||||
-rw-r--r-- | src/channels.c | 6 | ||||
-rw-r--r-- | src/chanserv.c | 6 | ||||
-rw-r--r-- | src/core/bs_badwords.c | 2 | ||||
-rw-r--r-- | src/core/cs_access.c | 2 | ||||
-rw-r--r-- | src/core/cs_akick.c | 10 | ||||
-rw-r--r-- | src/core/cs_list.c | 4 | ||||
-rw-r--r-- | src/core/cs_xop.c | 2 | ||||
-rw-r--r-- | src/core/hs_list.c | 2 | ||||
-rw-r--r-- | src/core/ns_access.c | 4 | ||||
-rw-r--r-- | src/core/ns_list.c | 4 | ||||
-rw-r--r-- | src/core/os_admin.c | 2 | ||||
-rw-r--r-- | src/core/os_akill.c | 4 | ||||
-rw-r--r-- | src/core/os_chanlist.c | 2 | ||||
-rw-r--r-- | src/core/os_noop.c | 2 | ||||
-rw-r--r-- | src/core/os_oper.c | 2 | ||||
-rw-r--r-- | src/core/os_session.c | 4 | ||||
-rw-r--r-- | src/core/os_sgline.c | 4 | ||||
-rw-r--r-- | src/core/os_sqline.c | 4 | ||||
-rw-r--r-- | src/core/os_szline.c | 4 | ||||
-rw-r--r-- | src/core/os_userlist.c | 2 | ||||
-rw-r--r-- | src/language.c | 2 | ||||
-rw-r--r-- | src/misc.c | 28 | ||||
-rw-r--r-- | src/nickserv.c | 4 | ||||
-rw-r--r-- | src/operserv.c | 40 | ||||
-rw-r--r-- | src/process.c | 2 | ||||
-rw-r--r-- | src/sessions.c | 6 | ||||
-rw-r--r-- | src/users.c | 14 | ||||
-rw-r--r-- | src/wildcard.cpp | 162 |
29 files changed, 180 insertions, 152 deletions
diff --git a/src/actions.c b/src/actions.c index f83b67160..6b96c66fa 100644 --- a/src/actions.c +++ b/src/actions.c @@ -95,7 +95,7 @@ void sqline(char *mask, char *reason) for (c = chanlist[i]; c; c = next) { next = c->next; - if (!Anope::Match(mask, c->name, false)) { + if (!match_wild_nocase(mask, c->name)) { continue; } for (cu = c->users; cu; cu = cunext) { diff --git a/src/channels.c b/src/channels.c index 06eacb612..d7e97d62f 100644 --- a/src/channels.c +++ b/src/channels.c @@ -2154,13 +2154,13 @@ int entry_match(Entry * e, const char *nick, const char *user, const char *host, && (!user || stricmp(e->host, host) != 0)) return 0; if ((e->type & ENTRYTYPE_NICK_WILD) - && !Anope::Match(e->nick, nick, false)) + && !match_wild_nocase(e->nick, nick)) return 0; if ((e->type & ENTRYTYPE_USER_WILD) - && !Anope::Match(e->user, user, false)) + && !match_wild_nocase(e->user, user)) return 0; if ((e->type & ENTRYTYPE_HOST_WILD) - && !Anope::Match(e->host, host, false)) + && !match_wild_nocase(e->host, host)) return 0; return 1; diff --git a/src/chanserv.c b/src/chanserv.c index 26823a710..393a5831b 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -2202,11 +2202,11 @@ AutoKick *is_stuck(ChannelInfo * ci, const char *mask) || !(akick->flags & AK_STUCK)) continue; /* Example: mask = *!*@*.org and akick->u.mask = *!*@*.anope.org */ - if (Anope::Match(mask, akick->u.mask, false)) + if (match_wild_nocase(mask, akick->u.mask)) return akick; if (ircd->reversekickcheck) { /* Example: mask = *!*@irc.anope.org and akick->u.mask = *!*@*.anope.org */ - if (Anope::Match(akick->u.mask, mask, false)) + if (match_wild_nocase(akick->u.mask, mask)) return akick; } } @@ -2240,7 +2240,7 @@ void stick_mask(ChannelInfo * ci, AutoKick * akick) if (ircd->reversekickcheck) { /* If akick is wider than a ban already in place. Example: c->bans[i] = *!*@irc.epona.org and akick->u.mask = *!*@*.epona.org */ - if (Anope::Match(akick->u.mask, ban->mask, false)) + if (match_wild_nocase(akick->u.mask, ban->mask)) return; } } diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c index a342e0c09..1b7007745 100644 --- a/src/core/bs_badwords.c +++ b/src/core/bs_badwords.c @@ -44,7 +44,7 @@ class CommandBSBadwords : public Command if (!(ci->badwords[i].in_use)) continue; if (word && ci->badwords[i].word - && !Anope::Match(word, ci->badwords[i].word, false)) + && !match_wild_nocase(word, ci->badwords[i].word)) continue; badwords_list(u, i, ci, &sent_header); } diff --git a/src/core/cs_access.c b/src/core/cs_access.c index 0d3bc9ea0..ec58b75ea 100644 --- a/src/core/cs_access.c +++ b/src/core/cs_access.c @@ -335,7 +335,7 @@ class CommandCSAccess : public Command } else { for (i = 0; i < ci->accesscount; i++) { if (nick && ci->access[i].nc - && !Anope::Match(nick, ci->access[i].nc->display, false)) + && !match_wild_nocase(nick, ci->access[i].nc->display)) continue; access_list(u, i, ci, &sent_header); } diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c index 0f360f009..a0efdc067 100644 --- a/src/core/cs_akick.c +++ b/src/core/cs_akick.c @@ -264,7 +264,7 @@ class CommandCSAKick : public Command if (na2->nc && ((na2->nc == ci->founder) || (get_access_nc(na2->nc, ci) >= get_access(u, ci)))) { snprintf(buf, BUFSIZE, "%s!%s", na2->nick, na2->last_usermask); - if (Anope::Match(mask, buf, false)) { + if (match_wild_nocase(mask, buf)) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); delete [] mask; return MOD_CONT; @@ -536,10 +536,10 @@ class CommandCSAKick : public Command continue; if (mask) { if (!(akick->flags & AK_ISNICK) - && !Anope::Match(mask, akick->u.mask, false)) + && !match_wild_nocase(mask, akick->u.mask)) continue; if ((akick->flags & AK_ISNICK) - && !Anope::Match(mask, akick->u.nc->display, false)) + && !match_wild_nocase(mask, akick->u.nc->display)) continue; } akick_list(u, i, ci, &sent_header); @@ -565,10 +565,10 @@ class CommandCSAKick : public Command continue; if (mask) { if (!(akick->flags & AK_ISNICK) - && !Anope::Match(mask, akick->u.mask, false)) + && !match_wild_nocase(mask, akick->u.mask)) continue; if ((akick->flags & AK_ISNICK) - && !Anope::Match(mask, akick->u.nc->display, false)) + && !match_wild_nocase(mask, akick->u.nc->display)) continue; } akick_view(u, i, ci, &sent_header); diff --git a/src/core/cs_list.c b/src/core/cs_list.c index bb3244cc2..f4ccc843a 100644 --- a/src/core/cs_list.c +++ b/src/core/cs_list.c @@ -136,8 +136,8 @@ public: if ((stricmp(pattern, ci->name) == 0) || (stricmp(spattern, ci->name) == 0) - || Anope::Match(pattern, ci->name, false) - || Anope::Match(spattern, ci->name, false)) + || match_wild_nocase(pattern, ci->name) + || match_wild_nocase(spattern, ci->name)) { if ((((count + 1 >= from) && (count + 1 <= to)) || ((from == 0) && (to == 0))) diff --git a/src/core/cs_xop.c b/src/core/cs_xop.c index 2fa830bd2..569ea3cdc 100644 --- a/src/core/cs_xop.c +++ b/src/core/cs_xop.c @@ -354,7 +354,7 @@ class XOPBase : public Command { for (int i = 0; i < ci->accesscount; ++i) { - if (nick && ci->access[i].nc && !Anope::Match(nick, ci->access[i].nc->display, false)) + if (nick && ci->access[i].nc && !match_wild_nocase(nick, ci->access[i].nc->display)) continue; xop_list(u, i, ci, &sent_header, level, messages[XOP_LIST_HEADER]); } diff --git a/src/core/hs_list.c b/src/core/hs_list.c index 3dfa52506..21ca61689 100644 --- a/src/core/hs_list.c +++ b/src/core/hs_list.c @@ -94,7 +94,7 @@ class CommandHSList : public Command { if (key) { - if ((Anope::Match(key, current->nick, false) || Anope::Match(key, current->vHost, false)) && display_counter < NSListMax) + if ((match_wild_nocase(key, current->nick) || match_wild_nocase(key, current->vHost)) && display_counter < NSListMax) { ++display_counter; tm = localtime(¤t->time); diff --git a/src/core/ns_access.c b/src/core/ns_access.c index f1a1749d1..e8e43b298 100644 --- a/src/core/ns_access.c +++ b/src/core/ns_access.c @@ -49,7 +49,7 @@ class CommandNSAccess : public Command notice_lang(s_NickServ, u, NICK_ACCESS_LIST_X, params[1].c_str()); for (access = nc->access, i = 0; i < nc->accesscount; ++access, ++i) { - if (mask && !Anope::Match(mask, *access, true)) + if (mask && !match_wild(mask, *access)) continue; u->SendMessage(s_NickServ, " %s", *access); } @@ -143,7 +143,7 @@ class CommandNSAccess : public Command notice_lang(s_NickServ, u, NICK_ACCESS_LIST); for (access = nc->access, i = 0; i < nc->accesscount; ++access, ++i) { - if (mask && !Anope::Match(mask, *access, true)) + if (mask && !match_wild(mask, *access)) continue; u->SendMessage(s_NickServ, " %s", *access); } diff --git a/src/core/ns_list.c b/src/core/ns_list.c index 7ab2639de..407d1bcd1 100644 --- a/src/core/ns_list.c +++ b/src/core/ns_list.c @@ -143,7 +143,7 @@ class CommandNSList : public Command * Instead we build a nice nick!user@host buffer to compare. * The output is then generated separately. -TheShadow */ snprintf(buf, sizeof(buf), "%s!%s", na->nick, na->last_usermask && !(na->status & NS_FORBIDDEN) ? na->last_usermask : "*@*"); - if (!stricmp(pattern, na->nick) || Anope::Match(pattern, buf, false)) + if (!stricmp(pattern, na->nick) || match_wild_nocase(pattern, buf)) { if (((count + 1 >= from && count + 1 <= to) || (!from && !to)) && ++nnicks <= NSListMax) { @@ -175,7 +175,7 @@ class CommandNSList : public Command for (nr = nrlists[i]; nr; nr = nr->next) { snprintf(buf, sizeof(buf), "%s!*@*", nr->nick); - if (!stricmp(pattern, nr->nick) || Anope::Match(pattern, buf, false)) + if (!stricmp(pattern, nr->nick) || match_wild_nocase(pattern, buf)) { if (++nnicks <= NSListMax) { diff --git a/src/core/os_admin.c b/src/core/os_admin.c index 9dc103b99..06391e498 100644 --- a/src/core/os_admin.c +++ b/src/core/os_admin.c @@ -180,7 +180,7 @@ class CommandOSAdmin : public Command int i; for (i = 0; i < servadmins.count; ++i) { - if (!stricmp(nick, (static_cast<NickCore *>(servadmins.list[i]))->display) || Anope::Match(nick, (static_cast<NickCore *>(servadmins.list[i]))->display, false)) + if (!stricmp(nick, (static_cast<NickCore *>(servadmins.list[i]))->display) || match_wild_nocase(nick, (static_cast<NickCore *>(servadmins.list[i]))->display)) admin_list(i + 1, static_cast<NickCore *>(servadmins.list[i]), u, &sent_header); } diff --git a/src/core/os_akill.c b/src/core/os_akill.c index 8f12e2ff0..7d5947db7 100644 --- a/src/core/os_akill.c +++ b/src/core/os_akill.c @@ -225,7 +225,7 @@ class CommandOSAKill : public Command for (i = 0; i < akills.count; ++i) { snprintf(amask, sizeof(amask), "%s@%s", (static_cast<Akill *>(akills.list[i]))->user, (static_cast<Akill *>(akills.list[i]))->host); - if (!stricmp(mask, amask) || Anope::Match(mask, amask, false)) + if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) akill_list(i + 1, static_cast<Akill *>(akills.list[i]), u, &sent_header); } @@ -268,7 +268,7 @@ class CommandOSAKill : public Command for (i = 0; i < akills.count; ++i) { snprintf(amask, sizeof(amask), "%s@%s", (static_cast<Akill *>(akills.list[i]))->user, (static_cast<Akill *>(akills.list[i]))->host); - if (!stricmp(mask, amask) || Anope::Match(mask, amask, false)) + if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) akill_view(i + 1, static_cast<Akill *>(akills.list[i]), u, &sent_header); } diff --git a/src/core/os_chanlist.c b/src/core/os_chanlist.c index abb5deecd..d86beaeed 100644 --- a/src/core/os_chanlist.c +++ b/src/core/os_chanlist.c @@ -59,7 +59,7 @@ class CommandOSChanList : public Command { for (c = chanlist[i]; c; c = c->next) { - if (pattern && !Anope::Match(pattern, c->name, false)) + if (pattern && !match_wild_nocase(pattern, c->name)) continue; if (modes && !(c->mode & modes)) continue; diff --git a/src/core/os_noop.c b/src/core/os_noop.c index de49185f1..cf1bdf23e 100644 --- a/src/core/os_noop.c +++ b/src/core/os_noop.c @@ -47,7 +47,7 @@ class CommandOSNOOP : public Command for (u2 = firstuser(); u2; u2 = u3) { u3 = nextuser(); - if (u2 && is_oper(u2) && u2->server->name && Anope::Match(server, u2->server->name, true)) + if (u2 && is_oper(u2) && u2->server->name && match_wild(server, u2->server->name)) kill_user(s_OperServ, u2->nick, reason); } } diff --git a/src/core/os_oper.c b/src/core/os_oper.c index ce2ab8158..7ddceb257 100644 --- a/src/core/os_oper.c +++ b/src/core/os_oper.c @@ -187,7 +187,7 @@ class CommandOSOper : public Command for (i = 0; i < servopers.count; ++i) { - if (!stricmp(nick, (static_cast<NickCore *>(servopers.list[i]))->display) || Anope::Match(nick, (static_cast<NickCore *>(servopers.list[i]))->display, false)) + if (!stricmp(nick, (static_cast<NickCore *>(servopers.list[i]))->display) || match_wild_nocase(nick, (static_cast<NickCore *>(servopers.list[i]))->display)) oper_list(i + 1, static_cast<NickCore *>(servopers.list[i]), u, &sent_header); } diff --git a/src/core/os_session.c b/src/core/os_session.c index ac6910c36..a1c19113e 100644 --- a/src/core/os_session.c +++ b/src/core/os_session.c @@ -382,7 +382,7 @@ class CommandOSException : public Command { for (i = 0; i < nexceptions; ++i) { - if (!mask || Anope::Match(mask, exceptions[i].mask, false)) + if (!mask || match_wild_nocase(mask, exceptions[i].mask)) exception_list(u, i, &sent_header); } } @@ -404,7 +404,7 @@ class CommandOSException : public Command { for (i = 0; i < nexceptions; ++i) { - if (!mask || Anope::Match(mask, exceptions[i].mask, false)) + if (!mask || match_wild_nocase(mask, exceptions[i].mask)) exception_view(u, i, &sent_header); } } diff --git a/src/core/os_sgline.c b/src/core/os_sgline.c index e75b256a4..9bea10147 100644 --- a/src/core/os_sgline.c +++ b/src/core/os_sgline.c @@ -222,7 +222,7 @@ class CommandOSSGLine : public Command for (i = 0; i < sglines.count; ++i) { amask = (static_cast<SXLine *>(sglines.list[i]))->mask; - if (!stricmp(mask, amask) || Anope::Match(mask, amask, false)) + if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) sgline_list(i + 1, static_cast<SXLine *>(sglines.list[i]), u, &sent_header); } @@ -265,7 +265,7 @@ class CommandOSSGLine : public Command for (i = 0; i < sglines.count; ++i) { amask = (static_cast<SXLine *>(sglines.list[i]))->mask; - if (!stricmp(mask, amask) || Anope::Match(mask, amask, false)) + if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) sgline_view(i + 1, static_cast<SXLine *>(sglines.list[i]), u, &sent_header); } diff --git a/src/core/os_sqline.c b/src/core/os_sqline.c index 1f06c3174..a1603008e 100644 --- a/src/core/os_sqline.c +++ b/src/core/os_sqline.c @@ -209,7 +209,7 @@ class CommandOSSQLine : public Command for (i = 0; i < sqlines.count; ++i) { amask = (static_cast<SXLine *>(sqlines.list[i]))->mask; - if (!stricmp(mask, amask) || Anope::Match(mask, amask, false)) + if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) sqline_list(i + 1, static_cast<SXLine *>(sqlines.list[i]), u, &sent_header); } @@ -252,7 +252,7 @@ class CommandOSSQLine : public Command for (i = 0; i < sqlines.count; ++i) { amask = (static_cast<SXLine *>(sqlines.list[i]))->mask; - if (!stricmp(mask, amask) || Anope::Match(mask, amask, false)) + if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) sqline_view(i + 1, static_cast<SXLine *>(sqlines.list[i]), u, &sent_header); } diff --git a/src/core/os_szline.c b/src/core/os_szline.c index 9ca16a127..406db111f 100644 --- a/src/core/os_szline.c +++ b/src/core/os_szline.c @@ -210,7 +210,7 @@ class CommandOSSZLine : public Command for (i = 0; i < szlines.count; ++i) { amask = (static_cast<SXLine *>(szlines.list[i]))->mask; - if (!stricmp(mask, amask) || Anope::Match(mask, amask, false)) + if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) szline_list(i + 1, static_cast<SXLine *>(szlines.list[i]), u, &sent_header); } @@ -251,7 +251,7 @@ class CommandOSSZLine : public Command for (i = 0; i < szlines.count; ++i) { amask = (static_cast<SXLine *>(szlines.list[i]))->mask; - if (!stricmp(mask, amask) || Anope::Match(mask, amask, false)) + if (!stricmp(mask, amask) || match_wild_nocase(mask, amask)) szline_view(i + 1, static_cast<SXLine *>(szlines.list[i]), u, &sent_header); } diff --git a/src/core/os_userlist.c b/src/core/os_userlist.c index 5d6bb2504..7d85e641c 100644 --- a/src/core/os_userlist.c +++ b/src/core/os_userlist.c @@ -63,7 +63,7 @@ class CommandOSUserList : public Command if (pattern) { snprintf(mask, sizeof(mask), "%s!%s@%s", u2->nick, u2->GetIdent().c_str(), u2->GetDisplayedHost().c_str()); - if (!Anope::Match(pattern, mask, false)) + if (!match_wild_nocase(pattern, mask)) continue; if (modes && !(u2->mode & modes)) continue; diff --git a/src/language.c b/src/language.c index 85d50fa77..13df53807 100644 --- a/src/language.c +++ b/src/language.c @@ -130,7 +130,7 @@ static void load_lang(int index, const char *filename) } else { langtexts[index][i] = new char[len + 1]; fseek(f, pos, SEEK_SET); - if ((int32)fread(langtexts[index][i], 1, len, f) != len) { + if (fread(langtexts[index][i], 1, len, f) != len) { alog("Failed to read string %d in language %d (%s)", i, index, filename); while (--i >= 0) { diff --git a/src/misc.c b/src/misc.c index f5b95c4f6..51c6dac3e 100644 --- a/src/misc.c +++ b/src/misc.c @@ -211,6 +211,34 @@ const char *merge_args(int argc, char **argv) /*************************************************************************/ /** + * match_wild: Case Senstive wild card search + * @param pattern To be matched + * @param str String in which the pattern is to be matched + * @return 1 if the string matches the pattern, 0 if not. + * NOTE: Deprecated by Anope::Match(). + */ +int match_wild(const char *pattern, const char *str) +{ + return Anope::Match(pattern, str, true); +} + +/*************************************************************************/ + +/** + * match_wild: Case Insenstive wild card search + * @param pattern To be matched + * @param str String in which the pattern is to be matched + * @return 1 if the string matches the pattern, 0 if not. + * NOTE: Deprecated by Anope::Match(). + */ +int match_wild_nocase(const char *pattern, const char *str) +{ + return Anope::Match(pattern, str, false); +} + +/*************************************************************************/ + +/** * Process a string containing a number/range list in the form * "n1[-n2][,n3[-n4]]...", calling a caller-specified routine for each * number in the list. If the callback returns -1, stop immediately. diff --git a/src/nickserv.c b/src/nickserv.c index fda5623d5..92a91a6b3 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -864,8 +864,8 @@ int is_on_access(User * u, NickCore * nc) for (i = 0; i < nc->accesscount; i++) { - if (Anope::Match(nc->access[i], buf, false) - || (ircd->vhost ? Anope::Match(nc->access[i], buf2, false) : 0)) + if (match_wild_nocase(nc->access[i], buf) + || (ircd->vhost ? match_wild_nocase(nc->access[i], buf2) : 0)) { delete [] buf; if (ircd->vhost) diff --git a/src/operserv.c b/src/operserv.c index c43d0c9ff..b0e0d0f0c 100644 --- a/src/operserv.c +++ b/src/operserv.c @@ -542,7 +542,7 @@ int add_akill(User * u, const char *mask, const char *by, const time_t expires, } } - if (Anope::Match(amask, mask,false) + if (match_wild_nocase(amask, mask) && (entry->expires >= expires || entry->expires == 0)) { if (u) notice_lang(s_OperServ, u, OPER_AKILL_ALREADY_COVERED, @@ -550,7 +550,7 @@ int add_akill(User * u, const char *mask, const char *by, const time_t expires, return -1; } - if (Anope::Match(mask, amask, false) + if (match_wild_nocase(mask, amask) && (entry->expires <= expires || expires == 0)) { slist_delete(&akills, i); deleted++; @@ -628,16 +628,16 @@ int check_akill(const char *nick, const char *username, const char *host, ak = static_cast<Akill *>(akills.list[i]); if (!ak) continue; - if (Anope::Match(ak->user, username, false) - && Anope::Match(ak->host, host, false)) { + if (match_wild_nocase(ak->user, username) + && match_wild_nocase(ak->host, host)) { ircdproto->SendAkill(ak->user, ak->host, ak->by, ak->seton, ak->expires, ak->reason); return 1; } if (ircd->vhost) { if (vhost) { - if (Anope::Match(ak->user, username, false) - && Anope::Match(ak->host, vhost, false)) { + if (match_wild_nocase(ak->user, username) + && match_wild_nocase(ak->host, vhost)) { ircdproto->SendAkill(ak->user, ak->host, ak->by, ak->seton, ak->expires, ak->reason); return 1; @@ -646,8 +646,8 @@ int check_akill(const char *nick, const char *username, const char *host, } if (ircd->nickip) { if (ip) { - if (Anope::Match(ak->user, username, false) - && Anope::Match(ak->host, ip, false)) { + if (match_wild_nocase(ak->user, username) + && match_wild_nocase(ak->host, ip)) { ircdproto->SendAkill(ak->user, ak->host, ak->by, ak->seton, ak->expires, ak->reason); return 1; @@ -766,7 +766,7 @@ int add_sgline(User * u, const char *mask, const char *by, time_t expires, } } - if (Anope::Match(entry->mask, mask, false) + if (match_wild_nocase(entry->mask, mask) && (entry->expires >= expires || entry->expires == 0)) { if (u) notice_lang(s_OperServ, u, OPER_SGLINE_ALREADY_COVERED, @@ -774,7 +774,7 @@ int add_sgline(User * u, const char *mask, const char *by, time_t expires, return -1; } - if (Anope::Match(mask, entry->mask, false) + if (match_wild_nocase(mask, entry->mask) && (entry->expires <= expires || expires == 0)) { slist_delete(&sglines, i); deleted++; @@ -812,7 +812,7 @@ int add_sgline(User * u, const char *mask, const char *by, time_t expires, while (u2) { next = nextuser(); if (!is_oper(u2)) { - if (Anope::Match(entry->mask, u2->realname, false)) { + if (match_wild_nocase(entry->mask, u2->realname)) { kill_user(ServerName, u2->nick, buf); } } @@ -837,7 +837,7 @@ int check_sgline(const char *nick, const char *realname) if (!sx) continue; - if (Anope::Match(sx->mask, realname, false)) { + if (match_wild_nocase(sx->mask, realname)) { ircdproto->SendSGLine(sx->mask, sx->reason); /* We kill nick since s_sgline can't */ ircdproto->SendSVSKill(ServerName, nick, "G-Lined: %s", sx->reason); @@ -953,7 +953,7 @@ int add_sqline(User * u, const char *mask, const char *by, time_t expires, } } - if (Anope::Match(entry->mask, mask, false) + if (match_wild_nocase(entry->mask, mask) && (entry->expires >= expires || entry->expires == 0)) { if (u) notice_lang(s_OperServ, u, OPER_SQLINE_ALREADY_COVERED, @@ -961,7 +961,7 @@ int add_sqline(User * u, const char *mask, const char *by, time_t expires, return -1; } - if (Anope::Match(mask, entry->mask, false) + if (match_wild_nocase(mask, entry->mask) && (entry->expires <= expires || expires == 0)) { slist_delete(&sqlines, i); deleted++; @@ -999,7 +999,7 @@ int add_sqline(User * u, const char *mask, const char *by, time_t expires, while (u2) { next = nextuser(); if (!is_oper(u2)) { - if (Anope::Match(entry->mask, u2->nick, false)) { + if (match_wild_nocase(entry->mask, u2->nick)) { kill_user(ServerName, u2->nick, buf); } } @@ -1031,7 +1031,7 @@ int check_sqline(const char *nick, int nick_change) continue; } - if (Anope::Match(sx->mask, nick, false)) { + if (match_wild_nocase(sx->mask, nick)) { sqline(sx->mask, sx->reason); /* We kill nick since s_sqline can't */ snprintf(reason, sizeof(reason), "Q-Lined: %s", sx->reason); @@ -1059,7 +1059,7 @@ int check_chan_sqline(const char *chan) if (*sx->mask != '#') continue; - if (Anope::Match(sx->mask, chan, false)) { + if (match_wild_nocase(sx->mask, chan)) { sqline(sx->mask, sx->reason); return 1; } @@ -1167,14 +1167,14 @@ int add_szline(User * u, const char *mask, const char *by, time_t expires, } } - if (Anope::Match(entry->mask, mask, false)) { + if (match_wild_nocase(entry->mask, mask)) { if (u) notice_lang(s_OperServ, u, OPER_SZLINE_ALREADY_COVERED, mask, entry->mask); return -1; } - if (Anope::Match(mask, entry->mask, false)) { + if (match_wild_nocase(mask, entry->mask)) { slist_delete(&szlines, i); deleted++; } @@ -1227,7 +1227,7 @@ int check_szline(const char *nick, char *ip) continue; } - if (Anope::Match(sx->mask, ip, false)) { + if (match_wild_nocase(sx->mask, ip)) { ircdproto->SendSZLine(sx->mask, sx->reason, sx->by); return 1; } diff --git a/src/process.c b/src/process.c index 283f02903..0590513e8 100644 --- a/src/process.c +++ b/src/process.c @@ -135,7 +135,7 @@ IgnoreData *get_ignore(const char *nick) } else snprintf(tmp, sizeof(tmp), "%s!*@*", nick); for (ign = ignore; ign; ign = ign->next) - if (Anope::Match(ign->mask, tmp, false)) + if (match_wild_nocase(ign->mask, tmp)) break; } /* Check whether the entry has timed out */ diff --git a/src/sessions.c b/src/sessions.c index b743ece60..ea225d888 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -280,7 +280,7 @@ Exception *find_host_exception(const char *host) int i; for (i = 0; i < nexceptions; i++) { - if ((Anope::Match(exceptions[i].mask, host, false))) { + if ((match_wild_nocase(exceptions[i].mask, host))) { return &exceptions[i]; } } @@ -295,9 +295,9 @@ Exception *find_hostip_exception(const char *host, const char *hostip) int i; for (i = 0; i < nexceptions; i++) { - if ((Anope::Match(exceptions[i].mask, host, false)) + if ((match_wild_nocase(exceptions[i].mask, host)) || ((ircd->nickip && hostip) - && (Anope::Match(exceptions[i].mask, hostip, false)))) { + && (match_wild_nocase(exceptions[i].mask, hostip)))) { return &exceptions[i]; } } diff --git a/src/users.c b/src/users.c index 3c66fedaf..4be186909 100644 --- a/src/users.c +++ b/src/users.c @@ -928,14 +928,14 @@ int match_usermask(const char *mask, User * user) } if (nick) { - result = Anope::Match(nick, user->nick, false) - && Anope::Match(username, user->GetIdent().c_str(), false) - && (Anope::Match(host, user->host, false) - || Anope::Match(host, user->vhost, false)); + result = match_wild_nocase(nick, user->nick) + && match_wild_nocase(username, user->GetIdent().c_str()) + && (match_wild_nocase(host, user->host) + || match_wild_nocase(host, user->vhost)); } else { - result = Anope::Match(username, user->GetIdent().c_str(), false) - && (Anope::Match(host, user->host, false) - || Anope::Match(host, user->vhost, false)); + result = match_wild_nocase(username, user->GetIdent().c_str()) + && (match_wild_nocase(host, user->host) + || match_wild_nocase(host, user->vhost)); } delete [] mask2; diff --git a/src/wildcard.cpp b/src/wildcard.cpp index b66b8b29c..65916d038 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -1,81 +1,81 @@ -#include "services.h" - -static bool match_internal(const unsigned char *str, const unsigned char *mask, bool case_sensitive) -{ - unsigned char *cp = NULL, *mp = NULL; - unsigned char* string = (unsigned char*)str; - unsigned char* wild = (unsigned char*)mask; - - while ((*string) && (*wild != '*')) - { - if (case_sensitive) - { - if (*wild != *string && *wild != '?') - return false; - } - else - { - if (tolower(*wild) != tolower(*string) && *wild != '?') - return false; - } - - wild++; - string++; - } - - while (*string) - { - if (*wild == '*') - { - if (!*++wild) - { - return 1; - } - - mp = wild; - cp = string+1; - } - else - { - if (case_sensitive) - { - if (*wild == *string || *wild == '?') - { - wild++; - string++; - } - else - { - wild = mp; - string = cp++; - } - } - else - { - if (tolower(*wild) == tolower(*string) || *wild == '?') - { - wild++; - string++; - } - else - { - wild = mp; - string = cp++; - } - } - } - - } - - while (*wild == '*') - { - wild++; - } - - return !*wild; -} - -CoreExport bool Anope::Match(const std::string &str, const std::string &mask, bool case_sensitive) -{ - return match_internal((const unsigned char *)str.c_str(), (const unsigned char *)mask.c_str(), case_sensitive); -} +#include "services.h"
+
+static bool match_internal(const unsigned char *str, const unsigned char *mask, bool case_sensitive)
+{
+ unsigned char *cp = NULL, *mp = NULL;
+ unsigned char* string = (unsigned char*)str;
+ unsigned char* wild = (unsigned char*)mask;
+
+ while ((*string) && (*wild != '*'))
+ {
+ if (case_sensitive)
+ {
+ if (*wild != *string && *wild != '?')
+ return false;
+ }
+ else
+ {
+ if (tolower(*wild) != tolower(*string) && *wild != '?')
+ return false;
+ }
+
+ wild++;
+ string++;
+ }
+
+ while (*string)
+ {
+ if (*wild == '*')
+ {
+ if (!*++wild)
+ {
+ return 1;
+ }
+
+ mp = wild;
+ cp = string+1;
+ }
+ else
+ {
+ if (case_sensitive)
+ {
+ if (*wild == *string || *wild == '?')
+ {
+ wild++;
+ string++;
+ }
+ else
+ {
+ wild = mp;
+ string = cp++;
+ }
+ }
+ else
+ {
+ if (tolower(*wild) == tolower(*string) || *wild == '?')
+ {
+ wild++;
+ string++;
+ }
+ else
+ {
+ wild = mp;
+ string = cp++;
+ }
+ }
+ }
+
+ }
+
+ while (*wild == '*')
+ {
+ wild++;
+ }
+
+ return !*wild;
+}
+
+CoreExport bool Anope::Match(const std::string &str, const std::string &mask, bool case_sensitive)
+{
+ return match_internal((const unsigned char *)str.c_str(), (const unsigned char *)mask.c_str(), case_sensitive);
+}
|