xref: /reactos/sdk/include/ucrt/locale.h (revision 04e0dc4a)
1 //
2 // locale.h
3 //
4 //      Copyright (c) Microsoft Corporation. All rights reserved.
5 //
6 // The C locale library.
7 //
8 #pragma once
9 #ifndef _INC_LOCALE // include guard for 3rd party interop
10 #define _INC_LOCALE
11 
12 #include <corecrt.h>
13 
14 #pragma warning(push)
15 #pragma warning(disable: _UCRT_DISABLED_WARNINGS)
16 _UCRT_DISABLE_CLANG_WARNINGS
17 
18 _CRT_BEGIN_C_HEADER
19 
20 
21 
22 // Locale categories
23 #define LC_ALL          0
24 #define LC_COLLATE      1
25 #define LC_CTYPE        2
26 #define LC_MONETARY     3
27 #define LC_NUMERIC      4
28 #define LC_TIME         5
29 
30 #define LC_MIN          LC_ALL
31 #define LC_MAX          LC_TIME
32 
33 // Locale convention structure
34 struct lconv
35 {
36     char*    decimal_point;
37     char*    thousands_sep;
38     char*    grouping;
39     char*    int_curr_symbol;
40     char*    currency_symbol;
41     char*    mon_decimal_point;
42     char*    mon_thousands_sep;
43     char*    mon_grouping;
44     char*    positive_sign;
45     char*    negative_sign;
46     char     int_frac_digits;
47     char     frac_digits;
48     char     p_cs_precedes;
49     char     p_sep_by_space;
50     char     n_cs_precedes;
51     char     n_sep_by_space;
52     char     p_sign_posn;
53     char     n_sign_posn;
54     wchar_t* _W_decimal_point;
55     wchar_t* _W_thousands_sep;
56     wchar_t* _W_int_curr_symbol;
57     wchar_t* _W_currency_symbol;
58     wchar_t* _W_mon_decimal_point;
59     wchar_t* _W_mon_thousands_sep;
60     wchar_t* _W_positive_sign;
61     wchar_t* _W_negative_sign;
62 };
63 
64 struct tm;
65 
66 // ANSI: char lconv members default is CHAR_MAX which is compile time dependent.
67 // Defining and using __do_unsigned_char_lconv_initialization here causes CRT
68 // startup code to initialize lconv members properly
69 #ifdef _CHAR_UNSIGNED
70     extern int __do_unsigned_char_lconv_initialization;
__use_char_max(void)71     extern __inline int __use_char_max(void)
72     {
73         return __do_unsigned_char_lconv_initialization;
74     }
75 #endif
76 
77 
78 
79 #define _ENABLE_PER_THREAD_LOCALE         0x0001
80 #define _DISABLE_PER_THREAD_LOCALE        0x0002
81 #define _ENABLE_PER_THREAD_LOCALE_GLOBAL  0x0010
82 #define _DISABLE_PER_THREAD_LOCALE_GLOBAL 0x0020
83 #define _ENABLE_PER_THREAD_LOCALE_NEW     0x0100
84 #define _DISABLE_PER_THREAD_LOCALE_NEW    0x0200
85 
86 #if _CRT_FUNCTIONS_REQUIRED
87 
88     _ACRTIMP void __cdecl _lock_locales(void);
89     _ACRTIMP void __cdecl _unlock_locales(void);
90 
91     _Check_return_opt_
92     _ACRTIMP int __cdecl _configthreadlocale(
93         _In_ int _Flag
94         );
95 
96     _Check_return_opt_ _Success_(return != 0) _Ret_z_
97     _ACRTIMP char* __cdecl setlocale(
98         _In_       int         _Category,
99         _In_opt_z_ char const* _Locale
100         );
101 
102     _Check_return_opt_
103     _ACRTIMP struct lconv* __cdecl localeconv(void);
104 
105     _Check_return_opt_
106     _ACRTIMP _locale_t __cdecl _get_current_locale(void);
107 
108     _Check_return_opt_
109     _ACRTIMP _locale_t __cdecl _create_locale(
110         _In_   int         _Category,
111         _In_z_ char const* _Locale
112         );
113 
114     _ACRTIMP void __cdecl _free_locale(
115         _In_opt_ _locale_t _Locale
116         );
117 
118     // Also declared in <wchar.h>
119     _Check_return_opt_ _Success_(return != 0) _Ret_z_
120     _ACRTIMP wchar_t* __cdecl _wsetlocale(
121         _In_       int            _Category,
122         _In_opt_z_ wchar_t const* _Locale
123         );
124 
125     _Check_return_opt_
126     _ACRTIMP _locale_t __cdecl _wcreate_locale(
127         _In_   int            _Category,
128         _In_z_ wchar_t const* _Locale
129         );
130 
131 
132 
133     _ACRTIMP wchar_t**    __cdecl ___lc_locale_name_func(void);
134     _ACRTIMP unsigned int __cdecl ___lc_codepage_func   (void);
135     _ACRTIMP unsigned int __cdecl ___lc_collate_cp_func (void);
136 
137 
138 
139 
140     // Time-related functions
141     _Success_(return != 0)
142     _Ret_z_
143     _ACRTIMP char*    __cdecl _Getdays(void);
144 
145     _Success_(return != 0)
146     _Ret_z_
147     _ACRTIMP char*    __cdecl _Getmonths(void);
148 
149     _ACRTIMP void*    __cdecl _Gettnames(void);
150 
151     _Success_(return != 0)
152     _Ret_z_
153     _ACRTIMP wchar_t* __cdecl _W_Getdays(void);
154 
155     _Success_(return != 0)
156     _Ret_z_
157     _ACRTIMP wchar_t* __cdecl _W_Getmonths(void);
158 
159     _ACRTIMP void*    __cdecl _W_Gettnames(void);
160 
161     _Success_(return > 0)
162     _ACRTIMP size_t __cdecl _Strftime(
163         _Out_writes_z_(_Max_size) char*           _Buffer,
164         _In_                     size_t           _Max_size,
165         _In_z_                   char const*      _Format,
166         _In_                     struct tm const* _Timeptr,
167         _In_opt_                 void*            _Lc_time_arg);
168 
169     _Success_(return > 0)
170     _ACRTIMP size_t __cdecl _Wcsftime(
171         _Out_writes_z_(_Max_size) wchar_t*        _Buffer,
172         _In_                     size_t           _Max_size,
173         _In_z_                   wchar_t const*   _Format,
174         _In_                     struct tm const* _Timeptr,
175         _In_opt_                 void*            _Lc_time_arg
176         );
177 
178 #endif // _CRT_FUNCTIONS_REQUIRED
179 
180 
181 _CRT_END_C_HEADER
182 _UCRT_RESTORE_CLANG_WARNINGS
183 #pragma warning(pop) // _UCRT_DISABLED_WARNINGS
184 #endif // _INC_LOCALE
185