diff options
author | aquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-05-05 00:40:23 +0000 |
---|---|---|
committer | aquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-05-05 00:40:23 +0000 |
commit | a3d00f20ae31b4d3b9147e5c9999739aef84f762 (patch) | |
tree | 5ebdd83460a29e4e5c0a7ef0e0da0d869b79d333 | |
parent | 8232baefbfbb2b3a8c059561e4d19a55344d87ac (diff) |
Convert m_spanningtree
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9626 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/modules/m_nicklock.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_opermotd.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 12 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 28 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_admin.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_map.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_modules.cpp | 10 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_motd.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_squit.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_stats.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_time.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_whois.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_spanningtree/postcommand.cpp | 12 | ||||
-rw-r--r-- | src/modules/m_spanningtree/precommand.cpp | 34 | ||||
-rw-r--r-- | src/modules/m_spanningtree/rconnect.cpp | 14 | ||||
-rw-r--r-- | src/modules/m_spanningtree/rconnect.h | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/rsquit.cpp | 10 | ||||
-rw-r--r-- | src/modules/m_spanningtree/rsquit.h | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket2.cpp | 20 |
19 files changed, 97 insertions, 105 deletions
diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp index 8fae46279..cd4a1f8ba 100644 --- a/src/modules/m_nicklock.cpp +++ b/src/modules/m_nicklock.cpp @@ -28,7 +28,7 @@ class CommandNicklock : public Command TRANSLATE3(TR_NICK, TR_TEXT, TR_END); } - CmdResult Handle(const char* const* parameters, int pcnt, User *user) + CmdResult Handle(const std::vector<const std::string>& parameters, User *user) { User* target = ServerInstance->FindNick(parameters[0]); irc::string server; diff --git a/src/modules/m_opermotd.cpp b/src/modules/m_opermotd.cpp index 15946cd1f..9cf068959 100644 --- a/src/modules/m_opermotd.cpp +++ b/src/modules/m_opermotd.cpp @@ -49,7 +49,7 @@ class CommandOpermotd : public Command syntax = "[<servername>]"; } - CmdResult Handle (const char* const* parameters, int pcnt, User* user) + CmdResult Handle (const std::vector<const std::string>& parameters, User* user) { return ShowOperMOTD(user); } diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 0cfa53a14..6c77de076 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -110,14 +110,14 @@ int ModuleSpanningTree::CountServs() return Utils->serverlist.size(); } -void ModuleSpanningTree::HandleLinks(const char* const* parameters, int pcnt, User* user) +void ModuleSpanningTree::HandleLinks(const std::vector<std::string>& parameters, User* user) { ShowLinks(Utils->TreeRoot,user,0); user->WriteNumeric(365, "%s * :End of /LINKS list.",user->nick); return; } -void ModuleSpanningTree::HandleLusers(const char* const* parameters, int pcnt, User* user) +void ModuleSpanningTree::HandleLusers(const std::vector<std::string>& parameters, User* user) { unsigned int n_users = ServerInstance->Users->UserCount(); @@ -337,7 +337,7 @@ void ModuleSpanningTree::AutoConnectServers(time_t curtime) } } -int ModuleSpanningTree::HandleVersion(const char* const* parameters, int pcnt, User* user) +int ModuleSpanningTree::HandleVersion(const std::vector<std::string>& parameters, User* user) { // we've already checked if pcnt > 0, so this is safe TreeServer* found = Utils->FindServerMask(parameters[0]); @@ -352,7 +352,7 @@ int ModuleSpanningTree::HandleVersion(const char* const* parameters, int pcnt, U } else { - user->WriteNumeric(402, "%s %s :No such server",user->nick,parameters[0]); + user->WriteNumeric(402, "%s %s :No such server",user->nick,parameters[0].c_str()); } return 1; } @@ -409,7 +409,7 @@ void ModuleSpanningTree::RemoteMessage(User* user, const char* format, ...) SendingRemoteMessage = false; } -int ModuleSpanningTree::HandleConnect(const char* const* parameters, int pcnt, User* user) +int ModuleSpanningTree::HandleConnect(const std::vector<std::string>& parameters, User* user) { for (std::vector<Link>::iterator x = Utils->LinkBlocks.begin(); x < Utils->LinkBlocks.end(); x++) { @@ -429,7 +429,7 @@ int ModuleSpanningTree::HandleConnect(const char* const* parameters, int pcnt, U } } } - RemoteMessage(user, "*** CONNECT: No server matching \002%s\002 could be found in the config file.",parameters[0]); + RemoteMessage(user, "*** CONNECT: No server matching \002%s\002 could be found in the config file.",parameters[0].c_str()); return 1; } diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 216cb6193..a302c1f4f 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -70,11 +70,11 @@ class ModuleSpanningTree : public Module /** Handle LINKS command */ - void HandleLinks(const char* const* parameters, int pcnt, User* user); + void HandleLinks(const std::vector<std::string>& parameters, User* user); /** Handle LUSERS command */ - void HandleLusers(const char* const* parameters, int pcnt, User* user); + void HandleLusers(const std::vector<std::string>& parameters, User* user); /** Show MAP output to a user (recursive) */ @@ -82,35 +82,35 @@ class ModuleSpanningTree : public Module /** Handle remote MOTD */ - int HandleMotd(const char* const* parameters, int pcnt, User* user); + int HandleMotd(const std::vector<std::string>& parameters, User* user); /** Handle remote ADMIN */ - int HandleAdmin(const char* const* parameters, int pcnt, User* user); + int HandleAdmin(const std::vector<std::string>& parameters, User* user); /** Handle remote STATS */ - int HandleStats(const char* const* parameters, int pcnt, User* user); + int HandleStats(const std::vector<std::string>& parameters, User* user); /** Handle MAP command */ - int HandleMap(const char* const* parameters, int pcnt, User* user); + int HandleMap(const std::vector<std::string>& parameters, User* user); /** Handle SQUIT */ - int HandleSquit(const char* const* parameters, int pcnt, User* user); + int HandleSquit(const std::vector<std::string>& parameters, User* user); /** Handle TIME */ - int HandleTime(const char* const* parameters, int pcnt, User* user); + int HandleTime(const std::vector<std::string>& parameters, User* user); /** Handle remote WHOIS */ - int HandleRemoteWhois(const char* const* parameters, int pcnt, User* user); + int HandleRemoteWhois(const std::vector<std::string>& parameters, User* user); /** Handle remote MODULES */ - int HandleModules(const char* const* parameters, int pcnt, User* user); + int HandleModules(const std::vector<std::string>& parameters, User* user); /** Ping all local servers */ @@ -126,11 +126,11 @@ class ModuleSpanningTree : public Module /** Handle remote VERSON */ - int HandleVersion(const char* const* parameters, int pcnt, User* user); + int HandleVersion(const std::vector<std::string>& parameters, User* user); /** Handle CONNECT */ - int HandleConnect(const char* const* parameters, int pcnt, User* user); + int HandleConnect(const std::vector<std::string>& parameters, User* user); /** Attempt to send a message to a user */ @@ -148,8 +148,8 @@ class ModuleSpanningTree : public Module ** *** MODULE EVENTS *** **/ - virtual int OnPreCommand(const std::string &command, const char* const* parameters, int pcnt, User *user, bool validated, const std::string &original_line); - virtual void OnPostCommand(const std::string &command, const char* const* parameters, int pcnt, User *user, CmdResult result, const std::string &original_line); + virtual int OnPreCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line); + virtual void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line); virtual void OnGetServerDescription(const std::string &servername,std::string &description); virtual void OnUserInvite(User* source,User* dest,Channel* channel, time_t); virtual void OnPostLocalTopicChange(User* user, Channel* chan, const std::string &topic); diff --git a/src/modules/m_spanningtree/override_admin.cpp b/src/modules/m_spanningtree/override_admin.cpp index c090cb071..3fd59f303 100644 --- a/src/modules/m_spanningtree/override_admin.cpp +++ b/src/modules/m_spanningtree/override_admin.cpp @@ -33,11 +33,11 @@ /* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h */ -int ModuleSpanningTree::HandleAdmin(const char* const* parameters, int pcnt, User* user) +int ModuleSpanningTree::HandleAdmin(const std::vector<std::string>& parameters, User* user) { - if (pcnt > 0) + if (parameters.size() > 0) { - if (match(ServerInstance->Config->ServerName, parameters[0])) + if (match(ServerInstance->Config->ServerName, parameters[0].c_str())) return 0; /* Remote ADMIN, the server is within the 1st parameter */ @@ -51,7 +51,7 @@ int ModuleSpanningTree::HandleAdmin(const char* const* parameters, int pcnt, Use Utils->DoOneToOne(user->uuid, "ADMIN", params, s->GetName()); } else - user->WriteServ( "402 %s %s :No such server", user->nick, parameters[0]); + user->WriteServ( "402 %s %s :No such server", user->nick, parameters[0].c_str()); return 1; } return 0; diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp index c8ccf5b99..fa93f8280 100644 --- a/src/modules/m_spanningtree/override_map.cpp +++ b/src/modules/m_spanningtree/override_map.cpp @@ -108,16 +108,16 @@ void ModuleSpanningTree::ShowMap(TreeServer* Current, User* user, int depth, cha // and divisons, we instead render the map onto a backplane of characters // (a character matrix), then draw the branches as a series of "L" shapes // from the nodes. This is not only friendlier on CPU it uses less stack. -int ModuleSpanningTree::HandleMap(const char* const* parameters, int pcnt, User* user) +int ModuleSpanningTree::HandleMap(const std::vector<std::string>& parameters, User* user) { - if (pcnt > 0) + if (parameters.size() > 0) { /* Remote MAP, the server is within the 1st parameter */ TreeServer* s = Utils->FindServerMask(parameters[0]); bool ret = false; if (!s) { - user->WriteServ( "402 %s %s :No such server", user->nick, parameters[0]); + user->WriteServ( "402 %s %s :No such server", user->nick, parameters[0].c_str()); ret = true; } else if (s && s != Utils->TreeRoot) diff --git a/src/modules/m_spanningtree/override_modules.cpp b/src/modules/m_spanningtree/override_modules.cpp index c47d642f8..bfeb0a03c 100644 --- a/src/modules/m_spanningtree/override_modules.cpp +++ b/src/modules/m_spanningtree/override_modules.cpp @@ -33,23 +33,23 @@ /* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h */ -int ModuleSpanningTree::HandleModules(const char* const* parameters, int pcnt, User* user) +int ModuleSpanningTree::HandleModules(const std::vector<std::string>& parameters, User* user) { - if (pcnt > 0) + if (parameters.size() > 0) { - if (match(ServerInstance->Config->ServerName, parameters[0])) + if (match(ServerInstance->Config->ServerName, parameters[0].c_str())) return 0; std::deque<std::string> params; params.push_back(parameters[0]); - TreeServer* s = Utils->FindServerMask(parameters[0]); + TreeServer* s = Utils->FindServerMask(parameters[0].c_str()); if (s) { params[0] = s->GetName(); Utils->DoOneToOne(user->uuid, "MODULES", params, s->GetName()); } else - user->WriteServ( "402 %s %s :No such server", user->nick, parameters[0]); + user->WriteServ( "402 %s %s :No such server", user->nick, parameters[0].c_str()); return 1; } return 0; diff --git a/src/modules/m_spanningtree/override_motd.cpp b/src/modules/m_spanningtree/override_motd.cpp index 4aa94334a..a87042794 100644 --- a/src/modules/m_spanningtree/override_motd.cpp +++ b/src/modules/m_spanningtree/override_motd.cpp @@ -33,11 +33,11 @@ /* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h */ -int ModuleSpanningTree::HandleMotd(const char* const* parameters, int pcnt, User* user) +int ModuleSpanningTree::HandleMotd(const std::vector<std::string>& parameters, User* user) { - if (pcnt > 0) + if (parameters.size() > 0) { - if (match(ServerInstance->Config->ServerName, parameters[0])) + if (match(ServerInstance->Config->ServerName, parameters[0].c_str())) return 0; /* Remote MOTD, the server is within the 1st parameter */ @@ -51,7 +51,7 @@ int ModuleSpanningTree::HandleMotd(const char* const* parameters, int pcnt, User Utils->DoOneToOne(user->uuid, "MOTD", params, s->GetName()); } else - user->WriteServ( "402 %s %s :No such server", user->nick, parameters[0]); + user->WriteServ( "402 %s %s :No such server", user->nick, parameters[0].c_str()); return 1; } return 0; diff --git a/src/modules/m_spanningtree/override_squit.cpp b/src/modules/m_spanningtree/override_squit.cpp index 5f5eae15e..581a00ef5 100644 --- a/src/modules/m_spanningtree/override_squit.cpp +++ b/src/modules/m_spanningtree/override_squit.cpp @@ -33,14 +33,14 @@ /* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h */ -int ModuleSpanningTree::HandleSquit(const char* const* parameters, int pcnt, User* user) +int ModuleSpanningTree::HandleSquit(const std::vector<std::string>& parameters, User* user) { TreeServer* s = Utils->FindServerMask(parameters[0]); if (s) { if (s == Utils->TreeRoot) { - user->WriteServ("NOTICE %s :*** SQUIT: Foolish mortal, you cannot make a server SQUIT itself! (%s matches local server name)",user->nick,parameters[0]); + user->WriteServ("NOTICE %s :*** SQUIT: Foolish mortal, you cannot make a server SQUIT itself! (%s matches local server name)",user->nick,parameters[0].c_str()); return 1; } @@ -48,7 +48,7 @@ int ModuleSpanningTree::HandleSquit(const char* const* parameters, int pcnt, Use if (sock) { - ServerInstance->SNO->WriteToSnoMask('l',"SQUIT: Server \002%s\002 removed from network by %s",parameters[0],user->nick); + ServerInstance->SNO->WriteToSnoMask('l',"SQUIT: Server \002%s\002 removed from network by %s",parameters[0].c_str(),user->nick); sock->Squit(s,std::string("Server quit by ") + user->GetFullRealHost()); ServerInstance->SE->DelFd(sock); sock->Close(); @@ -60,7 +60,7 @@ int ModuleSpanningTree::HandleSquit(const char* const* parameters, int pcnt, Use } else { - user->WriteServ("NOTICE %s :*** SQUIT: The server \002%s\002 does not exist on the network.",user->nick,parameters[0]); + user->WriteServ("NOTICE %s :*** SQUIT: The server \002%s\002 does not exist on the network.",user->nick,parameters[0].c_str()); } return 1; } diff --git a/src/modules/m_spanningtree/override_stats.cpp b/src/modules/m_spanningtree/override_stats.cpp index ba6650d6b..169454cc6 100644 --- a/src/modules/m_spanningtree/override_stats.cpp +++ b/src/modules/m_spanningtree/override_stats.cpp @@ -33,11 +33,11 @@ /* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h */ -int ModuleSpanningTree::HandleStats(const char* const* parameters, int pcnt, User* user) +int ModuleSpanningTree::HandleStats(const std::vector<std::string>& parameters, User* user) { - if (pcnt > 1) + if (parameters.size() > 1) { - if (match(ServerInstance->Config->ServerName, parameters[1])) + if (match(ServerInstance->Config->ServerName, parameters[1].c_str())) return 0; /* Remote STATS, the server is within the 2nd parameter */ @@ -54,7 +54,7 @@ int ModuleSpanningTree::HandleStats(const char* const* parameters, int pcnt, Use } else { - user->WriteServ( "402 %s %s :No such server", user->nick, parameters[1]); + user->WriteServ( "402 %s %s :No such server", user->nick, parameters[1].c_str()); } return 1; } diff --git a/src/modules/m_spanningtree/override_time.cpp b/src/modules/m_spanningtree/override_time.cpp index 20f377979..c24e6c95d 100644 --- a/src/modules/m_spanningtree/override_time.cpp +++ b/src/modules/m_spanningtree/override_time.cpp @@ -33,11 +33,11 @@ /* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h */ -int ModuleSpanningTree::HandleTime(const char* const* parameters, int pcnt, User* user) +int ModuleSpanningTree::HandleTime(const std::vector<std::string>& parameters, User* user) { - if ((IS_LOCAL(user)) && (pcnt)) + if ((IS_LOCAL(user)) && (parameters.size() > 0)) { - TreeServer* found = Utils->FindServerMask(parameters[0]); + TreeServer* found = Utils->FindServerMask(parameters[0].c_str()); if (found) { // we dont' override for local server @@ -51,7 +51,7 @@ int ModuleSpanningTree::HandleTime(const char* const* parameters, int pcnt, User } else { - user->WriteNumeric(402, "%s %s :No such server",user->nick,parameters[0]); + user->WriteNumeric(402, "%s %s :No such server",user->nick,parameters[0].c_str()); } } return 1; diff --git a/src/modules/m_spanningtree/override_whois.cpp b/src/modules/m_spanningtree/override_whois.cpp index c846794f3..8e4d20b6f 100644 --- a/src/modules/m_spanningtree/override_whois.cpp +++ b/src/modules/m_spanningtree/override_whois.cpp @@ -33,9 +33,9 @@ /* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h */ -int ModuleSpanningTree::HandleRemoteWhois(const char* const* parameters, int pcnt, User* user) +int ModuleSpanningTree::HandleRemoteWhois(const std::vector<std::string>& parameters, User* user) { - if ((IS_LOCAL(user)) && (pcnt > 1)) + if ((IS_LOCAL(user)) && (parameters.size() > 1)) { User* remote = ServerInstance->FindNick(parameters[1]); if ((remote) && (remote->GetFd() < 0)) @@ -47,8 +47,8 @@ int ModuleSpanningTree::HandleRemoteWhois(const char* const* parameters, int pcn } else if (!remote) { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[1]); - user->WriteNumeric(318, "%s %s :End of /WHOIS list.",user->nick, parameters[1]); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[1].c_str()); + user->WriteNumeric(318, "%s %s :End of /WHOIS list.",user->nick, parameters[1].c_str()); return 1; } } diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp index d303ef322..c485afe59 100644 --- a/src/modules/m_spanningtree/postcommand.cpp +++ b/src/modules/m_spanningtree/postcommand.cpp @@ -33,9 +33,9 @@ /* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h */ -void ModuleSpanningTree::OnPostCommand(const std::string &command, const char* const* parameters, int pcnt, User *user, CmdResult result, const std::string &original_line) +void ModuleSpanningTree::OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line) { - if ((result == CMD_SUCCESS) && (ServerInstance->IsValidModuleCommand(command, pcnt, user))) + if ((result == CMD_SUCCESS) && (ServerInstance->IsValidModuleCommand(command, parameters.size(), user))) { /* Safe, we know its non-null because IsValidModuleCommand returned true */ Command* thiscmd = ServerInstance->Parser->GetHandler(command); @@ -46,14 +46,14 @@ void ModuleSpanningTree::OnPostCommand(const std::string &command, const char* c // commands and linking protocols. std::deque<std::string> params; params.clear(); - int n_translate = thiscmd->translation.size(); + unsigned int n_translate = thiscmd->translation.size(); TranslateType translate_to; /* To make sure that parameters with spaces, or empty * parameters, etc, are always sent properly, *always* * prefix the last parameter with a :. This also removes * an extra strchr() */ - for (int j = 0; j < pcnt; j++) + for (unsigned int j = 0; j < parameters.size(); j++) { std::string target; @@ -66,10 +66,10 @@ void ModuleSpanningTree::OnPostCommand(const std::string &command, const char* c else translate_to = TR_TEXT; - ServerInstance->Logs->Log("m_spanningtree",DEBUG,"TRANSLATION: %s - type is %d", parameters[j], translate_to); + ServerInstance->Logs->Log("m_spanningtree",DEBUG,"TRANSLATION: %s - type is %d", parameters[j].c_str(), translate_to); ServerInstance->Parser->TranslateUIDs(translate_to, parameters[j], target); - if (j == (pcnt - 1)) + if (j == (parameters.size() - 1)) params.push_back(":" + target); else params.push_back(target); diff --git a/src/modules/m_spanningtree/precommand.cpp b/src/modules/m_spanningtree/precommand.cpp index 64e9a90dd..2fdd9a5d5 100644 --- a/src/modules/m_spanningtree/precommand.cpp +++ b/src/modules/m_spanningtree/precommand.cpp @@ -33,7 +33,7 @@ /* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h */ -int ModuleSpanningTree::OnPreCommand(const std::string &command, const char* const* parameters, int pcnt, User *user, bool validated, const std::string &original_line) +int ModuleSpanningTree::OnPreCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line) { /* If the command doesnt appear to be valid, we dont want to mess with it. */ if (!validated) @@ -41,58 +41,58 @@ int ModuleSpanningTree::OnPreCommand(const std::string &command, const char* con if (command == "CONNECT") { - return this->HandleConnect(parameters,pcnt,user); + return this->HandleConnect(parameters,user); } else if (command == "STATS") { - return this->HandleStats(parameters,pcnt,user); + return this->HandleStats(parameters,user); } else if (command == "MOTD") { - return this->HandleMotd(parameters,pcnt,user); + return this->HandleMotd(parameters,user); } else if (command == "ADMIN") { - return this->HandleAdmin(parameters,pcnt,user); + return this->HandleAdmin(parameters,user); } else if (command == "SQUIT") { - return this->HandleSquit(parameters,pcnt,user); + return this->HandleSquit(parameters,user); } else if (command == "MAP") { - return this->HandleMap(parameters,pcnt,user); + return this->HandleMap(parameters,user); } - else if ((command == "TIME") && (pcnt > 0)) + else if ((command == "TIME") && (parameters.size() > 0)) { - return this->HandleTime(parameters,pcnt,user); + return this->HandleTime(parameters,user); } else if (command == "LUSERS") { - this->HandleLusers(parameters,pcnt,user); + this->HandleLusers(parameters,user); return 1; } else if (command == "LINKS") { - this->HandleLinks(parameters,pcnt,user); + this->HandleLinks(parameters,user); return 1; } else if (command == "WHOIS") { - if (pcnt > 1) + if (parameters.size() > 1) { // remote whois - return this->HandleRemoteWhois(parameters,pcnt,user); + return this->HandleRemoteWhois(parameters,user); } } - else if ((command == "VERSION") && (pcnt > 0)) + else if ((command == "VERSION") && (parameters.size() > 0)) { - this->HandleVersion(parameters,pcnt,user); + this->HandleVersion(parameters,user); return 1; } - else if ((command == "MODULES") && (pcnt > 0)) + else if ((command == "MODULES") && (parameters.size() > 0)) { - return this->HandleModules(parameters,pcnt,user); + return this->HandleModules(parameters,user); } return 0; } diff --git a/src/modules/m_spanningtree/rconnect.cpp b/src/modules/m_spanningtree/rconnect.cpp index 32308377a..388f77ab7 100644 --- a/src/modules/m_spanningtree/rconnect.cpp +++ b/src/modules/m_spanningtree/rconnect.cpp @@ -36,27 +36,27 @@ cmd_rconnect::cmd_rconnect (InspIRCd* Instance, Module* Callback, SpanningTreeUt syntax = "<remote-server-mask> <target-server-mask>"; } -CmdResult cmd_rconnect::Handle (const char* const* parameters, int pcnt, User *user) +CmdResult cmd_rconnect::Handle (const std::vector<std::string>& parameters, User *user) { if (IS_LOCAL(user)) { if (!Utils->FindServerMask(parameters[0])) { - user->WriteServ("NOTICE %s :*** RCONNECT: Server \002%s\002 isn't connected to the network!", user->nick, parameters[0]); + user->WriteServ("NOTICE %s :*** RCONNECT: Server \002%s\002 isn't connected to the network!", user->nick, parameters[0].c_str()); return CMD_FAILURE; } - user->WriteServ("NOTICE %s :*** RCONNECT: Sending remote connect to \002%s\002 to connect server \002%s\002.",user->nick,parameters[0],parameters[1]); + user->WriteServ("NOTICE %s :*** RCONNECT: Sending remote connect to \002%s\002 to connect server \002%s\002.",user->nick,parameters[0].c_str(),parameters[1].c_str()); } /* Is this aimed at our server? */ if (ServerInstance->MatchText(ServerInstance->Config->ServerName,parameters[0])) { /* Yes, initiate the given connect */ - ServerInstance->SNO->WriteToSnoMask('l',"Remote CONNECT from %s matching \002%s\002, connecting server \002%s\002",user->nick,parameters[0],parameters[1]); - const char* para[1]; - para[0] = parameters[1]; + ServerInstance->SNO->WriteToSnoMask('l',"Remote CONNECT from %s matching \002%s\002, connecting server \002%s\002",user->nick,parameters[0].c_str(),parameters[1].c_str()); + std::vector<std::string> para(1); + para.push_back(parameters[1]); std::string original_command = std::string("CONNECT ") + parameters[1]; - Creator->OnPreCommand("CONNECT", para, 1, user, true, original_command); + Creator->OnPreCommand("CONNECT", para, user, true, original_command); } return CMD_SUCCESS; } diff --git a/src/modules/m_spanningtree/rconnect.h b/src/modules/m_spanningtree/rconnect.h index 94035dce2..b29bea550 100644 --- a/src/modules/m_spanningtree/rconnect.h +++ b/src/modules/m_spanningtree/rconnect.h @@ -22,7 +22,7 @@ class cmd_rconnect : public Command SpanningTreeUtilities* Utils; /* Utility class */ public: cmd_rconnect (InspIRCd* Instance, Module* Callback, SpanningTreeUtilities* Util); - CmdResult Handle (const char* const* parameters, int pcnt, User *user); + CmdResult Handle (const std::vector<std::string>& parameters, User *user); }; #endif diff --git a/src/modules/m_spanningtree/rsquit.cpp b/src/modules/m_spanningtree/rsquit.cpp index 0b3844f06..2a906dfe0 100644 --- a/src/modules/m_spanningtree/rsquit.cpp +++ b/src/modules/m_spanningtree/rsquit.cpp @@ -36,7 +36,7 @@ cmd_rsquit::cmd_rsquit (InspIRCd* Instance, Module* Callback, SpanningTreeUtilit syntax = "<target-server-mask> [reason]"; } -CmdResult cmd_rsquit::Handle (const char* const* parameters, int pcnt, User *user) +CmdResult cmd_rsquit::Handle (const std::vector<std::string>& parameters, User *user) { TreeServer *server_target; // Server to squit TreeServer *server_linked; // Server target is linked to @@ -44,13 +44,13 @@ CmdResult cmd_rsquit::Handle (const char* const* parameters, int pcnt, User *use server_target = Utils->FindServerMask(parameters[0]); if (!server_target) { - user->WriteServ("NOTICE %s :*** RSQUIT: Server \002%s\002 isn't connected to the network!", user->nick, parameters[0]); + user->WriteServ("NOTICE %s :*** RSQUIT: Server \002%s\002 isn't connected to the network!", user->nick, parameters[0].c_str()); return CMD_FAILURE; } if (server_target == Utils->TreeRoot) { - NoticeUser(user, "*** RSQUIT: Foolish mortal, you cannot make a server SQUIT itself! ("+ConvToStr(parameters[0])+" matches local server name)"); + NoticeUser(user, "*** RSQUIT: Foolish mortal, you cannot make a server SQUIT itself! ("+parameters[0]+" matches local server name)"); return CMD_FAILURE; } @@ -62,8 +62,8 @@ CmdResult cmd_rsquit::Handle (const char* const* parameters, int pcnt, User *use TreeSocket* sock = server_target->GetSocket(); if (sock) { - const char *reason = pcnt == 2 ? parameters[1] : "No reason"; - ServerInstance->SNO->WriteToSnoMask('l',"RSQUIT: Server \002%s\002 removed from network by %s (%s)", parameters[0], user->nick, reason); + const char *reason = parameters.size() == 2 ? parameters[1].c_str() : "No reason"; + ServerInstance->SNO->WriteToSnoMask('l',"RSQUIT: Server \002%s\002 removed from network by %s (%s)", parameters[0].c_str(), user->nick, reason); sock->Squit(server_target, std::string("Server quit by ") + user->GetFullRealHost() + " (" + reason + ")"); ServerInstance->SE->DelFd(sock); sock->Close(); diff --git a/src/modules/m_spanningtree/rsquit.h b/src/modules/m_spanningtree/rsquit.h index 5dce2f310..eb4ae5f5b 100644 --- a/src/modules/m_spanningtree/rsquit.h +++ b/src/modules/m_spanningtree/rsquit.h @@ -22,7 +22,7 @@ class cmd_rsquit : public Command SpanningTreeUtilities* Utils; /* Utility class */ public: cmd_rsquit (InspIRCd* Instance, Module* Callback, SpanningTreeUtilities* Util); - CmdResult Handle (const char* const* parameters, int pcnt, User *user); + CmdResult Handle (const std::vector<std::string>& parameters, User *user); void NoticeUser(User* user, const std::string &msg); }; diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 3cd2f8920..915158f8d 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -366,10 +366,8 @@ bool TreeSocket::ProcessLine(std::string &line) User* user = Instance->FindNick(prefix); if (user) { - const char* ptrs[127]; - for (size_t n = 0; (n < params.size()) && (n < 127); ++n) - ptrs[n] = params[n].c_str(); - return Utils->Creator->HandleMap(ptrs, params.size(), user); + std::vector<std::string> p(params.begin(), params.end()); + return Utils->Creator->HandleMap(p, user); } } else if (command == "SERVER") @@ -549,9 +547,7 @@ bool TreeSocket::ProcessLine(std::string &line) else if (command == "MODE") { // Server-prefix MODE. - const char* modelist[MAXPARAMETERS]; - for (size_t i = 0; i < params.size(); i++) - modelist[i] = params[i].c_str(); + std::vector<std::string> modelist(params.begin(), params.end()); /* We don't support this for channel mode changes any more! */ if (params.size() >= 1) @@ -564,7 +560,7 @@ bool TreeSocket::ProcessLine(std::string &line) } // Insert into the parser - this->Instance->SendMode(modelist, params.size(), this->Instance->FakeClient); + this->Instance->SendMode(modelist, this->Instance->FakeClient); // Pass out to the network return Utils->DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params); @@ -617,13 +613,9 @@ bool TreeSocket::ProcessLine(std::string &line) } // its a user - const char* strparams[127]; - for (unsigned int q = 0; q < params.size(); q++) - { - strparams[q] = params[q].c_str(); - } + std::vector<std::string> strparams(params.begin(), params.end()); - switch (this->Instance->CallCommandHandler(command.c_str(), strparams, params.size(), who)) + switch (this->Instance->CallCommandHandler(command.c_str(), strparams, who)) { case CMD_INVALID: /* |