]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_chghost.cpp
To be more specific, specify rpath() macro here
[user/henk/code/inspircd.git] / src / modules / m_chghost.cpp
index 7d629187f64475c4e47d54279447f145f19a40cd..d4047ad4828a0c3807cb589660e12d4aadf6b5ce 100644 (file)
@@ -26,9 +26,9 @@
 class cmd_chghost : public command_t
 {
  private:
-       char*& hostmap;
+       char* hostmap;
  public:
-       cmd_chghost (InspIRCd* Instance, char* &hmap) : command_t(Instance,"CHGHOST",'o',2), hostmap(hmap)
+       cmd_chghost (InspIRCd* Instance, char* hmap) : command_t(Instance,"CHGHOST",'o',2), hostmap(hmap)
        {
                this->source = "m_chghost.so";
                syntax = "<nick> <newhost>";
@@ -40,7 +40,7 @@ class cmd_chghost : public command_t
 
                for (; *x; x++)
                {
-                       if (!hostmap[*x])
+                       if (!hostmap[(unsigned char)*x])
                        {
                                user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
                                return CMD_FAILURE;
@@ -70,13 +70,12 @@ class cmd_chghost : public command_t
 class ModuleChgHost : public Module
 {
        cmd_chghost* mycommand;
-       char* hostmap;
+       char hostmap[256];
  public:
        ModuleChgHost(InspIRCd* Me)
                : Module::Module(Me)
        {
-               hostmap = new char[256];
-               OnRehash("");
+               OnRehash(NULL,"");
                mycommand = new cmd_chghost(ServerInstance, hostmap);
                ServerInstance->AddCommand(mycommand);
        }
@@ -86,22 +85,21 @@ class ModuleChgHost : public Module
                List[I_OnRehash] = 1;
        }
        
-       void OnRehash(const std::string &parameter)
+       void OnRehash(userrec* user, const std::string &parameter)
        {
                ConfigReader Conf(ServerInstance);
                std::string hmap = Conf.ReadValue("hostname", "charmap", 0);
 
                if (hmap.empty())
-                       hostmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789";
+                       hmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789";
 
-               memset(&hostmap, 0, sizeof(hostmap));
+               memset(&hostmap, 0, 255);
                for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
-                       hostmap[*n] = 1;
+                       hostmap[(unsigned char)*n] = 1;
        }
 
        ~ModuleChgHost()
        {
-               delete[] hostmap;
        }
        
        Version GetVersion()