]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd_io.cpp
Signal handlers were not being set when -nofork was enabled
[user/henk/code/inspircd.git] / src / inspircd_io.cpp
index 7033284c476c02c212abedaba51a5bd2478bb94a..dd5b146922c11e32278e4787c038aabdd66828d4 100644 (file)
@@ -27,7 +27,6 @@ using namespace std;
 #include <fstream>
 #include "inspircd.h"
 #include "inspircd_io.h"
-#include "inspircd_util.h"
 #include "inspstring.h"
 #include "helperfuncs.h"
 #include "xline.h"
@@ -64,6 +63,32 @@ void ServerConfig::ClearStack()
        include_stack.clear();
 }
 
+Module* ServerConfig::GetIOHook(int port)
+{
+       std::map<int,Module*>::iterator x = IOHookModule.find(port);
+       return (x != IOHookModule.end() ? x->second : NULL);
+}
+
+bool ServerConfig::AddIOHook(int port, Module* iomod)
+{
+       if (!GetIOHook(port))
+       {
+               IOHookModule[port] = iomod;
+               return true;
+       }
+       return false;
+}
+
+bool ServerConfig::DelIOHook(int port)
+{
+       std::map<int,Module*>::iterator x = IOHookModule.find(port);
+       if (x != IOHookModule.end())
+       {
+               IOHookModule.erase(x);
+               return true;
+       }
+       return false;
+}
 
 void ServerConfig::Read(bool bail, userrec* user)
 {
@@ -186,7 +211,7 @@ void ServerConfig::Read(bool bail, userrec* user)
         Classes.clear();
         for (int i = 0; i < ConfValueEnum("connect",&Config->config_f); i++)
         {
-                strcpy(Value,"");
+                *Value = 0;
                 ConfValue("connect","allow",i,Value,&Config->config_f);
                 ConfValue("connect","timeout",i,timeout,&Config->config_f);
                 ConfValue("connect","flood",i,flood,&Config->config_f);
@@ -196,11 +221,11 @@ void ServerConfig::Read(bool bail, userrec* user)
                 ConfValue("connect","recvq",i,rqmax,&Config->config_f);
                 if (*Value)
                 {
-                        strlcpy(c.host,Value,MAXBUF);
+                        c.host = Value;
                         c.type = CC_ALLOW;
                         strlcpy(Value,"",MAXBUF);
                         ConfValue("connect","password",i,Value,&Config->config_f);
-                        strlcpy(c.pass,Value,MAXBUF);
+                        c.pass = Value;
                         c.registration_timeout = 90; // default is 2 minutes
                         c.pingtime = 120;
                         c.flood = atoi(flood);
@@ -232,10 +257,10 @@ void ServerConfig::Read(bool bail, userrec* user)
                 else
                 {
                         ConfValue("connect","deny",i,Value,&Config->config_f);
-                        strlcpy(c.host,Value,MAXBUF);
+                        c.host = Value;
                         c.type = CC_DENY;
                         Classes.push_back(c);
-                        log(DEBUG,"Read connect class type DENY, host=%s",c.host);
+                        log(DEBUG,"Read connect class type DENY, host=%s",c.host.c_str());
                 }
 
         }
@@ -306,7 +331,7 @@ void ServerConfig::Read(bool bail, userrec* user)
                         }
                         else
                         {
-                                WriteServ(user->fd,"972 %s %s :Failed to unload module %s: %s",user->nick, removing->c_str(), removing->c_str(), ModuleError());
+                                WriteServ(user->fd,"972 %s %s :Failed to unload module %s: %s",user->nick, removing->c_str(), removing->c_str(), ServerInstance->ModuleError());
                         }
                 }
                 if (!added_modules.empty())
@@ -320,7 +345,7 @@ void ServerConfig::Read(bool bail, userrec* user)
                         }
                         else
                         {
-                                WriteServ(user->fd,"974 %s %s :Failed to load module %s: %s",user->nick, adding->c_str(), adding->c_str(), ModuleError());
+                                WriteServ(user->fd,"974 %s %s :Failed to load module %s: %s",user->nick, adding->c_str(), adding->c_str(), ServerInstance->ModuleError());
                         }
                 }
                 log(DEFAULT,"Successfully unloaded %lu of %lu modules and loaded %lu of %lu modules.",(unsigned long)rem,(unsigned long)removed_modules.size(),
@@ -329,8 +354,6 @@ void ServerConfig::Read(bool bail, userrec* user)
 }
 
 
-void WriteOpers(char* text, ...);
-
 void Exit (int status)
 {
        if (Config->log_file)
@@ -381,15 +404,19 @@ void WritePID(std::string filename)
        }
 }
 
-
-int DaemonSeed (void)
+void SetSignals()
 {
-       int childpid;
        signal (SIGALRM, SIG_IGN);
        signal (SIGHUP, Rehash);
        signal (SIGPIPE, SIG_IGN);
        signal (SIGTERM, Exit);
        signal (SIGSEGV, Error);
+}
+
+
+int DaemonSeed (void)
+{
+       int childpid;
        if ((childpid = fork ()) < 0)
                return (ERROR);
        else if (childpid > 0)
@@ -913,18 +940,18 @@ int ServerConfig::ReadConf(std::stringstream *config, const char* tag, const cha
                                                if (!key)
                                                {
                                                        /* value not found in tag */
-                                                       strcpy(result,"");
+                                                       *result = 0;
                                                        return 0;
                                                }
                                                else
                                                {
                                                        key+=strlen(var);
-                                                       while (key[0] !='"')
+                                                       while (*key !='"')
                                                        {
-                                                               if (!strlen(key))
+                                                               if (!*key)
                                                                {
                                                                        /* missing quote */
-                                                                       strcpy(result,"");
+                                                                       *result = 0;
                                                                        return 0;
                                                                }
                                                                key++;
@@ -962,7 +989,7 @@ int ServerConfig::ReadConf(std::stringstream *config, const char* tag, const cha
                        }
                }
        }
-       strcpy(result,""); // value or its tag not found at all
+       *result = 0; // value or its tag not found at all
        return 0;
 }