diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-13 01:44:22 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-13 01:44:22 +0000 |
commit | d1ddbd62f91d4b9453447b5d25f5e41e807b0010 (patch) | |
tree | 89ee0a02bab93e38f35195d236e13f3e22906932 /src | |
parent | 547e7e9b382255b1699ff897f40fb4ed659c3360 (diff) |
Change to new execution directory structure
Don't change CWD into bin/
Remove path-resolution hacks from configuration
Store pidfile and xline DBs in data, logs in logs.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11866 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/configreader.cpp | 89 | ||||
-rw-r--r-- | src/helperfuncs.cpp | 16 | ||||
-rw-r--r-- | src/inspircd.cpp | 16 | ||||
-rw-r--r-- | src/modules/m_xline_db.cpp | 6 |
4 files changed, 14 insertions, 113 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp index 540653567..70c99e8ae 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -1661,32 +1661,12 @@ bool ServerConfig::StartsWithWindowsDriveLetter(const std::string &path) bool ServerConfig::DoInclude(const std::string &file, bool allowexeinc) { - std::string confpath; - std::string newfile; - std::string::size_type pos; - - confpath = ServerInstance->ConfigFileName; - newfile = file; - - std::replace(newfile.begin(),newfile.end(),'\\','/'); - std::replace(confpath.begin(),confpath.end(),'\\','/'); - - if ((newfile[0] != '/') && (!StartsWithWindowsDriveLetter(newfile))) - { - pos = confpath.rfind("/"); - if(pos != std::string::npos) - { - /* Leaves us with just the path */ - newfile = confpath.substr(0, pos) + std::string("/") + newfile; - } - } - - FILE* conf = fopen(newfile.c_str(), "r"); + FILE* conf = fopen(file.c_str(), "r"); bool ret = false; if (conf) { - ret = LoadConf(conf, newfile, allowexeinc); + ret = LoadConf(conf, file, allowexeinc); fclose(conf); } else @@ -1889,29 +1869,9 @@ bool ServerConfig::ReadFile(file_cache &F, const char* fname) F.clear(); - if ((*fname != '/') && (*fname != '\\') && (!StartsWithWindowsDriveLetter(fname))) - { - std::string::size_type pos; - std::string confpath = ServerInstance->ConfigFileName; - std::string newfile = fname; - - if (((pos = confpath.rfind("/"))) != std::string::npos) - newfile = confpath.substr(0, pos) + std::string("/") + fname; - else if (((pos = confpath.rfind("\\"))) != std::string::npos) - newfile = confpath.substr(0, pos) + std::string("\\") + fname; - - ServerInstance->Logs->Log("config", DEBUG, "Filename: %s", newfile.c_str()); - - if (!FileExists(newfile.c_str())) - return false; - file = fopen(newfile.c_str(), "r"); - } - else - { - if (!FileExists(fname)) - return false; - file = fopen(fname, "r"); - } + if (!FileExists(fname)) + return false; + file = fopen(fname, "r"); if (file) { @@ -1942,8 +1902,8 @@ bool ServerConfig::FileExists(const char* file) if ((sb.st_mode & S_IFDIR) > 0) return false; - FILE *input; - if ((input = fopen (file, "r")) == NULL) + FILE *input = fopen(file, "r"); + if (input == NULL) return false; else { @@ -1960,41 +1920,6 @@ const char* ServerConfig::CleanFilename(const char* name) } -std::string ServerConfig::GetFullProgDir() -{ - char buffer[PATH_MAX]; -#ifdef WINDOWS - /* Windows has specific api calls to get the exe path that never fail. - * For once, windows has something of use, compared to the POSIX code - * for this, this is positively neato. - */ - if (GetModuleFileName(NULL, buffer, MAX_PATH)) - { - std::string fullpath = buffer; - std::string::size_type n = fullpath.rfind("\\inspircd.exe"); - return std::string(fullpath, 0, n); - } -#else - // Get the current working directory - if (getcwd(buffer, PATH_MAX)) - { - std::string remainder = this->argv[0]; - - /* Does argv[0] start with /? its a full path, use it */ - if (remainder[0] == '/') - { - std::string::size_type n = remainder.rfind("/inspircd"); - return std::string(remainder, 0, n); - } - - std::string fullpath = std::string(buffer) + "/" + remainder; - std::string::size_type n = fullpath.rfind("/inspircd"); - return std::string(fullpath, 0, n); - } -#endif - return "/"; -} - std::string ServerConfig::GetSID() { return sid; diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 6c2ceabb2..cd173b55f 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -281,20 +281,6 @@ bool InspIRCd::OpenLog(char**, int) { this->Logs->SetupNoFork(); } - Config->MyDir = Config->GetFullProgDir(); - - /* Attempt to find home directory, portable to windows */ - const char* home = getenv("HOME"); - if (!home) - { - /* No $HOME, log to %USERPROFILE% */ - home = getenv("USERPROFILE"); - if (!home) - { - /* Nothing could be found at all, log to current dir */ - Config->logpath = "./startup.log"; - } - } if (!Config->writelog) return true; // Skip opening default log if -nolog @@ -302,7 +288,7 @@ bool InspIRCd::OpenLog(char**, int) { if (Config->logpath.empty()) { - Config->logpath = "./startup.log"; + Config->logpath = "logs/startup.log"; } if (!Config->log_file) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index a932b95e1..4956cfa8c 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -286,18 +286,9 @@ bool InspIRCd::DaemonSeed() void InspIRCd::WritePID(const std::string &filename) { - std::string fname = (filename.empty() ? "inspircd.pid" : filename); - std::replace(fname.begin(), fname.end(), '\\', '/'); - if ((fname[0] != '/') && (!Config->StartsWithWindowsDriveLetter(filename))) - { - std::string::size_type pos; - std::string confpath = this->ConfigFileName; - if ((pos = confpath.rfind("/")) != std::string::npos) - { - /* Leaves us with just the path */ - fname = confpath.substr(0, pos) + std::string("/") + fname; - } - } + std::string fname(filename); + if (fname.empty()) + fname = "data/inspircd.pid"; std::ofstream outfile(fname.c_str()); if (outfile.is_open()) { @@ -470,7 +461,6 @@ InspIRCd::InspIRCd(int argc, char** argv) : WSAStartup(MAKEWORD(2,0), &wsadata); ChangeWindowsSpecificPointers(); #endif - Config->MyExecutable = argv[0]; /* Set the finished argument values */ Config->nofork = do_nofork; diff --git a/src/modules/m_xline_db.cpp b/src/modules/m_xline_db.cpp index 329fc8e27..c4225d439 100644 --- a/src/modules/m_xline_db.cpp +++ b/src/modules/m_xline_db.cpp @@ -92,7 +92,7 @@ class ModuleXLineDB : public Module * -- w00t */ ServerInstance->Logs->Log("m_xline_db",DEBUG, "xlinedb: Opening temporary database"); - f = fopen("xline.db.new", "w"); + f = fopen("data/xline.db.new", "w"); if (!f) { ServerInstance->Logs->Log("m_xline_db",DEBUG, "xlinedb: Cannot create database! %s (%d)", strerror(errno), errno); @@ -133,7 +133,7 @@ class ModuleXLineDB : public Module } // Use rename to move temporary to new db - this is guarenteed not to fuck up, even in case of a crash. - if (rename("xline.db.new", "xline.db") < 0) + if (rename("data/xline.db.new", "data/xline.db") < 0) { ServerInstance->Logs->Log("m_xline_db",DEBUG, "xlinedb: Cannot move new to old database! %s (%d)", strerror(errno), errno); ServerInstance->SNO->WriteToSnoMask('a', "database: cannot replace old with new db: %s (%d)", strerror(errno), errno); @@ -149,7 +149,7 @@ class ModuleXLineDB : public Module char linebuf[MAXBUF]; unsigned int lineno = 0; - f = fopen("xline.db", "r"); + f = fopen("data/xline.db", "r"); if (!f) { if (errno == ENOENT) |