Hans Leidekker : netapi32: Perform a case-insensitive string comparison in NETAPI_IsLocalComputer.

Alexandre Julliard julliard at winehq.org
Tue Nov 12 14:26:36 CST 2013


Module: wine
Branch: master
Commit: 65d12829b61227df3f4b26dff04ee00c41bd1f29
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=65d12829b61227df3f4b26dff04ee00c41bd1f29

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Tue Nov 12 10:03:54 2013 +0100

netapi32: Perform a case-insensitive string comparison in NETAPI_IsLocalComputer.

---

 dlls/netapi32/netapi32.c |   49 ++++++++++++++++-----------------------------
 1 files changed, 18 insertions(+), 31 deletions(-)

diff --git a/dlls/netapi32/netapi32.c b/dlls/netapi32/netapi32.c
index 57bc58b..313d1ac 100644
--- a/dlls/netapi32/netapi32.c
+++ b/dlls/netapi32/netapi32.c
@@ -50,10 +50,27 @@
 #include "dsgetdc.h"
 #include "wine/debug.h"
 #include "wine/list.h"
+#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
 
-BOOL NETAPI_IsLocalComputer(LMCSTR ServerName);
+/************************************************************
+ *                NETAPI_IsLocalComputer
+ *
+ * Checks whether the server name indicates local machine.
+ */
+static BOOL NETAPI_IsLocalComputer( LMCSTR name )
+{
+    WCHAR buf[MAX_COMPUTERNAME_LENGTH + 1];
+    DWORD size = sizeof(buf) / sizeof(buf[0]);
+    BOOL ret;
+
+    if (!name || !name[0]) return TRUE;
+
+    ret = GetComputerNameW( buf,  &size );
+    if (ret && name[0] == '\\' && name[1] == '\\') name += 2;
+    return ret && !strcmpiW( name, buf );
+}
 
 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 {
@@ -411,36 +428,6 @@ NET_API_STATUS WINAPI NetFileEnum(
     return ERROR_NOT_SUPPORTED;
 }
 
-/************************************************************
- *                NETAPI_IsLocalComputer
- *
- * Checks whether the server name indicates local machine.
- */
-DECLSPEC_HIDDEN BOOL NETAPI_IsLocalComputer(LMCSTR ServerName)
-{
-    if (!ServerName)
-    {
-        return TRUE;
-    }
-    else if (ServerName[0] == '\0')
-        return TRUE;
-    else
-    {
-        DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
-        BOOL Result;
-        LPWSTR buf;
-
-        NetApiBufferAllocate(dwSize * sizeof(WCHAR), (LPVOID *) &buf);
-        Result = GetComputerNameW(buf,  &dwSize);
-        if (Result && (ServerName[0] == '\\') && (ServerName[1] == '\\'))
-            ServerName += 2;
-        Result = Result && !lstrcmpW(ServerName, buf);
-        NetApiBufferFree(buf);
-
-        return Result;
-    }
-}
-
 static void wprint_mac(WCHAR* buffer, int len, const MIB_IFROW *ifRow)
 {
     int i;




More information about the wine-cvs mailing list