]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_spanningtree atoi() to ConvToInt() conversion, add const where possible
authorattilamolnar <attilamolnar@hush.com>
Wed, 4 Jul 2012 19:34:13 +0000 (21:34 +0200)
committerattilamolnar <attilamolnar@hush.com>
Fri, 12 Apr 2013 19:03:04 +0000 (21:03 +0200)
Remove two redundant functions from Utils

12 files changed:
src/modules/m_spanningtree/addline.cpp
src/modules/m_spanningtree/away.cpp
src/modules/m_spanningtree/capab.cpp
src/modules/m_spanningtree/ftopic.cpp
src/modules/m_spanningtree/opertype.cpp
src/modules/m_spanningtree/ping.cpp
src/modules/m_spanningtree/pong.cpp
src/modules/m_spanningtree/server.cpp
src/modules/m_spanningtree/svsnick.cpp
src/modules/m_spanningtree/treesocket2.cpp
src/modules/m_spanningtree/utils.cpp
src/modules/m_spanningtree/utils.h

index 7ee1a7ef1b0d5d57882d50aa1b2da96957d35f13..a43112ce97e0316be0b11c6c7816f5debe13769e 100644 (file)
@@ -57,14 +57,14 @@ bool TreeSocket::AddLine(const std::string &prefix, parameterlist &params)
        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)
index ed97c48cdfe7c9e49b055cd8c943fa9d79d0935b..a36c202c74967dec1df46f870705b391e560be57 100644 (file)
@@ -34,7 +34,7 @@ bool TreeSocket::Away(const std::string &prefix, parameterlist &params)
                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();
 
index f36692a542959636fcc45629bf0947e688831100..8592beec0999f16a064639c1dcbe5ced3ee25357 100644 (file)
@@ -194,7 +194,7 @@ bool TreeSocket::Capab(const parameterlist &params)
                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 &params)
                }
                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) +
index d559c6ae5c642bb3ba8f23bd9f03c489a390f443..4e57715f3d6caf826038068074f80b459de2cab5 100644 (file)
@@ -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)
        {
index 27c4271b8ac51acc03f480fe88f5dd8e09af2500..4772e92221fe7d8bb9e0e34089a8839811c7a3f8 100644 (file)
@@ -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;
index aec680b231c1cdb75971919a1e6583cdd2990816..3e05e6906cf7fbd7cb9526e1e206c109a143013d 100644 (file)
@@ -35,13 +35,12 @@ bool TreeSocket::LocalPing(const std::string &prefix, parameterlist &params)
                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
index 5966d05d9f953ed90b7667fc67bfcdabf2da92eb..0e36c16e3230890746bf13e9e74d36a2fe3d84d4 100644 (file)
@@ -46,7 +46,7 @@ bool TreeSocket::LocalPong(const std::string &prefix, parameterlist &params)
        }
        else
        {
-               std::string forwardto = params[1];
+               const std::string& forwardto = params[1];
                if (forwardto == ServerInstance->Config->GetSID() || forwardto == ServerInstance->Config->ServerName)
                {
                        /*
index d266b31f41d1ec5ab6a68a57e34ee9eab28b470e..bc97c097b2d8c2ae9b3a0f780c5d4cd14816196f 100644 (file)
@@ -105,7 +105,7 @@ bool TreeSocket::Outbound_Reply_Server(parameterlist &params)
        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 &params)
        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);
 
index 79dc27ea32bad0d277031352459389b8168ef65d..1caf679271a231cbc52a259c2d4466cc041374f2 100644 (file)
@@ -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;
index e2eb31f0d25505ab9c5b8a756747a64940cfc6b1..b7f28b55270b1e4dc3cbe16bf90dcef4e9f10079 100644 (file)
@@ -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.
index 1517ac1b97735bc3c6cf0334244123fa5bd773bc..076d074706232f8f83888cd14320168b397a7bb8 100644 (file)
@@ -202,7 +202,7 @@ void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeServerLis
        return;
 }
 
-bool SpanningTreeUtilities::DoOneToAllButSender(const std::string &prefix, const std::string &command, const parameterlist &params, 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 &params)
-{
-       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 &params, 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 &params, 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)
index fed90c253311b6511bcd0ac0d421d4a84ffaec91..8b73359c380c77936444320e9cd7f1e4372a8c34 100644 (file)
@@ -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 &params, 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 &params, 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 &params, 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 &params);
 
-       /** Send a message from this server to all others
-        */
-       bool DoOneToMany(const char* prefix, const char* command, const parameterlist &params);
-
        /** Read the spanningtree module's tags from the config file
         */
        void ReadConfiguration();