]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree.cpp
Fix test client error cheecking on result types
[user/henk/code/inspircd.git] / src / modules / m_spanningtree.cpp
index c632fa540bc46f27218d00bc3bc1897edd4952f4..22c9e92461acb262156cff05da6f2b3806363209 100644 (file)
@@ -41,11 +41,7 @@ using namespace std;
 #include "cull_list.h"
 #include "aes.h"
 
-#ifdef GCC3
 #define nspace __gnu_cxx
-#else
-#define nspace std
-#endif
 
 /*
  * The server list in InspIRCd is maintained as two structures
@@ -167,8 +163,6 @@ class TreeServer : public classbase
        TreeSocket* Socket;                     /* For directly connected servers this points at the socket object */
        time_t NextPing;                        /* After this time, the server should be PINGed*/
        bool LastPingWasGood;                   /* True if the server responded to the last PING with a PONG */
-       std::map<userrec*,userrec*> Users;      /* Users on this server */
-       bool DontModifyHash;                    /* When the server is splitting, this is set to true so we dont bash our own iterator to death */
        
  public:
 
@@ -183,7 +177,6 @@ class TreeServer : public classbase
                VersionString = "";
                UserCount = OperCount = 0;
                VersionString = Srv->GetVersion();
-               DontModifyHash = false;
        }
 
        /* We use this constructor only to create the 'root' item, TreeRoot, which
@@ -198,7 +191,6 @@ class TreeServer : public classbase
                VersionString = Srv->GetVersion();
                Route = NULL;
                Socket = NULL; /* Fix by brain */
-               DontModifyHash = false;
                AddHashEntry();
        }
 
@@ -210,7 +202,6 @@ class TreeServer : public classbase
        {
                VersionString = "";
                UserCount = OperCount = 0;
-               DontModifyHash = false;
                this->SetNextPingTime(time(NULL) + 120);
                this->SetPingFlag();
 
@@ -270,24 +261,24 @@ class TreeServer : public classbase
 
        int QuitUsers(const std::string &reason)
        {
-                log(DEBUG,"Removing all users from server %s",this->ServerName.c_str());
-                const char* reason_s = reason.c_str();
-                std::vector<userrec*> time_to_die;
-                for (user_hash::iterator n = clientlist.begin(); n != clientlist.end(); n++)
-                {
-                        if (!strcmp(n->second->server, this->ServerName.c_str()))
-                        {
-                                time_to_die.push_back(n->second);
-                        }
-                }
-                for (std::vector<userrec*>::iterator n = time_to_die.begin(); n != time_to_die.end(); n++)
-                {
-                        userrec* a = (userrec*)*n;
-                        log(DEBUG,"Kill %s fd=%d",a->nick,a->fd);
-                        if (!IS_LOCAL(a))
-                                kill_link(a,reason_s);
-                }
-                return time_to_die.size();
+               log(DEBUG,"Removing all users from server %s",this->ServerName.c_str());
+               const char* reason_s = reason.c_str();
+               std::vector<userrec*> time_to_die;
+               for (user_hash::iterator n = clientlist.begin(); n != clientlist.end(); n++)
+               {
+                       if (!strcmp(n->second->server, this->ServerName.c_str()))
+                       {
+                               time_to_die.push_back(n->second);
+                       }
+               }
+               for (std::vector<userrec*>::iterator n = time_to_die.begin(); n != time_to_die.end(); n++)
+               {
+                       userrec* a = (userrec*)*n;
+                       log(DEBUG,"Kill %s fd=%d",a->nick,a->fd);
+                       if (!IS_LOCAL(a))
+                               kill_link(a,reason_s);
+               }
+               return time_to_die.size();
        }
 
        /* This method is used to add the structure to the
@@ -564,9 +555,9 @@ class cmd_rconnect : public command_t
        cmd_rconnect (Module* Callback) : command_t("RCONNECT", 'o', 2), Creator(Callback)
        {
                this->source = "m_spanningtree.so";
-       }                
+       }
 
-       void Handle (char **parameters, int pcnt, userrec *user)
+       void Handle (const char** parameters, int pcnt, userrec *user)
        {
                WriteServ(user->fd,"NOTICE %s :*** RCONNECT: Sending remote connect to \002%s\002 to connect server \002%s\002.",user->nick,parameters[0],parameters[1]);
                /* Is this aimed at our server? */
@@ -574,7 +565,7 @@ class cmd_rconnect : public command_t
                {
                        /* Yes, initiate the given connect */
                        WriteOpers("*** Remote CONNECT from %s matching \002%s\002, connecting server \002%s\002",user->nick,parameters[0],parameters[1]);
-                       char* para[1];
+                       const char* para[1];
                        para[0] = parameters[1];
                        Creator->OnPreCommand("CONNECT", para, 1, user, true);
                }
@@ -897,7 +888,7 @@ class TreeSocket : public InspSocket
                        return true;
                userrec* who = new userrec();
                who->fd = FD_MAGIC_NUMBER;
-               char* modelist[64];
+               const char* modelist[64];
                memset(&modelist,0,sizeof(modelist));
                for (unsigned int q = 0; q < params.size(); q++)
                {
@@ -965,7 +956,7 @@ class TreeSocket : public InspSocket
                memset(&mode_users,0,sizeof(mode_users));
                mode_users[0] = first;
                mode_users[1] = modestring;
-               strcpy(mode_users[1],"+");
+               strcpy(first,"+");
                unsigned int modectr = 2;
                
                userrec* who = NULL;
@@ -1000,7 +991,7 @@ class TreeSocket : public InspSocket
                for (unsigned int usernum = 2; usernum < params.size(); usernum++)
                {
                        /* process one channel at a time, applying modes. */
-                       char* usr = const_cast<char*>(params[usernum].c_str());
+                       char* usr = (char*)params[usernum].c_str();
                        /* Safety check just to make sure someones not sent us an FJOIN full of spaces
                         * (is this even possible?) */
                        if (usr && *usr)
@@ -1037,7 +1028,7 @@ class TreeSocket : public InspSocket
                                                {
                                                        /* We also always let u-lined clients win, no matter what the TS value */
                                                        log(DEBUG,"Our our channel newer than theirs, accepting their modes");
-                                                       Srv->SendMode(mode_users,modectr,who);
+                                                       Srv->SendMode((const char**)mode_users,modectr,who);
                                                }
                                                else
                                                {
@@ -1067,7 +1058,7 @@ class TreeSocket : public InspSocket
                        if (ourTS >= TS)
                        {
                                log(DEBUG,"Our our channel newer than theirs, accepting their modes");
-                               Srv->SendMode(mode_users,modectr,who);
+                               Srv->SendMode((const char**)mode_users,modectr,who);
                        }
                        else
                        {
@@ -2564,10 +2555,10 @@ class TreeSocket : public InspSocket
                                                }
                                                // its a user
                                                target = who->server;
-                                               char* strparams[127];
+                                               const char* strparams[127];
                                                for (unsigned int q = 0; q < params.size(); q++)
                                                {
-                                                       strparams[q] = (char*)params[q].c_str();
+                                                       strparams[q] = params[q].c_str();
                                                }
                                                if (!Srv->CallCommandHandler(command.c_str(), strparams, params.size(), who))
                                                {
@@ -2979,14 +2970,14 @@ class ModuleSpanningTree : public Module
                return serverlist.size();
        }
 
-       void HandleLinks(char** parameters, int pcnt, userrec* user)
+       void HandleLinks(const char** parameters, int pcnt, userrec* user)
        {
                ShowLinks(TreeRoot,user,0);
                WriteServ(user->fd,"365 %s * :End of /LINKS list.",user->nick);
                return;
        }
 
-       void HandleLusers(char** parameters, int pcnt, userrec* user)
+       void HandleLusers(const char** parameters, int pcnt, userrec* user)
        {
                unsigned int n_users = usercnt();
 
@@ -3071,7 +3062,7 @@ class ModuleSpanningTree : public Module
        // (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.
 
-       void HandleMap(char** parameters, int pcnt, userrec* user)
+       void HandleMap(const char** parameters, int pcnt, userrec* user)
        {
                // This array represents a virtual screen which we will
                // "scratch" draw to, as the console device of an irc
@@ -3127,7 +3118,7 @@ class ModuleSpanningTree : public Module
                return;
        }
 
-       int HandleSquit(char** parameters, int pcnt, userrec* user)
+       int HandleSquit(const char** parameters, int pcnt, userrec* user)
        {
                TreeServer* s = FindServerMask(parameters[0]);
                if (s)
@@ -3157,7 +3148,7 @@ class ModuleSpanningTree : public Module
                return 1;
        }
 
-       int HandleTime(char** parameters, int pcnt, userrec* user)
+       int HandleTime(const char** parameters, int pcnt, userrec* user)
        {
                if ((user->fd > -1) && (pcnt))
                {
@@ -3181,7 +3172,7 @@ class ModuleSpanningTree : public Module
                return 1;
        }
 
-       int HandleRemoteWhois(char** parameters, int pcnt, userrec* user)
+       int HandleRemoteWhois(const char** parameters, int pcnt, userrec* user)
        {
                if ((user->fd > -1) && (pcnt > 1))
                {
@@ -3259,7 +3250,7 @@ class ModuleSpanningTree : public Module
                }
        }
 
-       int HandleVersion(char** parameters, int pcnt, userrec* user)
+       int HandleVersion(const char** parameters, int pcnt, userrec* user)
        {
                // we've already checked if pcnt > 0, so this is safe
                TreeServer* found = FindServerMask(parameters[0]);
@@ -3296,7 +3287,7 @@ class ModuleSpanningTree : public Module
                return 1;
        }
        
-       int HandleConnect(char** parameters, int pcnt, userrec* user)
+       int HandleConnect(const char** parameters, int pcnt, userrec* user)
        {
                for (std::vector<Link>::iterator x = LinkBlocks.begin(); x < LinkBlocks.end(); x++)
                {
@@ -3345,7 +3336,7 @@ class ModuleSpanningTree : public Module
                return 0;
        }
 
-       virtual int OnPreCommand(const std::string &command, char **parameters, int pcnt, userrec *user, bool validated)
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
        {
                /* If the command doesnt appear to be valid, we dont want to mess with it. */
                if (!validated)