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