]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd.cpp
Added CASEMAPPING and CHARSET to ISUPPORT (005)
[user/henk/code/inspircd.git] / src / inspircd.cpp
index b68f4934e105f36cd72f30545941c7c66cb67a10..dbae71a9b1335e9d391d757415bcb9aba918b0eb 100644 (file)
@@ -76,12 +76,10 @@ int openSockfd[MAXSOCKS];
 sockaddr_in client,server;
 socklen_t length;
 
-extern InspSocket* socket_ref[65535];
+extern InspSocket* socket_ref[MAX_DESCRIPTORS];
 
 time_t TIME = time(NULL), OLDTIME = time(NULL);
 
-SocketEngine* SE = NULL;
-
 // This table references users by file descriptor.
 // its an array to make it VERY fast, as all lookups are referenced
 // by an integer, meaning there is no need for a scan/search operation.
@@ -199,6 +197,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
        memset(&Config->implement_lists,0,sizeof(Config->implement_lists));
 
         printf("\n");
+       SetSignals();
         if (!Config->nofork)
         {
                 if (DaemonSeed() == ERROR)
@@ -277,6 +276,17 @@ void InspIRCd::erase_module(int j)
 
 }
 
+void InspIRCd::BuildISupport()
+{
+        // the neatest way to construct the initial 005 numeric, considering the number of configure constants to go in it...
+       std::stringstream v;
+       v << "WALLCHOPS MODES=13 CHANTYPES=# PREFIX=(ohv)@%+ MAP SAFELIST MAXCHANNELS=" << MAXCHANS << " MAXBANS=60 NICKLEN=" << NICKMAX;
+       v << " CASEMAPPING=rfc1459 STATUSMSG=@+ CHARSET=ascii TOPICLEN=" << MAXTOPIC << " KICKLEN=" << MAXKICK << " MAXTARGETS=20 AWAYLEN=";
+       v << MAXAWAY << " CHANMODES=ohvb,k,l,psmnti NETWORK=" << Config->Network;
+       Config->data005 = v.str();
+       FOREACH_MOD(I_On005Numeric,On005Numeric(Config->data005));
+}
+
 bool InspIRCd::UnloadModule(const char* filename)
 {
        std::string filename_str = filename;
@@ -315,6 +325,7 @@ bool InspIRCd::UnloadModule(const char* filename)
                         Parser->RemoveCommands(filename);
                        log(DEFAULT,"Module %s unloaded",filename);
                        MODCOUNT--;
+                       BuildISupport();
                        return true;
                }
        }
@@ -327,7 +338,7 @@ bool InspIRCd::LoadModule(const char* filename)
 {
        char modfile[MAXBUF];
 #ifdef STATIC_LINK
-       snprintf(modfile,MAXBUF,"%s",filename);
+       strlcpy(modfile,filename,MAXBUF);
 #else
        snprintf(modfile,MAXBUF,"%s/%s",Config->ModPath,filename);
 #endif
@@ -403,13 +414,14 @@ bool InspIRCd::LoadModule(const char* filename)
 #endif
        MODCOUNT++;
        FOREACH_MOD(I_OnLoadModule,OnLoadModule(modules[MODCOUNT],filename_str));
+       BuildISupport();
        return true;
 }
 
 int InspIRCd::Run()
 {
        bool expire_run = false;
-       std::vector<int> activefds;
+       int activefds[MAX_DESCRIPTORS];
        int incomingSockfd;
        int in_port;
        userrec* cu = NULL;
@@ -461,19 +473,22 @@ int InspIRCd::Run()
                        expire_run = true;
                        continue;
                }
-               if ((TIME % 8) == 1)
+               else if ((TIME % 8) == 1)
+               {
                        expire_run = false;
+               }
                
                /* Once a second, do the background processing */
                if (TIME != OLDTIME)
-                       while (DoBackgroundUserStuff(TIME));
+                       DoBackgroundUserStuff(TIME);
 
                /* Call the socket engine to wait on the active
                 * file descriptors. The socket engine has everything's
                 * descriptors in its list... dns, modules, users,
                 * servers... so its nice and easy, just one call.
                 */
-               SE->Wait(activefds);
+               if (!(numberactive = SE->Wait(activefds)))
+                       continue;
 
                /**
                 * Now process each of the fd's. For users, we have a fast
@@ -482,7 +497,6 @@ int InspIRCd::Run()
                 * listening ports or module sockets though, things could get
                 * ugly.
                 */
-               numberactive = activefds.size();
                for (unsigned int activefd = 0; activefd < numberactive; activefd++)
                {
                        int socket_type = SE->GetType(activefds[activefd]);