summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-08-11 11:29:15 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-08-11 11:29:15 +0000
commit8683e1c80d9d37ee7ffae54c0d888195a5e8d1a7 (patch)
tree4300f56266760c63163dfcac992cb017a94754e5 /src
parent0d59b84eb106499f58067e46c321d8b1de09b778 (diff)
Provide error output on failure to load a core command; to console on startup, and to user on /reload
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7708 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/command_parse.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 84850a880..a3b5b41c7 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -21,6 +21,7 @@
#include "socketengine.h"
#include "socket.h"
#include "command_parse.h"
+#include "exitcodes.h"
/* Directory Searching for Unix-Only */
#ifndef WIN32
@@ -459,7 +460,7 @@ bool CommandParser::FindSym(void** v, void* h)
return true;
}
-bool CommandParser::ReloadCommand(const char* cmd)
+bool CommandParser::ReloadCommand(const char* cmd, userrec* user)
{
char filename[MAXBUF];
char commandname[MAXBUF];
@@ -486,7 +487,9 @@ bool CommandParser::ReloadCommand(const char* cmd)
RFCCommands.erase(command);
snprintf(filename, MAXBUF, "cmd_%s.so", commandname);
- this->LoadCommand(filename);
+ const char* err = this->LoadCommand(filename);
+ if (err)
+ user->WriteServ("NOTICE %s :*** Error loading 'cmd_%s.so': %s", user->nick, cmd, err);
return true;
}
@@ -497,7 +500,7 @@ bool CommandParser::ReloadCommand(const char* cmd)
CmdResult cmd_reload::Handle(const char** parameters, int pcnt, userrec *user)
{
user->WriteServ("NOTICE %s :*** Reloading command '%s'",user->nick, parameters[0]);
- if (ServerInstance->Parser->ReloadCommand(parameters[0]))
+ if (ServerInstance->Parser->ReloadCommand(parameters[0], user))
{
user->WriteServ("NOTICE %s :*** Successfully reloaded command '%s'", user->nick, parameters[0]);
ServerInstance->WriteOpers("*** RELOAD: %s reloaded the '%s' command.", user->nick, parameters[0]);
@@ -510,7 +513,7 @@ CmdResult cmd_reload::Handle(const char** parameters, int pcnt, userrec *user)
}
}
-void CommandParser::LoadCommand(const char* name)
+const char* CommandParser::LoadCommand(const char* name)
{
char filename[MAXBUF];
void* h;
@@ -521,8 +524,9 @@ void CommandParser::LoadCommand(const char* name)
if (!h)
{
- ServerInstance->Log(SPARSE, "Error loading core command: %s", dlerror());
- return;
+ const char* n = dlerror();
+ ServerInstance->Log(SPARSE, "Error loading core command: %s", n);
+ return n;
}
if (this->FindSym((void **)&cmd_factory_func, h))
@@ -530,6 +534,7 @@ void CommandParser::LoadCommand(const char* name)
command_t* newcommand = cmd_factory_func(ServerInstance);
this->CreateCommand(newcommand, h);
}
+ return NULL;
}
void CommandParser::SetupCommandTable()
@@ -549,7 +554,12 @@ void CommandParser::SetupCommandTable()
{
printf(".");
fflush(stdout);
- this->LoadCommand(entry->d_name);
+ const char* err = this->LoadCommand(entry->d_name);
+ if (err)
+ {
+ printf("Error loading %s: %s", entry->d_name, err);
+ exit(EXIT_STATUS_BADHANDLER);
+ }
}
}
closedir(library);