]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Move configuration filename specification to start script, to reduce hardcoded paths...
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 24 Sep 2009 01:44:29 +0000 (01:44 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 24 Sep 2009 01:44:29 +0000 (01:44 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11759 e03df62e-2008-0410-955e-edbf42e46eb7

.inspircd.inc
configure
include/configreader.h
include/inspircd.h
src/commands/cmd_rehash.cpp
src/configreader.cpp
src/inspircd.cpp
src/server.cpp

index 362bdcf67ffcbb2d20055ed9edce987513548d98..91a06ccfd6430f849f13abb93f05fcd5eb749851 100644 (file)
@@ -25,7 +25,7 @@ my $version   =       "@VERSION@";
 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=(.*)$/)
@@ -34,6 +34,11 @@ for my $a (@ARGV)
                last;
        }
 }
+if (!defined $conf) {
+       $conf = $confpath . "inspircd.conf";
+       push @ARGV, '--config='.$conf;
+}
+
 getpidfile($conf);
 
 # System for naming script command subs:
index 2fc19947969bb6145b0da700c9db16f808ac8d53..05c4a5e9bbd6e5c9004f8e789771f3ca9403a2c5 100755 (executable)
--- a/configure
+++ b/configure
@@ -928,7 +928,6 @@ sub writefiles {
 #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)
index 45384b8a324845849e31a0ad6a71b14d6e2e085a..783af0942e32229450c642c103ab6399690b074c 100644 (file)
@@ -698,7 +698,7 @@ class CoreExport ServerConfig : public classbase
         * @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
index 72e49c09ac493d3507e22374ed626ca8c729796a..4c3aba95b1cf49772219c1c090a44f34fe2c4a75 100644 (file)
@@ -432,7 +432,7 @@ class CoreExport InspIRCd : public classbase
 
        /** Config file pathname specified on the commandline or via ./configure
         */
-       char ConfigFileName[MAXBUF];
+       std::string ConfigFileName;
 
        /** Mode handler, handles mode setting and removal
         */
index a689801aa51d852cdcb7e4837052ff6816d9ce94..b2a9fbde47c34c2bb7d25a5e68a58aaae80aa8a7 100644 (file)
@@ -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.
index 5e1dd6969b4feb555a0a1898c2dc912aa7bc2880..159ca598fce99bb6f24c7a40015f624ef12c7beb 100644 (file)
@@ -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);
 }
index 704fec475b40a4d2560cdb3ec4180ef1cd99e4d4..f28324d16b2b20c970bc8e648c6d52da7f9ff039 100644 (file)
@@ -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);
                }
        }
index 45834db655d44e2e0f8b10a87db41fdf6070683b..0c0eda6acf9092466c344744970e8b7a7832ee19 100644 (file)
@@ -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)