msvcrt: Use callback based printf in fprintf functions family.
[wine] / dlls / msvcrt / msvcrt.h
1 /*
2  * Copyright 2001 Jon Griffiths
3  * Copyright 2004 Dimitrie O. Paun
4  *
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.
9  *
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.
14  *
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
18  *
19  * NOTES
20  *   Naming conventions
21  *      - Symbols are prefixed with MSVCRT_ if they conflict
22  *        with libc symbols
23  *      - Internal symbols are usually prefixed by msvcrt_.
24  *      - Exported symbols that are not present in the public
25  *        headers are usually kept the same as the original.
26  *   Other conventions
27  *      - To avoid conflicts with the standard C library,
28  *        no msvcrt headers are included in the implementation.
29  *      - Instead, symbols are duplicated here, prefixed with 
30  *        MSVCRT_, as explained above.
31  *      - To avoid inconsistencies, a test for each symbol is
32  *        added into tests/headers.c. Please always add a
33  *        corresponding test when you add a new symbol!
34  */
35
36 #ifndef __WINE_MSVCRT_H
37 #define __WINE_MSVCRT_H
38
39 #include <stdarg.h>
40
41 #include "windef.h"
42 #include "winbase.h"
43
44 #define MSVCRT_LONG_MAX    0x7fffffffL
45 #define MSVCRT_ULONG_MAX   0xffffffffUL
46 #define MSVCRT_I64_MAX    (((__int64)0x7fffffff << 32) | 0xffffffff)
47 #define MSVCRT_I64_MIN    (-MSVCRT_I64_MAX-1)
48 #define MSVCRT_UI64_MAX   (((unsigned __int64)0xffffffff << 32) | 0xffffffff)
49
50 #define MSVCRT__MAX_DRIVE  3
51 #define MSVCRT__MAX_DIR    256
52 #define MSVCRT__MAX_FNAME  256
53 #define MSVCRT__MAX_EXT    256
54
55 typedef unsigned short MSVCRT_wchar_t;
56 typedef unsigned short MSVCRT_wint_t;
57 typedef unsigned short MSVCRT_wctype_t;
58 typedef unsigned short MSVCRT__ino_t;
59 typedef unsigned int   MSVCRT__fsize_t;
60 typedef int            MSVCRT_long;
61 typedef unsigned int   MSVCRT_ulong;
62 #ifdef _WIN64
63 typedef unsigned __int64 MSVCRT_size_t;
64 typedef __int64 MSVCRT_intptr_t;
65 typedef unsigned __int64 MSVCRT_uintptr_t;
66 #else
67 typedef unsigned long MSVCRT_size_t;
68 typedef long MSVCRT_intptr_t;
69 typedef unsigned long MSVCRT_uintptr_t;
70 #endif
71 typedef unsigned int   MSVCRT__dev_t;
72 typedef int MSVCRT__off_t;
73 typedef int MSVCRT_clock_t;
74 typedef int MSVCRT___time32_t;
75 typedef __int64 DECLSPEC_ALIGN(8) MSVCRT___time64_t;
76 typedef __int64 DECLSPEC_ALIGN(8) MSVCRT_fpos_t;
77
78 typedef void (*__cdecl MSVCRT_terminate_handler)(void);
79 typedef void (*__cdecl MSVCRT_terminate_function)(void);
80 typedef void (*__cdecl MSVCRT_unexpected_handler)(void);
81 typedef void (*__cdecl MSVCRT_unexpected_function)(void);
82 typedef void (*__cdecl MSVCRT__se_translator_function)(unsigned int code, struct _EXCEPTION_POINTERS *info);
83 typedef void (*__cdecl MSVCRT__beginthread_start_routine_t)(void *);
84 typedef unsigned int (__stdcall *MSVCRT__beginthreadex_start_routine_t)(void *);
85 typedef int (*__cdecl MSVCRT__onexit_t)(void);
86 typedef void (__cdecl *MSVCRT_invalid_parameter_handler)(const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, unsigned, MSVCRT_uintptr_t);
87 typedef void (__cdecl *MSVCRT_purecall_handler)(void);
88 typedef void (__cdecl *MSVCRT_security_error_handler)(int, void *);
89
90 typedef struct {ULONG x80[3];} MSVCRT__LDOUBLE; /* Intel 80 bit FP format has sizeof() 12 */
91
92 struct MSVCRT_tm {
93     int tm_sec;
94     int tm_min;
95     int tm_hour;
96     int tm_mday;
97     int tm_mon;
98     int tm_year;
99     int tm_wday;
100     int tm_yday;
101     int tm_isdst;
102 };
103
104
105 /* TLS data */
106 extern DWORD msvcrt_tls_index;
107
108 struct __thread_data {
109     int                             thread_errno;
110     MSVCRT_ulong                    thread_doserrno;
111     unsigned int                    random_seed;        /* seed for rand() */
112     char                           *strtok_next;        /* next ptr for strtok() */
113     unsigned char                  *mbstok_next;        /* next ptr for mbstok() */
114     MSVCRT_wchar_t                 *wcstok_next;        /* next ptr for wcstok() */
115     char                           *efcvt_buffer;       /* buffer for ecvt/fcvt */
116     char                           *asctime_buffer;     /* buffer for asctime */
117     MSVCRT_wchar_t                 *wasctime_buffer;    /* buffer for wasctime */
118     struct MSVCRT_tm                time_buffer;        /* buffer for localtime/gmtime */
119     char                           *strerror_buffer;    /* buffer for strerror */
120     MSVCRT_wchar_t                 *wcserror_buffer;    /* buffer for wcserror */
121     int                             fpecode;
122     MSVCRT_terminate_function       terminate_handler;
123     MSVCRT_unexpected_function      unexpected_handler;
124     MSVCRT__se_translator_function  se_translator;
125     EXCEPTION_RECORD               *exc_record;
126     struct MSVCRT_localeinfo_struct *locale;
127 };
128
129 typedef struct __thread_data thread_data_t;
130
131 extern thread_data_t *msvcrt_get_thread_data(void);
132
133 extern int MSVCRT___lc_codepage;
134 extern int MSVCRT___lc_collate_cp;
135 extern int MSVCRT___mb_cur_max;
136 extern WORD MSVCRT__ctype [257];
137 extern WORD* MSVCRT__pctype;
138
139 void   msvcrt_set_errno(int);
140
141 void __cdecl _purecall(void);
142 void __cdecl _amsg_exit(int errnum);
143
144 extern char **MSVCRT__environ;
145 extern MSVCRT_wchar_t **MSVCRT__wenviron;
146
147 extern char ** msvcrt_SnapshotOfEnvironmentA(char **);
148 extern MSVCRT_wchar_t ** msvcrt_SnapshotOfEnvironmentW(MSVCRT_wchar_t **);
149
150 MSVCRT_wchar_t *msvcrt_wstrdupa(const char *);
151
152 /* FIXME: This should be declared in new.h but it's not an extern "C" so
153  * it would not be much use anyway. Even for Winelib applications.
154  */
155 int __cdecl MSVCRT__set_new_mode(int mode);
156
157 void* __cdecl MSVCRT_operator_new(MSVCRT_size_t);
158 void __cdecl MSVCRT_operator_delete(void*);
159
160 typedef void* (*__cdecl malloc_func_t)(MSVCRT_size_t);
161 typedef void  (*__cdecl free_func_t)(void*);
162
163 extern char* __cdecl __unDName(char *,const char*,int,malloc_func_t,free_func_t,unsigned short int);
164 extern char* __cdecl __unDNameEx(char *,const char*,int,malloc_func_t,free_func_t,void *,unsigned short int);
165
166 /* Setup and teardown multi threaded locks */
167 extern void msvcrt_init_mt_locks(void);
168 extern void msvcrt_free_mt_locks(void);
169
170 extern void msvcrt_init_math(void);
171 extern void msvcrt_init_io(void);
172 extern void msvcrt_free_io(void);
173 extern void msvcrt_init_console(void);
174 extern void msvcrt_free_console(void);
175 extern void msvcrt_init_args(void);
176 extern void msvcrt_free_args(void);
177 extern void msvcrt_init_signals(void);
178 extern void msvcrt_free_signals(void);
179
180 extern unsigned msvcrt_create_io_inherit_block(WORD*, BYTE**);
181
182 extern unsigned int __cdecl _control87(unsigned int, unsigned int);
183
184 /* run-time error codes */
185 #define _RT_STACK       0
186 #define _RT_NULLPTR     1
187 #define _RT_FLOAT       2
188 #define _RT_INTDIV      3
189 #define _RT_EXECMEM     5
190 #define _RT_EXECFORM    6
191 #define _RT_EXECENV     7
192 #define _RT_SPACEARG    8
193 #define _RT_SPACEENV    9
194 #define _RT_ABORT       10
195 #define _RT_NPTR        12
196 #define _RT_FPTR        13
197 #define _RT_BREAK       14
198 #define _RT_INT         15
199 #define _RT_THREAD      16
200 #define _RT_LOCK        17
201 #define _RT_HEAP        18
202 #define _RT_OPENCON     19
203 #define _RT_QWIN        20
204 #define _RT_NOMAIN      21
205 #define _RT_NONCONT     22
206 #define _RT_INVALDISP   23
207 #define _RT_ONEXIT      24
208 #define _RT_PUREVIRT    25
209 #define _RT_STDIOINIT   26
210 #define _RT_LOWIOINIT   27
211 #define _RT_HEAPINIT    28
212 #define _RT_DOMAIN      120
213 #define _RT_SING        121
214 #define _RT_TLOSS       122
215 #define _RT_CRNL        252
216 #define _RT_BANNER      255
217
218 struct MSVCRT___timeb32 {
219     MSVCRT___time32_t  time;
220     unsigned short millitm;
221     short          timezone;
222     short          dstflag;
223 };
224
225 struct MSVCRT___timeb64 {
226     MSVCRT___time64_t time;
227     unsigned short millitm;
228     short          timezone;
229     short          dstflag;
230 };
231
232 struct MSVCRT__iobuf {
233   char* _ptr;
234   int   _cnt;
235   char* _base;
236   int   _flag;
237   int   _file;
238   int   _charbuf;
239   int   _bufsiz;
240   char* _tmpfname;
241 };
242
243 typedef struct MSVCRT__iobuf MSVCRT_FILE;
244
245 struct MSVCRT_lconv {
246     char* decimal_point;
247     char* thousands_sep;
248     char* grouping;
249     char* int_curr_symbol;
250     char* currency_symbol;
251     char* mon_decimal_point;
252     char* mon_thousands_sep;
253     char* mon_grouping;
254     char* positive_sign;
255     char* negative_sign;
256     char int_frac_digits;
257     char frac_digits;
258     char p_cs_precedes;
259     char p_sep_by_space;
260     char n_cs_precedes;
261     char n_sep_by_space;
262     char p_sign_posn;
263     char n_sign_posn;
264 };
265
266 struct MSVCRT__exception {
267   int     type;
268   char*   name;
269   double  arg1;
270   double  arg2;
271   double  retval;
272 };
273
274 struct MSVCRT__complex {
275   double x;      /* Real part */
276   double y;      /* Imaginary part */
277 };
278
279 typedef struct MSVCRT__div_t {
280     int quot;  /* quotient */
281     int rem;   /* remainder */
282 } MSVCRT_div_t;
283
284 typedef struct MSVCRT__ldiv_t {
285     MSVCRT_long quot;  /* quotient */
286     MSVCRT_long rem;   /* remainder */
287 } MSVCRT_ldiv_t;
288
289 struct MSVCRT__heapinfo {
290   int*           _pentry;
291   MSVCRT_size_t  _size;
292   int            _useflag;
293 };
294
295 #ifdef __i386__
296 struct MSVCRT___JUMP_BUFFER {
297     unsigned long Ebp;
298     unsigned long Ebx;
299     unsigned long Edi;
300     unsigned long Esi;
301     unsigned long Esp;
302     unsigned long Eip;
303     unsigned long Registration;
304     unsigned long TryLevel;
305     /* Start of new struct members */
306     unsigned long Cookie;
307     unsigned long UnwindFunc;
308     unsigned long UnwindData[6];
309 };
310 #elif defined(__x86_64__)
311 struct MSVCRT__SETJMP_FLOAT128
312 {
313     unsigned __int64 DECLSPEC_ALIGN(16) Part[2];
314 };
315 struct MSVCRT___JUMP_BUFFER
316 {
317     unsigned __int64 Frame;
318     unsigned __int64 Rbx;
319     unsigned __int64 Rsp;
320     unsigned __int64 Rbp;
321     unsigned __int64 Rsi;
322     unsigned __int64 Rdi;
323     unsigned __int64 R12;
324     unsigned __int64 R13;
325     unsigned __int64 R14;
326     unsigned __int64 R15;
327     unsigned __int64 Rip;
328     unsigned __int64 Spare;
329     struct MSVCRT__SETJMP_FLOAT128 Xmm6;
330     struct MSVCRT__SETJMP_FLOAT128 Xmm7;
331     struct MSVCRT__SETJMP_FLOAT128 Xmm8;
332     struct MSVCRT__SETJMP_FLOAT128 Xmm9;
333     struct MSVCRT__SETJMP_FLOAT128 Xmm10;
334     struct MSVCRT__SETJMP_FLOAT128 Xmm11;
335     struct MSVCRT__SETJMP_FLOAT128 Xmm12;
336     struct MSVCRT__SETJMP_FLOAT128 Xmm13;
337     struct MSVCRT__SETJMP_FLOAT128 Xmm14;
338     struct MSVCRT__SETJMP_FLOAT128 Xmm15;
339 };
340 #endif /* __i386__ */
341
342 struct MSVCRT__diskfree_t {
343   unsigned int total_clusters;
344   unsigned int avail_clusters;
345   unsigned int sectors_per_cluster;
346   unsigned int bytes_per_sector;
347 };
348
349 struct MSVCRT__finddata32_t {
350   unsigned int      attrib;
351   MSVCRT___time32_t time_create;
352   MSVCRT___time32_t time_access;
353   MSVCRT___time32_t time_write;
354   MSVCRT__fsize_t   size;
355   char              name[260];
356 };
357
358 struct MSVCRT__finddata32i64_t {
359   unsigned int      attrib;
360   MSVCRT___time32_t time_create;
361   MSVCRT___time32_t time_access;
362   MSVCRT___time32_t time_write;
363   __int64 DECLSPEC_ALIGN(8) size;
364   char              name[260];
365 };
366
367 struct MSVCRT__finddata64i32_t {
368   unsigned int      attrib;
369   MSVCRT___time64_t time_create;
370   MSVCRT___time64_t time_access;
371   MSVCRT___time64_t time_write;
372   MSVCRT__fsize_t   size;
373   char              name[260];
374 };
375
376 struct MSVCRT__finddata64_t {
377   unsigned int      attrib;
378   MSVCRT___time64_t time_create;
379   MSVCRT___time64_t time_access;
380   MSVCRT___time64_t time_write;
381   __int64 DECLSPEC_ALIGN(8) size;
382   char              name[260];
383 };
384
385 struct MSVCRT__wfinddata32_t {
386   unsigned int      attrib;
387   MSVCRT___time32_t time_create;
388   MSVCRT___time32_t time_access;
389   MSVCRT___time32_t time_write;
390   MSVCRT__fsize_t   size;
391   MSVCRT_wchar_t    name[260];
392 };
393
394 struct MSVCRT__wfinddata32i64_t {
395   unsigned int      attrib;
396   MSVCRT___time32_t time_create;
397   MSVCRT___time32_t time_access;
398   MSVCRT___time32_t time_write;
399   __int64 DECLSPEC_ALIGN(8) size;
400   MSVCRT_wchar_t    name[260];
401 };
402
403 struct MSVCRT__wfinddata64i32_t {
404   unsigned int      attrib;
405   MSVCRT___time64_t time_create;
406   MSVCRT___time64_t time_access;
407   MSVCRT___time64_t time_write;
408   MSVCRT__fsize_t   size;
409   MSVCRT_wchar_t    name[260];
410 };
411
412 struct MSVCRT__wfinddata64_t {
413   unsigned int      attrib;
414   MSVCRT___time64_t time_create;
415   MSVCRT___time64_t time_access;
416   MSVCRT___time64_t time_write;
417   __int64 DECLSPEC_ALIGN(8) size;
418   MSVCRT_wchar_t    name[260];
419 };
420
421 struct MSVCRT___utimbuf32
422 {
423     MSVCRT___time32_t actime;
424     MSVCRT___time32_t modtime;
425 };
426
427 struct MSVCRT___utimbuf64
428 {
429     MSVCRT___time64_t actime;
430     MSVCRT___time64_t modtime;
431 };
432
433 /* for FreeBSD */
434 #undef st_atime
435 #undef st_ctime
436 #undef st_mtime
437
438 struct MSVCRT__stat32 {
439   MSVCRT__dev_t     st_dev;
440   MSVCRT__ino_t     st_ino;
441   unsigned short    st_mode;
442   short             st_nlink;
443   short             st_uid;
444   short             st_gid;
445   MSVCRT__dev_t     st_rdev;
446   MSVCRT__off_t     st_size;
447   MSVCRT___time32_t st_atime;
448   MSVCRT___time32_t st_mtime;
449   MSVCRT___time32_t st_ctime;
450 };
451
452 struct MSVCRT__stat32i64 {
453   MSVCRT__dev_t     st_dev;
454   MSVCRT__ino_t     st_ino;
455   unsigned short    st_mode;
456   short             st_nlink;
457   short             st_uid;
458   short             st_gid;
459   MSVCRT__dev_t     st_rdev;
460   __int64 DECLSPEC_ALIGN(8) st_size;
461   MSVCRT___time32_t st_atime;
462   MSVCRT___time32_t st_mtime;
463   MSVCRT___time32_t st_ctime;
464 };
465
466 struct MSVCRT__stat64i32 {
467   MSVCRT__dev_t     st_dev;
468   MSVCRT__ino_t     st_ino;
469   unsigned short    st_mode;
470   short             st_nlink;
471   short             st_uid;
472   short             st_gid;
473   MSVCRT__dev_t     st_rdev;
474   MSVCRT__off_t     st_size;
475   MSVCRT___time64_t st_atime;
476   MSVCRT___time64_t st_mtime;
477   MSVCRT___time64_t st_ctime;
478 };
479
480 struct MSVCRT__stat64 {
481   MSVCRT__dev_t     st_dev;
482   MSVCRT__ino_t     st_ino;
483   unsigned short    st_mode;
484   short             st_nlink;
485   short             st_uid;
486   short             st_gid;
487   MSVCRT__dev_t     st_rdev;
488   __int64 DECLSPEC_ALIGN(8) st_size;
489   MSVCRT___time64_t st_atime;
490   MSVCRT___time64_t st_mtime;
491   MSVCRT___time64_t st_ctime;
492 };
493
494 #ifdef _WIN64
495 #define MSVCRT__finddata_t     MSVCRT__finddata64i32_t
496 #define MSVCRT__finddatai64_t  MSVCRT__finddata64_t
497 #define MSVCRT__wfinddata_t    MSVCRT__wfinddata64i32_t
498 #define MSVCRT__wfinddatai64_t MSVCRT__wfinddata64_t
499 #define MSVCRT__stat           MSVCRT__stat64i32
500 #define MSVCRT__stati64        MSVCRT__stat64
501 #else
502 #define MSVCRT__finddata_t     MSVCRT__finddata32_t
503 #define MSVCRT__finddatai64_t  MSVCRT__finddata32i64_t
504 #define MSVCRT__wfinddata_t    MSVCRT__wfinddata32_t
505 #define MSVCRT__wfinddatai64_t MSVCRT__wfinddata32i64_t
506 #define MSVCRT__stat           MSVCRT__stat32
507 #define MSVCRT__stati64        MSVCRT__stat32i64
508 #endif
509
510 #define MSVCRT_WEOF (MSVCRT_wint_t)(0xFFFF)
511 #define MSVCRT_EOF       (-1)
512 #define MSVCRT_TMP_MAX   0x7fff
513 #define MSVCRT_RAND_MAX  0x7fff
514 #define MSVCRT_BUFSIZ    512
515
516 #define MSVCRT_STDIN_FILENO  0
517 #define MSVCRT_STDOUT_FILENO 1
518 #define MSVCRT_STDERR_FILENO 2
519
520 /* more file._flag flags, but these conflict with Unix */
521 #define MSVCRT__IOFBF    0x0000
522 #define MSVCRT__IONBF    0x0004
523 #define MSVCRT__IOLBF    0x0040
524
525 #define MSVCRT_FILENAME_MAX 260
526 #define MSVCRT_DRIVE_MAX    3
527 #define MSVCRT_FNAME_MAX    256
528 #define MSVCRT_DIR_MAX      256
529 #define MSVCRT_EXT_MAX      256
530 #define MSVCRT_PATH_MAX     260
531 #define MSVCRT_stdin       (MSVCRT__iob+MSVCRT_STDIN_FILENO)
532 #define MSVCRT_stdout      (MSVCRT__iob+MSVCRT_STDOUT_FILENO)
533 #define MSVCRT_stderr      (MSVCRT__iob+MSVCRT_STDERR_FILENO)
534
535 #define MSVCRT__P_WAIT    0
536 #define MSVCRT__P_NOWAIT  1
537 #define MSVCRT__P_OVERLAY 2
538 #define MSVCRT__P_NOWAITO 3
539 #define MSVCRT__P_DETACH  4
540
541 #define MSVCRT_EPERM   1
542 #define MSVCRT_ENOENT  2
543 #define MSVCRT_ESRCH   3
544 #define MSVCRT_EINTR   4
545 #define MSVCRT_EIO     5
546 #define MSVCRT_ENXIO   6
547 #define MSVCRT_E2BIG   7
548 #define MSVCRT_ENOEXEC 8
549 #define MSVCRT_EBADF   9
550 #define MSVCRT_ECHILD  10
551 #define MSVCRT_EAGAIN  11
552 #define MSVCRT_ENOMEM  12
553 #define MSVCRT_EACCES  13
554 #define MSVCRT_EFAULT  14
555 #define MSVCRT_EBUSY   16
556 #define MSVCRT_EEXIST  17
557 #define MSVCRT_EXDEV   18
558 #define MSVCRT_ENODEV  19
559 #define MSVCRT_ENOTDIR 20
560 #define MSVCRT_EISDIR  21
561 #define MSVCRT_EINVAL  22
562 #define MSVCRT_ENFILE  23
563 #define MSVCRT_EMFILE  24
564 #define MSVCRT_ENOTTY  25
565 #define MSVCRT_EFBIG   27
566 #define MSVCRT_ENOSPC  28
567 #define MSVCRT_ESPIPE  29
568 #define MSVCRT_EROFS   30
569 #define MSVCRT_EMLINK  31
570 #define MSVCRT_EPIPE   32
571 #define MSVCRT_EDOM    33
572 #define MSVCRT_ERANGE  34
573 #define MSVCRT_EDEADLK 36
574 #define MSVCRT_EDEADLOCK MSVCRT_EDEADLK
575 #define MSVCRT_ENAMETOOLONG 38
576 #define MSVCRT_ENOLCK  39
577 #define MSVCRT_ENOSYS  40
578 #define MSVCRT_ENOTEMPTY 41
579 #define MSVCRT_EILSEQ    42
580 #define MSVCRT_STRUNCATE 80
581
582 #define MSVCRT_LC_ALL          0
583 #define MSVCRT_LC_COLLATE      1
584 #define MSVCRT_LC_CTYPE        2
585 #define MSVCRT_LC_MONETARY     3
586 #define MSVCRT_LC_NUMERIC      4
587 #define MSVCRT_LC_TIME         5
588 #define MSVCRT_LC_MIN          MSVCRT_LC_ALL
589 #define MSVCRT_LC_MAX          MSVCRT_LC_TIME
590
591 #define MSVCRT__HEAPEMPTY      -1
592 #define MSVCRT__HEAPOK         -2
593 #define MSVCRT__HEAPBADBEGIN   -3
594 #define MSVCRT__HEAPBADNODE    -4
595 #define MSVCRT__HEAPEND        -5
596 #define MSVCRT__HEAPBADPTR     -6
597
598 #define MSVCRT__FREEENTRY      0
599 #define MSVCRT__USEDENTRY      1
600
601 #define MSVCRT__OUT_TO_DEFAULT 0
602 #define MSVCRT__OUT_TO_STDERR  1
603 #define MSVCRT__OUT_TO_MSGBOX  2
604 #define MSVCRT__REPORT_ERRMODE 3
605
606 /* ASCII char classification table - binary compatible */
607 #define MSVCRT__UPPER    0x0001  /* C1_UPPER */
608 #define MSVCRT__LOWER    0x0002  /* C1_LOWER */
609 #define MSVCRT__DIGIT    0x0004  /* C1_DIGIT */
610 #define MSVCRT__SPACE    0x0008  /* C1_SPACE */
611 #define MSVCRT__PUNCT    0x0010  /* C1_PUNCT */
612 #define MSVCRT__CONTROL  0x0020  /* C1_CNTRL */
613 #define MSVCRT__BLANK    0x0040  /* C1_BLANK */
614 #define MSVCRT__HEX      0x0080  /* C1_XDIGIT */
615 #define MSVCRT__LEADBYTE 0x8000
616 #define MSVCRT__ALPHA   (0x0100|MSVCRT__UPPER|MSVCRT__LOWER)  /* (C1_ALPHA|_UPPER|_LOWER) */
617
618 #define MSVCRT__IOREAD   0x0001
619 #define MSVCRT__IOWRT    0x0002
620 #define MSVCRT__IOMYBUF  0x0008
621 #define MSVCRT__IOEOF    0x0010
622 #define MSVCRT__IOERR    0x0020
623 #define MSVCRT__IOSTRG   0x0040
624 #define MSVCRT__IORW     0x0080
625
626 #define MSVCRT__S_IEXEC  0x0040
627 #define MSVCRT__S_IWRITE 0x0080
628 #define MSVCRT__S_IREAD  0x0100
629 #define MSVCRT__S_IFIFO  0x1000
630 #define MSVCRT__S_IFCHR  0x2000
631 #define MSVCRT__S_IFDIR  0x4000
632 #define MSVCRT__S_IFREG  0x8000
633 #define MSVCRT__S_IFMT   0xF000
634
635 #define MSVCRT__LK_UNLCK  0
636 #define MSVCRT__LK_LOCK   1
637 #define MSVCRT__LK_NBLCK  2
638 #define MSVCRT__LK_RLCK   3
639 #define MSVCRT__LK_NBRLCK 4
640
641 #define MSVCRT__SH_COMPAT       0x00    /* Compatibility */
642 #define MSVCRT__SH_DENYRW       0x10    /* Deny read/write */
643 #define MSVCRT__SH_DENYWR       0x20    /* Deny write */
644 #define MSVCRT__SH_DENYRD       0x30    /* Deny read */
645 #define MSVCRT__SH_DENYNO       0x40    /* Deny nothing */
646
647 #define MSVCRT__O_RDONLY        0
648 #define MSVCRT__O_WRONLY        1
649 #define MSVCRT__O_RDWR          2
650 #define MSVCRT__O_ACCMODE       (MSVCRT__O_RDONLY|MSVCRT__O_WRONLY|MSVCRT__O_RDWR)
651 #define MSVCRT__O_APPEND        0x0008
652 #define MSVCRT__O_RANDOM        0x0010
653 #define MSVCRT__O_SEQUENTIAL    0x0020
654 #define MSVCRT__O_TEMPORARY     0x0040
655 #define MSVCRT__O_NOINHERIT     0x0080
656 #define MSVCRT__O_CREAT         0x0100
657 #define MSVCRT__O_TRUNC         0x0200
658 #define MSVCRT__O_EXCL          0x0400
659 #define MSVCRT__O_SHORT_LIVED   0x1000
660 #define MSVCRT__O_TEXT          0x4000
661 #define MSVCRT__O_BINARY        0x8000
662 #define MSVCRT__O_RAW           MSVCRT__O_BINARY
663
664 /* _statusfp bit flags */
665 #define MSVCRT__SW_INEXACT      0x00000001 /* inexact (precision) */
666 #define MSVCRT__SW_UNDERFLOW    0x00000002 /* underflow */
667 #define MSVCRT__SW_OVERFLOW     0x00000004 /* overflow */
668 #define MSVCRT__SW_ZERODIVIDE   0x00000008 /* zero divide */
669 #define MSVCRT__SW_INVALID      0x00000010 /* invalid */
670
671 #define MSVCRT__SW_UNEMULATED     0x00000040  /* unemulated instruction */
672 #define MSVCRT__SW_SQRTNEG        0x00000080  /* square root of a neg number */
673 #define MSVCRT__SW_STACKOVERFLOW  0x00000200  /* FP stack overflow */
674 #define MSVCRT__SW_STACKUNDERFLOW 0x00000400  /* FP stack underflow */
675
676 #define MSVCRT__SW_DENORMAL     0x00080000 /* denormal status bit */
677
678 /* fpclass constants */
679 #define MSVCRT__FPCLASS_SNAN 0x0001  /* Signaling "Not a Number" */
680 #define MSVCRT__FPCLASS_QNAN 0x0002  /* Quiet "Not a Number" */
681 #define MSVCRT__FPCLASS_NINF 0x0004  /* Negative Infinity */
682 #define MSVCRT__FPCLASS_NN   0x0008  /* Negative Normal */
683 #define MSVCRT__FPCLASS_ND   0x0010  /* Negative Denormal */
684 #define MSVCRT__FPCLASS_NZ   0x0020  /* Negative Zero */
685 #define MSVCRT__FPCLASS_PZ   0x0040  /* Positive Zero */
686 #define MSVCRT__FPCLASS_PD   0x0080  /* Positive Denormal */
687 #define MSVCRT__FPCLASS_PN   0x0100  /* Positive Normal */
688 #define MSVCRT__FPCLASS_PINF 0x0200  /* Positive Infinity */
689
690 #define MSVCRT__MCW_EM        0x0008001f
691 #define MSVCRT__MCW_IC        0x00040000
692 #define MSVCRT__MCW_RC        0x00000300
693 #define MSVCRT__MCW_PC        0x00030000
694 #define MSVCRT__MCW_DN        0x03000000
695
696 #define MSVCRT__EM_INVALID    0x00000010
697 #define MSVCRT__EM_DENORMAL   0x00080000
698 #define MSVCRT__EM_ZERODIVIDE 0x00000008
699 #define MSVCRT__EM_OVERFLOW   0x00000004
700 #define MSVCRT__EM_UNDERFLOW  0x00000002
701 #define MSVCRT__EM_INEXACT    0x00000001
702 #define MSVCRT__IC_AFFINE     0x00040000
703 #define MSVCRT__IC_PROJECTIVE 0x00000000
704 #define MSVCRT__RC_CHOP       0x00000300
705 #define MSVCRT__RC_UP         0x00000200
706 #define MSVCRT__RC_DOWN       0x00000100
707 #define MSVCRT__RC_NEAR       0x00000000
708 #define MSVCRT__PC_24         0x00020000
709 #define MSVCRT__PC_53         0x00010000
710 #define MSVCRT__PC_64         0x00000000
711 #define MSVCRT__DN_SAVE       0x00000000
712 #define MSVCRT__DN_FLUSH      0x01000000
713 #define MSVCRT__DN_FLUSH_OPERANDS_SAVE_RESULTS 0x02000000
714 #define MSVCRT__DN_SAVE_OPERANDS_FLUSH_RESULTS 0x03000000
715 #define MSVCRT__EM_AMBIGUOUS  0x80000000
716
717 #define MSVCRT_CLOCKS_PER_SEC 1000
718
719 /* signals */
720 #define MSVCRT_SIGINT   2
721 #define MSVCRT_SIGILL   4
722 #define MSVCRT_SIGFPE   8
723 #define MSVCRT_SIGSEGV  11
724 #define MSVCRT_SIGTERM  15
725 #define MSVCRT_SIGBREAK 21
726 #define MSVCRT_SIGABRT  22
727 #define MSVCRT_NSIG     (MSVCRT_SIGABRT + 1)
728
729 typedef void (__cdecl *MSVCRT___sighandler_t)(int);
730
731 #define MSVCRT_SIG_DFL ((MSVCRT___sighandler_t)0)
732 #define MSVCRT_SIG_IGN ((MSVCRT___sighandler_t)1)
733 #define MSVCRT_SIG_ERR ((MSVCRT___sighandler_t)-1)
734
735 #define MSVCRT__FPE_INVALID            0x81
736 #define MSVCRT__FPE_DENORMAL           0x82
737 #define MSVCRT__FPE_ZERODIVIDE         0x83
738 #define MSVCRT__FPE_OVERFLOW           0x84
739 #define MSVCRT__FPE_UNDERFLOW          0x85
740 #define MSVCRT__FPE_INEXACT            0x86
741 #define MSVCRT__FPE_UNEMULATED         0x87
742 #define MSVCRT__FPE_SQRTNEG            0x88
743 #define MSVCRT__FPE_STACKOVERFLOW      0x8a
744 #define MSVCRT__FPE_STACKUNDERFLOW     0x8b
745 #define MSVCRT__FPE_EXPLICITGEN        0x8c
746
747 #define _MS     0x01
748 #define _MP     0x02
749 #define _M1     0x04
750 #define _M2     0x08
751
752 #define _SBUP   0x10
753 #define _SBLOW  0x20
754
755 #define _MBC_SINGLE     0
756 #define _MBC_LEAD       1
757 #define _MBC_TRAIL      2
758 #define _MBC_ILLEGAL    -1
759
760 #define _MB_CP_SBCS     0
761 #define _MB_CP_OEM      -2
762 #define _MB_CP_ANSI     -3
763 #define _MB_CP_LOCALE   -4
764
765 #define MSVCRT__TRUNCATE ((MSVCRT_size_t)-1)
766
767 #define _MAX__TIME64_T    (((MSVCRT___time64_t)0x00000007 << 32) | 0x93406FFF)
768
769 /* _set_abort_behavior codes */
770 #define MSVCRT__WRITE_ABORT_MSG    1
771 #define MSVCRT__CALL_REPORTFAULT   2
772
773 /* _get_output_format return code */
774 #define MSVCRT__TWO_DIGIT_EXPONENT 0x1
775
776 void  __cdecl    MSVCRT_free(void*);
777 void* __cdecl    MSVCRT_malloc(MSVCRT_size_t);
778 void* __cdecl    MSVCRT_calloc(MSVCRT_size_t,MSVCRT_size_t);
779 void* __cdecl    MSVCRT_realloc(void*,MSVCRT_size_t);
780
781 int __cdecl      MSVCRT_iswalpha(MSVCRT_wint_t);
782 int __cdecl      MSVCRT_iswspace(MSVCRT_wint_t);
783 int __cdecl      MSVCRT_iswdigit(MSVCRT_wint_t);
784 int __cdecl      MSVCRT_isleadbyte(int);
785
786 int __cdecl      MSVCRT_fgetc(MSVCRT_FILE*);
787 int __cdecl      MSVCRT_ungetc(int,MSVCRT_FILE*);
788 MSVCRT_wint_t __cdecl MSVCRT_fgetwc(MSVCRT_FILE*);
789 MSVCRT_wint_t __cdecl MSVCRT_ungetwc(MSVCRT_wint_t,MSVCRT_FILE*);
790 void __cdecl     MSVCRT__exit(int);
791 void __cdecl     MSVCRT_abort(void);
792 MSVCRT_ulong* __cdecl MSVCRT___doserrno(void);
793 int* __cdecl     MSVCRT__errno(void);
794 char* __cdecl    MSVCRT_getenv(const char*);
795 char* __cdecl    MSVCRT_setlocale(int,const char*);
796 int __cdecl      MSVCRT_fclose(MSVCRT_FILE*);
797 void __cdecl     MSVCRT_terminate(void);
798 MSVCRT_FILE* __cdecl MSVCRT__iob_func(void);
799 MSVCRT_clock_t __cdecl MSVCRT_clock(void);
800 MSVCRT___time32_t __cdecl MSVCRT__time32(MSVCRT___time32_t*);
801 MSVCRT___time64_t __cdecl MSVCRT__time64(MSVCRT___time64_t*);
802 MSVCRT_FILE*   __cdecl MSVCRT__fdopen(int, const char *);
803 MSVCRT_FILE*   __cdecl MSVCRT__wfdopen(int, const MSVCRT_wchar_t *);
804 int            __cdecl MSVCRT_vsnprintf(char *str, MSVCRT_size_t len, const char *format, __ms_va_list valist);
805 int            __cdecl MSVCRT_vsnwprintf(MSVCRT_wchar_t *str, MSVCRT_size_t len,
806                                        const MSVCRT_wchar_t *format, __ms_va_list valist );
807 int            __cdecl MSVCRT__snwprintf(MSVCRT_wchar_t*, unsigned int, const MSVCRT_wchar_t*, ...);
808 int            __cdecl MSVCRT_sprintf(char*,const char*,...);
809 int            __cdecl MSVCRT__scprintf(const char*,...);
810 int            __cdecl MSVCRT_raise(int sig);
811
812 typedef struct MSVCRT_tagLC_ID {
813     unsigned short wLanguage;
814     unsigned short wCountry;
815     unsigned short wCodePage;
816 } MSVCRT_LC_ID, *MSVCRT_LPLC_ID;
817
818 typedef struct MSVCRT_threadlocaleinfostruct {
819     int refcount;
820     unsigned int lc_codepage;
821     unsigned int lc_collate_cp;
822     unsigned long lc_handle[6];
823     MSVCRT_LC_ID lc_id[6];
824     struct {
825         char *locale;
826         wchar_t *wlocale;
827         int *refcount;
828         int *wrefcount;
829     } lc_category[6];
830     int lc_clike;
831     int mb_cur_max;
832     int *lconv_intl_refcount;
833     int *lconv_num_refcount;
834     int *lconv_mon_refcount;
835     struct MSVCRT_lconv *lconv;
836     int *ctype1_refcount;
837     unsigned short *ctype1;
838     unsigned short *pctype;
839     unsigned char *pclmap;
840     unsigned char *pcumap;
841     struct MSVCRT___lc_time_data *lc_time_curr;
842 } MSVCRT_threadlocinfo;
843
844 typedef struct MSVCRT_threadmbcinfostruct {
845     int refcount;
846     int mbcodepage;
847     int ismbcodepage;
848     int mblcid;
849     unsigned short mbulinfo[6];
850     char mbctype[257];
851     char mbcasemap[256];
852 } MSVCRT_threadmbcinfo;
853
854 typedef struct MSVCRT_threadlocaleinfostruct *MSVCRT_pthreadlocinfo;
855 typedef struct MSVCRT_threadmbcinfostruct *MSVCRT_pthreadmbcinfo;
856
857 typedef struct MSVCRT_localeinfo_struct
858 {
859     MSVCRT_pthreadlocinfo locinfo;
860     MSVCRT_pthreadmbcinfo mbcinfo;
861 } MSVCRT__locale_tstruct, *MSVCRT__locale_t;
862
863 #define MSVCRT__ENABLE_PER_THREAD_LOCALE 1
864 #define MSVCRT__DISABLE_PER_THREAD_LOCALE 2
865
866 extern MSVCRT__locale_t MSVCRT_locale;
867 MSVCRT__locale_t get_locale(void);
868 void __cdecl MSVCRT__free_locale(MSVCRT__locale_t);
869
870 #ifndef __WINE_MSVCRT_TEST
871 int            __cdecl MSVCRT__write(int,const void*,unsigned int);
872 int            __cdecl _getch(void);
873 int            __cdecl _ismbblead(unsigned int);
874 int            __cdecl _ismbstrail(const unsigned char* start, const unsigned char* str);
875 MSVCRT_size_t  __cdecl MSVCRT_mbstowcs(MSVCRT_wchar_t*,const char*,MSVCRT_size_t);
876 MSVCRT_intptr_t __cdecl MSVCRT__spawnve(int,const char*,const char* const *,const char* const *);
877 MSVCRT_intptr_t __cdecl MSVRT__spawnvpe(int,const char*,const char* const *,const char* const *);
878 MSVCRT_intptr_t __cdecl _wspawnve(int,const MSVCRT_wchar_t*,const MSVCRT_wchar_t* const *,const MSVCRT_wchar_t* const *);
879 MSVCRT_intptr_t __cdecl _wspawnvpe(int,const MSVCRT_wchar_t*,const MSVCRT_wchar_t* const *,const MSVCRT_wchar_t* const *);
880 void __cdecl     _searchenv(const char*,const char*,char*);
881 int __cdecl      _getdrive(void);
882 char* __cdecl    _strdup(const char*);
883 char* __cdecl    MSVCRT__strnset(char*,int,MSVCRT_size_t);
884 char* __cdecl    _strset(char*,int);
885 int __cdecl      _ungetch(int);
886 int __cdecl      _cputs(const char*);
887 int __cdecl      _cprintf(const char*,...);
888 int __cdecl      _cwprintf(const MSVCRT_wchar_t*,...);
889 char*** __cdecl  __p__environ(void);
890 int*    __cdecl  __p___mb_cur_max(void);
891 unsigned int*  __cdecl __p__fmode(void);
892 MSVCRT_wchar_t* __cdecl _wcsdup(const MSVCRT_wchar_t*);
893 MSVCRT_wchar_t*** __cdecl __p__wenviron(void);
894 char*   __cdecl _strdate(char* date);
895 char*   __cdecl _strtime(char* date);
896 int     __cdecl _setmbcp(int);
897 int     __cdecl MSVCRT__close(int);
898 int     __cdecl MSVCRT__dup(int);
899 int     __cdecl MSVCRT__dup2(int, int);
900 int     __cdecl MSVCRT__pipe(int *, unsigned int, int);
901 MSVCRT_wchar_t* __cdecl _wgetenv(const MSVCRT_wchar_t*);
902 void __cdecl    _wsearchenv(const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, MSVCRT_wchar_t*);
903 MSVCRT_intptr_t __cdecl MSVCRT__spawnvpe(int, const char*, const char* const*, const char* const*);
904 void __cdecl MSVCRT__invalid_parameter(const MSVCRT_wchar_t *expr, const MSVCRT_wchar_t *func,
905                                        const MSVCRT_wchar_t *file, unsigned int line, MSVCRT_uintptr_t arg);
906
907 /* Maybe one day we'll enable the invalid parameter handlers with the full set of information (msvcrXXd)
908  *      #define MSVCRT_INVALID_PMT(x) MSVCRT_call_invalid_parameter_handler(x, __FUNCTION__, __FILE__, __LINE__, 0)
909  *      #define MSVCRT_CHECK_PMT(x)   ((x) ? TRUE : MSVCRT_INVALID_PMT(#x),FALSE)
910  * Until this is done, just keep the same semantics for CHECK_PMT(), but without generating / sending
911  * any information
912  * NB : MSVCRT_call_invalid_parameter_handler is a wrapper around MSVCRT__invalid_parameter in order
913  * to do the Ansi to Unicode transformation
914  */
915 #define MSVCRT_INVALID_PMT(x) MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0)
916 #define MSVCRT_CHECK_PMT(x)   ((x) || (MSVCRT_INVALID_PMT(0),FALSE))
917 #endif
918
919 typedef struct pf_output_t
920 {
921     int used;
922     int len;
923     BOOL unicode;
924     union {
925         LPWSTR W;
926         LPSTR  A;
927     } buf;
928     union {
929         LPWSTR W;
930         LPSTR  A;
931     } grow;
932 } pf_output;
933
934 int pf_vsnprintf( pf_output *out, const WCHAR *format,
935                   MSVCRT__locale_t locale, BOOL valid, __ms_va_list valist );
936
937 typedef int (*puts_clbk_a)(void*, int, const char*);
938 typedef int (*puts_clbk_w)(void*, int, const MSVCRT_wchar_t*);
939 typedef union _printf_arg
940 {
941     void *get_ptr;
942     int get_int;
943     LONGLONG get_longlong;
944     double get_double;
945 } printf_arg;
946 typedef printf_arg (*args_clbk)(void*, int, int, __ms_va_list*);
947 int pf_printf_a(puts_clbk_a, void*, const char*, MSVCRT__locale_t,
948         BOOL, BOOL, args_clbk, void*, __ms_va_list);
949 int pf_printf_w(puts_clbk_w, void*, const MSVCRT_wchar_t*, MSVCRT__locale_t,
950         BOOL, BOOL, args_clbk, void*, __ms_va_list);
951 printf_arg arg_clbk_valist(void*, int, int, __ms_va_list*);
952
953 #define MSVCRT__OVERFLOW  3
954 #define MSVCRT__UNDERFLOW 4
955
956 typedef struct
957 {
958     float f;
959 } MSVCRT__CRT_FLOAT;
960
961 #endif /* __WINE_MSVCRT_H */