summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspircd_io.h6
-rw-r--r--src/commands.cpp10
-rw-r--r--src/helperfuncs.cpp1
-rw-r--r--src/inspircd.cpp20
-rw-r--r--src/inspircd_io.cpp9
-rw-r--r--src/mode.cpp4
-rw-r--r--src/modules.cpp8
-rw-r--r--src/userprocess.cpp1
8 files changed, 30 insertions, 29 deletions
diff --git a/include/inspircd_io.h b/include/inspircd_io.h
index b5993d8af..5575c4cda 100644
--- a/include/inspircd_io.h
+++ b/include/inspircd_io.h
@@ -19,6 +19,7 @@
#include <sstream>
#include <string>
+#include <vector>
#include "inspircd.h"
#include "globals.h"
@@ -32,6 +33,9 @@
class ServerConfig
{
+ private:
+ std::vector<std::string> include_stack;
+
public:
char ServerName[MAXBUF];
char Network[MAXBUF];
@@ -67,8 +71,10 @@ class ServerConfig
char PID[1024];
std::stringstream config_f;
ClassVector Classes;
+ std::vector<std::string> module_names;
ServerConfig();
+ ClearStack();
void Read(bool bail, userrec* user);
};
diff --git a/src/commands.cpp b/src/commands.cpp
index a9bc5895e..29eb0d7fe 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -73,11 +73,9 @@ extern int WHOWAS_STALE;
extern int WHOWAS_MAX;
extern time_t startup_time;
extern time_t TIME;
-extern std::vector<std::string> module_names;
extern int boundPortCount;
extern int portCount;
extern int ports[MAXSOCKS];
-extern ClassVector Classes;
const long duration_m = 60;
const long duration_h = duration_m * 60;
@@ -1276,7 +1274,7 @@ void handle_trace(char **parameters, int pcnt, userrec *user)
void handle_modules(char **parameters, int pcnt, userrec *user)
{
- for (unsigned int i = 0; i < module_names.size(); i++)
+ for (unsigned int i = 0; i < Config->module_names.size(); i++)
{
Version V = modules[i]->GetVersion();
char modulename[MAXBUF];
@@ -1292,7 +1290,7 @@ void handle_modules(char **parameters, int pcnt, userrec *user)
strlcat(flagstate,", service provider",MAXBUF);
if (!flagstate[0])
strcpy(flagstate," <no flags>");
- strlcpy(modulename,module_names[i].c_str(),256);
+ strlcpy(modulename,Config->module_names[i].c_str(),256);
if (strchr(user->modes,'o'))
{
WriteServ(user->fd,"900 %s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick,modules[i],V.Major,V.Minor,V.Revision,V.Build,CleanFilename(modulename),flagstate+2);
@@ -1328,7 +1326,7 @@ void handle_stats(char **parameters, int pcnt, userrec *user)
if (*parameters[0] == 'i')
{
int idx = 0;
- for (ClassVector::iterator i = Classes.begin(); i != Classes.end(); i++)
+ for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
{
WriteServ(user->fd,"215 %s I * * * %d %d %s *",user->nick,MAXCLIENTS,idx,Config->ServerName);
idx++;
@@ -1338,7 +1336,7 @@ void handle_stats(char **parameters, int pcnt, userrec *user)
if (*parameters[0] == 'y')
{
int idx = 0;
- for (ClassVector::iterator i = Classes.begin(); i != Classes.end(); i++)
+ for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
{
WriteServ(user->fd,"218 %s Y %d %d 0 %d %d",user->nick,idx,120,i->flood,i->registration_timeout);
idx++;
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 65a416a47..9e153c2f5 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -60,7 +60,6 @@ extern userrec* fd_ref_table[65536];
extern serverstats* stats;
static char already_sent[65536];
extern std::vector<userrec*> all_opers;
-extern ClassVector Classes;
extern user_hash clientlist;
extern chan_hash chanlist;
extern command_table cmdlist;
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 577b348e2..002b3ca52 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -68,7 +68,6 @@ int DieDelay = 5;
time_t startup_time = time(NULL);
extern std::vector<Module*> modules;
-std::vector<std::string> module_names;
extern std::vector<ircd_module*> factory;
std::vector<InspSocket*> module_sockets;
@@ -84,8 +83,6 @@ time_t TIME = time(NULL), OLDTIME = time(NULL);
SocketEngine* SE = NULL;
-extern std::vector<std::string> include_stack;
-
// 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.
@@ -1775,11 +1772,11 @@ void erase_module(int j)
v1++;
}
int v2 = 0;
- for (std::vector<std::string>::iterator v = module_names.begin(); v != module_names.end(); v++)
+ for (std::vector<std::string>::iterator v = Config->module_names.begin(); v != Config->module_names.end(); v++)
{
if (v2 == j)
{
- module_names.erase(v);
+ Config->module_names.erase(v);
break;
}
v2++;
@@ -1790,9 +1787,9 @@ void erase_module(int j)
bool UnloadModule(const char* filename)
{
std::string filename_str = filename;
- for (unsigned int j = 0; j != module_names.size(); j++)
+ for (unsigned int j = 0; j != Config->module_names.size(); j++)
{
- if (module_names[j] == filename_str)
+ if (Config->module_names[j] == filename_str)
{
if (modules[j]->GetVersion().Flags & VF_STATIC)
{
@@ -1809,7 +1806,7 @@ bool UnloadModule(const char* filename)
{
modules[j]->OnCleanup(TYPE_USER,u->second);
}
- FOREACH_MOD OnUnloadModule(modules[j],module_names[j]);
+ FOREACH_MOD OnUnloadModule(modules[j],Config->module_names[j]);
// found the module
log(DEBUG,"Deleting module...");
erase_module(j);
@@ -1849,9 +1846,9 @@ bool LoadModule(const char* filename)
if (FileExists(modfile))
{
#endif
- for (unsigned int j = 0; j < module_names.size(); j++)
+ for (unsigned int j = 0; j < Config->module_names.size(); j++)
{
- if (module_names[j] == filename_str)
+ if (Config->module_names[j] == filename_str)
{
log(DEFAULT,"Module %s is already loaded, cannot load a module twice!",modfile);
snprintf(MODERR,MAXBUF,"Module already loaded");
@@ -1873,7 +1870,7 @@ bool LoadModule(const char* filename)
modules[MODCOUNT+1] = m;
/* save the module and the module's classfactory, if
* this isnt done, random crashes can occur :/ */
- module_names.push_back(filename);
+ Config->module_names.push_back(filename);
}
else
{
@@ -1962,6 +1959,7 @@ int InspIRCd(char** argv, int argc)
* into smaller sub-functions, much tidier -- Brain
*/
OpenLog(argv, argc);
+ Config->ClearStack();
Config->Read(true,NULL);
CheckRoot();
SetupCommandTable();
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index 24eacb833..8bfa6a77e 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -30,15 +30,17 @@ using namespace std;
#include "inspircd_util.h"
#include "inspstring.h"
#include "helperfuncs.h"
+#include "xline.h"
extern ServerConfig *Config;
extern int boundPortCount;
extern int openSockfd[MAXSOCKS];
extern time_t TIME;
-std::vector<std::string> include_stack;
+
ServerConfig::ServerConfig()
{
+ this->ClearStack();
*ServerName = *Network = *ServerDesc = *AdminName = '\0';
*AdminEmail = *AdminNick = *diepass = *restartpass = '\0';
*motd = *rules = *PrefixQuit = *DieValue = *DNSServer = '\0';
@@ -57,6 +59,11 @@ ServerConfig::ServerConfig()
DieDelay = 5;
}
+ServerConfig::ClearStack()
+{
+ include_stack.clear();
+}
+
void ServerConfig::Read(bool bail, userrec* user)
{
diff --git a/src/mode.cpp b/src/mode.cpp
index 6e6270104..1e557dc25 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -49,8 +49,6 @@ using namespace std;
extern int MODCOUNT;
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
-extern std::vector<std::string> module_names;
-
extern ServerConfig* Config;
extern time_t TIME;
@@ -1220,7 +1218,7 @@ bool process_module_umode(char umode, userrec* source, void* dest, bool adding)
{
if (modules[i]->OnExtendedMode(source,(void*)dest,umode,MT_CLIENT,adding,p))
{
- log(DEBUG,"Module %s claims umode %c",module_names[i].c_str(),umode);
+ log(DEBUG,"Module %s claims umode %c",Config->module_names[i].c_str(),umode);
return true;
}
}
diff --git a/src/modules.cpp b/src/modules.cpp
index 62e84f218..4ff89df0c 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -55,28 +55,23 @@ extern ServerConfig *Config;
extern int MODCOUNT;
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
-extern std::vector<std::string> include_stack;
extern std::vector<InspSocket*> module_sockets;
extern time_t TIME;
extern int WHOWAS_STALE;
extern int WHOWAS_MAX;
extern time_t startup_time;
-extern std::vector<std::string> module_names;
extern int boundPortCount;
extern int portCount;
extern int ports[MAXSOCKS];
class Server;
-
extern userrec* fd_ref_table[65536];
extern user_hash clientlist;
extern chan_hash chanlist;
extern whowas_hash whowas;
extern command_table cmdlist;
-extern file_cache MOTD;
-extern file_cache RULES;
extern address_cache IP;
ExtModeList EMode;
@@ -738,7 +733,7 @@ Module* Server::FindModule(std::string name)
ConfigReader::ConfigReader()
{
- include_stack.clear();
+ Config->ClearStack();
this->cache = new std::stringstream(std::stringstream::in | std::stringstream::out);
this->errorlog = new std::stringstream(std::stringstream::in | std::stringstream::out);
this->readerror = LoadConf(CONFIG_FILE,this->cache,this->errorlog);
@@ -758,6 +753,7 @@ ConfigReader::~ConfigReader()
ConfigReader::ConfigReader(std::string filename)
{
+ Config->ClearStack();
this->cache = new std::stringstream(std::stringstream::in | std::stringstream::out);
this->errorlog = new std::stringstream(std::stringstream::in | std::stringstream::out);
this->readerror = LoadConf(filename.c_str(),this->cache,this->errorlog);
diff --git a/src/userprocess.cpp b/src/userprocess.cpp
index 055dc2075..338d7a1fd 100644
--- a/src/userprocess.cpp
+++ b/src/userprocess.cpp
@@ -64,7 +64,6 @@ extern int openSockfd[MAXSOCKS];
extern struct sockaddr_in client,server;
extern socklen_t length;
extern std::vector<Module*> modules;
-extern std::vector<std::string> module_names;
extern std::vector<ircd_module*> factory;
extern std::vector<InspSocket*> module_sockets;
extern SocketEngine* SE;