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