win32u: Move NtUserTranslateMessage implementation from user32.
[wine.git] / dlls / msvcrt / msvcrt.h
blob1d965ff8ffc04449217e291fa44ff7de6459e50b
1 /*
2 * Copyright 2001 Jon Griffiths
3 * Copyright 2004 Dimitrie O. Paun
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #ifndef __WINE_MSVCRT_H
21 #define __WINE_MSVCRT_H
23 #include <errno.h>
24 #include <stdarg.h>
25 #include <stdint.h>
26 #define _NO_CRT_STDIO_INLINE
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <wchar.h>
31 #include "windef.h"
32 #include "winbase.h"
33 #undef strncpy
34 #undef wcsncpy
36 extern BOOL sse2_supported DECLSPEC_HIDDEN;
38 #define DBL80_MAX_10_EXP 4932
39 #define DBL80_MIN_10_EXP -4951
41 typedef void (__cdecl *terminate_function)(void);
42 typedef void (__cdecl *unexpected_function)(void);
43 typedef void (__cdecl *_se_translator_function)(unsigned int code, struct _EXCEPTION_POINTERS *info);
44 void __cdecl terminate(void);
46 typedef void (__cdecl *MSVCRT_security_error_handler)(int, void *);
48 typedef struct {ULONG x80[3];} MSVCRT__LDOUBLE; /* Intel 80 bit FP format has sizeof() 12 */
50 typedef struct __lc_time_data {
51 union {
52 const char *str[43];
53 struct {
54 const char *short_wday[7];
55 const char *wday[7];
56 const char *short_mon[12];
57 const char *mon[12];
58 const char *am;
59 const char *pm;
60 const char *short_date;
61 const char *date;
62 const char *time;
63 } names;
64 } str;
65 #if _MSVCR_VER < 110
66 LCID lcid;
67 #endif
68 int unk;
69 LONG refcount;
70 #if _MSVCR_VER == 0 || _MSVCR_VER >= 100
71 union {
72 const wchar_t *wstr[43];
73 struct {
74 const wchar_t *short_wday[7];
75 const wchar_t *wday[7];
76 const wchar_t *short_mon[12];
77 const wchar_t *mon[12];
78 const wchar_t *am;
79 const wchar_t *pm;
80 const wchar_t *short_date;
81 const wchar_t *date;
82 const wchar_t *time;
83 } names;
84 } wstr;
85 #endif
86 #if _MSVCR_VER >= 110
87 const wchar_t *locname;
88 #endif
89 char data[1];
90 } __lc_time_data;
92 typedef struct threadmbcinfostruct {
93 LONG refcount;
94 int mbcodepage;
95 int ismbcodepage;
96 int mblcid;
97 unsigned short mbulinfo[6];
98 unsigned char mbctype[257];
99 unsigned char mbcasemap[256];
100 } threadmbcinfo;
102 typedef struct _frame_info
104 void *object;
105 struct _frame_info *next;
106 } frame_info;
108 typedef struct
110 frame_info frame_info;
111 EXCEPTION_RECORD *rec;
112 CONTEXT *context;
113 } cxx_frame_info;
115 frame_info* __cdecl _CreateFrameInfo(frame_info *fi, void *obj);
116 BOOL __cdecl __CxxRegisterExceptionObject(EXCEPTION_POINTERS*, cxx_frame_info*);
117 void __cdecl __CxxUnregisterExceptionObject(cxx_frame_info*, BOOL);
118 void CDECL __DestructExceptionObject(EXCEPTION_RECORD*);
120 /* TLS data */
121 extern DWORD msvcrt_tls_index DECLSPEC_HIDDEN;
123 #define LOCALE_FREE 0x1
124 #define LOCALE_THREAD 0x2
126 /* Keep in sync with msvcr90/tests/msvcr90.c */
127 struct __thread_data {
128 DWORD tid;
129 HANDLE handle;
130 int thread_errno;
131 __msvcrt_ulong thread_doserrno;
132 int unk1;
133 unsigned int random_seed; /* seed for rand() */
134 char *strtok_next; /* next ptr for strtok() */
135 wchar_t *wcstok_next; /* next ptr for wcstok() */
136 unsigned char *mbstok_next; /* next ptr for mbstok() */
137 char *strerror_buffer; /* buffer for strerror */
138 wchar_t *wcserror_buffer; /* buffer for wcserror */
139 char *tmpnam_buffer; /* buffer for tmpname() */
140 wchar_t *wtmpnam_buffer; /* buffer for wtmpname() */
141 void *unk2[2];
142 char *asctime_buffer; /* buffer for asctime */
143 wchar_t *wasctime_buffer; /* buffer for wasctime */
144 struct tm *time_buffer; /* buffer for localtime/gmtime */
145 char *efcvt_buffer; /* buffer for ecvt/fcvt */
146 int unk3[2];
147 void *unk4[3];
148 EXCEPTION_POINTERS *xcptinfo;
149 int fpecode;
150 pthreadmbcinfo mbcinfo;
151 pthreadlocinfo locinfo;
152 int locale_flags;
153 int unk5[1];
154 terminate_function terminate_handler;
155 unexpected_function unexpected_handler;
156 _se_translator_function se_translator; /* preserve offset to exc_record and processing_throw */
157 void *unk6;
158 EXCEPTION_RECORD *exc_record;
159 CONTEXT *ctx_record;
160 int processing_throw;
161 frame_info *frame_info_head;
162 void *unk8[6];
163 LCID cached_lcid;
164 BOOL cached_sname;
165 int unk9[2];
166 DWORD cached_cp;
167 char cached_locale[131];
168 void *unk10[100];
169 #if _MSVCR_VER >= 140
170 _invalid_parameter_handler invalid_parameter_handler;
171 HMODULE module;
172 #endif
175 typedef struct __thread_data thread_data_t;
177 extern thread_data_t *CDECL msvcrt_get_thread_data(void) DECLSPEC_HIDDEN;
179 LCID locale_to_LCID(const char*, unsigned short*, BOOL*) DECLSPEC_HIDDEN;
180 extern _locale_t MSVCRT_locale DECLSPEC_HIDDEN;
181 extern __lc_time_data cloc_time_data DECLSPEC_HIDDEN;
182 extern unsigned int MSVCRT___lc_codepage;
183 extern int MSVCRT___lc_collate_cp;
184 extern WORD MSVCRT__ctype [257];
185 extern BOOL initial_locale DECLSPEC_HIDDEN;
186 extern WORD *MSVCRT__pwctype;
188 void msvcrt_set_errno(int) DECLSPEC_HIDDEN;
189 #if _MSVCR_VER >= 80
190 void throw_bad_alloc(void) DECLSPEC_HIDDEN;
191 #endif
193 void __cdecl _purecall(void);
194 void __cdecl _amsg_exit(int errnum);
196 extern char **MSVCRT__environ;
197 extern wchar_t **MSVCRT__wenviron;
199 extern char ** msvcrt_SnapshotOfEnvironmentA(char **) DECLSPEC_HIDDEN;
200 extern wchar_t ** msvcrt_SnapshotOfEnvironmentW(wchar_t **) DECLSPEC_HIDDEN;
202 wchar_t *msvcrt_wstrdupa(const char *) DECLSPEC_HIDDEN;
204 extern unsigned int MSVCRT__commode;
206 /* FIXME: This should be declared in new.h but it's not an extern "C" so
207 * it would not be much use anyway. Even for Winelib applications.
209 void* __cdecl operator_new(size_t);
210 void __cdecl operator_delete(void*);
211 int __cdecl _set_new_mode(int mode);
213 typedef void* (__cdecl *malloc_func_t)(size_t);
214 typedef void (__cdecl *free_func_t)(void*);
216 /* Setup and teardown multi threaded locks */
217 extern void msvcrt_init_mt_locks(void) DECLSPEC_HIDDEN;
218 extern void msvcrt_free_locks(void) DECLSPEC_HIDDEN;
220 extern void msvcrt_init_exception(void*) DECLSPEC_HIDDEN;
221 extern BOOL msvcrt_init_locale(void) DECLSPEC_HIDDEN;
222 extern void msvcrt_init_math(void*) DECLSPEC_HIDDEN;
223 extern void msvcrt_init_io(void) DECLSPEC_HIDDEN;
224 extern void msvcrt_free_io(void) DECLSPEC_HIDDEN;
225 extern void msvcrt_free_console(void) DECLSPEC_HIDDEN;
226 extern void msvcrt_init_args(void) DECLSPEC_HIDDEN;
227 extern void msvcrt_free_args(void) DECLSPEC_HIDDEN;
228 extern void msvcrt_init_signals(void) DECLSPEC_HIDDEN;
229 extern void msvcrt_free_signals(void) DECLSPEC_HIDDEN;
230 extern void msvcrt_free_popen_data(void) DECLSPEC_HIDDEN;
231 extern BOOL msvcrt_init_heap(void) DECLSPEC_HIDDEN;
232 extern void msvcrt_destroy_heap(void) DECLSPEC_HIDDEN;
233 extern void msvcrt_init_clock(void) DECLSPEC_HIDDEN;
235 #if _MSVCR_VER >= 100
236 extern void msvcrt_init_concurrency(void*) DECLSPEC_HIDDEN;
237 extern void msvcrt_free_concurrency(void) DECLSPEC_HIDDEN;
238 extern void msvcrt_free_scheduler_thread(void) DECLSPEC_HIDDEN;
239 #endif
241 extern BOOL msvcrt_create_io_inherit_block(WORD*, BYTE**) DECLSPEC_HIDDEN;
243 /* run-time error codes */
244 #define _RT_STACK 0
245 #define _RT_NULLPTR 1
246 #define _RT_FLOAT 2
247 #define _RT_INTDIV 3
248 #define _RT_EXECMEM 5
249 #define _RT_EXECFORM 6
250 #define _RT_EXECENV 7
251 #define _RT_SPACEARG 8
252 #define _RT_SPACEENV 9
253 #define _RT_ABORT 10
254 #define _RT_NPTR 12
255 #define _RT_FPTR 13
256 #define _RT_BREAK 14
257 #define _RT_INT 15
258 #define _RT_THREAD 16
259 #define _RT_LOCK 17
260 #define _RT_HEAP 18
261 #define _RT_OPENCON 19
262 #define _RT_QWIN 20
263 #define _RT_NOMAIN 21
264 #define _RT_NONCONT 22
265 #define _RT_INVALDISP 23
266 #define _RT_ONEXIT 24
267 #define _RT_PUREVIRT 25
268 #define _RT_STDIOINIT 26
269 #define _RT_LOWIOINIT 27
270 #define _RT_HEAPINIT 28
271 #define _RT_DOMAIN 120
272 #define _RT_SING 121
273 #define _RT_TLOSS 122
274 #define _RT_CRNL 252
275 #define _RT_BANNER 255
277 extern FILE MSVCRT__iob[];
279 #define MSVCRT_NO_CONSOLE_FD (-2)
280 #define MSVCRT_NO_CONSOLE ((HANDLE)MSVCRT_NO_CONSOLE_FD)
282 #define MSVCRT_stdin (MSVCRT__iob+STDIN_FILENO)
283 #define MSVCRT_stdout (MSVCRT__iob+STDOUT_FILENO)
284 #define MSVCRT_stderr (MSVCRT__iob+STDERR_FILENO)
286 /* internal file._flag flags */
287 #define MSVCRT__USERBUF 0x0100
288 #define MSVCRT__IOCOMMIT 0x4000
290 #define _MAX__TIME64_T (((__time64_t)0x00000007 << 32) | 0x93406FFF)
292 _locale_t CDECL get_current_locale_noalloc(_locale_t locale) DECLSPEC_HIDDEN;
293 void CDECL free_locale_noalloc(_locale_t locale) DECLSPEC_HIDDEN;
294 pthreadlocinfo CDECL get_locinfo(void) DECLSPEC_HIDDEN;
295 pthreadmbcinfo CDECL get_mbcinfo(void) DECLSPEC_HIDDEN;
296 threadmbcinfo* create_mbcinfo(int, LCID, threadmbcinfo*) DECLSPEC_HIDDEN;
297 void free_locinfo(pthreadlocinfo) DECLSPEC_HIDDEN;
298 void free_mbcinfo(pthreadmbcinfo) DECLSPEC_HIDDEN;
299 int __cdecl __crtLCMapStringA(LCID, DWORD, const char*, int, char*, int, unsigned int, int) DECLSPEC_HIDDEN;
301 enum fpmod {
302 FP_ROUND_ZERO, /* only used when dropped part contains only zeros */
303 FP_ROUND_DOWN,
304 FP_ROUND_EVEN,
305 FP_ROUND_UP,
306 FP_VAL_INFINITY,
307 FP_VAL_NAN
310 struct fpnum {
311 int sign;
312 int exp;
313 ULONGLONG m;
314 enum fpmod mod;
316 struct fpnum fpnum_parse(wchar_t (*)(void*), void (*)(void*),
317 void*, pthreadlocinfo, BOOL) DECLSPEC_HIDDEN;
318 int fpnum_double(struct fpnum*, double*) DECLSPEC_HIDDEN;
319 /* Maybe one day we'll enable the invalid parameter handlers with the full set of information (msvcrXXd)
320 * #define MSVCRT_INVALID_PMT(x) MSVCRT_call_invalid_parameter_handler(x, __FUNCTION__, __FILE__, __LINE__, 0)
321 * #define MSVCRT_CHECK_PMT(x) ((x) ? TRUE : MSVCRT_INVALID_PMT(#x),FALSE)
322 * Until this is done, just keep the same semantics for CHECK_PMT(), but without generating / sending
323 * any information
324 * NB : MSVCRT_call_invalid_parameter_handler is a wrapper around _invalid_parameter in order
325 * to do the Ansi to Unicode transformation
327 #define MSVCRT_INVALID_PMT(x,err) (*_errno() = (err), _invalid_parameter(NULL, NULL, NULL, 0, 0))
328 #define MSVCRT_CHECK_PMT_ERR(x,err) ((x) || (MSVCRT_INVALID_PMT( 0, (err) ), FALSE))
329 #define MSVCRT_CHECK_PMT(x) MSVCRT_CHECK_PMT_ERR((x), EINVAL)
331 typedef int (*puts_clbk_a)(void*, int, const char*);
332 typedef int (*puts_clbk_w)(void*, int, const wchar_t*);
333 typedef union _printf_arg
335 void *get_ptr;
336 int get_int;
337 LONGLONG get_longlong;
338 double get_double;
339 } printf_arg;
340 typedef printf_arg (*args_clbk)(void*, int, int, va_list*);
341 int pf_printf_a(puts_clbk_a, void*, const char*, _locale_t,
342 DWORD, args_clbk, void*, va_list*) DECLSPEC_HIDDEN;
343 int pf_printf_w(puts_clbk_w, void*, const wchar_t*, _locale_t,
344 DWORD, args_clbk, void*, va_list*) DECLSPEC_HIDDEN;
345 int create_positional_ctx_a(void*, const char*, va_list) DECLSPEC_HIDDEN;
346 int create_positional_ctx_w(void*, const wchar_t*, va_list) DECLSPEC_HIDDEN;
347 printf_arg arg_clbk_valist(void*, int, int, va_list*) DECLSPEC_HIDDEN;
348 printf_arg arg_clbk_positional(void*, int, int, va_list*) DECLSPEC_HIDDEN;
350 extern char* __cdecl __unDName(char *,const char*,int,malloc_func_t,free_func_t,unsigned short int);
352 /* __unDName/__unDNameEx flags */
353 #define UNDNAME_COMPLETE (0x0000)
354 #define UNDNAME_NO_LEADING_UNDERSCORES (0x0001) /* Don't show __ in calling convention */
355 #define UNDNAME_NO_MS_KEYWORDS (0x0002) /* Don't show calling convention at all */
356 #define UNDNAME_NO_FUNCTION_RETURNS (0x0004) /* Don't show function/method return value */
357 #define UNDNAME_NO_ALLOCATION_MODEL (0x0008)
358 #define UNDNAME_NO_ALLOCATION_LANGUAGE (0x0010)
359 #define UNDNAME_NO_MS_THISTYPE (0x0020)
360 #define UNDNAME_NO_CV_THISTYPE (0x0040)
361 #define UNDNAME_NO_THISTYPE (0x0060)
362 #define UNDNAME_NO_ACCESS_SPECIFIERS (0x0080) /* Don't show access specifier (public/protected/private) */
363 #define UNDNAME_NO_THROW_SIGNATURES (0x0100)
364 #define UNDNAME_NO_MEMBER_TYPE (0x0200) /* Don't show static/virtual specifier */
365 #define UNDNAME_NO_RETURN_UDT_MODEL (0x0400)
366 #define UNDNAME_32_BIT_DECODE (0x0800)
367 #define UNDNAME_NAME_ONLY (0x1000) /* Only report the variable/method name */
368 #define UNDNAME_NO_ARGUMENTS (0x2000) /* Don't show method arguments */
369 #define UNDNAME_NO_SPECIAL_SYMS (0x4000)
370 #define UNDNAME_NO_COMPLEX_TYPE (0x8000)
372 #define UCRTBASE_PRINTF_MASK ( \
373 _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION | \
374 _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR | \
375 _CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS | \
376 _CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY | \
377 _CRT_INTERNAL_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS | \
378 _CRT_INTERNAL_PRINTF_STANDARD_ROUNDING )
380 #define MSVCRT_PRINTF_POSITIONAL_PARAMS (0x0100)
381 #define MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER (0x0200)
383 #define UCRTBASE_SCANF_MASK ( \
384 _CRT_INTERNAL_SCANF_SECURECRT | \
385 _CRT_INTERNAL_SCANF_LEGACY_WIDE_SPECIFIERS | \
386 _CRT_INTERNAL_SCANF_LEGACY_MSVCRT_COMPATIBILITY )
388 #define COOPERATIVE_TIMEOUT_INFINITE ((unsigned int)-1)
389 #define COOPERATIVE_WAIT_TIMEOUT ~0
391 #define INHERIT_THREAD_PRIORITY 0xF000
393 #endif /* __WINE_MSVCRT_H */