1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
18 #include "inspstring.h"
24 * Slow, horrible, etc.
26 * The vastly available 'public domain' one
28 * ZNC's, thought to be faster than ours, but it turned out that we could do better ;-)
30 * Largely from work by peavey and myself (w00t) :)
33 static bool match_internal(const unsigned char *string, const unsigned char *wild, unsigned const char *map)
35 const unsigned char* s;
44 while (*wild && *wild == '*')
49 else if (*wild != '?')
54 if ((map[*wild] == map[*s]))
57 if (*(wild+1) || !*(s+1))
67 else if ( (map[*wild] != map[*string]) && (*wild != '?') )
77 while (*wild && *wild == '*')
83 /********************************************************************
84 * Below here is all wrappers around match_internal
85 ********************************************************************/
87 CoreExport bool InspIRCd::Match(const std::string &str, const std::string &mask, unsigned const char *map)
89 return match_internal((const unsigned char *)str.c_str(), (const unsigned char *)mask.c_str(), map);
92 CoreExport bool InspIRCd::Match(const char *str, const char *mask, unsigned const char *map)
94 return match_internal((const unsigned char *)str, (const unsigned char *)mask, map);
98 CoreExport bool InspIRCd::MatchCIDR(const std::string &str, const std::string &mask, unsigned const char *map)
100 if (irc::sockets::MatchCIDR(str, mask, true))
103 // Fall back to regular match
104 return InspIRCd::Match(str, mask, NULL);
107 CoreExport bool InspIRCd::MatchCIDR(const char *str, const char *mask, unsigned const char *map)
109 if (irc::sockets::MatchCIDR(str, mask, true))
112 // Fall back to regular match
113 return InspIRCd::Match(str, mask, NULL);