diff options
author | Pierre Humblet <phumblet@phumblet.no-ip.org> | 2003-06-19 04:57:26 +0400 |
---|---|---|
committer | Pierre Humblet <phumblet@phumblet.no-ip.org> | 2003-06-19 04:57:26 +0400 |
commit | c9a5cfa0d3b7cb05aef7e034352c3b8675a52bff (patch) | |
tree | 6459772dbd408b6ab1fedec038bd77dfcc72800a /winsup/cygwin/net.cc | |
parent | 2302957c535e3507b5c8920ab93c3dea7bf82f4a (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/net.cc')
-rw-r--r-- | winsup/cygwin/net.cc | 31 |
1 files changed, 25 insertions, 6 deletions
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. */ |