]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd.cpp
Fix RemoveCommands to remove all commands (this function had some really odd removal...
[user/henk/code/inspircd.git] / src / inspircd.cpp
index 40e1d84269c99620bafcb60e0c8ca879cf07f95e..d533a6e450b035157bdb5d81f6a0adbfbf96029f 100644 (file)
@@ -12,8 +12,6 @@
  */
 
 /* $Install: src/inspircd $(BINPATH) */
-
-
 #include "inspircd.h"
 #include <signal.h>
 
        #ifndef RUSAGE_SELF
                #define RUSAGE_SELF 0
        #endif
+
+       /* CRT memory debugging */
+       #ifdef DEBUG
+       #define _CRTDBG_MAP_ALLOC
+       #include <stdlib.h>
+       #include <crtdbg.h>
+       #endif
 #endif
 
 #include <fstream>
@@ -277,22 +282,38 @@ void InspIRCd::WritePID(const std::string &filename)
 InspIRCd::InspIRCd(int argc, char** argv)
        : GlobalCulls(this),
 
-        /* Functor initialisation. Note that the ordering here is very important. */
+        /* Functor initialisation. Note that the ordering here is very important. 
+         *
+         * THIS MUST MATCH ORDER OF DECLARATION OF THE HandleWhateverFunc classes
+         * within class InspIRCd.
+         */
         HandleProcessUser(this),
         HandleIsNick(this),
         HandleIsIdent(this),
         HandleFindDescriptor(this),
         HandleFloodQuitUser(this),
-
-        /* Functor pointer initialisation. Must match the order of the list above */
+        HandleIsChannel(this),
+        HandleIsSID(this),
+        HandleRehash(this),
+
+        /* Functor pointer initialisation. Must match the order of the list above
+         *
+         * THIS MUST MATCH THE ORDER OF DECLARATION OF THE FUNCTORS, e.g. the methods
+         * themselves within the class.
+         */
         ProcessUser(&HandleProcessUser),
+        IsChannel(&HandleIsChannel),
+        IsSID(&HandleIsSID),
+        Rehash(&HandleRehash),
         IsNick(&HandleIsNick),
         IsIdent(&HandleIsIdent),
         FindDescriptor(&HandleFindDescriptor),
         FloodQuitUser(&HandleFloodQuitUser)
 
 {
-
+#ifdef WIN32
+       _CrtSetDbgFlag ( _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
+#endif
        int found_ports = 0;
        FailedPortList pl;
        int do_version = 0, do_nofork = 0, do_debug = 0,
@@ -309,11 +330,13 @@ InspIRCd::InspIRCd(int argc, char** argv)
        SE = SEF->Create(this);
        delete SEF;
 
-
        ThreadEngineFactory* tef = new ThreadEngineFactory();
        this->Threads = tef->Create(this);
        delete tef;
 
+       /* Default implementation does nothing */
+       this->PI = new ProtocolInterface(this);
+
        this->s_signal = 0;
        
        // Create base manager classes early, so nothing breaks
@@ -509,8 +532,6 @@ InspIRCd::InspIRCd(int argc, char** argv)
                Config->sid[2] = (char)(sid % 10 + 48);
        }
 
-       this->InitialiseUID();
-
        /* set up fake client again this time with the correct uid */
        this->FakeClient = new User(this, "#INVALID");
        this->FakeClient->SetFd(FD_MAGIC_NUMBER);
@@ -519,7 +540,6 @@ InspIRCd::InspIRCd(int argc, char** argv)
        this->XLines->CheckELines();
        this->XLines->ApplyLines();
 
-
        CheckDie();
        int bounditems = BindPorts(true, found_ports, pl);
 
@@ -542,12 +562,16 @@ InspIRCd::InspIRCd(int argc, char** argv)
        {
                printf("\nWARNING: Not all your client ports could be bound --\nstarting anyway with %d of %d client ports bound.\n\n", bounditems, found_ports);
                printf("The following port(s) failed to bind:\n");
+               printf("Hint: Try using an IP instead of blank or *\n\n");
                int j = 1;
                for (FailedPortList::iterator i = pl.begin(); i != pl.end(); i++, j++)
                {
                        printf("%d.\tIP: %s\tPort: %lu\n", j, i->first.empty() ? "<all>" : i->first.c_str(), (unsigned long)i->second);
                }
        }
+
+       printf("\nInspIRCd is now running as '%s'[%s] with %d max open sockets\n", Config->ServerName,Config->GetSID().c_str(), SE->GetMaxFds());
+       
 #ifndef WINDOWS
        if (!Config->nofork)
        {
@@ -584,34 +608,11 @@ InspIRCd::InspIRCd(int argc, char** argv)
        }
 #endif
 
-       printf("\nInspIRCd is now running as '%s'[%s]\n", Config->ServerName,Config->GetSID().c_str());
-       Logs->Log("STARTUP", DEFAULT, "Startup complete as '%s'[%s]", Config->ServerName,Config->GetSID().c_str());
+       Logs->Log("STARTUP", DEFAULT, "Startup complete as '%s'[%s], %d max open sockets", Config->ServerName,Config->GetSID().c_str(), SE->GetMaxFds());
 
        this->WritePID(Config->PID);
 }
 
-/* moved to a function, as UID generation can call this also */
-void InspIRCd::InitialiseUID()
-{
-       int i = 3;
-
-printf("FUCKING UID IS %s\n", current_uid);
-
-       current_uid[0] = Config->sid[0];
-       current_uid[1] = Config->sid[1];
-       current_uid[2] = Config->sid[2];
-
-       /* Initialise UID */
-       for(i = 3; i < UUID_LENGTH - 1; i++)
-               current_uid[i] = 'A';
-
-printf("FUCKING UID IS %s %d\n", current_uid, strlen(current_uid));
-
-       current_uid[UUID_LENGTH] = '\0';
-
-printf("FUCKING UID IS %s %d\n", current_uid, strlen(current_uid));
-}
-
 int InspIRCd::Run()
 {
        /* See if we're supposed to be running the test suite rather than entering the mainloop */
@@ -676,7 +677,7 @@ int InspIRCd::Run()
                {
                        if (TIME < OLDTIME)
                        {
-                               SNO->WriteToSnoMask('A', "\002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %ld secs.",OLDTIME-TIME);
+                               SNO->WriteToSnoMask('A', "\002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %lu secs.", (unsigned long)OLDTIME-TIME);
                        }
 
                        if ((TIME % 3600) == 0)