X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fhelperfuncs.cpp;h=1f2a6646b5ea838ef952f77feaa25dad8656ab50;hb=eb28eaea35d9d109a0b7b890de9d957d562da675;hp=be8c9ac6746a12edb9574f485d57a2d517dceb02;hpb=89749a74402913d50bd5a9140757a383d6ff175e;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index be8c9ac67..1f2a6646b 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -16,7 +16,6 @@ #include #include "inspircd_config.h" -#include "inspircd.h" #include "configreader.h" #include #include @@ -43,6 +42,7 @@ #include "helperfuncs.h" #include "hashcomp.h" #include "typedefs.h" +#include "inspircd.h" extern int MODCOUNT; extern ModuleList modules; @@ -50,13 +50,9 @@ extern InspIRCd* ServerInstance; extern time_t TIME; extern char lowermap[255]; extern std::vector all_opers; -extern user_hash clientlist; -extern chan_hash chanlist; char LOG_FILE[MAXBUF]; -extern std::vector local_users; - static char TIMESTR[26]; static time_t LAST = 0; @@ -171,7 +167,7 @@ void WriteOpers_NoFormat(const char* text) } } -void ServerNoticeAll(char* text, ...) +void InspIRCd::ServerNoticeAll(char* text, ...) { if (!text) return; @@ -192,7 +188,7 @@ void ServerNoticeAll(char* text, ...) } } -void ServerPrivmsgAll(char* text, ...) +void InspIRCd::ServerPrivmsgAll(char* text, ...) { if (!text) return; @@ -213,7 +209,7 @@ void ServerPrivmsgAll(char* text, ...) } } -void WriteMode(const char* modes, int flags, const char* text, ...) +void InspIRCd::WriteMode(const char* modes, int flags, const char* text, ...) { char textbuffer[MAXBUF]; int modelen; @@ -269,32 +265,6 @@ void WriteMode(const char* modes, int flags, const char* text, ...) } } -void NoticeAll(userrec *source, bool local_only, char* text, ...) -{ - char textbuffer[MAXBUF]; - char formatbuffer[MAXBUF]; - va_list argsPtr; - - if ((!text) || (!source)) - { - log(DEFAULT,"*** BUG *** NoticeAll was given an invalid parameter"); - return; - } - - va_start(argsPtr, text); - vsnprintf(textbuffer, MAXBUF, text, argsPtr); - va_end(argsPtr); - - snprintf(formatbuffer,MAXBUF,"NOTICE $* :%s",textbuffer); - - for (std::vector::const_iterator i = local_users.begin(); i != local_users.end(); i++) - { - userrec* t = *i; - t->WriteFrom(source,std::string(formatbuffer)); - } -} - - /* convert a string to lowercase. Note following special circumstances * taken from RFC 1459. Many "official" server branches still hold to this * rule so i will too; @@ -317,9 +287,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 +303,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 +323,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 +371,12 @@ void purge_empty_chans(userrec* u) for (std::vector::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); } } @@ -559,12 +529,6 @@ int usercount_i(chanrec *c) return count; } -int usercount(chanrec *c) -{ - return (c ? c->GetUserCounter() : 0); -} - - /* looks up a users password for their connection class (/ tags) * NOTE: If the or tag specifies an ip, and this user resolves, * then their ip will be taken as 'priority' anyway, so for example, @@ -587,11 +551,9 @@ ConnectClass GetClass(userrec *user) * sends out an error notice to all connected clients (not to be used * lightly!) */ -void send_error(char *s) +void InspIRCd::SendError(const char *s) { - log(DEBUG,"send_error: %s",s); - - for (std::vector::const_iterator i = local_users.begin(); i != local_users.end(); i++) + for (std::vector::const_iterator i = this->local_users.begin(); i != this->local_users.end(); i++) { userrec* t = (userrec*)(*i); if (t->registered == REG_ALL) @@ -632,7 +594,7 @@ void Error(int status) #else log(DEFAULT,"You do not have execinfo.h so i could not backtrace -- on FreeBSD, please install the libexecinfo port."); #endif - send_error("Somebody screwed up... Whoops. IRC Server terminating."); + ServerInstance->SendError("Somebody screwed up... Whoops. IRC Server terminating."); signal(SIGSEGV, SIG_DFL); if (raise(SIGSEGV) == -1) { @@ -642,13 +604,13 @@ void Error(int status) } // this function counts all users connected, wether they are registered or NOT. -int usercnt(void) +int InspIRCd::usercnt() { return 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 -int registered_usercount(void) +int InspIRCd::registered_usercount() { int c = 0; @@ -660,7 +622,7 @@ int registered_usercount(void) return c; } -int usercount_invisible(void) +int InspIRCd::usercount_invisible() { int c = 0; @@ -672,7 +634,7 @@ int usercount_invisible(void) return c; } -int usercount_opers(void) +int InspIRCd::usercount_opers() { int c = 0; @@ -684,7 +646,7 @@ int usercount_opers(void) return c; } -int usercount_unknown(void) +int InspIRCd::usercount_unknown() { int c = 0; @@ -698,12 +660,12 @@ int usercount_unknown(void) return c; } -long chancount(void) +long InspIRCd::chancount() { return chanlist.size(); } -long local_count() +long InspIRCd::local_count() { int c = 0;