]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/helperfuncs.cpp
...because every now and again, i have to do a massive commit.
[user/henk/code/inspircd.git] / src / helperfuncs.cpp
index 80feae464c6e52468463de830163772c3d8a58be..ffa30fb840799e8f4cdc025f1cbfd8a1170a3290 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
  * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
 #include "xline.h"
 #include "exitcodes.h"
 
-std::string InspIRCd::GetServerDescription(const char* servername)
+std::string InspIRCd::GetServerDescription(const std::string& servername)
 {
        std::string description;
 
-       FOREACH_MOD_I(this,I_OnGetServerDescription,OnGetServerDescription(servername,description));
+       FOREACH_MOD(I_OnGetServerDescription,OnGetServerDescription(servername,description));
 
        if (!description.empty())
        {
@@ -123,7 +123,7 @@ Channel* InspIRCd::FindChan(const std::string &chan)
 /* Send an error notice to all users, registered or not */
 void InspIRCd::SendError(const std::string &s)
 {
-       for (std::vector<User*>::const_iterator i = this->Users->local_users.begin(); i != this->Users->local_users.end(); i++)
+       for (std::vector<LocalUser*>::const_iterator i = this->Users->local_users.begin(); i != this->Users->local_users.end(); i++)
        {
                User* u = *i;
                if (u->registered == REG_ALL)
@@ -276,50 +276,19 @@ bool IsSIDHandler::Call(const std::string &str)
 /* open the proper logfile */
 bool InspIRCd::OpenLog(char**, int)
 {
-       /* This function only happens at startup now */
-       if (Config->nofork)
-       {
-               this->Logs->SetupNoFork();
-       }
-       Config->MyDir = Config->GetFullProgDir();
-
-       /* Attempt to find home directory, portable to windows */
-       const char* home = getenv("HOME");
-       if (!home)
-       {
-               /* No $HOME, log to %USERPROFILE% */
-               home = getenv("USERPROFILE");
-               if (!home)
-               {
-                       /* Nothing could be found at all, log to current dir */
-                       Config->logpath = "./startup.log";
-               }
-       }
+       if (!Config->cmdline.writelog) return true; // Skip opening default log if -nolog
 
-       if (!Config->writelog) return true; // Skip opening default log if -nolog
+       if (Config->cmdline.startup_log.empty())
+               Config->cmdline.startup_log = "logs/startup.log";
+       FILE* startup = fopen(Config->cmdline.startup_log.c_str(), "a+");
 
-       if (!*this->LogFileName)
-       {
-               if (Config->logpath.empty())
-               {
-                       Config->logpath = "./startup.log";
-               }
-
-               if (!Config->log_file)
-                       Config->log_file = fopen(Config->logpath.c_str(),"a+");
-       }
-       else
-       {
-               Config->log_file = fopen(this->LogFileName,"a+");
-       }
-
-       if (!Config->log_file)
+       if (!startup)
        {
                return false;
        }
 
-       FileWriter* fw = new FileWriter(this, Config->log_file);
-       FileLogStream *f = new FileLogStream(this, (Config->forcedebug ? DEBUG : DEFAULT), fw);
+       FileWriter* fw = new FileWriter(startup);
+       FileLogStream *f = new FileLogStream((Config->cmdline.forcedebug ? DEBUG : DEFAULT), fw);
 
        this->Logs->AddLogType("*", f, true);
 
@@ -341,9 +310,9 @@ void InspIRCd::SendWhoisLine(User* user, User* dest, int numeric, const std::str
        std::string copy_text = text;
 
        ModResult MOD_RESULT;
-       FIRST_MOD_RESULT(this, OnWhoisLine, MOD_RESULT, (user, dest, numeric, copy_text));
+       FIRST_MOD_RESULT(OnWhoisLine, MOD_RESULT, (user, dest, numeric, copy_text));
 
-       if (!MOD_RESULT)
+       if (MOD_RESULT != MOD_RES_DENY)
                user->WriteServ("%d %s", numeric, copy_text.c_str());
 }
 
@@ -401,22 +370,21 @@ long InspIRCd::Duration(const std::string &str)
        return total + subtotal;
 }
 
-bool InspIRCd::ULine(const char* sserver)
+bool InspIRCd::ULine(const std::string& sserver)
 {
-       if (!sserver)
-               return false;
-       if (!*sserver)
+       if (sserver.empty())
                return true;
 
-       return (Config->ulines.find(sserver) != Config->ulines.end());
+       return (Config->ulines.find(sserver.c_str()) != Config->ulines.end());
 }
 
-bool InspIRCd::SilentULine(const char* sserver)
+bool InspIRCd::SilentULine(const std::string& sserver)
 {
-       std::map<irc::string,bool>::iterator n = Config->ulines.find(sserver);
+       std::map<irc::string,bool>::iterator n = Config->ulines.find(sserver.c_str());
        if (n != Config->ulines.end())
                return n->second;
-       else return false;
+       else
+               return false;
 }
 
 std::string InspIRCd::TimeString(time_t curtime)