X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_chghost.cpp;h=0ca7dc78c97e12d18b18d42c60222a29f34b6e7b;hb=33bf99090f7e3e8d3fa7f570c486f1f3d7670db9;hp=8b588b63dd5d38073c4faf0cf48ee8132dd0bc29;hpb=d23c030c9a8fd58807438245a004e4aa5b7288ba;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp index 8b588b63d..0ca7dc78c 100644 --- a/src/modules/m_chghost.cpp +++ b/src/modules/m_chghost.cpp @@ -25,17 +25,19 @@ */ class CommandChghost : public Command { - char* hostmap; public: - CommandChghost(Module* Creator, char* hmap) : Command(Creator,"CHGHOST", 2), hostmap(hmap) + std::bitset hostmap; + + CommandChghost(Module* Creator) + : Command(Creator,"CHGHOST", 2) { allow_empty_last_param = false; flags_needed = 'o'; - syntax = " "; + syntax = " "; TRANSLATE2(TR_NICK, TR_TEXT); } - CmdResult Handle(const std::vector ¶meters, User *user) + CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE { if (parameters[1].length() > ServerInstance->Config->Limits.MaxHost) { @@ -45,7 +47,7 @@ class CommandChghost : public Command for (std::string::const_iterator x = parameters[1].begin(); x != parameters[1].end(); x++) { - if (!hostmap[(unsigned char)*x]) + if (!hostmap.test(static_cast(*x))) { user->WriteNotice("*** CHGHOST: Invalid characters in hostname"); return CMD_FAILURE; @@ -73,7 +75,7 @@ class CommandChghost : public Command return CMD_SUCCESS; } - RouteDescriptor GetRouting(User* user, const std::vector& parameters) + RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE { return ROUTE_OPT_UCAST(parameters[0]); } @@ -83,10 +85,10 @@ class CommandChghost : public Command class ModuleChgHost : public Module { CommandChghost cmd; - char hostmap[256]; public: - ModuleChgHost() : cmd(this, hostmap) + ModuleChgHost() + : cmd(this) { } @@ -94,14 +96,14 @@ class ModuleChgHost : 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(*n)); } Version GetVersion() CXX11_OVERRIDE { - return Version("Provides support for the CHGHOST command", VF_OPTCOMMON | VF_VENDOR); + return Version("Provides the CHGHOST command", VF_OPTCOMMON | VF_VENDOR); } };