]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
national_case_sensitive_map must be static, thanks to the match stuff being static...
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 7 Dec 2008 18:31:54 +0000 (18:31 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 7 Dec 2008 18:31:54 +0000 (18:31 +0000)
Default to national charset map instead of rfc map, as modules may change the pointer.

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10857 e03df62e-2008-0410-955e-edbf42e46eb7

include/inspircd.h
src/inspircd.cpp
src/wildcard.cpp

index 59e840b7b177c8f2d0cac5733ae53c2ff5ff1007..19674c1189989991d126af18653d92b28b3f34e4 100644 (file)
@@ -408,7 +408,7 @@ class CoreExport InspIRCd : public classbase
         * This is provided as a pointer so that modules can change it to their custom mapping tables,
         * e.g. for national character support.
         */
-       unsigned const char *national_case_sensitive_map;
+       static unsigned const char *national_case_sensitive_map;
 
        /** Returns the next available UID for this server.
         */
index 1f323e023051f4c0560da05b16fec611c4a3fadc..dd772f94e461055f174d4a0d45c21990691f6541 100644 (file)
@@ -444,7 +444,6 @@ InspIRCd::InspIRCd(int argc, char** argv)
        this->XLines = 0;
        this->Modes = 0;
        this->Res = 0;
-       this->national_case_sensitive_map = rfc_case_insensitive_map;
 
        // Initialise TIME
        this->TIME = time(NULL);
@@ -986,6 +985,7 @@ void InspIRCd::SetSignal(int signal)
  */
 ENTRYPOINT
 {
+       InspIRCd::national_case_sensitive_map = rfc_case_insensitive_map;
        SI = new InspIRCd(argc, argv);
        mysig = &SI->s_signal;
        SI->Run();
index 63a28b8cb797fe2e25bb9e4d8e94847c530752ec..9f91d9c6831a99a79b5e49311921f88c2225a1d9 100644 (file)
 
 static bool match_internal(const unsigned char *str, const unsigned char *mask, unsigned const char *map)
 {
-        unsigned char *cp = NULL, *mp = NULL;
-        unsigned char* string = (unsigned char*)str;
-        unsigned char* wild = (unsigned char*)mask;
-
-       if (!map)
-               map = rfc_case_insensitive_map;
-
-        while ((*string) && (*wild != '*'))
-        {
-                if ((map[*wild] != map[*string]) && (*wild != '?'))
-                {
-                        return 0;
-                }
-                wild++;
-                string++;
-        }
-
-        while (*string)
-        {
-                if (*wild == '*')
-                {
-                        if (!*++wild)
-                        {
-                                return 1;
-                        }
-                        mp = wild;
-                        cp = string+1;
-                }
-                else
-                if ((map[*wild] == map[*string]) || (*wild == '?'))
-                {
-                        wild++;
-                        string++;
-                }
-                else
-                {
-                        wild = mp;
-                        string = cp++;
-                }
-
-        }
-
-        while (*wild == '*')
-        {
-                wild++;
-        }
-
-        return !*wild;
+       unsigned char *cp = NULL, *mp = NULL;
+       unsigned char* string = (unsigned char*)str;
+       unsigned char* wild = (unsigned char*)mask;
+
+       while ((*string) && (*wild != '*'))
+       {
+               if ((map[*wild] != map[*string]) && (*wild != '?'))
+               {
+                       return 0;
+               }
+               wild++;
+               string++;
+       }
+
+       while (*string)
+       {
+               if (*wild == '*')
+               {
+                       if (!*++wild)
+                       {
+                               return 1;
+                       }
+                       mp = wild;
+                       cp = string+1;
+               }
+               else
+                       if ((map[*wild] == map[*string]) || (*wild == '?'))
+                       {
+                               wild++;
+                               string++;
+                       }
+                       else
+                       {
+                               wild = mp;
+                               string = cp++;
+                       }
+
+       }
+
+       while (*wild == '*')
+       {
+               wild++;
+       }
+
+       return !*wild;
 }
 
 /********************************************************************
@@ -75,11 +72,16 @@ static bool match_internal(const unsigned char *str, const unsigned char *mask,
 
 CoreExport bool InspIRCd::Match(const std::string &str, const std::string &mask, unsigned const char *map)
 {
+       if (!map)
+               map = this->national_case_sensitive_map;
+
        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)
 {
+       if (!map)
+               map = this->national_case_sensitive_map;
        return match_internal((const unsigned char *)str, (const unsigned char *)mask, map);
 }
 
@@ -88,8 +90,11 @@ CoreExport bool InspIRCd::MatchCIDR(const std::string &str, const std::string &m
        if (irc::sockets::MatchCIDR(str, mask, true))
                return true;
 
+       if (!map)
+               map = this->national_case_sensitive_map;
+
        // Fall back to regular match
-       return InspIRCd::Match(str, mask, NULL);
+       return InspIRCd::Match(str, mask, map);
 }
 
 CoreExport bool InspIRCd::MatchCIDR(const  char *str, const char *mask, unsigned const char *map)
@@ -97,7 +102,10 @@ CoreExport bool InspIRCd::MatchCIDR(const  char *str, const char *mask, unsigned
        if (irc::sockets::MatchCIDR(str, mask, true))
                return true;
 
+       if (!map)
+               map = this->national_case_sensitive_map;
+
        // Fall back to regular match
-       return InspIRCd::Match(str, mask, NULL);
+       return InspIRCd::Match(str, mask, map);
 }