our($pid,$pidfile);
# Lets see what they want to do.. Set the variable (Cause i'm a lazy coder)
my $arg = shift(@ARGV);
-my $conf = $confpath . "inspircd.conf";
+my $conf;
for my $a (@ARGV)
{
if ($a =~ m/^--config=(.*)$/)
last;
}
}
+if (!defined $conf) {
+ $conf = $confpath . "inspircd.conf";
+ push @ARGV, '--config='.$conf;
+}
+
getpidfile($conf);
# System for naming script command subs:
#define CoreExport /**/
#define DllExport /**/
-#define CONFIG_FILE "$config{CONFIG_DIR}/inspircd.conf"
#define MOD_PATH "$config{MODULE_DIR}"
#define SOMAXCONN_S "$config{_SOMAXCONN}"
#define ENTRYPOINT int main(int argc, char** argv)
* @param name Directory to tidy
* @return The cleaned filename
*/
- static char* CleanFilename(char* name);
+ static const char* CleanFilename(const char* name);
/** Check if a file exists.
* @param file The full path to a file
/** Config file pathname specified on the commandline or via ./configure
*/
- char ConfigFileName[MAXBUF];
+ std::string ConfigFileName;
/** Mode handler, handles mode setting and removal
*/
// 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.
}
}
-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);
}
HandleIsChannel(this),
HandleIsSID(this),
HandleRehash(this),
+ ConfigFileName("inspircd.conf"),
/* Functor pointer initialisation. Must match the order of the list above
*
srand(this->TIME);
*this->LogFileName = 0;
- strlcpy(this->ConfigFileName, CONFIG_FILE, MAXBUF);
struct option longopts[] =
{
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 */
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. */
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);
}
}
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)