]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modmanager_static.cpp
Merge pull request #1157 from SaberUK/insp20+fix-cron-restart
[user/henk/code/inspircd.git] / src / modmanager_static.cpp
index 18a95f78f9ded633fcd5cb9e73d5bb89e890a169..cea40c7a32364e75a807866f7979e6730c88a40c 100644 (file)
@@ -1,7 +1,27 @@
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
+ *
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
 #define MODNAME cmd_all
 
 #include "inspircd.h"
 #include "exitcodes.h"
+#include <iostream>
 
 #ifdef PURE_STATIC
 
@@ -73,6 +93,7 @@ bool ModuleManager::Load(const std::string& name, bool defer)
                mod = (*it->second->init)();
                mod->ModuleSourceFile = name;
                mod->ModuleDLLManager = NULL;
+               mod->dying = false;
                Modules[name] = mod;
                if (defer)
                {
@@ -137,7 +158,8 @@ namespace {
                        ServerInstance->Modules->DoSafeUnload(mod);
                        ServerInstance->GlobalCulls.Apply();
                        bool rv = ServerInstance->Modules->Load(name.c_str());
-                       callback->Call(rv);
+                       if (callback)
+                               callback->Call(rv);
                        ServerInstance->GlobalCulls.AddItem(this);
                }
        };
@@ -155,7 +177,7 @@ void ModuleManager::Reload(Module* mod, HandlerBase1<void, bool>* callback)
 {
        if (CanUnload(mod))
                ServerInstance->AtomicActions.AddAction(new ReloadAction(mod, callback));
-       else
+       else if (callback)
                callback->Call(false);
 }
 
@@ -163,18 +185,19 @@ void ModuleManager::LoadAll()
 {
        Load("cmd_all", true);
        Load("cmd_whowas.so", true);
+       Load("cmd_lusers.so", true);
 
        ConfigTagList tags = ServerInstance->Config->ConfTags("module");
        for(ConfigIter i = tags.first; i != tags.second; ++i)
        {
                ConfigTag* tag = i->second;
                std::string name = tag->getString("name");
-               printf_c("[\033[1;32m*\033[0m] Loading module:\t\033[1;32m%s\033[0m\n",name.c_str());
+               std::cout << "[" << con_green << "*" << con_reset << "] Loading module:\t" << con_green << name << con_reset << std::endl;
 
                if (!this->Load(name, true))
                {
                        ServerInstance->Logs->Log("MODULE", DEFAULT, this->LastError());
-                       printf_c("\n[\033[1;31m*\033[0m] %s\n\n", this->LastError().c_str());
+                       std::cout << std::endl << "[" << con_red << "*" << con_reset << "] " << this->LastError() << std::endl << std::endl;
                        ServerInstance->Exit(EXIT_STATUS_MODULE);
                }
        }
@@ -190,7 +213,7 @@ void ModuleManager::LoadAll()
                {
                        LastModuleError = "Unable to initialize " + mod->ModuleSourceFile + ": " + modexcept.GetReason();
                        ServerInstance->Logs->Log("MODULE", DEFAULT, LastModuleError);
-                       printf_c("\n[\033[1;31m*\033[0m] %s\n\n", LastModuleError.c_str());
+                       std::cout << std::endl << "[" << con_red << "*" << con_reset << "] " << LastModuleError << std::endl << std::endl;
                        ServerInstance->Exit(EXIT_STATUS_MODULE);
                }
        }