]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Remove redundant ServerInstance* fields
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 13 Sep 2009 20:31:54 +0000 (20:31 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 13 Sep 2009 20:31:54 +0000 (20:31 +0000)
It has been impossible to have more than one InspIRCd* object in the
same address space for some time now, and this feature was never used.
This formalizes class InspIRCd as a singleton object.

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11703 e03df62e-2008-0410-955e-edbf42e46eb7

16 files changed:
include/channels.h
include/inspircd.h
include/mode.h
include/modules.h
include/users.h
src/channels.cpp
src/inspircd.cpp
src/mode.cpp
src/modules.cpp
src/modules/m_callerid.cpp
src/modules/m_delayjoin.cpp
src/modules/m_nicklock.cpp
src/modules/m_operprefix.cpp
src/modules/m_permchannels.cpp
src/modules/m_spanningtree/main.cpp
src/users.cpp

index 7b6999316f41f45f5cd95cbc20fb60b59ee9ea12..fb32f1156edd802d30f3220de68b9f9eb8f19ca0 100644 (file)
@@ -94,10 +94,6 @@ class CoreExport Channel : public Extensible
        int maxbans;
 
  public:
-       /** Pointer to creator object
-        */
-       InspIRCd* ServerInstance;
-
        /** Creates a channel record and initialises it with default values
         * @throw Nothing at present.
         */
index a7eed47ff53b1ffcac09a9e4ea7a0f450ebc1df6..45b21909678eca46a87b62778997a6dfbd3fe42f 100644 (file)
@@ -936,6 +936,7 @@ class CoreExport InspIRCd : public classbase
        }
 };
 
+extern InspIRCd* ServerInstance;
 ENTRYPOINT;
 
 template<class Cmd>
index 0c367a1c2548ac68c071fb0a0a42fa6f952b49b2..db115a3c90588af452e2ec08b68e5a8076c24d31 100644 (file)
@@ -152,7 +152,6 @@ class CoreExport ModeHandler : public classbase
        int levelrequired;
 
  public:
-       static InspIRCd* ServerInstance;
        /** Module that created this mode. NULL for core modes */
        Module* creator;
 
@@ -425,10 +424,6 @@ typedef std::vector<ModeWatcher*>::iterator ModeWatchIter;
 class CoreExport ModeParser : public classbase
 {
  private:
-       /**
-        * Creator/owner pointer
-        */
-       InspIRCd* ServerInstance;
        /** Mode handlers for each mode, to access a handler subtract
         * 65 from the ascii value of the mode letter.
         * The upper bit of the value indicates if its a usermode
index 81381ab8bb6dc4408af417efaf2402a9c32a25f8..4e960ec6457bcae36e5ddd4f7c4152695fd3e77e 100644 (file)
@@ -425,9 +425,6 @@ class ConfigReader;
 class CoreExport Module : public Extensible
 {
  public:
-       /** Creator/owner pointer
-        */
-       InspIRCd* ServerInstance;
        /** File that this module was loaded from
         */
        std::string ModuleSourceFile;
index f9128013977bd7c6c3baf32112922e8ac9b62254..505c43b9e621fcc570707989af43e97095cfb2ab 100644 (file)
@@ -255,12 +255,6 @@ class CoreExport User : public EventHandler
        std::bitset<64> AllowedChanModes;
 
  public:
-       /** Pointer to creator.
-        * This is required to make use of core functions
-        * from within the User class.
-        */
-       InspIRCd* ServerInstance;
-
        static LocalIntExt NICKForced;
        static LocalStringExt OperQuit;
 
index 3685f66046c83f00477c21281db6692eefc67ea3..7f2cefd2bb8059d4fb505f2ebc6e15bfb4d35674 100644 (file)
@@ -17,7 +17,7 @@
 #include <cstdarg>
 #include "mode.h"
 
-Channel::Channel(InspIRCd* Instance, const std::string &cname, time_t ts) : ServerInstance(Instance)
+Channel::Channel(InspIRCd* Instance, const std::string &cname, time_t ts)
 {
        chan_hash::iterator findchan = ServerInstance->chanlist->find(cname);
        if (findchan != Instance->chanlist->end())
@@ -930,7 +930,7 @@ unsigned int Membership::getRank()
        unsigned int rv = 0;
        if (mchar)
        {
-               ModeHandler* mh = chan->ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
+               ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
                if (mh)
                        rv = mh->GetPrefixRank();
        }
index 3d80f5250e7fd54b7296c486eb943e91bdb97c16..8f763e2b632a0dfe70f9f3bbb032ffb76f5b358a 100644 (file)
@@ -43,7 +43,7 @@
 #include "caller.h"
 #include "testsuite.h"
 
-InspIRCd* SI = NULL;
+InspIRCd* ServerInstance = NULL;
 int* mysig = NULL;
 
 /** Seperate from the other casemap tables so that code *can* still exclusively rely on RFC casemapping
@@ -351,6 +351,8 @@ InspIRCd::InspIRCd(int argc, char** argv) :
        WindowsIPC = 0;
 #endif
 
+       ServerInstance = this;
+
        Extensible::Register(&User::NICKForced);
        Extensible::Register(&User::OperQuit);
 
@@ -888,9 +890,9 @@ void InspIRCd::SetSignal(int signal)
  */
 ENTRYPOINT
 {
-       SI = new InspIRCd(argc, argv);
-       mysig = &SI->s_signal;
-       SI->Run();
-       delete SI;
+       new InspIRCd(argc, argv);
+       mysig = &ServerInstance->s_signal;
+       ServerInstance->Run();
+       delete ServerInstance;
        return 0;
 }
index 86438bf733fce705c18b9933e1d3546fbb563c91..9c608c37a4285de0c10c2d36a389404b384b7f32 100644 (file)
@@ -49,8 +49,6 @@
 /* +s (server notice masks) */
 #include "modes/umode_s.h"
 
-InspIRCd* ModeHandler::ServerInstance;
-
 ModeHandler::ModeHandler(Module* Creator, char modeletter, ParamSpec Params, ModeType type)
        : mode(modeletter), parameters_taken(Params), list(false), m_type(type), m_paramtype(TR_TEXT),
        oper(false), prefix(0), count(0), levelrequired(HALFOP_VALUE), creator(Creator)
@@ -941,9 +939,8 @@ void ModeHandler::RemoveMode(Channel* channel, irc::modestacker* stack)
        }
 }
 
-ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance)
+ModeParser::ModeParser(InspIRCd* Instance)
 {
-       ModeHandler::ServerInstance = Instance;
        ModeHandler* modes[] =
        {
                new ModeChannelSecret(Instance),
index 979c42119dc268556d613f93b216c4ebce3642d3..9664e817f1e48d733e6b71d896ea506ff44a5861 100644 (file)
@@ -28,7 +28,7 @@
 
 // version is a simple class for holding a modules version number
 Version::Version(const std::string &modv, int flags, int api_ver, const std::string& rev)
-: version(modv + " " + rev), Flags(flags), API(api_ver)
+: version(modv + " " + rev), Flags(flags), API(api_ver)
 {
 }
 
@@ -90,7 +90,7 @@ Module* Event::GetSource()
        return this->source;
 }
 
-char* Event::Send(InspIRCd* ServerInstance)
+char* Event::Send(InspIRCd* SI)
 {
        FOREACH_MOD(I_OnEvent,OnEvent(this));
        return NULL;
@@ -104,7 +104,7 @@ std::string Event::GetEventID()
 
 // These declarations define the behavours of the base class Module (which does nothing at all)
 
-Module::Module(InspIRCd* Me) : ServerInstance(Me) { }
+Module::Module(InspIRCd*) { }
 Module::~Module() { }
 
 ModResult      Module::OnSendSnotice(char &snomask, std::string &type, const std::string &message) { return MOD_RES_PASSTHRU; }
index 16b883f632862c5cacb1285841fd3c60fc6a6057..b84ee2c9caab73e4ecd06a1541f705132419264b 100644 (file)
@@ -32,7 +32,7 @@ class callerid_data : public classbase
        std::list<callerid_data *> wholistsme;
 
        callerid_data() : lastnotify(0) { }
-       callerid_data(const std::string& str, InspIRCd* ServerInstance)
+       callerid_data(const std::string& str)
        {
                irc::commasepstream s(str);
                std::string tok;
@@ -85,7 +85,7 @@ struct CallerIDExtInfo : public ExtensionItem
 
        void unserialize(Module* requestor, Extensible* container, const std::string& value)
        {
-               callerid_data* dat = new callerid_data(value, requestor->ServerInstance);
+               callerid_data* dat = new callerid_data(value);
                set_raw(container, dat);
        }
 
index ffaf1223b0c5d9df7afb81cb0a492967125a1963..a7a8575b4c7a19bff41d7ccd08fe79269b6312a7 100644 (file)
@@ -169,7 +169,7 @@ void ModuleDelayJoin::OnText(User* user, void* dest, int target_type, const std:
        /* Display the join to everyone else (the user who joined got it earlier) */
        channel->WriteAllExceptSender(user, false, 0, "JOIN %s", channel->name.c_str());
 
-       std::string n = this->ServerInstance->Modes->ModeString(user, channel);
+       std::string n = ServerInstance->Modes->ModeString(user, channel);
        if (n.length() > 0)
                channel->WriteAllExceptSender(user, false, 0, "MODE %s +%s", channel->name.c_str(), n.c_str());
 }
index ddfc4745597257c61ed7a5bf04a77ad5f942ef70..9a3eb32226e9957ddd581f7908317f8cd5532568 100644 (file)
@@ -21,7 +21,7 @@ class CommandNicklock : public Command
 {
  public:
        LocalIntExt& locked;
-       CommandNicklock (Module* Creator, LocalIntExt& ext) : Command(Creator->ServerInstance, Creator,"NICKLOCK", "o", 2),
+       CommandNicklock (Module* Creator, LocalIntExt& ext) : Command(ServerInstance, Creator,"NICKLOCK", "o", 2),
                locked(ext)
        {
                syntax = "<oldnick> <newnick>";
@@ -89,7 +89,7 @@ class CommandNickunlock : public Command
 {
  public:
        LocalIntExt& locked;
-       CommandNickunlock (Module* Creator, LocalIntExt& ext) : Command(Creator->ServerInstance, Creator,"NICKUNLOCK", "o", 1),
+       CommandNickunlock (Module* Creator, LocalIntExt& ext) : Command(ServerInstance, Creator,"NICKUNLOCK", "o", 1),
                locked(ext)
        {
                syntax = "<locked-nick>";
index 47f19e90d4b2f3039beeff737714a06806780463..7bf3a36236e40f253dc1255702c26bcce0b75910 100644 (file)
@@ -98,7 +98,7 @@ class ModuleOperPrefixMode : public Module
                modechange.push_back(channel->name);
                modechange.push_back(modeline);
                modechange.push_back(user->nick);
-               ServerInstance->SendMode(modechange,this->ServerInstance->FakeClient);
+               ServerInstance->SendMode(modechange,ServerInstance->FakeClient);
        }
 
        void OnPostJoin(Membership* memb)
index 41a5daf333efb06cb1a6881ad342796ea354779d..674a6dca54ffc826ce7fd4cbf66443024afdbe61 100644 (file)
@@ -17,7 +17,7 @@
 
 // Not in a class due to circular dependancy hell.
 static std::string permchannelsconf;
-static bool WriteDatabase(InspIRCd *ServerInstance)
+static bool WriteDatabase()
 {
        FILE *f;
 
@@ -100,7 +100,7 @@ class PermChannel : public ModeHandler
                                channel->SetMode('P',true);
 
                                // Save permchannels db if needed.
-                               WriteDatabase(ServerInstance);
+                               WriteDatabase();
                                return MODEACTION_ALLOW;
                        }
                }
@@ -134,7 +134,7 @@ class PermChannel : public ModeHandler
                                channel->SetMode('P',false);
 
                                // Save permchannels db if needed.
-                               WriteDatabase(ServerInstance);
+                               WriteDatabase();
                                return MODEACTION_ALLOW;
                        }
                }
@@ -253,7 +253,7 @@ public:
        virtual ModResult OnRawMode(User* user, Channel* chan, const char mode, const std::string &param, bool adding, int pcnt)
        {
                if (chan && chan->IsModeSet('P'))
-                       WriteDatabase(ServerInstance);
+                       WriteDatabase();
 
                return MOD_RES_PASSTHRU;
        }
@@ -261,7 +261,7 @@ public:
        virtual void OnPostTopicChange(User*, Channel *c, const std::string&)
        {
                if (c->IsModeSet('P'))
-                       WriteDatabase(ServerInstance);
+                       WriteDatabase();
        }
 
        virtual Version GetVersion()
index 2549461f1e432945f6abec8ae6590091dfd629d9..3877daf42e8ea2ff64f1194f8d1a230d08e5698e 100644 (file)
@@ -250,7 +250,7 @@ void ModuleSpanningTree::ConnectServer(Link* x)
 
        if (InspIRCd::Match(ServerInstance->Config->ServerName, assign(x->Name)))
        {
-               this->ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Not connecting to myself.");
+               ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Not connecting to myself.");
                return;
        }
 
@@ -282,7 +282,7 @@ void ModuleSpanningTree::ConnectServer(Link* x)
                }
                else
                {
-                       this->ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
+                       ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
                        if (ServerInstance->SocketCull.find(newsocket) == ServerInstance->SocketCull.end())
                                ServerInstance->SocketCull[newsocket] = newsocket;
                        Utils->DoFailOver(x);
@@ -298,7 +298,7 @@ void ModuleSpanningTree::ConnectServer(Link* x)
                }
                catch (ModuleException& e)
                {
-                       this->ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(), e.GetReason());
+                       ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(), e.GetReason());
                        Utils->DoFailOver(x);
                }
        }
index 7f60b2f93eea5c86979734b5cbfc35ad18b4ccba..b361205da7aa1053fc0ca50288d4111c94f6fea7 100644 (file)
@@ -109,9 +109,9 @@ void User::StartDNSLookup()
                UserResolver *res_reverse;
 
                QueryType resolvtype = this->client_sa.sa.sa_family == AF_INET6 ? DNS_QUERY_PTR6 : DNS_QUERY_PTR4;
-               res_reverse = new UserResolver(this->ServerInstance, this, sip, resolvtype, cached);
+               res_reverse = new UserResolver(ServerInstance, this, sip, resolvtype, cached);
 
-               this->ServerInstance->AddResolver(res_reverse, cached);
+               ServerInstance->AddResolver(res_reverse, cached);
        }
        catch (CoreException& e)
        {
@@ -205,7 +205,7 @@ void User::DecrementModes()
        }
 }
 
-User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance)
+User::User(InspIRCd* Instance, const std::string &uid)
 {
        server = Instance->FindServerNamePtr(Instance->Config->ServerName);
        age = ServerInstance->Time();
@@ -716,7 +716,7 @@ void User::FlushWriteBuf()
                        this->bytes_out += n_sent;
                        this->cmds_out++;
                        if (n_sent != old_sendq_length)
-                               this->ServerInstance->SE->WantWrite(this);
+                               ServerInstance->SE->WantWrite(this);
                }
        }
 
@@ -1219,7 +1219,7 @@ void User::Write(const std::string& text)
                this->AddWriteBuf("\r\n");
        }
        ServerInstance->stats->statsSent += text.length() + 2;
-       this->ServerInstance->SE->WantWrite(this);
+       ServerInstance->SE->WantWrite(this);
 }
 
 /** Write()
@@ -1567,7 +1567,7 @@ void User::DoHostCycle(const std::string &quitline)
                Channel* c = *v;
                snprintf(buffer, MAXBUF, ":%s JOIN %s", GetFullHost().c_str(), c->name.c_str());
                std::string joinline(buffer);
-               std::string modeline = this->ServerInstance->Modes->ModeString(this, c);
+               std::string modeline = ServerInstance->Modes->ModeString(this, c);
                if (modeline.length() > 0)
                {
                        snprintf(buffer, MAXBUF, ":%s MODE %s +%s", GetFullHost().c_str(), c->name.c_str(), modeline.c_str());