summaryrefslogtreecommitdiff
path: root/src/inspircd.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-11-02 18:06:03 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-11-02 18:06:03 +0000
commit3475ebe194f0be23eb70cb496cbc8ebbae775163 (patch)
treeb1a3a3d649bfb8f09fb023feba8fa5b0a4a7d8ea /src/inspircd.cpp
parentb5b704f5dd92e9ba2ac9f06ef4f43c7a20ff2589 (diff)
Allow wildcards in LoadModule calls. If a filename contains either * or ? it will attempt to readdir() the currently configured module dir and load all modules which match.
If any one module fails, LoadModule then returns false. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5626 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r--src/inspircd.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index fe8b0b819..055e42a73 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -30,6 +30,7 @@
#include "inspircd.h"
#include "configreader.h"
#include <signal.h>
+#include <dirent.h>
#include <exception>
#include <fstream>
#include "modules.h"
@@ -536,28 +537,41 @@ bool InspIRCd::UnloadModule(const char* filename)
bool InspIRCd::LoadModule(const char* filename)
{
+ if (strchr(filename,'*') || (strchr(filename,'?')))
+ {
+ bool all_success = true;
+ DIR* library = opendir(Config->ModPath);
+ if (library)
+ {
+ dirent* entry = NULL;
+ while ((entry = readdir(library)))
+ {
+ if (this->MatchText(entry->d_name, filename))
+ {
+ if (!this->LoadModule(entry->d_name))
+ all_success = false;
+ }
+ }
+ closedir(library);
+ }
+ return all_success;
+ }
+
char modfile[MAXBUF];
-#ifdef STATIC_LINK
- strlcpy(modfile,filename,MAXBUF);
-#else
snprintf(modfile,MAXBUF,"%s/%s",Config->ModPath,filename);
-#endif
std::string filename_str = filename;
-#ifndef STATIC_LINK
-#ifndef IS_CYGWIN
+
if (!ServerConfig::DirValid(modfile))
{
this->Log(DEFAULT,"Module %s is not within the modules directory.",modfile);
snprintf(MODERR,MAXBUF,"Module %s is not within the modules directory.",modfile);
return false;
}
-#endif
-#endif
this->Log(DEBUG,"Loading module: %s",modfile);
-#ifndef STATIC_LINK
+
if (ServerConfig::FileExists(modfile))
{
-#endif
+
for (unsigned int j = 0; j < Config->module_names.size(); j++)
{
if (Config->module_names[j] == filename_str)
@@ -623,7 +637,6 @@ bool InspIRCd::LoadModule(const char* filename)
snprintf(MODERR,MAXBUF,"Factory function threw an exception: %s",modexcept.GetReason());
return false;
}
-#ifndef STATIC_LINK
}
else
{
@@ -631,7 +644,6 @@ bool InspIRCd::LoadModule(const char* filename)
snprintf(MODERR,MAXBUF,"Module file could not be found");
return false;
}
-#endif
this->ModCount++;
FOREACH_MOD_I(this,I_OnLoadModule,OnLoadModule(modules[this->ModCount],filename_str));
// now work out which modules, if any, want to move to the back of the queue,