diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-01-14 13:30:43 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-01-14 13:30:43 +0000 |
commit | 0c828ad6d498a15f42b1d281ea979135a91b87e2 (patch) | |
tree | 96e8754700385a37ebef8bc3ef9d54302d672645 /src/wildcard.cpp | |
parent | b3685095cd00ac6204ed17161a635888905c16d6 (diff) |
Add alias:matchcase config setting (per-alias, determines wether to match case on format string) and ability for case sensitive match()
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6319 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/wildcard.cpp')
-rw-r--r-- | src/wildcard.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/wildcard.cpp b/src/wildcard.cpp index f99054939..2243bc882 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -28,6 +28,55 @@ using irc::sockets::MatchCIDR; // (unattributed to any author) all over the 'net. // For now, we'll just consider this public domain. +bool csmatch(const char *str, const char *mask) +{ + unsigned char *cp = NULL, *mp = NULL; + unsigned char* string = (unsigned char*)str; + unsigned char* wild = (unsigned char*)mask; + + while ((*string) && (*wild != '*')) + { + if ((*wild != *string) && (*wild != '?')) + { + return 0; + } + wild++; + string++; + } + + while (*string) + { + if (*wild == '*') + { + if (!*++wild) + { + return 1; + } + mp = wild; + cp = string+1; + } + else + if ((*wild == *string) || (*wild == '?')) + { + wild++; + string++; + } + else + { + wild = mp; + string = cp++; + } + + } + + while (*wild == '*') + { + wild++; + } + + return !*wild; +} + bool match(const char *str, const char *mask) { unsigned char *cp = NULL, *mp = NULL; @@ -84,3 +133,10 @@ bool match(const char *str, const char *mask, bool use_cidr_match) return true; return match(str, mask); } + +bool match(bool case_sensitive, const char *str, const char *mask, bool use_cidr_match) +{ + if (use_cidr_match && MatchCIDR(str, mask, true)) + return true; + return csmatch(str, mask); +} |