summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspircd.h12
-rw-r--r--include/modules.h26
-rw-r--r--src/channels.cpp3
-rw-r--r--src/cmd_away.cpp5
-rw-r--r--src/cmd_eline.cpp3
-rw-r--r--src/cmd_gline.cpp3
-rw-r--r--src/cmd_info.cpp3
-rw-r--r--src/cmd_invite.cpp3
-rw-r--r--src/cmd_kill.cpp3
-rw-r--r--src/cmd_kline.cpp3
-rw-r--r--src/cmd_modules.cpp9
-rw-r--r--src/cmd_nick.cpp3
-rw-r--r--src/cmd_notice.cpp3
-rw-r--r--src/cmd_oper.cpp3
-rw-r--r--src/cmd_privmsg.cpp3
-rw-r--r--src/cmd_qline.cpp3
-rw-r--r--src/cmd_quit.cpp3
-rw-r--r--src/cmd_rehash.cpp3
-rw-r--r--src/cmd_stats.cpp10
-rw-r--r--src/cmd_topic.cpp3
-rw-r--r--src/cmd_user.cpp4
-rw-r--r--src/cmd_wallops.cpp3
-rw-r--r--src/cmd_whois.cpp3
-rw-r--r--src/cmd_zline.cpp3
-rw-r--r--src/command_parse.cpp6
-rw-r--r--src/commands.cpp3
-rw-r--r--src/configreader.cpp4
-rw-r--r--src/helperfuncs.cpp15
-rw-r--r--src/inspircd.cpp56
-rw-r--r--src/mode.cpp4
-rw-r--r--src/modules.cpp26
-rw-r--r--src/modules/extra/m_sqloper.cpp4
-rw-r--r--src/modules/m_conn_lusers.cpp5
-rw-r--r--src/modules/m_httpd_stats.cpp4
-rw-r--r--src/modules/m_remove.cpp2
-rw-r--r--src/modules/m_safelist.cpp5
-rw-r--r--src/modules/m_spanningtree.cpp8
-rw-r--r--src/snomasks.cpp4
-rw-r--r--src/userprocess.cpp3
-rw-r--r--src/users.cpp3
-rw-r--r--src/xline.cpp4
41 files changed, 79 insertions, 197 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 63e8c8ce5..fd7cd3da9 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -104,6 +104,11 @@ class InspIRCd : public classbase
bool AllModulesReportReady(userrec* user);
+ int ModCount;
+ char LogFileName[MAXBUF];
+
+ featurelist Features;
+
public:
time_t startup_time;
ModeParser* ModeGrok;
@@ -120,6 +125,13 @@ class InspIRCd : public classbase
DNS* Res;
TimerManager* Timers;
+ ModuleList modules;
+ FactoryList factory;
+
+ int GetModuleCount();
+
+ Module* FindModule(const std::string &name);
+
void AddServerName(const std::string &servername);
const char* FindServerNamePtr(const std::string &servername);
bool FindServerName(const std::string &servername);
diff --git a/include/modules.h b/include/modules.h
index fc68db62e..6e326e00b 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -90,11 +90,11 @@ typedef std::map<std::string,Module*> featurelist;
* 'FOREACH_MOD(I_OnXonnwxr,OnConnect(user));'
*/
#define FOREACH_MOD(y,x) if (ServerInstance->Config->global_implementation[y] > 0) { \
- for (int _i = 0; _i <= MODCOUNT; _i++) { \
+ for (int _i = 0; _i <= ServerInstance->GetModuleCount(); _i++) { \
if (ServerInstance->Config->implement_lists[_i][y]) \
try \
{ \
- modules[_i]->x ; \
+ ServerInstance->modules[_i]->x ; \
} \
catch (ModuleException& modexcept) \
{ \
@@ -104,11 +104,11 @@ typedef std::map<std::string,Module*> featurelist;
}
#define FOREACH_MOD_I(z,y,x) if (z->Config->global_implementation[y] > 0) { \
- for (int _i = 0; _i <= MODCOUNT; _i++) { \
+ for (int _i = 0; _i <= z->GetModuleCount(); _i++) { \
if (z->Config->implement_lists[_i][y]) \
try \
{ \
- modules[_i]->x ; \
+ z->modules[_i]->x ; \
} \
catch (ModuleException& modexcept) \
{ \
@@ -123,11 +123,11 @@ typedef std::map<std::string,Module*> featurelist;
*/
#define FOREACH_RESULT(y,x) { if (ServerInstance->Config->global_implementation[y] > 0) { \
MOD_RESULT = 0; \
- for (int _i = 0; _i <= MODCOUNT; _i++) { \
+ for (int _i = 0; _i <= ServerInstance->GetModuleCount(); _i++) { \
if (ServerInstance->Config->implement_lists[_i][y]) { \
try \
{ \
- int res = modules[_i]->x ; \
+ int res = ServerInstance->modules[_i]->x ; \
if (res != 0) { \
MOD_RESULT = res; \
break; \
@@ -144,11 +144,11 @@ typedef std::map<std::string,Module*> featurelist;
#define FOREACH_RESULT_I(z,y,x) { if (z->Config->global_implementation[y] > 0) { \
MOD_RESULT = 0; \
- for (int _i = 0; _i <= MODCOUNT; _i++) { \
+ for (int _i = 0; _i <= z->GetModuleCount(); _i++) { \
if (z->Config->implement_lists[_i][y]) { \
try \
{ \
- int res = modules[_i]->x ; \
+ int res = z->modules[_i]->x ; \
if (res != 0) { \
MOD_RESULT = res; \
break; \
@@ -1414,12 +1414,6 @@ class Server : public Extensible
*/
bool IsValidMask(const std::string &mask);
- /** This function finds a module by name.
- * You must provide the filename of the module. If the module cannot be found (is not loaded)
- * the function will return NULL.
- */
- Module* FindModule(const std::string &name);
-
/** Adds a class derived from InspSocket to the server's socket engine.
*/
void AddSocket(InspSocket* sock);
@@ -1438,10 +1432,6 @@ class Server : public Extensible
*/
void RehashServer();
- /** This method returns the total number of channels on the network.
- */
- long GetChannelCount();
-
/** This method returns a channel whos index is greater than or equal to 0 and less than the number returned by Server::GetChannelCount().
* This is slower (by factors of dozens) than requesting a channel by name with Server::FindChannel(), however there are times when
* you wish to safely iterate the channel list, saving your position, with large amounts of time in between, which is what this function
diff --git a/src/channels.cpp b/src/channels.cpp
index 0a544b1d4..5e06e529d 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -38,9 +38,6 @@ using namespace std;
#include "helperfuncs.h"
#include "typedefs.h"
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
extern time_t TIME;
chanrec::chanrec(InspIRCd* Instance) : ServerInstance(Instance)
diff --git a/src/cmd_away.cpp b/src/cmd_away.cpp
index f5803f6ae..caef2c829 100644
--- a/src/cmd_away.cpp
+++ b/src/cmd_away.cpp
@@ -24,11 +24,6 @@
#include "commands/cmd_away.h"
extern InspIRCd* ServerInstance;
-extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-
void cmd_away::Handle (const char** parameters, int pcnt, userrec *user)
{
diff --git a/src/cmd_eline.cpp b/src/cmd_eline.cpp
index e2679fc14..c7e50eb16 100644
--- a/src/cmd_eline.cpp
+++ b/src/cmd_eline.cpp
@@ -24,10 +24,7 @@
#include "helperfuncs.h"
#include "commands/cmd_eline.h"
-extern int MODCOUNT;
extern InspIRCd* ServerInstance;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
void cmd_eline::Handle (const char** parameters, int pcnt, userrec *user)
{
diff --git a/src/cmd_gline.cpp b/src/cmd_gline.cpp
index ea526f8c8..208afd09c 100644
--- a/src/cmd_gline.cpp
+++ b/src/cmd_gline.cpp
@@ -25,9 +25,6 @@
#include "commands/cmd_eline.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
void cmd_gline::Handle (const char** parameters, int pcnt, userrec *user)
{
diff --git a/src/cmd_info.cpp b/src/cmd_info.cpp
index 536a1637f..e792f5fc2 100644
--- a/src/cmd_info.cpp
+++ b/src/cmd_info.cpp
@@ -22,9 +22,6 @@
#include "commands/cmd_info.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
void cmd_info::Handle (const char** parameters, int pcnt, userrec *user)
{
diff --git a/src/cmd_invite.cpp b/src/cmd_invite.cpp
index 9ca25aa08..f418fda5d 100644
--- a/src/cmd_invite.cpp
+++ b/src/cmd_invite.cpp
@@ -23,9 +23,6 @@
#include "commands/cmd_invite.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
void cmd_invite::Handle (const char** parameters, int pcnt, userrec *user)
{
diff --git a/src/cmd_kill.cpp b/src/cmd_kill.cpp
index 86a014267..ca2e9c6b4 100644
--- a/src/cmd_kill.cpp
+++ b/src/cmd_kill.cpp
@@ -25,9 +25,6 @@
#include "commands/cmd_kill.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user)
{
diff --git a/src/cmd_kline.cpp b/src/cmd_kline.cpp
index 5bdba041d..dc6c49dc2 100644
--- a/src/cmd_kline.cpp
+++ b/src/cmd_kline.cpp
@@ -32,9 +32,6 @@
#include "commands/cmd_kline.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
extern time_t TIME;
void cmd_kline::Handle (const char** parameters, int pcnt, userrec *user)
diff --git a/src/cmd_modules.cpp b/src/cmd_modules.cpp
index 650f2c587..c665580f7 100644
--- a/src/cmd_modules.cpp
+++ b/src/cmd_modules.cpp
@@ -32,9 +32,6 @@
#include "commands/cmd_modules.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
char* itab[] = {
"OnUserConnect", "OnUserQuit", "OnUserDisconnect", "OnUserJoin", "OnUserPart", "OnRehash", "OnServerRaw",
@@ -55,7 +52,7 @@ void cmd_modules::Handle (const char** parameters, int pcnt, userrec *user)
{
for (unsigned int i = 0; i < ServerInstance->Config->module_names.size(); i++)
{
- Version V = modules[i]->GetVersion();
+ Version V = ServerInstance->modules[i]->GetVersion();
char modulename[MAXBUF];
char flagstate[MAXBUF];
*flagstate = 0;
@@ -76,7 +73,7 @@ void cmd_modules::Handle (const char** parameters, int pcnt, userrec *user)
{
if (match(ServerInstance->Config->module_names[i].c_str(),parameters[1]))
{
- user->WriteServ("900 %s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick,modules[i],V.Major,V.Minor,V.Revision,V.Build,ServerConfig::CleanFilename(modulename),flagstate+2);
+ user->WriteServ("900 %s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick,ServerInstance->modules[i],V.Major,V.Minor,V.Revision,V.Build,ServerConfig::CleanFilename(modulename),flagstate+2);
for (int it = 0; itab[it];)
{
char data[MAXBUF];
@@ -107,7 +104,7 @@ void cmd_modules::Handle (const char** parameters, int pcnt, userrec *user)
}
else
{
- user->WriteServ("900 %s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick,modules[i],V.Major,V.Minor,V.Revision,V.Build,ServerConfig::CleanFilename(modulename),flagstate+2);
+ user->WriteServ("900 %s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick,ServerInstance->modules[i],V.Major,V.Minor,V.Revision,V.Build,ServerConfig::CleanFilename(modulename),flagstate+2);
}
}
else
diff --git a/src/cmd_nick.cpp b/src/cmd_nick.cpp
index 681c495aa..5dacc4812 100644
--- a/src/cmd_nick.cpp
+++ b/src/cmd_nick.cpp
@@ -29,9 +29,6 @@
#include "commands/cmd_nick.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
extern time_t TIME;
void cmd_nick::Handle (const char** parameters, int pcnt, userrec *user)
diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp
index c32960719..f94ac5bb7 100644
--- a/src/cmd_notice.cpp
+++ b/src/cmd_notice.cpp
@@ -29,9 +29,6 @@
#include "commands/cmd_notice.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
extern time_t TIME;
void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user)
diff --git a/src/cmd_oper.cpp b/src/cmd_oper.cpp
index 2b4e3e206..a15c3d7e0 100644
--- a/src/cmd_oper.cpp
+++ b/src/cmd_oper.cpp
@@ -37,9 +37,6 @@
#include "commands/cmd_oper.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern ModuleList modules;
-extern FactoryList factory;
extern time_t TIME;
bool OneOfMatches(const char* host, const char* ip, const char* hostlist)
diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp
index f77c47c98..06207059d 100644
--- a/src/cmd_privmsg.cpp
+++ b/src/cmd_privmsg.cpp
@@ -26,9 +26,6 @@
#include "commands/cmd_privmsg.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern ModuleList modules;
-extern FactoryList factory;
extern time_t TIME;
void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user)
diff --git a/src/cmd_qline.cpp b/src/cmd_qline.cpp
index 1452a0658..3e5e9fbdf 100644
--- a/src/cmd_qline.cpp
+++ b/src/cmd_qline.cpp
@@ -24,9 +24,6 @@
#include "commands/cmd_qline.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern ModuleList modules;
-extern FactoryList factory;
void cmd_qline::Handle (const char** parameters, int pcnt, userrec *user)
{
diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp
index afc4e9d8c..9c1e11179 100644
--- a/src/cmd_quit.cpp
+++ b/src/cmd_quit.cpp
@@ -35,9 +35,6 @@
#include "commands/cmd_quit.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern ModuleList modules;
-extern FactoryList factory;
extern time_t TIME;
void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
diff --git a/src/cmd_rehash.cpp b/src/cmd_rehash.cpp
index 3f6657943..bb09734a6 100644
--- a/src/cmd_rehash.cpp
+++ b/src/cmd_rehash.cpp
@@ -22,9 +22,6 @@
#include "commands/cmd_rehash.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern ModuleList modules;
-extern FactoryList factory;
void cmd_rehash::Handle (const char** parameters, int pcnt, userrec *user)
{
diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp
index 98a46569f..e8d92e106 100644
--- a/src/cmd_stats.cpp
+++ b/src/cmd_stats.cpp
@@ -42,10 +42,7 @@
#include "commands/cmd_stats.h"
extern InspIRCd* ServerInstance;
-extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern ModuleList modules;
-extern FactoryList factory;
+
extern time_t TIME;
void cmd_stats::Handle (const char** parameters, int pcnt, userrec *user)
@@ -163,12 +160,13 @@ void DoStats(char statschar, userrec* user, string_list &results)
if (statschar == 'z')
{
rusage R;
+ results.push_back(sn+" 240 "+user->nick+" :InspIRCd(CLASS) "+ConvToStr(sizeof(InspIRCd))+" bytes");
results.push_back(sn+" 249 "+user->nick+" :Users(HASH_MAP) "+ConvToStr(ServerInstance->clientlist.size())+" ("+ConvToStr(ServerInstance->clientlist.size()*sizeof(userrec))+" bytes, "+ConvToStr(ServerInstance->clientlist.bucket_count())+" buckets)");
results.push_back(sn+" 249 "+user->nick+" :Channels(HASH_MAP) "+ConvToStr(ServerInstance->chanlist.size())+" ("+ConvToStr(ServerInstance->chanlist.size()*sizeof(chanrec))+" bytes, "+ConvToStr(ServerInstance->chanlist.bucket_count())+" buckets)");
results.push_back(sn+" 249 "+user->nick+" :Commands(VECTOR) "+ConvToStr(ServerInstance->Parser->cmdlist.size())+" ("+ConvToStr(ServerInstance->Parser->cmdlist.size()*sizeof(command_t))+" bytes)");
results.push_back(sn+" 249 "+user->nick+" :MOTD(VECTOR) "+ConvToStr(ServerInstance->Config->MOTD.size())+", RULES(VECTOR) "+ConvToStr(ServerInstance->Config->RULES.size()));
- results.push_back(sn+" 249 "+user->nick+" :Modules(VECTOR) "+ConvToStr(modules.size())+" ("+ConvToStr(modules.size()*sizeof(Module))+")");
- results.push_back(sn+" 249 "+user->nick+" :ClassFactories(VECTOR) "+ConvToStr(factory.size())+" ("+ConvToStr(factory.size()*sizeof(ircd_module))+")");
+ results.push_back(sn+" 249 "+user->nick+" :Modules(VECTOR) "+ConvToStr(ServerInstance->modules.size())+" ("+ConvToStr(ServerInstance->modules.size()*sizeof(Module))+")");
+ results.push_back(sn+" 249 "+user->nick+" :ClassFactories(VECTOR) "+ConvToStr(ServerInstance->factory.size())+" ("+ConvToStr(ServerInstance->factory.size()*sizeof(ircd_module))+")");
if (!getrusage(RUSAGE_SELF,&R))
{
results.push_back(sn+" 249 "+user->nick+" :Total allocation: "+ConvToStr(R.ru_maxrss)+"K");
diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp
index adb460c80..e745e5abc 100644
--- a/src/cmd_topic.cpp
+++ b/src/cmd_topic.cpp
@@ -23,10 +23,7 @@
#include "helperfuncs.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
extern time_t TIME;
-extern ModuleList modules;
-extern FactoryList factory;
void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
{
diff --git a/src/cmd_user.cpp b/src/cmd_user.cpp
index 72eb3afcf..79bb9c691 100644
--- a/src/cmd_user.cpp
+++ b/src/cmd_user.cpp
@@ -23,10 +23,6 @@
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern ModuleList modules;
-extern FactoryList factory;
-
void cmd_user::Handle (const char** parameters, int pcnt, userrec *user)
{
if (user->registered < REG_NICKUSER)
diff --git a/src/cmd_wallops.cpp b/src/cmd_wallops.cpp
index 752d14f41..91c6853e3 100644
--- a/src/cmd_wallops.cpp
+++ b/src/cmd_wallops.cpp
@@ -20,9 +20,6 @@
#include "helperfuncs.h"
#include "commands/cmd_wallops.h"
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
extern InspIRCd* ServerInstance;
void cmd_wallops::Handle (const char** parameters, int pcnt, userrec *user)
diff --git a/src/cmd_whois.cpp b/src/cmd_whois.cpp
index bbd3f28e4..15ae9110b 100644
--- a/src/cmd_whois.cpp
+++ b/src/cmd_whois.cpp
@@ -24,9 +24,6 @@
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern ModuleList modules;
-extern FactoryList factory;
extern time_t TIME;
const char* Spacify(char* n)
diff --git a/src/cmd_zline.cpp b/src/cmd_zline.cpp
index ab068479e..f62c7058a 100644
--- a/src/cmd_zline.cpp
+++ b/src/cmd_zline.cpp
@@ -25,9 +25,6 @@
#include "commands/cmd_zline.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern ModuleList modules;
-extern FactoryList factory;
void cmd_zline::Handle (const char** parameters, int pcnt, userrec *user)
{
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 3e6a9ed20..952a65e36 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -50,16 +50,10 @@
extern InspIRCd* ServerInstance;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-
-extern int MODCOUNT;
extern time_t TIME;
extern Server* MyServer;
-extern chan_hash chanlist;
-
/* Special commands which may occur without registration of the user */
cmd_user* command_user;
cmd_nick* command_nick;
diff --git a/src/commands.cpp b/src/commands.cpp
index edaa8045d..9fe677d70 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -51,9 +51,6 @@
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern ModuleList modules;
-extern FactoryList factory;
extern time_t TIME;
const long duration_m = 60;
diff --git a/src/configreader.cpp b/src/configreader.cpp
index f60885c2e..0f9fbfc7f 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -28,10 +28,6 @@
extern time_t TIME;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-
using irc::sockets::BindPorts;
std::vector<std::string> old_module_names, new_module_names, added_modules, removed_modules;
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index a6c4f1f5e..dc6c3e00d 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -43,15 +43,9 @@
#include "typedefs.h"
#include "inspircd.h"
-extern int MODCOUNT;
-extern ModuleList modules;
-
extern time_t TIME;
-extern char lowermap[255];
extern std::vector<userrec*> all_opers;
-char LOG_FILE[MAXBUF];
-
static char TIMESTR[26];
static time_t LAST = 0;
@@ -473,7 +467,7 @@ bool InspIRCd::IsChannel(const char *chname)
void InspIRCd::OpenLog(char** argv, int argc)
{
- if (!*LOG_FILE)
+ if (!*this->LogFileName)
{
if (Config->logpath == "")
{
@@ -482,7 +476,7 @@ void InspIRCd::OpenLog(char** argv, int argc)
}
else
{
- Config->log_file = fopen(LOG_FILE,"a+");
+ Config->log_file = fopen(this->LogFileName,"a+");
if (!Config->log_file)
{
@@ -526,7 +520,7 @@ void InspIRCd::LoadAllModules()
{
char configToken[MAXBUF];
Config->module_names.clear();
- MODCOUNT = -1;
+ this->ModCount = -1;
for (int count = 0; count < Config->ConfValueEnum(Config->config_data, "module"); count++)
{
@@ -540,6 +534,7 @@ void InspIRCd::LoadAllModules()
Exit(ERROR);
}
}
- log(DEFAULT,"Total loaded modules: %lu",(unsigned long)MODCOUNT+1);
+ printf("\nA total of \033[1;32m%d\033[0m module%s been loaded.\n", this->ModCount+1, this->ModCount+1 == 1 ? " has" : "s have");
+ log(DEFAULT,"Total loaded modules: %d", this->ModCount+1);
}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index dfebb00d7..5ed9b1cc9 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -72,12 +72,6 @@ using irc::sockets::insp_sockaddr;
InspIRCd* ServerInstance = NULL;
-extern ModuleList modules;
-extern FactoryList factory;
-
-extern int MODCOUNT;
-extern char LOG_FILE[MAXBUF];
-
int iterations = 0;
insp_sockaddr client, server;
@@ -216,10 +210,14 @@ void InspIRCd::MakeLowerMap()
lowermap[(unsigned)'\\'] = '|';
}
-InspIRCd::InspIRCd(int argc, char** argv)
+InspIRCd::InspIRCd(int argc, char** argv) : ModCount(-1)
{
bool SEGVHandler = false;
ServerInstance = this;
+
+ modules.resize(255);
+ factory.resize(255);
+
this->Config = new ServerConfig(this);
this->Start();
this->module_sockets.clear();
@@ -233,7 +231,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
printf("ERROR: Your config file is missing, this IRCd will self destruct in 10 seconds!\n");
Exit(ERROR);
}
- *LOG_FILE = 0;
+ *this->LogFileName = 0;
if (argc > 1) {
for (int i = 1; i < argc; i++)
{
@@ -265,8 +263,8 @@ InspIRCd::InspIRCd(int argc, char** argv)
{
if (argc > i+1)
{
- strlcpy(LOG_FILE,argv[i+1],MAXBUF);
- printf("LOG: Setting logfile to %s\n",LOG_FILE);
+ strlcpy(LogFileName,argv[i+1],MAXBUF);
+ printf("LOG: Setting logfile to %s\n",LogFileName);
}
else
{
@@ -366,7 +364,7 @@ void InspIRCd::EraseFactory(int j)
void InspIRCd::EraseModule(int j)
{
int v1 = 0;
- for (std::vector<Module*>::iterator m = modules.begin(); m!= modules.end(); m++)
+ for (ModuleList::iterator m = modules.begin(); m!= modules.end(); m++)
{
if (v1 == j)
{
@@ -397,7 +395,7 @@ void InspIRCd::MoveTo(std::string modulename,int slot)
{
if (Config->module_names[v] == modulename)
{
- // found an instance, swap it with the item at MODCOUNT
+ // found an instance, swap it with the item at the end
v2 = v;
break;
}
@@ -468,7 +466,7 @@ void InspIRCd::MoveToFirst(std::string modulename)
void InspIRCd::MoveToLast(std::string modulename)
{
- MoveTo(modulename,MODCOUNT);
+ MoveTo(modulename,this->GetModuleCount());
}
void InspIRCd::BuildISupport()
@@ -530,7 +528,7 @@ bool InspIRCd::UnloadModule(const char* filename)
log(DEBUG,"Erasing module entry...");
this->EraseFactory(j);
log(DEFAULT,"Module %s unloaded",filename);
- MODCOUNT--;
+ this->ModCount--;
BuildISupport();
return true;
}
@@ -576,29 +574,29 @@ bool InspIRCd::LoadModule(const char* filename)
try
{
ircd_module* a = new ircd_module(modfile);
- factory[MODCOUNT+1] = a;
- if (factory[MODCOUNT+1]->LastError())
+ factory[this->ModCount+1] = a;
+ if (factory[this->ModCount+1]->LastError())
{
- log(DEFAULT,"Unable to load %s: %s",modfile,factory[MODCOUNT+1]->LastError());
- snprintf(MODERR,MAXBUF,"Loader/Linker error: %s",factory[MODCOUNT+1]->LastError());
+ log(DEFAULT,"Unable to load %s: %s",modfile,factory[this->ModCount+1]->LastError());
+ snprintf(MODERR,MAXBUF,"Loader/Linker error: %s",factory[this->ModCount+1]->LastError());
return false;
}
- if ((long)factory[MODCOUNT+1]->factory != -1)
+ if ((long)factory[this->ModCount+1]->factory != -1)
{
- Module* m = factory[MODCOUNT+1]->factory->CreateModule(MyServer);
- modules[MODCOUNT+1] = m;
+ Module* m = factory[this->ModCount+1]->factory->CreateModule(MyServer);
+ modules[this->ModCount+1] = m;
/* save the module and the module's classfactory, if
* this isnt done, random crashes can occur :/ */
Config->module_names.push_back(filename);
- char* x = &Config->implement_lists[MODCOUNT+1][0];
+ char* x = &Config->implement_lists[this->ModCount+1][0];
for(int t = 0; t < 255; t++)
x[t] = 0;
- modules[MODCOUNT+1]->Implements(x);
+ modules[this->ModCount+1]->Implements(x);
for(int t = 0; t < 255; t++)
- Config->global_implementation[t] += Config->implement_lists[MODCOUNT+1][t];
+ Config->global_implementation[t] += Config->implement_lists[this->ModCount+1][t];
}
else
{
@@ -622,8 +620,8 @@ bool InspIRCd::LoadModule(const char* filename)
return false;
}
#endif
- MODCOUNT++;
- FOREACH_MOD(I_OnLoadModule,OnLoadModule(modules[MODCOUNT],filename_str));
+ this->ModCount++;
+ FOREACH_MOD(I_OnLoadModule,OnLoadModule(modules[this->ModCount],filename_str));
// now work out which modules, if any, want to move to the back of the queue,
// and if they do, move them there.
std::vector<std::string> put_to_back;
@@ -1026,7 +1024,7 @@ bool InspIRCd::AllModulesReportReady(userrec* user)
if (!Config->global_implementation[I_OnCheckReady])
return true;
- for (int i = 0; i <= MODCOUNT; i++)
+ for (int i = 0; i <= this->GetModuleCount(); i++)
{
if (Config->implement_lists[i][I_OnCheckReady])
{
@@ -1038,4 +1036,8 @@ bool InspIRCd::AllModulesReportReady(userrec* user)
return true;
}
+int InspIRCd::GetModuleCount()
+{
+ return this->ModCount;
+}
diff --git a/src/mode.cpp b/src/mode.cpp
index b0043b828..29b935475 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -65,10 +65,6 @@ using namespace std;
/* +n (notice mask - our implementation of snomasks) */
#include "modes/umode_n.h"
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-
extern InspIRCd* ServerInstance;
extern time_t TIME;
diff --git a/src/modules.cpp b/src/modules.cpp
index f3219df76..9321047a8 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -46,16 +46,11 @@
#include "inspircd.h"
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern ModuleList modules;
-extern FactoryList factory;
extern time_t TIME;
extern command_table cmdlist;
class Server;
-featurelist Features;
-
// version is a simple class for holding a modules version number
Version::Version(int major, int minor, int revision, int build, int flags)
@@ -298,9 +293,9 @@ Module* InspIRCd::FindFeature(const std::string &FeatureName)
const std::string& InspIRCd::GetModuleName(Module* m)
{
static std::string nothing = ""; /* Prevent compiler warning */
- for (int i = 0; i <= MODCOUNT; i++)
+ for (int i = 0; i <= this->GetModuleCount(); i++)
{
- if (modules[i] == m)
+ if (this->modules[i] == m)
{
return this->Config->module_names[i];
}
@@ -326,11 +321,6 @@ void Server::DelSocket(InspSocket* sock)
}
}
-long Server::GetChannelCount()
-{
- return (long)ServerInstance->chanlist.size();
-}
-
/* This is ugly, yes, but hash_map's arent designed to be
* addressed in this manner, and this is a bit of a kludge.
* Luckily its a specialist function and rarely used by
@@ -578,13 +568,13 @@ bool Server::IsValidMask(const std::string &mask)
return true;
}
-Module* Server::FindModule(const std::string &name)
+Module* InspIRCd::FindModule(const std::string &name)
{
- for (int i = 0; i <= MODCOUNT; i++)
+ for (int i = 0; i <= this->GetModuleCount(); i++)
{
- if (ServerInstance->Config->module_names[i] == name)
+ if (this->Config->module_names[i] == name)
{
- return modules[i];
+ return this->modules[i];
}
}
return NULL;
@@ -806,7 +796,3 @@ int FileReader::FileSize()
}
-std::vector<Module*> modules(255);
-std::vector<ircd_module*> factory(255);
-
-int MODCOUNT = -1;
diff --git a/src/modules/extra/m_sqloper.cpp b/src/modules/extra/m_sqloper.cpp
index 7e905d691..cd4ef7102 100644
--- a/src/modules/extra/m_sqloper.cpp
+++ b/src/modules/extra/m_sqloper.cpp
@@ -28,10 +28,6 @@
/* $ModDesc: Allows storage of oper credentials in an SQL table */
-/* Required for the FOREACH_MOD alias (OnOper event) */
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
extern InspIRCd* ServerInstance;
class ModuleSQLOper : public Module
diff --git a/src/modules/m_conn_lusers.cpp b/src/modules/m_conn_lusers.cpp
index 2d9823015..f988c76c0 100644
--- a/src/modules/m_conn_lusers.cpp
+++ b/src/modules/m_conn_lusers.cpp
@@ -19,9 +19,12 @@ using namespace std;
#include "users.h"
#include "channels.h"
#include "modules.h"
+#include "inspircd.h"
/* $ModDesc: Sends the /LUSERS on connect */
+extern InspIRCd* ServerInstance;
+
// This has to be the simplest module ever.
// The RFC doesnt specify that you should send the /LUSERS numerics
// on connect, but someone asked for it, so its in a module.
@@ -60,7 +63,7 @@ class ModuleConnLUSERS : public Module
// protocol module. Yes, at some point there will
// be a way to get the current protocol module's name
// from the core and probably a pointer to its class.
- Module* Proto = Srv->FindModule("m_spanningtree.so");
+ Module* Proto = ServerInstance->FindModule("m_spanningtree.so");
if (Proto)
{
Proto->OnPreCommand("LUSERS", NULL, 0, user, true);
diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp
index e68a3756f..27548c91c 100644
--- a/src/modules/m_httpd_stats.cpp
+++ b/src/modules/m_httpd_stats.cpp
@@ -31,8 +31,6 @@ using namespace std;
extern std::vector<userrec*> all_opers;
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-
typedef std::map<irc::string,int> StatsHash;
typedef StatsHash::iterator StatsIter;
@@ -123,7 +121,7 @@ class ModuleHttpStats : public Module
data << "<div class='modules'>";
data << "<h2>Modules</h2>";
data << "<table>";
- for (int i = 0; i <= MODCOUNT; i++)
+ for (int i = 0; i <= ServerInstance->GetModuleCount(); i++)
{
if (ServerInstance->Config->module_names[i] != "")
data << "<tr><td>" << ServerInstance->Config->module_names[i] << "</td></tr>";
diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp
index e681d39b6..5fa614312 100644
--- a/src/modules/m_remove.cpp
+++ b/src/modules/m_remove.cpp
@@ -154,7 +154,7 @@ class RemoveBase
tlevel = chartolevel(channel->GetStatusChar(target));
}
- hasnokicks = (Srv->FindModule("m_nokicks.so") && channel->IsModeSet('Q'));
+ hasnokicks = (ServerInstance->FindModule("m_nokicks.so") && channel->IsModeSet('Q'));
/* We support the +Q channel mode via. the m_nokicks module, if the module is loaded and the mode is set then disallow the /remove */
if(!supportnokicks || !hasnokicks || (ulevel == ULINE))
diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp
index 2ffb851b9..543966112 100644
--- a/src/modules/m_safelist.cpp
+++ b/src/modules/m_safelist.cpp
@@ -75,13 +75,14 @@ class ListTimer : public InspTimer
/*
* What we do here:
* - Get where they are up to
- * - If it's > GetChannelCount, erase them from the iterator, set go_again to true
+ * - If it's more than total number of channels, erase
+ * them from the iterator, set go_again to true
* - If not, spool more channels
*/
userrec* u = (userrec*)(*iter);
ListData* ld;
u->GetExt("safelist_cache", ld);
- if (ld->list_position > Srv->GetChannelCount())
+ if ((size_t)ld->list_position > ServerInstance->chanlist.size())
{
u->Shrink("safelist_cache");
DELETE(ld);
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index cd13e5bfd..d9e18ef80 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -71,10 +71,6 @@ static ModuleSpanningTree* TreeProtocolModule;
extern InspIRCd* ServerInstance;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-extern int MODCOUNT;
-
/* Any socket can have one of five states at any one time.
* The LISTENER state indicates a socket which is listening
* for connections. It cannot receive data itself, only incoming
@@ -820,9 +816,9 @@ class TreeSocket : public InspSocket
std::vector<std::string> modlist;
std::string capabilities = "";
- for (int i = 0; i <= MODCOUNT; i++)
+ for (int i = 0; i <= ServerInstance->GetModuleCount(); i++)
{
- if ((modules[i]->GetVersion().Flags & VF_STATIC) || (modules[i]->GetVersion().Flags & VF_COMMON))
+ if ((ServerInstance->modules[i]->GetVersion().Flags & VF_STATIC) || (ServerInstance->modules[i]->GetVersion().Flags & VF_COMMON))
modlist.push_back(ServerInstance->Config->module_names[i]);
}
sort(modlist.begin(),modlist.end());
diff --git a/src/snomasks.cpp b/src/snomasks.cpp
index 083d8023c..7aac60330 100644
--- a/src/snomasks.cpp
+++ b/src/snomasks.cpp
@@ -24,7 +24,3 @@
#include "helperfuncs.h"
#include "snomasks.h"
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-
diff --git a/src/userprocess.cpp b/src/userprocess.cpp
index d2549b7c2..9789a2ddf 100644
--- a/src/userprocess.cpp
+++ b/src/userprocess.cpp
@@ -53,8 +53,7 @@ using namespace std;
extern struct sockaddr_in client,server;
extern socklen_t length;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
+
extern time_t TIME;
extern time_t OLDTIME;
char data[65536];
diff --git a/src/users.cpp b/src/users.cpp
index 7c1409a33..63cc1763d 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -31,9 +31,6 @@
#include "xline.h"
#include "cull_list.h"
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-extern int MODCOUNT;
extern time_t TIME;
extern Server* MyServer;
diff --git a/src/xline.cpp b/src/xline.cpp
index c32b7bd39..6584a70e6 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -40,10 +40,6 @@ using namespace std;
extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-
/* Version two, now with optimized expiry!
*
* Because the old way was horrendously slow, the new way of expiring xlines is very