mirror of
https://github.com/reactos/reactos.git
synced 2025-05-25 12:14:32 +00:00
- Revert the change from REG_SZ to REG_MULTI_SZ because it turns out that Windows does it this same way (research fail?)
svn path=/trunk/; revision=48611
This commit is contained in:
parent
2ddee30677
commit
0ea1a11d0d
2 changed files with 42 additions and 20 deletions
|
@ -507,25 +507,24 @@ void set_name_servers( PDHCP_ADAPTER Adapter, struct client_lease *new_lease ) {
|
|||
char *nsbuf;
|
||||
int i, addrs =
|
||||
new_lease->options[DHO_DOMAIN_NAME_SERVERS].len / sizeof(ULONG);
|
||||
int len = 0;
|
||||
|
||||
nsbuf = malloc( addrs * sizeof(IP_ADDRESS_STRING) + 1 );
|
||||
nsbuf = malloc( addrs * sizeof(IP_ADDRESS_STRING) );
|
||||
|
||||
if( nsbuf) {
|
||||
memset(nsbuf, 0, addrs * sizeof(IP_ADDRESS_STRING) + 1);
|
||||
nsbuf[0] = 0;
|
||||
for( i = 0; i < addrs; i++ ) {
|
||||
nameserver.len = sizeof(ULONG);
|
||||
memcpy( nameserver.iabuf,
|
||||
new_lease->options[DHO_DOMAIN_NAME_SERVERS].data +
|
||||
(i * sizeof(ULONG)), sizeof(ULONG) );
|
||||
strcat( nsbuf, piaddr(nameserver) );
|
||||
len += strlen(nsbuf) + 1;
|
||||
if( i != addrs-1 ) strcat( nsbuf, "," );
|
||||
}
|
||||
|
||||
DH_DbgPrint(MID_TRACE,("Setting DhcpNameserver: %s\n", nsbuf));
|
||||
|
||||
RegSetValueExA( RegKey, "DhcpNameServer", 0, REG_MULTI_SZ,
|
||||
(LPBYTE)nsbuf, len + 1 );
|
||||
RegSetValueExA( RegKey, "DhcpNameServer", 0, REG_SZ,
|
||||
(LPBYTE)nsbuf, strlen(nsbuf) + 1 );
|
||||
free( nsbuf );
|
||||
}
|
||||
|
||||
|
|
|
@ -122,24 +122,47 @@ static void EnumInterfaces( PVOID Data, EnumInterfacesFunc cb ) {
|
|||
|
||||
void EnumNameServers( HANDLE RegHandle, PWCHAR Interface,
|
||||
PVOID Data, EnumNameServersFunc cb ) {
|
||||
PWCHAR *NameServerString =
|
||||
QueryRegistryValueStringMulti(RegHandle, L"DhcpNameServer");
|
||||
DWORD i;
|
||||
PWCHAR NameServerString =
|
||||
QueryRegistryValueString(RegHandle, L"DhcpNameServer");
|
||||
|
||||
if (!NameServerString)
|
||||
NameServerString = QueryRegistryValueStringMulti(RegHandle, L"NameServer");
|
||||
NameServerString = QueryRegistryValueString(RegHandle, L"NameServer");
|
||||
|
||||
if (!NameServerString) return;
|
||||
|
||||
for (i = 0; NameServerString[i]; i++)
|
||||
{
|
||||
cb(Interface, NameServerString[i], Data);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, NameServerString[i]);
|
||||
if (NameServerString) {
|
||||
/* Now, count the non-empty comma separated */
|
||||
DWORD ch;
|
||||
DWORD LastNameStart = 0;
|
||||
for (ch = 0; NameServerString[ch]; ch++) {
|
||||
if (NameServerString[ch] == ',') {
|
||||
if (ch - LastNameStart > 0) { /* Skip empty entries */
|
||||
PWCHAR NameServer =
|
||||
malloc(((ch - LastNameStart) + 1) * sizeof(WCHAR));
|
||||
if (NameServer) {
|
||||
memcpy(NameServer,NameServerString + LastNameStart,
|
||||
(ch - LastNameStart) * sizeof(WCHAR));
|
||||
NameServer[ch - LastNameStart] = 0;
|
||||
cb( Interface, NameServer, Data );
|
||||
free(NameServer);
|
||||
LastNameStart = ch +1;
|
||||
}
|
||||
}
|
||||
LastNameStart = ch + 1; /* The first one after the comma */
|
||||
}
|
||||
}
|
||||
if (ch - LastNameStart > 0) { /* A last name? */
|
||||
PWCHAR NameServer = malloc(((ch - LastNameStart) + 1) * sizeof(WCHAR));
|
||||
if (NameServer) {
|
||||
memcpy(NameServer,NameServerString + LastNameStart,
|
||||
(ch - LastNameStart) * sizeof(WCHAR));
|
||||
NameServer[ch - LastNameStart] = 0;
|
||||
cb( Interface, NameServer, Data );
|
||||
free(NameServer);
|
||||
}
|
||||
}
|
||||
ConsumeRegValueString(NameServerString);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, NameServerString);
|
||||
}
|
||||
|
||||
static void CreateNameServerListEnumNamesFuncCount( PWCHAR Interface,
|
||||
PWCHAR Server,
|
||||
PVOID _Data ) {
|
||||
|
|
Loading…
Reference in a new issue