ReactOS  0.4.14-dev-77-gd9e7c48
locale_list.c
Go to the documentation of this file.
1 /*
2  * PROJECT: input.dll
3  * FILE: dll/cpl/input/locale_list.c
4  * PURPOSE: input.dll
5  * PROGRAMMER: Dmitry Chapyshev (dmitry@reactos.org)
6  */
7 
8 #include "locale_list.h"
9 
10 
12 
13 
14 static LOCALE_LIST_NODE*
16 {
17  LOCALE_LIST_NODE *pCurrent;
18  LOCALE_LIST_NODE *pNew;
19 
20  if (pszName == NULL)
21  return NULL;
22 
23  pCurrent = _LocaleList;
24 
25  pNew = (LOCALE_LIST_NODE*)malloc(sizeof(LOCALE_LIST_NODE));
26  if (pNew == NULL)
27  return NULL;
28 
29  ZeroMemory(pNew, sizeof(LOCALE_LIST_NODE));
30 
31  pNew->pszName = _wcsdup(pszName);
32  if (pNew->pszName == NULL)
33  {
34  free(pNew);
35  return NULL;
36  }
37 
38  pNew->dwId = dwId;
39 
40  if (pCurrent == NULL)
41  {
42  _LocaleList = pNew;
43  }
44  else
45  {
46  while (pCurrent->pNext != NULL)
47  {
48  pCurrent = pCurrent->pNext;
49  }
50 
51  pNew->pPrev = pCurrent;
52  pCurrent->pNext = pNew;
53  }
54 
55  return pNew;
56 }
57 
58 
59 VOID
61 {
62  LOCALE_LIST_NODE *pCurrent;
63 
64  if (_LocaleList == NULL)
65  return;
66 
67  pCurrent = _LocaleList;
68 
69  while (pCurrent != NULL)
70  {
71  LOCALE_LIST_NODE *pNext = pCurrent->pNext;
72 
73  free(pCurrent->pszName);
74  free(pCurrent);
75 
76  pCurrent = pNext;
77  }
78 
79  _LocaleList = NULL;
80 }
81 
82 
85 {
86  WCHAR szValue[MAX_PATH];
87  DWORD dwIndex;
88  DWORD dwSize;
89  HKEY hKey;
90 
92  L"SYSTEM\\CurrentControlSet\\Control\\Nls\\Language",
93  0,
95  &hKey) != ERROR_SUCCESS)
96  {
97  return NULL;
98  }
99 
100  dwSize = ARRAYSIZE(szValue);
101  dwIndex = 0;
102 
103  while (RegEnumValueW(hKey, dwIndex, szValue, &dwSize,
105  {
107  DWORD dwId;
108 
109  dwId = DWORDfromString(szValue);
110 
114  {
116  }
117 
118  dwSize = ARRAYSIZE(szValue);
119  ++dwIndex;
120  }
121 
122  RegCloseKey(hKey);
123 
124  return _LocaleList;
125 }
126 
127 
130 {
131  LOCALE_LIST_NODE *pCurrent;
132 
133  for (pCurrent = _LocaleList; pCurrent != NULL; pCurrent = pCurrent->pNext)
134  {
135  if (LOWORD(pCurrent->dwId) == LOWORD(hkl))
136  {
137  return pCurrent;
138  }
139  }
140 
141  return NULL;
142 }
143 
144 
147 {
148  return _LocaleList;
149 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define LOCALE_SLANGUAGE
Definition: winnls.h:26
#define free
Definition: debug_ros.c:5
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define ZeroMemory
Definition: winbase.h:1635
static LOCALE_LIST_NODE * _LocaleList
Definition: locale_list.c:11
VOID LocaleList_Destroy(VOID)
Definition: locale_list.c:60
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
LOCALE_LIST_NODE * LocaleList_GetFirst(VOID)
Definition: locale_list.c:146
struct _LOCALE_LIST_NODE * pNext
Definition: locale_list.h:12
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2853
smooth NULL
Definition: ftsmooth.c:416
static LOCALE_LIST_NODE * LocaleList_Append(DWORD dwId, const WCHAR *pszName)
Definition: locale_list.c:15
struct _LAYOUT_LIST_NODE * pNext
Definition: layout_list.h:13
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _LOCALE_LIST_NODE * pPrev
Definition: locale_list.h:11
static const WCHAR L[]
Definition: oid.c:1250
UINT_PTR HKL
Definition: msctf.idl:101
HKL hkl
Definition: msctf.idl:611
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define MAX_STR_LEN
Definition: defines.h:33
static DWORD DWORDfromString(const WCHAR *pszString)
Definition: input.h:78
static const WCHAR szName[]
Definition: msipriv.h:1194
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define malloc
Definition: debug_ros.c:4
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
#define LOWORD(l)
Definition: pedump.c:82
LOCALE_LIST_NODE * LocaleList_Create(VOID)
Definition: locale_list.c:84
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
LOCALE_LIST_NODE * LocaleList_GetByHkl(HKL hkl)
Definition: locale_list.c:129
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019