]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/helperfuncs.cpp
Removed a pointless check in ./configure --clean that made it only work with one...
[user/henk/code/inspircd.git] / src / helperfuncs.cpp
index 7eb4544fbf58c3ff337998dc2cb7d36e4775f801..dab21744aafaf1780f0751cd03b9584903156dd9 100644 (file)
@@ -2,14 +2,11 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- *                    E-mail:
- *             <brain@chatspike.net>
- *             <Craig@chatspike.net>
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
  *
- * Written by Craig Edwards, Craig McLure, and others.
  * This program is free but copyrighted software; see
- *         the file COPYING for details.
+ *            the file COPYING for details.
  *
  * ---------------------------------------------------
  */
@@ -32,11 +29,15 @@ static time_t LAST = 0;
  */
 void InspIRCd::Log(int level, const char* text, ...)
 {
+       /* Do this check again here so that we save pointless vsnprintf calls */
+       if ((level < Config->LogLevel) && !Config->forcedebug)
+               return;
+
        va_list argsPtr;
-       char textbuffer[MAXBUF];
+       char textbuffer[65536];
 
        va_start(argsPtr, text);
-       vsnprintf(textbuffer, MAXBUF, text, argsPtr);
+       vsnprintf(textbuffer, 65536, text, argsPtr);
        va_end(argsPtr);
 
        this->Log(level, std::string(textbuffer));
@@ -75,7 +76,7 @@ void InspIRCd::Log(int level, const std::string &text)
 
 std::string InspIRCd::GetServerDescription(const char* servername)
 {
-       std::string description = "";
+       std::string description;
 
        FOREACH_MOD_I(this,I_OnGetServerDescription,OnGetServerDescription(servername,description));
 
@@ -237,12 +238,7 @@ userrec* InspIRCd::FindNick(const std::string &nick)
 
 userrec* InspIRCd::FindNick(const char* nick)
 {
-       user_hash::iterator iter;
-
-       if (!nick)
-               return NULL;
-
-       iter = clientlist.find(nick);
+       user_hash::iterator iter = clientlist.find(nick);
        
        if (iter == clientlist.end())
                return NULL;
@@ -254,12 +250,7 @@ userrec* InspIRCd::FindNick(const char* nick)
 
 chanrec* InspIRCd::FindChan(const char* chan)
 {
-       chan_hash::iterator iter;
-
-       if (!chan)
-               return NULL;
-
-       iter = chanlist.find(chan);
+       chan_hash::iterator iter = chanlist.find(chan);
 
        if (iter == chanlist.end())
                /* Couldn't find it */
@@ -279,7 +270,6 @@ chanrec* InspIRCd::FindChan(const std::string &chan)
        return iter->second;
 }
 
-
 /*
  * sends out an error notice to all connected clients (not to be used
  * lightly!)
@@ -310,14 +300,7 @@ int InspIRCd::UserCount()
 // this counts only registered users, so that the percentages in /MAP don't mess up when users are sitting in an unregistered state
 int InspIRCd::RegisteredUserCount()
 {
-       int c = 0;
-
-       for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
-       {
-               c += (i->second->registered == REG_ALL);
-       }
-
-       return c;
+       return clientlist.size() - this->UnregisteredUserCount();
 }
 
 int InspIRCd::InvisibleUserCount()
@@ -506,18 +489,18 @@ void InspIRCd::LoadAllModules()
        this->Log(DEFAULT,"Total loaded modules: %d", this->ModCount+1);
 }
 
-void InspIRCd::SendWhoisLine(userrec* user, int numeric, const std::string &text)
+void InspIRCd::SendWhoisLine(userrec* user, userrec* dest, int numeric, const std::string &text)
 {
        std::string copy_text = text;
 
        int MOD_RESULT = 0;
-       FOREACH_RESULT_I(this, I_OnWhoisLine, OnWhoisLine(user, numeric, copy_text));
+       FOREACH_RESULT_I(this, I_OnWhoisLine, OnWhoisLine(user, dest, numeric, copy_text));
 
        if (!MOD_RESULT)
                user->WriteServ("%d %s", numeric, copy_text.c_str());
 }
 
-void InspIRCd::SendWhoisLine(userrec* user, int numeric, const char* format, ...)
+void InspIRCd::SendWhoisLine(userrec* user, userrec* dest, int numeric, const char* format, ...)
 {
        char textbuffer[MAXBUF];
        va_list argsPtr;
@@ -525,6 +508,6 @@ void InspIRCd::SendWhoisLine(userrec* user, int numeric, const char* format, ...
        vsnprintf(textbuffer, MAXBUF, format, argsPtr);
        va_end(argsPtr);
 
-       this->SendWhoisLine(user, numeric, std::string(textbuffer));
+       this->SendWhoisLine(user, dest, numeric, std::string(textbuffer));
 }