summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/commands.h1
-rw-r--r--include/inspircd.h3
-rw-r--r--src/commands.cpp12
-rw-r--r--src/inspircd.cpp13
4 files changed, 27 insertions, 2 deletions
diff --git a/include/commands.h b/include/commands.h
index 1242671b3..aa6fcf206 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -79,6 +79,7 @@ void handle_zline(char **parameters, int pcnt, userrec *user);
void handle_qline(char **parameters, int pcnt, userrec *user);
void handle_eline(char **parameters, int pcnt, userrec *user);
void handle_server(char **parameters, int pcnt, userrec *user);
+void handle_loadmodule(char **parameters, int pcnt, userrec *user);
/** Special functions for processing server to server traffic
*/
diff --git a/include/inspircd.h b/include/inspircd.h
index 2f16fbc82..e54da779b 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -158,7 +158,8 @@ char islast(const char* s);
long map_count(const char* s);
userrec* ReHashNick(char* Old, char* New);
long GetMaxBans(char* name);
-
+bool LoadModule(const char* filename);
+char* ModuleError();
// mesh network functions
diff --git a/src/commands.cpp b/src/commands.cpp
index 00074fb51..5d8f94316 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -270,6 +270,18 @@ void handle_kick(char **parameters, int pcnt, userrec *user)
NetSendToAll(buffer);
}
+void handle_loadmodule(char **parameters, int pcnt, userrec *user)
+{
+ if (LoadModule(parameters[0]))
+ {
+ WriteOpers("*** NEW MODULE: %s",parameters[0]);
+ WriteServ(user->fd,"975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
+ }
+ else
+ {
+ WriteServ(user->fd,"974 %s %s :Failed to load module: %s",user->nick, parameters[0],ModuleError());
+ }
+}
void handle_die(char **parameters, int pcnt, userrec *user)
{
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 64ba6a8c1..d3c9e9ed4 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -2985,6 +2985,7 @@ void SetupCommandTable(void)
createcommand("ZLINE",handle_zline,'o',1);
createcommand("QLINE",handle_qline,'o',1);
createcommand("ELINE",handle_eline,'o',1);
+ createcommand("LOADMODULE",handle_loadmodule,'o',1);
createcommand("SERVER",handle_server,0,0);
}
@@ -3233,6 +3234,12 @@ void RemoveServer(const char* name)
int reap_counter = 0;
+char MODERR[MAXBUF];
+
+char* ModuleError()
+{
+ return MODERR;
+}
bool LoadModule(const char* filename)
{
@@ -3246,6 +3253,7 @@ bool LoadModule(const char* filename)
if (module_names[j] == std::string(filename))
{
log(DEFAULT,"Module %s is already loaded, cannot load a module twice!",modfile);
+ snprintf(MODERR,MAXBUF,"Module already loaded");
return false;
}
}
@@ -3253,6 +3261,7 @@ bool LoadModule(const char* filename)
if (factory[MODCOUNT+1]->LastError())
{
log(DEFAULT,"Unable to load %s: %s",modfile,factory[MODCOUNT+1]->LastError());
+ snprintf(MODERR,MAXBUF,"Loader/Linker error: %s",factory[MODCOUNT+1]->LastError());
MODCOUNT--;
return false;
}
@@ -3266,12 +3275,14 @@ bool LoadModule(const char* filename)
else
{
log(DEFAULT,"Unable to load %s",modfile);
+ snprintf(MODERR,MAXBUF,"Factory function failed!");
return false;
}
}
else
{
log(DEFAULT,"InspIRCd: startup: Module Not Found %s",modfile);
+ snprintf(MODERR,MAXBUF,"Module file could not be found");
return false;
}
MODCOUNT++;
@@ -3371,7 +3382,7 @@ int InspIRCd(void)
if (!LoadModule(configToken))
{
log(DEBUG,"Exiting due to a module loader error.");
- printf("There was an error loading a module. View your ircd.log for details.\n");
+ printf("There was an error loading a module: %s\n",ModuleError());
Exit(0);
}
}