]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd.cpp
Add template creation tool for caller classes
[user/henk/code/inspircd.git] / src / inspircd.cpp
index eb32eac493e15f9ecf36e8849434ec815fdf5ce6..09f1e868505215d39988f5b12c12dae4a6a18e79 100644 (file)
@@ -39,6 +39,7 @@
 #include "typedefs.h"
 #include "command_parse.h"
 #include "exitcodes.h"
+#include "caller.h"
 
 #ifdef WIN32
 
@@ -173,38 +174,6 @@ const char* ExitCodes[] =
                "Received SIGTERM", /* 15 */
 };
 
-void InspIRCd::AddServerName(const std::string &servername)
-{
-       servernamelist::iterator itr = servernames.begin();
-       for(; itr != servernames.end(); ++itr)
-               if(**itr == servername)
-                       return;
-
-       string * ns = new string(servername);
-       servernames.push_back(ns);
-}
-
-const char* InspIRCd::FindServerNamePtr(const std::string &servername)
-{
-       servernamelist::iterator itr = servernames.begin();
-       for(; itr != servernames.end(); ++itr)
-               if(**itr == servername)
-                       return (*itr)->c_str();
-
-       servernames.push_back(new string(servername));
-       itr = --servernames.end();
-       return (*itr)->c_str();
-}
-
-bool InspIRCd::FindServerName(const std::string &servername)
-{
-       servernamelist::iterator itr = servernames.begin();
-       for(; itr != servernames.end(); ++itr)
-               if(**itr == servername)
-                       return true;
-       return false;
-}
-
 void InspIRCd::Exit(int status)
 {
 #ifdef WINDOWS
@@ -295,35 +264,12 @@ void InspIRCd::Restart(const std::string &reason)
        }
 }
 
-void InspIRCd::Start()
-{
-       printf_c("\033[1;32mInspire Internet Relay Chat Server, compiled %s at %s\n",__DATE__,__TIME__);
-       printf_c("(C) InspIRCd Development Team.\033[0m\n\n");
-       printf_c("Developers:\t\t\033[1;32mBrain, FrostyCoolSlug, w00t, Om, Special, pippijn, peavey, Burlex\033[0m\n");
-       printf_c("Others:\t\t\t\033[1;32mSee /INFO Output\033[0m\n");
-}
-
-void InspIRCd::Rehash(int status)
-{
-       SI->WriteOpers("*** Rehashing config file %s due to SIGHUP",ServerConfig::CleanFilename(SI->ConfigFileName));
-       SI->CloseLog();
-       SI->OpenLog(SI->Config->argv, SI->Config->argc);
-       SI->RehashUsersAndChans();
-       FOREACH_MOD_I(SI, I_OnGarbageCollect, OnGarbageCollect());
-       SI->Config->Read(false,NULL);
-       SI->ResetMaxBans();
-       SI->Res->Rehash();
-       FOREACH_MOD_I(SI,I_OnRehash,OnRehash(NULL,""));
-       SI->BuildISupport();
-}
-
 void InspIRCd::ResetMaxBans()
 {
        for (chan_hash::const_iterator i = chanlist->begin(); i != chanlist->end(); i++)
                i->second->ResetMaxBans();
 }
 
-
 /** Because hash_map doesnt free its buckets when we delete items (this is a 'feature')
  * we must occasionally rehash the hash (yes really).
  * We do this by copying the entries from the old hash to a new hash, causing all
@@ -445,13 +391,10 @@ void InspIRCd::WritePID(const std::string &filename)
        }
 }
 
-std::string InspIRCd::GetRevision()
-{
-       return REVISION;
-}
-
 InspIRCd::InspIRCd(int argc, char** argv)
-       : ModCount(-1), GlobalCulls(this)
+       : ModCount(0),
+         GlobalCulls(this),
+        HandleIsNick(this), IsNick(&HandleIsNick)
 {
        int found_ports = 0;
        FailedPortList pl;
@@ -549,7 +492,10 @@ InspIRCd::InspIRCd(int argc, char** argv)
                Exit(EXIT_STATUS_CONFIG);
        }
 
-       this->Start();
+       printf_c("\033[1;32mInspire Internet Relay Chat Server, compiled %s at %s\n",__DATE__,__TIME__);
+       printf_c("(C) InspIRCd Development Team.\033[0m\n\n");
+       printf_c("Developers:\t\t\033[1;32mBrain, FrostyCoolSlug, w00t, Om, Special, pippijn, peavey, Burlex\033[0m\n");
+       printf_c("Others:\t\t\t\033[1;32mSee /INFO Output\033[0m\n");
 
        /* Set the finished argument values */
        Config->nofork = do_nofork;
@@ -679,34 +625,6 @@ InspIRCd::InspIRCd(int argc, char** argv)
        this->WritePID(Config->PID);
 }
 
-std::string InspIRCd::GetVersionString()
-{
-       char versiondata[MAXBUF];
-       char dnsengine[] = "singlethread-object";
-
-       if (*Config->CustomVersion)
-       {
-               snprintf(versiondata,MAXBUF,"%s %s :%s",VERSION,Config->ServerName,Config->CustomVersion);
-       }
-       else
-       {
-               snprintf(versiondata,MAXBUF,"%s %s :%s [FLAGS=%s,%s,%s]",VERSION,Config->ServerName,SYSTEM,REVISION,SE->GetName().c_str(),dnsengine);
-       }
-       return versiondata;
-}
-
-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 WALLVOICES MODES=" << MAXMODES-1 << " CHANTYPES=# PREFIX=" << this->Modes->BuildPrefixes() << " MAP MAXCHANNELS=" << Config->MaxChans << " MAXBANS=60 VBANLIST NICKLEN=" << NICKMAX-1;
-       v << " CASEMAPPING=rfc1459 STATUSMSG=@%+ CHARSET=ascii TOPICLEN=" << MAXTOPIC << " KICKLEN=" << MAXKICK << " MAXTARGETS=" << Config->MaxTargets << " AWAYLEN=";
-       v << MAXAWAY << " CHANMODES=" << this->Modes->ChanModes() << " FNC NETWORK=" << Config->Network << " MAXPARA=32 ELIST=MU";
-       Config->data005 = v.str();
-       FOREACH_MOD_I(this,I_On005Numeric,On005Numeric(Config->data005));
-       Config->Update005();
-}
-
 void InspIRCd::DoOneIteration(bool process_module_sockets)
 {
 #ifndef WIN32
@@ -774,10 +692,10 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
         * This will cause any read or write events to be
         * dispatched to their handlers.
         */
-       SE->DispatchEvents();
+       this->SE->DispatchEvents();
 
        /* if any users was quit, take them out */
-       GlobalCulls.Apply();
+       this->GlobalCulls.Apply();
 
        /* If any inspsockets closed, remove them */
        this->InspSocketCull();
@@ -881,89 +799,3 @@ int InspIRCd::GetTimeDelta()
 {
        return time_delta;
 }
-
-bool FileLogger::Readable()
-{
-       return false;
-}
-
-void FileLogger::HandleEvent(EventType et, int errornum)
-{
-       this->WriteLogLine("");
-       if (log)
-               ServerInstance->SE->DelFd(this);
-}
-
-void FileLogger::WriteLogLine(const std::string &line)
-{
-       if (line.length())
-               buffer.append(line);
-
-       if (log)
-       {
-               int written = fprintf(log,"%s",buffer.c_str());
-#ifdef WINDOWS
-               buffer.clear();
-#else
-               if ((written >= 0) && (written < (int)buffer.length()))
-               {
-                       buffer.erase(0, buffer.length());
-                       ServerInstance->SE->AddFd(this);
-               }
-               else if (written == -1)
-               {
-                       if (errno == EAGAIN)
-                               ServerInstance->SE->AddFd(this);
-               }
-               else
-               {
-                       /* Wrote the whole buffer, and no need for write callback */
-                       buffer.clear();
-               }
-#endif
-               if (writeops++ % 20)
-               {
-                       fflush(log);
-               }
-       }
-}
-
-void FileLogger::Close()
-{
-       if (log)
-       {
-               /* Burlex: Windows assumes nonblocking on FILE* pointers anyway, and also "file" fd's aren't the same
-                * as socket fd's. */
-#ifndef WIN32
-               int flags = fcntl(fileno(log), F_GETFL, 0);
-               fcntl(fileno(log), F_SETFL, flags ^ O_NONBLOCK);
-#endif
-               if (buffer.size())
-                       fprintf(log,"%s",buffer.c_str());
-
-#ifndef WINDOWS
-               ServerInstance->SE->DelFd(this);
-#endif
-
-               fflush(log);
-               fclose(log);
-       }
-
-       buffer.clear();
-}
-
-FileLogger::FileLogger(InspIRCd* Instance, FILE* logfile) : ServerInstance(Instance), log(logfile), writeops(0)
-{
-       if (log)
-       {
-               irc::sockets::NonBlocking(fileno(log));
-               this->SetFd(fileno(log));
-               buffer.clear();
-       }
-}
-
-FileLogger::~FileLogger()
-{
-       this->Close();
-}
-