diff options
author | attilamolnar <attilamolnar@hush.com> | 2012-07-04 21:34:13 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-04-12 21:03:04 +0200 |
commit | f4cd5fb72ad191a3708d3d39a4fc74cc1ae4377e (patch) | |
tree | 46024e82c3dd201423e102bd7efe4f7a33524048 /src | |
parent | 9c2e2ef9d24c348f42261d32f424ad04865b19ef (diff) |
m_spanningtree atoi() to ConvToInt() conversion, add const where possible
Remove two redundant functions from Utils
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_spanningtree/addline.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/away.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/capab.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/ftopic.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/opertype.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/ping.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_spanningtree/pong.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/server.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/svsnick.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket2.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 18 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.h | 12 |
12 files changed, 19 insertions, 42 deletions
diff --git a/src/modules/m_spanningtree/addline.cpp b/src/modules/m_spanningtree/addline.cpp index 7ee1a7ef1..a43112ce9 100644 --- a/src/modules/m_spanningtree/addline.cpp +++ b/src/modules/m_spanningtree/addline.cpp @@ -57,14 +57,14 @@ bool TreeSocket::AddLine(const std::string &prefix, parameterlist ¶ms) XLine* xl = NULL; try { - xl = xlf->Generate(ServerInstance->Time(), atoi(params[4].c_str()), params[2], params[5], params[1]); + xl = xlf->Generate(ServerInstance->Time(), ConvToInt(params[4]), params[2], params[5], params[1]); } catch (ModuleException &e) { ServerInstance->SNO->WriteToSnoMask('d',"Unable to ADDLINE type %s from %s: %s", params[0].c_str(), setter.c_str(), e.GetReason()); return true; } - xl->SetCreateTime(atoi(params[3].c_str())); + xl->SetCreateTime(ConvToInt(params[3])); if (ServerInstance->XLines->AddLine(xl, NULL)) { if (xl->duration) diff --git a/src/modules/m_spanningtree/away.cpp b/src/modules/m_spanningtree/away.cpp index ed97c48cd..a36c202c7 100644 --- a/src/modules/m_spanningtree/away.cpp +++ b/src/modules/m_spanningtree/away.cpp @@ -34,7 +34,7 @@ bool TreeSocket::Away(const std::string &prefix, parameterlist ¶ms) FOREACH_MOD(I_OnSetAway, OnSetAway(u, params[params.size() - 1])); if (params.size() > 1) - u->awaytime = atoi(params[0].c_str()); + u->awaytime = ConvToInt(params[0]); else u->awaytime = ServerInstance->Time(); diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp index f36692a54..8592beec0 100644 --- a/src/modules/m_spanningtree/capab.cpp +++ b/src/modules/m_spanningtree/capab.cpp @@ -194,7 +194,7 @@ bool TreeSocket::Capab(const parameterlist ¶ms) capab->OptModuleList.clear(); capab->CapKeys.clear(); if (params.size() > 1) - proto_version = atoi(params[1].c_str()); + proto_version = ConvToInt(params[1]); SendCapabilities(2); } else if (params[0] == "END") @@ -248,7 +248,7 @@ bool TreeSocket::Capab(const parameterlist ¶ms) } else { - proto_version = atoi(capab->CapKeys.find("PROTOCOL")->second.c_str()); + proto_version = ConvToInt(capab->CapKeys.find("PROTOCOL")->second); if (proto_version < MinCompatProtocol) { reason = "Server is using protocol version " + ConvToStr(proto_version) + diff --git a/src/modules/m_spanningtree/ftopic.cpp b/src/modules/m_spanningtree/ftopic.cpp index d559c6ae5..4e57715f3 100644 --- a/src/modules/m_spanningtree/ftopic.cpp +++ b/src/modules/m_spanningtree/ftopic.cpp @@ -28,7 +28,7 @@ /** FTOPIC command */ CmdResult CommandFTopic::Handle(const std::vector<std::string>& params, User *user) { - time_t ts = atoi(params[1].c_str()); + time_t ts = ConvToInt(params[1]); Channel* c = ServerInstance->FindChan(params[0]); if (c) { diff --git a/src/modules/m_spanningtree/opertype.cpp b/src/modules/m_spanningtree/opertype.cpp index 27c4271b8..4772e9222 100644 --- a/src/modules/m_spanningtree/opertype.cpp +++ b/src/modules/m_spanningtree/opertype.cpp @@ -29,7 +29,7 @@ CmdResult CommandOpertype::Handle(const std::vector<std::string>& params, User *u) { SpanningTreeUtilities* Utils = ((ModuleSpanningTree*)(Module*)creator)->Utils; - std::string opertype = params[0]; + const std::string& opertype = params[0]; if (!u->IsOper()) ServerInstance->Users->all_opers.push_back(u); u->modes[UM_OPERATOR] = 1; diff --git a/src/modules/m_spanningtree/ping.cpp b/src/modules/m_spanningtree/ping.cpp index aec680b23..3e05e6906 100644 --- a/src/modules/m_spanningtree/ping.cpp +++ b/src/modules/m_spanningtree/ping.cpp @@ -35,13 +35,12 @@ bool TreeSocket::LocalPing(const std::string &prefix, parameterlist ¶ms) return true; if (params.size() == 1) { - std::string stufftobounce = params[0]; - this->WriteLine(":"+ServerInstance->Config->GetSID()+" PONG "+stufftobounce); + this->WriteLine(":"+ServerInstance->Config->GetSID()+" PONG "+params[0]); return true; } else { - std::string forwardto = params[1]; + const std::string& forwardto = params[1]; if (forwardto == ServerInstance->Config->ServerName || forwardto == ServerInstance->Config->GetSID()) { // this is a ping for us, send back PONG to the requesting server diff --git a/src/modules/m_spanningtree/pong.cpp b/src/modules/m_spanningtree/pong.cpp index 5966d05d9..0e36c16e3 100644 --- a/src/modules/m_spanningtree/pong.cpp +++ b/src/modules/m_spanningtree/pong.cpp @@ -46,7 +46,7 @@ bool TreeSocket::LocalPong(const std::string &prefix, parameterlist ¶ms) } else { - std::string forwardto = params[1]; + const std::string& forwardto = params[1]; if (forwardto == ServerInstance->Config->GetSID() || forwardto == ServerInstance->Config->ServerName) { /* diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp index d266b31f4..bc97c097b 100644 --- a/src/modules/m_spanningtree/server.cpp +++ b/src/modules/m_spanningtree/server.cpp @@ -105,7 +105,7 @@ bool TreeSocket::Outbound_Reply_Server(parameterlist ¶ms) std::string password = params[1]; std::string sid = params[3]; std::string description = params[4]; - int hops = atoi(params[2].c_str()); + int hops = ConvToInt(params[2]); this->SendCapabilities(2); @@ -197,7 +197,7 @@ bool TreeSocket::Inbound_Server(parameterlist ¶ms) std::string password = params[1]; std::string sid = params[3]; std::string description = params[4]; - int hops = atoi(params[2].c_str()); + int hops = ConvToInt(params[2]); this->SendCapabilities(2); diff --git a/src/modules/m_spanningtree/svsnick.cpp b/src/modules/m_spanningtree/svsnick.cpp index 79dc27ea3..1caf67927 100644 --- a/src/modules/m_spanningtree/svsnick.cpp +++ b/src/modules/m_spanningtree/svsnick.cpp @@ -44,7 +44,7 @@ CmdResult CommandSVSNick::Handle(const std::vector<std::string>& parameters, Use } } - u->age = atoi(parameters[2].c_str()); + u->age = ConvToInt(parameters[2]); } return CMD_SUCCESS; diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index e2eb31f0d..b7f28b552 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -151,7 +151,7 @@ void TreeSocket::ProcessLine(std::string &line) { if (params.size()) { - time_t them = atoi(params[0].c_str()); + time_t them = ConvToInt(params[0]); time_t delta = them - ServerInstance->Time(); if ((delta < -600) || (delta > 600)) { @@ -427,7 +427,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, } /* Update timestamp on user when they change nicks */ - who->age = atoi(params[1].c_str()); + who->age = ConvToInt(params[1]); /* * On nick messages, check that the nick doesnt already exist here. diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 1517ac1b9..076d07470 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -202,7 +202,7 @@ void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeServerLis return; } -bool SpanningTreeUtilities::DoOneToAllButSender(const std::string &prefix, const std::string &command, const parameterlist ¶ms, std::string omit) +bool SpanningTreeUtilities::DoOneToAllButSender(const std::string& prefix, const std::string& command, const parameterlist& params, const std::string& omit) { TreeServer* omitroute = this->BestRouteTo(omit); std::string FullLine = ":" + prefix + " " + command; @@ -251,21 +251,7 @@ bool SpanningTreeUtilities::DoOneToMany(const std::string &prefix, const std::st return true; } -bool SpanningTreeUtilities::DoOneToMany(const char* prefix, const char* command, const parameterlist ¶ms) -{ - std::string spfx = prefix; - std::string scmd = command; - return this->DoOneToMany(spfx, scmd, params); -} - -bool SpanningTreeUtilities::DoOneToAllButSender(const char* prefix, const char* command, const parameterlist ¶ms, std::string omit) -{ - std::string spfx = prefix; - std::string scmd = command; - return this->DoOneToAllButSender(spfx, scmd, params, omit); -} - -bool SpanningTreeUtilities::DoOneToOne(const std::string &prefix, const std::string &command, const parameterlist ¶ms, std::string target) +bool SpanningTreeUtilities::DoOneToOne(const std::string& prefix, const std::string& command, const parameterlist& params, const std::string& target) { TreeServer* Route = this->BestRouteTo(target); if (Route) diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index fed90c253..8b73359c3 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -124,24 +124,16 @@ class SpanningTreeUtilities : public classbase /** Send a message from this server to one other local or remote */ - bool DoOneToOne(const std::string &prefix, const std::string &command, const parameterlist ¶ms, std::string target); + bool DoOneToOne(const std::string& prefix, const std::string& command, const parameterlist& params, const std::string& target); /** Send a message from this server to all but one other, local or remote */ - bool DoOneToAllButSender(const std::string &prefix, const std::string &command, const parameterlist ¶ms, std::string omit); - - /** Send a message from this server to all but one other, local or remote - */ - bool DoOneToAllButSender(const char* prefix, const char* command, const parameterlist ¶ms, std::string omit); + bool DoOneToAllButSender(const std::string &prefix, const std::string &command, const parameterlist& params, const std::string& omit); /** Send a message from this server to all others */ bool DoOneToMany(const std::string &prefix, const std::string &command, const parameterlist ¶ms); - /** Send a message from this server to all others - */ - bool DoOneToMany(const char* prefix, const char* command, const parameterlist ¶ms); - /** Read the spanningtree module's tags from the config file */ void ReadConfiguration(); |