summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd_die.cpp3
-rw-r--r--src/configreader.cpp7
-rw-r--r--src/helperfuncs.cpp9
-rw-r--r--src/inspircd.cpp20
-rw-r--r--src/modules/m_dnsbl.cpp3
-rw-r--r--src/socketengine_epoll.cpp3
-rw-r--r--src/socketengine_kqueue.cpp3
7 files changed, 27 insertions, 21 deletions
diff --git a/src/cmd_die.cpp b/src/cmd_die.cpp
index 9bebf3fe6..5f1a88f67 100644
--- a/src/cmd_die.cpp
+++ b/src/cmd_die.cpp
@@ -14,6 +14,7 @@
#include "configreader.h"
#include "users.h"
#include "commands/cmd_die.h"
+#include "exitcodes.h"
extern "C" command_t* init_command(InspIRCd* Instance)
{
@@ -44,7 +45,7 @@ CmdResult cmd_die::Handle (const char** parameters, int pcnt, userrec *user)
}
sleep(ServerInstance->Config->DieDelay);
- InspIRCd::Exit(ERROR);
+ InspIRCd::Exit(EXIT_STATUS_DIE);
}
else
{
diff --git a/src/configreader.cpp b/src/configreader.cpp
index dde2d04db..f6c8ffbde 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -16,6 +16,7 @@
#include <fstream>
#include "inspircd.h"
#include "xline.h"
+#include "exitcodes.h"
std::vector<std::string> old_module_names, new_module_names, added_modules, removed_modules;
@@ -152,7 +153,7 @@ bool ServerConfig::CheckOnce(char* tag, bool bail, userrec* user)
if (bail)
{
printf("There were errors in your configuration:\nYou have more than one <%s> tag, this is not permitted.\n",tag);
- InspIRCd::Exit(ERROR);
+ InspIRCd::Exit(EXIT_STATUS_CONFIG);
}
else
{
@@ -174,7 +175,7 @@ bool ServerConfig::CheckOnce(char* tag, bool bail, userrec* user)
if (bail)
{
printf("There were errors in your configuration:\nYou have not defined a <%s> tag, this is required.\n",tag);
- InspIRCd::Exit(ERROR);
+ InspIRCd::Exit(EXIT_STATUS_CONFIG);
}
else
{
@@ -552,7 +553,7 @@ void ServerConfig::ReportConfigError(const std::string &errormessage, bool bail,
{
/* Unneeded because of the ServerInstance->Log() aboive? */
printf("There were errors in your configuration:\n%s\n\n",errormessage.c_str());
- InspIRCd::Exit(ERROR);
+ InspIRCd::Exit(EXIT_STATUS_CONFIG);
}
else
{
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 9ddfe338f..4f303d32c 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -19,6 +19,7 @@
#include "mode.h"
#include "xline.h"
#include "inspircd.h"
+#include "exitcodes.h"
static char TIMESTR[26];
static time_t LAST = 0;
@@ -448,7 +449,7 @@ void InspIRCd::OpenLog(char** argv, int argc)
if (!Config->log_file)
{
printf("ERROR: Could not write to logfile %s: %s\n\n", Config->logpath.c_str(), strerror(errno));
- Exit(ERROR);
+ Exit(EXIT_STATUS_LOG);
}
this->Logger = new FileLogger(this, Config->log_file);
@@ -460,7 +461,7 @@ void InspIRCd::CheckRoot()
{
printf("WARNING!!! You are running an irc server as ROOT!!! DO NOT DO THIS!!!\n\n");
this->Log(DEFAULT,"Cant start as root");
- Exit(ERROR);
+ Exit(EXIT_STATUS_ROOT);
}
}
@@ -470,7 +471,7 @@ void InspIRCd::CheckDie()
{
printf("WARNING: %s\n\n",Config->DieValue);
this->Log(DEFAULT,"Died because of <die> tag: %s",Config->DieValue);
- Exit(ERROR);
+ Exit(EXIT_STATUS_DIETAG);
}
}
@@ -490,7 +491,7 @@ void InspIRCd::LoadAllModules()
{
this->Log(DEFAULT,"There was an error loading a module: %s", this->ModuleError());
printf("\nThere was an error loading a module: %s\n\n",this->ModuleError());
- Exit(ERROR);
+ Exit(EXIT_STATUS_MODULE);
}
}
printf("\nA total of \033[1;32m%d\033[0m module%s been loaded.\n", this->ModCount+1, this->ModCount+1 == 1 ? " has" : "s have");
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 29b2105ce..ab438df16 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -25,6 +25,7 @@
#include "socket.h"
#include "typedefs.h"
#include "command_parse.h"
+#include "exitcodes.h"
#include <dlfcn.h>
using irc::sockets::NonBlocking;
@@ -65,10 +66,9 @@ void InspIRCd::Exit(int status)
{
if (SI)
{
- SI->SendError("Exiting with status " + ConvToStr(status));
+ SI->SendError("Exiting with status " + ConvToStr(status) + " (" + std::string(ExitCodes[status]) + ")");
SI->Cleanup();
}
-
exit (status);
}
@@ -167,7 +167,7 @@ bool InspIRCd::DaemonSeed()
*/
while (kill(childpid, 0) != -1)
sleep(1);
- exit(ERROR);
+ Exit(EXIT_STATUS_FORK);
}
setsid ();
umask (007);
@@ -212,7 +212,7 @@ void InspIRCd::WritePID(const std::string &filename)
{
printf("Failed to write PID-file '%s', exiting.\n",fname.c_str());
this->Log(DEFAULT,"Failed to write PID-file '%s', exiting.",fname.c_str());
- Exit(0);
+ Exit(EXIT_STATUS_PID);
}
}
@@ -245,7 +245,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
printf("ERROR: Cannot open config file: %s\nExiting...\n",CONFIG_FILE);
this->Log(DEFAULT,"main: no config");
printf("ERROR: Your config file is missing, this IRCd will self destruct in 10 seconds!\n");
- Exit(ERROR);
+ Exit(EXIT_STATUS_CONFIG);
}
*this->LogFileName = 0;
if (argc > 1) {
@@ -277,14 +277,14 @@ InspIRCd::InspIRCd(int argc, char** argv)
else
{
printf("ERROR: The -logfile parameter must be followed by a log file name and path.\n");
- Exit(ERROR);
+ Exit(EXIT_STATUS_CONFIG);
}
i++;
}
else
{
printf("Usage: %s [-nofork] [-nolog] [-debug] [-wait] [-logfile <filename>]\n",argv[0]);
- Exit(ERROR);
+ Exit(EXIT_STATUS_ARGV);
}
}
}
@@ -317,7 +317,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
if (!this->DaemonSeed())
{
printf("ERROR: could not go into daemon mode. Shutting down.\n");
- Exit(ERROR);
+ Exit(EXIT_STATUS_FORK);
}
}
@@ -337,7 +337,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
if ((stats->BoundPortCount == 0) && (found_ports > 0))
{
printf("\nERROR: I couldn't bind any ports! Are you sure you didn't start InspIRCd twice?\n");
- Exit(ERROR);
+ Exit(EXIT_STATUS_BIND);
}
if (stats->BoundPortCount != (unsigned int)found_ports)
@@ -361,7 +361,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
if (!SE->AddFd(Config->openSockfd[count]))
{
printf("\nEH? Could not add listener to socketengine. You screwed up, aborting.\n");
- Exit(ERROR);
+ Exit(EXIT_STATUS_INTERNAL);
}
}
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp
index b4d993703..cf089584d 100644
--- a/src/modules/m_dnsbl.cpp
+++ b/src/modules/m_dnsbl.cpp
@@ -71,7 +71,8 @@ class DNSBLResolver : public Resolver
while(tmp.length()>0)
{
std::string octet;
- unsigned int lastdot = tmp.rfind(".");
+ /* Fix by brain, npos is -1, so unsigned int will never match */
+ std::string::size_type lastdot = tmp.rfind(".");
if (lastdot == std::string::npos)
{
diff --git a/src/socketengine_epoll.cpp b/src/socketengine_epoll.cpp
index 245509a30..b3c30b8c8 100644
--- a/src/socketengine_epoll.cpp
+++ b/src/socketengine_epoll.cpp
@@ -12,6 +12,7 @@
*/
#include "inspircd.h"
+#include "exitcodes.h"
#include <sys/epoll.h>
#include "socketengine_epoll.h"
@@ -25,7 +26,7 @@ EPollEngine::EPollEngine(InspIRCd* Instance) : SocketEngine(Instance)
ServerInstance->Log(SPARSE,"ERROR: this is a fatal error, exiting now.");
printf("ERROR: Could not initialize socket engine. Your kernel probably does not have the proper features.");
printf("ERROR: this is a fatal error, exiting now.");
- InspIRCd::Exit(ERROR);
+ InspIRCd::Exit(EXIT_STATUS_SOCKETENGINE);
}
CurrentSetSize = 0;
}
diff --git a/src/socketengine_kqueue.cpp b/src/socketengine_kqueue.cpp
index 02cef0e44..469f5908d 100644
--- a/src/socketengine_kqueue.cpp
+++ b/src/socketengine_kqueue.cpp
@@ -12,6 +12,7 @@
*/
#include "inspircd.h"
+#include "exitcodes.h"
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
@@ -27,7 +28,7 @@ KQueueEngine::KQueueEngine(InspIRCd* Instance) : SocketEngine(Instance)
ServerInstance->Log(SPARSE,"ERROR: this is a fatal error, exiting now.");
printf("ERROR: Could not initialize socket engine. Your kernel probably does not have the proper features.");
printf("ERROR: this is a fatal error, exiting now.");
- InspIRCd::Exit(ERROR);
+ InspIRCd::Exit(EXIT_STATUS_SOCKETENGINE);
}
CurrentSetSize = 0;
}