[09/10] netapi32: Perform a case-insensitive string comparison in NETAPI_IsLocalComputer.
Hans Leidekker
hans at codeweavers.com
Tue Nov 12 03:03:54 CST 2013
---
dlls/netapi32/netapi32.c | 49 ++++++++++++++++++------------------------------
1 file 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;
--
1.8.1.5
More information about the wine-patches
mailing list