1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
18 #include "inspstring.h"
20 static bool match_internal(const unsigned char *str, const unsigned char *mask, unsigned const char *map)
22 unsigned char *cp = NULL, *mp = NULL;
23 unsigned char* string = (unsigned char*)str;
24 unsigned char* wild = (unsigned char*)mask;
26 while ((*string) && (*wild != '*'))
28 if ((map[*wild] != map[*string]) && (*wild != '?'))
48 if ((map[*wild] == map[*string]) || (*wild == '?'))
69 /********************************************************************
70 * Below here is all wrappers around match_internal
71 ********************************************************************/
73 CoreExport bool InspIRCd::Match(const std::string &str, const std::string &mask, unsigned const char *map)
76 map = national_case_insensitive_map;
78 return match_internal((const unsigned char *)str.c_str(), (const unsigned char *)mask.c_str(), map);
81 CoreExport bool InspIRCd::Match(const char *str, const char *mask, unsigned const char *map)
84 map = national_case_insensitive_map;
85 return match_internal((const unsigned char *)str, (const unsigned char *)mask, map);
88 CoreExport bool InspIRCd::MatchCIDR(const std::string &str, const std::string &mask, unsigned const char *map)
90 if (irc::sockets::MatchCIDR(str, mask, true))
94 map = national_case_insensitive_map;
96 // Fall back to regular match
97 return InspIRCd::Match(str, mask, map);
100 CoreExport bool InspIRCd::MatchCIDR(const char *str, const char *mask, unsigned const char *map)
102 if (irc::sockets::MatchCIDR(str, mask, true))
106 map = national_case_insensitive_map;
108 // Fall back to regular match
109 return InspIRCd::Match(str, mask, map);