diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-09 16:35:24 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-09 16:35:24 +0000 |
commit | 1cbf29e3cd070c12437a657b47fc433008b2c74d (patch) | |
tree | 22b7a435ffd8bfa7dd97f2457b73df564753eddc /src | |
parent | 89749a74402913d50bd5a9140757a383d6ff175e (diff) |
Move clientlist and chanlist into InspIRCd*
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4818 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/channels.cpp | 43 | ||||
-rw-r--r-- | src/cmd_kill.cpp | 7 | ||||
-rw-r--r-- | src/cmd_list.cpp | 5 | ||||
-rw-r--r-- | src/cmd_quit.cpp | 8 | ||||
-rw-r--r-- | src/cmd_stats.cpp | 8 | ||||
-rw-r--r-- | src/cmd_trace.cpp | 5 | ||||
-rw-r--r-- | src/cmd_who.cpp | 3 | ||||
-rw-r--r-- | src/command_parse.cpp | 1 | ||||
-rw-r--r-- | src/commands.cpp | 15 | ||||
-rw-r--r-- | src/cull_list.cpp | 3 | ||||
-rw-r--r-- | src/helperfuncs.cpp | 30 | ||||
-rw-r--r-- | src/inspircd.cpp | 13 | ||||
-rw-r--r-- | src/modules.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_check.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_httpd_stats.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_redirect.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 55 | ||||
-rw-r--r-- | src/modules/m_tline.cpp | 5 | ||||
-rw-r--r-- | src/userprocess.cpp | 3 | ||||
-rw-r--r-- | src/users.cpp | 33 | ||||
-rw-r--r-- | src/xline.cpp | 1 |
21 files changed, 114 insertions, 146 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 39ae745ad..bf2596bb1 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -45,7 +45,6 @@ extern int MODCOUNT; extern std::vector<Module*> modules; extern std::vector<ircd_module*> factory; extern time_t TIME; -extern chan_hash chanlist; chanrec::chanrec() { @@ -240,15 +239,15 @@ chanrec* chanrec::JoinUser(userrec *user, const char* cn, bool override, const c } /* create a new one */ - chanlist[cname] = new chanrec(); - strlcpy(chanlist[cname]->name, cname,CHANMAX); - chanlist[cname]->modes[CM_TOPICLOCK] = chanlist[cname]->modes[CM_NOEXTERNAL] = 1; - //chanlist[cname]->binarymodes = CM_TOPICLOCK | CM_NOEXTERNAL; - chanlist[cname]->created = TIME; - *chanlist[cname]->topic = 0; - strlcpy(chanlist[cname]->setby, user->nick,NICKMAX-1); - chanlist[cname]->topicset = 0; - Ptr = chanlist[cname]; + Ptr = new chanrec(); + ServerInstance->chanlist[cname] = Ptr; + + strlcpy(Ptr->name, cname,CHANMAX); + Ptr->modes[CM_TOPICLOCK] = Ptr->modes[CM_NOEXTERNAL] = 1; + Ptr->created = TIME; + *Ptr->topic = 0; + strlcpy(Ptr->setby, user->nick,NICKMAX-1); + Ptr->topicset = 0; log(DEBUG,"chanrec::JoinUser(): created: %s",cname); /* * set created to 2 to indicate user @@ -402,12 +401,12 @@ chanrec* chanrec::JoinUser(userrec *user, const char* cn, bool override, const c { log(DEBUG,"BLAMMO, Whacking channel."); /* Things went seriously pear shaped, so take this away. bwahaha. */ - chan_hash::iterator n = chanlist.find(cname); - if (n != chanlist.end()) + chan_hash::iterator n = ServerInstance->chanlist.find(cname); + if (n != ServerInstance->chanlist.end()) { Ptr->DelUser(user); DELETE(Ptr); - chanlist.erase(n); + ServerInstance->chanlist.erase(n); for (unsigned int index =0; index < user->chans.size(); index++) { if (user->chans[index]->channel == Ptr) @@ -497,13 +496,13 @@ long chanrec::PartUser(userrec *user, const char* reason) if (!this->DelUser(user)) /* if there are no users left on the channel... */ { - chan_hash::iterator iter = chanlist.find(this->name); + chan_hash::iterator iter = ServerInstance->chanlist.find(this->name); /* kill the record */ - if (iter != chanlist.end()) + if (iter != ServerInstance->chanlist.end()) { log(DEBUG,"del_channel: destroyed: %s", this->name); FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(this)); - chanlist.erase(iter); + ServerInstance->chanlist.erase(iter); } return 0; } @@ -543,12 +542,12 @@ long chanrec::ServerKickUser(userrec* user, const char* reason, bool triggereven if (!this->DelUser(user)) { - chan_hash::iterator iter = chanlist.find(this->name); + chan_hash::iterator iter = ServerInstance->chanlist.find(this->name); /* kill the record */ - if (iter != chanlist.end()) + if (iter != ServerInstance->chanlist.end()) { FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(this)); - chanlist.erase(iter); + ServerInstance->chanlist.erase(iter); } return 0; } @@ -626,13 +625,13 @@ long chanrec::KickUser(userrec *src, userrec *user, const char* reason) if (!this->DelUser(user)) /* if there are no users left on the channel */ { - chan_hash::iterator iter = chanlist.find(this->name); + chan_hash::iterator iter = ServerInstance->chanlist.find(this->name); /* kill the record */ - if (iter != chanlist.end()) + if (iter != ServerInstance->chanlist.end()) { FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(this)); - chanlist.erase(iter); + ServerInstance->chanlist.erase(iter); } return 0; } diff --git a/src/cmd_kill.cpp b/src/cmd_kill.cpp index 82a1f088d..a7c710968 100644 --- a/src/cmd_kill.cpp +++ b/src/cmd_kill.cpp @@ -28,7 +28,6 @@ extern InspIRCd* ServerInstance; extern int MODCOUNT; extern std::vector<Module*> modules; extern std::vector<ircd_module*> factory; -extern user_hash clientlist; void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user) { @@ -57,12 +56,12 @@ void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user) u->WriteCommonExcept("QUIT :%s", killreason); FOREACH_MOD(I_OnRemoteKill, OnRemoteKill(user, u, killreason)); - user_hash::iterator iter = clientlist.find(u->nick); + user_hash::iterator iter = ServerInstance->clientlist.find(u->nick); - if (iter != clientlist.end()) + if (iter != ServerInstance->clientlist.end()) { log(DEBUG,"deleting user hash value %d", iter->second); - clientlist.erase(iter); + ServerInstance->clientlist.erase(iter); } if (u->registered == REG_ALL) diff --git a/src/cmd_list.cpp b/src/cmd_list.cpp index f08e56d20..26fa3cc10 100644 --- a/src/cmd_list.cpp +++ b/src/cmd_list.cpp @@ -18,14 +18,15 @@ #include "ctables.h" #include "commands.h" #include "helperfuncs.h" +#include "inspircd.h" #include "commands/cmd_list.h" -extern chan_hash chanlist; +extern InspIRCd* ServerInstance; void cmd_list::Handle (const char** parameters, int pcnt, userrec *user) { user->WriteServ("321 %s Channel :Users Name",user->nick); - for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++) + for (chan_hash::const_iterator i = ServerInstance->chanlist.begin(); i != ServerInstance->chanlist.end(); i++) { // if the channel is not private/secret, OR the user is on the channel anyway bool n = i->second->HasUser(user); diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp index b9fcc9db5..f24abbe7c 100644 --- a/src/cmd_quit.cpp +++ b/src/cmd_quit.cpp @@ -40,13 +40,11 @@ extern int MODCOUNT; extern ModuleList modules; extern FactoryList factory; extern time_t TIME; -extern user_hash clientlist; -extern chan_hash chanlist; extern std::vector<userrec*> local_users; void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user) { - user_hash::iterator iter = clientlist.find(user->nick); + user_hash::iterator iter = ServerInstance->clientlist.find(user->nick); char reason[MAXBUF]; if (user->registered == REG_ALL) @@ -101,9 +99,9 @@ void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user) user->CloseSocket(); } - if (iter != clientlist.end()) + if (iter != ServerInstance->clientlist.end()) { - clientlist.erase(iter); + ServerInstance->clientlist.erase(iter); } if (user->registered == REG_ALL) { diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp index ce8d22434..30cc2eb0d 100644 --- a/src/cmd_stats.cpp +++ b/src/cmd_stats.cpp @@ -48,8 +48,6 @@ extern int MODCOUNT; extern ModuleList modules; extern FactoryList factory; extern time_t TIME; -extern user_hash clientlist; -extern chan_hash chanlist; extern std::vector<userrec*> local_users; void cmd_stats::Handle (const char** parameters, int pcnt, userrec *user) @@ -113,7 +111,7 @@ void DoStats(char statschar, userrec* user, string_list &results) if (statschar == 'P') { int idx = 0; - for (user_hash::iterator i = clientlist.begin(); i != clientlist.end(); i++) + for (user_hash::iterator i = ServerInstance->clientlist.begin(); i != ServerInstance->clientlist.end(); i++) { if (*i->second->oper) { @@ -167,8 +165,8 @@ void DoStats(char statschar, userrec* user, string_list &results) if (statschar == 'z') { rusage R; - results.push_back(sn+" 249 "+user->nick+" :Users(HASH_MAP) "+ConvToStr(clientlist.size())+" ("+ConvToStr(clientlist.size()*sizeof(userrec))+" bytes, "+ConvToStr(clientlist.bucket_count())+" buckets)"); - results.push_back(sn+" 249 "+user->nick+" :Channels(HASH_MAP) "+ConvToStr(chanlist.size())+" ("+ConvToStr(chanlist.size()*sizeof(chanrec))+" bytes, "+ConvToStr(chanlist.bucket_count())+" buckets)"); + 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))+")"); diff --git a/src/cmd_trace.cpp b/src/cmd_trace.cpp index ea07ee258..26a94f7a0 100644 --- a/src/cmd_trace.cpp +++ b/src/cmd_trace.cpp @@ -17,13 +17,14 @@ #include "users.h" #include "commands.h" #include "helperfuncs.h" +#include "inspircd.h" #include "commands/cmd_trace.h" -extern user_hash clientlist; +extern InspIRCd* ServerInstance; void cmd_trace::Handle (const char** parameters, int pcnt, userrec *user) { - for (user_hash::iterator i = clientlist.begin(); i != clientlist.end(); i++) + for (user_hash::iterator i = ServerInstance->clientlist.begin(); i != ServerInstance->clientlist.end(); i++) { if (i->second) { diff --git a/src/cmd_who.cpp b/src/cmd_who.cpp index 0a6637242..de3f30196 100644 --- a/src/cmd_who.cpp +++ b/src/cmd_who.cpp @@ -24,7 +24,6 @@ #include "commands/cmd_who.h" extern InspIRCd* ServerInstance; -extern user_hash clientlist; extern chan_hash chanlist; extern std::vector<userrec*> all_opers; @@ -196,7 +195,7 @@ void cmd_who::Handle (const char** parameters, int pcnt, userrec *user) } else { - for (user_hash::iterator i = clientlist.begin(); i != clientlist.end(); i++) + for (user_hash::iterator i = ServerInstance->clientlist.begin(); i != ServerInstance->clientlist.end(); i++) { if (whomatch(i->second, matchtext, opt_realname, opt_showrealhost)) { diff --git a/src/command_parse.cpp b/src/command_parse.cpp index a0097b924..57c8f44c1 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -60,7 +60,6 @@ extern time_t TIME; extern Server* MyServer; -extern user_hash clientlist; extern chan_hash chanlist; /* Special commands which may occur without registration of the user */ diff --git a/src/commands.cpp b/src/commands.cpp index 9a6be7206..8504c174d 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -63,9 +63,6 @@ const long duration_d = duration_h * 24; const long duration_w = duration_d * 7; const long duration_y = duration_w * 52; -extern user_hash clientlist; -extern chan_hash chanlist; - extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; @@ -202,7 +199,7 @@ bool host_matches_everyone(const std::string &mask, userrec* user) if (ServerInstance->Config->ConfValueBool(ServerInstance->Config->config_data, "insane","hostmasks", 0)) return false; - for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++) + for (user_hash::iterator u = ServerInstance->clientlist.begin(); u != ServerInstance->clientlist.end(); u++) { strlcpy(buffer,u->second->ident,MAXBUF); charlcat(buffer,'@',MAXBUF); @@ -210,7 +207,7 @@ bool host_matches_everyone(const std::string &mask, userrec* user) if (match(buffer,mask.c_str())) matches++; } - float percent = ((float)matches / (float)clientlist.size()) * 100; + float percent = ((float)matches / (float)ServerInstance->clientlist.size()) * 100; if (percent > (float)atof(itrigger)) { WriteOpers("*** \2WARNING\2: %s tried to set a G/K/E line mask of %s, which covers %.2f%% of the network!",user->nick,mask.c_str(),percent); @@ -230,13 +227,13 @@ bool ip_matches_everyone(const std::string &ip, userrec* user) if (ServerInstance->Config->ConfValueBool(ServerInstance->Config->config_data, "insane","ipmasks",0)) return false; - for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++) + for (user_hash::iterator u = ServerInstance->clientlist.begin(); u != ServerInstance->clientlist.end(); u++) { if (match(u->second->GetIPString(),ip.c_str(),true)) matches++; } - float percent = ((float)matches / (float)clientlist.size()) * 100; + float percent = ((float)matches / (float)ServerInstance->clientlist.size()) * 100; if (percent > (float)atof(itrigger)) { WriteOpers("*** \2WARNING\2: %s tried to set a Z line mask of %s, which covers %.2f%% of the network!",user->nick,ip.c_str(),percent); @@ -256,13 +253,13 @@ bool nick_matches_everyone(const std::string &nick, userrec* user) if (ServerInstance->Config->ConfValueBool(ServerInstance->Config->config_data, "insane","nickmasks",0)) return false; - for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++) + for (user_hash::iterator u = ServerInstance->clientlist.begin(); u != ServerInstance->clientlist.end(); u++) { if (match(u->second->nick,nick.c_str())) matches++; } - float percent = ((float)matches / (float)clientlist.size()) * 100; + float percent = ((float)matches / (float)ServerInstance->clientlist.size()) * 100; if (percent > (float)atof(itrigger)) { WriteOpers("*** \2WARNING\2: %s tried to set a Q line mask of %s, which covers %.2f%% of the network!",user->nick,nick.c_str(),percent); diff --git a/src/cull_list.cpp b/src/cull_list.cpp index e6b105925..bfa37e51a 100644 --- a/src/cull_list.cpp +++ b/src/cull_list.cpp @@ -40,7 +40,6 @@ using namespace std; #include "cull_list.h" extern InspIRCd* ServerInstance; -extern user_hash clientlist; /* * In current implementation of CullList, this isn't used. It did odd things with a lot of sockets. @@ -52,7 +51,7 @@ bool CullList::IsValid(userrec* user) if (es != exempt.end()) esignon = es->second; - for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++) + for (user_hash::iterator u = ServerInstance->clientlist.begin(); u != ServerInstance->clientlist.end(); u++) { /* * BUGFIX diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index be8c9ac67..e9b969ee2 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -50,8 +50,6 @@ extern InspIRCd* ServerInstance; extern time_t TIME; extern char lowermap[255]; extern std::vector<userrec*> all_opers; -extern user_hash clientlist; -extern chan_hash chanlist; char LOG_FILE[MAXBUF]; @@ -317,9 +315,9 @@ void strlower(char *n) userrec* Find(const std::string &nick) { - user_hash::iterator iter = clientlist.find(nick); + user_hash::iterator iter = ServerInstance->clientlist.find(nick); - if (iter == clientlist.end()) + if (iter == ServerInstance->clientlist.end()) /* Couldn't find it */ return NULL; @@ -333,9 +331,9 @@ userrec* Find(const char* nick) if (!nick) return NULL; - iter = clientlist.find(nick); + iter = ServerInstance->clientlist.find(nick); - if (iter == clientlist.end()) + if (iter == ServerInstance->clientlist.end()) return NULL; return iter->second; @@ -353,9 +351,9 @@ chanrec* FindChan(const char* chan) return NULL; } - iter = chanlist.find(chan); + iter = ServerInstance->chanlist.find(chan); - if (iter == chanlist.end()) + if (iter == ServerInstance->chanlist.end()) /* Couldn't find it */ return NULL; @@ -401,12 +399,12 @@ void purge_empty_chans(userrec* u) for (std::vector<chanrec*>::iterator n = to_delete.begin(); n != to_delete.end(); n++) { chanrec* thischan = (chanrec*)*n; - chan_hash::iterator i2 = chanlist.find(thischan->name); - if (i2 != chanlist.end()) + chan_hash::iterator i2 = ServerInstance->chanlist.find(thischan->name); + if (i2 != ServerInstance->chanlist.end()) { FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(i2->second)); DELETE(i2->second); - chanlist.erase(i2); + ServerInstance->chanlist.erase(i2); } } @@ -644,7 +642,7 @@ void Error(int status) // this function counts all users connected, wether they are registered or NOT. int usercnt(void) { - return clientlist.size(); + return ServerInstance->clientlist.size(); } // this counts only registered users, so that the percentages in /MAP don't mess up when users are sitting in an unregistered state @@ -652,7 +650,7 @@ int registered_usercount(void) { int c = 0; - for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++) + for (user_hash::const_iterator i = ServerInstance->clientlist.begin(); i != ServerInstance->clientlist.end(); i++) { c += (i->second->registered == REG_ALL); } @@ -664,7 +662,7 @@ int usercount_invisible(void) { int c = 0; - for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++) + for (user_hash::const_iterator i = ServerInstance->clientlist.begin(); i != ServerInstance->clientlist.end(); i++) { c += ((i->second->registered == REG_ALL) && (i->second->modes[UM_INVISIBLE])); } @@ -676,7 +674,7 @@ int usercount_opers(void) { int c = 0; - for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++) + for (user_hash::const_iterator i = ServerInstance->clientlist.begin(); i != ServerInstance->clientlist.end(); i++) { if (*(i->second->oper)) c++; @@ -700,7 +698,7 @@ int usercount_unknown(void) long chancount(void) { - return chanlist.size(); + return ServerInstance->chanlist.size(); } long local_count() diff --git a/src/inspircd.cpp b/src/inspircd.cpp index e272d4c6e..5c3afe70c 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -83,12 +83,9 @@ socklen_t length; time_t TIME = time(NULL), OLDTIME = time(NULL); Server* MyServer = new Server; -user_hash clientlist; -chan_hash chanlist; -servernamelist servernames; char lowermap[255]; -void AddServerName(const std::string &servername) +void InspIRCd::AddServerName(const std::string &servername) { log(DEBUG,"Adding server name: %s",servername.c_str()); @@ -96,7 +93,7 @@ void AddServerName(const std::string &servername) servernames.push_back(servername); /* Wasn't already there. */ } -const char* FindServerNamePtr(const std::string &servername) +const char* InspIRCd::FindServerNamePtr(const std::string &servername) { servernamelist::iterator iter = find(servernames.begin(), servernames.end(), servername); @@ -109,7 +106,7 @@ const char* FindServerNamePtr(const std::string &servername) return iter->c_str(); } -bool FindServerName(const std::string &servername) +bool InspIRCd::FindServerName(const std::string &servername) { return (find(servernames.begin(), servernames.end(), servername) != servernames.end()); } @@ -503,11 +500,11 @@ bool InspIRCd::UnloadModule(const char* filename) return false; } /* Give the module a chance to tidy out all its metadata */ - for (chan_hash::iterator c = chanlist.begin(); c != chanlist.end(); c++) + for (chan_hash::iterator c = this->chanlist.begin(); c != this->chanlist.end(); c++) { modules[j]->OnCleanup(TYPE_CHANNEL,c->second); } - for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++) + for (user_hash::iterator u = this->clientlist.begin(); u != this->clientlist.end(); u++) { modules[j]->OnCleanup(TYPE_USER,u->second); } diff --git a/src/modules.cpp b/src/modules.cpp index 4eed4d781..1c90bd7c0 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -51,8 +51,6 @@ extern ModuleList modules; extern FactoryList factory; extern std::vector<userrec*> local_users; extern time_t TIME; -extern user_hash clientlist; -extern chan_hash chanlist; extern command_table cmdlist; class Server; @@ -356,7 +354,7 @@ void Server::DelSocket(InspSocket* sock) long Server::GetChannelCount() { - return (long)chanlist.size(); + return (long)ServerInstance->chanlist.size(); } /* This is ugly, yes, but hash_map's arent designed to be @@ -369,7 +367,7 @@ long Server::GetChannelCount() chanrec* Server::GetChannelIndex(long index) { int target = 0; - for (chan_hash::iterator n = chanlist.begin(); n != chanlist.end(); n++, target++) + for (chan_hash::iterator n = ServerInstance->chanlist.begin(); n != ServerInstance->chanlist.end(); n++, target++) { if (index == target) return n->second; diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 92b6d64f0..f697c4670 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -23,11 +23,11 @@ using namespace std; #include "commands.h" #include "inspircd.h" #include "helperfuncs.h" +#include "wildcard.h" /* $ModDesc: Provides the /check command to retrieve information on a user, channel, or IP address */ -extern user_hash clientlist; -extern bool match(const char *, const char *); +extern InspIRCd* ServerInstance; static Server *Srv; @@ -161,7 +161,7 @@ class cmd_check : public command_t long x = 0; /* hostname or other */ - for (user_hash::const_iterator a = clientlist.begin(); a != clientlist.end(); a++) + for (user_hash::const_iterator a = ServerInstance->clientlist.begin(); a != ServerInstance->clientlist.end(); a++) { if (match(a->second->host, parameters[0]) || match(a->second->dhost, parameters[0])) { diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index 544cc1475..fa4f27f04 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -28,8 +28,6 @@ using namespace std; /* $ModDesc: Provides statistics over HTTP via m_httpd.so */ -extern user_hash clientlist; -extern chan_hash chanlist; extern std::vector<userrec*> all_opers; extern InspIRCd* ServerInstance; @@ -115,8 +113,8 @@ class ModuleHttpStats : public Module data << "<div class='totals'>"; data << "<h2>Totals</h2>"; data << "<table>"; - data << "<tr><td>Users</td><td>" << clientlist.size() << "</td></tr>"; - data << "<tr><td>Channels</td><td>" << chanlist.size() << "</td></tr>"; + data << "<tr><td>Users</td><td>" << ServerInstance->clientlist.size() << "</td></tr>"; + data << "<tr><td>Channels</td><td>" << ServerInstance->chanlist.size() << "</td></tr>"; data << "<tr><td>Opers</td><td>" << all_opers.size() << "</td></tr>"; data << "<tr><td>Sockets</td><td>" << (ServerInstance->SE->GetMaxFds() - ServerInstance->SE->GetRemainingFds()) << " (Max: " << ServerInstance->SE->GetMaxFds() << " via socket engine '" << ServerInstance->SE->GetName() << "')</td></tr>"; data << "</table>"; diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index 208e55de2..ae45c67a3 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -25,7 +25,7 @@ using namespace std; /* $ModDesc: Provides channel mode +L (limit redirection) */ -extern chan_hash chanlist; +extern InspIRCd* ServerInstance; class Redirect : public ModeHandler { @@ -74,7 +74,7 @@ class Redirect : public ModeHandler } else { - for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++) + for (chan_hash::const_iterator i = ServerInstance->chanlist.begin(); i != ServerInstance->chanlist.end(); i++) { if ((i->second != channel) && (i->second->IsModeSet('L')) && (irc::string(i->second->GetModeParameter('L').c_str()) == irc::string(channel->name))) { diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 448e3470b..d0d7389de 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -90,10 +90,6 @@ extern int MODCOUNT; */ enum ServerState { LISTENER, CONNECTING, WAIT_AUTH_1, WAIT_AUTH_2, CONNECTED }; -/* We need to import these from the core for use in netbursts */ -extern user_hash clientlist; -extern chan_hash chanlist; - /* Foward declarations */ class TreeServer; class TreeSocket; @@ -317,7 +313,7 @@ class TreeServer : public classbase log(DEBUG,"Removing all users from server %s",this->ServerName.c_str()); const char* reason_s = reason.c_str(); std::vector<userrec*> time_to_die; - for (user_hash::iterator n = clientlist.begin(); n != clientlist.end(); n++) + for (user_hash::iterator n = ServerInstance->clientlist.begin(); n != ServerInstance->clientlist.end(); n++) { if (!strcmp(n->second->server, this->ServerName.c_str())) { @@ -1548,9 +1544,9 @@ class TreeSocket : public InspSocket const char* tempnick = params[1].c_str(); log(DEBUG,"Introduce client %s!%s@%s",tempnick,params[4].c_str(),params[2].c_str()); - user_hash::iterator iter = clientlist.find(tempnick); + user_hash::iterator iter = this->Instance->clientlist.find(tempnick); - if (iter != clientlist.end()) + if (iter != this->Instance->clientlist.end()) { // nick collision log(DEBUG,"Nick collision on %s!%s@%s: %lu %lu",tempnick,params[4].c_str(),params[2].c_str(),(unsigned long)age,(unsigned long)iter->second->age); @@ -1558,28 +1554,27 @@ class TreeSocket : public InspSocket return true; } - clientlist[tempnick] = new userrec(); - clientlist[tempnick]->fd = FD_MAGIC_NUMBER; - strlcpy(clientlist[tempnick]->nick, tempnick,NICKMAX-1); - strlcpy(clientlist[tempnick]->host, params[2].c_str(),63); - strlcpy(clientlist[tempnick]->dhost, params[3].c_str(),63); - clientlist[tempnick]->server = FindServerNamePtr(source.c_str()); - strlcpy(clientlist[tempnick]->ident, params[4].c_str(),IDENTMAX); - strlcpy(clientlist[tempnick]->fullname, params[7].c_str(),MAXGECOS); - clientlist[tempnick]->registered = REG_ALL; - clientlist[tempnick]->signon = age; + userrec* _new = new userrec(); + this->Instance->clientlist[tempnick] = _new; + _new->fd = FD_MAGIC_NUMBER; + strlcpy(_new->nick, tempnick,NICKMAX-1); + strlcpy(_new->host, params[2].c_str(),63); + strlcpy(_new->dhost, params[3].c_str(),63); + _new->server = this->Instance->FindServerNamePtr(source.c_str()); + strlcpy(_new->ident, params[4].c_str(),IDENTMAX); + strlcpy(_new->fullname, params[7].c_str(),MAXGECOS); + _new->registered = REG_ALL; + _new->signon = age; for (std::string::iterator v = params[5].begin(); v != params[5].end(); v++) - { - clientlist[tempnick]->modes[(*v)-65] = 1; - } + _new->modes[(*v)-65] = 1; if (params[6].find_first_of(":") != std::string::npos) - clientlist[tempnick]->SetSockAddr(AF_INET6, params[6].c_str(), 0); + _new->SetSockAddr(AF_INET6, params[6].c_str(), 0); else - clientlist[tempnick]->SetSockAddr(AF_INET, params[6].c_str(), 0); + _new->SetSockAddr(AF_INET, params[6].c_str(), 0); - WriteOpers("*** Client connecting at %s: %s!%s@%s [%s]",clientlist[tempnick]->server,clientlist[tempnick]->nick,clientlist[tempnick]->ident,clientlist[tempnick]->host, clientlist[tempnick]->GetIPString()); + WriteOpers("*** Client connecting at %s: %s!%s@%s [%s]",_new->server,_new->nick,_new->ident,_new->host, _new->GetIPString()); params[7] = ":" + params[7]; DoOneToAllButSender(source,"NICK",params,source); @@ -1588,7 +1583,7 @@ class TreeSocket : public InspSocket TreeServer* SourceServer = FindServer(source); if (SourceServer) { - log(DEBUG,"Found source server of %s",clientlist[tempnick]->nick); + log(DEBUG,"Found source server of %s",_new->nick); SourceServer->AddUserCount(); } @@ -1756,7 +1751,7 @@ class TreeSocket : public InspSocket int iterations = 0; std::string n = Srv->GetServerName(); const char* sn = n.c_str(); - for (chan_hash::iterator c = chanlist.begin(); c != chanlist.end(); c++, iterations++) + for (chan_hash::iterator c = this->Instance->chanlist.begin(); c != this->Instance->chanlist.end(); c++, iterations++) { SendFJoins(Current, c->second); if (*c->second->topic) @@ -1780,7 +1775,7 @@ class TreeSocket : public InspSocket char data[MAXBUF]; std::deque<std::string> list; int iterations = 0; - for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++, iterations++) + for (user_hash::iterator u = this->Instance->clientlist.begin(); u != this->Instance->clientlist.end(); u++, iterations++) { if (u->second->registered == REG_ALL) { @@ -1812,10 +1807,6 @@ class TreeSocket : public InspSocket */ void DoBurst(TreeServer* s) { - /* The calls here to ServerInstance-> yield the processing - * back to the core so that a large burst is split into at least 6 sections - * (possibly more) - */ std::string burst = "BURST "+ConvToStr(time(NULL)); std::string endburst = "ENDBURST"; // Because by the end of the netburst, it could be gone! @@ -3539,13 +3530,13 @@ class ModuleSpanningTree : public Module float percent; char text[80]; - if (clientlist.size() == 0) { + if (ServerInstance->clientlist.size() == 0) { // If there are no users, WHO THE HELL DID THE /MAP?!?!?! percent = 0; } else { - percent = ((float)Current->GetUserCount() / (float)clientlist.size()) * 100; + percent = ((float)Current->GetUserCount() / (float)ServerInstance->clientlist.size()) * 100; } snprintf(text, 80, "%s %s%5d [%5.2f%%]", Current->GetName().c_str(), spacer, Current->GetUserCount(), percent); totusers += Current->GetUserCount(); diff --git a/src/modules/m_tline.cpp b/src/modules/m_tline.cpp index 6ee4d9176..47f82200e 100644 --- a/src/modules/m_tline.cpp +++ b/src/modules/m_tline.cpp @@ -22,12 +22,13 @@ using namespace std; #include "modules.h" #include "helperfuncs.h" #include "wildcard.h" +#include "inspircd.h" #include "dns.h" /* $ModDesc: Provides /tline command used to test who a mask matches */ static Server *Srv; -extern user_hash clientlist; +extern InspIRCd* ServerInstance; class cmd_tline : public command_t { @@ -45,7 +46,7 @@ class cmd_tline : public command_t float n_match_host = 0; float n_match_ip = 0; - for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++) + for (user_hash::const_iterator u = ServerInstance->clientlist.begin(); u != ServerInstance->clientlist.end(); u++) { n_counted++; if (match(u->second->GetFullRealHost(),parameters[0])) diff --git a/src/userprocess.cpp b/src/userprocess.cpp index b2c8034a3..88fdeec54 100644 --- a/src/userprocess.cpp +++ b/src/userprocess.cpp @@ -61,9 +61,6 @@ extern time_t OLDTIME; extern std::vector<userrec*> local_users; char data[65536]; -extern user_hash clientlist; -extern chan_hash chanlist; - void InspIRCd::ProcessUser(userrec* cu) { int result = EAGAIN; diff --git a/src/users.cpp b/src/users.cpp index 6faea40ce..cb6fbc1f3 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -38,7 +38,6 @@ extern std::vector<ircd_module*> factory; extern std::vector<InspSocket*> module_sockets; extern int MODCOUNT; extern time_t TIME; -extern user_hash clientlist; extern Server* MyServer; extern std::vector<userrec*> local_users; @@ -261,7 +260,7 @@ userrec::userrec() { // the PROPER way to do it, AVOID bzero at *ALL* costs *password = *nick = *ident = *host = *dhost = *fullname = *awaymsg = *oper = 0; - server = (char*)FindServerNamePtr(ServerInstance->Config->ServerName); + server = (char*)ServerInstance->FindServerNamePtr(ServerInstance->Config->ServerName); reset_due = TIME; lines_in = fd = lastping = signon = idle_lastmsg = nping = registered = 0; timeout = flood = bytes_in = bytes_out = cmds_in = cmds_out = 0; @@ -643,7 +642,7 @@ void userrec::UnOper() void userrec::QuitUser(userrec *user,const std::string &quitreason) { - user_hash::iterator iter = clientlist.find(user->nick); + user_hash::iterator iter = ServerInstance->clientlist.find(user->nick); /* * I'm pretty sure returning here is causing a desync when part of the net thinks a user is gone, @@ -708,7 +707,7 @@ void userrec::QuitUser(userrec *user,const std::string &quitreason) user->AddToWhoWas(); } - if (iter != clientlist.end()) + if (iter != ServerInstance->clientlist.end()) { log(DEBUG,"deleting user hash value %lx",(unsigned long)user); if (IS_LOCAL(user)) @@ -717,7 +716,7 @@ void userrec::QuitUser(userrec *user,const std::string &quitreason) if (find(local_users.begin(),local_users.end(),user) != local_users.end()) local_users.erase(find(local_users.begin(),local_users.end(),user)); } - clientlist.erase(iter); + ServerInstance->clientlist.erase(iter); DELETE(user); } } @@ -800,7 +799,7 @@ void userrec::AddToWhoWas() void userrec::AddClient(int socket, int port, bool iscached, insp_inaddr ip) { std::string tempnick = ConvToStr(socket) + "-unknown"; - user_hash::iterator iter = clientlist.find(tempnick); + user_hash::iterator iter = ServerInstance->clientlist.find(tempnick); const char *ipaddr = insp_ntoa(ip); userrec* _new; int j = 0; @@ -814,21 +813,21 @@ void userrec::AddClient(int socket, int port, bool iscached, insp_inaddr ip) * this was probably the cause of 'server ignores me when i hammer it with reconnects' * issue in earlier alphas/betas */ - if (iter != clientlist.end()) + if (iter != ServerInstance->clientlist.end()) { userrec* goner = iter->second; DELETE(goner); - clientlist.erase(iter); + ServerInstance->clientlist.erase(iter); } log(DEBUG,"AddClient: %d %d %s",socket,port,ipaddr); _new = new userrec(); - clientlist[tempnick] = _new; + ServerInstance->clientlist[tempnick] = _new; _new->fd = socket; strlcpy(_new->nick,tempnick.c_str(),NICKMAX-1); - _new->server = FindServerNamePtr(ServerInstance->Config->ServerName); + _new->server = ServerInstance->FindServerNamePtr(ServerInstance->Config->ServerName); /* We don't need range checking here, we KNOW 'unknown\0' will fit into the ident field. */ strcpy(_new->ident, "unknown"); @@ -933,7 +932,7 @@ long userrec::GlobalCloneCount() char u1[1024]; char u2[1024]; long x = 0; - for (user_hash::const_iterator a = clientlist.begin(); a != clientlist.end(); a++) + for (user_hash::const_iterator a = ServerInstance->clientlist.begin(); a != ServerInstance->clientlist.end(); a++) { /* We have to match ip's as strings - we don't know what protocol * a remote user may be using @@ -1072,18 +1071,18 @@ void userrec::FullConnect(CullList* Goners) userrec* userrec::UpdateNickHash(const char* New) { //user_hash::iterator newnick; - user_hash::iterator oldnick = clientlist.find(this->nick); + user_hash::iterator oldnick = ServerInstance->clientlist.find(this->nick); if (!strcasecmp(this->nick,New)) return oldnick->second; - if (oldnick == clientlist.end()) + if (oldnick == ServerInstance->clientlist.end()) return NULL; /* doesnt exist */ userrec* olduser = oldnick->second; - clientlist[New] = olduser; - clientlist.erase(oldnick); - return clientlist[New]; + ServerInstance->clientlist[New] = olduser; + ServerInstance->clientlist.erase(oldnick); + return ServerInstance->clientlist[New]; } bool userrec::ForceNickChange(const char* newnick) @@ -1483,7 +1482,7 @@ void userrec::WriteCommonExcept(const std::string &text) split >> server_one; split >> server_two; - if ((FindServerName(server_one)) && (FindServerName(server_two))) + if ((ServerInstance->FindServerName(server_one)) && (ServerInstance->FindServerName(server_two))) { strlcpy(oper_quit,textbuffer,MAXQUIT); strlcpy(check,"*.net *.split",MAXQUIT); diff --git a/src/xline.cpp b/src/xline.cpp index eb0fa559c..868508db6 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -44,7 +44,6 @@ extern InspIRCd* ServerInstance; extern int MODCOUNT; extern std::vector<Module*> modules; extern std::vector<ircd_module*> factory; -extern user_hash clientlist; extern std::vector<userrec*> local_users; /* Version two, now with optimized expiry! |