]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/helperfuncs.cpp
Remove Command and ModeHandler objects in their destructors; fixes possible pointer...
[user/henk/code/inspircd.git] / src / helperfuncs.cpp
index 80feae464c6e52468463de830163772c3d8a58be..cd173b55ffb1148fe22ab32013a957552815ab09 100644 (file)
 #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())
        {
@@ -281,20 +281,6 @@ bool InspIRCd::OpenLog(char**, int)
        {
                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->writelog) return true; // Skip opening default log if -nolog
 
@@ -302,7 +288,7 @@ bool InspIRCd::OpenLog(char**, int)
        {
                if (Config->logpath.empty())
                {
-                       Config->logpath = "./startup.log";
+                       Config->logpath = "logs/startup.log";
                }
 
                if (!Config->log_file)
@@ -318,8 +304,8 @@ bool InspIRCd::OpenLog(char**, int)
                return false;
        }
 
-       FileWriter* fw = new FileWriter(this, Config->log_file);
-       FileLogStream *f = new FileLogStream(this, (Config->forcedebug ? DEBUG : DEFAULT), fw);
+       FileWriter* fw = new FileWriter(Config->log_file);
+       FileLogStream *f = new FileLogStream((Config->forcedebug ? DEBUG : DEFAULT), fw);
 
        this->Logs->AddLogType("*", f, true);
 
@@ -341,9 +327,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 +387,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)