From a1a7b96a8c994eb09a3d071f3daf28252b8c188b Mon Sep 17 00:00:00 2001
From: w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Date: Fri, 22 Aug 2008 16:14:36 +0000
Subject: Match conversion stuff.

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10216 e03df62e-2008-0410-955e-edbf42e46eb7
---
 include/inspircd.h                              | 13 +++++++------
 include/u_listmode.h                            |  4 +---
 src/modules/extra/m_ssl_oper_cert.cpp           |  3 +--
 src/modules/extra/m_sslinfo.cpp                 |  1 -
 src/modules/m_alias.cpp                         | 12 +++++++++---
 src/modules/m_banexception.cpp                  |  9 ++++-----
 src/modules/m_banredirect.cpp                   |  2 +-
 src/modules/m_cgiirc.cpp                        |  4 ++--
 src/modules/m_check.cpp                         |  5 ++---
 src/modules/m_cloaking.cpp                      |  3 +--
 src/modules/m_clones.cpp                        |  1 -
 src/modules/m_conn_umodes.cpp                   |  3 +--
 src/modules/m_customtitle.cpp                   |  3 +--
 src/modules/m_dccallow.cpp                      |  6 +++---
 src/modules/m_denychans.cpp                     |  9 ++++-----
 src/modules/m_filter.cpp                        |  2 +-
 src/modules/m_globalload.cpp                    |  6 +++---
 src/modules/m_hostchange.cpp                    |  3 +--
 src/modules/m_httpd_acl.cpp                     |  7 +++----
 src/modules/m_inviteexception.cpp               |  4 ++--
 src/modules/m_override.cpp                      |  1 -
 src/modules/m_safelist.cpp                      |  5 ++---
 src/modules/m_securelist.cpp                    |  2 +-
 src/modules/m_shun.cpp                          |  2 +-
 src/modules/m_silence.cpp                       |  3 +--
 src/modules/m_spanningtree/admin.cpp            |  2 +-
 src/modules/m_spanningtree/cachetimer.cpp       |  1 -
 src/modules/m_spanningtree/encap.cpp            |  2 +-
 src/modules/m_spanningtree/handshaketimer.cpp   |  1 -
 src/modules/m_spanningtree/hmac.cpp             |  1 -
 src/modules/m_spanningtree/main.cpp             |  3 +--
 src/modules/m_spanningtree/modules.cpp          |  2 +-
 src/modules/m_spanningtree/motd.cpp             |  2 +-
 src/modules/m_spanningtree/override_admin.cpp   |  3 +--
 src/modules/m_spanningtree/override_map.cpp     |  1 -
 src/modules/m_spanningtree/override_modules.cpp |  3 +--
 src/modules/m_spanningtree/override_motd.cpp    |  3 +--
 src/modules/m_spanningtree/override_squit.cpp   |  1 -
 src/modules/m_spanningtree/override_stats.cpp   |  3 +--
 src/modules/m_spanningtree/override_time.cpp    |  1 -
 src/modules/m_spanningtree/override_whois.cpp   |  1 -
 src/modules/m_spanningtree/ping.cpp             |  1 -
 src/modules/m_spanningtree/pong.cpp             |  1 -
 src/modules/m_spanningtree/postcommand.cpp      |  1 -
 src/modules/m_spanningtree/precommand.cpp       |  1 -
 src/modules/m_spanningtree/push.cpp             |  1 -
 src/modules/m_spanningtree/rconnect.cpp         |  3 +--
 src/modules/m_spanningtree/resolvers.cpp        |  1 -
 src/modules/m_spanningtree/resolvers.h          |  1 -
 src/modules/m_spanningtree/rsquit.cpp           |  1 -
 src/modules/m_spanningtree/server.cpp           |  1 -
 src/modules/m_spanningtree/stats.cpp            |  3 +--
 src/modules/m_spanningtree/svsjoin.cpp          |  1 -
 src/modules/m_spanningtree/svsnick.cpp          |  1 -
 src/modules/m_spanningtree/svspart.cpp          |  1 -
 src/modules/m_spanningtree/time.cpp             |  1 -
 src/modules/m_spanningtree/treeserver.cpp       |  1 -
 src/modules/m_spanningtree/treesocket.h         |  1 -
 src/modules/m_spanningtree/treesocket1.cpp      |  1 -
 src/modules/m_spanningtree/treesocket2.cpp      |  1 -
 src/modules/m_spanningtree/uid.cpp              |  1 -
 src/modules/m_spanningtree/utils.cpp            |  5 ++---
 src/modules/m_spanningtree/version.cpp          |  1 -
 src/modules/m_spanningtree/whois.cpp            |  1 -
 src/modules/m_spy.cpp                           |  1 -
 src/modules/m_tline.cpp                         |  5 ++---
 src/wildcard.cpp                                | 24 ++++++++----------------
 67 files changed, 75 insertions(+), 129 deletions(-)

diff --git a/include/inspircd.h b/include/inspircd.h
index 85800f4da..12e22794d 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -713,20 +713,21 @@ class CoreExport InspIRCd : public classbase
 	void SendMode(const std::vector<std::string>& parameters, User *user);
 
 	/** Match two strings using pattern matching, optionally, with a map
-	 * to check case against (may be NULL).
+	 * to check case against (may be NULL). If map is null, match will be case insensitive.
 	 * @param str The literal string to match against
 	 * @param mask The glob pattern to match against.
 	 */
-	static bool Match(const std::string &str, const std::string &mask, unsigned const char *map);
-	static bool Match(const  char *str, const char *mask, unsigned const char *map);
+	static bool Match(const std::string &str, const std::string &mask, unsigned const char *map = NULL);
+	static bool Match(const  char *str, const char *mask, unsigned const char *map = NULL);
 
 	/** Match two strings using pattern matching, optionally, with a map
-	 * to check case against (may be NULL). Supports CIDR patterns as well as globs.
+	 * to check case against (may be NULL). If map is null, match will be case insensitive.
+	 * Supports CIDR patterns as well as globs.
 	 * @param str The literal string to match against
 	 * @param mask The glob or CIDR pattern to match against.
 	 */
-	static bool MatchCIDR(const std::string &str, const std::string &mask, unsigned const char *map);
-	static bool MatchCIDR(const  char *str, const char *mask, unsigned const char *map);
+	static bool MatchCIDR(const std::string &str, const std::string &mask, unsigned const char *map = NULL);
+	static bool MatchCIDR(const  char *str, const char *mask, unsigned const char *map = NULL);
 
 	/** Call the handler for a given command.
 	 * @param commandname The command whos handler you wish to call
diff --git a/include/u_listmode.h b/include/u_listmode.h
index cad52fc12..f98faefd5 100644
--- a/include/u_listmode.h
+++ b/include/u_listmode.h
@@ -14,8 +14,6 @@
 #ifndef INSPIRCD_LISTMODE_PROVIDER
 #define INSPIRCD_LISTMODE_PROVIDER
 
-#include "wildcard.h"
-
 /** Get the time as a string
  */
 inline std::string stringtime()
@@ -284,7 +282,7 @@ class ListModeBase : public ModeHandler
 
 			for (limitlist::iterator it = chanlimits.begin(); it != chanlimits.end(); it++)
 			{
-				if (match(channel->name, it->mask))
+				if (InspIRCd::Match(channel->name, it->mask))
 				{
 					// We have a pattern matching the channel...
 					maxsize = el->size();
diff --git a/src/modules/extra/m_ssl_oper_cert.cpp b/src/modules/extra/m_ssl_oper_cert.cpp
index 817854fa8..794aabcd2 100644
--- a/src/modules/extra/m_ssl_oper_cert.cpp
+++ b/src/modules/extra/m_ssl_oper_cert.cpp
@@ -20,7 +20,6 @@
 #include "channels.h"
 #include "modules.h"
 #include "transport.h"
-#include "wildcard.h"
 
 /** Handle /FINGERPRINT
  */
@@ -104,7 +103,7 @@ class ModuleOperSSLCert : public Module
 		std::string xhost;
 		while (hl >> xhost)
 		{
-			if (match(host, xhost) || match(ip, xhost, true))
+			if (InspIRCd::Match(host, xhost) || InspIRCd::MatchCIDR(ip, xhost))
 			{
 				return true;
 			}
diff --git a/src/modules/extra/m_sslinfo.cpp b/src/modules/extra/m_sslinfo.cpp
index 82ac7c18e..5c4e50721 100644
--- a/src/modules/extra/m_sslinfo.cpp
+++ b/src/modules/extra/m_sslinfo.cpp
@@ -16,7 +16,6 @@
 #include "channels.h"
 #include "modules.h"
 #include "transport.h"
-#include "wildcard.h"
 #include "dns.h"
 
 /* $ModDesc: Provides /sslinfo command used to test who a mask matches */
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index 28190cec9..118c38287 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -12,7 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "wildcard.h"
 
 /* $ModDesc: Provides aliases of commands. */
 
@@ -157,8 +156,15 @@ class ModuleAlias : public Module
 				/* Does it match the pattern? */
 				if (!Aliases[i].format.empty())
 				{
-					if (!match(Aliases[i].case_sensitive, compare, Aliases[i].format))
-						continue;
+					if (Aliases[i].case_sensitive)
+					{
+						if (InspIRCd::Match(compare, Aliases[i].format))
+							continue;
+					}
+					else
+					{
+						throw "not implemented"; // XXX fixme
+					}
 				}
 
 				if ((Aliases[i].operonly) && (!IS_OPER(user)))
diff --git a/src/modules/m_banexception.cpp b/src/modules/m_banexception.cpp
index 6cd99c73e..7ad8a1fdd 100644
--- a/src/modules/m_banexception.cpp
+++ b/src/modules/m_banexception.cpp
@@ -13,7 +13,6 @@
 
 #include "inspircd.h"
 #include "u_listmode.h"
-#include "wildcard.h"
 
 /* $ModDesc: Provides support for the +e channel mode */
 /* $ModDep: ../../include/u_listmode.h */
@@ -78,7 +77,7 @@ public:
 
 				std::string maskptr = it->mask.substr(2);
 
-				if (match(user->GetFullRealHost(), maskptr) || match(user->GetFullHost(), maskptr) || (match(mask, maskptr, true)))
+				if (InspIRCd::Match(user->GetFullRealHost(), maskptr) || InspIRCd::Match(user->GetFullHost(), maskptr) || (InspIRCd::MatchCIDR(mask, maskptr)))
 				{
 					// They match an entry on the list, so let them pass this.
 					return 1;
@@ -104,7 +103,7 @@ public:
 					continue;
 
 				std::string maskptr = it->mask.substr(2);
-				if (match(str, maskptr))
+				if (InspIRCd::Match(str, maskptr))
 					return 1; // matches
 			}
 		}
@@ -128,7 +127,7 @@ public:
 			std::string mask = std::string(user->nick) + "!" + user->ident + "@" + user->GetIPString();
 			for (modelist::iterator it = list->begin(); it != list->end(); it++)
 			{
-				if (match(user->GetFullRealHost(), it->mask) || match(user->GetFullHost(), it->mask) || (match(mask, it->mask, true)))
+				if (InspIRCd::Match(user->GetFullRealHost(), it->mask) || InspIRCd::Match(user->GetFullHost(), it->mask) || (InspIRCd::MatchCIDR(mask, it->mask)))
 				{
 					// They match an entry on the list, so let them in.
 					return 1;
@@ -170,7 +169,7 @@ public:
 				std::string mask = std::string(LM->user->nick) + "!" + LM->user->ident + "@" + LM->user->GetIPString();
 				for (modelist::iterator it = list->begin(); it != list->end(); it++)
 				{
-					if (match(LM->user->GetFullRealHost(), it->mask) || match(LM->user->GetFullHost(), it->mask) || (match(mask, it->mask, true)))
+					if (InspIRCd::Match(LM->user->GetFullRealHost(), it->mask) || InspIRCd::Match(LM->user->GetFullHost(), it->mask) || (InspIRCd::MatchCIDR(mask, it->mask)))
 					{
 						// They match an entry
 						return (char*)it->mask.c_str();
diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp
index 80beaa450..92c25e0bd 100644
--- a/src/modules/m_banredirect.cpp
+++ b/src/modules/m_banredirect.cpp
@@ -294,7 +294,7 @@ class ModuleBanRedirect : public Module
 
 				for(BanRedirectList::iterator redir = redirects->begin(); redir != redirects->end(); redir++)
 				{
-					if(ServerInstance->MatchText(user->GetFullRealHost(), redir->banmask) || ServerInstance->MatchText(user->GetFullHost(), redir->banmask) || ServerInstance->MatchText(ipmask, redir->banmask))
+					if(InspIRCd::Match(user->GetFullRealHost(), redir->banmask) || InspIRCd::Match(user->GetFullHost(), redir->banmask) || InspIRCd::MatchCIDR(ipmask, redir->banmask))
 					{
 						/* tell them they're banned and are being transferred */
 						Channel* destchan = ServerInstance->FindChan(redir->targetchan);
diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp
index a9abb4b15..564702a16 100644
--- a/src/modules/m_cgiirc.cpp
+++ b/src/modules/m_cgiirc.cpp
@@ -68,7 +68,7 @@ class CommandWebirc : public Command
 
 			for(CGIHostlist::iterator iter = Hosts.begin(); iter != Hosts.end(); iter++)
 			{
-				if(ServerInstance->MatchText(user->host, iter->hostmask) || ServerInstance->MatchText(user->GetIPString(), iter->hostmask))
+				if(InspIRCd::Match(user->host, iter->hostmask) || InspIRCd::MatchCIDR(user->GetIPString(), iter->hostmask))
 				{
 					if(iter->type == WEBIRC && parameters[0] == iter->password)
 					{
@@ -262,7 +262,7 @@ public:
 	{
 		for(CGIHostlist::iterator iter = Hosts.begin(); iter != Hosts.end(); iter++)
 		{
-			if(ServerInstance->MatchText(user->host, iter->hostmask) || ServerInstance->MatchText(user->GetIPString(), iter->hostmask))
+			if(InspIRCd::Match(user->host, iter->hostmask) || InspIRCd::MatchCIDR(user->GetIPString(), iter->hostmask))
 			{
 				// Deal with it...
 				if(iter->type == PASS)
diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp
index ac9e8f2ac..4fd7da90a 100644
--- a/src/modules/m_check.cpp
+++ b/src/modules/m_check.cpp
@@ -12,7 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "wildcard.h"
 
 /* $ModDesc: Provides the /check command to retrieve information on a user, channel, or IP address */
 
@@ -131,13 +130,13 @@ class CommandCheck : public Command
 			/* hostname or other */
 			for (user_hash::const_iterator a = ServerInstance->Users->clientlist->begin(); a != ServerInstance->Users->clientlist->end(); a++)
 			{
-				if (match(a->second->host, parameters[0]) || match(a->second->dhost, parameters[0]))
+				if (InspIRCd::Match(a->second->host, parameters[0]) || InspIRCd::Match(a->second->dhost, parameters[0]))
 				{
 					/* host or vhost matches mask */
 					user->WriteServ(checkstr + " match " + ConvToStr(++x) + " " + a->second->GetFullRealHost());
 				}
 				/* IP address */
-				else if (match(a->second->GetIPString(), parameters[0], true))
+				else if (InspIRCd::MatchCIDR(a->second->GetIPString(), parameters[0]))
 				{
 					/* same IP. */
 					user->WriteServ(checkstr + " match " + ConvToStr(++x) + " " + a->second->GetFullRealHost());
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index 64ba71d95..f5b3d08da 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -12,7 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "wildcard.h"
 #include "m_hash.h"
 
 /* $ModDesc: Provides masking of user hostnames */
@@ -314,7 +313,7 @@ class ModuleCloaking : public Module
 			snprintf(mask, MAXBUF, "%s!%s@%s", user->nick.c_str(), user->ident.c_str(), tofree->c_str());
 			for (BanList::iterator i = chan->bans.begin(); i != chan->bans.end(); i++)
 			{
-				if (match(mask,i->data))
+				if (InspIRCd::Match(mask,i->data))
 					return -1;
 			}
 		}
diff --git a/src/modules/m_clones.cpp b/src/modules/m_clones.cpp
index 82bdf5550..097227d39 100644
--- a/src/modules/m_clones.cpp
+++ b/src/modules/m_clones.cpp
@@ -12,7 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "wildcard.h"
 
 /* $ModDesc: Provides the /clones command to retrieve information on clones. */
 
diff --git a/src/modules/m_conn_umodes.cpp b/src/modules/m_conn_umodes.cpp
index 2489f2a1f..097f8c8d6 100644
--- a/src/modules/m_conn_umodes.cpp
+++ b/src/modules/m_conn_umodes.cpp
@@ -12,7 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "wildcard.h"
 
 /* $ModDesc: Sets (and unsets) modes on users when they connect */
 
@@ -64,7 +63,7 @@ class ModuleModesOnConnect : public Module
 		{
 			std::string hostn = Conf->ReadValue("connect","allow",j);
 			/* XXX: Fixme: does not respect port, limit, etc */
-			if ((match(user->GetIPString(),hostn,true)) || (match(user->host,hostn)))
+			if ((InspIRCd::MatchCIDR(user->GetIPString(),hostn)) || (InspIRCd::Match(user->host,hostn)))
 			{
 				std::string ThisModes = Conf->ReadValue("connect","modes",j);
 				if (!ThisModes.empty())
diff --git a/src/modules/m_customtitle.cpp b/src/modules/m_customtitle.cpp
index 0023ab6dc..85f097237 100644
--- a/src/modules/m_customtitle.cpp
+++ b/src/modules/m_customtitle.cpp
@@ -12,7 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "wildcard.h"
 
 /* $ModDesc: Provides the TITLE command which allows setting of CUSTOM WHOIS TITLE line */
 
@@ -34,7 +33,7 @@ class CommandTitle : public Command
 		std::string xhost;
 		while (hl >> xhost)
 		{
-			if (match(host, xhost) || match(ip,xhost, true))
+			if (InspIRCd::Match(host, xhost) || InspIRCd::MatchCIDR(ip,xhost))
 			{
 				return true;
 			}
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp
index 76658f454..738567ff7 100644
--- a/src/modules/m_dccallow.cpp
+++ b/src/modules/m_dccallow.cpp
@@ -139,7 +139,7 @@ class CommandDccallow : public Command
 							user->WriteNumeric(996, "%s %s :%s is already on your DCCALLOW list", user->nick.c_str(), user->nick.c_str(), target->nick.c_str());
 							return CMD_FAILURE;
 						}
-						else if (ServerInstance->MatchText(user->GetFullHost(), k->hostmask))
+						else if (InspIRCd::Match(user->GetFullHost(), k->hostmask))
 						{
 							user->WriteNumeric(996, "%s %s :You cannot add yourself to your own DCCALLOW list!", user->nick.c_str(), user->nick.c_str());
 							return CMD_FAILURE;
@@ -312,7 +312,7 @@ class ModuleDCCAllow : public Module
 					if (u->GetExt("dccallow_list", dl) && dl->size())
 					{
 						for (dccallowlist::const_iterator iter = dl->begin(); iter != dl->end(); ++iter)
-							if (ServerInstance->MatchText(user->GetFullHost(), iter->hostmask))
+							if (InspIRCd::Match(user->GetFullHost(), iter->hostmask))
 								return 0;
 					}
 
@@ -338,7 +338,7 @@ class ModuleDCCAllow : public Module
 
 						for (unsigned int i = 0; i < bfl.size(); i++)
 						{
-							if (ServerInstance->MatchText(filename, bfl[i].filemask))
+							if (InspIRCd::Match(filename, bfl[i].filemask))
 							{
 								if (bfl[i].action == "allow")
 									return 0;
diff --git a/src/modules/m_denychans.cpp b/src/modules/m_denychans.cpp
index 2717d873a..45c9cbcd6 100644
--- a/src/modules/m_denychans.cpp
+++ b/src/modules/m_denychans.cpp
@@ -12,7 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "wildcard.h"
 
 /* $ModDesc: Implements config tags which allow blocking of joins to channels */
 
@@ -54,12 +53,12 @@ class ModuleDenyChannels : public Module
 
 				for (int j =0; j < Conf->Enumerate("badchan"); j++)
 				{
-					if (match(redirect, Conf->ReadValue("badchan","name",j)))
+					if (InspIRCd::Match(redirect, Conf->ReadValue("badchan","name",j)))
 					{
 						bool goodchan = false;
 						for (int k =0; k < Conf->Enumerate("goodchan"); k++)
 						{
-							if (match(redirect, Conf->ReadValue("goodchan","name",k)))
+							if (InspIRCd::Match(redirect, Conf->ReadValue("goodchan","name",k)))
 								goodchan = true;
 						}
 
@@ -91,7 +90,7 @@ class ModuleDenyChannels : public Module
 	{
 		for (int j =0; j < Conf->Enumerate("badchan"); j++)
 		{
-			if (match(cname, Conf->ReadValue("badchan","name",j)))
+			if (InspIRCd::Match(cname, Conf->ReadValue("badchan","name",j)))
 			{
 				if (IS_OPER(user) && Conf->ReadFlag("badchan","allowopers",j))
 				{
@@ -104,7 +103,7 @@ class ModuleDenyChannels : public Module
 
 					for (int i = 0; i < Conf->Enumerate("goodchan"); i++)
 					{
-						if (match(cname, Conf->ReadValue("goodchan", "name", i)))
+						if (InspIRCd::Match(cname, Conf->ReadValue("goodchan", "name", i)))
 						{
 							return 0;
 						}
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index 3609d0d10..480d9975a 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -45,7 +45,7 @@ class ModuleFilter : public FilterBase
 			if (!FilterBase::AppliesToMe(user, index->second, iflags))
 				continue;
 
-			if (ServerInstance->MatchText(text,index->first))
+			if (InspIRCd::Match(text,index->first))
 			{
 				FilterResult* fr = index->second;
 				if (index != filters.begin())
diff --git a/src/modules/m_globalload.cpp b/src/modules/m_globalload.cpp
index d24f23aa9..a900083e1 100644
--- a/src/modules/m_globalload.cpp
+++ b/src/modules/m_globalload.cpp
@@ -31,7 +31,7 @@ class CommandGloadmodule : public Command
 	{
 		std::string servername = parameters.size() > 1 ? parameters[1] : "*";
 
-		if (ServerInstance->MatchText(ServerInstance->Config->ServerName, servername))
+		if (InspIRCd::Match(ServerInstance->Config->ServerName, servername))
 		{
 			if (ServerInstance->Modules->Load(parameters[0].c_str()))
 			{
@@ -65,7 +65,7 @@ class CommandGunloadmodule : public Command
 	{
 		std::string servername = parameters.size() > 1 ? parameters[1] : "*";
 
-		if (ServerInstance->MatchText(ServerInstance->Config->ServerName, servername))
+		if (InspIRCd::Match(ServerInstance->Config->ServerName, servername))
 		{
 			if (ServerInstance->Modules->Unload(parameters[0].c_str()))
 			{
@@ -99,7 +99,7 @@ class CommandGreloadmodule : public Command
 	{
 		std::string servername = parameters.size() > 1 ? parameters[1] : "*";
 
-		if (ServerInstance->MatchText(ServerInstance->Config->ServerName, servername))
+		if (InspIRCd::Match(ServerInstance->Config->ServerName, servername))
 		{
 			if (!ServerInstance->Modules->Unload(parameters[0].c_str()))
 			{
diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp
index 95c40d65e..3d4dde887 100644
--- a/src/modules/m_hostchange.cpp
+++ b/src/modules/m_hostchange.cpp
@@ -12,7 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "wildcard.h"
 
 /* $ModDesc: Provides masking of user hostnames in a different way to m_cloaking */
 
@@ -97,7 +96,7 @@ class ModuleHostChange : public Module
 	{
 		for (hostchanges_t::iterator i = hostchanges.begin(); i != hostchanges.end(); i++)
 		{
-			if (((match(user->MakeHost(), i->first, true)) || (match(user->MakeHostIP(), i->first))))
+			if (((InspIRCd::MatchCIDR(user->MakeHost(), i->first)) || (InspIRCd::MatchCIDR(user->MakeHostIP(), i->first))))
 			{
 				Host* h = i->second;
 
diff --git a/src/modules/m_httpd_acl.cpp b/src/modules/m_httpd_acl.cpp
index 0aa462818..0258deba9 100644
--- a/src/modules/m_httpd_acl.cpp
+++ b/src/modules/m_httpd_acl.cpp
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "httpd.h"
 #include "protocol.h"
-#include "wildcard.h"
 
 /* $ModDesc: Provides access control lists (passwording of resources, ip restrictions etc) to m_httpd.so dependent modules */
 /* $ModDep: httpd.h */
@@ -173,7 +172,7 @@ class ModuleHTTPAccessList : public Module
 
 			for (std::vector<HTTPACL>::const_iterator this_acl = acl_list.begin(); this_acl != acl_list.end(); ++this_acl)
 			{
-				if (match(http->GetURI(), this_acl->path))
+				if (InspIRCd::Match(http->GetURI(), this_acl->path))
 				{
 					if (!this_acl->blacklist.empty())
 					{
@@ -183,7 +182,7 @@ class ModuleHTTPAccessList : public Module
 
 						while (sep.GetToken(entry))
 						{
-							if (match(http->GetIP(), entry))
+							if (InspIRCd::Match(http->GetIP(), entry))
 							{
 								ServerInstance->Logs->Log("m_httpd_acl", DEBUG, "Denying access to blacklisted resource %s (matched by pattern %s) from ip %s (matched by entry %s)",
 										http->GetURI().c_str(), this_acl->path.c_str(), http->GetIP().c_str(), entry.c_str());
@@ -201,7 +200,7 @@ class ModuleHTTPAccessList : public Module
 
 						while (sep.GetToken(entry))
 						{
-							if (match(http->GetIP(), entry))
+							if (InspIRCd::Match(http->GetIP(), entry))
 								allow_access = true;
 						}
 
diff --git a/src/modules/m_inviteexception.cpp b/src/modules/m_inviteexception.cpp
index 98b1ab55e..3ea1c83fc 100644
--- a/src/modules/m_inviteexception.cpp
+++ b/src/modules/m_inviteexception.cpp
@@ -69,7 +69,7 @@ public:
 				std::string mask = std::string(user->nick) + "!" + user->ident + "@" + user->GetIPString();
 				for (modelist::iterator it = list->begin(); it != list->end(); it++)
 				{
-					if(match(user->GetFullRealHost(), it->mask) || match(user->GetFullHost(), it->mask) || (match(mask, it->mask, true)))
+					if(InspIRCd::Match(user->GetFullRealHost(), it->mask) || InspIRCd::Match(user->GetFullHost(), it->mask) || (InspIRCd::MatchCIDR(mask, it->mask)))
 					{
 						// They match an entry on the list, so let them in.
 						return 1;
@@ -94,7 +94,7 @@ public:
 				std::string mask = std::string(LM->user->nick) + "!" + LM->user->ident + "@" + LM->user->GetIPString();
 				for (modelist::iterator it = list->begin(); it != list->end(); it++)
 				{
-					if (match(LM->user->GetFullRealHost(), it->mask) || match(LM->user->GetFullHost(), it->mask.c_str()) || (match(mask, it->mask, true)))
+					if (InspIRCd::Match(LM->user->GetFullRealHost(), it->mask) || InspIRCd::Match(LM->user->GetFullHost(), it->mask.c_str()) || (InspIRCd::MatchCIDR(mask, it->mask)))
 					{
 						// They match an entry
 						return (char*)it->mask.c_str();
diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp
index 8d01833d6..9e2cbd719 100644
--- a/src/modules/m_override.cpp
+++ b/src/modules/m_override.cpp
@@ -12,7 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "wildcard.h"
 
 /* $ModDesc: Provides support for unreal-style oper-override */
 
diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp
index f719b9e87..eb47e329e 100644
--- a/src/modules/m_safelist.cpp
+++ b/src/modules/m_safelist.cpp
@@ -12,7 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "wildcard.h"
 
 /** Holds a users m_safelist state
  */
@@ -185,7 +184,7 @@ class ModuleSafeList : public Module
 
 				if ((chan) && (chan->modes[CM_PRIVATE]) && (!IS_OPER(user)))
 				{
-					bool display = (match(chan->name, ld->glob) || (!chan->topic.empty() && match(chan->topic, ld->glob)));
+					bool display = (InspIRCd::Match(chan->name, ld->glob) || (!chan->topic.empty() && InspIRCd::Match(chan->topic, ld->glob)));
 					if ((users) && (display))
 					{
 						int counter = snprintf(buffer, MAXBUF, "322 %s * %ld :", user->nick.c_str(), users);
@@ -195,7 +194,7 @@ class ModuleSafeList : public Module
 				}
 				else if ((chan) && ((((!(chan->IsModeSet('p'))) && (!(chan->IsModeSet('s'))))) || (has_user) || IS_OPER(user)))
 				{
-					bool display = (match(chan->name, ld->glob) || (!chan->topic.empty() && match(chan->topic, ld->glob)));
+					bool display = (InspIRCd::Match(chan->name, ld->glob) || (!chan->topic.empty() && InspIRCd::Match(chan->topic, ld->glob)));
 					if ((users) && (display))
 					{
 						int counter = snprintf(buffer, MAXBUF, "322 %s %s %ld :[+%s] %s", user->nick.c_str(), chan->name.c_str(), users, chan->ChanModes(has_user || IS_OPER(user)), chan->topic.c_str());
diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp
index 0d04a13ae..d40904d61 100644
--- a/src/modules/m_securelist.cpp
+++ b/src/modules/m_securelist.cpp
@@ -64,7 +64,7 @@ class ModuleSecureList : public Module
 		{
 			/* Normally wouldnt be allowed here, are they exempt? */
 			for (std::vector<std::string>::iterator x = allowlist.begin(); x != allowlist.end(); x++)
-				if (ServerInstance->MatchText(user->MakeHost(), *x))
+				if (InspIRCd::Match(user->MakeHost(), *x))
 					return 0;
 
 			/* Not exempt, BOOK EM DANNO! */
diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp
index bdf990313..b4cdfac72 100644
--- a/src/modules/m_shun.cpp
+++ b/src/modules/m_shun.cpp
@@ -19,7 +19,7 @@ public:
 
 	bool Matches(User *u)
 	{
-		if (ServerInstance->MatchText(u->GetFullHost(), matchtext) || ServerInstance->MatchText(u->GetFullRealHost(), matchtext))
+		if (InspIRCd::Match(u->GetFullHost(), matchtext) || InspIRCd::Match(u->GetFullRealHost(), matchtext))
 			return true;
 
 		return false;
diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp
index cdd968212..eae8675a8 100644
--- a/src/modules/m_silence.cpp
+++ b/src/modules/m_silence.cpp
@@ -12,7 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "wildcard.h"
 
 /* $ModDesc: Provides support for the /SILENCE command */
 
@@ -391,7 +390,7 @@ class ModuleSilence : public Module
 		{
 			for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++)
 			{
-				if (((((c->second & pattern) > 0)) || ((c->second & SILENCE_ALL) > 0)) && (ServerInstance->MatchText(source->GetFullHost(), c->first)))
+				if (((((c->second & pattern) > 0)) || ((c->second & SILENCE_ALL) > 0)) && (InspIRCd::Match(source->GetFullHost(), c->first)))
 					return !(((c->second & SILENCE_EXCLUDE) > 0));
 			}
 		}
diff --git a/src/modules/m_spanningtree/admin.cpp b/src/modules/m_spanningtree/admin.cpp
index 0faff3d57..a034d7f52 100644
--- a/src/modules/m_spanningtree/admin.cpp
+++ b/src/modules/m_spanningtree/admin.cpp
@@ -25,7 +25,7 @@ bool TreeSocket::Admin(const std::string &prefix, std::deque<std::string> &param
 {
 	if (params.size() > 0)
 	{
-		if (this->Instance->MatchText(this->Instance->Config->ServerName, params[0]))
+		if (InspIRCd::Match(this->Instance->Config->ServerName, params[0]))
 		{
 			/* It's for our server */
 			string_list results;
diff --git a/src/modules/m_spanningtree/cachetimer.cpp b/src/modules/m_spanningtree/cachetimer.cpp
index 71214dcfa..97b9b3b4f 100644
--- a/src/modules/m_spanningtree/cachetimer.cpp
+++ b/src/modules/m_spanningtree/cachetimer.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
diff --git a/src/modules/m_spanningtree/encap.cpp b/src/modules/m_spanningtree/encap.cpp
index 9335c0c7f..02233e916 100644
--- a/src/modules/m_spanningtree/encap.cpp
+++ b/src/modules/m_spanningtree/encap.cpp
@@ -27,7 +27,7 @@ bool TreeSocket::Encap(const std::string &prefix, std::deque<std::string> &param
 {
 	if (params.size() > 1)
 	{
-		if (Instance->MatchText(Instance->Config->GetSID(), params[0]))
+		if (InspIRCd::Match(Instance->Config->GetSID(), params[0]))
 		{
 			Event event((char*) &params, (Module*)this->Utils->Creator, "encap_received");
 			event.Send(Instance);
diff --git a/src/modules/m_spanningtree/handshaketimer.cpp b/src/modules/m_spanningtree/handshaketimer.cpp
index c1e36df38..44938bafa 100644
--- a/src/modules/m_spanningtree/handshaketimer.cpp
+++ b/src/modules/m_spanningtree/handshaketimer.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
diff --git a/src/modules/m_spanningtree/hmac.cpp b/src/modules/m_spanningtree/hmac.cpp
index 7744ab217..418a64724 100644
--- a/src/modules/m_spanningtree/hmac.cpp
+++ b/src/modules/m_spanningtree/hmac.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "m_hash.h"
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 7085d501d..423400c3d 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -17,7 +17,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
@@ -402,7 +401,7 @@ int ModuleSpanningTree::HandleConnect(const std::vector<std::string>& parameters
 {
 	for (std::vector<Link>::iterator x = Utils->LinkBlocks.begin(); x < Utils->LinkBlocks.end(); x++)
 	{
-		if (ServerInstance->MatchText(x->Name.c_str(),parameters[0]))
+		if (InspIRCd::Match(x->Name.c_str(),parameters[0]))
 		{
 			TreeServer* CheckDupe = Utils->FindServer(x->Name.c_str());
 			if (!CheckDupe)
diff --git a/src/modules/m_spanningtree/modules.cpp b/src/modules/m_spanningtree/modules.cpp
index 17321c5fd..71cd93041 100644
--- a/src/modules/m_spanningtree/modules.cpp
+++ b/src/modules/m_spanningtree/modules.cpp
@@ -26,7 +26,7 @@ bool TreeSocket::Modules(const std::string &prefix, std::deque<std::string> &par
 	if (params.empty())
 		return true;
 
-	if (!this->Instance->MatchText(this->Instance->Config->ServerName, params[0]))
+	if (!InspIRCd::Match(this->Instance->Config->ServerName, params[0]))
 	{
 		/* Pass it on, not for us */
 		Utils->DoOneToOne(prefix, "MODULES", params, params[0]);
diff --git a/src/modules/m_spanningtree/motd.cpp b/src/modules/m_spanningtree/motd.cpp
index 517d4b48c..6ec09c5fd 100644
--- a/src/modules/m_spanningtree/motd.cpp
+++ b/src/modules/m_spanningtree/motd.cpp
@@ -27,7 +27,7 @@ bool TreeSocket::Motd(const std::string &prefix, std::deque<std::string> &params
 {
 	if (params.size() > 0)
 	{
-		if (this->Instance->MatchText(this->Instance->Config->ServerName, params[0]))
+		if (InspIRCd::Match(this->Instance->Config->ServerName, params[0]))
 		{
 			/* It's for our server */
 			string_list results;
diff --git a/src/modules/m_spanningtree/override_admin.cpp b/src/modules/m_spanningtree/override_admin.cpp
index 3a4aa2a1f..46d030c06 100644
--- a/src/modules/m_spanningtree/override_admin.cpp
+++ b/src/modules/m_spanningtree/override_admin.cpp
@@ -17,7 +17,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
@@ -32,7 +31,7 @@ int ModuleSpanningTree::HandleAdmin(const std::vector<std::string>& parameters,
 {
 	if (parameters.size() > 0)
 	{
-		if (match(ServerInstance->Config->ServerName, parameters[0]))
+		if (InspIRCd::Match(ServerInstance->Config->ServerName, parameters[0]))
 			return 0;
 
 		/* Remote ADMIN, the server is within the 1st parameter */
diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp
index 48050b7af..cccfad4dc 100644
--- a/src/modules/m_spanningtree/override_map.cpp
+++ b/src/modules/m_spanningtree/override_map.cpp
@@ -14,7 +14,6 @@
 /* $ModDesc: Provides a spanning tree server link protocol */
 
 #include "inspircd.h"
-#include "wildcard.h"
 
 #include "m_spanningtree/main.h"
 #include "m_spanningtree/utils.h"
diff --git a/src/modules/m_spanningtree/override_modules.cpp b/src/modules/m_spanningtree/override_modules.cpp
index 1d33d104e..b824612ff 100644
--- a/src/modules/m_spanningtree/override_modules.cpp
+++ b/src/modules/m_spanningtree/override_modules.cpp
@@ -17,7 +17,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
@@ -32,7 +31,7 @@ int ModuleSpanningTree::HandleModules(const std::vector<std::string>& parameters
 {
 	if (parameters.size() > 0)
 	{
-		if (match(ServerInstance->Config->ServerName, parameters[0]))
+		if (InspIRCd::Match(ServerInstance->Config->ServerName, parameters[0]))
 			return 0;
 
 		std::deque<std::string> params;
diff --git a/src/modules/m_spanningtree/override_motd.cpp b/src/modules/m_spanningtree/override_motd.cpp
index e689be1f7..0ed8417fa 100644
--- a/src/modules/m_spanningtree/override_motd.cpp
+++ b/src/modules/m_spanningtree/override_motd.cpp
@@ -17,7 +17,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
@@ -32,7 +31,7 @@ int ModuleSpanningTree::HandleMotd(const std::vector<std::string>& parameters, U
 {
 	if (parameters.size() > 0)
 	{
-		if (match(ServerInstance->Config->ServerName, parameters[0]))
+		if (InspIRCd::Match(ServerInstance->Config->ServerName, parameters[0]))
 			return 0;
 
 		/* Remote MOTD, the server is within the 1st parameter */
diff --git a/src/modules/m_spanningtree/override_squit.cpp b/src/modules/m_spanningtree/override_squit.cpp
index 812424c81..d73408a45 100644
--- a/src/modules/m_spanningtree/override_squit.cpp
+++ b/src/modules/m_spanningtree/override_squit.cpp
@@ -17,7 +17,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
diff --git a/src/modules/m_spanningtree/override_stats.cpp b/src/modules/m_spanningtree/override_stats.cpp
index d6ae89e4d..2b1b5660c 100644
--- a/src/modules/m_spanningtree/override_stats.cpp
+++ b/src/modules/m_spanningtree/override_stats.cpp
@@ -17,7 +17,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
@@ -33,7 +32,7 @@ int ModuleSpanningTree::HandleStats(const std::vector<std::string>& parameters,
 {
 	if (parameters.size() > 1)
 	{
-		if (match(ServerInstance->Config->ServerName, parameters[1]))
+		if (InspIRCd::Match(ServerInstance->Config->ServerName, parameters[1]))
 			return 0;
 
 		/* Remote STATS, the server is within the 2nd parameter */
diff --git a/src/modules/m_spanningtree/override_time.cpp b/src/modules/m_spanningtree/override_time.cpp
index 882607161..cb7850047 100644
--- a/src/modules/m_spanningtree/override_time.cpp
+++ b/src/modules/m_spanningtree/override_time.cpp
@@ -17,7 +17,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
diff --git a/src/modules/m_spanningtree/override_whois.cpp b/src/modules/m_spanningtree/override_whois.cpp
index d10298348..25af17620 100644
--- a/src/modules/m_spanningtree/override_whois.cpp
+++ b/src/modules/m_spanningtree/override_whois.cpp
@@ -17,7 +17,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
diff --git a/src/modules/m_spanningtree/ping.cpp b/src/modules/m_spanningtree/ping.cpp
index a4a188665..b884305b2 100644
--- a/src/modules/m_spanningtree/ping.cpp
+++ b/src/modules/m_spanningtree/ping.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "socketengine.h"
diff --git a/src/modules/m_spanningtree/pong.cpp b/src/modules/m_spanningtree/pong.cpp
index e9bed25b8..8e21f5a3e 100644
--- a/src/modules/m_spanningtree/pong.cpp
+++ b/src/modules/m_spanningtree/pong.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "socketengine.h"
diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp
index 37109a79d..fa65e742e 100644
--- a/src/modules/m_spanningtree/postcommand.cpp
+++ b/src/modules/m_spanningtree/postcommand.cpp
@@ -17,7 +17,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
diff --git a/src/modules/m_spanningtree/precommand.cpp b/src/modules/m_spanningtree/precommand.cpp
index beffba6e9..6a78e6c88 100644
--- a/src/modules/m_spanningtree/precommand.cpp
+++ b/src/modules/m_spanningtree/precommand.cpp
@@ -17,7 +17,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
diff --git a/src/modules/m_spanningtree/push.cpp b/src/modules/m_spanningtree/push.cpp
index 460cb71db..b2fc045f0 100644
--- a/src/modules/m_spanningtree/push.cpp
+++ b/src/modules/m_spanningtree/push.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "socketengine.h"
diff --git a/src/modules/m_spanningtree/rconnect.cpp b/src/modules/m_spanningtree/rconnect.cpp
index 3e514563d..7fbbf4d58 100644
--- a/src/modules/m_spanningtree/rconnect.cpp
+++ b/src/modules/m_spanningtree/rconnect.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
@@ -48,7 +47,7 @@ CmdResult cmd_rconnect::Handle (const std::vector<std::string>& parameters, User
 	}
 
 	/* Is this aimed at our server? */
-	if (ServerInstance->MatchText(ServerInstance->Config->ServerName,parameters[0]))
+	if (InspIRCd::Match(ServerInstance->Config->ServerName,parameters[0]))
 	{
 		/* Yes, initiate the given connect */
 		ServerInstance->SNO->WriteToSnoMask('l',"Remote CONNECT from %s matching \002%s\002, connecting server \002%s\002",user->nick.c_str(),parameters[0].c_str(),parameters[1].c_str());
diff --git a/src/modules/m_spanningtree/resolvers.cpp b/src/modules/m_spanningtree/resolvers.cpp
index 1673a02de..3ea6e2bdf 100644
--- a/src/modules/m_spanningtree/resolvers.cpp
+++ b/src/modules/m_spanningtree/resolvers.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
diff --git a/src/modules/m_spanningtree/resolvers.h b/src/modules/m_spanningtree/resolvers.h
index 54fd9c481..552815ac0 100644
--- a/src/modules/m_spanningtree/resolvers.h
+++ b/src/modules/m_spanningtree/resolvers.h
@@ -18,7 +18,6 @@
 #include "commands/cmd_stats.h"
 #include "socket.h"
 #include "inspircd.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
diff --git a/src/modules/m_spanningtree/rsquit.cpp b/src/modules/m_spanningtree/rsquit.cpp
index 1b798deb7..5407189b3 100644
--- a/src/modules/m_spanningtree/rsquit.cpp
+++ b/src/modules/m_spanningtree/rsquit.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp
index 40e12b03a..0ff0e30f6 100644
--- a/src/modules/m_spanningtree/server.cpp
+++ b/src/modules/m_spanningtree/server.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "socketengine.h"
diff --git a/src/modules/m_spanningtree/stats.cpp b/src/modules/m_spanningtree/stats.cpp
index 9ac255c37..8d74a8bbf 100644
--- a/src/modules/m_spanningtree/stats.cpp
+++ b/src/modules/m_spanningtree/stats.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "socketengine.h"
@@ -35,7 +34,7 @@ bool TreeSocket::Stats(const std::string &prefix, std::deque<std::string> &param
 	 */
 	if (params.size() > 1)
 	{
-		if (this->Instance->MatchText(this->Instance->Config->ServerName, params[1]))
+		if (InspIRCd::Match(this->Instance->Config->ServerName, params[1]))
 		{
 			/* It's for our server */
 			string_list results;
diff --git a/src/modules/m_spanningtree/svsjoin.cpp b/src/modules/m_spanningtree/svsjoin.cpp
index 276138200..d3c47f47b 100644
--- a/src/modules/m_spanningtree/svsjoin.cpp
+++ b/src/modules/m_spanningtree/svsjoin.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "socketengine.h"
diff --git a/src/modules/m_spanningtree/svsnick.cpp b/src/modules/m_spanningtree/svsnick.cpp
index b2cd67128..ef57f6dbb 100644
--- a/src/modules/m_spanningtree/svsnick.cpp
+++ b/src/modules/m_spanningtree/svsnick.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "socketengine.h"
diff --git a/src/modules/m_spanningtree/svspart.cpp b/src/modules/m_spanningtree/svspart.cpp
index c3bc1b081..95d1a1c23 100644
--- a/src/modules/m_spanningtree/svspart.cpp
+++ b/src/modules/m_spanningtree/svspart.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "socketengine.h"
diff --git a/src/modules/m_spanningtree/time.cpp b/src/modules/m_spanningtree/time.cpp
index 85377a478..eb90eab8d 100644
--- a/src/modules/m_spanningtree/time.cpp
+++ b/src/modules/m_spanningtree/time.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "socketengine.h"
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index 0b21a462d..c3167b9b3 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index fef7b107b..fb0fe1c31 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -18,7 +18,6 @@
 #include "commands/cmd_stats.h"
 #include "socket.h"
 #include "inspircd.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index 3e9558e83..1f0288a66 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "m_hash.h"
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 6f66598d9..5b3ace4d4 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "socketengine.h"
diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp
index ce7718324..2ebceb3cf 100644
--- a/src/modules/m_spanningtree/uid.cpp
+++ b/src/modules/m_spanningtree/uid.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "m_hash.h"
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index 5e1d226ab..2b72d581c 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "socketengine.h"
@@ -91,7 +90,7 @@ TreeServer* SpanningTreeUtilities::FindServerMask(const std::string &ServerName)
 {
 	for (server_hash::iterator i = serverlist.begin(); i != serverlist.end(); i++)
 	{
-		if (match(i->first,ServerName))
+		if (InspIRCd::Match(i->first,ServerName))
 			return i->second;
 	}
 	return NULL;
@@ -630,7 +629,7 @@ Link* SpanningTreeUtilities::FindLink(const std::string& name)
 {
 	for (std::vector<Link>::iterator x = LinkBlocks.begin(); x < LinkBlocks.end(); x++)
 	{
-		if (ServerInstance->MatchText(x->Name.c_str(), name.c_str()))
+		if (InspIRCd::Match(x->Name.c_str(), name.c_str()))
 		{
 			return &(*x);
 		}
diff --git a/src/modules/m_spanningtree/version.cpp b/src/modules/m_spanningtree/version.cpp
index 5271be1d3..e2129d884 100644
--- a/src/modules/m_spanningtree/version.cpp
+++ b/src/modules/m_spanningtree/version.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "socketengine.h"
diff --git a/src/modules/m_spanningtree/whois.cpp b/src/modules/m_spanningtree/whois.cpp
index 1763f427a..b38f25a38 100644
--- a/src/modules/m_spanningtree/whois.cpp
+++ b/src/modules/m_spanningtree/whois.cpp
@@ -15,7 +15,6 @@
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-#include "wildcard.h"
 #include "xline.h"
 #include "transport.h"
 #include "socketengine.h"
diff --git a/src/modules/m_spy.cpp b/src/modules/m_spy.cpp
index c43cee956..193d22234 100644
--- a/src/modules/m_spy.cpp
+++ b/src/modules/m_spy.cpp
@@ -14,7 +14,6 @@
 /* $ModDesc: Provides the ability to see the complete names list of channels an oper is not a member of */
 
 #include "inspircd.h"
-#include "wildcard.h"
 
 class ModuleSpy : public Module
 {
diff --git a/src/modules/m_tline.cpp b/src/modules/m_tline.cpp
index 31bd67e17..c249f3b3b 100644
--- a/src/modules/m_tline.cpp
+++ b/src/modules/m_tline.cpp
@@ -12,7 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "wildcard.h"
 
 /* $ModDesc: Provides /tline command used to test who a mask matches */
 
@@ -37,7 +36,7 @@ class CommandTline : public Command
 		for (user_hash::const_iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++)
 		{
 			n_counted++;
-			if (match(u->second->GetFullRealHost(),parameters[0]))
+			if (InspIRCd::Match(u->second->GetFullRealHost(),parameters[0]))
 			{
 				n_matched++;
 				n_match_host++;
@@ -45,7 +44,7 @@ class CommandTline : public Command
 			else
 			{
 				std::string host = std::string(u->second->ident) + "@" + u->second->GetIPString();
-				if (match(host, parameters[0], true))
+				if (InspIRCd::MatchCIDR(host, parameters[0]))
 				{
 					n_matched++;
 					n_match_ip++;
diff --git a/src/wildcard.cpp b/src/wildcard.cpp
index 199b43965..e717b0ad4 100644
--- a/src/wildcard.cpp
+++ b/src/wildcard.cpp
@@ -28,21 +28,14 @@ static bool match_internal(const unsigned char *str, const unsigned char *mask,
 	const unsigned char *cp = NULL;
 	const unsigned char *mp = NULL;
 
+	if (!map)
+		map = lowermap; // default to case insensitive search
+
 	while ((*string) && (*wild != '*'))
 	{
-		if (!map)
+		if (map[*wild] != map[*string] && (*wild != '?'))
 		{
-			if ((*wild != *string) && (*wild != '?'))
-			{
-				return false;
-			}
-		}
-		else
-		{
-			if (map[*wild] != map[*string] && (*wild != '?'))
-			{
-				return false;
-			}
+			return false;
 		}
 
 		++wild;
@@ -61,10 +54,9 @@ static bool match_internal(const unsigned char *str, const unsigned char *mask,
 			mp = wild;
 			cp = string+1;
 		}
-		// if there is no charmap and str == wild OR
-		// there is a map and mapped char == mapped wild AND
-		// wild is NOT ?
-		else if (((!map && *wild == *string) || (map && map[*wild] == map[*string])) && (*wild == '?'))
+
+		// if mapped char == mapped wild AND wild is NOT ?
+		else if (map[*wild] == map[*string] && (*wild == '?'))
 		{
 			++wild;
 			++string;
-- 
cgit v1.2.3