]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modulemanager.cpp
Convert the ISO 8859-2 nationalchars files to codepage configs.
[user/henk/code/inspircd.git] / src / modulemanager.cpp
index 86edd572f7188cdd6789e6db3aba8b7b2dd8ed65..cac1263581ce2c8e4d03c04e13512ff71beac67c 100644 (file)
@@ -1,6 +1,12 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2013, 2015, 2019-2020 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2013 Adam <Adam@anope.org>
+ *   Copyright (C) 2012-2013, 2015 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2012 ChrisTX <xpipe@hotmail.de>
+ *   Copyright (C) 2010 Craig Edwards <brain@inspircd.org>
  *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
 #include "exitcodes.h"
 #include <iostream>
 
-#ifndef _WIN32
-#include <dirent.h>
-#endif
-
 bool ModuleManager::Load(const std::string& modname, bool defer)
 {
        /* Don't allow people to specify paths for modules, it doesn't work as expected */
@@ -67,13 +69,13 @@ bool ModuleManager::Load(const std::string& modname, bool defer)
                        newmod->ModuleSourceFile = filename;
                        newmod->ModuleDLLManager = newhandle;
                        Modules[filename] = newmod;
-                       std::string version = newhandle->GetVersion();
-                       if (version.empty())
-                               version.assign("unknown");
+                       const char* version = newhandle->GetVersion();
+                       if (!version)
+                               version = "unknown";
                        if (defer)
                        {
                                ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "New module introduced: %s (Module version %s)",
-                                       filename.c_str(), version.c_str());
+                                       filename.c_str(), version);
                        }
                        else
                        {
@@ -86,7 +88,7 @@ bool ModuleManager::Load(const std::string& modname, bool defer)
 
                                Version v = newmod->GetVersion();
                                ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "New module introduced: %s (Module version %s)%s",
-                                       filename.c_str(), version.c_str(), (!(v.Flags & VF_VENDOR) ? " [3rd Party]" : " [Vendor]"));
+                                       filename.c_str(), version, (!(v.Flags & VF_VENDOR) ? " [3rd Party]" : " [Vendor]"));
                        }
                }
                else
@@ -126,31 +128,29 @@ bool ModuleManager::Load(const std::string& modname, bool defer)
 /* We must load the modules AFTER initializing the socket engine, now */
 void ModuleManager::LoadCoreModules(std::map<std::string, ServiceList>& servicemap)
 {
-       std::cout << std::endl << "Loading core commands";
-       fflush(stdout);
+       std::cout << "Loading core modules " << std::flush;
 
-       DIR* library = opendir(ServerInstance->Config->Paths.Module.c_str());
-       if (library)
+       std::vector<std::string> files;
+       if (!FileSystem::GetFileList(ServerInstance->Config->Paths.Module, files, "core_*.so"))
        {
-               dirent* entry = NULL;
-               while (0 != (entry = readdir(library)))
-               {
-                       if (InspIRCd::Match(entry->d_name, "core_*.so", ascii_case_insensitive_map))
-                       {
-                               std::cout << ".";
-                               fflush(stdout);
+               std::cout << "failed!" << std::endl;
+               ServerInstance->Exit(EXIT_STATUS_MODULE);
+       }
 
-                               this->NewServices = &servicemap[entry->d_name];
+       for (std::vector<std::string>::const_iterator iter = files.begin(); iter != files.end(); ++iter)
+       {
+               std::cout << "." << std::flush;
 
-                               if (!Load(entry->d_name, true))
-                               {
-                                       ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, this->LastError());
-                                       std::cout << std::endl << "[" << con_red << "*" << con_reset << "] " << this->LastError() << std::endl << std::endl;
-                                       ServerInstance->Exit(EXIT_STATUS_MODULE);
-                               }
-                       }
+               const std::string& name = *iter;
+               this->NewServices = &servicemap[name];
+
+               if (!Load(name, true))
+               {
+                       ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, this->LastError());
+                       std::cout << std::endl << "[" << con_red << "*" << con_reset << "] " << this->LastError() << std::endl << std::endl;
+                       ServerInstance->Exit(EXIT_STATUS_MODULE);
                }
-               closedir(library);
-               std::cout << std::endl;
        }
+
+       std::cout << std::endl;
 }