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
26 #define _NO_CRT_STDIO_INLINE
35 #define DBL80_MAX_10_EXP 4932
36 #define DBL80_MIN_10_EXP -4951
38 typedef void (__cdecl
*terminate_function
)(void);
39 typedef void (__cdecl
*unexpected_function
)(void);
40 typedef void (__cdecl
*_se_translator_function
)(unsigned int code
, struct _EXCEPTION_POINTERS
*info
);
41 void __cdecl
terminate(void);
43 typedef void (__cdecl
*MSVCRT_security_error_handler
)(int, void *);
45 typedef struct {ULONG x80
[3];} MSVCRT__LDOUBLE
; /* Intel 80 bit FP format has sizeof() 12 */
47 typedef struct __lc_time_data
{
51 const char *short_wday
[7];
53 const char *short_mon
[12];
57 const char *short_date
;
68 const wchar_t *wstr
[43];
70 const wchar_t *short_wday
[7];
71 const wchar_t *wday
[7];
72 const wchar_t *short_mon
[12];
73 const wchar_t *mon
[12];
76 const wchar_t *short_date
;
82 const wchar_t *locname
;
87 typedef struct threadmbcinfostruct
{
92 unsigned short mbulinfo
[6];
93 unsigned char mbctype
[257];
94 unsigned char mbcasemap
[256];
97 typedef struct _frame_info
100 struct _frame_info
*next
;
105 frame_info frame_info
;
106 EXCEPTION_RECORD
*rec
;
110 frame_info
* __cdecl
_CreateFrameInfo(frame_info
*fi
, void *obj
);
111 BOOL __cdecl
__CxxRegisterExceptionObject(EXCEPTION_POINTERS
*, cxx_frame_info
*);
112 void __cdecl
__CxxUnregisterExceptionObject(cxx_frame_info
*, BOOL
);
113 void CDECL
__DestructExceptionObject(EXCEPTION_RECORD
*);
116 extern DWORD msvcrt_tls_index DECLSPEC_HIDDEN
;
118 #define LOCALE_FREE 0x1
119 #define LOCALE_THREAD 0x2
121 /* Keep in sync with msvcr90/tests/msvcr90.c */
122 struct __thread_data
{
126 __msvcrt_ulong thread_doserrno
;
128 unsigned int random_seed
; /* seed for rand() */
129 char *strtok_next
; /* next ptr for strtok() */
130 wchar_t *wcstok_next
; /* next ptr for wcstok() */
131 unsigned char *mbstok_next
; /* next ptr for mbstok() */
132 char *strerror_buffer
; /* buffer for strerror */
133 wchar_t *wcserror_buffer
; /* buffer for wcserror */
134 char *tmpnam_buffer
; /* buffer for tmpname() */
135 wchar_t *wtmpnam_buffer
; /* buffer for wtmpname() */
137 char *asctime_buffer
; /* buffer for asctime */
138 wchar_t *wasctime_buffer
; /* buffer for wasctime */
139 struct tm
*time_buffer
; /* buffer for localtime/gmtime */
140 char *efcvt_buffer
; /* buffer for ecvt/fcvt */
143 EXCEPTION_POINTERS
*xcptinfo
;
145 pthreadmbcinfo mbcinfo
;
146 pthreadlocinfo locinfo
;
149 terminate_function terminate_handler
;
150 unexpected_function unexpected_handler
;
151 _se_translator_function se_translator
; /* preserve offset to exc_record and processing_throw */
153 EXCEPTION_RECORD
*exc_record
;
155 int processing_throw
;
156 frame_info
*frame_info_head
;
162 char cached_locale
[131];
164 #if _MSVCR_VER >= 140
165 _invalid_parameter_handler invalid_parameter_handler
;
169 typedef struct __thread_data thread_data_t
;
171 extern thread_data_t
*CDECL
msvcrt_get_thread_data(void) DECLSPEC_HIDDEN
;
173 LCID
locale_to_LCID(const char*, unsigned short*, BOOL
*) DECLSPEC_HIDDEN
;
174 extern _locale_t MSVCRT_locale DECLSPEC_HIDDEN
;
175 extern __lc_time_data cloc_time_data DECLSPEC_HIDDEN
;
176 extern unsigned int MSVCRT___lc_codepage
;
177 extern int MSVCRT___lc_collate_cp
;
178 extern WORD MSVCRT__ctype
[257];
179 extern BOOL initial_locale DECLSPEC_HIDDEN
;
180 extern WORD
*MSVCRT__pwctype
;
182 void msvcrt_set_errno(int) DECLSPEC_HIDDEN
;
186 #if _MSVCR_VER >= 100
187 EXCEPTION_SCHEDULER_RESOURCE_ALLOCATION_ERROR
,
188 EXCEPTION_IMPROPER_LOCK
,
189 EXCEPTION_INVALID_SCHEDULER_POLICY_KEY
,
190 EXCEPTION_INVALID_SCHEDULER_POLICY_VALUE
,
191 EXCEPTION_INVALID_SCHEDULER_POLICY_THREAD_SPECIFICATION
,
192 EXCEPTION_IMPROPER_SCHEDULER_ATTACH
,
193 EXCEPTION_IMPROPER_SCHEDULER_DETACH
,
196 void throw_exception(exception_type
, HRESULT
, const char*) DECLSPEC_HIDDEN
;
199 void __cdecl
_purecall(void);
200 void __cdecl
_amsg_exit(int errnum
);
202 extern char **MSVCRT__environ
;
203 extern wchar_t **MSVCRT__wenviron
;
205 extern char ** msvcrt_SnapshotOfEnvironmentA(char **) DECLSPEC_HIDDEN
;
206 extern wchar_t ** msvcrt_SnapshotOfEnvironmentW(wchar_t **) DECLSPEC_HIDDEN
;
208 wchar_t *msvcrt_wstrdupa(const char *) DECLSPEC_HIDDEN
;
210 extern unsigned int MSVCRT__commode
;
212 /* FIXME: This should be declared in new.h but it's not an extern "C" so
213 * it would not be much use anyway. Even for Winelib applications.
215 void* __cdecl
operator_new(size_t);
216 void __cdecl
operator_delete(void*);
217 int __cdecl
_set_new_mode(int mode
);
219 typedef void* (__cdecl
*malloc_func_t
)(size_t);
220 typedef void (__cdecl
*free_func_t
)(void*);
222 /* Setup and teardown multi threaded locks */
223 extern void msvcrt_init_mt_locks(void) DECLSPEC_HIDDEN
;
224 extern void msvcrt_free_locks(void) DECLSPEC_HIDDEN
;
226 extern void msvcrt_init_exception(void*) DECLSPEC_HIDDEN
;
227 extern BOOL
msvcrt_init_locale(void) DECLSPEC_HIDDEN
;
228 extern void msvcrt_init_math(void*) DECLSPEC_HIDDEN
;
229 extern void msvcrt_init_io(void) DECLSPEC_HIDDEN
;
230 extern void msvcrt_free_io(void) DECLSPEC_HIDDEN
;
231 extern void msvcrt_init_console(void) DECLSPEC_HIDDEN
;
232 extern void msvcrt_free_console(void) DECLSPEC_HIDDEN
;
233 extern void msvcrt_init_args(void) DECLSPEC_HIDDEN
;
234 extern void msvcrt_free_args(void) DECLSPEC_HIDDEN
;
235 extern void msvcrt_init_signals(void) DECLSPEC_HIDDEN
;
236 extern void msvcrt_free_signals(void) DECLSPEC_HIDDEN
;
237 extern void msvcrt_free_popen_data(void) DECLSPEC_HIDDEN
;
238 extern BOOL
msvcrt_init_heap(void) DECLSPEC_HIDDEN
;
239 extern void msvcrt_destroy_heap(void) DECLSPEC_HIDDEN
;
240 extern void msvcrt_init_clock(void) DECLSPEC_HIDDEN
;
242 #if _MSVCR_VER >= 100
243 extern void msvcrt_init_scheduler(void*) DECLSPEC_HIDDEN
;
244 extern void msvcrt_free_scheduler(void) DECLSPEC_HIDDEN
;
245 extern void msvcrt_free_scheduler_thread(void) DECLSPEC_HIDDEN
;
248 extern unsigned msvcrt_create_io_inherit_block(WORD
*, BYTE
**) DECLSPEC_HIDDEN
;
250 /* run-time error codes */
252 #define _RT_NULLPTR 1
255 #define _RT_EXECMEM 5
256 #define _RT_EXECFORM 6
257 #define _RT_EXECENV 7
258 #define _RT_SPACEARG 8
259 #define _RT_SPACEENV 9
265 #define _RT_THREAD 16
268 #define _RT_OPENCON 19
270 #define _RT_NOMAIN 21
271 #define _RT_NONCONT 22
272 #define _RT_INVALDISP 23
273 #define _RT_ONEXIT 24
274 #define _RT_PUREVIRT 25
275 #define _RT_STDIOINIT 26
276 #define _RT_LOWIOINIT 27
277 #define _RT_HEAPINIT 28
278 #define _RT_DOMAIN 120
280 #define _RT_TLOSS 122
282 #define _RT_BANNER 255
284 extern FILE MSVCRT__iob
[];
286 #define MSVCRT_RAND_MAX 0x7fff
288 #define MSVCRT_NO_CONSOLE_FD (-2)
289 #define MSVCRT_NO_CONSOLE ((HANDLE)MSVCRT_NO_CONSOLE_FD)
291 #define MSVCRT_DRIVE_MAX 3
292 #define MSVCRT_FNAME_MAX 256
293 #define MSVCRT_DIR_MAX 256
294 #define MSVCRT_EXT_MAX 256
295 #define MSVCRT_PATH_MAX 260
296 #define MSVCRT_stdin (MSVCRT__iob+STDIN_FILENO)
297 #define MSVCRT_stdout (MSVCRT__iob+STDOUT_FILENO)
298 #define MSVCRT_stderr (MSVCRT__iob+STDERR_FILENO)
300 #define MSVCRT__P_WAIT 0
301 #define MSVCRT__P_NOWAIT 1
302 #define MSVCRT__P_OVERLAY 2
303 #define MSVCRT__P_NOWAITO 3
304 #define MSVCRT__P_DETACH 4
306 #define MSVCRT__OUT_TO_DEFAULT 0
307 #define MSVCRT__OUT_TO_STDERR 1
308 #define MSVCRT__OUT_TO_MSGBOX 2
309 #define MSVCRT__REPORT_ERRMODE 3
311 /* internal file._flag flags */
312 #define MSVCRT__USERBUF 0x0100
313 #define MSVCRT__IOCOMMIT 0x4000
315 #define MSVCRT__S_IEXEC 0x0040
316 #define MSVCRT__S_IWRITE 0x0080
317 #define MSVCRT__S_IREAD 0x0100
318 #define MSVCRT__S_IFIFO 0x1000
319 #define MSVCRT__S_IFCHR 0x2000
320 #define MSVCRT__S_IFDIR 0x4000
321 #define MSVCRT__S_IFREG 0x8000
322 #define MSVCRT__S_IFMT 0xF000
324 #define MSVCRT__LK_UNLCK 0
325 #define MSVCRT__LK_LOCK 1
326 #define MSVCRT__LK_NBLCK 2
327 #define MSVCRT__LK_RLCK 3
328 #define MSVCRT__LK_NBRLCK 4
330 #define MSVCRT__SH_COMPAT 0x00 /* Compatibility */
331 #define MSVCRT__SH_DENYRW 0x10 /* Deny read/write */
332 #define MSVCRT__SH_DENYWR 0x20 /* Deny write */
333 #define MSVCRT__SH_DENYRD 0x30 /* Deny read */
334 #define MSVCRT__SH_DENYNO 0x40 /* Deny nothing */
336 #define MSVCRT__O_RDONLY 0
337 #define MSVCRT__O_WRONLY 1
338 #define MSVCRT__O_RDWR 2
339 #define MSVCRT__O_ACCMODE (MSVCRT__O_RDONLY|MSVCRT__O_WRONLY|MSVCRT__O_RDWR)
340 #define MSVCRT__O_APPEND 0x0008
341 #define MSVCRT__O_RANDOM 0x0010
342 #define MSVCRT__O_SEQUENTIAL 0x0020
343 #define MSVCRT__O_TEMPORARY 0x0040
344 #define MSVCRT__O_NOINHERIT 0x0080
345 #define MSVCRT__O_CREAT 0x0100
346 #define MSVCRT__O_TRUNC 0x0200
347 #define MSVCRT__O_EXCL 0x0400
348 #define MSVCRT__O_SHORT_LIVED 0x1000
349 #define MSVCRT__O_TEXT 0x4000
350 #define MSVCRT__O_BINARY 0x8000
351 #define MSVCRT__O_RAW MSVCRT__O_BINARY
352 #define MSVCRT__O_WTEXT 0x10000
353 #define MSVCRT__O_U16TEXT 0x20000
354 #define MSVCRT__O_U8TEXT 0x40000
356 #define MSVCRT_CLOCKS_PER_SEC 1000
358 #define MSVCRT__TRUNCATE ((size_t)-1)
360 #define _MAX__TIME64_T (((__time64_t)0x00000007 << 32) | 0x93406FFF)
362 /* _set_abort_behavior codes */
363 #define MSVCRT__WRITE_ABORT_MSG 1
364 #define MSVCRT__CALL_REPORTFAULT 2
366 /* _get_output_format return code */
367 #define MSVCRT__TWO_DIGIT_EXPONENT 0x1
369 #define MSVCRT__NLSCMPERROR ((unsigned int)0x7fffffff)
371 int __cdecl
MSVCRT_iswdigit(wint_t);
373 int __cdecl
MSVCRT__fgetc_nolock(FILE*);
374 int __cdecl
MSVCRT__fputc_nolock(int,FILE*);
375 int __cdecl
MSVCRT__ungetc_nolock(int,FILE*);
376 wint_t __cdecl
MSVCRT__fgetwc_nolock(FILE*);
377 wint_t __cdecl
MSVCRT__fputwc_nolock(wint_t,FILE*);
378 wint_t __cdecl
MSVCRT__ungetwc_nolock(wint_t, FILE*);
379 int __cdecl
MSVCRT__fseeki64_nolock(FILE*,__int64
,int);
380 __int64 __cdecl
MSVCRT__ftelli64(FILE* file
);
381 __int64 __cdecl
MSVCRT__ftelli64_nolock(FILE*);
382 size_t __cdecl
MSVCRT__fread_nolock(void*,size_t,size_t,FILE*);
383 size_t __cdecl
MSVCRT__fread_nolock_s(void*,size_t,size_t,size_t,FILE*);
384 size_t __cdecl
MSVCRT__fwrite_nolock(const void*,size_t,size_t,FILE*);
385 int __cdecl
MSVCRT__fclose_nolock(FILE*);
386 int __cdecl
MSVCRT__fflush_nolock(FILE*);
387 FILE* __cdecl
MSVCRT__iob_func(void);
388 __time32_t __cdecl
MSVCRT__time32(__time32_t
*);
389 __time64_t __cdecl
MSVCRT__time64(__time64_t
*);
390 FILE* __cdecl
MSVCRT__fdopen(int, const char *);
392 #define MSVCRT__ENABLE_PER_THREAD_LOCALE 1
393 #define MSVCRT__DISABLE_PER_THREAD_LOCALE 2
395 _locale_t CDECL
get_current_locale_noalloc(_locale_t locale
) DECLSPEC_HIDDEN
;
396 void CDECL
free_locale_noalloc(_locale_t locale
) DECLSPEC_HIDDEN
;
397 pthreadlocinfo CDECL
get_locinfo(void) DECLSPEC_HIDDEN
;
398 pthreadmbcinfo CDECL
get_mbcinfo(void) DECLSPEC_HIDDEN
;
399 threadmbcinfo
* create_mbcinfo(int, LCID
, threadmbcinfo
*) DECLSPEC_HIDDEN
;
400 void free_locinfo(pthreadlocinfo
) DECLSPEC_HIDDEN
;
401 void free_mbcinfo(pthreadmbcinfo
) DECLSPEC_HIDDEN
;
402 int __cdecl
__crtLCMapStringA(LCID
, DWORD
, const char*, int, char*, int, unsigned int, int) DECLSPEC_HIDDEN
;
404 int __cdecl
_getch(void);
405 int __cdecl
_ismbblead(unsigned int);
406 int __cdecl
_ismbblead_l(unsigned int, _locale_t
);
407 int __cdecl
_ismbclegal(unsigned int c
);
408 int __cdecl
_ismbstrail(const unsigned char* start
, const unsigned char* str
);
409 void __cdecl
MSVCRT__searchenv(const char*,const char*,char*);
410 char* __cdecl
_strset(char*,int);
411 int __cdecl
_ungetch(int);
412 int __cdecl
_cputs(const char*);
413 int WINAPIV
_cprintf(const char*,...);
414 int WINAPIV
_cwprintf(const wchar_t*,...);
415 char*** __cdecl
MSVCRT___p__environ(void);
416 int* __cdecl
__p___mb_cur_max(void);
417 wchar_t*** __cdecl
MSVCRT___p__wenviron(void);
418 char* __cdecl
MSVCRT__strdate(char* date
);
419 char* __cdecl
MSVCRT__strtime(char* date
);
420 int __cdecl
_setmbcp(int);
421 void __cdecl
MSVCRT__wsearchenv(const wchar_t*, const wchar_t*, wchar_t*);
422 int __cdecl
MSVCRT__towupper_l(wint_t,_locale_t
);
423 int __cdecl
MSVCRT__towlower_l(wint_t,_locale_t
);
424 int __cdecl
MSVCRT_strcmp(const char*, const char*);
425 char* __cdecl
MSVCRT__itoa(int, char*, int);
427 float __cdecl
MSVCRT_floorf( float x
);
428 double __cdecl
MSVCRT_sqrt( double x
);
429 float __cdecl
MSVCRT_sqrtf( float x
);
432 FP_ROUND_ZERO
, /* only used when dropped part contains only zeros */
446 struct fpnum
fpnum_parse(wchar_t (*)(void*), void (*)(void*),
447 void*, pthreadlocinfo
, BOOL
) DECLSPEC_HIDDEN
;
448 int fpnum_double(struct fpnum
*, double*) DECLSPEC_HIDDEN
;
449 /* Maybe one day we'll enable the invalid parameter handlers with the full set of information (msvcrXXd)
450 * #define MSVCRT_INVALID_PMT(x) MSVCRT_call_invalid_parameter_handler(x, __FUNCTION__, __FILE__, __LINE__, 0)
451 * #define MSVCRT_CHECK_PMT(x) ((x) ? TRUE : MSVCRT_INVALID_PMT(#x),FALSE)
452 * Until this is done, just keep the same semantics for CHECK_PMT(), but without generating / sending
454 * NB : MSVCRT_call_invalid_parameter_handler is a wrapper around _invalid_parameter in order
455 * to do the Ansi to Unicode transformation
457 #define MSVCRT_INVALID_PMT(x,err) (*_errno() = (err), _invalid_parameter(NULL, NULL, NULL, 0, 0))
458 #define MSVCRT_CHECK_PMT_ERR(x,err) ((x) || (MSVCRT_INVALID_PMT( 0, (err) ), FALSE))
459 #define MSVCRT_CHECK_PMT(x) MSVCRT_CHECK_PMT_ERR((x), EINVAL)
461 typedef int (*puts_clbk_a
)(void*, int, const char*);
462 typedef int (*puts_clbk_w
)(void*, int, const wchar_t*);
463 typedef union _printf_arg
467 LONGLONG get_longlong
;
470 typedef printf_arg (*args_clbk
)(void*, int, int, __ms_va_list
*);
471 int pf_printf_a(puts_clbk_a
, void*, const char*, _locale_t
,
472 DWORD
, args_clbk
, void*, __ms_va_list
*) DECLSPEC_HIDDEN
;
473 int pf_printf_w(puts_clbk_w
, void*, const wchar_t*, _locale_t
,
474 DWORD
, args_clbk
, void*, __ms_va_list
*) DECLSPEC_HIDDEN
;
475 int create_positional_ctx_a(void*, const char*, __ms_va_list
) DECLSPEC_HIDDEN
;
476 int create_positional_ctx_w(void*, const wchar_t*, __ms_va_list
) DECLSPEC_HIDDEN
;
477 printf_arg
arg_clbk_valist(void*, int, int, __ms_va_list
*) DECLSPEC_HIDDEN
;
478 printf_arg
arg_clbk_positional(void*, int, int, __ms_va_list
*) DECLSPEC_HIDDEN
;
480 extern char* __cdecl
__unDName(char *,const char*,int,malloc_func_t
,free_func_t
,unsigned short int);
482 /* __unDName/__unDNameEx flags */
483 #define UNDNAME_COMPLETE (0x0000)
484 #define UNDNAME_NO_LEADING_UNDERSCORES (0x0001) /* Don't show __ in calling convention */
485 #define UNDNAME_NO_MS_KEYWORDS (0x0002) /* Don't show calling convention at all */
486 #define UNDNAME_NO_FUNCTION_RETURNS (0x0004) /* Don't show function/method return value */
487 #define UNDNAME_NO_ALLOCATION_MODEL (0x0008)
488 #define UNDNAME_NO_ALLOCATION_LANGUAGE (0x0010)
489 #define UNDNAME_NO_MS_THISTYPE (0x0020)
490 #define UNDNAME_NO_CV_THISTYPE (0x0040)
491 #define UNDNAME_NO_THISTYPE (0x0060)
492 #define UNDNAME_NO_ACCESS_SPECIFIERS (0x0080) /* Don't show access specifier (public/protected/private) */
493 #define UNDNAME_NO_THROW_SIGNATURES (0x0100)
494 #define UNDNAME_NO_MEMBER_TYPE (0x0200) /* Don't show static/virtual specifier */
495 #define UNDNAME_NO_RETURN_UDT_MODEL (0x0400)
496 #define UNDNAME_32_BIT_DECODE (0x0800)
497 #define UNDNAME_NAME_ONLY (0x1000) /* Only report the variable/method name */
498 #define UNDNAME_NO_ARGUMENTS (0x2000) /* Don't show method arguments */
499 #define UNDNAME_NO_SPECIAL_SYMS (0x4000)
500 #define UNDNAME_NO_COMPLEX_TYPE (0x8000)
502 #define UCRTBASE_PRINTF_MASK ( \
503 _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION | \
504 _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR | \
505 _CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS | \
506 _CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY | \
507 _CRT_INTERNAL_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS | \
508 _CRT_INTERNAL_PRINTF_STANDARD_ROUNDING )
510 #define MSVCRT_PRINTF_POSITIONAL_PARAMS (0x0100)
511 #define MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER (0x0200)
513 #define UCRTBASE_SCANF_MASK ( \
514 _CRT_INTERNAL_SCANF_SECURECRT | \
515 _CRT_INTERNAL_SCANF_LEGACY_WIDE_SPECIFIERS | \
516 _CRT_INTERNAL_SCANF_LEGACY_MSVCRT_COMPATIBILITY )
518 #define COOPERATIVE_TIMEOUT_INFINITE ((unsigned int)-1)
519 #define COOPERATIVE_WAIT_TIMEOUT ~0
521 #define INHERIT_THREAD_PRIORITY 0xF000
523 #endif /* __WINE_MSVCRT_H */