diff --git a/include/logger.h b/include/logger.h index cb3d00d6a..2a11967b9 100644 --- a/include/logger.h +++ b/include/logger.h @@ -88,11 +88,7 @@ class CoreExport LogInfo void AddType(std::list &list, const Anope::string &type); - bool HasType(std::list &list, const Anope::string &type) const; - - std::list &GetList(LogType type); - - bool HasType(LogType Type); + bool HasType(LogType ltype, const Anope::string &type) const; void ProcessMessage(const Log *l); }; diff --git a/src/logger.cpp b/src/logger.cpp index 4ccfa813f..d4d09565c 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -205,9 +205,39 @@ void LogInfo::AddType(std::list &list, const Anope::string &type) list.push_back(type); } -bool LogInfo::HasType(std::list &list, const Anope::string &type) const +bool LogInfo::HasType(LogType ltype, const Anope::string &type) const { - for (std::list::iterator it = list.begin(), it_end = list.end(); it != it_end; ++it) + const std::list *list = NULL; + switch (ltype) + { + case LOG_ADMIN: + list = &this->Admin; + case LOG_OVERRIDE: + list = &this->Override; + case LOG_COMMAND: + list = &this->Commands; + case LOG_SERVER: + list = &this->Servers; + case LOG_CHANNEL: + list = &this->Channels; + case LOG_USER: + list = &this->Users; + case LOG_NORMAL: + list = &this->Normal; + case LOG_TERMINAL: + return true; + case LOG_RAWIO: + return debug ? true : this->RawIO; + case LOG_DEBUG: + return debug ? true : this->Debug; + default: + break; + } + + if (list == NULL) + return false; + + for (std::list::const_iterator it = list->begin(), it_end = list->end(); it != it_end; ++it) { Anope::string cat = *it; bool inverse = false; @@ -225,67 +255,13 @@ bool LogInfo::HasType(std::list &list, const Anope::string &type) return false; } -std::list &LogInfo::GetList(LogType type) -{ - static std::list empty; - - switch (type) - { - case LOG_ADMIN: - return this->Admin; - case LOG_OVERRIDE: - return this->Override; - case LOG_COMMAND: - return this->Commands; - case LOG_SERVER: - return this->Servers; - case LOG_CHANNEL: - return this->Channels; - case LOG_USER: - return this->Users; - case LOG_NORMAL: - return this->Normal; - default: - return empty; - } -} - -bool LogInfo::HasType(LogType type) -{ - switch (type) - { - case LOG_ADMIN: - case LOG_OVERRIDE: - case LOG_COMMAND: - case LOG_SERVER: - case LOG_CHANNEL: - case LOG_USER: - case LOG_NORMAL: - return !this->GetList(type).empty(); - case LOG_TERMINAL: - return true; - case LOG_RAWIO: - return debug ? true : this->RawIO; - case LOG_DEBUG: - return debug ? true : this->Debug; - // LOG_DEBUG_[234] - default: - break; - } - - return false; -} - void LogInfo::ProcessMessage(const Log *l) { static time_t lastwarn = Anope::CurTime; if (!l) throw CoreException("Bad values passed to LogInfo::ProcessMessages"); - - if (!this->HasType(l->Type)) - return; - else if (!this->HasType(this->GetList(l->Type), l->Category)) + else if (!this->HasType(l->Type, l->Category)) return; if (!this->Sources.empty()) diff --git a/src/servers.cpp b/src/servers.cpp index 2a9dd7911..19140c154 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -323,7 +323,7 @@ Server *Server::Find(const Anope::string &name, Server *s) if (!s) s = Me; - if (s->GetName().equals_cs(name) || s->GetSID().equals_cs(name)) + if (s->GetName().equals_ci(name) || s->GetSID().equals_cs(name)) return s; if (!s->GetLinks().empty()) diff --git a/src/sockets.cpp b/src/sockets.cpp index f255a4edf..7765d3066 100644 --- a/src/sockets.cpp +++ b/src/sockets.cpp @@ -282,10 +282,10 @@ ClientSocket *SocketIO::Accept(ListenSocket *s) int newsock = accept(s->GetFD(), &conaddr.sa, &size); #ifndef INVALID_SOCKET -# define INVALID_SOCKET 0 +# define INVALID_SOCKET -1 #endif - if (newsock > 0 && newsock != INVALID_SOCKET) + if (newsock >= 0 && newsock != INVALID_SOCKET) return s->OnAccept(newsock, conaddr); else throw SocketException("Unable to accept connection: " + Anope::LastError());