diff options
-rw-r--r-- | src/modules/m_filter.h | 28 | ||||
-rw-r--r-- | src/modules/m_globalload.cpp | 46 | ||||
-rw-r--r-- | src/modules/m_globops.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_helpop.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_invisible.cpp | 12 | ||||
-rw-r--r-- | src/modules/m_jumpserver.cpp | 14 |
6 files changed, 57 insertions, 55 deletions
diff --git a/src/modules/m_filter.h b/src/modules/m_filter.h index 2ec56ea4f..288ed9310 100644 --- a/src/modules/m_filter.h +++ b/src/modules/m_filter.h @@ -113,7 +113,7 @@ protected: virtual void OnSyncOtherMetaData(Module* proto, void* opaque, bool displayable = false); virtual void OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata); virtual int OnStats(char symbol, User* user, string_list &results) = 0; - virtual int OnPreCommand(const std::string &command, const char* const* parameters, int pcnt, User *user, bool validated, const std::string &original_line); + virtual int OnPreCommand(const std::string &command, const std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line); bool AppliesToMe(User* user, FilterResult* filter, int flags); }; @@ -127,26 +127,26 @@ class CommandFilter : public Command this->syntax = "<filter-definition> <type> <flags> [<gline-duration>] :<reason>"; } - CmdResult Handle(const char* const* parameters, int pcnt, User *user) + CmdResult Handle(const std::vector<std::string> ¶meters, User *user) { - if (pcnt == 1) + if (parameters.size() == 1) { /* Deleting a filter */ if (Base->DeleteFilter(parameters[0])) { - user->WriteServ("NOTICE %s :*** Deleted filter '%s'", user->nick, parameters[0]); + user->WriteServ("NOTICE %s :*** Deleted filter '%s'", user->nick, parameters[0].c_str()); return CMD_SUCCESS; } else { - user->WriteServ("NOTICE %s :*** Filter '%s' not found on list.", user->nick, parameters[0]); + user->WriteServ("NOTICE %s :*** Filter '%s' not found on list.", user->nick, parameters[0].c_str()); return CMD_FAILURE; } } else { /* Adding a filter */ - if (pcnt >= 4) + if (parameters.size() >= 4) { std::string freeform = parameters[0]; std::string type = parameters[1]; @@ -163,7 +163,7 @@ class CommandFilter : public Command if (type == "gline") { - if (pcnt >= 5) + if (parameters.size() >= 5) { duration = ServerInstance->Duration(parameters[3]); reason = parameters[4]; @@ -182,7 +182,7 @@ class CommandFilter : public Command if (result.first) { user->WriteServ("NOTICE %s :*** Added filter '%s', type '%s'%s%s, flags '%s', reason: '%s'", user->nick, freeform.c_str(), - type.c_str(), (duration ? " duration: " : ""), (duration ? parameters[3] : ""), + type.c_str(), (duration ? " duration: " : ""), (duration ? parameters[3].c_str() : ""), flags.c_str(), reason.c_str()); return CMD_SUCCESS; } @@ -295,7 +295,7 @@ int FilterBase::OnUserPreNotice(User* user,void* dest,int target_type, std::stri return 0; } -int FilterBase::OnPreCommand(const std::string &command, const char* const* parameters, int pcnt, User *user, bool validated, const std::string &original_line) +int FilterBase::OnPreCommand(const std::string &command, const std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) { flags = 0; if ((validated == 1) && (IS_LOCAL(user))) @@ -307,7 +307,7 @@ int FilterBase::OnPreCommand(const std::string &command, const char* const* para if (command == "QUIT") { /* QUIT with no reason: nothing to do */ - if (pcnt < 1) + if (parameters.size() < 1) return 0; checkline = parameters[0]; @@ -318,7 +318,7 @@ int FilterBase::OnPreCommand(const std::string &command, const char* const* para else if (command == "PART") { /* PART with no reason: nothing to do */ - if (pcnt < 2) + if (parameters.size() < 2) return 0; std::vector<std::string>::iterator i = find(exemptfromfilter.begin(), exemptfromfilter.end(), parameters[0]); @@ -345,8 +345,8 @@ int FilterBase::OnPreCommand(const std::string &command, const char* const* para Command* c = ServerInstance->Parser->GetHandler(command); if (c) { - const char* params[MAXPARAMETERS]; - for (int item = 0; item < pcnt; item++) + std::vector<std::string> params; + for (int item = 0; item < (int)parameters.size(); item++) params[item] = parameters[item]; params[replacepoint] = "Reason filtered"; @@ -355,7 +355,7 @@ int FilterBase::OnPreCommand(const std::string &command, const char* const* para */ if ((f->action == "block") || (((!parting) && (f->action == "kill"))) || (f->action == "silent")) { - c->Handle(params, pcnt, user); + c->Handle(params, user); return 1; } else diff --git a/src/modules/m_globalload.cpp b/src/modules/m_globalload.cpp index 2de9be9f6..1c08a48c6 100644 --- a/src/modules/m_globalload.cpp +++ b/src/modules/m_globalload.cpp @@ -27,24 +27,24 @@ class CommandGloadmodule : public Command TRANSLATE3(TR_TEXT, TR_TEXT, TR_END); } - CmdResult Handle (const char* const* parameters, int pcnt, User *user) + CmdResult Handle (const std::vector<std::string> ¶meters, User *user) { - std::string servername = pcnt > 1 ? parameters[1] : "*"; + std::string servername = parameters.size() > 1 ? parameters[1] : "*"; if (ServerInstance->MatchText(ServerInstance->Config->ServerName, servername)) { - if (ServerInstance->Modules->Load(parameters[0])) + if (ServerInstance->Modules->Load(parameters[0].c_str())) { - ServerInstance->SNO->WriteToSnoMask('A', "NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick); - user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick, parameters[0]); + ServerInstance->SNO->WriteToSnoMask('A', "NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0].c_str(), user->nick); + user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick, parameters[0].c_str()); } else { - user->WriteNumeric(974, "%s %s :%s",user->nick, parameters[0],ServerInstance->Modules->LastError().c_str()); + user->WriteNumeric(974, "%s %s :%s",user->nick, parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); } } else - ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBAL LOAD BY '%s' (not loaded here)",parameters[0],user->nick); + ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBAL LOAD BY '%s' (not loaded here)",parameters[0].c_str(), user->nick); return CMD_SUCCESS; } @@ -61,24 +61,24 @@ class CommandGunloadmodule : public Command syntax = "<modulename> [servermask]"; } - CmdResult Handle (const char* const* parameters, int pcnt, User *user) + CmdResult Handle (const std::vector<std::string> ¶meters, User *user) { - std::string servername = pcnt > 1 ? parameters[1] : "*"; + std::string servername = parameters.size() > 1 ? parameters[1] : "*"; if (ServerInstance->MatchText(ServerInstance->Config->ServerName, servername)) { - if (ServerInstance->Modules->Unload(parameters[0])) + if (ServerInstance->Modules->Unload(parameters[0].c_str())) { - ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick); - user->WriteNumeric(973, "%s %s :Module successfully unloaded.",user->nick, parameters[0]); + ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0].c_str(), user->nick); + user->WriteNumeric(973, "%s %s :Module successfully unloaded.",user->nick, parameters[0].c_str()); } else { - user->WriteNumeric(972, "%s %s :%s",user->nick, parameters[0],ServerInstance->Modules->LastError().c_str()); + user->WriteNumeric(972, "%s %s :%s",user->nick, parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); } } else - ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBAL UNLOAD BY '%s' (not unloaded here)",parameters[0],user->nick); + ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBAL UNLOAD BY '%s' (not unloaded here)",parameters[0].c_str(), user->nick); return CMD_SUCCESS; } @@ -95,25 +95,25 @@ class CommandGreloadmodule : public Command syntax = "<modulename> [servermask]"; } - CmdResult Handle(const char* const* parameters, int pcnt, User *user) + CmdResult Handle(const std::vector<std::string> ¶meters, User *user) { - std::string servername = pcnt > 1 ? parameters[1] : "*"; + std::string servername = parameters.size() > 1 ? parameters[1] : "*"; if (ServerInstance->MatchText(ServerInstance->Config->ServerName, servername)) { - if (!ServerInstance->Modules->Unload(parameters[0])) + if (!ServerInstance->Modules->Unload(parameters[0].c_str())) { - user->WriteNumeric(972, "%s %s :%s",user->nick, parameters[0],ServerInstance->Modules->LastError().c_str()); + user->WriteNumeric(972, "%s %s :%s",user->nick, parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); } - if (!ServerInstance->Modules->Load(parameters[0])) + if (!ServerInstance->Modules->Load(parameters[0].c_str())) { - user->WriteNumeric(974, "%s %s :%s",user->nick, parameters[0],ServerInstance->Modules->LastError().c_str()); + user->WriteNumeric(974, "%s %s :%s",user->nick, parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); } - ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBALLY RELOADED BY '%s'",parameters[0],user->nick); - user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick, parameters[0]); + ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBALLY RELOADED BY '%s'",parameters[0].c_str(), user->nick); + user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick, parameters[0].c_str()); } else - ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBAL RELOAD BY '%s' (not reloaded here)",parameters[0],user->nick); + ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBAL RELOAD BY '%s' (not reloaded here)",parameters[0].c_str(), user->nick); return CMD_SUCCESS; } diff --git a/src/modules/m_globops.cpp b/src/modules/m_globops.cpp index b16b1ee1c..81aef9f57 100644 --- a/src/modules/m_globops.cpp +++ b/src/modules/m_globops.cpp @@ -29,12 +29,12 @@ class CommandGlobops : public Command TRANSLATE2(TR_TEXT, TR_END); } - CmdResult Handle (const char* const* parameters, int pcnt, User *user) + CmdResult Handle (const std::vector<std::string> ¶meters, User *user) { std::string line = "From " + std::string(user->nick) + ": "; - for (int i = 0; i < pcnt; i++) + for (int i = 0; i < (int)parameters.size(); i++) { - line = line + std::string(parameters[i]) + " "; + line = line + parameters[i] + " "; } ServerInstance->SNO->WriteToSnoMask('g',line); diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp index 3ed172644..af55f9bc8 100644 --- a/src/modules/m_helpop.cpp +++ b/src/modules/m_helpop.cpp @@ -36,11 +36,11 @@ class CommandHelpop : public Command syntax = "<any-text>"; } - CmdResult Handle (const char* const* parameters, int pcnt, User *user) + CmdResult Handle (const std::vector<std::string> ¶meters, User *user) { irc::string parameter("start"); - if (pcnt > 0) - parameter = parameters[0]; + if (parameters.size() > 0) + parameter = parameters[0].c_str(); if (parameter == "index") { diff --git a/src/modules/m_invisible.cpp b/src/modules/m_invisible.cpp index b90394164..de573dfde 100644 --- a/src/modules/m_invisible.cpp +++ b/src/modules/m_invisible.cpp @@ -140,8 +140,10 @@ class InvisibleDeOper : public ModeWatcher /* Users who are opers and have +Q get their +Q removed when they deoper */ if ((!adding) && (dest->IsModeSet('Q'))) { - const char* newmodes[] = { dest->nick, "-Q" }; - ServerInstance->Modes->Process(newmodes, 2, source, true); + std::vector<std::string> newmodes; + newmodes[0] = dest->nick; + newmodes[1] = "-Q"; + ServerInstance->Modes->Process(newmodes, source, true); } return true; } @@ -221,7 +223,7 @@ class ModuleInvisible : public Module { Command* parthandler = ServerInstance->Parser->GetHandler("PART"); std::vector<std::string> to_leave; - const char* parameters[2]; + std::vector<std::string> parameters; if (parthandler) { for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) @@ -229,9 +231,9 @@ class ModuleInvisible : public Module /* We cant do this neatly in one loop, as we are modifying the map we are iterating */ for (std::vector<std::string>::iterator n = to_leave.begin(); n != to_leave.end(); n++) { - parameters[0] = n->c_str(); + parameters[0] = *n; /* This triggers our OnUserPart, above, making the PART silent */ - parthandler->Handle(parameters, 1, user); + parthandler->Handle(parameters, user); } } } diff --git a/src/modules/m_jumpserver.cpp b/src/modules/m_jumpserver.cpp index 5593b482a..14448c72e 100644 --- a/src/modules/m_jumpserver.cpp +++ b/src/modules/m_jumpserver.cpp @@ -37,17 +37,17 @@ class CommandJumpserver : public Command redirect_all_immediately = redirect_new_users = false; } - CmdResult Handle (const char* const* parameters, int pcnt, User *user) + CmdResult Handle (const std::vector<std::string> ¶meters, User *user) { int n_done = 0; - reason = (pcnt < 4) ? "Please use this server/port instead" : parameters[3]; + reason = (parameters.size() < 4) ? "Please use this server/port instead" : parameters[3]; redirect_all_immediately = false; redirect_new_users = true; direction = true; std::string n_done_s; /* No parameters: jumpserver disabled */ - if (!pcnt) + if (!parameters.size()) { if (port) user->WriteServ("NOTICE %s :*** Disabled jumpserver (previously set to '%s:%d')", user->nick, redirect_to.c_str(), port); @@ -62,7 +62,7 @@ class CommandJumpserver : public Command port = 0; redirect_to.clear(); - for (const char* n = parameters[2]; *n; n++) + for (const char* n = parameters[2].c_str(); *n; n++) { switch (*n) { @@ -89,7 +89,7 @@ class CommandJumpserver : public Command User* t = *i; if (!IS_OPER(t)) { - t->WriteNumeric(10, "%s %s %s :Please use this Server/Port instead", user->nick, parameters[0], parameters[1]); + t->WriteNumeric(10, "%s %s %s :Please use this Server/Port instead", user->nick, parameters[0].c_str(), parameters[1].c_str()); ServerInstance->Users->QuitUser(t, reason); n_done++; } @@ -103,10 +103,10 @@ class CommandJumpserver : public Command if (redirect_new_users) { redirect_to = parameters[0]; - port = atoi(parameters[1]); + port = atoi(parameters[1].c_str()); } - user->WriteServ("NOTICE %s :*** Set jumpserver to server '%s' port '%s', flags '+%s%s'%s%s%s: %s", user->nick, parameters[0], parameters[1], + user->WriteServ("NOTICE %s :*** Set jumpserver to server '%s' port '%s', flags '+%s%s'%s%s%s: %s", user->nick, parameters[0].c_str(), parameters[1].c_str(), redirect_all_immediately ? "a" : "", redirect_new_users ? "n" : "", n_done ? " (" : "", |