X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_chghost.cpp;h=0ca7dc78c97e12d18b18d42c60222a29f34b6e7b;hb=e59cb85871f75b7603c63c6cd274d57536cf6794;hp=60146c78b1258e5eda99f3015593baa2cec9dc8b;hpb=5267fb9d362aeb326c9e64f7171c957f76776f90;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp index 60146c78b..0ca7dc78c 100644 --- a/src/modules/m_chghost.cpp +++ b/src/modules/m_chghost.cpp @@ -25,29 +25,29 @@ */ 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 { - const char* x = parameters[1].c_str(); - if (parameters[1].length() > ServerInstance->Config->Limits.MaxHost) { user->WriteNotice("*** CHGHOST: Host too long"); return CMD_FAILURE; } - for (; *x; x++) + 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; @@ -68,14 +68,14 @@ class CommandChghost : public Command if ((dest->ChangeDisplayedHost(parameters[1])) && (!user->server->IsULine())) { // fix by brain - ulines set hosts silently - ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used CHGHOST to make the displayed host of "+dest->nick+" become "+dest->dhost); + ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used CHGHOST to make the displayed host of "+dest->nick+" become "+dest->GetDisplayedHost()); } } 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]); } @@ -85,10 +85,10 @@ class CommandChghost : public Command class ModuleChgHost : public Module { CommandChghost cmd; - char hostmap[256]; public: - ModuleChgHost() : cmd(this, hostmap) + ModuleChgHost() + : cmd(this) { } @@ -96,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); } };