diff options
author | Adam <Adam@anope.org> | 2011-03-14 20:16:38 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-03-14 20:16:38 -0400 |
commit | ddfb16de1a61a9b80ece0ba6e5fd34326abf5f18 (patch) | |
tree | 81e29e3eebc8ae6241e6bdd6970e48a037291203 /src | |
parent | 2555d0d6373e631ca2504826a02aaae2e82cd7a4 (diff) |
Fixed compile
Diffstat (limited to 'src')
-rw-r--r-- | src/bots.cpp | 12 | ||||
-rw-r--r-- | src/botserv.cpp | 18 | ||||
-rw-r--r-- | src/hashcomp.cpp | 15 | ||||
-rw-r--r-- | src/init.cpp | 4 | ||||
-rw-r--r-- | src/logger.cpp | 4 | ||||
-rw-r--r-- | src/main.cpp | 28 | ||||
-rw-r--r-- | src/misc.cpp | 20 | ||||
-rw-r--r-- | src/operserv.cpp | 14 | ||||
-rw-r--r-- | src/servers.cpp | 7 | ||||
-rw-r--r-- | src/sessions.cpp | 14 | ||||
-rw-r--r-- | src/users.cpp | 28 |
11 files changed, 73 insertions, 91 deletions
diff --git a/src/bots.cpp b/src/bots.cpp index 85fcf8055..95a5c2aa5 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -9,8 +9,8 @@ #include "modules.h" #include "commands.h" -patricia_tree<BotInfo *, ci::ci_char_traits> BotListByNick; -patricia_tree<BotInfo *> BotListByUID; +Anope::insensitive_map<BotInfo *> BotListByNick; +Anope::map<BotInfo *> BotListByUID; BotInfo *BotServ = NULL; BotInfo *ChanServ = NULL; @@ -46,9 +46,9 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A else this->UnsetFlag(BI_CORE); - BotListByNick.insert(this->nick, this); + BotListByNick[this->nick] = this; if (!this->uid.empty()) - BotListByUID.insert(this->uid, this); + BotListByUID[this->uid] = this; // If we're synchronised with the uplink already, send the bot. if (Me && Me->IsSynced()) @@ -118,8 +118,8 @@ void BotInfo::SetNewNick(const Anope::string &newnick) this->nick = newnick; - UserListByNick.insert(this->nick, this); - BotListByNick.insert(this->nick, this); + UserListByNick[this->nick] = this; + BotListByNick[this->nick] = this; } void BotInfo::RejoinAll() diff --git a/src/botserv.cpp b/src/botserv.cpp index a7076bcf5..4d0255cd5 100644 --- a/src/botserv.cpp +++ b/src/botserv.cpp @@ -34,9 +34,9 @@ void get_botserv_stats(long *nrec, long *memuse) { long count = 0, mem = 0; - for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();) + for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { - BotInfo *bi = *it; + BotInfo *bi = it->second; ++count; mem += sizeof(*bi); @@ -361,11 +361,19 @@ void botchanmsgs(User *u, ChannelInfo *ci, const Anope::string &buf) BotInfo *findbot(const Anope::string &nick) { - BotInfo *bi; + BotInfo *bi = NULL; if (isdigit(nick[0]) && ircd->ts6) - bi = BotListByUID.find(nick); + { + Anope::map<BotInfo *>::iterator it = BotListByUID.find(nick); + if (it != BotListByUID.end()) + bi = it->second; + } else - bi = BotListByNick.find(nick); + { + Anope::insensitive_map<BotInfo *>::iterator it = BotListByNick.find(nick); + if (it != BotListByNick.end()) + bi = it->second; + } FOREACH_MOD(I_OnFindBot, OnFindBot(nick)); diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index eb1c9f5a3..7881f2c7a 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -87,11 +87,6 @@ const char *irc::irc_char_traits::find(const char *s1, int n, char c) return n >= 0 ? s1 : NULL; } -const char irc::irc_char_traits::chartolower(char c1) -{ - return rfc_case_insensitive_map[static_cast<unsigned char>(c1)]; -} - /* VS 2008 specific function */ bool irc::hash::operator()(const Anope::string &s1, const Anope::string &s2) const { @@ -158,11 +153,6 @@ const char *ci::ci_char_traits::find(const char *s1, int n, char c) return n >= 0 ? s1 : NULL; } -const char ci::ci_char_traits::chartolower(char c1) -{ - return ascii_case_insensitive_map[static_cast<unsigned char>(c1)]; -} - /* VS 2008 specific function */ bool ci::hash::operator()(const Anope::string &s1, const Anope::string &s2) const { @@ -188,11 +178,6 @@ size_t ci::hash::operator()(const Anope::string &s) const return operator()(s.ci_str()); } -const char std::std_char_traits::chartolower(char c1) -{ - return c1; -} - /** Compare two Anope::strings as ci::strings * @param s1 The first string * @param s2 The second string diff --git a/src/init.cpp b/src/init.cpp index 05b15aecb..31d525c7b 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -57,9 +57,9 @@ void introduce_user(const Anope::string &user) } /* We make the bots go online */ - for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) + for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it) { - User *u = *it; + User *u = it->second; ircdproto->SendClientIntroduction(u, ircd->pseudoclient_mode); diff --git a/src/logger.cpp b/src/logger.cpp index b40fdc11d..1265dc3e2 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -32,9 +32,9 @@ void InitLogChannels(ServerConfig *config) c->SetFlag(CH_LOGCHAN); c->SetFlag(CH_PERSIST); - for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();) + for (Anope::insensitive_map<BotInfo *>::iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { - BotInfo *bi = *it; + BotInfo *bi = it->second; if (bi->HasFlag(BI_CORE) && !c->FindUser(bi)) bi->Join(c, &config->BotModeList); diff --git a/src/main.cpp b/src/main.cpp index c350f4323..3ca033507 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -170,11 +170,9 @@ void do_restart_services() if (quitmsg.empty()) quitmsg = "Restarting"; /* Send a quit for all of our bots */ - patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); - for (bool next = it.next(); next;) + for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { - BotInfo *bi = *it; - next = it.next(); + BotInfo *bi = it->second; /* Don't use quitmsg here, it may contain information you don't want people to see */ ircdproto->SendQuit(bi, "Restarting"); @@ -214,11 +212,9 @@ static void services_shutdown() if (started && UplinkSock) { /* Send a quit for all of our bots */ - patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); - for (bool next = it.next(); next;) + for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { - BotInfo *bi = *it; - next = it.next(); + BotInfo *bi = it->second; /* Don't use quitmsg here, it may contain information you don't want people to see */ ircdproto->SendQuit(bi, "Shutting down"); @@ -230,11 +226,10 @@ static void services_shutdown() ircdproto->SendSquit(Config->ServerName, quitmsg); - patricia_tree<User *, ci::ci_char_traits>::iterator uit(UserListByNick); - for (bool next = uit.next(); next;) + for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();) { - User *u = *uit; - next = uit.next(); + User *u = it->second; + ++it; delete u; } } @@ -505,11 +500,10 @@ int main(int ac, char **av, char **envp) FOREACH_MOD(I_OnServerDisconnect, OnServerDisconnect()); /* Clear all of our users, but not our bots */ - patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); - for (bool next = it.next(); next;) + for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();) { - User *u = *it; - next = it.next(); + User *u = it->second; + ++it; if (u->server != Me) delete u; @@ -551,4 +545,4 @@ int main(int ac, char **av, char **envp) } return 0; -}
\ No newline at end of file +} diff --git a/src/misc.cpp b/src/misc.cpp index 1e1110fd9..edabe8f56 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -501,23 +501,9 @@ bool nickIsServices(const Anope::string &tempnick, bool bot) nick = nick.substr(0, at); } - if (!Config->s_NickServ.empty() && nick.equals_ci(Config->s_NickServ)) - return true; - else if (!Config->s_ChanServ.empty() && nick.equals_ci(Config->s_ChanServ)) - return true; - else if (!Config->s_HostServ.empty() && nick.equals_ci(Config->s_HostServ)) - return true; - else if (!Config->s_MemoServ.empty() && nick.equals_ci(Config->s_MemoServ)) - return true; - else if (!Config->s_BotServ.empty() && nick.equals_ci(Config->s_BotServ)) - return true; - else if (!Config->s_OperServ.empty() && nick.equals_ci(Config->s_OperServ)) - return true; - else if (!Config->s_GlobalNoticer.empty() && nick.equals_ci(Config->s_GlobalNoticer)) - return true; - else if (!Config->s_BotServ.empty() && bot && BotListByNick.find(nick)) - return true; - + BotInfo *bi = findbot(nick); + if (bi) + return bot ? true : bi->HasFlag(BI_CORE); return false; } diff --git a/src/operserv.cpp b/src/operserv.cpp index a00e086fd..86afda8bc 100644 --- a/src/operserv.cpp +++ b/src/operserv.cpp @@ -593,11 +593,10 @@ XLine *SNLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_ { Anope::string rreason = "G-Lined: " + reason; - patricia_tree<User *, ci::ci_char_traits>::iterator uit(UserListByNick); - for (bool next = uit.next(); next;) + for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();) { - User *user = *uit; - next = uit.next(); + User *user = it->second; + ++it; if (!user->HasMode(UMODE_OPER) && user->server != Me && Anope::Match(user->realname, x->Mask)) kill_user(Config->ServerName, user, rreason); @@ -727,11 +726,10 @@ XLine *SQLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_ } else { - patricia_tree<User *, ci::ci_char_traits>::iterator uit(UserListByNick); - for (bool next = uit.next(); next;) + for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();) { - User *user = *uit; - next = uit.next(); + User *user = it->second; + ++it; if (!user->HasMode(UMODE_OPER) && user->server != Me && Anope::Match(user->nick, x->Mask)) kill_user(Config->ServerName, user, rreason); diff --git a/src/servers.cpp b/src/servers.cpp index 4b287b8f9..7bde57a35 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -65,11 +65,10 @@ Server::~Server() if (Capab.HasFlag(CAPAB_NOQUIT) || Capab.HasFlag(CAPAB_QS)) { - patricia_tree<User *, ci::ci_char_traits>::iterator uit(UserListByNick); - for (bool next = uit.next(); next;) + for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();) { - User *u = *uit; - next = uit.next(); + User *u = it->second; + ++it; if (u->server == this) { diff --git a/src/sessions.cpp b/src/sessions.cpp index dcbbff3e6..2be83410c 100644 --- a/src/sessions.cpp +++ b/src/sessions.cpp @@ -40,7 +40,7 @@ /*************************************************************************/ -patricia_tree<Session *> SessionList; +Anope::map<Session *> SessionList; std::vector<Exception *> exceptions; @@ -53,10 +53,9 @@ void get_session_stats(long &count, long &mem) count = SessionList.size(); mem = sizeof(Session) * SessionList.size(); - for (patricia_tree<Session *>::iterator it(SessionList); it.next();) + for (Anope::map<Session *>::iterator it = SessionList.begin(), it_end = SessionList.end(); it != it_end; ++it) { - Session *session = *it; - + Session *session = it->second; mem += session->host.length() + 1; } } @@ -84,7 +83,10 @@ void get_exception_stats(long &count, long &mem) Session *findsession(const Anope::string &host) { - return SessionList.find(host); + Anope::map<Session *>::iterator it = SessionList.find(host); + if (it != SessionList.end()) + return it->second; + return NULL; } /* Attempt to add a host to the session list. If the addition of the new host @@ -149,7 +151,7 @@ void add_session(User *u) session->count = 1; session->hits = 0; - SessionList.insert(session->host, session); + SessionList[session->host] = session; } } diff --git a/src/users.cpp b/src/users.cpp index 5e97fee5d..42e7984ec 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -12,8 +12,8 @@ #include "services.h" #include "modules.h" -patricia_tree<User *, ci::ci_char_traits> UserListByNick; -patricia_tree<User *> UserListByUID; +Anope::insensitive_map<User *> UserListByNick; +Anope::map<User *> UserListByUID; int32 opcnt = 0; uint32 usercnt = 0, maxusercnt = 0; @@ -42,9 +42,9 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope: this->uid = suid; this->isSuperAdmin = 0; - UserListByNick.insert(snick, this); + UserListByNick[snick] = this; if (!suid.empty()) - UserListByUID.insert(suid, this); + UserListByUID[suid] = this; this->nc = NULL; @@ -68,7 +68,7 @@ void User::SetNewNick(const Anope::string &newnick) this->nick = newnick; - UserListByNick.insert(this->nick, this); + UserListByNick[this->nick] = this; OnAccess = false; NickAlias *na = findnick(this->nick); @@ -761,9 +761,9 @@ void get_user_stats(long &count, long &mem) { count = mem = 0; - for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) + for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { - User *user = *it; + User *user = it->second; ++count; mem += sizeof(*user); @@ -784,9 +784,19 @@ void get_user_stats(long &count, long &mem) User *finduser(const Anope::string &nick) { if (isdigit(nick[0]) && ircd->ts6) - return UserListByUID.find(nick); + { + Anope::map<User *>::iterator it = UserListByUID.find(nick); + if (it != UserListByUID.end()) + return it->second; + } + else + { + Anope::insensitive_map<User *>::iterator it = UserListByNick.find(nick); + if (it != UserListByNick.end()) + return it->second; + } - return UserListByNick.find(nick); + return NULL; } /*************************************************************************/ |