]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/configreader.cpp
Change for reverse output of lists, most recent first, for bug #307. Also fix(Oms...
[user/henk/code/inspircd.git] / src / configreader.cpp
index 392c7eb297a68b156c6f0d02b642800eb29c93fc..5ec60d1c31beb187cfe0474b0a9bba5226259e8a 100644 (file)
  * ---------------------------------------------------
  */
 
+#include "inspircd.h"
 #include "configreader.h"
 #include <sstream>
 #include <fstream>
-#include "inspircd.h"
 #include "xline.h"
 #include "exitcodes.h"
 #include "commands/cmd_whowas.h"
@@ -221,10 +221,16 @@ bool ValidateDnsServer(ServerConfig* conf, const char* tag, const char* value, V
 {
        if (!*(data.GetString()))
        {
+               std::string nameserver;
+#ifdef WINDOWS
+               conf->GetInstance()->Log(DEFAULT,"WARNING: <dns:server> not defined, attempting to find working server in the registry...");
+               nameserver = FindNameServerWin();
+               data.Set(nameserver.c_str());
+               conf->GetInstance()->Log(DEFAULT,"<dns:server> set to '%s' as first active resolver in registry.", nameserver.c_str());
+#else
                // attempt to look up their nameserver from /etc/resolv.conf
                conf->GetInstance()->Log(DEFAULT,"WARNING: <dns:server> not defined, attempting to find working server in /etc/resolv.conf...");
                ifstream resolv("/etc/resolv.conf");
-               std::string nameserver;
                bool found_server = false;
 
                if (resolv.is_open())
@@ -251,6 +257,7 @@ bool ValidateDnsServer(ServerConfig* conf, const char* tag, const char* value, V
                        conf->GetInstance()->Log(DEFAULT,"/etc/resolv.conf can't be opened! Defaulting to nameserver '127.0.0.1'!");
                        data.Set("127.0.0.1");
                }
+#endif
        }
        return true;
 }
@@ -1593,42 +1600,28 @@ bool ServerConfig::DirValid(const char* dirandfile)
        }
 }
 
-std::string ServerConfig::GetFullProgDir(char** argv, int argc)
+std::string ServerConfig::GetFullProgDir()
 {
-       char work[1024];
-       char buffer[1024];
-       char otherdir[1024];
-       int p;
+       char buffer[PATH_MAX+1];
 
-       strlcpy(work,argv[0],1024);
-       p = strlen(work);
-
-       // we just want the dir
-       while (*work)
+       // Get the current working directory
+       if (getcwd(buffer, PATH_MAX))
        {
-               if (work[p] == '/')
+               std::string remainder = this->argv[0];
+
+               /* Does argv[0] start with /? its a full path, use it */
+               if (remainder[0] == '/')
                {
-                       work[p] = '\0';
-                       break;
+                       std::string::size_type n = remainder.rfind("/inspircd");
+                       return std::string(remainder, 0, n);
                }
 
-               work[p--] = '\0';
+               std::string fullpath = std::string(buffer) + "/" + remainder;
+               std::string::size_type n = fullpath.rfind("/inspircd");
+               return std::string(fullpath, 0, n);
        }
 
-       // Get the current working directory
-       if (getcwd(buffer, 1024) == NULL)
-               return "";
-
-       if (chdir(work) == -1)
-               return "";
-
-       if (getcwd(otherdir, 1024) == NULL)
-               return "";
-
-       if (chdir(buffer) == -1)
-               return "";
-
-       return otherdir;
+       return "/";
 }
 
 InspIRCd* ServerConfig::GetInstance()