]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/helperfuncs.cpp
Adding hook type checking to event calls to speed them up
[user/henk/code/inspircd.git] / src / helperfuncs.cpp
index e80bec80c420ae7768ee9edbed1132735479c722..71840a22a19542e89005bf857aff88f95d72cb4e 100644 (file)
@@ -52,6 +52,7 @@ using namespace std;
 extern int MODCOUNT;
 extern std::vector<Module*> modules;
 extern ServerConfig *Config;
+extern InspIRCd* ServerInstance;
 extern time_t TIME;
 extern char lowermap[255];
 static char list[MAXBUF];
@@ -60,7 +61,6 @@ static char already_sent[65536];
 extern std::vector<userrec*> all_opers;
 extern user_hash clientlist;
 extern chan_hash chanlist;
-extern Module* IOHookModule;
 
 void log(int level,char *text, ...)
 {
@@ -139,9 +139,9 @@ void Write(int sock,char *text, ...)
         chop(tb);
         if (fd_ref_table[sock])
         {
-               if (IOHookModule)
+               if (Config->GetIOHook(fd_ref_table[sock]->port))
                {
-                       IOHookModule->OnRawSocketWrite(sock,tb,bytes);
+                       Config->GetIOHook(fd_ref_table[sock]->port)->OnRawSocketWrite(sock,tb,bytes);
                }
                else
                {
@@ -172,9 +172,9 @@ void WriteServ(int sock, char* text, ...)
         chop(tb);
         if (fd_ref_table[sock])
         {
-               if (IOHookModule)
+               if (Config->GetIOHook(fd_ref_table[sock]->port))
                {
-                       IOHookModule->OnRawSocketWrite(sock,tb,bytes);
+                       Config->GetIOHook(fd_ref_table[sock]->port)->OnRawSocketWrite(sock,tb,bytes);
                }
                else
                {
@@ -205,9 +205,9 @@ void WriteFrom(int sock, userrec *user,char* text, ...)
         chop(tb);
         if (fd_ref_table[sock])
         {
-               if (IOHookModule)
+               if (Config->GetIOHook(fd_ref_table[sock]->port))
                {
-                       IOHookModule->OnRawSocketWrite(sock,tb,bytes);
+                       Config->GetIOHook(fd_ref_table[sock]->port)->OnRawSocketWrite(sock,tb,bytes);
                }
                else
                {
@@ -366,7 +366,7 @@ void ChanExceptSender(chanrec* Ptr, userrec* user, char* text, ...)
 std::string GetServerDescription(char* servername)
 {
        std::string description = "";
-       FOREACH_MOD OnGetServerDescription(servername,description);
+       FOREACH_MOD(I_OnGetServerDescription,OnGetServerDescription(servername,description));
        if (description != "")
        {
                return description;
@@ -922,9 +922,9 @@ char* Passwd(userrec *user)
 {
         for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
         {
-                if ((i->type == CC_ALLOW) && match(user->host,i->host))
+                if ((i->type == CC_ALLOW) && match(user->host,i->host.c_str()))
                 {
-                        return i->pass;
+                        return (char*)i->pass.c_str();
                 }
         }
         return "";
@@ -934,7 +934,7 @@ bool IsDenied(userrec *user)
 {
         for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
         {
-                if ((i->type == CC_DENY) && match(user->host,i->host))
+                if ((i->type == CC_DENY) && match(user->host,i->host.c_str()))
                 {
                         return true;
                 }
@@ -1064,9 +1064,9 @@ void ShowMOTD(userrec *user)
         snprintf(mbuf,MAXBUF,":%s 376 %s :End of message of the day.\r\n", Config->ServerName, user->nick);
         WholeMOTD = WholeMOTD + mbuf;
         // only one write operation
-       if (IOHookModule)
+       if (Config->GetIOHook(user->port))
        {
-               IOHookModule->OnRawSocketWrite(user->fd,(char*)WholeMOTD.c_str(),WholeMOTD.length());
+               Config->GetIOHook(user->port)->OnRawSocketWrite(user->fd,(char*)WholeMOTD.c_str(),WholeMOTD.length());
        }
        else
        {