]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - win/inspircd_win32wrapper.cpp
- Fix two minor warnings here (catch (ModuleException& e) -> catch (ModuleException...
[user/henk/code/inspircd.git] / win / inspircd_win32wrapper.cpp
index dde2415aa0c6920ada772bb9fe11e99c6bad52f0..1cdd46444096c2b981a81fca4375328728fce334 100644 (file)
@@ -368,12 +368,15 @@ void CloseIPC()
 }\r
 \r
 \r
+/* These three functions were created from looking at how ares does it\r
+ * (...and they look far tidier in C++)\r
+ */\r
+\r
+/* Get active nameserver */\r
 bool GetNameServer(HKEY regkey, const char *key, char* &output)\r
 {\r
-       /* Test for the size we need */\r
        DWORD size = 0;\r
        DWORD result = RegQueryValueEx(regkey, key, 0, NULL, NULL, &size);\r
-\r
        if (((result != ERROR_SUCCESS) && (result != ERROR_MORE_DATA)) || (!size))\r
                return false;\r
 \r
@@ -387,6 +390,7 @@ bool GetNameServer(HKEY regkey, const char *key, char* &output)
        return true;\r
 }\r
 \r
+/* Check a network interface for its nameserver */\r
 bool GetInterface(HKEY regkey, const char *key, char* &output)\r
 {\r
        char buf[39];\r
@@ -414,8 +418,10 @@ std::string FindNameServerWin()
        HKEY top, key;\r
        char* dns = NULL;\r
 \r
+       /* Lets see if the correct registry hive and tree exist */\r
        if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Services\\Tcpip\\Parameters", 0, KEY_READ, &top) == ERROR_SUCCESS)\r
        {\r
+               /* If they do, attempt to get the nameserver name */\r
                RegOpenKeyEx(top, "Interfaces", 0, KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS, &key);\r
                if ((GetNameServer(top, "NameServer", dns)) || (GetNameServer(top, "DhcpNameServer", dns))\r
                        || (GetInterface(key, "NameServer", dns)) || (GetInterface(key, "DhcpNameServer", dns)))\r
@@ -431,3 +437,4 @@ std::string FindNameServerWin()
        }\r
        return returnval;\r
 }\r
+\r