diff options
-rw-r--r-- | include/inspircd.h | 4 | ||||
-rw-r--r-- | src/commands.cpp | 19 | ||||
-rw-r--r-- | src/inspircd.cpp | 6 | ||||
-rw-r--r-- | src/mode.cpp | 27 | ||||
-rw-r--r-- | src/modules.cpp | 11 | ||||
-rw-r--r-- | src/userprocess.cpp | 4 |
6 files changed, 33 insertions, 38 deletions
diff --git a/include/inspircd.h b/include/inspircd.h index 0ebc3420c..4e7710714 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -42,6 +42,8 @@ #include "users.h" #include "channels.h" #include "socket.h" +#include "mode.h" +#include "command_parse.h" // some misc defines @@ -103,6 +105,8 @@ class InspIRCd public: time_t startup_time; + ModeParser* ModeGrok; + CommandParser* Parser; std::string GetRevision(); std::string GetVersionString(); diff --git a/src/commands.cpp b/src/commands.cpp index 061ec61ae..6fb096d5c 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -66,7 +66,6 @@ using namespace std; extern SocketEngine* SE; extern ServerConfig* Config; extern InspIRCd* ServerInstance; -extern CommandParser *Parser; extern int MODCOUNT; extern std::vector<Module*> modules; @@ -497,7 +496,7 @@ void handle_names(char **parameters, int pcnt, userrec *user) return; } - if (Parser->LoopCall(handle_names,parameters,pcnt,user,0,pcnt-1,0)) + if (ServerInstance->Parser->LoopCall(handle_names,parameters,pcnt,user,0,pcnt-1,0)) return; c = FindChan(parameters[0]); if (c) @@ -523,7 +522,7 @@ void handle_privmsg(char **parameters, int pcnt, userrec *user) user->idle_lastmsg = TIME; - if (Parser->LoopCall(handle_privmsg,parameters,pcnt,user,0,pcnt-2,0)) + if (ServerInstance->Parser->LoopCall(handle_privmsg,parameters,pcnt,user,0,pcnt-2,0)) return; if (parameters[0][0] == '$') { @@ -618,7 +617,7 @@ void handle_notice(char **parameters, int pcnt, userrec *user) user->idle_lastmsg = TIME; - if (Parser->LoopCall(handle_notice,parameters,pcnt,user,0,pcnt-2,0)) + if (ServerInstance->Parser->LoopCall(handle_notice,parameters,pcnt,user,0,pcnt-2,0)) return; if (parameters[0][0] == '$') { @@ -762,7 +761,7 @@ void handle_time(char **parameters, int pcnt, userrec *user) void handle_whois(char **parameters, int pcnt, userrec *user) { userrec *dest; - if (Parser->LoopCall(handle_whois,parameters,pcnt,user,0,pcnt-1,0)) + if (ServerInstance->Parser->LoopCall(handle_whois,parameters,pcnt,user,0,pcnt-1,0)) return; dest = Find(parameters[0]); if (dest) @@ -1401,14 +1400,14 @@ void handle_stats(char **parameters, int pcnt, userrec *user) /* stats m (list number of times each command has been used, plus bytecount) */ if (*parameters[0] == 'm') { - for (unsigned int i = 0; i < Parser->cmdlist.size(); i++) + for (unsigned int i = 0; i < ServerInstance->Parser->cmdlist.size(); i++) { - if (Parser->cmdlist[i].handler_function) + if (ServerInstance->Parser->cmdlist[i].handler_function) { - if (Parser->cmdlist[i].use_count) + if (ServerInstance->Parser->cmdlist[i].use_count) { /* RPL_STATSCOMMANDS */ - WriteServ(user->fd,"212 %s %s %d %d",user->nick,Parser->cmdlist[i].command,Parser->cmdlist[i].use_count,Parser->cmdlist[i].total_bytes); + WriteServ(user->fd,"212 %s %s %d %d",user->nick,ServerInstance->Parser->cmdlist[i].command,ServerInstance->Parser->cmdlist[i].use_count,ServerInstance->Parser->cmdlist[i].total_bytes); } } } @@ -1421,7 +1420,7 @@ void handle_stats(char **parameters, int pcnt, userrec *user) rusage R; WriteServ(user->fd,"249 %s :Users(HASH_MAP) %d (%d bytes, %d buckets)",user->nick,clientlist.size(),clientlist.size()*sizeof(userrec),clientlist.bucket_count()); WriteServ(user->fd,"249 %s :Channels(HASH_MAP) %d (%d bytes, %d buckets)",user->nick,chanlist.size(),chanlist.size()*sizeof(chanrec),chanlist.bucket_count()); - WriteServ(user->fd,"249 %s :Commands(VECTOR) %d (%d bytes)",user->nick,Parser->cmdlist.size(),Parser->cmdlist.size()*sizeof(command_t)); + WriteServ(user->fd,"249 %s :Commands(VECTOR) %d (%d bytes)",user->nick,ServerInstance->Parser->cmdlist.size(),ServerInstance->Parser->cmdlist.size()*sizeof(command_t)); WriteServ(user->fd,"249 %s :MOTD(VECTOR) %d, RULES(VECTOR) %d",user->nick,Config->MOTD.size(),Config->RULES.size()); WriteServ(user->fd,"249 %s :Modules(VECTOR) %d (%d)",user->nick,modules.size(),modules.size()*sizeof(Module)); WriteServ(user->fd,"249 %s :ClassFactories(VECTOR) %d (%d)",user->nick,factory.size(),factory.size()*sizeof(ircd_module)); diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 89b7d9e8c..ddd5c148f 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -92,8 +92,6 @@ userrec* fd_ref_table[65536]; serverstats* stats = new serverstats; Server* MyServer = new Server; ServerConfig *Config = new ServerConfig; -CommandParser *Parser = NULL; -ModeParser *ModeGrok = NULL; user_hash clientlist; chan_hash chanlist; @@ -189,8 +187,8 @@ InspIRCd::InspIRCd(int argc, char** argv) Config->ClearStack(); Config->Read(true,NULL); CheckRoot(); - ModeGrok = new ModeParser(); - Parser = new CommandParser(); + this->ModeGrok = new ModeParser(); + this->Parser = new CommandParser(); AddServerName(Config->ServerName); CheckDie(); stats->BoundPortCount = BindPorts(); diff --git a/src/mode.cpp b/src/mode.cpp index 2aa781348..570ac5ad7 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -50,7 +50,6 @@ extern int MODCOUNT; extern std::vector<Module*> modules; extern std::vector<ircd_module*> factory; extern ServerConfig* Config; -extern ModeParser* ModeGrok; extern time_t TIME; @@ -1264,7 +1263,7 @@ void handle_mode(char **parameters, int pcnt, userrec *user) if ((dest) && (pcnt > 1)) { - std::string tidied = ModeGrok->CompressModes(parameters[1],false); + std::string tidied = ServerInstance->ModeGrok->CompressModes(parameters[1],false); parameters[1] = (char*)tidied.c_str(); char dmodes[MAXBUF]; @@ -1341,7 +1340,7 @@ void handle_mode(char **parameters, int pcnt, userrec *user) } else { - if ((parameters[1][i] == 'i') || (parameters[1][i] == 'w') || (parameters[1][i] == 's') || (ModeGrok->AllowedUmode(parameters[1][i],user->modes,direction,false))) + if ((parameters[1][i] == 'i') || (parameters[1][i] == 'w') || (parameters[1][i] == 's') || (ServerInstance->ModeGrok->AllowedUmode(parameters[1][i],user->modes,direction,false))) { can_change = 1; } @@ -1350,10 +1349,10 @@ void handle_mode(char **parameters, int pcnt, userrec *user) { if (direction == 1) { - if ((!strchr(dmodes,parameters[1][i])) && (ModeGrok->AllowedUmode(parameters[1][i],user->modes,true,false))) + if ((!strchr(dmodes,parameters[1][i])) && (ServerInstance->ModeGrok->AllowedUmode(parameters[1][i],user->modes,true,false))) { char umode = parameters[1][i]; - if ((ModeGrok->ProcessModuleUmode(umode, user, dest, direction)) || (umode == 'i') || (umode == 's') || (umode == 'w') || (umode == 'o')) + if ((ServerInstance->ModeGrok->ProcessModuleUmode(umode, user, dest, direction)) || (umode == 'i') || (umode == 's') || (umode == 'w') || (umode == 'o')) { int q = strlen(dmodes); int r = strlen(outpars); @@ -1370,10 +1369,10 @@ void handle_mode(char **parameters, int pcnt, userrec *user) } else { - if ((ModeGrok->AllowedUmode(parameters[1][i],user->modes,false,false)) && (strchr(dmodes,parameters[1][i]))) + if ((ServerInstance->ModeGrok->AllowedUmode(parameters[1][i],user->modes,false,false)) && (strchr(dmodes,parameters[1][i]))) { char umode = parameters[1][i]; - if ((ModeGrok->ProcessModuleUmode(umode, user, dest, direction)) || (umode == 'i') || (umode == 's') || (umode == 'w') || (umode == 'o')) + if ((ServerInstance->ModeGrok->ProcessModuleUmode(umode, user, dest, direction)) || (umode == 'i') || (umode == 's') || (umode == 'w') || (umode == 'o')) { unsigned int q = 0; char temp[MAXBUF]; @@ -1519,7 +1518,7 @@ void handle_mode(char **parameters, int pcnt, userrec *user) } } - ModeGrok->ProcessModes(parameters,user,Ptr,cstatus(user,Ptr),pcnt,false,false,false); + ServerInstance->ModeGrok->ProcessModes(parameters,user,Ptr,cstatus(user,Ptr),pcnt,false,false,false); } } else @@ -1549,7 +1548,7 @@ void ModeParser::ServerMode(char **parameters, int pcnt, userrec *user) if ((dest) && (pcnt > 1)) { - std::string tidied = ModeGrok->CompressModes(parameters[1],false); + std::string tidied = ServerInstance->ModeGrok->CompressModes(parameters[1],false); parameters[1] = (char*)tidied.c_str(); char dmodes[MAXBUF]; @@ -1607,11 +1606,11 @@ void ModeParser::ServerMode(char **parameters, int pcnt, userrec *user) if (direction == 1) { log(DEBUG,"umode %c being added",parameters[1][i]); - if ((!strchr(dmodes,parameters[1][i])) && (ModeGrok->AllowedUmode(parameters[1][i],user->modes,true,true))) + if ((!strchr(dmodes,parameters[1][i])) && (ServerInstance->ModeGrok->AllowedUmode(parameters[1][i],user->modes,true,true))) { char umode = parameters[1][i]; log(DEBUG,"umode %c is an allowed umode",umode); - if ((ModeGrok->ProcessModuleUmode(umode, user, dest, direction)) || (umode == 'i') || (umode == 's') || (umode == 'w') || (umode == 'o')) + if ((ServerInstance->ModeGrok->ProcessModuleUmode(umode, user, dest, direction)) || (umode == 'i') || (umode == 's') || (umode == 'w') || (umode == 'o')) { int v1 = strlen(dmodes); int v2 = strlen(outpars); @@ -1626,11 +1625,11 @@ void ModeParser::ServerMode(char **parameters, int pcnt, userrec *user) { // can only remove a mode they already have log(DEBUG,"umode %c being removed",parameters[1][i]); - if ((ModeGrok->AllowedUmode(parameters[1][i],user->modes,false,true)) && (strchr(dmodes,parameters[1][i]))) + if ((ServerInstance->ModeGrok->AllowedUmode(parameters[1][i],user->modes,false,true)) && (strchr(dmodes,parameters[1][i]))) { char umode = parameters[1][i]; log(DEBUG,"umode %c is an allowed umode",umode); - if ((ModeGrok->ProcessModuleUmode(umode, user, dest, direction)) || (umode == 'i') || (umode == 's') || (umode == 'w') || (umode == 'o')) + if ((ServerInstance->ModeGrok->ProcessModuleUmode(umode, user, dest, direction)) || (umode == 'i') || (umode == 's') || (umode == 'w') || (umode == 'o')) { unsigned int q = 0; char temp[MAXBUF]; @@ -1714,7 +1713,7 @@ void ModeParser::ServerMode(char **parameters, int pcnt, userrec *user) Ptr = FindChan(parameters[0]); if (Ptr) { - ModeGrok->ProcessModes(parameters,user,Ptr,STATUS_OP,pcnt,true,false,false); + ServerInstance->ModeGrok->ProcessModes(parameters,user,Ptr,STATUS_OP,pcnt,true,false,false); } else { diff --git a/src/modules.cpp b/src/modules.cpp index 7e66e5225..395f10f97 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -54,13 +54,10 @@ using namespace std; extern SocketEngine* SE; extern ServerConfig *Config; extern InspIRCd* ServerInstance; -extern ModeParser* ModeGrok; extern int MODCOUNT; extern std::vector<Module*> modules; extern std::vector<ircd_module*> factory; extern std::vector<InspSocket*> module_sockets; -extern CommandParser *Parser; - extern time_t TIME; class Server; extern userrec* fd_ref_table[65536]; @@ -405,12 +402,12 @@ bool Server::IsUlined(std::string server) void Server::CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user) { - Parser->CallHandler(commandname,parameters,pcnt,user); + ServerInstance->Parser->CallHandler(commandname,parameters,pcnt,user); } bool Server::IsValidModuleCommand(std::string commandname, int pcnt, userrec* user) { - return Parser->IsValidCommand(commandname, pcnt, user); + return ServerInstance->Parser->IsValidCommand(commandname, pcnt, user); } void Server::Log(int level, std::string s) @@ -420,12 +417,12 @@ void Server::Log(int level, std::string s) void Server::AddCommand(char* cmd, handlerfunc f, char flags, int minparams, char* source) { - Parser->CreateCommand(cmd,f,flags,minparams,source); + ServerInstance->Parser->CreateCommand(cmd,f,flags,minparams,source); } void Server::SendMode(char **parameters, int pcnt, userrec *user) { - ModeGrok->ServerMode(parameters,pcnt,user); + ServerInstance->ModeGrok->ServerMode(parameters,pcnt,user); } void Server::Send(int Socket, std::string s) diff --git a/src/userprocess.cpp b/src/userprocess.cpp index f800c11d1..837fc2b28 100644 --- a/src/userprocess.cpp +++ b/src/userprocess.cpp @@ -73,8 +73,6 @@ extern InspIRCd* ServerInstance; extern SocketEngine* SE; extern serverstats* stats; extern ServerConfig *Config; -extern CommandParser *Parser; - extern userrec* fd_ref_table[65536]; char data[65536]; @@ -207,7 +205,7 @@ void ProcessUser(userrec* cu) userrec* old_comp = fd_ref_table[currfd]; // we're gonna re-scan to check if the nick is gone, after every // command - if it has, we're gonna bail - Parser->ProcessBuffer(sanitized,current); + ServerInstance->Parser->ProcessBuffer(sanitized,current); // look for the user's record in case it's changed... if theyve quit, // we cant do anything more with their buffer, so bail. // there used to be an ugly, slow loop here. Now we have a reference |