]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules.cpp
Remove an extern, partly because it's unused, partly because it then gets shadowed...
[user/henk/code/inspircd.git] / src / modules.cpp
index 680bd950afc37b650afd2a35f922c8abd5f064dc..223b1fe3001b46fba98b630d72d94a5862c79213 100644 (file)
  * ---------------------------------------------------
  */
 
-using namespace std;
-
 #include "inspircd_config.h"
 #include "inspircd.h"
-#include "inspircd_io.h"
+#include "configreader.h"
 #include <unistd.h>
 #include <sys/errno.h>
 #include <time.h>
 #include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
 #include <map>
 #include <sstream>
 #include <vector>
@@ -54,17 +47,18 @@ using namespace std;
 extern ServerConfig *Config;
 extern InspIRCd* ServerInstance;
 extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
+extern ModuleList modules;
+extern FactoryList factory;
 extern std::vector<InspSocket*> module_sockets;
 extern std::vector<userrec*> local_users;
 extern time_t TIME;
-class Server;
 extern userrec* fd_ref_table[MAX_DESCRIPTORS];
-
 extern user_hash clientlist;
 extern chan_hash chanlist;
 extern command_table cmdlist;
+
+class Server;
+
 ExtModeList EMode;
 
 // returns true if an extended mode character is in use
@@ -324,12 +318,12 @@ void Server::AddSocket(InspSocket* sock)
 
 void Server::RemoveSocket(InspSocket* sock)
 {
-        for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++)
-        {
-                InspSocket* s = (InspSocket*)*a;
-                if (s == sock)
+       for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++)
+       {
+               InspSocket* s = (InspSocket*)*a;
+               if (s == sock)
                        s->MarkAsClosed();
-        }
+       }
 }
 
 long Server::PriorityAfter(const std::string &modulename)
@@ -704,8 +698,8 @@ bool Server::UserToPseudo(userrec* user, const std::string &message)
        }
 
        ServerInstance->SE->DelFd(old_fd);
-        shutdown(old_fd,2);
-        close(old_fd);
+       shutdown(old_fd,2);
+       close(old_fd);
        return true;
 }
 
@@ -722,29 +716,29 @@ bool Server::PseudoToUser(userrec* alive, userrec* zombie, const std::string &me
        std::string oldhost = alive->host;
        std::string oldident = alive->ident;
        kill_link(alive,message.c_str());
-        if (find(local_users.begin(),local_users.end(),alive) != local_users.end())
-        {
+       if (find(local_users.begin(),local_users.end(),alive) != local_users.end())
+       {
                local_users.erase(find(local_users.begin(),local_users.end(),alive));
                log(DEBUG,"Delete local user");
-        }
+       }
        // Fix by brain - cant write the user until their fd table entry is updated
        fd_ref_table[zombie->fd] = zombie;
        Write(zombie->fd,":%s!%s@%s NICK %s",oldnick.c_str(),oldident.c_str(),oldhost.c_str(),zombie->nick);
-        for (std::vector<ucrec*>::const_iterator i = zombie->chans.begin(); i != zombie->chans.end(); i++)
-        {
-                if (((ucrec*)(*i))->channel != NULL)
-                {
+       for (std::vector<ucrec*>::const_iterator i = zombie->chans.begin(); i != zombie->chans.end(); i++)
+       {
+               if (((ucrec*)(*i))->channel != NULL)
+               {
                                chanrec* Ptr = ((ucrec*)(*i))->channel;
                                WriteFrom(zombie->fd,zombie,"JOIN %s",Ptr->name);
-                               if (Ptr->topicset)
-                               {
-                                       WriteServ(zombie->fd,"332 %s %s :%s", zombie->nick, Ptr->name, Ptr->topic);
-                                       WriteServ(zombie->fd,"333 %s %s %s %d", zombie->nick, Ptr->name, Ptr->setby, Ptr->topicset);
-                               }
-                               userlist(zombie,Ptr);
-                               WriteServ(zombie->fd,"366 %s %s :End of /NAMES list.", zombie->nick, Ptr->name);
-                }
-        }
+                               if (Ptr->topicset)
+                               {
+                                       WriteServ(zombie->fd,"332 %s %s :%s", zombie->nick, Ptr->name, Ptr->topic);
+                                       WriteServ(zombie->fd,"333 %s %s %s %d", zombie->nick, Ptr->name, Ptr->setby, Ptr->topicset);
+                               }
+                               userlist(zombie,Ptr);
+                               WriteServ(zombie->fd,"366 %s %s :End of /NAMES list.", zombie->nick, Ptr->name);
+               }
+       }
        if ((find(local_users.begin(),local_users.end(),zombie) == local_users.end()) && (zombie->fd != FD_MAGIC_NUMBER))
                local_users.push_back(zombie);
 
@@ -806,31 +800,35 @@ long Server::CalcDuration(const std::string &delta)
        return duration(delta.c_str());
 }
 
+/*
+ * XXX why on *earth* is this in modules.cpp...? I think
+ * perhaps we need a server.cpp for Server:: stuff where possible. -- w00t
+ */
 bool Server::IsValidMask(const std::string &mask)
 {
        char* dest = (char*)mask.c_str();
-        if (strchr(dest,'!')==0)
-                return false;
-        if (strchr(dest,'@')==0)
-                return false;
-        for (char* i = dest; *i; i++)
-                if (*i < 32)
-                        return false;
-        for (char* i = dest; *i; i++)
-                if (*i > 126)
-                        return false;
-        unsigned int c = 0;
-        for (char* i = dest; *i; i++)
-                if (*i == '!')
-                        c++;
-        if (c>1)
-                return false;
-        c = 0;
-        for (char* i = dest; *i; i++)
-                if (*i == '@')
-                        c++;
-        if (c>1)
-                return false;
+       if (strchr(dest,'!')==0)
+               return false;
+       if (strchr(dest,'@')==0)
+               return false;
+       for (char* i = dest; *i; i++)
+               if (*i < 32)
+                       return false;
+       for (char* i = dest; *i; i++)
+               if (*i > 126)
+                       return false;
+       unsigned int c = 0;
+       for (char* i = dest; *i; i++)
+               if (*i == '!')
+                       c++;
+       if (c>1)
+               return false;
+       c = 0;
+       for (char* i = dest; *i; i++)
+               if (*i == '@')
+                       c++;
+       if (c>1)
+               return false;
 
        return true;
 }