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"
22 * Wildcard matching, the third (and probably final) iteration!
25 static bool match_internal(const unsigned char *mask, const unsigned char *str, unsigned const char *map)
27 const unsigned char *wild = str;
28 const unsigned char *string = mask;
29 const unsigned char *cp = NULL;
30 const unsigned char *mp = NULL;
33 map = lowermap; // default to case insensitive search
35 while ((*string) && (*wild != '*'))
37 if (map[*wild] != map[*string] && (*wild != '?'))
59 // if mapped char == mapped wild AND wild is NOT ?
60 else if (map[*wild] == map[*string] && (*wild == '?'))
78 std::cout << "*wild == 0\n";
80 std::cout << "*wild != 0\n";
84 CoreExport bool InspIRCd::Match(const std::string &str, const std::string &mask, unsigned const char *map)
86 return match_internal((const unsigned char *)str.c_str(), (const unsigned char *)mask.c_str(), map);
89 CoreExport bool InspIRCd::Match(const char *str, const char *mask, unsigned const char *map)
91 return match_internal((const unsigned char *)str, (const unsigned char *)mask, map);
95 CoreExport bool InspIRCd::MatchCIDR(const std::string &str, const std::string &mask, unsigned const char *map)
97 if (irc::sockets::MatchCIDR(str, mask, true))
100 // Fall back to regular match
101 return InspIRCd::Match(str, mask, NULL);
104 CoreExport bool InspIRCd::MatchCIDR(const char *str, const char *mask, unsigned const char *map)
106 if (irc::sockets::MatchCIDR(str, mask, true))
109 // Fall back to regular match
110 return InspIRCd::Match(str, mask, NULL);