[prev in list] [next in list] [prev in thread] [next in thread]
List: wine-patches
Subject: KERNEL: improve stubs for DnsHostnameToComputerName{A,W}
From: Hans Leidekker <hans () it ! vu ! nl>
Date: 2005-03-30 11:36:21
Message-ID: 200503301336.21332.hans () it ! vu ! nl
[Download RAW message or body]
Now without the toupper() calls as suggested by Alexandre.
----
This should help with apps that don't check the return value
and/or GetLastError() after calling this function. In many
cases the computername will match the hostname anyway.
-Hans
Changelog:
Return a computername constructed from the hostname.
["kernel_computername_c.diff" (text/x-diff)]
Index: dlls/kernel/computername.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/computername.c,v
retrieving revision 1.11
diff -u -p -r1.11 computername.c
--- dlls/kernel/computername.c 6 Dec 2004 11:38:25 -0000 1.11
+++ dlls/kernel/computername.c 30 Mar 2005 11:32:08 -0000
@@ -683,23 +683,58 @@ BOOL WINAPI SetComputerNameExA( COMPUTER
/***********************************************************************
* DnsHostnameToComputerNameA (KERNEL32.@)
*/
-BOOL WINAPI DnsHostnameToComputerNameA(LPCSTR Hostname, LPSTR ComputerName,
- LPDWORD nSize)
+BOOL WINAPI DnsHostnameToComputerNameA(LPCSTR hostname,
+ LPSTR computername, LPDWORD size)
{
- FIXME("(%s, %s, %08lx): stub\n", debugstr_a(Hostname),
- debugstr_a(ComputerName), *nSize);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ DWORD len;
+
+ FIXME("(%s, %s, %p): stub\n", debugstr_a(hostname),
+ debugstr_a(computername), size);
+
+ if (!hostname || !size) return FALSE;
+ len = lstrlenW(hostname);
+
+ if (len > MAX_COMPUTERNAME_LENGTH)
+ len = MAX_COMPUTERNAME_LENGTH;
+
+ if (*size < len)
+ {
+ *size = len;
+ return FALSE;
+ }
+ if (!computername) return FALSE;
+
+ memcpy( computername, hostname, len );
+ computername[len + 1] = 0;
+ return TRUE;
}
/***********************************************************************
* DnsHostnameToComputerNameW (KERNEL32.@)
*/
-BOOL WINAPI DnsHostnameToComputerNameW(LPCWSTR Hostname, LPWSTR ComputerName,
- LPDWORD nSize)
+BOOL WINAPI DnsHostnameToComputerNameW(LPCWSTR hostname,
+ LPWSTR computername, LPDWORD size)
{
- FIXME("(%s, %s, %08lx): stub\n", debugstr_w(Hostname),
- debugstr_w(ComputerName), *nSize);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ int i;
+ DWORD len;
+
+ FIXME("(%s, %s, %p): stub\n", debugstr_w(hostname),
+ debugstr_w(computername), size);
+
+ if (!hostname || !size) return FALSE;
+ len = lstrlenW(hostname);
+
+ if (len > MAX_COMPUTERNAME_LENGTH)
+ len = MAX_COMPUTERNAME_LENGTH;
+
+ if (*size < len)
+ {
+ *size = len;
+ return FALSE;
+ }
+ if (!computername) return FALSE;
+
+ memcpy( computername, hostname, len * sizeof(WCHAR) );
+ computername[len + 1] = 0;
+ return TRUE;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic