]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_sethost.cpp
Some more text fixes and improvements (#1618).
[user/henk/code/inspircd.git] / src / modules / m_sethost.cpp
index e2a5dc281b603b38c8a5e9afd831956e7a9113f8..dad8491530c59da43d3dfb32f4b6dfb90e647fe7 100644 (file)
  */
 class CommandSethost : public Command
 {
-       char* hostmap;
-
  public:
-       CommandSethost(Module* Creator, char* hmap) : Command(Creator,"SETHOST", 1), hostmap(hmap)
+       std::bitset<UCHAR_MAX> hostmap;
+
+       CommandSethost(Module* Creator)
+               : Command(Creator,"SETHOST", 1)
        {
                allow_empty_last_param = false;
-               flags_needed = 'o'; syntax = "<new-hostname>";
+               flags_needed = 'o'; syntax = "<host>";
        }
 
-       CmdResult Handle (const std::vector<std::string>& parameters, User *user)
+       CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
        {
                if (parameters[0].length() > ServerInstance->Config->Limits.MaxHost)
                {
@@ -44,7 +45,7 @@ class CommandSethost : public Command
 
                for (std::string::const_iterator x = parameters[0].begin(); x != parameters[0].end(); x++)
                {
-                       if (!hostmap[(const unsigned char)*x])
+                       if (!hostmap.test(static_cast<unsigned char>(*x)))
                        {
                                user->WriteNotice("*** SETHOST: Invalid characters in hostname");
                                return CMD_FAILURE;
@@ -53,7 +54,7 @@ class CommandSethost : public Command
 
                if (user->ChangeDisplayedHost(parameters[0]))
                {
-                       ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used SETHOST to change their displayed host to "+user->dhost);
+                       ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used SETHOST to change their displayed host to "+user->GetDisplayedHost());
                        return CMD_SUCCESS;
                }
 
@@ -65,11 +66,10 @@ class CommandSethost : public Command
 class ModuleSetHost : public Module
 {
        CommandSethost cmd;
-       char hostmap[256];
 
  public:
        ModuleSetHost()
-               : cmd(this, hostmap)
+               : cmd(this)
        {
        }
 
@@ -77,14 +77,14 @@ class ModuleSetHost : public Module
        {
                std::string hmap = ServerInstance->Config->ConfValue("hostname")->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789");
 
-               memset(hostmap, 0, sizeof(hostmap));
+               cmd.hostmap.reset();
                for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
-                       hostmap[(unsigned char)*n] = 1;
+                       cmd.hostmap.set(static_cast<unsigned char>(*n));
        }
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Provides support for the SETHOST command", VF_VENDOR);
+               return Version("Provides the SETHOST command", VF_VENDOR);
        }
 };