2010-07-20 23:22:59 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Piotr Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdlib.h"
|
2010-08-18 10:36:40 +02:00
|
|
|
#include "windef.h"
|
2012-07-03 16:52:39 +02:00
|
|
|
#include "cxx.h"
|
2010-07-20 23:22:59 +02:00
|
|
|
|
2013-12-19 17:02:11 +01:00
|
|
|
#define ALIGNED_SIZE(size, alignment) (((size)+((alignment)-1))/(alignment)*(alignment))
|
|
|
|
|
2011-05-27 14:34:27 +02:00
|
|
|
typedef unsigned char MSVCP_bool;
|
2011-05-27 14:56:18 +02:00
|
|
|
typedef SIZE_T MSVCP_size_t;
|
2013-12-19 17:02:11 +01:00
|
|
|
|
|
|
|
#if _MSVCP_VER >= 100
|
|
|
|
typedef __int64 DECLSPEC_ALIGN(8) streamoff;
|
|
|
|
typedef __int64 DECLSPEC_ALIGN(8) streamsize;
|
|
|
|
#define STREAMOFF_BITS 64
|
|
|
|
#define STREAMSIZE_BITS 64
|
|
|
|
#else
|
2012-06-06 14:49:05 +02:00
|
|
|
typedef SSIZE_T streamoff;
|
|
|
|
typedef SSIZE_T streamsize;
|
2013-12-19 16:19:33 +01:00
|
|
|
#define STREAMOFF_BITS 32
|
|
|
|
#define STREAMSIZE_BITS 32
|
2013-12-19 17:02:11 +01:00
|
|
|
#endif
|
2010-07-20 23:22:59 +02:00
|
|
|
|
2015-11-03 22:54:34 +01:00
|
|
|
void __cdecl _invalid_parameter_noinfo(void);
|
2010-07-20 23:22:59 +02:00
|
|
|
void __cdecl _invalid_parameter(const wchar_t*, const wchar_t*,
|
|
|
|
const wchar_t*, unsigned int, uintptr_t);
|
2012-06-01 17:03:36 +02:00
|
|
|
BOOL __cdecl __uncaught_exception(void);
|
2015-11-03 22:54:34 +01:00
|
|
|
int __cdecl _callnewh(size_t);
|
2010-07-22 09:40:19 +02:00
|
|
|
|
2011-05-27 14:56:18 +02:00
|
|
|
extern void* (__cdecl *MSVCRT_operator_new)(MSVCP_size_t);
|
2010-07-25 12:23:22 +02:00
|
|
|
extern void (__cdecl *MSVCRT_operator_delete)(void*);
|
2011-09-13 10:30:29 +02:00
|
|
|
extern void* (__cdecl *MSVCRT_set_new_handler)(void*);
|
2010-07-22 09:40:19 +02:00
|
|
|
|
2014-06-26 13:46:09 +02:00
|
|
|
#if _MSVCP_VER >= 110
|
|
|
|
/* keep in sync with msvcrt/lock.c */
|
|
|
|
typedef struct cs_queue
|
|
|
|
{
|
|
|
|
struct cs_queue *next;
|
|
|
|
BOOL free;
|
|
|
|
int unknown;
|
|
|
|
} cs_queue;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ULONG_PTR unk_thread_id;
|
|
|
|
cs_queue unk_active;
|
|
|
|
void *unknown[2];
|
|
|
|
cs_queue *head;
|
|
|
|
void *tail;
|
|
|
|
} critical_section;
|
|
|
|
|
|
|
|
extern critical_section* (__thiscall *critical_section_ctor)(critical_section*);
|
|
|
|
extern void (__thiscall *critical_section_dtor)(critical_section*);
|
|
|
|
extern void (__thiscall *critical_section_lock)(critical_section*);
|
|
|
|
extern void (__thiscall *critical_section_unlock)(critical_section*);
|
|
|
|
extern MSVCP_bool (__thiscall *critical_section_trylock)(critical_section*);
|
|
|
|
#endif
|
|
|
|
|
2010-08-19 12:17:11 +02:00
|
|
|
/* basic_string<char, char_traits<char>, allocator<char>> */
|
2012-07-03 16:52:39 +02:00
|
|
|
typedef struct
|
2010-08-19 12:17:11 +02:00
|
|
|
{
|
2014-10-17 12:07:29 +02:00
|
|
|
#if _MSVCP_VER <= 90
|
2010-08-19 12:17:11 +02:00
|
|
|
void *allocator;
|
2014-10-17 12:07:29 +02:00
|
|
|
#endif
|
2010-08-30 16:35:30 +02:00
|
|
|
union {
|
2015-03-12 14:07:09 +01:00
|
|
|
#if _MSVCP_VER >= 70
|
|
|
|
#define BUF_SIZE_CHAR 16
|
2010-08-19 12:17:11 +02:00
|
|
|
char buf[BUF_SIZE_CHAR];
|
2015-03-12 14:07:09 +01:00
|
|
|
#endif
|
2010-08-19 12:17:11 +02:00
|
|
|
char *ptr;
|
|
|
|
} data;
|
2011-05-27 14:56:18 +02:00
|
|
|
MSVCP_size_t size;
|
|
|
|
MSVCP_size_t res;
|
2014-10-17 12:07:29 +02:00
|
|
|
#if _MSVCP_VER == 100
|
|
|
|
char allocator;
|
|
|
|
#endif
|
2010-08-19 12:17:11 +02:00
|
|
|
} basic_string_char;
|
|
|
|
|
2012-06-28 12:32:47 +02:00
|
|
|
basic_string_char* __thiscall MSVCP_basic_string_char_ctor(basic_string_char*);
|
2013-11-25 13:22:34 +01:00
|
|
|
basic_string_char* __thiscall MSVCP_basic_string_char_ctor_cstr(basic_string_char*, const char*);
|
2012-06-28 12:32:47 +02:00
|
|
|
basic_string_char* __thiscall MSVCP_basic_string_char_ctor_cstr_len(basic_string_char*, const char*, MSVCP_size_t);
|
2013-11-25 13:22:34 +01:00
|
|
|
basic_string_char* __thiscall MSVCP_basic_string_char_copy_ctor(basic_string_char*, const basic_string_char*);
|
2015-11-24 05:17:12 +01:00
|
|
|
void* __thiscall MSVCP_basic_string_char_dtor(basic_string_char*);
|
2013-11-25 13:22:34 +01:00
|
|
|
const char* __thiscall MSVCP_basic_string_char_c_str(const basic_string_char*);
|
2012-06-12 18:14:09 +02:00
|
|
|
void __thiscall MSVCP_basic_string_char_clear(basic_string_char*);
|
|
|
|
basic_string_char* __thiscall MSVCP_basic_string_char_append_ch(basic_string_char*, char);
|
2012-06-15 11:07:23 +02:00
|
|
|
MSVCP_size_t __thiscall MSVCP_basic_string_char_length(const basic_string_char*);
|
2013-08-28 15:13:54 +02:00
|
|
|
basic_string_char* __thiscall MSVCP_basic_string_char_assign(basic_string_char*, const basic_string_char*);
|
2010-08-19 23:48:56 +02:00
|
|
|
|
2012-07-03 16:52:39 +02:00
|
|
|
typedef struct
|
2010-08-30 16:35:30 +02:00
|
|
|
{
|
2014-10-17 12:07:29 +02:00
|
|
|
#if _MSVCP_VER <= 90
|
2010-08-30 16:35:30 +02:00
|
|
|
void *allocator;
|
2014-10-17 12:07:29 +02:00
|
|
|
#endif
|
2010-08-30 16:35:30 +02:00
|
|
|
union {
|
2015-03-12 14:07:09 +01:00
|
|
|
#if _MSVCP_VER >= 70
|
|
|
|
#define BUF_SIZE_WCHAR 8
|
2010-08-30 16:35:30 +02:00
|
|
|
wchar_t buf[BUF_SIZE_WCHAR];
|
2015-03-12 14:07:09 +01:00
|
|
|
#endif
|
2010-08-30 16:35:30 +02:00
|
|
|
wchar_t *ptr;
|
|
|
|
} data;
|
2011-05-27 14:56:18 +02:00
|
|
|
MSVCP_size_t size;
|
|
|
|
MSVCP_size_t res;
|
2014-10-17 12:07:29 +02:00
|
|
|
#if _MSVCP_VER == 100
|
|
|
|
char allocator;
|
|
|
|
#endif
|
2010-08-30 16:35:30 +02:00
|
|
|
} basic_string_wchar;
|
|
|
|
|
2012-06-29 12:03:55 +02:00
|
|
|
basic_string_wchar* __thiscall MSVCP_basic_string_wchar_ctor(basic_string_wchar*);
|
2013-11-25 13:22:34 +01:00
|
|
|
basic_string_wchar* __thiscall MSVCP_basic_string_wchar_ctor_cstr(basic_string_wchar*, const wchar_t*);
|
2012-06-29 12:03:55 +02:00
|
|
|
basic_string_wchar* __thiscall MSVCP_basic_string_wchar_ctor_cstr_len(basic_string_wchar*, const wchar_t*, MSVCP_size_t);
|
2015-11-24 05:17:12 +01:00
|
|
|
void* __thiscall MSVCP_basic_string_wchar_dtor(basic_string_wchar*);
|
2012-06-25 15:48:18 +02:00
|
|
|
const wchar_t* __thiscall MSVCP_basic_string_wchar_c_str(const basic_string_wchar*);
|
2012-06-26 14:34:26 +02:00
|
|
|
void __thiscall MSVCP_basic_string_wchar_clear(basic_string_wchar*);
|
|
|
|
basic_string_wchar* __thiscall MSVCP_basic_string_wchar_append_ch(basic_string_wchar*, wchar_t);
|
2012-06-25 15:48:18 +02:00
|
|
|
MSVCP_size_t __thiscall MSVCP_basic_string_wchar_length(const basic_string_wchar*);
|
2012-03-28 11:20:22 +02:00
|
|
|
|
2013-11-25 13:22:34 +01:00
|
|
|
char* __thiscall MSVCP_allocator_char_allocate(void*, MSVCP_size_t);
|
|
|
|
void __thiscall MSVCP_allocator_char_deallocate(void*, char*, MSVCP_size_t);
|
2014-10-17 12:07:29 +02:00
|
|
|
MSVCP_size_t __thiscall MSVCP_allocator_char_max_size(const void*);
|
2013-11-25 13:22:34 +01:00
|
|
|
wchar_t* __thiscall MSVCP_allocator_wchar_allocate(void*, MSVCP_size_t);
|
|
|
|
void __thiscall MSVCP_allocator_wchar_deallocate(void*, wchar_t*, MSVCP_size_t);
|
2014-10-17 12:07:29 +02:00
|
|
|
MSVCP_size_t __thiscall MSVCP_allocator_wchar_max_size(const void*);
|
2011-05-27 14:34:27 +02:00
|
|
|
|
2013-12-19 17:02:11 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
char null_str;
|
|
|
|
} _Yarn_char;
|
|
|
|
|
2016-05-10 15:24:04 +02:00
|
|
|
_Yarn_char* __thiscall _Yarn_char_ctor(_Yarn_char*);
|
2013-12-19 17:02:11 +01:00
|
|
|
_Yarn_char* __thiscall _Yarn_char_ctor_cstr(_Yarn_char*, const char*);
|
|
|
|
_Yarn_char* __thiscall _Yarn_char_copy_ctor(_Yarn_char*, const _Yarn_char*);
|
|
|
|
const char* __thiscall _Yarn_char_c_str(const _Yarn_char*);
|
|
|
|
void __thiscall _Yarn_char_dtor(_Yarn_char*);
|
|
|
|
_Yarn_char* __thiscall _Yarn_char_op_assign(_Yarn_char*, const _Yarn_char*);
|
|
|
|
|
2015-06-06 00:08:21 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
wchar_t *str;
|
|
|
|
wchar_t null_str;
|
|
|
|
} _Yarn_wchar;
|
|
|
|
|
2015-06-08 23:17:39 +02:00
|
|
|
_Yarn_wchar* __thiscall _Yarn_wchar_ctor(_Yarn_wchar*);
|
|
|
|
const wchar_t* __thiscall _Yarn_wchar__C_str(const _Yarn_wchar*);
|
|
|
|
void __thiscall _Yarn_wchar_dtor(_Yarn_wchar*);
|
|
|
|
_Yarn_wchar* __thiscall _Yarn_wchar_op_assign_cstr(_Yarn_wchar*, const wchar_t*);
|
|
|
|
|
2012-06-12 18:12:32 +02:00
|
|
|
/* class locale::facet */
|
|
|
|
typedef struct {
|
|
|
|
const vtable_ptr *vtable;
|
|
|
|
MSVCP_size_t refs;
|
|
|
|
} locale_facet;
|
|
|
|
|
2012-06-12 18:13:06 +02:00
|
|
|
typedef enum {
|
|
|
|
CODECVT_ok = 0,
|
|
|
|
CODECVT_partial = 1,
|
|
|
|
CODECVT_error = 2,
|
|
|
|
CODECVT_noconv = 3
|
|
|
|
} codecvt_base_result;
|
|
|
|
|
2012-06-18 16:59:56 +02:00
|
|
|
typedef struct {
|
2014-01-14 13:56:17 +01:00
|
|
|
#if _MSVCP_VER < 110
|
2012-06-18 16:59:56 +02:00
|
|
|
LCID handle;
|
2014-01-14 13:56:17 +01:00
|
|
|
#endif
|
2012-06-18 16:59:56 +02:00
|
|
|
unsigned page;
|
|
|
|
const short *table;
|
|
|
|
int delfl;
|
2014-01-14 13:56:17 +01:00
|
|
|
#if _MSVCP_VER >= 110
|
|
|
|
wchar_t *name;
|
|
|
|
#endif
|
2012-06-18 16:59:56 +02:00
|
|
|
} _Ctypevec;
|
|
|
|
|
2012-06-12 18:13:06 +02:00
|
|
|
/* class codecvt_base */
|
|
|
|
typedef struct {
|
|
|
|
locale_facet facet;
|
|
|
|
} codecvt_base;
|
|
|
|
|
|
|
|
/* class codecvt<char> */
|
|
|
|
typedef struct {
|
|
|
|
codecvt_base base;
|
|
|
|
} codecvt_char;
|
|
|
|
|
|
|
|
MSVCP_bool __thiscall codecvt_base_always_noconv(const codecvt_base*);
|
|
|
|
int __thiscall codecvt_char_unshift(const codecvt_char*, int*, char*, char*, char**);
|
|
|
|
int __thiscall codecvt_char_out(const codecvt_char*, int*, const char*,
|
|
|
|
const char*, const char**, char*, char*, char**);
|
|
|
|
int __thiscall codecvt_char_in(const codecvt_char*, int*, const char*,
|
|
|
|
const char*, const char**, char*, char*, char**);
|
|
|
|
int __thiscall codecvt_base_max_length(const codecvt_base*);
|
|
|
|
|
2012-06-14 15:37:13 +02:00
|
|
|
typedef struct {
|
2015-04-22 15:57:40 +02:00
|
|
|
#if _MSVCP_VER < 110
|
2012-06-14 15:37:13 +02:00
|
|
|
LCID handle;
|
2015-04-22 15:57:40 +02:00
|
|
|
#endif
|
2012-06-14 15:37:13 +02:00
|
|
|
unsigned page;
|
2015-04-22 15:57:40 +02:00
|
|
|
#if _MSVCP_VER >= 110
|
|
|
|
int mb_max;
|
|
|
|
int unk;
|
|
|
|
BYTE isleadbyte[32];
|
|
|
|
#endif
|
2012-06-18 16:59:56 +02:00
|
|
|
} _Cvtvec;
|
|
|
|
|
|
|
|
/* class codecvt<wchar> */
|
|
|
|
typedef struct {
|
|
|
|
codecvt_base base;
|
|
|
|
_Cvtvec cvt;
|
|
|
|
} codecvt_wchar;
|
2012-06-14 15:37:13 +02:00
|
|
|
|
2012-08-14 10:51:55 +02:00
|
|
|
int __thiscall codecvt_wchar_unshift(const codecvt_wchar*, int*, char*, char*, char**);
|
|
|
|
int __thiscall codecvt_wchar_out(const codecvt_wchar*, int*, const wchar_t*,
|
|
|
|
const wchar_t*, const wchar_t**, char*, char*, char**);
|
|
|
|
int __thiscall codecvt_wchar_in(const codecvt_wchar*, int*, const char*,
|
|
|
|
const char*, const char**, wchar_t*, wchar_t*, wchar_t**);
|
|
|
|
|
2012-06-14 15:37:13 +02:00
|
|
|
/* class ctype_base */
|
|
|
|
typedef struct {
|
|
|
|
locale_facet facet;
|
|
|
|
} ctype_base;
|
|
|
|
|
|
|
|
/* class ctype<char> */
|
|
|
|
typedef struct {
|
|
|
|
ctype_base base;
|
|
|
|
_Ctypevec ctype;
|
|
|
|
} ctype_char;
|
|
|
|
|
|
|
|
MSVCP_bool __thiscall ctype_char_is_ch(const ctype_char*, short, char);
|
2012-06-15 11:09:04 +02:00
|
|
|
char __thiscall ctype_char_narrow_ch(const ctype_char*, char, char);
|
2012-06-15 11:09:15 +02:00
|
|
|
char __thiscall ctype_char_widen_ch(const ctype_char*, char);
|
2012-06-15 11:09:04 +02:00
|
|
|
|
|
|
|
/* class ctype<wchar> */
|
|
|
|
typedef struct {
|
|
|
|
ctype_base base;
|
|
|
|
_Ctypevec ctype;
|
|
|
|
_Cvtvec cvt;
|
|
|
|
} ctype_wchar;
|
|
|
|
|
2012-06-26 14:34:26 +02:00
|
|
|
MSVCP_bool __thiscall ctype_wchar_is_ch(const ctype_wchar*, short, wchar_t);
|
2012-06-15 11:09:04 +02:00
|
|
|
char __thiscall ctype_wchar_narrow_ch(const ctype_wchar*, wchar_t, char);
|
2012-06-15 11:09:15 +02:00
|
|
|
wchar_t __thiscall ctype_wchar_widen_ch(const ctype_wchar*, char);
|
2012-06-14 15:37:13 +02:00
|
|
|
|
2011-05-27 14:34:27 +02:00
|
|
|
/* class locale */
|
|
|
|
typedef struct
|
|
|
|
{
|
2011-11-23 16:14:11 +01:00
|
|
|
struct _locale__Locimp *ptr;
|
2011-05-27 14:34:27 +02:00
|
|
|
} locale;
|
2011-06-22 14:03:54 +02:00
|
|
|
|
2011-08-24 14:38:53 +02:00
|
|
|
locale* __thiscall locale_ctor(locale*);
|
2012-03-28 11:20:56 +02:00
|
|
|
locale* __thiscall locale_copy_ctor(locale*, const locale*);
|
2012-03-29 16:11:31 +02:00
|
|
|
locale* __thiscall locale_operator_assign(locale*, const locale*);
|
2011-08-24 14:38:53 +02:00
|
|
|
void __thiscall locale_dtor(locale*);
|
2012-06-12 18:12:12 +02:00
|
|
|
void free_locale(void);
|
2012-06-12 18:13:06 +02:00
|
|
|
codecvt_char* codecvt_char_use_facet(const locale*);
|
2012-08-14 10:51:55 +02:00
|
|
|
codecvt_wchar* codecvt_wchar_use_facet(const locale*);
|
|
|
|
codecvt_wchar* codecvt_short_use_facet(const locale*);
|
2012-06-14 15:37:13 +02:00
|
|
|
ctype_char* ctype_char_use_facet(const locale*);
|
2012-06-15 11:09:04 +02:00
|
|
|
ctype_wchar* ctype_wchar_use_facet(const locale*);
|
2012-08-14 10:52:22 +02:00
|
|
|
ctype_wchar* ctype_short_use_facet(const locale*);
|
2011-08-24 14:38:53 +02:00
|
|
|
|
2011-06-22 14:03:54 +02:00
|
|
|
/* class _Lockit */
|
|
|
|
typedef struct {
|
2015-03-12 09:25:45 +01:00
|
|
|
#if _MSVCP_VER >= 70
|
2011-06-22 14:03:54 +02:00
|
|
|
int locktype;
|
2015-03-12 09:25:45 +01:00
|
|
|
#else
|
|
|
|
char empty_struct;
|
|
|
|
#endif
|
2011-06-22 14:03:54 +02:00
|
|
|
} _Lockit;
|
|
|
|
|
2011-08-24 14:38:35 +02:00
|
|
|
#define _LOCK_LOCALE 0
|
|
|
|
#define _LOCK_MALLOC 1
|
|
|
|
#define _LOCK_STREAM 2
|
|
|
|
#define _LOCK_DEBUG 3
|
|
|
|
#define _MAX_LOCK 4
|
|
|
|
|
2011-06-22 14:03:54 +02:00
|
|
|
void init_lockit(void);
|
|
|
|
void free_lockit(void);
|
2011-08-24 14:38:35 +02:00
|
|
|
_Lockit* __thiscall _Lockit_ctor_locktype(_Lockit*, int);
|
|
|
|
void __thiscall _Lockit_dtor(_Lockit*);
|
2011-08-23 11:50:56 +02:00
|
|
|
|
|
|
|
/* class mutex */
|
|
|
|
typedef struct {
|
2012-11-02 20:06:08 +01:00
|
|
|
void *mutex;
|
2011-08-23 11:50:56 +02:00
|
|
|
} mutex;
|
2011-08-24 14:39:12 +02:00
|
|
|
|
|
|
|
mutex* __thiscall mutex_ctor(mutex*);
|
|
|
|
void __thiscall mutex_dtor(mutex*);
|
|
|
|
void __thiscall mutex_lock(mutex*);
|
|
|
|
void __thiscall mutex_unlock(mutex*);
|
2012-06-15 11:07:49 +02:00
|
|
|
|
2012-06-21 12:25:23 +02:00
|
|
|
typedef enum {
|
|
|
|
FMTFLAG_skipws = 0x0001,
|
|
|
|
FMTFLAG_unitbuf = 0x0002,
|
|
|
|
FMTFLAG_uppercase = 0x0004,
|
|
|
|
FMTFLAG_showbase = 0x0008,
|
|
|
|
FMTFLAG_showpoint = 0x0010,
|
|
|
|
FMTFLAG_showpos = 0x0020,
|
|
|
|
FMTFLAG_left = 0x0040,
|
|
|
|
FMTFLAG_right = 0x0080,
|
|
|
|
FMTFLAG_internal = 0x0100,
|
|
|
|
FMTFLAG_dec = 0x0200,
|
|
|
|
FMTFLAG_oct = 0x0400,
|
|
|
|
FMTFLAG_hex = 0x0800,
|
|
|
|
FMTFLAG_scientific = 0x1000,
|
|
|
|
FMTFLAG_fixed = 0x2000,
|
|
|
|
FMTFLAG_hexfloat = 0x3000,
|
|
|
|
FMTFLAG_boolalpha = 0x4000,
|
|
|
|
FMTFLAG_stdio = 0x8000,
|
|
|
|
FMTFLAG_adjustfield = FMTFLAG_left|FMTFLAG_right|FMTFLAG_internal,
|
|
|
|
FMTFLAG_basefield = FMTFLAG_dec|FMTFLAG_oct|FMTFLAG_hex,
|
2012-06-22 10:27:50 +02:00
|
|
|
FMTFLAG_floatfield = FMTFLAG_scientific|FMTFLAG_fixed,
|
2012-06-21 12:25:23 +02:00
|
|
|
FMTFLAG_mask = 0xffff
|
|
|
|
} IOSB_fmtflags;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
OPENMODE_in = 0x01,
|
|
|
|
OPENMODE_out = 0x02,
|
|
|
|
OPENMODE_ate = 0x04,
|
|
|
|
OPENMODE_app = 0x08,
|
|
|
|
OPENMODE_trunc = 0x10,
|
|
|
|
OPENMODE__Nocreate = 0x40,
|
|
|
|
OPENMODE__Noreplace = 0x80,
|
|
|
|
OPENMODE_binary = 0x20,
|
|
|
|
OPENMODE_mask = 0xff
|
|
|
|
} IOSB_openmode;
|
|
|
|
|
|
|
|
typedef enum {
|
2012-08-15 10:27:28 +02:00
|
|
|
SEEKDIR_beg = 0x0,
|
|
|
|
SEEKDIR_cur = 0x1,
|
|
|
|
SEEKDIR_end = 0x2,
|
2012-06-21 12:25:23 +02:00
|
|
|
SEEKDIR_mask = 0x3
|
|
|
|
} IOSB_seekdir;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
IOSTATE_goodbit = 0x00,
|
|
|
|
IOSTATE_eofbit = 0x01,
|
|
|
|
IOSTATE_failbit = 0x02,
|
|
|
|
IOSTATE_badbit = 0x04,
|
|
|
|
IOSTATE__Hardfail = 0x10,
|
|
|
|
IOSTATE_mask = 0x17
|
|
|
|
} IOSB_iostate;
|
|
|
|
|
|
|
|
typedef struct _iosarray {
|
|
|
|
struct _iosarray *next;
|
|
|
|
int index;
|
|
|
|
int long_val;
|
|
|
|
void *ptr_val;
|
|
|
|
} IOS_BASE_iosarray;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
EVENT_erase_event,
|
|
|
|
EVENT_imbue_event,
|
|
|
|
EVENT_copyfmt_event
|
|
|
|
} IOS_BASE_event;
|
|
|
|
|
|
|
|
struct _ios_base;
|
|
|
|
typedef void (CDECL *IOS_BASE_event_callback)(IOS_BASE_event, struct _ios_base*, int);
|
|
|
|
typedef struct _fnarray {
|
|
|
|
struct _fnarray *next;
|
|
|
|
int index;
|
|
|
|
IOS_BASE_event_callback event_handler;
|
|
|
|
} IOS_BASE_fnarray;
|
|
|
|
|
|
|
|
/* class ios_base */
|
|
|
|
typedef struct _ios_base {
|
|
|
|
const vtable_ptr *vtable;
|
2013-12-19 17:02:11 +01:00
|
|
|
#if _MSVCP_VER >= 100
|
|
|
|
MSVCP_size_t DECLSPEC_ALIGN(8) stdstr;
|
2014-12-25 16:50:27 +01:00
|
|
|
#elif _MSVCP_VER >= 71
|
2012-06-21 12:25:23 +02:00
|
|
|
MSVCP_size_t stdstr;
|
2013-12-19 17:02:11 +01:00
|
|
|
#endif
|
2012-06-21 12:25:23 +02:00
|
|
|
IOSB_iostate state;
|
|
|
|
IOSB_iostate except;
|
|
|
|
IOSB_fmtflags fmtfl;
|
|
|
|
streamsize prec;
|
|
|
|
streamsize wide;
|
|
|
|
IOS_BASE_iosarray *arr;
|
|
|
|
IOS_BASE_fnarray *calls;
|
2015-03-12 14:07:09 +01:00
|
|
|
#if _MSVCP_VER < 70
|
|
|
|
locale loc;
|
|
|
|
#else
|
2012-06-21 12:25:23 +02:00
|
|
|
locale *loc;
|
2015-03-12 14:07:09 +01:00
|
|
|
#endif
|
|
|
|
#if _MSVCP_VER <= 70
|
2014-12-25 16:50:27 +01:00
|
|
|
MSVCP_size_t stdstr;
|
|
|
|
#endif
|
2012-06-21 12:25:23 +02:00
|
|
|
} ios_base;
|
|
|
|
|
2012-06-21 12:25:44 +02:00
|
|
|
/* class basic_streambuf<char> */
|
|
|
|
typedef struct {
|
|
|
|
const vtable_ptr *vtable;
|
2015-03-12 14:07:09 +01:00
|
|
|
#if _MSVCP_VER >= 70 && _MSVCP_VER <= 100
|
2012-06-21 12:25:44 +02:00
|
|
|
mutex lock;
|
2014-01-14 13:55:56 +01:00
|
|
|
#endif
|
2012-06-21 12:25:44 +02:00
|
|
|
char *rbuf;
|
|
|
|
char *wbuf;
|
|
|
|
char **prbuf;
|
|
|
|
char **pwbuf;
|
|
|
|
char *rpos;
|
|
|
|
char *wpos;
|
|
|
|
char **prpos;
|
|
|
|
char **pwpos;
|
|
|
|
int rsize;
|
|
|
|
int wsize;
|
|
|
|
int *prsize;
|
|
|
|
int *pwsize;
|
2015-03-12 14:07:09 +01:00
|
|
|
#if _MSVCP_VER < 70
|
|
|
|
locale loc;
|
|
|
|
#else
|
2012-06-21 12:25:44 +02:00
|
|
|
locale *loc;
|
2015-03-12 14:07:09 +01:00
|
|
|
#endif
|
2012-06-21 12:25:44 +02:00
|
|
|
} basic_streambuf_char;
|
|
|
|
|
2012-06-21 12:27:21 +02:00
|
|
|
typedef struct {
|
|
|
|
basic_streambuf_char *strbuf;
|
|
|
|
MSVCP_bool got;
|
|
|
|
char val;
|
|
|
|
} istreambuf_iterator_char;
|
|
|
|
|
2012-06-22 10:26:32 +02:00
|
|
|
typedef struct {
|
2014-01-03 14:08:19 +01:00
|
|
|
#if _MSVCP_VER == 80
|
|
|
|
void *iter_container;
|
|
|
|
#endif
|
2012-06-22 10:26:32 +02:00
|
|
|
MSVCP_bool failed;
|
|
|
|
basic_streambuf_char *strbuf;
|
|
|
|
} ostreambuf_iterator_char;
|
|
|
|
|
2012-06-21 12:26:20 +02:00
|
|
|
int __thiscall basic_streambuf_char_sgetc(basic_streambuf_char*);
|
|
|
|
int __thiscall basic_streambuf_char_sbumpc(basic_streambuf_char*);
|
2012-06-22 10:26:48 +02:00
|
|
|
int __thiscall basic_streambuf_char_sputc(basic_streambuf_char*, char);
|
2012-06-21 12:26:20 +02:00
|
|
|
|
2012-06-21 12:25:44 +02:00
|
|
|
/* class basic_streambuf<wchar> */
|
|
|
|
typedef struct {
|
|
|
|
const vtable_ptr *vtable;
|
2015-03-12 14:07:09 +01:00
|
|
|
#if _MSVCP_VER >= 70 && _MSVCP_VER <= 100
|
2012-06-21 12:25:44 +02:00
|
|
|
mutex lock;
|
2014-01-14 13:55:56 +01:00
|
|
|
#endif
|
2012-06-21 12:25:44 +02:00
|
|
|
wchar_t *rbuf;
|
|
|
|
wchar_t *wbuf;
|
|
|
|
wchar_t **prbuf;
|
|
|
|
wchar_t **pwbuf;
|
|
|
|
wchar_t *rpos;
|
|
|
|
wchar_t *wpos;
|
|
|
|
wchar_t **prpos;
|
|
|
|
wchar_t **pwpos;
|
|
|
|
int rsize;
|
|
|
|
int wsize;
|
|
|
|
int *prsize;
|
|
|
|
int *pwsize;
|
2015-03-12 14:07:09 +01:00
|
|
|
#if _MSVCP_VER < 70
|
|
|
|
locale loc;
|
|
|
|
#else
|
2012-06-21 12:25:44 +02:00
|
|
|
locale *loc;
|
2015-03-12 14:07:09 +01:00
|
|
|
#endif
|
2012-06-21 12:25:44 +02:00
|
|
|
} basic_streambuf_wchar;
|
|
|
|
|
2012-06-25 15:48:59 +02:00
|
|
|
typedef struct {
|
|
|
|
basic_streambuf_wchar *strbuf;
|
|
|
|
MSVCP_bool got;
|
|
|
|
wchar_t val;
|
|
|
|
} istreambuf_iterator_wchar;
|
|
|
|
|
2012-06-25 15:48:18 +02:00
|
|
|
typedef struct {
|
2014-01-03 14:08:19 +01:00
|
|
|
#if _MSVCP_VER == 80
|
|
|
|
void *iter_container;
|
|
|
|
#endif
|
2012-06-25 15:48:18 +02:00
|
|
|
MSVCP_bool failed;
|
|
|
|
basic_streambuf_wchar *strbuf;
|
|
|
|
} ostreambuf_iterator_wchar;
|
|
|
|
|
2012-06-25 15:48:59 +02:00
|
|
|
unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar*);
|
|
|
|
unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar*);
|
2012-06-25 15:48:18 +02:00
|
|
|
unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar*, wchar_t);
|
|
|
|
|
2015-03-16 09:25:08 +01:00
|
|
|
#if _MSVCP_VER < 70
|
|
|
|
#define IOS_LOCALE(ios) (&(ios)->loc)
|
|
|
|
#else
|
|
|
|
#define IOS_LOCALE(ios) ((ios)->loc)
|
|
|
|
#endif
|
|
|
|
|
2012-06-21 12:27:21 +02:00
|
|
|
/* class num_get<char> */
|
|
|
|
typedef struct {
|
|
|
|
locale_facet facet;
|
|
|
|
_Cvtvec cvt;
|
|
|
|
} num_get;
|
|
|
|
|
|
|
|
num_get* num_get_char_use_facet(const locale*);
|
|
|
|
istreambuf_iterator_char* __thiscall num_get_char_get_long(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, LONG*);
|
|
|
|
istreambuf_iterator_char* __thiscall num_get_char_get_ushort(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, unsigned short*);
|
|
|
|
istreambuf_iterator_char* __thiscall num_get_char_get_uint(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, unsigned int*);
|
|
|
|
istreambuf_iterator_char* __thiscall num_get_char_get_ulong(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, ULONG*);
|
|
|
|
istreambuf_iterator_char* __thiscall num_get_char_get_float(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, float*);
|
|
|
|
istreambuf_iterator_char *__thiscall num_get_char_get_double(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, double*);
|
|
|
|
istreambuf_iterator_char *__thiscall num_get_char_get_ldouble(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, double*);
|
|
|
|
istreambuf_iterator_char *__thiscall num_get_char_get_void(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, void**);
|
|
|
|
istreambuf_iterator_char *__thiscall num_get_char_get_int64(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, LONGLONG*);
|
|
|
|
istreambuf_iterator_char *__thiscall num_get_char_get_uint64(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, ULONGLONG*);
|
|
|
|
istreambuf_iterator_char *__thiscall num_get_char_get_bool(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, MSVCP_bool*);
|
|
|
|
|
2012-06-26 14:34:26 +02:00
|
|
|
num_get* num_get_wchar_use_facet(const locale*);
|
2012-08-14 10:52:22 +02:00
|
|
|
num_get* num_get_short_use_facet(const locale*);
|
2012-06-26 14:34:26 +02:00
|
|
|
istreambuf_iterator_wchar* __thiscall num_get_wchar_get_long(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, LONG*);
|
|
|
|
istreambuf_iterator_wchar* __thiscall num_get_wchar_get_ushort(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, unsigned short*);
|
|
|
|
istreambuf_iterator_wchar* __thiscall num_get_wchar_get_uint(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, unsigned int*);
|
|
|
|
istreambuf_iterator_wchar* __thiscall num_get_wchar_get_ulong(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, ULONG*);
|
|
|
|
istreambuf_iterator_wchar* __thiscall num_get_wchar_get_float(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, float*);
|
|
|
|
istreambuf_iterator_wchar *__thiscall num_get_wchar_get_double(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, double*);
|
|
|
|
istreambuf_iterator_wchar *__thiscall num_get_wchar_get_ldouble(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, double*);
|
|
|
|
istreambuf_iterator_wchar *__thiscall num_get_wchar_get_void(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, void**);
|
|
|
|
istreambuf_iterator_wchar *__thiscall num_get_wchar_get_int64(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, LONGLONG*);
|
|
|
|
istreambuf_iterator_wchar *__thiscall num_get_wchar_get_uint64(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, ULONGLONG*);
|
|
|
|
istreambuf_iterator_wchar *__thiscall num_get_wchar_get_bool(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, MSVCP_bool*);
|
|
|
|
|
2012-06-22 10:26:32 +02:00
|
|
|
/* class num_put<char> */
|
2012-06-25 15:48:18 +02:00
|
|
|
/* class num_put<wchar> */
|
2012-06-22 10:26:32 +02:00
|
|
|
typedef struct {
|
|
|
|
locale_facet facet;
|
2016-05-10 15:24:12 +02:00
|
|
|
#if _MSVCP_VER < 110
|
2012-06-22 10:26:32 +02:00
|
|
|
_Cvtvec cvt;
|
2016-05-10 15:24:12 +02:00
|
|
|
#endif
|
2012-06-22 10:26:32 +02:00
|
|
|
} num_put;
|
|
|
|
|
2012-06-22 10:28:05 +02:00
|
|
|
num_put* num_put_char_use_facet(const locale*);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_long(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, LONG);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_ulong(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, ULONG);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_double(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, double);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_ldouble(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, double);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_ptr(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, const void*);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_int64(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, __int64);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_uint64(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, unsigned __int64);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_bool(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, MSVCP_bool);
|
|
|
|
|
2012-06-25 15:49:53 +02:00
|
|
|
num_put* num_put_wchar_use_facet(const locale*);
|
2012-08-14 10:52:09 +02:00
|
|
|
num_put* num_put_short_use_facet(const locale*);
|
2012-06-25 15:49:53 +02:00
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_long(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, LONG);
|
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_ulong(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, ULONG);
|
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_double(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, double);
|
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_ldouble(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, double);
|
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_ptr(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, const void*);
|
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_int64(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, __int64);
|
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_uint64(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, unsigned __int64);
|
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_bool(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, MSVCP_bool);
|
|
|
|
|
2012-09-07 11:01:35 +02:00
|
|
|
void init_exception(void*);
|
|
|
|
void init_locale(void*);
|
|
|
|
void init_io(void*);
|
2012-06-15 11:07:49 +02:00
|
|
|
void free_io(void);
|
2014-10-17 12:07:23 +02:00
|
|
|
void init_misc(void*);
|
2013-01-16 14:27:04 +01:00
|
|
|
|
|
|
|
/* class complex<float> */
|
|
|
|
typedef struct {
|
|
|
|
float real;
|
|
|
|
float imag;
|
|
|
|
} complex_float;
|
|
|
|
|
|
|
|
/* class complex<double> */
|
|
|
|
/* class complex<long double> */
|
|
|
|
typedef struct {
|
|
|
|
double real;
|
|
|
|
double imag;
|
|
|
|
} complex_double;
|
2014-01-13 12:52:17 +01:00
|
|
|
|
|
|
|
#if _MSVCP_VER < 80
|
2014-10-27 09:47:03 +01:00
|
|
|
static inline int memcpy_wrapper( void *dst, size_t size, const void *src, size_t count )
|
|
|
|
{
|
|
|
|
memcpy( dst, src, count );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline int memmove_wrapper( void *dst, size_t size, const void *src, size_t count )
|
|
|
|
{
|
|
|
|
memmove( dst, src, count );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline int mbstowcs_wrapper( size_t *ret, wchar_t *wcs, size_t size, const char *mbs, size_t count )
|
|
|
|
{
|
|
|
|
mbstowcs( wcs, mbs, count );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#define memcpy_s( dst, size, src, count ) memcpy_wrapper( dst, size, src, count )
|
|
|
|
#define memmove_s( dst, size, src, count ) memmove_wrapper( dst, size, src, count )
|
|
|
|
#define mbstowcs_s( ret, wcs, size, mbs, count ) mbstowcs_wrapper( ret, wcs, size, mbs, count )
|
2014-01-13 12:52:17 +01:00
|
|
|
#define hypotf( x, y ) ((float)hypot( (double)(x), (double)(y) ))
|
|
|
|
#endif
|
2015-11-04 02:10:16 +01:00
|
|
|
|
|
|
|
void free_misc(void);
|
2015-11-03 22:54:34 +01:00
|
|
|
|
|
|
|
#if _MSVCP_VER >= 140
|
|
|
|
#define UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR (0x0002)
|
|
|
|
int __cdecl __stdio_common_vsprintf(unsigned __int64 options, char *str, size_t len, const char *format,
|
|
|
|
_locale_t locale, __ms_va_list valist);
|
|
|
|
#endif
|