ReactOS 0.4.16-dev-2279-gc890759
lcformatansi.c File Reference
#include <k32.h>
#include <debug.h>
#include "lcformat_private.h"
Include dependency graph for lcformatansi.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define CAL_SABBREVERASTRING   0x00000039
 

Functions

 DEBUG_CHANNEL (nls)
 
INT WINAPI GetNumberFormatA (LCID lcid, DWORD dwFlags, LPCSTR lpszValue, const NUMBERFMTA *lpFormat, LPSTR lpNumberStr, int cchOut)
 
INT WINAPI GetCurrencyFormatA (LCID lcid, DWORD dwFlags, LPCSTR lpszValue, const CURRENCYFMTA *lpFormat, LPSTR lpCurrencyStr, int cchOut)
 
BOOL WINAPI EnumDateFormatsA (DATEFMT_ENUMPROCA proc, LCID lcid, DWORD flags)
 
BOOL WINAPI EnumTimeFormatsA (TIMEFMT_ENUMPROCA proc, LCID lcid, DWORD flags)
 
BOOL WINAPI EnumCalendarInfoA (CALINFO_ENUMPROCA calinfoproc, LCID locale, CALID calendar, CALTYPE caltype)
 
BOOL WINAPI EnumCalendarInfoExA (CALINFO_ENUMPROCEXA calinfoproc, LCID locale, CALID calendar, CALTYPE caltype)
 
int WINAPI GetCalendarInfoA (LCID lcid, CALID Calendar, CALTYPE CalType, LPSTR lpCalData, int cchData, LPDWORD lpValue)
 
int WINAPI SetCalendarInfoA (LCID Locale, CALID Calendar, CALTYPE CalType, LPCSTR lpCalData)
 

Macro Definition Documentation

◆ CAL_SABBREVERASTRING

#define CAL_SABBREVERASTRING   0x00000039

Definition at line 34 of file lcformatansi.c.

◆ NDEBUG

#define NDEBUG

Definition at line 27 of file lcformatansi.c.

Function Documentation

◆ DEBUG_CHANNEL()

DEBUG_CHANNEL ( nls  )

◆ EnumCalendarInfoA()

BOOL WINAPI EnumCalendarInfoA ( CALINFO_ENUMPROCA  calinfoproc,
LCID  locale,
CALID  calendar,
CALTYPE  caltype 
)

Definition at line 275 of file lcformatansi.c.

277{
278 struct enumcalendar_context ctxt;
279
280 TRACE("(%p,0x%08x,0x%08x,0x%08x)\n", calinfoproc, locale, calendar, caltype);
281
282 ctxt.type = CALLBACK_ENUMPROC;
283 ctxt.u.callback = (CALINFO_ENUMPROCW)calinfoproc;
284 ctxt.lcid = locale;
285 ctxt.calendar = calendar;
286 ctxt.caltype = caltype;
287 ctxt.lParam = 0;
288 ctxt.unicode = FALSE;
289 return NLS_EnumCalendarInfo(&ctxt);
290}
Definition: _locale.h:75
#define FALSE
Definition: types.h:117
BOOL NLS_EnumCalendarInfo(const struct enumcalendar_context *ctxt)
Definition: lcformat.c:1959
@ CALLBACK_ENUMPROC
#define TRACE(s)
Definition: solgame.cpp:4
BOOL(CALLBACK * CALINFO_ENUMPROCW)(LPWSTR)
Definition: winnls.h:592

Referenced by test_EnumCalendarInfoA().

◆ EnumCalendarInfoExA()

BOOL WINAPI EnumCalendarInfoExA ( CALINFO_ENUMPROCEXA  calinfoproc,
LCID  locale,
CALID  calendar,
CALTYPE  caltype 
)

Definition at line 295 of file lcformatansi.c.

297{
298 struct enumcalendar_context ctxt;
299
300 TRACE("(%p,0x%08x,0x%08x,0x%08x)\n", calinfoproc, locale, calendar, caltype);
301
302 ctxt.type = CALLBACK_ENUMPROCEX;
303 ctxt.u.callbackex = (CALINFO_ENUMPROCEXW)calinfoproc;
304 ctxt.lcid = locale;
305 ctxt.calendar = calendar;
306 ctxt.caltype = caltype;
307 ctxt.lParam = 0;
308 ctxt.unicode = FALSE;
309 return NLS_EnumCalendarInfo(&ctxt);
310}
@ CALLBACK_ENUMPROCEX
BOOL(CALLBACK * CALINFO_ENUMPROCEXW)(LPWSTR, CALID)
Definition: winnls.h:594

Referenced by test_EnumCalendarInfoExA().

◆ EnumDateFormatsA()

BOOL WINAPI EnumDateFormatsA ( DATEFMT_ENUMPROCA  proc,
LCID  lcid,
DWORD  flags 
)

Definition at line 232 of file lcformatansi.c.

233{
234 struct enumdateformats_context ctxt;
235
236 ctxt.type = CALLBACK_ENUMPROC;
237 ctxt.u.callback = (DATEFMT_ENUMPROCW)proc;
238 ctxt.lcid = lcid;
239 ctxt.flags = flags;
240 ctxt.unicode = FALSE;
241
242 return NLS_EnumDateFormats(&ctxt);
243}
LCID lcid
Definition: locale.c:5656
GLbitfield flags
Definition: glext.h:7161
BOOL NLS_EnumDateFormats(const struct enumdateformats_context *ctxt)
Definition: lcformat.c:1720
static HANDLE proc()
Definition: pdb.c:34
enum enum_callback_type type
BOOL(CALLBACK * DATEFMT_ENUMPROCW)(LPWSTR)
Definition: winnls.h:607

Referenced by test_EnumDateFormatsA().

◆ EnumTimeFormatsA()

BOOL WINAPI EnumTimeFormatsA ( TIMEFMT_ENUMPROCA  proc,
LCID  lcid,
DWORD  flags 
)

Definition at line 251 of file lcformatansi.c.

252{
253 struct enumtimeformats_context ctxt;
254
255 /* EnumTimeFormatsA doesn't support flags, EnumTimeFormatsW does. */
257 {
259 return FALSE;
260 }
261
262 ctxt.type = CALLBACK_ENUMPROC;
263 ctxt.u.callback = (TIMEFMT_ENUMPROCW)proc;
264 ctxt.lcid = lcid;
265 ctxt.flags = flags;
266 ctxt.unicode = FALSE;
267
268 return NLS_EnumTimeFormats(&ctxt);
269}
#define SetLastError(x)
Definition: compat.h:752
BOOL NLS_EnumTimeFormats(struct enumtimeformats_context *ctxt)
Definition: lcformat.c:1852
#define ERROR_INVALID_FLAGS
Definition: winerror.h:907
#define LOCALE_USE_CP_ACP
Definition: winnls.h:20
BOOL(CALLBACK * TIMEFMT_ENUMPROCW)(LPWSTR)
Definition: winnls.h:611

Referenced by test_EnumTimeFormatsA(), and test_EnumTimeFormatsW().

◆ GetCalendarInfoA()

int WINAPI GetCalendarInfoA ( LCID  lcid,
CALID  Calendar,
CALTYPE  CalType,
LPSTR  lpCalData,
int  cchData,
LPDWORD  lpValue 
)

Definition at line 315 of file lcformatansi.c.

317{
318 int ret, cchDataW = cchData;
319 LPWSTR lpCalDataW = NULL;
320#ifdef __REACTOS__
321 DWORD cp = CP_ACP;
322 if (!(CalType & CAL_USE_CP_ACP))
323 {
324 DWORD dwFlags = ((CalType & CAL_NOUSEROVERRIDE) ? LOCALE_NOUSEROVERRIDE : 0);
326 if (!cp)
327 {
329 return 0;
330 }
331 }
332 if ((CalType & 0xFFFF) == CAL_SABBREVERASTRING)
333 {
334 /* NOTE: CAL_SABBREVERASTRING is not supported in GetCalendarInfoA */
336 return 0;
337 }
338#endif
339
341 {
343 return 0;
344 }
345
346 if (!cchData && !(CalType & CAL_RETURN_NUMBER))
347 cchDataW = GetCalendarInfoW(lcid, Calendar, CalType, NULL, 0, NULL);
348 if (!(lpCalDataW = HeapAlloc(GetProcessHeap(), 0, cchDataW*sizeof(WCHAR))))
349 return 0;
350
351 ret = GetCalendarInfoW(lcid, Calendar, CalType, lpCalDataW, cchDataW, lpValue);
352 if(ret && lpCalDataW && lpCalData)
353#ifdef __REACTOS__
354 ret = WideCharToMultiByte(cp, 0, lpCalDataW, -1, lpCalData, cchData, NULL, NULL);
355#else
356 ret = WideCharToMultiByte(CP_ACP, 0, lpCalDataW, -1, lpCalData, cchData, NULL, NULL);
357#endif
358 else if (CalType & CAL_RETURN_NUMBER)
359 ret *= sizeof(WCHAR);
360 HeapFree(GetProcessHeap(), 0, lpCalDataW);
361
362 return ret;
363}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
return ret
Definition: mutex.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL NLS_IsUnicodeOnlyLcid(LCID lcid)
Definition: lcformat.c:372
DWORD NLS_GetAnsiCodePage(LCID lcid, DWORD dwFlags)
Definition: lcformat.c:361
int WINAPI GetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType, LPWSTR lpCalData, int cchData, LPDWORD lpValue)
Definition: lcformat.c:2144
#define CAL_SABBREVERASTRING
Definition: lcformatansi.c:34
POINT cp
Definition: magnifier.c:59
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by NLS_EnumCalendarInfo(), and START_TEST().

◆ GetCurrencyFormatA()

INT WINAPI GetCurrencyFormatA ( LCID  lcid,
DWORD  dwFlags,
LPCSTR  lpszValue,
const CURRENCYFMTA lpFormat,
LPSTR  lpCurrencyStr,
int  cchOut 
)

Definition at line 160 of file lcformatansi.c.

163{
164 DWORD cp = CP_ACP;
165 WCHAR szDec[8], szGrp[8], szCy[8], szIn[128], szOut[128];
167 const CURRENCYFMTW *pfmt = NULL;
168 INT iRet;
169
170 TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_a(lpszValue),
171 lpFormat, lpCurrencyStr, cchOut);
172
174 {
176 return 0;
177 }
178
179 if (!(dwFlags & LOCALE_USE_CP_ACP))
180 {
182 if (!cp)
183 {
185 return 0;
186 }
187 }
188
189 if (lpFormat)
190 {
191 memcpy(&fmt, lpFormat, sizeof(fmt));
192 pfmt = &fmt;
193 if (lpFormat->lpDecimalSep)
194 {
195 MultiByteToWideChar(cp, 0, lpFormat->lpDecimalSep, -1, szDec, ARRAY_SIZE(szDec));
196 fmt.lpDecimalSep = szDec;
197 }
198 if (lpFormat->lpThousandSep)
199 {
200 MultiByteToWideChar(cp, 0, lpFormat->lpThousandSep, -1, szGrp, ARRAY_SIZE(szGrp));
201 fmt.lpThousandSep = szGrp;
202 }
203 if (lpFormat->lpCurrencySymbol)
204 {
205 MultiByteToWideChar(cp, 0, lpFormat->lpCurrencySymbol, -1, szCy, ARRAY_SIZE(szCy));
206 fmt.lpCurrencySymbol = szCy;
207 }
208 }
209
210 if (lpszValue)
211 MultiByteToWideChar(cp, 0, lpszValue, -1, szIn, ARRAY_SIZE(szIn));
212
213 if (cchOut > (int) ARRAY_SIZE(szOut))
214 cchOut = ARRAY_SIZE(szOut);
215
216 szOut[0] = '\0';
217
218 iRet = GetCurrencyFormatW(lcid, dwFlags, lpszValue ? szIn : NULL, pfmt,
219 lpCurrencyStr ? szOut : NULL, cchOut);
220
221 if (szOut[0] && lpCurrencyStr)
222 WideCharToMultiByte(cp, 0, szOut, -1, lpCurrencyStr, cchOut, 0, 0);
223 return iRet;
224}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define MultiByteToWideChar
Definition: compat.h:110
#define debugstr_a
Definition: kernel32.h:31
INT WINAPI GetCurrencyFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const CURRENCYFMTW *lpFormat, LPWSTR lpCurrencyStr, int cchOut)
Definition: lcformat.c:1401
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: dsound.c:943
LPCWSTR lpFormat
Definition: trayclock.cpp:32
int32_t INT
Definition: typedefs.h:58

Referenced by test_GetCurrencyFormatA().

◆ GetNumberFormatA()

INT WINAPI GetNumberFormatA ( LCID  lcid,
DWORD  dwFlags,
LPCSTR  lpszValue,
const NUMBERFMTA lpFormat,
LPSTR  lpNumberStr,
int  cchOut 
)

Definition at line 68 of file lcformatansi.c.

71{
72 DWORD cp = CP_ACP;
73 WCHAR szDec[8], szGrp[8], szIn[128], szOut[128];
75 const NUMBERFMTW *pfmt = NULL;
76 INT iRet;
77
78 TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_a(lpszValue),
79 lpFormat, lpNumberStr, cchOut);
80
82 {
84 return 0;
85 }
86
88 {
90 if (!cp)
91 {
93 return 0;
94 }
95 }
96
97 if (lpFormat)
98 {
99 memcpy(&fmt, lpFormat, sizeof(fmt));
100 pfmt = &fmt;
101 if (lpFormat->lpDecimalSep)
102 {
103 MultiByteToWideChar(cp, 0, lpFormat->lpDecimalSep, -1, szDec, ARRAY_SIZE(szDec));
104 fmt.lpDecimalSep = szDec;
105 }
106 if (lpFormat->lpThousandSep)
107 {
108 MultiByteToWideChar(cp, 0, lpFormat->lpThousandSep, -1, szGrp, ARRAY_SIZE(szGrp));
109 fmt.lpThousandSep = szGrp;
110 }
111 }
112
113 if (lpszValue)
114 MultiByteToWideChar(cp, 0, lpszValue, -1, szIn, ARRAY_SIZE(szIn));
115
116 if (cchOut > (int) ARRAY_SIZE(szOut))
117 cchOut = ARRAY_SIZE(szOut);
118
119 szOut[0] = '\0';
120
121 iRet = GetNumberFormatW(lcid, dwFlags, lpszValue ? szIn : NULL, pfmt,
122 lpNumberStr ? szOut : NULL, cchOut);
123
124 if (szOut[0] && lpNumberStr)
125 WideCharToMultiByte(cp, 0, szOut, -1, lpNumberStr, cchOut, 0, 0);
126 return iRet;
127}
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1130

Referenced by test_GetNumberFormatA().

◆ SetCalendarInfoA()

int WINAPI SetCalendarInfoA ( LCID  Locale,
CALID  Calendar,
CALTYPE  CalType,
LPCSTR  lpCalData 
)

Definition at line 368 of file lcformatansi.c.

369{
370 FIXME("(%08x,%08x,%08x,%s): stub\n",
371 Locale, Calendar, CalType, debugstr_a(lpCalData));
372 return 0;
373}
#define FIXME(fmt,...)
Definition: precomp.h:53