diff --git a/src/dll/fuse/fuse_opt.c b/src/dll/fuse/fuse_opt.c index c65c914d..2940e185 100644 --- a/src/dll/fuse/fuse_opt.c +++ b/src/dll/fuse/fuse_opt.c @@ -107,7 +107,7 @@ static void fsp_fuse_opt_match_templ( if ('%' == *p || '\0' == *p) *pspec = p, *parg = q; else - *parg = 0 == lstrcmpA(q, p) ? + *parg = 0 == invariant_strcmp(q, p) ? fsp_fuse_opt_match_exact : fsp_fuse_opt_match_none; } else diff --git a/src/dll/np.c b/src/dll/np.c index 831ae580..bfaae0bf 100644 --- a/src/dll/np.c +++ b/src/dll/np.c @@ -252,7 +252,7 @@ static WCHAR FspNpGetDriveLetter(PDWORD PLogicalDrives, PWSTR VolumeName) LocalNameBuf[0] = Drive; if (QueryDosDeviceW(LocalNameBuf, VolumeNameBuf, sizeof VolumeNameBuf / sizeof(WCHAR))) { - if (0 == lstrcmpW(VolumeNameBuf, VolumeName)) + if (0 == invariant_wcscmp(VolumeNameBuf, VolumeName)) { *PLogicalDrives &= ~(1 << (Drive - 'A')); return Drive; @@ -432,7 +432,7 @@ DWORD APIENTRY NPGetConnection( { if (L'\0' == *P) { - if (0 == lstrcmpW(VolumeNameBuf, VolumeName)) + if (0 == invariant_wcscmp(VolumeNameBuf, VolumeName)) { /* * Looks like this is a WinFsp device. Extract the VolumePrefix from the VolumeName. @@ -604,7 +604,7 @@ DWORD APIENTRY NPAddConnection(LPNETRESOURCEW lpNetResource, LPWSTR lpPassword, RemoteNameSize = sizeof RemoteNameBuf / sizeof(WCHAR); NpResult = NPGetConnection(LocalNameBuf, RemoteNameBuf, &RemoteNameSize); if (WN_SUCCESS == NpResult) - NpResult = 0 == lstrcmpW(ExpectRemoteNameBuf, RemoteNameBuf) ? WN_SUCCESS : WN_NO_NETWORK; + NpResult = 0 == invariant_wcscmp(ExpectRemoteNameBuf, RemoteNameBuf) ? WN_SUCCESS : WN_NO_NETWORK; else NpResult = WN_NO_NETWORK; } @@ -1036,9 +1036,7 @@ NTSTATUS FspNpRegister(VOID) { if (L',' == *P || '\0' == *P) { - if (CSTR_EQUAL == CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, - Part, (int)(P - Part), - L"" FSP_NP_NAME, (int)(sizeof L"" FSP_NP_NAME - sizeof(WCHAR)) / sizeof(WCHAR))) + if (0 == invariant_wcsncmp(Part, L"" FSP_NP_NAME, P - Part)) { FoundProvider = TRUE; break; @@ -1099,9 +1097,7 @@ NTSTATUS FspNpUnregister(VOID) { if (L',' == *P || '\0' == *P) { - if (CSTR_EQUAL == CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, - Part, (int)(P - Part), - L"" FSP_NP_NAME, (int)(sizeof L"" FSP_NP_NAME - sizeof(WCHAR)) / sizeof(WCHAR))) + if (0 == invariant_wcsncmp(Part, L"" FSP_NP_NAME, P - Part)) { FoundProvider = TRUE; break; diff --git a/src/launcher/launchctl.c b/src/launcher/launchctl.c index ad74375a..6e4c5d71 100644 --- a/src/launcher/launchctl.c +++ b/src/launcher/launchctl.c @@ -227,7 +227,7 @@ int wmain(int argc, wchar_t **argv) if (0 == argc) usage(); - if (0 == lstrcmpW(L"start", argv[0])) + if (0 == invariant_wcscmp(L"start", argv[0])) { if (3 > argc || argc > 12) usage(); @@ -236,7 +236,7 @@ int wmain(int argc, wchar_t **argv) FALSE); } else - if (0 == lstrcmpW(L"startWithSecret", argv[0])) + if (0 == invariant_wcscmp(L"startWithSecret", argv[0])) { if (4 > argc || argc > 13) usage(); @@ -245,7 +245,7 @@ int wmain(int argc, wchar_t **argv) TRUE); } else - if (0 == lstrcmpW(L"stop", argv[0])) + if (0 == invariant_wcscmp(L"stop", argv[0])) { if (3 != argc) usage(); @@ -253,7 +253,7 @@ int wmain(int argc, wchar_t **argv) return stop(PipeBuf, LAUNCHER_PIPE_BUFFER_SIZE, argv[1], argv[2]); } else - if (0 == lstrcmpW(L"info", argv[0])) + if (0 == invariant_wcscmp(L"info", argv[0])) { if (3 != argc) usage(); @@ -261,7 +261,7 @@ int wmain(int argc, wchar_t **argv) return getinfo(PipeBuf, LAUNCHER_PIPE_BUFFER_SIZE, argv[1], argv[2]); } else - if (0 == lstrcmpW(L"list", argv[0])) + if (0 == invariant_wcscmp(L"list", argv[0])) { if (1 != argc) usage(); @@ -269,7 +269,7 @@ int wmain(int argc, wchar_t **argv) return list(PipeBuf, LAUNCHER_PIPE_BUFFER_SIZE); } else - if (0 == lstrcmpW(L"quit", argv[0])) + if (0 == invariant_wcscmp(L"quit", argv[0])) { if (1 != argc) usage(); diff --git a/src/launcher/launcher.c b/src/launcher/launcher.c index 6de0c4d3..90463797 100644 --- a/src/launcher/launcher.c +++ b/src/launcher/launcher.c @@ -157,8 +157,8 @@ static SVC_INSTANCE *SvcInstanceLookup(PWSTR ClassName, PWSTR InstanceName) { SvcInstance = CONTAINING_RECORD(ListEntry, SVC_INSTANCE, ListEntry); - if (0 == lstrcmpiW(ClassName, SvcInstance->ClassName) && - 0 == lstrcmpiW(InstanceName, SvcInstance->InstanceName)) + if (0 == invariant_wcsicmp(ClassName, SvcInstance->ClassName) && + 0 == invariant_wcsicmp(InstanceName, SvcInstance->InstanceName)) return SvcInstance; } diff --git a/src/shared/minimal.h b/src/shared/minimal.h index a0fddd52..03210906 100644 --- a/src/shared/minimal.h +++ b/src/shared/minimal.h @@ -87,6 +87,41 @@ void *memmove(void *dst, const void *src, size_t siz) return dst; } +#define WINFSP_SHARED_MINIMAL_STRCMP(NAME, TYPE, CONV)\ + static inline\ + int NAME(const TYPE *s, const TYPE *t)\ + {\ + int v = 0;\ + while (0 == (v = CONV(*s) - CONV(*t)) && *t)\ + ++s, ++t;\ + return v;/*(0 < v) - (0 > v);*/\ + } +#define WINFSP_SHARED_MINIMAL_STRNCMP(NAME, TYPE, CONV)\ + static inline\ + int NAME(const TYPE *s, const TYPE *t, size_t n)\ + {\ + int v = 0;\ + const void *e = t + n;\ + while (e > (const void *)t && 0 == (v = CONV(*s) - CONV(*t)) && *t)\ + ++s, ++t;\ + return v;/*(0 < v) - (0 > v);*/\ + } +static inline +unsigned invariant_toupper(unsigned c) +{ + return ('a' <= c && c <= 'z') ? c & ~0x20 : c; +} +WINFSP_SHARED_MINIMAL_STRCMP(invariant_strcmp, char, (unsigned)) +WINFSP_SHARED_MINIMAL_STRCMP(invariant_stricmp, char, invariant_toupper) +WINFSP_SHARED_MINIMAL_STRNCMP(invariant_strncmp, char, (unsigned)) +WINFSP_SHARED_MINIMAL_STRNCMP(invariant_strnicmp, char, invariant_toupper) +WINFSP_SHARED_MINIMAL_STRCMP(invariant_wcscmp, wchar_t, (unsigned)) +WINFSP_SHARED_MINIMAL_STRCMP(invariant_wcsicmp, wchar_t, invariant_toupper) +WINFSP_SHARED_MINIMAL_STRNCMP(invariant_wcsncmp, wchar_t, (unsigned)) +WINFSP_SHARED_MINIMAL_STRNCMP(invariant_wcsnicmp, wchar_t, invariant_toupper) +#undef WINFSP_SHARED_MINIMAL_STRCMP +#undef WINFSP_SHARED_MINIMAL_STRNCMP + static inline void *MemAlloc(size_t Size) { return HeapAlloc(GetProcessHeap(), 0, Size);