Commit 7c0032b6 authored by Alexandre Julliard's avatar Alexandre Julliard

kernel32: Move some locale functions to kernelbase.

parent e3e1bede
......@@ -242,7 +242,7 @@
@ stdcall CompareStringA(long long str long str long)
@ stdcall CompareStringW(long long wstr long wstr long)
@ stdcall CompareStringEx(wstr long wstr long wstr long ptr ptr long)
@ stdcall CompareStringOrdinal(wstr long wstr long long)
@ stdcall -import CompareStringOrdinal(wstr long wstr long long)
@ stdcall -import ConnectNamedPipe(long ptr)
@ stub ConsoleMenuControl
@ stub ConsoleSubst
......@@ -508,7 +508,7 @@
@ stdcall FindResourceExA(long str str long)
@ stdcall -import FindResourceExW(long wstr wstr long)
@ stdcall -import FindResourceW(long wstr wstr)
@ stdcall FindStringOrdinal(long wstr long wstr long long)
@ stdcall -import FindStringOrdinal(long wstr long wstr long long)
@ stdcall FindVolumeClose(ptr)
@ stdcall FindVolumeMountPointClose(ptr)
@ stdcall -import FlsAlloc(ptr)
......@@ -818,10 +818,10 @@
@ stdcall GetStringTypeExW(long long wstr long ptr)
@ stdcall GetStringTypeW(long wstr long ptr)
@ stdcall GetSystemFileCacheSize(ptr ptr ptr)
@ stdcall GetSystemDefaultLCID()
@ stdcall GetSystemDefaultLangID()
@ stdcall GetSystemDefaultLocaleName(ptr long)
@ stdcall GetSystemDefaultUILanguage()
@ stdcall -import GetSystemDefaultLCID()
@ stdcall -import GetSystemDefaultLangID()
@ stdcall -import GetSystemDefaultLocaleName(ptr long)
@ stdcall -import GetSystemDefaultUILanguage()
@ stdcall GetSystemDEPPolicy()
@ stdcall GetSystemDirectoryA(ptr long)
@ stdcall GetSystemDirectoryW(ptr long)
......@@ -852,7 +852,7 @@
@ stdcall -import GetThreadIOPendingFlag(long ptr)
@ stdcall -import GetThreadId(ptr)
# @ stub GetThreadIdealProcessorEx
@ stdcall GetThreadLocale()
@ stdcall -import GetThreadLocale()
@ stdcall GetThreadPreferredUILanguages(long ptr ptr ptr)
@ stdcall -import GetThreadPriority(long)
@ stdcall -import GetThreadPriorityBoost(long ptr)
......@@ -869,10 +869,10 @@
# @ stub GetUILanguageInfo
@ stdcall -arch=x86_64 GetUmsCompletionListEvent(ptr ptr)
# @ stub -arch=x86_64 GetUmsSystemThreadInformation
@ stdcall GetUserDefaultLCID()
@ stdcall GetUserDefaultLangID()
@ stdcall GetUserDefaultLocaleName(ptr long)
@ stdcall GetUserDefaultUILanguage()
@ stdcall -import GetUserDefaultLCID()
@ stdcall -import GetUserDefaultLangID()
@ stdcall -import GetUserDefaultLocaleName(ptr long)
@ stdcall -import GetUserDefaultUILanguage()
@ stdcall GetUserGeoID(long)
@ stub GetVDMCurrentDirectories
@ stdcall -import GetVersion()
......@@ -1024,7 +1024,7 @@
@ stdcall K32QueryWorkingSetEx(long ptr long)
@ stdcall -i386 -private -norelay K32Thk1632Epilog() krnl386.exe16.K32Thk1632Epilog
@ stdcall -i386 -private -norelay K32Thk1632Prolog() krnl386.exe16.K32Thk1632Prolog
@ stdcall LCIDToLocaleName(long ptr long long)
@ stdcall -import LCIDToLocaleName(long ptr long long)
@ stdcall LCMapStringA(long long str long ptr long)
@ stdcall LCMapStringEx(wstr long wstr long ptr long ptr ptr long)
@ stdcall LCMapStringW(long long wstr long ptr long)
......@@ -1282,7 +1282,7 @@
@ stdcall -import ResetEvent(long)
@ stdcall -import ResetWriteWatch(ptr long)
@ stdcall ResolveDelayLoadedAPI(ptr ptr ptr ptr ptr long) ntdll.LdrResolveDelayLoadedAPI
@ stdcall ResolveLocaleName(wstr ptr long)
@ stdcall -import ResolveLocaleName(wstr ptr long)
@ stdcall RestoreLastError(long) ntdll.RtlRestoreLastWin32Error
@ stdcall -import ResumeThread(long)
@ cdecl -arch=arm,arm64,x86_64 RtlAddFunctionTable(ptr long long) ntdll.RtlAddFunctionTable
......@@ -1452,13 +1452,13 @@
@ stdcall -import SetThreadGroupAffinity(long ptr ptr)
@ stdcall -import SetThreadIdealProcessor(long long)
@ stdcall -import SetThreadIdealProcessorEx(long ptr ptr)
@ stdcall SetThreadLocale(long)
@ stdcall -import SetThreadLocale(long)
@ stdcall SetThreadPreferredUILanguages(long ptr ptr)
@ stdcall -import SetThreadPriority(long long)
@ stdcall -import SetThreadPriorityBoost(long long)
@ stdcall -import SetThreadStackGuarantee(ptr)
# @ stub SetThreadToken
@ stdcall SetThreadUILanguage(long)
@ stdcall -import SetThreadUILanguage(long)
# @ stub SetThreadpoolStackInformation
@ stdcall SetThreadpoolThreadMaximum(ptr long) ntdll.TpSetPoolMaxThreads
@ stdcall SetThreadpoolThreadMinimum(ptr long) ntdll.TpSetPoolMinThreads
......@@ -1550,8 +1550,8 @@
@ stub VDMOperationStarted
@ stub ValidateLCType
@ stub ValidateLocale
@ stdcall VerLanguageNameA(long str long)
@ stdcall VerLanguageNameW(long wstr long)
@ stdcall -import VerLanguageNameA(long str long)
@ stdcall -import VerLanguageNameW(long wstr long)
@ stdcall -ret64 VerSetConditionMask(long long long long) ntdll.VerSetConditionMask
@ stdcall VerifyConsoleIoHandle(long)
# @ stub VerifyScripts
......
......@@ -8,6 +8,7 @@ C_SRCS = \
debug.c \
file.c \
loader.c \
locale.c \
main.c \
memory.c \
path.c \
......
......@@ -155,7 +155,7 @@
# @ stub CompareObjectHandles
@ stdcall CompareStringA(long long str long str long) kernel32.CompareStringA
@ stdcall CompareStringEx(wstr long wstr long wstr long ptr ptr long) kernel32.CompareStringEx
@ stdcall CompareStringOrdinal(wstr long wstr long long) kernel32.CompareStringOrdinal
@ stdcall CompareStringOrdinal(wstr long wstr long long)
@ stdcall CompareStringW(long long wstr long wstr long) kernel32.CompareStringW
@ stdcall ConnectNamedPipe(long ptr)
@ stdcall ContinueDebugEvent(long long long)
......@@ -373,7 +373,7 @@
# @ stub FindPackagesByPackageFamily
@ stdcall FindResourceExW(long wstr wstr long)
@ stdcall FindResourceW(long wstr wstr)
@ stdcall FindStringOrdinal(long wstr long wstr long long) kernel32.FindStringOrdinal
@ stdcall FindStringOrdinal(long wstr long wstr long long)
@ stdcall FindVolumeClose(ptr) kernel32.FindVolumeClose
@ stdcall FlsAlloc(ptr)
@ stdcall FlsFree(long)
......@@ -681,10 +681,10 @@
# @ stub GetSystemAppDataFolder
# @ stub GetSystemAppDataKey
# @ stub GetSystemCpuSetInformation
@ stdcall GetSystemDefaultLCID() kernel32.GetSystemDefaultLCID
@ stdcall GetSystemDefaultLangID() kernel32.GetSystemDefaultLangID
@ stdcall GetSystemDefaultLocaleName(ptr long) kernel32.GetSystemDefaultLocaleName
@ stdcall GetSystemDefaultUILanguage() kernel32.GetSystemDefaultUILanguage
@ stdcall GetSystemDefaultLCID()
@ stdcall GetSystemDefaultLangID()
@ stdcall GetSystemDefaultLocaleName(ptr long)
@ stdcall GetSystemDefaultUILanguage()
@ stdcall GetSystemDirectoryA(ptr long)
@ stdcall GetSystemDirectoryW(ptr long)
@ stdcall GetSystemFileCacheSize(ptr ptr ptr) kernel32.GetSystemFileCacheSize
......@@ -719,7 +719,7 @@
@ stdcall GetThreadId(ptr)
# @ stub GetThreadIdealProcessorEx
# @ stub GetThreadInformation
@ stdcall GetThreadLocale() kernel32.GetThreadLocale
@ stdcall GetThreadLocale()
@ stdcall GetThreadPreferredUILanguages(long ptr ptr ptr) kernel32.GetThreadPreferredUILanguages
@ stdcall GetThreadPriority(long)
@ stdcall GetThreadPriorityBoost(long ptr)
......@@ -740,10 +740,10 @@
@ stub GetUILanguageInfo
# @ stub GetUnicodeStringToEightBitSizeRoutine
# @ stub GetUnicodeStringToEightBitStringRoutine
@ stdcall GetUserDefaultLCID() kernel32.GetUserDefaultLCID
@ stdcall GetUserDefaultLangID() kernel32.GetUserDefaultLangID
@ stdcall GetUserDefaultLocaleName(ptr long) kernel32.GetUserDefaultLocaleName
@ stdcall GetUserDefaultUILanguage() kernel32.GetUserDefaultUILanguage
@ stdcall GetUserDefaultLCID()
@ stdcall GetUserDefaultLangID()
@ stdcall GetUserDefaultLocaleName(ptr long)
@ stdcall GetUserDefaultUILanguage()
@ stdcall GetUserGeoID(long) kernel32.GetUserGeoID
@ stub GetUserInfo
@ stub GetUserInfoWord
......@@ -914,7 +914,7 @@
@ stdcall K32QueryWorkingSet(long ptr long) kernel32.K32QueryWorkingSet
@ stdcall K32QueryWorkingSetEx(long ptr long) kernel32.K32QueryWorkingSetEx
@ stub KernelBaseGetGlobalData
@ stdcall LCIDToLocaleName(long ptr long long) kernel32.LCIDToLocaleName
@ stdcall LCIDToLocaleName(long ptr long long)
@ stdcall LCMapStringA(long long str long ptr long) kernel32.LCMapStringA
@ stdcall LCMapStringEx(wstr long wstr long ptr long ptr ptr long) kernel32.LCMapStringEx
@ stdcall LCMapStringW(long long wstr long ptr long) kernel32.LCMapStringW
......@@ -1346,7 +1346,7 @@
@ stdcall ResetWriteWatch(ptr long)
@ stdcall ResolveDelayLoadedAPI(ptr ptr ptr ptr ptr long) kernel32.ResolveDelayLoadedAPI
# @ stub ResolveDelayLoadsFromDll
@ stdcall ResolveLocaleName(wstr ptr long) kernel32.ResolveLocaleName
@ stdcall ResolveLocaleName(wstr ptr long)
@ stdcall RestoreLastError(long) ntdll.RtlRestoreLastWin32Error
@ stdcall ResumeThread(long)
@ stdcall RevertToSelf()
......@@ -1485,14 +1485,14 @@
@ stdcall SetThreadIdealProcessor(long long)
@ stdcall SetThreadIdealProcessorEx(long ptr ptr)
# @ stub SetThreadInformation
@ stdcall SetThreadLocale(long) kernel32.SetThreadLocale
@ stdcall SetThreadLocale(long)
@ stdcall SetThreadPreferredUILanguages(long ptr ptr) kernel32.SetThreadPreferredUILanguages
@ stdcall SetThreadPriority(long long)
@ stdcall SetThreadPriorityBoost(long long)
# @ stub SetThreadSelectedCpuSets
@ stdcall SetThreadStackGuarantee(ptr)
@ stdcall SetThreadToken(ptr ptr)
@ stdcall SetThreadUILanguage(long) kernel32.SetThreadUILanguage
@ stdcall SetThreadUILanguage(long)
@ stub SetThreadpoolStackInformation
@ stdcall SetThreadpoolThreadMaximum(ptr long) ntdll.TpSetPoolMaxThreads
@ stdcall SetThreadpoolThreadMinimum(ptr long) ntdll.TpSetPoolMinThreads
......@@ -1657,8 +1657,8 @@
@ stdcall UrlUnescapeW(wstr ptr ptr long)
@ stdcall VerFindFileA(long str str str ptr ptr ptr ptr)
@ stdcall VerFindFileW(long wstr wstr wstr ptr ptr ptr ptr)
@ stdcall VerLanguageNameA(long str long) kernel32.VerLanguageNameA
@ stdcall VerLanguageNameW(long wstr long) kernel32.VerLanguageNameW
@ stdcall VerLanguageNameA(long str long)
@ stdcall VerLanguageNameW(long wstr long)
@ stdcall VerQueryValueA(ptr str ptr ptr)
@ stdcall VerQueryValueW(ptr wstr ptr ptr)
@ stdcall -ret64 VerSetConditionMask(long long long long) ntdll.VerSetConditionMask
......
/*
* Locale support
*
* Copyright 1995 Martin von Loewis
* Copyright 1998 David Lee Lambert
* Copyright 2000 Julio César Gázquez
* Copyright 2002 Alexandre Julliard for CodeWeavers
* Copyright 2003 Jon Griffiths
* Copyright 2005 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winternl.h"
#include "kernelbase.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(nls);
/******************************************************************************
* CompareStringOrdinal (kernelbase.@)
*/
INT WINAPI DECLSPEC_HOTPATCH CompareStringOrdinal( const WCHAR *str1, INT len1,
const WCHAR *str2, INT len2, BOOL ignore_case )
{
int ret;
if (!str1 || !str2)
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
if (len1 < 0) len1 = lstrlenW( str1 );
if (len2 < 0) len2 = lstrlenW( str2 );
ret = RtlCompareUnicodeStrings( str1, len1, str2, len2, ignore_case );
if (ret < 0) return CSTR_LESS_THAN;
if (ret > 0) return CSTR_GREATER_THAN;
return CSTR_EQUAL;
}
/******************************************************************************
* FindStringOrdinal (kernelbase.@)
*/
INT WINAPI DECLSPEC_HOTPATCH FindStringOrdinal( DWORD flag, const WCHAR *src, INT src_size,
const WCHAR *val, INT val_size, BOOL ignore_case )
{
INT offset, inc, count;
TRACE( "%#x %s %d %s %d %d\n", flag, wine_dbgstr_w(src), src_size,
wine_dbgstr_w(val), val_size, ignore_case );
if (!src || !val)
{
SetLastError( ERROR_INVALID_PARAMETER );
return -1;
}
if (flag != FIND_FROMSTART && flag != FIND_FROMEND && flag != FIND_STARTSWITH && flag != FIND_ENDSWITH)
{
SetLastError( ERROR_INVALID_FLAGS );
return -1;
}
if (src_size == -1) src_size = lstrlenW( src );
if (val_size == -1) val_size = lstrlenW( val );
SetLastError( ERROR_SUCCESS );
src_size -= val_size;
if (src_size < 0) return -1;
count = flag & (FIND_FROMSTART | FIND_FROMEND) ? src_size + 1 : 1;
offset = flag & (FIND_FROMSTART | FIND_STARTSWITH) ? 0 : src_size;
inc = flag & (FIND_FROMSTART | FIND_STARTSWITH) ? 1 : -1;
while (count--)
{
if (CompareStringOrdinal( src + offset, val_size, val, val_size, ignore_case ) == CSTR_EQUAL)
return offset;
offset += inc;
}
return -1;
}
/***********************************************************************
* LCIDToLocaleName (kernelbase.@)
*/
INT WINAPI DECLSPEC_HOTPATCH LCIDToLocaleName( LCID lcid, LPWSTR name, INT count, DWORD flags )
{
static int once;
if (flags && !once++) FIXME( "unsupported flags %x\n", flags );
return GetLocaleInfoW( lcid, LOCALE_SNAME | LOCALE_NOUSEROVERRIDE, name, count );
}
/***********************************************************************
* GetSystemDefaultLCID (kernelbase.@)
*/
LCID WINAPI DECLSPEC_HOTPATCH GetSystemDefaultLCID(void)
{
LCID lcid;
NtQueryDefaultLocale( FALSE, &lcid );
return lcid;
}
/***********************************************************************
* GetSystemDefaultLangID (kernelbase.@)
*/
LANGID WINAPI DECLSPEC_HOTPATCH GetSystemDefaultLangID(void)
{
return LANGIDFROMLCID( GetSystemDefaultLCID() );
}
/***********************************************************************
* GetSystemDefaultLocaleName (kernelbase.@)
*/
INT WINAPI DECLSPEC_HOTPATCH GetSystemDefaultLocaleName( LPWSTR name, INT len )
{
return LCIDToLocaleName( GetSystemDefaultLCID(), name, len, 0 );
}
/***********************************************************************
* GetSystemDefaultUILanguage (kernelbase.@)
*/
LANGID WINAPI DECLSPEC_HOTPATCH GetSystemDefaultUILanguage(void)
{
LANGID lang;
NtQueryInstallUILanguage( &lang );
return lang;
}
/***********************************************************************
* GetUserDefaultLCID (kernelbase.@)
*/
LCID WINAPI DECLSPEC_HOTPATCH GetUserDefaultLCID(void)
{
LCID lcid;
NtQueryDefaultLocale( TRUE, &lcid );
return lcid;
}
/***********************************************************************
* GetUserDefaultLangID (kernelbase.@)
*/
LANGID WINAPI DECLSPEC_HOTPATCH GetUserDefaultLangID(void)
{
return LANGIDFROMLCID( GetUserDefaultLCID() );
}
/***********************************************************************
* GetUserDefaultLocaleName (kernelbase.@)
*/
INT WINAPI DECLSPEC_HOTPATCH GetUserDefaultLocaleName( LPWSTR name, INT len )
{
return LCIDToLocaleName( GetUserDefaultLCID(), name, len, 0 );
}
/***********************************************************************
* GetUserDefaultUILanguage (kernelbase.@)
*/
LANGID WINAPI DECLSPEC_HOTPATCH GetUserDefaultUILanguage(void)
{
LANGID lang;
NtQueryDefaultUILanguage( &lang );
return lang;
}
/******************************************************************************
* ResolveLocaleName (kernelbase.@)
*/
INT WINAPI DECLSPEC_HOTPATCH ResolveLocaleName( LPCWSTR name, LPWSTR buffer, INT len )
{
FIXME( "stub: %s, %p, %d\n", wine_dbgstr_w(name), buffer, len );
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
return 0;
}
/***********************************************************************
* VerLanguageNameA (kernelbase.@)
*/
DWORD WINAPI DECLSPEC_HOTPATCH VerLanguageNameA( DWORD lang, LPSTR buffer, DWORD size )
{
return GetLocaleInfoA( MAKELCID( lang, SORT_DEFAULT ), LOCALE_SENGLANGUAGE, buffer, size );
}
/***********************************************************************
* VerLanguageNameW (kernelbase.@)
*/
DWORD WINAPI DECLSPEC_HOTPATCH VerLanguageNameW( DWORD lang, LPWSTR buffer, DWORD size )
{
return GetLocaleInfoW( MAKELCID( lang, SORT_DEFAULT ), LOCALE_SENGLANGUAGE, buffer, size );
}
......@@ -26,6 +26,7 @@
#define NONAMELESSUNION
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winternl.h"
#include "kernelbase.h"
......@@ -249,6 +250,17 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetThreadId( HANDLE thread )
}
/***********************************************************************
* GetThreadLocale (kernelbase.@)
*/
LCID WINAPI DECLSPEC_HOTPATCH GetThreadLocale(void)
{
LCID ret = NtCurrentTeb()->CurrentLocale;
if (!ret) NtCurrentTeb()->CurrentLocale = ret = GetUserDefaultLCID();
return ret;
}
/**********************************************************************
* GetThreadPriority (kernelbase.@)
*/
......@@ -447,6 +459,25 @@ BOOL WINAPI DECLSPEC_HOTPATCH SetThreadIdealProcessorEx( HANDLE thread, PROCESSO
/**********************************************************************
* SetThreadLocale (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH SetThreadLocale( LCID lcid )
{
lcid = ConvertDefaultLocale( lcid );
if (lcid != GetThreadLocale())
{
if (!IsValidLocale( lcid, LCID_SUPPORTED ))
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
NtCurrentTeb()->CurrentLocale = lcid;
}
return TRUE;
}
/**********************************************************************
* SetThreadPriority (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH SetThreadPriority( HANDLE thread, INT priority )
......@@ -488,6 +519,18 @@ BOOL WINAPI DECLSPEC_HOTPATCH SetThreadStackGuarantee( ULONG *size )
/**********************************************************************
* SetThreadUILanguage (kernelbase.@)
*/
LANGID WINAPI DECLSPEC_HOTPATCH SetThreadUILanguage( LANGID langid )
{
TRACE( "(0x%04x) stub - returning success\n", langid );
if (!langid) langid = GetThreadUILanguage();
return langid;
}
/**********************************************************************
* SuspendThread (kernelbase.@)
*/
DWORD WINAPI DECLSPEC_HOTPATCH SuspendThread( HANDLE thread )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment