msvcrt.h 37 KB
Newer Older
1 2
/*
 * Copyright 2001 Jon Griffiths
3
 * Copyright 2004 Dimitrie O. Paun
4 5 6 7 8 9 10 11 12 13 14 15 16
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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 20 21 22
 *
 * NOTES
 *   Naming conventions
 *	- Symbols are prefixed with MSVCRT_ if they conflict
 *        with libc symbols
23
 *      - Internal symbols are usually prefixed by msvcrt_.
24 25 26 27 28 29 30 31 32 33
 *      - Exported symbols that are not present in the public
 *        headers are usually kept the same as the original.
 *   Other conventions
 *      - To avoid conflicts with the standard C library,
 *        no msvcrt headers are included in the implementation.
 *      - Instead, symbols are duplicated here, prefixed with 
 *        MSVCRT_, as explained above.
 *      - To avoid inconsistencies, a test for each symbol is
 *        added into tests/headers.c. Please always add a
 *        corresponding test when you add a new symbol!
34 35
 */

36 37 38
#ifndef __WINE_MSVCRT_H
#define __WINE_MSVCRT_H

39 40
#include <stdarg.h>

41 42 43
#include "windef.h"
#include "winbase.h"

44
#define MSVCRT_LONG_MAX    0x7fffffff
45
#define MSVCRT_LONG_MIN    (-MSVCRT_LONG_MAX-1)
46
#define MSVCRT_ULONG_MAX   0xffffffff
47 48 49
#define MSVCRT_I64_MAX    (((__int64)0x7fffffff << 32) | 0xffffffff)
#define MSVCRT_I64_MIN    (-MSVCRT_I64_MAX-1)
#define MSVCRT_UI64_MAX   (((unsigned __int64)0xffffffff << 32) | 0xffffffff)
50
#define MSVCRT_MB_LEN_MAX 5
51 52 53 54 55
#ifdef _WIN64
#define MSVCRT_SIZE_MAX MSVCRT_UI64_MAX
#else
#define MSVCRT_SIZE_MAX MSVCRT_ULONG_MAX
#endif
56

57 58 59 60 61
#define MSVCRT__MAX_DRIVE  3
#define MSVCRT__MAX_DIR    256
#define MSVCRT__MAX_FNAME  256
#define MSVCRT__MAX_EXT    256

62
typedef unsigned char  MSVCRT_bool;
63 64 65 66
typedef unsigned short MSVCRT_wchar_t;
typedef unsigned short MSVCRT_wint_t;
typedef unsigned short MSVCRT_wctype_t;
typedef unsigned short MSVCRT__ino_t;
67
typedef unsigned int   MSVCRT__fsize_t;
68 69
typedef int            MSVCRT_long;
typedef unsigned int   MSVCRT_ulong;
70
typedef __int64        MSVCRT_longlong;
71 72 73 74 75
#ifdef _WIN64
typedef unsigned __int64 MSVCRT_size_t;
typedef __int64 MSVCRT_intptr_t;
typedef unsigned __int64 MSVCRT_uintptr_t;
#else
76 77 78
typedef unsigned long MSVCRT_size_t;
typedef long MSVCRT_intptr_t;
typedef unsigned long MSVCRT_uintptr_t;
79
#endif
80
typedef unsigned int   MSVCRT__dev_t;
81 82
typedef int MSVCRT__off_t;
typedef int MSVCRT_clock_t;
83
typedef int MSVCRT___time32_t;
84 85
typedef __int64 DECLSPEC_ALIGN(8) MSVCRT___time64_t;
typedef __int64 DECLSPEC_ALIGN(8) MSVCRT_fpos_t;
86
typedef int MSVCRT_mbstate_t;
87

88 89 90 91 92 93
typedef void (__cdecl *MSVCRT_terminate_handler)(void);
typedef void (__cdecl *MSVCRT_terminate_function)(void);
typedef void (__cdecl *MSVCRT_unexpected_handler)(void);
typedef void (__cdecl *MSVCRT_unexpected_function)(void);
typedef void (__cdecl *MSVCRT__se_translator_function)(unsigned int code, struct _EXCEPTION_POINTERS *info);
typedef void (__cdecl *MSVCRT__beginthread_start_routine_t)(void *);
94
typedef unsigned int (__stdcall *MSVCRT__beginthreadex_start_routine_t)(void *);
95
typedef int (__cdecl *MSVCRT__onexit_t)(void);
96
typedef void (__cdecl *MSVCRT_invalid_parameter_handler)(const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, unsigned, MSVCRT_uintptr_t);
97
typedef void (__cdecl *MSVCRT_purecall_handler)(void);
98
typedef void (__cdecl *MSVCRT_security_error_handler)(int, void *);
99

100
typedef struct {ULONG x80[3];} MSVCRT__LDOUBLE; /* Intel 80 bit FP format has sizeof() 12 */
Louis Lenders's avatar
Louis Lenders committed
101

102 103 104 105 106 107 108 109 110 111 112 113
struct MSVCRT_tm {
    int tm_sec;
    int tm_min;
    int tm_hour;
    int tm_mday;
    int tm_mon;
    int tm_year;
    int tm_wday;
    int tm_yday;
    int tm_isdst;
};

114 115 116 117 118 119
typedef struct MSVCRT_tagLC_ID {
    unsigned short wLanguage;
    unsigned short wCountry;
    unsigned short wCodePage;
} MSVCRT_LC_ID, *MSVCRT_LPLC_ID;

120
typedef struct {
121 122 123 124 125 126 127 128 129 130 131 132 133 134
    union {
        char *str[43];
        struct {
            char *short_wday[7];
            char *wday[7];
            char *short_mon[12];
            char *mon[12];
            char *am;
            char *pm;
            char *short_date;
            char *date;
            char *time;
        } names;
    } str;
135 136 137 138 139 140
    LCID lcid;
    int  unk[2];
    MSVCRT_wchar_t *wstr[43];
    char data[1];
} MSVCRT___lc_time_data;

141 142 143 144
typedef struct MSVCRT_threadlocaleinfostruct {
    int refcount;
    unsigned int lc_codepage;
    unsigned int lc_collate_cp;
145
    MSVCRT_ulong lc_handle[6];
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
    MSVCRT_LC_ID lc_id[6];
    struct {
        char *locale;
        wchar_t *wlocale;
        int *refcount;
        int *wrefcount;
    } lc_category[6];
    int lc_clike;
    int mb_cur_max;
    int *lconv_intl_refcount;
    int *lconv_num_refcount;
    int *lconv_mon_refcount;
    struct MSVCRT_lconv *lconv;
    int *ctype1_refcount;
    unsigned short *ctype1;
    unsigned short *pctype;
    unsigned char *pclmap;
    unsigned char *pcumap;
164
    MSVCRT___lc_time_data *lc_time_curr;
165 166 167 168 169 170 171 172
} MSVCRT_threadlocinfo;

typedef struct MSVCRT_threadmbcinfostruct {
    int refcount;
    int mbcodepage;
    int ismbcodepage;
    int mblcid;
    unsigned short mbulinfo[6];
173 174
    unsigned char mbctype[257];
    unsigned char mbcasemap[256];
175 176 177 178 179 180 181 182 183 184 185
} MSVCRT_threadmbcinfo;

typedef struct MSVCRT_threadlocaleinfostruct *MSVCRT_pthreadlocinfo;
typedef struct MSVCRT_threadmbcinfostruct *MSVCRT_pthreadmbcinfo;

typedef struct MSVCRT_localeinfo_struct
{
    MSVCRT_pthreadlocinfo locinfo;
    MSVCRT_pthreadmbcinfo mbcinfo;
} MSVCRT__locale_tstruct, *MSVCRT__locale_t;

186

187
/* TLS data */
188
extern DWORD msvcrt_tls_index DECLSPEC_HIDDEN;
189

190
/* Keep in sync with msvcr90/tests/msvcr90.c */
191
struct __thread_data {
192 193
    DWORD                           tid;
    HANDLE                          handle;
194
    int                             thread_errno;
195
    MSVCRT_ulong                    thread_doserrno;
196
    int                             unk1;
197
    unsigned int                    random_seed;        /* seed for rand() */
198 199
    char                           *strtok_next;        /* next ptr for strtok() */
    MSVCRT_wchar_t                 *wcstok_next;        /* next ptr for wcstok() */
200 201 202
    unsigned char                  *mbstok_next;        /* next ptr for mbstok() */
    char                           *strerror_buffer;    /* buffer for strerror */
    MSVCRT_wchar_t                 *wcserror_buffer;    /* buffer for wcserror */
203 204 205
    char                           *tmpnam_buffer;      /* buffer for tmpname() */
    MSVCRT_wchar_t                 *wtmpnam_buffer;     /* buffer for wtmpname() */
    void                           *unk2[2];
206 207
    char                           *asctime_buffer;     /* buffer for asctime */
    MSVCRT_wchar_t                 *wasctime_buffer;    /* buffer for wasctime */
208
    struct MSVCRT_tm               *time_buffer;        /* buffer for localtime/gmtime */
209 210
    char                           *efcvt_buffer;       /* buffer for ecvt/fcvt */
    int                             unk3[2];
211 212
    void                           *unk4[3];
    EXCEPTION_POINTERS             *xcptinfo;
213
    int                             fpecode;
214 215 216 217
    MSVCRT_pthreadmbcinfo           mbcinfo;
    MSVCRT_pthreadlocinfo           locinfo;
    BOOL                            have_locale;
    int                             unk5[1];
218 219 220
    MSVCRT_terminate_function       terminate_handler;
    MSVCRT_unexpected_function      unexpected_handler;
    MSVCRT__se_translator_function  se_translator;
221 222
    void                           *unk6[3];
    int                             unk7;
223
    EXCEPTION_RECORD               *exc_record;
224
    void                           *unk8[100];
225 226 227 228
};

typedef struct __thread_data thread_data_t;

229
extern thread_data_t *msvcrt_get_thread_data(void) DECLSPEC_HIDDEN;
230

231
LCID MSVCRT_locale_to_LCID(const char*, unsigned short*) DECLSPEC_HIDDEN;
232
extern MSVCRT__locale_t MSVCRT_locale DECLSPEC_HIDDEN;
233
extern unsigned int MSVCRT___lc_codepage;
234 235
extern int MSVCRT___lc_collate_cp;
extern WORD MSVCRT__ctype [257];
236

237 238 239 240
void msvcrt_set_errno(int) DECLSPEC_HIDDEN;
#if _MSVCR_VER >= 80
void throw_bad_alloc(const char*) DECLSPEC_HIDDEN;
#endif
241

242 243
void __cdecl _purecall(void);
void __cdecl _amsg_exit(int errnum);
244

245
extern char **MSVCRT__environ;
246
extern MSVCRT_wchar_t **MSVCRT__wenviron;
247

248 249
extern char ** msvcrt_SnapshotOfEnvironmentA(char **) DECLSPEC_HIDDEN;
extern MSVCRT_wchar_t ** msvcrt_SnapshotOfEnvironmentW(MSVCRT_wchar_t **) DECLSPEC_HIDDEN;
250

251
MSVCRT_wchar_t *msvcrt_wstrdupa(const char *) DECLSPEC_HIDDEN;
252

253 254
extern unsigned int MSVCRT__commode;

255
/* FIXME: This should be declared in new.h but it's not an extern "C" so
256 257
 * it would not be much use anyway. Even for Winelib applications.
 */
258
int __cdecl MSVCRT__set_new_mode(int mode);
259

260
void* __cdecl MSVCRT_operator_new(MSVCRT_size_t);
261
void __cdecl MSVCRT_operator_delete(void*);
262

263 264
typedef void* (__cdecl *malloc_func_t)(MSVCRT_size_t);
typedef void  (__cdecl *free_func_t)(void*);
265

266
/* Setup and teardown multi threaded locks */
267
extern void msvcrt_init_mt_locks(void) DECLSPEC_HIDDEN;
268
extern void msvcrt_free_locks(void) DECLSPEC_HIDDEN;
269

270
extern void msvcrt_init_exception(void*) DECLSPEC_HIDDEN;
271 272 273 274 275 276 277 278 279 280
extern BOOL msvcrt_init_locale(void) DECLSPEC_HIDDEN;
extern void msvcrt_init_math(void) DECLSPEC_HIDDEN;
extern void msvcrt_init_io(void) DECLSPEC_HIDDEN;
extern void msvcrt_free_io(void) DECLSPEC_HIDDEN;
extern void msvcrt_init_console(void) DECLSPEC_HIDDEN;
extern void msvcrt_free_console(void) DECLSPEC_HIDDEN;
extern void msvcrt_init_args(void) DECLSPEC_HIDDEN;
extern void msvcrt_free_args(void) DECLSPEC_HIDDEN;
extern void msvcrt_init_signals(void) DECLSPEC_HIDDEN;
extern void msvcrt_free_signals(void) DECLSPEC_HIDDEN;
281
extern void msvcrt_free_popen_data(void) DECLSPEC_HIDDEN;
282 283
extern BOOL msvcrt_init_heap(void) DECLSPEC_HIDDEN;
extern void msvcrt_destroy_heap(void) DECLSPEC_HIDDEN;
284 285

extern unsigned msvcrt_create_io_inherit_block(WORD*, BYTE**) DECLSPEC_HIDDEN;
286

287 288
extern unsigned int __cdecl _control87(unsigned int, unsigned int);

289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
/* run-time error codes */
#define _RT_STACK       0
#define _RT_NULLPTR     1
#define _RT_FLOAT       2
#define _RT_INTDIV      3
#define _RT_EXECMEM     5
#define _RT_EXECFORM    6
#define _RT_EXECENV     7
#define _RT_SPACEARG    8
#define _RT_SPACEENV    9
#define _RT_ABORT       10
#define _RT_NPTR        12
#define _RT_FPTR        13
#define _RT_BREAK       14
#define _RT_INT         15
#define _RT_THREAD      16
#define _RT_LOCK        17
#define _RT_HEAP        18
#define _RT_OPENCON     19
#define _RT_QWIN        20
#define _RT_NOMAIN      21
#define _RT_NONCONT     22
#define _RT_INVALDISP   23
#define _RT_ONEXIT      24
#define _RT_PUREVIRT    25
#define _RT_STDIOINIT   26
#define _RT_LOWIOINIT   27
#define _RT_HEAPINIT    28
#define _RT_DOMAIN      120
#define _RT_SING        121
#define _RT_TLOSS       122
#define _RT_CRNL        252
#define _RT_BANNER      255

323 324 325 326 327 328 329 330 331
struct MSVCRT___timeb32 {
    MSVCRT___time32_t  time;
    unsigned short millitm;
    short          timezone;
    short          dstflag;
};

struct MSVCRT___timeb64 {
    MSVCRT___time64_t time;
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
    unsigned short millitm;
    short          timezone;
    short          dstflag;
};

struct MSVCRT__iobuf {
  char* _ptr;
  int   _cnt;
  char* _base;
  int   _flag;
  int   _file;
  int   _charbuf;
  int   _bufsiz;
  char* _tmpfname;
};

typedef struct MSVCRT__iobuf MSVCRT_FILE;

struct MSVCRT_lconv {
    char* decimal_point;
    char* thousands_sep;
    char* grouping;
    char* int_curr_symbol;
    char* currency_symbol;
    char* mon_decimal_point;
    char* mon_thousands_sep;
    char* mon_grouping;
    char* positive_sign;
    char* negative_sign;
    char int_frac_digits;
    char frac_digits;
    char p_cs_precedes;
    char p_sep_by_space;
    char n_cs_precedes;
    char n_sep_by_space;
    char p_sign_posn;
    char n_sign_posn;
369 370 371 372 373 374 375 376 377 378
#if _MSVCR_VER >= 120
    MSVCRT_wchar_t* _W_decimal_point;
    MSVCRT_wchar_t* _W_thousands_sep;
    MSVCRT_wchar_t* _W_int_curr_symbol;
    MSVCRT_wchar_t* _W_currency_symbol;
    MSVCRT_wchar_t* _W_mon_decimal_point;
    MSVCRT_wchar_t* _W_mon_thousands_sep;
    MSVCRT_wchar_t* _W_positive_sign;
    MSVCRT_wchar_t* _W_negative_sign;
#endif
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
};

struct MSVCRT__exception {
  int     type;
  char*   name;
  double  arg1;
  double  arg2;
  double  retval;
};

struct MSVCRT__complex {
  double x;      /* Real part */
  double y;      /* Imaginary part */
};

394 395 396 397 398 399
typedef struct MSVCRT__div_t {
    int quot;  /* quotient */
    int rem;   /* remainder */
} MSVCRT_div_t;

typedef struct MSVCRT__ldiv_t {
400 401
    MSVCRT_long quot;  /* quotient */
    MSVCRT_long rem;   /* remainder */
402 403
} MSVCRT_ldiv_t;

404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
struct MSVCRT__heapinfo {
  int*           _pentry;
  MSVCRT_size_t  _size;
  int            _useflag;
};

#ifdef __i386__
struct MSVCRT___JUMP_BUFFER {
    unsigned long Ebp;
    unsigned long Ebx;
    unsigned long Edi;
    unsigned long Esi;
    unsigned long Esp;
    unsigned long Eip;
    unsigned long Registration;
    unsigned long TryLevel;
    /* Start of new struct members */
    unsigned long Cookie;
    unsigned long UnwindFunc;
    unsigned long UnwindData[6];
};
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
#elif defined(__x86_64__)
struct MSVCRT__SETJMP_FLOAT128
{
    unsigned __int64 DECLSPEC_ALIGN(16) Part[2];
};
struct MSVCRT___JUMP_BUFFER
{
    unsigned __int64 Frame;
    unsigned __int64 Rbx;
    unsigned __int64 Rsp;
    unsigned __int64 Rbp;
    unsigned __int64 Rsi;
    unsigned __int64 Rdi;
    unsigned __int64 R12;
    unsigned __int64 R13;
    unsigned __int64 R14;
    unsigned __int64 R15;
    unsigned __int64 Rip;
    unsigned __int64 Spare;
    struct MSVCRT__SETJMP_FLOAT128 Xmm6;
    struct MSVCRT__SETJMP_FLOAT128 Xmm7;
    struct MSVCRT__SETJMP_FLOAT128 Xmm8;
    struct MSVCRT__SETJMP_FLOAT128 Xmm9;
    struct MSVCRT__SETJMP_FLOAT128 Xmm10;
    struct MSVCRT__SETJMP_FLOAT128 Xmm11;
    struct MSVCRT__SETJMP_FLOAT128 Xmm12;
    struct MSVCRT__SETJMP_FLOAT128 Xmm13;
    struct MSVCRT__SETJMP_FLOAT128 Xmm14;
    struct MSVCRT__SETJMP_FLOAT128 Xmm15;
};
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
#elif defined(__arm__)
struct MSVCRT___JUMP_BUFFER
{
    unsigned long Frame;
    unsigned long R4;
    unsigned long R5;
    unsigned long R6;
    unsigned long R7;
    unsigned long R8;
    unsigned long R9;
    unsigned long R10;
    unsigned long R11;
    unsigned long Sp;
    unsigned long Pc;
    unsigned long Fpscr;
    unsigned long long D[8];
};
472 473 474 475 476 477 478 479 480
#endif /* __i386__ */

struct MSVCRT__diskfree_t {
  unsigned int total_clusters;
  unsigned int avail_clusters;
  unsigned int sectors_per_cluster;
  unsigned int bytes_per_sector;
};

481 482 483 484 485 486 487
struct MSVCRT__finddata32_t {
  unsigned int      attrib;
  MSVCRT___time32_t time_create;
  MSVCRT___time32_t time_access;
  MSVCRT___time32_t time_write;
  MSVCRT__fsize_t   size;
  char              name[260];
488 489
};

490 491 492 493 494
struct MSVCRT__finddata32i64_t {
  unsigned int      attrib;
  MSVCRT___time32_t time_create;
  MSVCRT___time32_t time_access;
  MSVCRT___time32_t time_write;
495
  __int64 DECLSPEC_ALIGN(8) size;
496
  char              name[260];
497 498
};

499 500 501 502 503 504 505
struct MSVCRT__finddata64i32_t {
  unsigned int      attrib;
  MSVCRT___time64_t time_create;
  MSVCRT___time64_t time_access;
  MSVCRT___time64_t time_write;
  MSVCRT__fsize_t   size;
  char              name[260];
506 507
};

508 509 510 511 512
struct MSVCRT__finddata64_t {
  unsigned int      attrib;
  MSVCRT___time64_t time_create;
  MSVCRT___time64_t time_access;
  MSVCRT___time64_t time_write;
513
  __int64 DECLSPEC_ALIGN(8) size;
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530
  char              name[260];
};

struct MSVCRT__wfinddata32_t {
  unsigned int      attrib;
  MSVCRT___time32_t time_create;
  MSVCRT___time32_t time_access;
  MSVCRT___time32_t time_write;
  MSVCRT__fsize_t   size;
  MSVCRT_wchar_t    name[260];
};

struct MSVCRT__wfinddata32i64_t {
  unsigned int      attrib;
  MSVCRT___time32_t time_create;
  MSVCRT___time32_t time_access;
  MSVCRT___time32_t time_write;
531
  __int64 DECLSPEC_ALIGN(8) size;
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
  MSVCRT_wchar_t    name[260];
};

struct MSVCRT__wfinddata64i32_t {
  unsigned int      attrib;
  MSVCRT___time64_t time_create;
  MSVCRT___time64_t time_access;
  MSVCRT___time64_t time_write;
  MSVCRT__fsize_t   size;
  MSVCRT_wchar_t    name[260];
};

struct MSVCRT__wfinddata64_t {
  unsigned int      attrib;
  MSVCRT___time64_t time_create;
  MSVCRT___time64_t time_access;
  MSVCRT___time64_t time_write;
549
  __int64 DECLSPEC_ALIGN(8) size;
550
  MSVCRT_wchar_t    name[260];
551 552
};

553
struct MSVCRT___utimbuf32
554
{
555 556 557 558 559 560 561 562
    MSVCRT___time32_t actime;
    MSVCRT___time32_t modtime;
};

struct MSVCRT___utimbuf64
{
    MSVCRT___time64_t actime;
    MSVCRT___time64_t modtime;
563 564 565 566 567 568 569
};

/* for FreeBSD */
#undef st_atime
#undef st_ctime
#undef st_mtime

570 571 572 573 574 575 576 577 578 579 580 581
struct MSVCRT__stat32 {
  MSVCRT__dev_t     st_dev;
  MSVCRT__ino_t     st_ino;
  unsigned short    st_mode;
  short             st_nlink;
  short             st_uid;
  short             st_gid;
  MSVCRT__dev_t     st_rdev;
  MSVCRT__off_t     st_size;
  MSVCRT___time32_t st_atime;
  MSVCRT___time32_t st_mtime;
  MSVCRT___time32_t st_ctime;
582 583
};

584 585 586 587 588 589 590 591 592 593 594 595
struct MSVCRT__stat32i64 {
  MSVCRT__dev_t     st_dev;
  MSVCRT__ino_t     st_ino;
  unsigned short    st_mode;
  short             st_nlink;
  short             st_uid;
  short             st_gid;
  MSVCRT__dev_t     st_rdev;
  __int64 DECLSPEC_ALIGN(8) st_size;
  MSVCRT___time32_t st_atime;
  MSVCRT___time32_t st_mtime;
  MSVCRT___time32_t st_ctime;
596 597
};

598 599 600 601 602 603 604 605 606 607 608 609
struct MSVCRT__stat64i32 {
  MSVCRT__dev_t     st_dev;
  MSVCRT__ino_t     st_ino;
  unsigned short    st_mode;
  short             st_nlink;
  short             st_uid;
  short             st_gid;
  MSVCRT__dev_t     st_rdev;
  MSVCRT__off_t     st_size;
  MSVCRT___time64_t st_atime;
  MSVCRT___time64_t st_mtime;
  MSVCRT___time64_t st_ctime;
610 611
};

612 613 614 615 616 617 618 619 620 621 622 623 624 625
struct MSVCRT__stat64 {
  MSVCRT__dev_t     st_dev;
  MSVCRT__ino_t     st_ino;
  unsigned short    st_mode;
  short             st_nlink;
  short             st_uid;
  short             st_gid;
  MSVCRT__dev_t     st_rdev;
  __int64 DECLSPEC_ALIGN(8) st_size;
  MSVCRT___time64_t st_atime;
  MSVCRT___time64_t st_mtime;
  MSVCRT___time64_t st_ctime;
};

626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641
#ifdef _WIN64
#define MSVCRT__finddata_t     MSVCRT__finddata64i32_t
#define MSVCRT__finddatai64_t  MSVCRT__finddata64_t
#define MSVCRT__wfinddata_t    MSVCRT__wfinddata64i32_t
#define MSVCRT__wfinddatai64_t MSVCRT__wfinddata64_t
#define MSVCRT__stat           MSVCRT__stat64i32
#define MSVCRT__stati64        MSVCRT__stat64
#else
#define MSVCRT__finddata_t     MSVCRT__finddata32_t
#define MSVCRT__finddatai64_t  MSVCRT__finddata32i64_t
#define MSVCRT__wfinddata_t    MSVCRT__wfinddata32_t
#define MSVCRT__wfinddatai64_t MSVCRT__wfinddata32i64_t
#define MSVCRT__stat           MSVCRT__stat32
#define MSVCRT__stati64        MSVCRT__stat32i64
#endif

642 643 644
#define MSVCRT_WEOF (MSVCRT_wint_t)(0xFFFF)
#define MSVCRT_EOF       (-1)
#define MSVCRT_TMP_MAX   0x7fff
645
#define MSVCRT_RAND_MAX  0x7fff
646 647 648 649 650 651 652 653 654 655 656 657
#define MSVCRT_BUFSIZ    512

#define MSVCRT_STDIN_FILENO  0
#define MSVCRT_STDOUT_FILENO 1
#define MSVCRT_STDERR_FILENO 2

/* more file._flag flags, but these conflict with Unix */
#define MSVCRT__IOFBF    0x0000
#define MSVCRT__IONBF    0x0004
#define MSVCRT__IOLBF    0x0040

#define MSVCRT_FILENAME_MAX 260
658 659 660 661 662
#define MSVCRT_DRIVE_MAX    3
#define MSVCRT_FNAME_MAX    256
#define MSVCRT_DIR_MAX      256
#define MSVCRT_EXT_MAX      256
#define MSVCRT_PATH_MAX     260
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710
#define MSVCRT_stdin       (MSVCRT__iob+MSVCRT_STDIN_FILENO)
#define MSVCRT_stdout      (MSVCRT__iob+MSVCRT_STDOUT_FILENO)
#define MSVCRT_stderr      (MSVCRT__iob+MSVCRT_STDERR_FILENO)

#define MSVCRT__P_WAIT    0
#define MSVCRT__P_NOWAIT  1
#define MSVCRT__P_OVERLAY 2
#define MSVCRT__P_NOWAITO 3
#define MSVCRT__P_DETACH  4

#define MSVCRT_EPERM   1
#define MSVCRT_ENOENT  2
#define MSVCRT_ESRCH   3
#define MSVCRT_EINTR   4
#define MSVCRT_EIO     5
#define MSVCRT_ENXIO   6
#define MSVCRT_E2BIG   7
#define MSVCRT_ENOEXEC 8
#define MSVCRT_EBADF   9
#define MSVCRT_ECHILD  10
#define MSVCRT_EAGAIN  11
#define MSVCRT_ENOMEM  12
#define MSVCRT_EACCES  13
#define MSVCRT_EFAULT  14
#define MSVCRT_EBUSY   16
#define MSVCRT_EEXIST  17
#define MSVCRT_EXDEV   18
#define MSVCRT_ENODEV  19
#define MSVCRT_ENOTDIR 20
#define MSVCRT_EISDIR  21
#define MSVCRT_EINVAL  22
#define MSVCRT_ENFILE  23
#define MSVCRT_EMFILE  24
#define MSVCRT_ENOTTY  25
#define MSVCRT_EFBIG   27
#define MSVCRT_ENOSPC  28
#define MSVCRT_ESPIPE  29
#define MSVCRT_EROFS   30
#define MSVCRT_EMLINK  31
#define MSVCRT_EPIPE   32
#define MSVCRT_EDOM    33
#define MSVCRT_ERANGE  34
#define MSVCRT_EDEADLK 36
#define MSVCRT_EDEADLOCK MSVCRT_EDEADLK
#define MSVCRT_ENAMETOOLONG 38
#define MSVCRT_ENOLCK  39
#define MSVCRT_ENOSYS  40
#define MSVCRT_ENOTEMPTY 41
711
#define MSVCRT_EILSEQ    42
712
#define MSVCRT_STRUNCATE 80
713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733

#define MSVCRT_LC_ALL          0
#define MSVCRT_LC_COLLATE      1
#define MSVCRT_LC_CTYPE        2
#define MSVCRT_LC_MONETARY     3
#define MSVCRT_LC_NUMERIC      4
#define MSVCRT_LC_TIME         5
#define MSVCRT_LC_MIN          MSVCRT_LC_ALL
#define MSVCRT_LC_MAX          MSVCRT_LC_TIME

#define MSVCRT__HEAPEMPTY      -1
#define MSVCRT__HEAPOK         -2
#define MSVCRT__HEAPBADBEGIN   -3
#define MSVCRT__HEAPBADNODE    -4
#define MSVCRT__HEAPEND        -5
#define MSVCRT__HEAPBADPTR     -6

#define MSVCRT__FREEENTRY      0
#define MSVCRT__USEDENTRY      1

#define MSVCRT__OUT_TO_DEFAULT 0
734 735
#define MSVCRT__OUT_TO_STDERR  1
#define MSVCRT__OUT_TO_MSGBOX  2
736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756
#define MSVCRT__REPORT_ERRMODE 3

/* ASCII char classification table - binary compatible */
#define MSVCRT__UPPER    0x0001  /* C1_UPPER */
#define MSVCRT__LOWER    0x0002  /* C1_LOWER */
#define MSVCRT__DIGIT    0x0004  /* C1_DIGIT */
#define MSVCRT__SPACE    0x0008  /* C1_SPACE */
#define MSVCRT__PUNCT    0x0010  /* C1_PUNCT */
#define MSVCRT__CONTROL  0x0020  /* C1_CNTRL */
#define MSVCRT__BLANK    0x0040  /* C1_BLANK */
#define MSVCRT__HEX      0x0080  /* C1_XDIGIT */
#define MSVCRT__LEADBYTE 0x8000
#define MSVCRT__ALPHA   (0x0100|MSVCRT__UPPER|MSVCRT__LOWER)  /* (C1_ALPHA|_UPPER|_LOWER) */

#define MSVCRT__IOREAD   0x0001
#define MSVCRT__IOWRT    0x0002
#define MSVCRT__IOMYBUF  0x0008
#define MSVCRT__IOEOF    0x0010
#define MSVCRT__IOERR    0x0020
#define MSVCRT__IOSTRG   0x0040
#define MSVCRT__IORW     0x0080
757
#define MSVCRT__USERBUF  0x0100
758
#define MSVCRT__IOCOMMIT 0x4000
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796

#define MSVCRT__S_IEXEC  0x0040
#define MSVCRT__S_IWRITE 0x0080
#define MSVCRT__S_IREAD  0x0100
#define MSVCRT__S_IFIFO  0x1000
#define MSVCRT__S_IFCHR  0x2000
#define MSVCRT__S_IFDIR  0x4000
#define MSVCRT__S_IFREG  0x8000
#define MSVCRT__S_IFMT   0xF000

#define MSVCRT__LK_UNLCK  0
#define MSVCRT__LK_LOCK   1
#define MSVCRT__LK_NBLCK  2
#define MSVCRT__LK_RLCK   3
#define MSVCRT__LK_NBRLCK 4

#define	MSVCRT__SH_COMPAT	0x00	/* Compatibility */
#define	MSVCRT__SH_DENYRW	0x10	/* Deny read/write */
#define	MSVCRT__SH_DENYWR	0x20	/* Deny write */
#define	MSVCRT__SH_DENYRD	0x30	/* Deny read */
#define	MSVCRT__SH_DENYNO	0x40	/* Deny nothing */

#define MSVCRT__O_RDONLY        0
#define MSVCRT__O_WRONLY        1
#define MSVCRT__O_RDWR          2
#define MSVCRT__O_ACCMODE       (MSVCRT__O_RDONLY|MSVCRT__O_WRONLY|MSVCRT__O_RDWR)
#define MSVCRT__O_APPEND        0x0008
#define MSVCRT__O_RANDOM        0x0010
#define MSVCRT__O_SEQUENTIAL    0x0020
#define MSVCRT__O_TEMPORARY     0x0040
#define MSVCRT__O_NOINHERIT     0x0080
#define MSVCRT__O_CREAT         0x0100
#define MSVCRT__O_TRUNC         0x0200
#define MSVCRT__O_EXCL          0x0400
#define MSVCRT__O_SHORT_LIVED   0x1000
#define MSVCRT__O_TEXT          0x4000
#define MSVCRT__O_BINARY        0x8000
#define MSVCRT__O_RAW           MSVCRT__O_BINARY
797 798 799
#define MSVCRT__O_WTEXT         0x10000
#define MSVCRT__O_U16TEXT       0x20000
#define MSVCRT__O_U8TEXT        0x40000
800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826

/* _statusfp bit flags */
#define MSVCRT__SW_INEXACT      0x00000001 /* inexact (precision) */
#define MSVCRT__SW_UNDERFLOW    0x00000002 /* underflow */
#define MSVCRT__SW_OVERFLOW     0x00000004 /* overflow */
#define MSVCRT__SW_ZERODIVIDE   0x00000008 /* zero divide */
#define MSVCRT__SW_INVALID      0x00000010 /* invalid */

#define MSVCRT__SW_UNEMULATED     0x00000040  /* unemulated instruction */
#define MSVCRT__SW_SQRTNEG        0x00000080  /* square root of a neg number */
#define MSVCRT__SW_STACKOVERFLOW  0x00000200  /* FP stack overflow */
#define MSVCRT__SW_STACKUNDERFLOW 0x00000400  /* FP stack underflow */

#define MSVCRT__SW_DENORMAL     0x00080000 /* denormal status bit */

/* fpclass constants */
#define MSVCRT__FPCLASS_SNAN 0x0001  /* Signaling "Not a Number" */
#define MSVCRT__FPCLASS_QNAN 0x0002  /* Quiet "Not a Number" */
#define MSVCRT__FPCLASS_NINF 0x0004  /* Negative Infinity */
#define MSVCRT__FPCLASS_NN   0x0008  /* Negative Normal */
#define MSVCRT__FPCLASS_ND   0x0010  /* Negative Denormal */
#define MSVCRT__FPCLASS_NZ   0x0020  /* Negative Zero */
#define MSVCRT__FPCLASS_PZ   0x0040  /* Positive Zero */
#define MSVCRT__FPCLASS_PD   0x0080  /* Positive Denormal */
#define MSVCRT__FPCLASS_PN   0x0100  /* Positive Normal */
#define MSVCRT__FPCLASS_PINF 0x0200  /* Positive Infinity */

827 828 829 830 831 832 833
/* fpclassify constants */
#define MSVCRT_FP_INFINITE   1
#define MSVCRT_FP_NAN        2
#define MSVCRT_FP_NORMAL    -1
#define MSVCRT_FP_SUBNORMAL -2
#define MSVCRT_FP_ZERO       0

834 835 836 837 838 839
#define MSVCRT__MCW_EM        0x0008001f
#define MSVCRT__MCW_IC        0x00040000
#define MSVCRT__MCW_RC        0x00000300
#define MSVCRT__MCW_PC        0x00030000
#define MSVCRT__MCW_DN        0x03000000

840 841 842 843 844 845 846 847 848 849 850 851 852 853 854
#define MSVCRT__EM_INVALID    0x00000010
#define MSVCRT__EM_DENORMAL   0x00080000
#define MSVCRT__EM_ZERODIVIDE 0x00000008
#define MSVCRT__EM_OVERFLOW   0x00000004
#define MSVCRT__EM_UNDERFLOW  0x00000002
#define MSVCRT__EM_INEXACT    0x00000001
#define MSVCRT__IC_AFFINE     0x00040000
#define MSVCRT__IC_PROJECTIVE 0x00000000
#define MSVCRT__RC_CHOP       0x00000300
#define MSVCRT__RC_UP         0x00000200
#define MSVCRT__RC_DOWN       0x00000100
#define MSVCRT__RC_NEAR       0x00000000
#define MSVCRT__PC_24         0x00020000
#define MSVCRT__PC_53         0x00010000
#define MSVCRT__PC_64         0x00000000
855 856 857 858 859
#define MSVCRT__DN_SAVE       0x00000000
#define MSVCRT__DN_FLUSH      0x01000000
#define MSVCRT__DN_FLUSH_OPERANDS_SAVE_RESULTS 0x02000000
#define MSVCRT__DN_SAVE_OPERANDS_FLUSH_RESULTS 0x03000000
#define MSVCRT__EM_AMBIGUOUS  0x80000000
860

861 862
#define MSVCRT_CLOCKS_PER_SEC 1000

863 864 865 866 867 868 869 870 871 872
/* signals */
#define MSVCRT_SIGINT   2
#define MSVCRT_SIGILL   4
#define MSVCRT_SIGFPE   8
#define MSVCRT_SIGSEGV  11
#define MSVCRT_SIGTERM  15
#define MSVCRT_SIGBREAK 21
#define MSVCRT_SIGABRT  22
#define MSVCRT_NSIG     (MSVCRT_SIGABRT + 1)

873
typedef void (__cdecl *MSVCRT___sighandler_t)(int);
874 875 876 877 878

#define MSVCRT_SIG_DFL ((MSVCRT___sighandler_t)0)
#define MSVCRT_SIG_IGN ((MSVCRT___sighandler_t)1)
#define MSVCRT_SIG_ERR ((MSVCRT___sighandler_t)-1)

879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908
#define MSVCRT__FPE_INVALID            0x81
#define MSVCRT__FPE_DENORMAL           0x82
#define MSVCRT__FPE_ZERODIVIDE         0x83
#define MSVCRT__FPE_OVERFLOW           0x84
#define MSVCRT__FPE_UNDERFLOW          0x85
#define MSVCRT__FPE_INEXACT            0x86
#define MSVCRT__FPE_UNEMULATED         0x87
#define MSVCRT__FPE_SQRTNEG            0x88
#define MSVCRT__FPE_STACKOVERFLOW      0x8a
#define MSVCRT__FPE_STACKUNDERFLOW     0x8b
#define MSVCRT__FPE_EXPLICITGEN        0x8c

#define _MS     0x01
#define _MP     0x02
#define _M1     0x04
#define _M2     0x08

#define _SBUP   0x10
#define _SBLOW  0x20

#define _MBC_SINGLE     0
#define _MBC_LEAD       1
#define _MBC_TRAIL      2
#define _MBC_ILLEGAL    -1

#define _MB_CP_SBCS     0
#define _MB_CP_OEM      -2
#define _MB_CP_ANSI     -3
#define _MB_CP_LOCALE   -4

909
#define MSVCRT__TRUNCATE ((MSVCRT_size_t)-1)
910

911 912
#define _MAX__TIME64_T    (((MSVCRT___time64_t)0x00000007 << 32) | 0x93406FFF)

913 914 915 916
/* _set_abort_behavior codes */
#define MSVCRT__WRITE_ABORT_MSG    1
#define MSVCRT__CALL_REPORTFAULT   2

917 918 919
/* _get_output_format return code */
#define MSVCRT__TWO_DIGIT_EXPONENT 0x1

920 921
#define MSVCRT__NLSCMPERROR ((unsigned int)0x7fffffff)

922 923 924 925 926 927 928 929 930
void  __cdecl    MSVCRT_free(void*);
void* __cdecl    MSVCRT_malloc(MSVCRT_size_t);
void* __cdecl    MSVCRT_calloc(MSVCRT_size_t,MSVCRT_size_t);
void* __cdecl    MSVCRT_realloc(void*,MSVCRT_size_t);

int __cdecl      MSVCRT_iswalpha(MSVCRT_wint_t);
int __cdecl      MSVCRT_iswspace(MSVCRT_wint_t);
int __cdecl      MSVCRT_iswdigit(MSVCRT_wint_t);
int __cdecl      MSVCRT_isleadbyte(int);
931
int __cdecl      MSVCRT__isleadbyte_l(int, MSVCRT__locale_t);
932

933 934
void __cdecl     MSVCRT__lock_file(MSVCRT_FILE*);
void __cdecl     MSVCRT__unlock_file(MSVCRT_FILE*);
935
int __cdecl      MSVCRT_fgetc(MSVCRT_FILE*);
936
int __cdecl      MSVCRT__fgetc_nolock(MSVCRT_FILE*);
937
int __cdecl      MSVCRT__fputc_nolock(int,MSVCRT_FILE*);
938
int __cdecl      MSVCRT_ungetc(int,MSVCRT_FILE*);
939
int __cdecl      MSVCRT__ungetc_nolock(int,MSVCRT_FILE*);
940
MSVCRT_wint_t __cdecl MSVCRT_fgetwc(MSVCRT_FILE*);
941
MSVCRT_wint_t __cdecl MSVCRT__fgetwc_nolock(MSVCRT_FILE*);
942
MSVCRT_wint_t __cdecl MSVCRT__fputwc_nolock(MSVCRT_wint_t,MSVCRT_FILE*);
943
MSVCRT_wint_t __cdecl MSVCRT_ungetwc(MSVCRT_wint_t,MSVCRT_FILE*);
944
MSVCRT_wint_t __cdecl MSVCRT__ungetwc_nolock(MSVCRT_wint_t, MSVCRT_FILE*);
945
int __cdecl      MSVCRT__fseeki64_nolock(MSVCRT_FILE*,__int64,int);
946
__int64 __cdecl  MSVCRT__ftelli64(MSVCRT_FILE* file);
947
__int64 __cdecl  MSVCRT__ftelli64_nolock(MSVCRT_FILE*);
948 949
void __cdecl     MSVCRT__exit(int);
void __cdecl     MSVCRT_abort(void);
950
MSVCRT_ulong* __cdecl MSVCRT___doserrno(void);
951 952
int* __cdecl     MSVCRT__errno(void);
char* __cdecl    MSVCRT_getenv(const char*);
953
MSVCRT_size_t __cdecl MSVCRT__fread_nolock(void*,MSVCRT_size_t,MSVCRT_size_t,MSVCRT_FILE*);
954
MSVCRT_size_t __cdecl MSVCRT__fread_nolock_s(void*,MSVCRT_size_t,MSVCRT_size_t,MSVCRT_size_t,MSVCRT_FILE*);
955
MSVCRT_size_t __cdecl MSVCRT__fwrite_nolock(const void*,MSVCRT_size_t,MSVCRT_size_t,MSVCRT_FILE*);
956
int __cdecl      MSVCRT_fclose(MSVCRT_FILE*);
957
int __cdecl      MSVCRT__fclose_nolock(MSVCRT_FILE*);
958
int __cdecl      MSVCRT__fflush_nolock(MSVCRT_FILE*);
959
void __cdecl     MSVCRT_terminate(void);
960
MSVCRT_FILE* __cdecl MSVCRT__iob_func(void);
961
MSVCRT_clock_t __cdecl MSVCRT_clock(void);
962 963
MSVCRT___time32_t __cdecl MSVCRT__time32(MSVCRT___time32_t*);
MSVCRT___time64_t __cdecl MSVCRT__time64(MSVCRT___time64_t*);
964 965
MSVCRT_FILE*   __cdecl MSVCRT__fdopen(int, const char *);
MSVCRT_FILE*   __cdecl MSVCRT__wfdopen(int, const MSVCRT_wchar_t *);
966
int            __cdecl MSVCRT_vsnprintf(char *str, MSVCRT_size_t len, const char *format, __ms_va_list valist);
967
int            __cdecl MSVCRT_vsnwprintf(MSVCRT_wchar_t *str, MSVCRT_size_t len,
968
                                       const MSVCRT_wchar_t *format, __ms_va_list valist );
969
int            __cdecl MSVCRT__snwprintf(MSVCRT_wchar_t*, unsigned int, const MSVCRT_wchar_t*, ...);
970
int            __cdecl MSVCRT_sprintf(char*,const char*,...);
971
int            __cdecl MSVCRT__snprintf(char*,unsigned int,const char*,...);
972
int            __cdecl MSVCRT__scprintf(const char*,...);
973
int            __cdecl MSVCRT_raise(int sig);
974
int            __cdecl MSVCRT__set_printf_count_output(int);
975

976 977 978
#define MSVCRT__ENABLE_PER_THREAD_LOCALE 1
#define MSVCRT__DISABLE_PER_THREAD_LOCALE 2

979
extern MSVCRT__locale_t MSVCRT_locale;
980 981
MSVCRT_pthreadlocinfo get_locinfo(void) DECLSPEC_HIDDEN;
MSVCRT_pthreadmbcinfo get_mbcinfo(void) DECLSPEC_HIDDEN;
982
void __cdecl MSVCRT__free_locale(MSVCRT__locale_t);
983 984 985
void free_locinfo(MSVCRT_pthreadlocinfo) DECLSPEC_HIDDEN;
void free_mbcinfo(MSVCRT_pthreadmbcinfo) DECLSPEC_HIDDEN;
int _setmbcp_l(int, LCID, MSVCRT_pthreadmbcinfo) DECLSPEC_HIDDEN;
986

987
#ifndef __WINE_MSVCRT_TEST
988 989
int            __cdecl MSVCRT__write(int,const void*,unsigned int);
int            __cdecl _getch(void);
990
int            __cdecl _ismbblead(unsigned int);
991
int            __cdecl _ismbclegal(unsigned int c);
992
int            __cdecl _ismbstrail(const unsigned char* start, const unsigned char* str);
993
int            __cdecl MSVCRT_mbtowc(MSVCRT_wchar_t*,const char*,MSVCRT_size_t);
994
MSVCRT_size_t  __cdecl MSVCRT_mbstowcs(MSVCRT_wchar_t*,const char*,MSVCRT_size_t);
995
MSVCRT_size_t  __cdecl MSVCRT_wcstombs(char*,const MSVCRT_wchar_t*,MSVCRT_size_t);
996 997
MSVCRT_intptr_t __cdecl MSVCRT__spawnve(int,const char*,const char* const *,const char* const *);
MSVCRT_intptr_t __cdecl MSVRT__spawnvpe(int,const char*,const char* const *,const char* const *);
998 999 1000 1001 1002
MSVCRT_intptr_t __cdecl MSVCRT__wspawnve(int,const MSVCRT_wchar_t*,const MSVCRT_wchar_t* const *,const MSVCRT_wchar_t* const *);
MSVCRT_intptr_t __cdecl MSVCRT__wspawnvpe(int,const MSVCRT_wchar_t*,const MSVCRT_wchar_t* const *,const MSVCRT_wchar_t* const *);
void __cdecl     MSVCRT__searchenv(const char*,const char*,char*);
int __cdecl      MSVCRT__getdrive(void);
char* __cdecl    MSVCRT__strdup(const char*);
1003
char* __cdecl    MSVCRT__strnset(char*,int,MSVCRT_size_t);
1004 1005 1006 1007
char* __cdecl    _strset(char*,int);
int __cdecl      _ungetch(int);
int __cdecl      _cputs(const char*);
int __cdecl      _cprintf(const char*,...);
1008
int __cdecl      _cwprintf(const MSVCRT_wchar_t*,...);
1009
char*** __cdecl  MSVCRT___p__environ(void);
1010 1011
int*    __cdecl  __p___mb_cur_max(void);
unsigned int*  __cdecl __p__fmode(void);
1012 1013
MSVCRT_wchar_t* __cdecl MSVCRT__wcsdup(const MSVCRT_wchar_t*);
MSVCRT_wchar_t*** __cdecl MSVCRT___p__wenviron(void);
1014
INT     __cdecl MSVCRT_wctomb(char*,MSVCRT_wchar_t);
1015 1016
char*   __cdecl MSVCRT__strdate(char* date);
char*   __cdecl MSVCRT__strtime(char* date);
1017
int     __cdecl _setmbcp(int);
1018 1019 1020 1021
int     __cdecl MSVCRT__close(int);
int     __cdecl MSVCRT__dup(int);
int     __cdecl MSVCRT__dup2(int, int);
int     __cdecl MSVCRT__pipe(int *, unsigned int, int);
1022 1023
MSVCRT_wchar_t* __cdecl MSVCRT__wgetenv(const MSVCRT_wchar_t*);
void __cdecl    MSVCRT__wsearchenv(const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, MSVCRT_wchar_t*);
1024
MSVCRT_intptr_t __cdecl MSVCRT__spawnvpe(int, const char*, const char* const*, const char* const*);
1025 1026
void __cdecl MSVCRT__invalid_parameter(const MSVCRT_wchar_t *expr, const MSVCRT_wchar_t *func,
                                       const MSVCRT_wchar_t *file, unsigned int line, MSVCRT_uintptr_t arg);
1027 1028
int __cdecl      MSVCRT__toupper_l(int,MSVCRT__locale_t);
int __cdecl      MSVCRT__tolower_l(int,MSVCRT__locale_t);
1029
int __cdecl      MSVCRT__strnicoll_l(const char*, const char*, MSVCRT_size_t, MSVCRT__locale_t);
1030
int __cdecl      MSVCRT__strncoll_l(const char*, const char*, MSVCRT_size_t, MSVCRT__locale_t);
1031
unsigned int __cdecl MSVCRT__get_output_format(void);
1032
char* __cdecl MSVCRT_strtok_s(char*, const char*, char**);
1033 1034 1035 1036 1037 1038 1039 1040 1041

/* Maybe one day we'll enable the invalid parameter handlers with the full set of information (msvcrXXd)
 *      #define MSVCRT_INVALID_PMT(x) MSVCRT_call_invalid_parameter_handler(x, __FUNCTION__, __FILE__, __LINE__, 0)
 *      #define MSVCRT_CHECK_PMT(x)   ((x) ? TRUE : MSVCRT_INVALID_PMT(#x),FALSE)
 * Until this is done, just keep the same semantics for CHECK_PMT(), but without generating / sending
 * any information
 * NB : MSVCRT_call_invalid_parameter_handler is a wrapper around MSVCRT__invalid_parameter in order
 * to do the Ansi to Unicode transformation
 */
1042 1043 1044
#define MSVCRT_INVALID_PMT(x,err)   (*MSVCRT__errno() = (err), MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0))
#define MSVCRT_CHECK_PMT_ERR(x,err) ((x) || (MSVCRT_INVALID_PMT( 0, (err) ), FALSE))
#define MSVCRT_CHECK_PMT(x)         MSVCRT_CHECK_PMT_ERR((x), MSVCRT_EINVAL)
1045 1046
#endif

1047
#define MSVCRT__ARGMAX 100
1048 1049 1050 1051 1052 1053 1054 1055 1056
typedef int (*puts_clbk_a)(void*, int, const char*);
typedef int (*puts_clbk_w)(void*, int, const MSVCRT_wchar_t*);
typedef union _printf_arg
{
    void *get_ptr;
    int get_int;
    LONGLONG get_longlong;
    double get_double;
} printf_arg;
1057
typedef printf_arg (*args_clbk)(void*, int, int, __ms_va_list*);
1058
int pf_printf_a(puts_clbk_a, void*, const char*, MSVCRT__locale_t,
1059
        BOOL, BOOL, args_clbk, void*, __ms_va_list*) DECLSPEC_HIDDEN;
1060
int pf_printf_w(puts_clbk_w, void*, const MSVCRT_wchar_t*, MSVCRT__locale_t,
1061 1062
        BOOL, BOOL, args_clbk, void*, __ms_va_list*) DECLSPEC_HIDDEN;
printf_arg arg_clbk_valist(void*, int, int, __ms_va_list*) DECLSPEC_HIDDEN;
1063

1064
#define MSVCRT_FLT_MIN 1.175494351e-38F
1065
#define MSVCRT_DBL_MIN 2.2250738585072014e-308
1066 1067 1068 1069 1070 1071 1072 1073
#define MSVCRT__OVERFLOW  3
#define MSVCRT__UNDERFLOW 4

typedef struct
{
    float f;
} MSVCRT__CRT_FLOAT;

1074 1075 1076 1077 1078
typedef struct
{
    double x;
} MSVCRT__CRT_DOUBLE;

1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100
extern char* __cdecl __unDName(char *,const char*,int,malloc_func_t,free_func_t,unsigned short int);

/* __unDName/__unDNameEx flags */
#define UNDNAME_COMPLETE                 (0x0000)
#define UNDNAME_NO_LEADING_UNDERSCORES   (0x0001) /* Don't show __ in calling convention */
#define UNDNAME_NO_MS_KEYWORDS           (0x0002) /* Don't show calling convention at all */
#define UNDNAME_NO_FUNCTION_RETURNS      (0x0004) /* Don't show function/method return value */
#define UNDNAME_NO_ALLOCATION_MODEL      (0x0008)
#define UNDNAME_NO_ALLOCATION_LANGUAGE   (0x0010)
#define UNDNAME_NO_MS_THISTYPE           (0x0020)
#define UNDNAME_NO_CV_THISTYPE           (0x0040)
#define UNDNAME_NO_THISTYPE              (0x0060)
#define UNDNAME_NO_ACCESS_SPECIFIERS     (0x0080) /* Don't show access specifier (public/protected/private) */
#define UNDNAME_NO_THROW_SIGNATURES      (0x0100)
#define UNDNAME_NO_MEMBER_TYPE           (0x0200) /* Don't show static/virtual specifier */
#define UNDNAME_NO_RETURN_UDT_MODEL      (0x0400)
#define UNDNAME_32_BIT_DECODE            (0x0800)
#define UNDNAME_NAME_ONLY                (0x1000) /* Only report the variable/method name */
#define UNDNAME_NO_ARGUMENTS             (0x2000) /* Don't show method arguments */
#define UNDNAME_NO_SPECIAL_SYMS          (0x4000)
#define UNDNAME_NO_COMPLEX_TYPE          (0x8000)

1101
#endif /* __WINE_MSVCRT_H */