ReactOS 0.4.16-dev-2332-g4cba65d
locale.h File Reference
#include <corecrt.h>
Include dependency graph for locale.h:

Go to the source code of this file.

Classes

struct  lconv
 

Macros

#define LC_ALL   0
 
#define LC_COLLATE   1
 
#define LC_CTYPE   2
 
#define LC_MONETARY   3
 
#define LC_NUMERIC   4
 
#define LC_TIME   5
 
#define LC_MIN   LC_ALL
 
#define LC_MAX   LC_TIME
 
#define _LCONV_DEFINED
 
#define _CONFIG_LOCALE_SWT
 
#define _ENABLE_PER_THREAD_LOCALE   0x1
 
#define _DISABLE_PER_THREAD_LOCALE   0x2
 
#define _ENABLE_PER_THREAD_LOCALE_GLOBAL   0x10
 
#define _DISABLE_PER_THREAD_LOCALE_GLOBAL   0x20
 
#define _ENABLE_PER_THREAD_LOCALE_NEW   0x100
 
#define _DISABLE_PER_THREAD_LOCALE_NEW   0x200
 
#define _WLOCALE_DEFINED
 

Functions

_ACRTIMP char *__cdecl setlocale (int, const char *)
 
_ACRTIMP struct lconv *__cdecl localeconv (void)
 
_ACRTIMP size_t __cdecl _Strftime (char *, size_t, const char *, const struct tm *, void *)
 
_ACRTIMP int __cdecl _configthreadlocale (int)
 
_ACRTIMP _locale_t __cdecl _get_current_locale (void)
 
_ACRTIMP _locale_t __cdecl _create_locale (int, const char *)
 
_ACRTIMP void __cdecl _free_locale (_locale_t)
 
_ACRTIMP unsigned int __cdecl ___lc_codepage_func (void)
 
_ACRTIMP wchar_t *__cdecl _wsetlocale (int, const wchar_t *)
 

Macro Definition Documentation

◆ _CONFIG_LOCALE_SWT

#define _CONFIG_LOCALE_SWT

Definition at line 72 of file locale.h.

◆ _DISABLE_PER_THREAD_LOCALE

#define _DISABLE_PER_THREAD_LOCALE   0x2

Definition at line 75 of file locale.h.

◆ _DISABLE_PER_THREAD_LOCALE_GLOBAL

#define _DISABLE_PER_THREAD_LOCALE_GLOBAL   0x20

Definition at line 77 of file locale.h.

◆ _DISABLE_PER_THREAD_LOCALE_NEW

#define _DISABLE_PER_THREAD_LOCALE_NEW   0x200

Definition at line 79 of file locale.h.

◆ _ENABLE_PER_THREAD_LOCALE

#define _ENABLE_PER_THREAD_LOCALE   0x1

Definition at line 74 of file locale.h.

◆ _ENABLE_PER_THREAD_LOCALE_GLOBAL

#define _ENABLE_PER_THREAD_LOCALE_GLOBAL   0x10

Definition at line 76 of file locale.h.

◆ _ENABLE_PER_THREAD_LOCALE_NEW

#define _ENABLE_PER_THREAD_LOCALE_NEW   0x100

Definition at line 78 of file locale.h.

◆ _LCONV_DEFINED

#define _LCONV_DEFINED

Definition at line 35 of file locale.h.

◆ _WLOCALE_DEFINED

#define _WLOCALE_DEFINED

Definition at line 98 of file locale.h.

◆ LC_ALL

#define LC_ALL   0

Definition at line 25 of file locale.h.

◆ LC_COLLATE

#define LC_COLLATE   1

Definition at line 26 of file locale.h.

◆ LC_CTYPE

#define LC_CTYPE   2

Definition at line 27 of file locale.h.

◆ LC_MAX

#define LC_MAX   LC_TIME

Definition at line 32 of file locale.h.

◆ LC_MIN

#define LC_MIN   LC_ALL

Definition at line 31 of file locale.h.

◆ LC_MONETARY

#define LC_MONETARY   3

Definition at line 28 of file locale.h.

◆ LC_NUMERIC

#define LC_NUMERIC   4

Definition at line 29 of file locale.h.

◆ LC_TIME

#define LC_TIME   5

Definition at line 30 of file locale.h.

Function Documentation

◆ ___lc_codepage_func()

_ACRTIMP unsigned int __cdecl ___lc_codepage_func ( void  )

Definition at line 1047 of file locale.c.

1048{
1049 return get_locinfo()->lc_codepage;
1050}
pthreadlocinfo CDECL get_locinfo(void)
Definition: locale.c:635
unsigned int lc_codepage
Definition: corecrt.h:278

Referenced by get_aw_cp(), mbrtowc(), START_TEST(), Test___lc_codepage(), test_fopen(), and tzset_from_system_nolock().

◆ _configthreadlocale()

_ACRTIMP int __cdecl _configthreadlocale ( int  i)

Definition at line 71 of file wsetlocale.cpp.

72{
73 /*
74 * ownlocale flag struct:
75 * bits: 000000000000000000000000 000W 00P1
76 * P is set when _ENABLE_PER_THREAD_LOCALE is called for this thread
77 * or _ENABLE_PER_THREAD_LOCALE_NEW was set when this thread was created.
78 * W is set when _WSETLOCALE_AVOID_SYNC_LOCALE_BIT is set by _wsetlocale.
79 * It is used to disable global-ptd resynchronization during a call to _wsetlocale.
80 *
81 * __globallocalestatus structure:
82 * bits: 111111111111111111111111 1111 1N1G
83 * G is set if _ENABLE_PER_THREAD_LOCALE_GLOBAL is set.
84 * G is 0 if _ENABLE_PER_THREAD_LOCALE_GLOBAL is not set.
85 * N is set if _ENABLE_PER_THREAD_LOCALE_NEW is set.
86 * N is 0 if _ENABLE_PER_THREAD_LOCALE_NEW is not set.
87 */
88 __acrt_ptd* const ptd = __acrt_getptd();
90
91 switch(i)
92 {
94 // same behavior as __acrt_disable_global_locale_sync()
95 ptd->_own_locale = ptd->_own_locale | _PER_THREAD_LOCALE_BIT;
96 break;
97
99 // same behavior as __acrt_enable_global_locale_sync()
100 ptd->_own_locale = ptd->_own_locale & ~_PER_THREAD_LOCALE_BIT;
101 break;
102
103 case 0:
104 break;
105
106 /* used only during dll startup for linkopt */
107 case -1:
109 break;
110
111 default:
112 _VALIDATE_RETURN(("Invalid parameter for _configthreadlocale",0),EINVAL,-1);
113 break;
114 }
115
116 return retval;
117}
__acrt_ptd *__cdecl __acrt_getptd(void)
#define _PER_THREAD_LOCALE_BIT
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
_In_ size_t const _In_ int _In_ bool const _In_ unsigned const _In_ __acrt_rounding_mode const _Inout_ __crt_cached_ptd_host & ptd
Definition: cvt.cpp:355
#define EINVAL
Definition: errno.h:44
#define _DISABLE_PER_THREAD_LOCALE
Definition: locale.h:75
#define _ENABLE_PER_THREAD_LOCALE
Definition: locale.h:74
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int __globallocalestatus
Definition: glstatus.cpp:13
int retval
Definition: wcstombs.cpp:91

◆ _create_locale()

_ACRTIMP _locale_t __cdecl _create_locale ( int  category,
const char locale 
)

Definition at line 1981 of file locale.c.

1982{
1983 _locale_t loc;
1984
1985 loc = malloc(sizeof(_locale_tstruct));
1986 if(!loc)
1987 return NULL;
1988
1990 if(!loc->locinfo) {
1991 free(loc);
1992 return NULL;
1993 }
1994
1996 loc->locinfo->lc_handle[LC_CTYPE], NULL);
1997 if(!loc->mbcinfo) {
1998 free_locinfo(loc->locinfo);
1999 free(loc);
2000 return NULL;
2001 }
2002 return loc;
2003}
Definition: _locale.h:75
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define LC_CTYPE
Definition: locale.h:27
void free_locinfo(pthreadlocinfo locinfo)
Definition: locale.c:1061
static pthreadlocinfo create_locinfo(int category, const char *locale, const threadlocinfo *old_locinfo)
Definition: locale.c:1278
threadmbcinfo * create_mbcinfo(int cp, LCID lcid, threadmbcinfo *old_mbcinfo)
Definition: mbcs.c:219
pthreadlocinfo locinfo
Definition: corecrt.h:260
pthreadmbcinfo mbcinfo
Definition: corecrt.h:261
unsigned short wCodePage
Definition: corecrt.h:268
__msvcrt_ulong lc_handle[6]
Definition: corecrt.h:286

Referenced by msvcrt_init_locale(), test_C_locale(), and test_SpecialCasing().

◆ _free_locale()

_ACRTIMP void __cdecl _free_locale ( _locale_t  locale)

Definition at line 1183 of file locale.c.

1184{
1185 if (!locale)
1186 return;
1187
1189 free(locale);
1190}
void CDECL free_locale_noalloc(_locale_t locale)
Definition: locale.c:1162

Referenced by DllMain(), test_C_locale(), and test_SpecialCasing().

◆ _get_current_locale()

_ACRTIMP _locale_t __cdecl _get_current_locale ( void  )

Definition at line 1171 of file locale.c.

1172{
1173 _locale_t loc = malloc(sizeof(_locale_tstruct));
1174 if(!loc)
1175 return NULL;
1176
1177 return get_current_locale_noalloc(loc);
1178}
_locale_t CDECL get_current_locale_noalloc(_locale_t locale)
Definition: locale.c:1149

◆ _Strftime()

_ACRTIMP size_t __cdecl _Strftime ( char str,
size_t  max,
const char format,
const struct tm mstm,
void time_data 
)

Definition at line 1528 of file time.c.

1530{
1531 return strftime_helper(str, max, format, mstm, time_data, NULL);
1532}
static size_t strftime_helper(char *str, size_t max, const char *format, const struct tm *mstm, __lc_time_data *time_data, _locale_t loc)
Definition: time.c:1466
const WCHAR * str
Definition: format.c:58
#define max(a, b)
Definition: svc.c:63

Referenced by test_strftime().

◆ _wsetlocale()

_ACRTIMP wchar_t *__cdecl _wsetlocale ( int  category,
const wchar_t wlocale 
)

Definition at line 2097 of file locale.c.

2098{
2099 static wchar_t current_lc_all[MAX_LOCALE_LENGTH];
2100
2101 char *locale = NULL;
2102 const char *ret;
2103 size_t len;
2104
2105 if(wlocale) {
2106 len = wcstombs(NULL, wlocale, 0);
2107 if(len == -1)
2108 return NULL;
2109
2110 locale = malloc(++len);
2111 if(!locale)
2112 return NULL;
2113
2114 wcstombs(locale, wlocale, len);
2115 }
2116
2117 _lock_locales();
2119 free(locale);
2120
2121 if(ret && mbstowcs(current_lc_all, ret, MAX_LOCALE_LENGTH)==-1)
2122 ret = NULL;
2123
2125 return ret ? current_lc_all : NULL;
2126}
void CDECL _lock_locales(void)
Definition: locale.c:574
void CDECL _unlock_locales(void)
Definition: locale.c:582
#define MAX_LOCALE_LENGTH
Definition: locale.c:42
return ret
Definition: mutex.c:146
GLenum GLsizei len
Definition: glext.h:6722
wcstombs
Definition: stdlib.h:1013
mbstowcs
Definition: stdlib.h:925
#define setlocale(n, s)
Definition: locale.h:46

Referenced by call_wsetlocale().

◆ localeconv()

_ACRTIMP struct lconv *__cdecl localeconv ( void  )

Definition at line 1004 of file locale.c.

1005{
1006 return get_locinfo()->lconv;
1007}
struct lconv * lconv
Definition: corecrt.h:301

Referenced by ftoes(), and ftofs().

◆ setlocale()

_ACRTIMP char *__cdecl setlocale ( int  category,
const char locale 
)

Definition at line 2035 of file locale.c.

2036{
2038 pthreadlocinfo locinfo = get_locinfo(), newlocinfo;
2039 int locale_flags;
2040
2042 return NULL;
2043
2044 if(!locale) {
2045 if(category == LC_ALL)
2046 return construct_lc_all(locinfo);
2047
2048 return locinfo->lc_category[category].locale;
2049 }
2050
2051 /* Make sure that locinfo is not updated by e.g. stricmp function */
2052 locale_flags = data->locale_flags;
2053 data->locale_flags |= LOCALE_THREAD;
2054 newlocinfo = create_locinfo(category, locale, locinfo);
2055 data->locale_flags = locale_flags;
2056 if(!newlocinfo) {
2057 WARN("%d %s failed\n", category, locale);
2058 return NULL;
2059 }
2060
2061 if(locale[0] != 'C' || locale[1] != '\0')
2063
2064 if(data->locale_flags & LOCALE_THREAD)
2065 {
2066 if(data->locale_flags & LOCALE_FREE)
2067 free_locinfo(data->locinfo);
2068 data->locinfo = newlocinfo;
2069 }
2070 else
2071 {
2072 int i;
2073
2074 _lock_locales();
2076 MSVCRT_locale->locinfo = newlocinfo;
2077
2078 MSVCRT___lc_codepage = newlocinfo->lc_codepage;
2079 MSVCRT___lc_collate_cp = newlocinfo->lc_collate_cp;
2080 MSVCRT___mb_cur_max = newlocinfo->mb_cur_max;
2081 MSVCRT__pctype = newlocinfo->pctype;
2082 for(i=LC_MIN; i<=LC_MAX; i++)
2086 }
2087
2088 if(category == LC_ALL)
2089 return construct_lc_all(data->locinfo);
2090
2091 return data->locinfo->lc_category[category].locale;
2092}
#define WARN(fmt,...)
Definition: precomp.h:61
#define FALSE
Definition: types.h:117
#define LC_MAX
Definition: locale.h:32
#define LC_MIN
Definition: locale.h:31
#define LC_ALL
Definition: locale.h:25
unsigned short * MSVCRT__pctype
Definition: locale.c:44
int MSVCRT___lc_collate_cp
Definition: locale.c:46
static void update_thread_locale(thread_data_t *data)
Definition: locale.c:609
unsigned int MSVCRT___lc_codepage
Definition: locale.c:45
static char * construct_lc_all(pthreadlocinfo locinfo)
Definition: locale.c:649
BOOL initial_locale
Definition: locale.c:49
LCID MSVCRT___lc_handle[LC_MAX - LC_MIN+1]
Definition: locale.c:47
int MSVCRT___mb_cur_max
Definition: locale.c:48
_locale_t MSVCRT_locale
Definition: locale.c:43
thread_data_t *CDECL msvcrt_get_thread_data(void)
Definition: ucrt_tls_sup.c:59
#define LOCALE_FREE
Definition: msvcrt.h:172
#define LOCALE_THREAD
Definition: msvcrt.h:173
else locinfo
Definition: scanf.h:225
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950