diff options
author | Adam <adam@sigterm.info> | 2013-05-15 12:33:47 -0700 |
---|---|---|
committer | Adam <adam@sigterm.info> | 2013-05-15 12:33:47 -0700 |
commit | e586aaab7c4f7b03514c83451d73b73f55dc6998 (patch) | |
tree | 18f4370778cc79d2f21a4308dafbb29a77cfa213 /src/wildcard.cpp | |
parent | 23e8bba13c55d33ce89d505780da36c9589e300a (diff) | |
parent | accccc212cd4f08a3c5532b1ae7a17e76bac8718 (diff) |
Merge pull request #531 from SaberUK/master+snprintf-removal
Replace some C-isms with C++-isms.
Diffstat (limited to 'src/wildcard.cpp')
-rw-r--r-- | src/wildcard.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/wildcard.cpp b/src/wildcard.cpp index eb9151293..b64d2d6e8 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -78,7 +78,7 @@ static bool match_internal(const unsigned char *str, const unsigned char *mask, * Below here is all wrappers around match_internal ********************************************************************/ -CoreExport bool InspIRCd::Match(const std::string &str, const std::string &mask, unsigned const char *map) +bool InspIRCd::Match(const std::string &str, const std::string &mask, unsigned const char *map) { if (!map) map = national_case_insensitive_map; @@ -86,14 +86,14 @@ CoreExport bool InspIRCd::Match(const std::string &str, const std::string &mask, return match_internal((const unsigned char *)str.c_str(), (const unsigned char *)mask.c_str(), map); } -CoreExport bool InspIRCd::Match(const char *str, const char *mask, unsigned const char *map) +bool InspIRCd::Match(const char *str, const char *mask, unsigned const char *map) { if (!map) map = national_case_insensitive_map; return match_internal((const unsigned char *)str, (const unsigned char *)mask, map); } -CoreExport bool InspIRCd::MatchCIDR(const std::string &str, const std::string &mask, unsigned const char *map) +bool InspIRCd::MatchCIDR(const std::string &str, const std::string &mask, unsigned const char *map) { if (irc::sockets::MatchCIDR(str, mask, true)) return true; @@ -105,7 +105,7 @@ CoreExport bool InspIRCd::MatchCIDR(const std::string &str, const std::string &m return InspIRCd::Match(str, mask, map); } -CoreExport bool InspIRCd::MatchCIDR(const char *str, const char *mask, unsigned const char *map) +bool InspIRCd::MatchCIDR(const char *str, const char *mask, unsigned const char *map) { if (irc::sockets::MatchCIDR(str, mask, true)) return true; @@ -117,3 +117,17 @@ CoreExport bool InspIRCd::MatchCIDR(const char *str, const char *mask, unsigned return InspIRCd::Match(str, mask, map); } +bool InspIRCd::MatchMask(const std::string& masks, const std::string& hostname, const std::string& ipaddr) +{ + std::stringstream masklist(masks); + std::string mask; + while (masklist >> mask) + { + if (InspIRCd::Match(hostname, mask, ascii_case_insensitive_map) || + InspIRCd::MatchCIDR(ipaddr, mask, ascii_case_insensitive_map)) + { + return true; + } + } + return false; +} |