]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd.cpp
Added some missing parameter checking in m_swhois
[user/henk/code/inspircd.git] / src / inspircd.cpp
index 7d2fd2ad4f7cd7a1806e147d58451d1604087cd3..858862e9dfa79c0ce06d05fbe9d3ddf1096fef84 100644 (file)
 #include "inspircd.h"
 #include "configreader.h"
 #include <signal.h>
-#ifndef WIN32
 
+#ifndef WIN32
 #include <dirent.h>
 #include <unistd.h>
 #include <sys/resource.h>
+#include <dlfcn.h>
+#include <getopt.h>
 
-/* This is just to be completely certain that the change which fixed getrusage on RH7 doesn't break anything else -- Om */  
+/* Some systems don't define RUSAGE_SELF. This should fix them. */
 #ifndef RUSAGE_SELF
-#define RUSAGE_SELF 0
+       #define RUSAGE_SELF 0
 #endif
 
 #endif
+
 #include <exception>
 #include <fstream>
 #include "modules.h"
 #include "command_parse.h"
 #include "exitcodes.h"
 
-#ifndef WIN32
-#include <dlfcn.h>
-#include <getopt.h>
-#else
+#ifdef WIN32
+
+/* This MUST remain static and delcared outside the class, so that WriteProcessMemory can reference it properly */
 static DWORD owner_processid = 0;
 
 DWORD WindowsForkStart(InspIRCd * Instance)
@@ -504,14 +506,10 @@ InspIRCd::InspIRCd(int argc, char** argv)
                        case 'f':
                                /* Log filename was set */
                                strlcpy(LogFileName, optarg, MAXBUF);
-                               if (owner_processid)
-                                       printf("LOG: Setting logfile to %s\n", LogFileName);
                        break;
                        case 'c':
                                /* Config filename was set */
                                strlcpy(ConfigFileName, optarg, MAXBUF);
-                               if (owner_processid)
-                                       printf("CONFIG: Setting config file to %s\n", ConfigFileName);
                        break;
                        case 0:
                                /* getopt_long_only() set an int variable, just keep going */
@@ -957,9 +955,11 @@ bool InspIRCd::LoadModule(const char* filename)
                                return false;
                        }
                }
+               Module* m = NULL;
+               ircd_module* a = NULL;
                try
                {
-                       ircd_module* a = new ircd_module(this, modfile);
+                       a = new ircd_module(this, modfile);
                        factory[this->ModCount+1] = a;
                        if (factory[this->ModCount+1]->LastError())
                        {
@@ -969,14 +969,13 @@ bool InspIRCd::LoadModule(const char* filename)
                        }
                        if ((long)factory[this->ModCount+1]->factory != -1)
                        {
-                               Module* m = factory[this->ModCount+1]->factory->CreateModule(this);
+                               m = factory[this->ModCount+1]->factory->CreateModule(this);
 
                                Version v = m->GetVersion();
 
                                if (v.API != API_VERSION)
                                {
                                        delete m;
-                                       delete a;
                                        this->Log(DEFAULT,"Unable to load %s: Incorrect module API version: %d (our version: %d)",modfile,v.API,API_VERSION);
                                        snprintf(MODERR,MAXBUF,"Loader/Linker error: Incorrect module API version: %d (our version: %d)",v.API,API_VERSION);
                                        return false;