Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Humblet <phumblet@phumblet.no-ip.org>2003-06-19 04:57:26 +0400
committerPierre Humblet <phumblet@phumblet.no-ip.org>2003-06-19 04:57:26 +0400
commitc9a5cfa0d3b7cb05aef7e034352c3b8675a52bff (patch)
tree6459772dbd408b6ab1fedec038bd77dfcc72800a /winsup/cygwin
parent2302957c535e3507b5c8920ab93c3dea7bf82f4a (diff)
2003-06-18 Pierre Humblet <pierre.humblet@ieee.org>
* autoload.cc (GetNetworkParams): Add. * net.cc (getdomainname): Call GetNetworkParams and read the DhcpDomain registry value if warranted.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/autoload.cc1
-rw-r--r--winsup/cygwin/net.cc31
3 files changed, 32 insertions, 6 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index e1706ec4a..8948d5429 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+2003-06-18 Pierre Humblet <pierre.humblet@ieee.org>
+
+ * autoload.cc (GetNetworkParams): Add.
+ * net.cc (getdomainname): Call GetNetworkParams and read the
+ DhcpDomain registry value if warranted.
+
2003-06-17 Christopher Faylor <cgf@redhat.com>
* path.cc (mount): Do more strict checking on posix path arguments.
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index 71e7f9ead..f5cc250fa 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -492,6 +492,7 @@ LoadDLLfuncEx (WSAEnumNetworkEvents, 12, ws2_32, 1)
LoadDLLfuncEx (GetIfTable, 12, iphlpapi, 1)
LoadDLLfuncEx (GetIfEntry, 4, iphlpapi, 1)
LoadDLLfuncEx (GetIpAddrTable, 12, iphlpapi, 1)
+LoadDLLfuncEx (GetNetworkParams, 8, iphlpapi, 1)
LoadDLLfunc (CoInitialize, 4, ole32)
LoadDLLfunc (CoUninitialize, 0, ole32)
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index c5a2a3ec4..ffa4c5100 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -1291,20 +1291,39 @@ getdomainname (char *domain, size_t len)
if (__check_null_invalid_struct_errno (domain, len))
return -1;
+ PFIXED_INFO info = NULL;
+ ULONG size = 0;
+
+ if (GetNetworkParams(info, &size) == ERROR_BUFFER_OVERFLOW
+ && (info = (PFIXED_INFO) alloca(size))
+ && GetNetworkParams(info, &size) == ERROR_SUCCESS)
+ {
+ strncpy(domain, info->DomainName, len);
+ return 0;
+ }
+
+ /* This is only used by Win95 and NT <= 4.0.
+ The registry names are language independent.
+ FIXME: Handle DHCP on Win95. The DhcpDomain(s) may be available
+ in ..VxD\DHCP\DhcpInfoXX\OptionInfo, RFC 1533 format */
+
reg_key r (HKEY_LOCAL_MACHINE, KEY_READ,
(!wincap.is_winnt ()) ? "System" : "SYSTEM",
"CurrentControlSet", "Services",
(!wincap.is_winnt ()) ? "VxD" : "Tcpip",
(!wincap.is_winnt ()) ? "MSTCP" : "Parameters", NULL);
- /* FIXME: Are registry keys case sensitive? */
- if (r.error () || r.get_string ("Domain", domain, len, "") != ERROR_SUCCESS)
+ if (!r.error ())
{
- __seterrno ();
- return -1;
+ int res1, res2 = 0; /* Suppress compiler warning */
+ res1 = r.get_string ("Domain", domain, len, "");
+ if (res1 != ERROR_SUCCESS || !domain[0])
+ res2 = r.get_string ("DhcpDomain", domain, len, "");
+ if (res1 == ERROR_SUCCESS || res2 == ERROR_SUCCESS)
+ return 0;
}
-
- return 0;
+ __seterrno ();
+ return -1;
}
/* Fill out an ifconf struct. */