summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-24 01:44:29 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-24 01:44:29 +0000
commitc8026bc2d73344e1df526f0a80694046efa4b22a (patch)
tree539e3bca92733aeff631fad70ecc6722550ef0b0 /src
parent58895f9b1daa1e13927462d046a36dec853a40e0 (diff)
Move configuration filename specification to start script, to reduce hardcoded paths in executable
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11759 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/commands/cmd_rehash.cpp6
-rw-r--r--src/configreader.cpp4
-rw-r--r--src/inspircd.cpp12
-rw-r--r--src/server.cpp2
4 files changed, 12 insertions, 12 deletions
diff --git a/src/commands/cmd_rehash.cpp b/src/commands/cmd_rehash.cpp
index a689801aa..b2a9fbde4 100644
--- a/src/commands/cmd_rehash.cpp
+++ b/src/commands/cmd_rehash.cpp
@@ -67,15 +67,15 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use
// Rehash for me. Try to start the rehash thread
if (!ServerInstance->ConfigThread)
{
- std::string m = user->nick + " is rehashing config file " + ServerConfig::CleanFilename(ServerInstance->ConfigFileName) + " on " + ServerInstance->Config->ServerName;
+ std::string m = user->nick + " is rehashing config file " + ServerConfig::CleanFilename(ServerInstance->ConfigFileName.c_str()) + " on " + ServerInstance->Config->ServerName;
ServerInstance->SNO->WriteGlobalSno('a', m);
if (IS_LOCAL(user))
user->WriteNumeric(RPL_REHASHING, "%s %s :Rehashing",
- user->nick.c_str(),ServerConfig::CleanFilename(ServerInstance->ConfigFileName));
+ user->nick.c_str(),ServerConfig::CleanFilename(ServerInstance->ConfigFileName.c_str()));
else
ServerInstance->PI->SendUserNotice(user, std::string("*** Rehashing server ") +
- ServerConfig::CleanFilename(ServerInstance->ConfigFileName));
+ ServerConfig::CleanFilename(ServerInstance->ConfigFileName.c_str()));
/* Don't do anything with the logs here -- logs are restarted
* after the config thread has completed.
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 5e1dd6969..159ca598f 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -1969,9 +1969,9 @@ bool ServerConfig::FileExists(const char* file)
}
}
-char* ServerConfig::CleanFilename(char* name)
+const char* ServerConfig::CleanFilename(const char* name)
{
- char* p = name + strlen(name);
+ const char* p = name + strlen(name);
while ((p != name) && (*p != '/') && (*p != '\\')) p--;
return (p != name ? ++p : p);
}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 704fec475..f28324d16 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -328,6 +328,7 @@ InspIRCd::InspIRCd(int argc, char** argv) :
HandleIsChannel(this),
HandleIsSID(this),
HandleRehash(this),
+ ConfigFileName("inspircd.conf"),
/* Functor pointer initialisation. Must match the order of the list above
*
@@ -428,7 +429,6 @@ InspIRCd::InspIRCd(int argc, char** argv) :
srand(this->TIME);
*this->LogFileName = 0;
- strlcpy(this->ConfigFileName, CONFIG_FILE, MAXBUF);
struct option longopts[] =
{
@@ -454,7 +454,7 @@ InspIRCd::InspIRCd(int argc, char** argv) :
break;
case 'c':
/* Config filename was set */
- strlcpy(ConfigFileName, optarg, MAXBUF);
+ ConfigFileName = optarg;
break;
case 0:
/* getopt_long_only() set an int variable, just keep going */
@@ -508,7 +508,7 @@ InspIRCd::InspIRCd(int argc, char** argv) :
Exit(EXIT_STATUS_LOG);
}
- if (!ServerConfig::FileExists(this->ConfigFileName))
+ if (!ServerConfig::FileExists(ConfigFileName.c_str()))
{
#ifdef WIN32
/* Windows can (and defaults to) hide file extensions, so let's play a bit nice for windows users. */
@@ -517,13 +517,13 @@ InspIRCd::InspIRCd(int argc, char** argv) :
if (ServerConfig::FileExists(txtconf.c_str()))
{
- strlcat(this->ConfigFileName, ".txt", MAXBUF);
+ ConfigFileName = txtconf;
}
else
#endif
{
- printf("ERROR: Cannot open config file: %s\nExiting...\n", this->ConfigFileName);
- this->Logs->Log("STARTUP",DEFAULT,"Unable to open config file %s", this->ConfigFileName);
+ printf("ERROR: Cannot open config file: %s\nExiting...\n", ConfigFileName.c_str());
+ this->Logs->Log("STARTUP",DEFAULT,"Unable to open config file %s", ConfigFileName.c_str());
Exit(EXIT_STATUS_CONFIG);
}
}
diff --git a/src/server.cpp b/src/server.cpp
index 45834db65..0c0eda6ac 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -50,7 +50,7 @@ void InspIRCd::Exit(int status)
void RehashHandler::Call(const std::string &reason)
{
- Server->SNO->WriteToSnoMask('a', "Rehashing config file %s %s",ServerConfig::CleanFilename(Server->ConfigFileName), reason.c_str());
+ Server->SNO->WriteToSnoMask('a', "Rehashing config file %s %s",ServerConfig::CleanFilename(Server->ConfigFileName.c_str()), reason.c_str());
Server->RehashUsersAndChans();
FOREACH_MOD_I(Server, I_OnGarbageCollect, OnGarbageCollect());
if (!Server->ConfigThread)