]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modmanager_dynamic.cpp
Don't hardcode mode characters which are sent in 005 tokens.
[user/henk/code/inspircd.git] / src / modmanager_dynamic.cpp
index 7789c90bf8764294438c12c4f608b4cd4bbd6d44..644d2140f614435dbc9e51f286fc34fb22ded050 100644 (file)
 
 
 #include "inspircd.h"
-#include "xline.h"
-#include "socket.h"
-#include "socketengine.h"
-#include "command_parse.h"
 #include "exitcodes.h"
 #include <iostream>
 
 #include <dirent.h>
 #endif
 
-#ifndef PURE_STATIC
+#ifndef INSPIRCD_STATIC
 
-bool ModuleManager::Load(const std::string& filename, bool defer)
+bool ModuleManager::Load(const std::string& modname, bool defer)
 {
        /* Don't allow people to specify paths for modules, it doesn't work as expected */
-       if (filename.find('/') != std::string::npos)
+       if (modname.find('/') != std::string::npos)
+       {
+               LastModuleError = "You can't load modules with a path: " + modname;
                return false;
+       }
 
+       const std::string filename = ExpandModName(modname);
        const std::string moduleFile = ServerInstance->Config->Paths.PrependModule(filename);
 
-       if (!ServerConfig::FileExists(moduleFile.c_str()))
+       if (!FileSystem::FileExists(moduleFile))
        {
                LastModuleError = "Module file could not be found: " + filename;
                ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, LastModuleError);
@@ -55,10 +55,14 @@ bool ModuleManager::Load(const std::string& filename, bool defer)
 
        Module* newmod = NULL;
        DLLManager* newhandle = new DLLManager(moduleFile.c_str());
+       ServiceList newservices;
+       if (!defer)
+               this->NewServices = &newservices;
 
        try
        {
                newmod = newhandle->CallInit();
+               this->NewServices = NULL;
 
                if (newmod)
                {
@@ -67,6 +71,8 @@ bool ModuleManager::Load(const std::string& filename, bool defer)
                        newmod->dying = false;
                        Modules[filename] = newmod;
                        std::string version = newhandle->GetVersion();
+                       if (version.empty())
+                               version.assign("unknown");
                        if (defer)
                        {
                                ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "New module introduced: %s (Module version %s)",
@@ -77,6 +83,7 @@ bool ModuleManager::Load(const std::string& filename, bool defer)
                                ConfigStatus confstatus;
 
                                AttachAll(newmod);
+                               AddServices(newservices);
                                newmod->init();
                                newmod->ReadConfig(confstatus);
 
@@ -95,6 +102,8 @@ bool ModuleManager::Load(const std::string& filename, bool defer)
        }
        catch (CoreException& modexcept)
        {
+               this->NewServices = NULL;
+
                // failure in module constructor
                if (newmod)
                {
@@ -118,7 +127,7 @@ bool ModuleManager::Load(const std::string& filename, bool defer)
 }
 
 /* We must load the modules AFTER initializing the socket engine, now */
-void ModuleManager::LoadCoreModules()
+void ModuleManager::LoadCoreModules(std::map<std::string, ServiceList>& servicemap)
 {
        std::cout << std::endl << "Loading core commands";
        fflush(stdout);
@@ -129,11 +138,13 @@ void ModuleManager::LoadCoreModules()
                dirent* entry = NULL;
                while (0 != (entry = readdir(library)))
                {
-                       if (InspIRCd::Match(entry->d_name, "cmd_*.so", ascii_case_insensitive_map))
+                       if (InspIRCd::Match(entry->d_name, "core_*.so", ascii_case_insensitive_map))
                        {
                                std::cout << ".";
                                fflush(stdout);
 
+                               this->NewServices = &servicemap[entry->d_name];
+
                                if (!Load(entry->d_name, true))
                                {
                                        ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, this->LastError());