ReactOS 0.4.16-dev-1025-gd3456f5
timeset.cpp
Go to the documentation of this file.
1//
2// timeset.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// The time zone values for the default time zone, and other global time data.
7//
9
10#undef _daylight
11#undef _dstbias
12#undef _timezone
13#undef _tzname
14
15
16
17__crt_state_management::dual_state_global<long> _timezone; // Pacific Time Zone
18__crt_state_management::dual_state_global<int> _daylight; // Daylight Saving Time (DST) in timezone
19__crt_state_management::dual_state_global<long> _dstbias; // DST offset in seconds
20
21// Note that NT POSIX's TZNAME_MAX is only 10.
22
23#define _PST_STRING "PST"
24#define _PDT_STRING "PDT"
25
26#define L_PST_STRING L"PST"
27#define L_PDT_STRING L"PDT"
28
31
34
35#ifdef _CRT_GLOBAL_STATE_ISOLATION
36 static char tzstd_os[_TZ_STRINGS_SIZE] = { _PST_STRING };
37 static char tzdst_os[_TZ_STRINGS_SIZE] = { _PDT_STRING };
38
39 static wchar_t w_tzstd_os[_TZ_STRINGS_SIZE] = { L_PST_STRING };
40 static wchar_t w_tzdst_os[_TZ_STRINGS_SIZE] = { L_PDT_STRING };
41#endif
42
43static char* tzname_states[__crt_state_management::state_index_count][2] =
44{
46 #ifdef _CRT_GLOBAL_STATE_ISOLATION
47 { tzstd_os, tzdst_os }
48 #endif
49};
50
51static wchar_t* w_tzname_states[__crt_state_management::state_index_count][2] =
52{
54 #ifdef _CRT_GLOBAL_STATE_ISOLATION
55 { w_tzstd_os, w_tzdst_os }
56 #endif
57};
58
59static __crt_state_management::dual_state_global<char **> _tzname;
60static __crt_state_management::dual_state_global<wchar_t **> w_tzname;
61
62// Initializer for the timeset globals:
63_CRT_LINKER_FORCE_INCLUDE(__acrt_timeset_initializer);
64
66{
67 _timezone.initialize(8 * 3600L);
68 _daylight.initialize(1);
69 _dstbias.initialize (-3600);
70
71 char*** const first_state = _tzname.dangerous_get_state_array();
72 for (unsigned i = 0; i != __crt_state_management::state_index_count; ++i)
73 {
74 first_state[i] = tzname_states[i];
75 }
76
77 wchar_t*** const w_first_state = w_tzname.dangerous_get_state_array();
78 for (unsigned i = 0; i != __crt_state_management::state_index_count; ++i)
79 {
80 w_first_state[i] = w_tzname_states[i];
81 }
82
83 return 0;
84}
85
86extern "C" errno_t __cdecl _get_daylight(int* const result)
87{
89
90 // This variable is correctly inited at startup, so no need to check if
91 // CRT init finished.
92 *result = _daylight.value();
93 return 0;
94}
95
97{
99
100 // This variable is correctly inited at startup, so no need to check if
101 // CRT init finished.
102 *result = _dstbias.value();
103 return 0;
104}
105
107{
109
110 // This variable is correctly inited at startup, so no need to check if
111 // CRT init finished.
112 *result = _timezone.value();
113 return 0;
114}
115
117 size_t* const length,
118 char* const buffer,
119 size_t const size_in_bytes,
120 int const index)
121{
123 (buffer != nullptr && size_in_bytes > 0) ||
124 (buffer == nullptr && size_in_bytes == 0),
125 EINVAL);
126
127 if (buffer != nullptr)
128 buffer[0] = '\0';
129
132
133 // _tzname is correctly inited at startup, so no need to check if
134 // CRT init finished.
135 *length = strlen(_tzname.value()[index]) + 1;
136
137 // If the buffer pointer is null, the caller is interested only in the size
138 // of the string, not in the actual value of the string:
139 if (buffer == nullptr)
140 return 0;
141
142 if (*length > size_in_bytes)
143 return ERANGE;
144
145 return strcpy_s(buffer, size_in_bytes, _tzname.value()[index]);
146}
147
148
149
150// Day names must be three character abbreviations strung together
151extern "C" const char __dnames[] =
152{
153 "SunMonTueWedThuFriSat"
154};
155
156// Month names must be three character abbreviations strung together
157extern "C" const char __mnames[] =
158{
159 "JanFebMarAprMayJunJulAugSepOctNovDec"
160};
161
162
163
164// Accessors for the global time data
165extern "C" int* __cdecl __daylight()
166{
167 return &_daylight.value();
168}
169
170extern "C" long* __cdecl __dstbias()
171{
172 return &_dstbias.value();
173}
174
175extern "C" long* __cdecl __timezone()
176{
177 return &_timezone.value();
178}
179
180extern "C" char** __cdecl __tzname()
181{
182 return _tzname.value();
183}
184
185extern "C" wchar_t** __cdecl __wide_tzname()
186{
187 return w_tzname.value();
188}
#define EINVAL
Definition: acclib.h:90
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ERANGE
Definition: acclib.h:92
#define __cdecl
Definition: accygwin.h:79
#define _CRT_LINKER_FORCE_INCLUDE(name)
#define _TZ_STRINGS_SIZE
GLuint buffer
Definition: glext.h:5915
GLuint index
Definition: glext.h:6031
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLuint64EXT * result
Definition: glext.h:11304
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
#define _VALIDATE_RETURN_ERRCODE(expr, errorcode)
#define strcpy_s(d, l, s)
Definition: utility.h:200
#define _PDT_STRING
Definition: timeset.cpp:24
static wchar_t w_tzstd_program[_TZ_STRINGS_SIZE]
Definition: timeset.cpp:32
errno_t __cdecl _get_dstbias(long *result)
Definition: timeset.cpp:96
__crt_state_management::dual_state_global< long > _dstbias
Definition: timeset.cpp:19
static __crt_state_management::dual_state_global< char ** > _tzname
Definition: timeset.cpp:59
__crt_state_management::dual_state_global< int > _daylight
Definition: timeset.cpp:18
static wchar_t * w_tzname_states[__crt_state_management::state_index_count][2]
Definition: timeset.cpp:51
static char tzdst_program[_TZ_STRINGS_SIZE]
Definition: timeset.cpp:30
#define L_PDT_STRING
Definition: timeset.cpp:27
const char __dnames[]
Definition: timeset.cpp:151
errno_t __cdecl _get_timezone(long *result)
Definition: timeset.cpp:106
#define _PST_STRING
Definition: timeset.cpp:23
static char * tzname_states[__crt_state_management::state_index_count][2]
Definition: timeset.cpp:43
static wchar_t w_tzdst_program[_TZ_STRINGS_SIZE]
Definition: timeset.cpp:33
errno_t __cdecl _get_daylight(int *const result)
Definition: timeset.cpp:86
int __cdecl __acrt_initialize_timeset()
Definition: timeset.cpp:65
const char __mnames[]
Definition: timeset.cpp:157
int *__cdecl __daylight()
Definition: timeset.cpp:165
#define L_PST_STRING
Definition: timeset.cpp:26
long *__cdecl __dstbias()
Definition: timeset.cpp:170
static char tzstd_program[_TZ_STRINGS_SIZE]
Definition: timeset.cpp:29
char **__cdecl __tzname()
Definition: timeset.cpp:180
static __crt_state_management::dual_state_global< wchar_t ** > w_tzname
Definition: timeset.cpp:60
wchar_t **__cdecl __wide_tzname()
Definition: timeset.cpp:185
errno_t __cdecl _get_tzname(size_t *const length, char *const buffer, size_t const size_in_bytes, int const index)
Definition: timeset.cpp:116
long *__cdecl __timezone()
Definition: timeset.cpp:175
__crt_state_management::dual_state_global< long > _timezone
Definition: timeset.cpp:17
int errno_t
Definition: corecrt.h:615