summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-13 20:31:54 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-13 20:31:54 +0000
commitd9e3bb8d4343643504ab7ee6ab943a000065cc8a (patch)
tree24d5d857f66b843f2d08c8a39ebbf812592c0f73 /src
parent8f9dafbfa3b62b1c88a8b1ad7988d5786f914528 (diff)
Remove redundant ServerInstance* fields
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
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp4
-rw-r--r--src/inspircd.cpp12
-rw-r--r--src/mode.cpp5
-rw-r--r--src/modules.cpp6
-rw-r--r--src/modules/m_callerid.cpp4
-rw-r--r--src/modules/m_delayjoin.cpp2
-rw-r--r--src/modules/m_nicklock.cpp4
-rw-r--r--src/modules/m_operprefix.cpp2
-rw-r--r--src/modules/m_permchannels.cpp10
-rw-r--r--src/modules/m_spanningtree/main.cpp6
-rw-r--r--src/users.cpp12
11 files changed, 33 insertions, 34 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 3685f6604..7f2cefd2b 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -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();
}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 3d80f5250..8f763e2b6 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -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;
}
diff --git a/src/mode.cpp b/src/mode.cpp
index 86438bf73..9c608c37a 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -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),
diff --git a/src/modules.cpp b/src/modules.cpp
index 979c42119..9664e817f 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -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; }
diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp
index 16b883f63..b84ee2c9c 100644
--- a/src/modules/m_callerid.cpp
+++ b/src/modules/m_callerid.cpp
@@ -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);
}
diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp
index ffaf1223b..a7a8575b4 100644
--- a/src/modules/m_delayjoin.cpp
+++ b/src/modules/m_delayjoin.cpp
@@ -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());
}
diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp
index ddfc47455..9a3eb3222 100644
--- a/src/modules/m_nicklock.cpp
+++ b/src/modules/m_nicklock.cpp
@@ -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>";
diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp
index 47f19e90d..7bf3a3623 100644
--- a/src/modules/m_operprefix.cpp
+++ b/src/modules/m_operprefix.cpp
@@ -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)
diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp
index 41a5daf33..674a6dca5 100644
--- a/src/modules/m_permchannels.cpp
+++ b/src/modules/m_permchannels.cpp
@@ -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()
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 2549461f1..3877daf42 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -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);
}
}
diff --git a/src/users.cpp b/src/users.cpp
index 7f60b2f93..b361205da 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -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());