2007-09-28 20:43:43 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 Alexandre Julliard
|
2015-06-03 21:10:23 +02:00
|
|
|
* Copyright (C) 2015 Iván Matellanes
|
2007-09-28 20:43:43 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2008-08-20 10:18:58 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2015-08-05 20:32:29 +02:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <io.h>
|
|
|
|
#include <share.h>
|
2007-09-28 20:43:43 +02:00
|
|
|
#include <stdarg.h>
|
2015-06-03 21:10:23 +02:00
|
|
|
#include <stdio.h>
|
2015-08-05 20:32:29 +02:00
|
|
|
#include <sys/stat.h>
|
2007-09-28 20:43:43 +02:00
|
|
|
|
2015-05-26 13:08:39 +02:00
|
|
|
#include "msvcirt.h"
|
2007-09-28 20:43:43 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msvcirt);
|
|
|
|
|
2015-06-08 21:26:21 +02:00
|
|
|
#define RESERVE_SIZE 512
|
2015-07-17 16:37:18 +02:00
|
|
|
#define STATEBUF_SIZE 8
|
2015-06-08 21:26:21 +02:00
|
|
|
|
2015-08-03 16:48:43 +02:00
|
|
|
/* ?sh_none@filebuf@@2HB */
|
|
|
|
const int filebuf_sh_none = 0x800;
|
|
|
|
/* ?sh_read@filebuf@@2HB */
|
|
|
|
const int filebuf_sh_read = 0xa00;
|
|
|
|
/* ?sh_write@filebuf@@2HB */
|
|
|
|
const int filebuf_sh_write = 0xc00;
|
|
|
|
/* ?openprot@filebuf@@2HB */
|
|
|
|
const int filebuf_openprot = 420;
|
|
|
|
/* ?binary@filebuf@@2HB */
|
2015-08-10 20:09:01 +02:00
|
|
|
const int filebuf_binary = _O_BINARY;
|
2015-08-03 16:48:43 +02:00
|
|
|
/* ?text@filebuf@@2HB */
|
2015-08-10 20:09:01 +02:00
|
|
|
const int filebuf_text = _O_TEXT;
|
2015-08-03 16:48:43 +02:00
|
|
|
|
2015-07-17 16:37:05 +02:00
|
|
|
/* ?adjustfield@ios@@2JB */
|
|
|
|
const LONG ios_adjustfield = FLAGS_left | FLAGS_right | FLAGS_internal;
|
|
|
|
/* ?basefield@ios@@2JB */
|
|
|
|
const LONG ios_basefield = FLAGS_dec | FLAGS_oct | FLAGS_hex;
|
|
|
|
/* ?floatfield@ios@@2JB */
|
|
|
|
const LONG ios_floatfield = FLAGS_scientific | FLAGS_fixed;
|
2015-07-17 16:37:24 +02:00
|
|
|
/* ?fLockcInit@ios@@0HA */
|
|
|
|
/* FIXME: should be initialized to 0 and increased on construction of cin, cout, cerr and clog */
|
|
|
|
int ios_fLockcInit = 4;
|
2015-07-16 13:12:30 +02:00
|
|
|
/* ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A */
|
|
|
|
extern CRITICAL_SECTION ios_static_lock;
|
|
|
|
CRITICAL_SECTION_DEBUG ios_static_lock_debug =
|
|
|
|
{
|
|
|
|
0, 0, &ios_static_lock,
|
|
|
|
{ &ios_static_lock_debug.ProcessLocksList, &ios_static_lock_debug.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": ios_static_lock") }
|
|
|
|
};
|
|
|
|
CRITICAL_SECTION ios_static_lock = { &ios_static_lock_debug, -1, 0, 0, 0, 0 };
|
2015-07-17 16:37:14 +02:00
|
|
|
/* ?x_maxbit@ios@@0JA */
|
|
|
|
LONG ios_maxbit = 0x8000;
|
2015-07-17 16:37:18 +02:00
|
|
|
/* ?x_curindex@ios@@0HA */
|
|
|
|
int ios_curindex = -1;
|
|
|
|
/* ?x_statebuf@ios@@0PAJA */
|
|
|
|
LONG ios_statebuf[STATEBUF_SIZE] = {0};
|
2015-07-16 13:12:30 +02:00
|
|
|
|
2015-06-03 21:10:23 +02:00
|
|
|
/* class streambuf */
|
|
|
|
typedef struct {
|
|
|
|
const vtable_ptr *vtable;
|
|
|
|
int allocated;
|
|
|
|
int unbuffered;
|
2015-06-16 11:32:19 +02:00
|
|
|
int stored_char;
|
2015-06-03 21:10:23 +02:00
|
|
|
char *base;
|
|
|
|
char *ebuf;
|
|
|
|
char *pbase;
|
|
|
|
char *pptr;
|
|
|
|
char *epptr;
|
|
|
|
char *eback;
|
|
|
|
char *gptr;
|
|
|
|
char *egptr;
|
2015-06-08 21:26:43 +02:00
|
|
|
int do_lock;
|
2015-06-03 21:10:23 +02:00
|
|
|
CRITICAL_SECTION lock;
|
|
|
|
} streambuf;
|
|
|
|
|
2015-06-08 21:26:21 +02:00
|
|
|
void __thiscall streambuf_setb(streambuf*, char*, char*, int);
|
2015-06-03 21:10:23 +02:00
|
|
|
streambuf* __thiscall streambuf_setbuf(streambuf*, char*, int);
|
|
|
|
void __thiscall streambuf_setg(streambuf*, char*, char*, char*);
|
|
|
|
void __thiscall streambuf_setp(streambuf*, char*, char*);
|
|
|
|
|
2015-08-03 16:48:37 +02:00
|
|
|
/* class filebuf */
|
|
|
|
typedef struct {
|
|
|
|
streambuf base;
|
|
|
|
filedesc fd;
|
|
|
|
int close;
|
|
|
|
} filebuf;
|
|
|
|
|
2015-08-05 20:32:29 +02:00
|
|
|
filebuf* __thiscall filebuf_close(filebuf*);
|
|
|
|
|
2015-07-04 16:24:37 +02:00
|
|
|
/* class ios */
|
|
|
|
struct _ostream;
|
2010-07-31 10:11:44 +02:00
|
|
|
typedef struct {
|
2015-07-04 16:24:37 +02:00
|
|
|
const vtable_ptr *vtable;
|
|
|
|
streambuf *sb;
|
|
|
|
ios_io_state state;
|
|
|
|
int special[4];
|
|
|
|
int delbuf;
|
|
|
|
struct _ostream *tie;
|
|
|
|
ios_flags flags;
|
|
|
|
int precision;
|
|
|
|
char fill;
|
|
|
|
int width;
|
|
|
|
int do_lock;
|
|
|
|
CRITICAL_SECTION lock;
|
|
|
|
} ios;
|
2010-07-31 10:11:44 +02:00
|
|
|
|
2015-07-04 16:24:53 +02:00
|
|
|
ios* __thiscall ios_assign(ios*, const ios*);
|
2015-07-17 16:37:00 +02:00
|
|
|
int __thiscall ios_fail(const ios*);
|
2015-07-16 13:12:40 +02:00
|
|
|
void __cdecl ios_lock(ios*);
|
2015-07-17 16:37:14 +02:00
|
|
|
void __cdecl ios_lockc(void);
|
2015-07-17 16:37:09 +02:00
|
|
|
LONG __thiscall ios_setf_mask(ios*, LONG, LONG);
|
2015-07-16 13:12:40 +02:00
|
|
|
void __cdecl ios_unlock(ios*);
|
2015-07-17 16:37:14 +02:00
|
|
|
void __cdecl ios_unlockc(void);
|
2015-07-04 16:24:53 +02:00
|
|
|
|
2015-07-04 16:24:37 +02:00
|
|
|
/* class ostream */
|
|
|
|
typedef struct _ostream {
|
|
|
|
const vtable_ptr *vtable;
|
|
|
|
} ostream;
|
2008-08-20 10:18:58 +02:00
|
|
|
|
2010-07-31 10:11:44 +02:00
|
|
|
typedef struct {
|
|
|
|
LPVOID VTable;
|
|
|
|
} class_strstreambuf;
|
|
|
|
|
2015-06-03 21:10:23 +02:00
|
|
|
/* ??_7streambuf@@6B@ */
|
|
|
|
extern const vtable_ptr MSVCP_streambuf_vtable;
|
2015-08-03 16:48:37 +02:00
|
|
|
/* ??_7filebuf@@6B@ */
|
|
|
|
extern const vtable_ptr MSVCP_filebuf_vtable;
|
2015-07-04 16:24:37 +02:00
|
|
|
/* ??_7ios@@6B@ */
|
|
|
|
extern const vtable_ptr MSVCP_ios_vtable;
|
2015-06-03 21:10:23 +02:00
|
|
|
|
|
|
|
#ifndef __GNUC__
|
|
|
|
void __asm_dummy_vtables(void) {
|
|
|
|
#endif
|
|
|
|
__ASM_VTABLE(streambuf,
|
|
|
|
VTABLE_ADD_FUNC(streambuf_vector_dtor)
|
|
|
|
VTABLE_ADD_FUNC(streambuf_sync)
|
|
|
|
VTABLE_ADD_FUNC(streambuf_setbuf)
|
|
|
|
VTABLE_ADD_FUNC(streambuf_seekoff)
|
|
|
|
VTABLE_ADD_FUNC(streambuf_seekpos)
|
|
|
|
VTABLE_ADD_FUNC(streambuf_xsputn)
|
|
|
|
VTABLE_ADD_FUNC(streambuf_xsgetn)
|
|
|
|
VTABLE_ADD_FUNC(streambuf_overflow)
|
|
|
|
VTABLE_ADD_FUNC(streambuf_underflow)
|
|
|
|
VTABLE_ADD_FUNC(streambuf_pbackfail)
|
|
|
|
VTABLE_ADD_FUNC(streambuf_doallocate));
|
2015-08-03 16:48:37 +02:00
|
|
|
__ASM_VTABLE(filebuf,
|
|
|
|
VTABLE_ADD_FUNC(filebuf_vector_dtor)
|
|
|
|
VTABLE_ADD_FUNC(filebuf_sync)
|
|
|
|
VTABLE_ADD_FUNC(filebuf_setbuf)
|
|
|
|
VTABLE_ADD_FUNC(filebuf_seekoff)
|
|
|
|
VTABLE_ADD_FUNC(streambuf_seekpos)
|
|
|
|
VTABLE_ADD_FUNC(streambuf_xsputn)
|
|
|
|
VTABLE_ADD_FUNC(streambuf_xsgetn)
|
|
|
|
VTABLE_ADD_FUNC(filebuf_overflow)
|
|
|
|
VTABLE_ADD_FUNC(filebuf_underflow)
|
|
|
|
VTABLE_ADD_FUNC(streambuf_pbackfail)
|
|
|
|
VTABLE_ADD_FUNC(streambuf_doallocate));
|
2015-07-04 16:24:37 +02:00
|
|
|
__ASM_VTABLE(ios,
|
|
|
|
VTABLE_ADD_FUNC(ios_vector_dtor));
|
2015-06-03 21:10:23 +02:00
|
|
|
#ifndef __GNUC__
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
DEFINE_RTTI_DATA0(streambuf, 0, ".?AVstreambuf@@")
|
2015-08-03 16:48:37 +02:00
|
|
|
DEFINE_RTTI_DATA1(filebuf, 0, &streambuf_rtti_base_descriptor, ".?AVfilebuf@@")
|
2015-07-04 16:24:37 +02:00
|
|
|
DEFINE_RTTI_DATA0(ios, 0, ".?AVios@@")
|
2015-06-03 21:10:23 +02:00
|
|
|
|
|
|
|
/* ??0streambuf@@IAE@PADH@Z */
|
|
|
|
/* ??0streambuf@@IEAA@PEADH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_reserve_ctor, 12)
|
|
|
|
streambuf* __thiscall streambuf_reserve_ctor(streambuf *this, char *buffer, int length)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p %d)\n", this, buffer, length);
|
|
|
|
this->vtable = &MSVCP_streambuf_vtable;
|
|
|
|
this->allocated = 0;
|
2015-06-16 11:32:19 +02:00
|
|
|
this->stored_char = EOF;
|
2015-06-08 21:26:43 +02:00
|
|
|
this->do_lock = -1;
|
2015-06-03 21:10:23 +02:00
|
|
|
this->base = NULL;
|
|
|
|
streambuf_setbuf(this, buffer, length);
|
|
|
|
streambuf_setg(this, NULL, NULL, NULL);
|
|
|
|
streambuf_setp(this, NULL, NULL);
|
|
|
|
InitializeCriticalSection(&this->lock);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ??0streambuf@@IAE@XZ */
|
|
|
|
/* ??0streambuf@@IEAA@XZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_ctor, 4)
|
|
|
|
streambuf* __thiscall streambuf_ctor(streambuf *this)
|
|
|
|
{
|
|
|
|
streambuf_reserve_ctor(this, NULL, 0);
|
|
|
|
this->unbuffered = 0;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ??0streambuf@@QAE@ABV0@@Z */
|
|
|
|
/* ??0streambuf@@QEAA@AEBV0@@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_copy_ctor, 8)
|
|
|
|
streambuf* __thiscall streambuf_copy_ctor(streambuf *this, const streambuf *copy)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p)\n", this, copy);
|
|
|
|
*this = *copy;
|
|
|
|
this->vtable = &MSVCP_streambuf_vtable;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ??1streambuf@@UAE@XZ */
|
|
|
|
/* ??1streambuf@@UEAA@XZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_dtor, 4)
|
|
|
|
void __thiscall streambuf_dtor(streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
if (this->allocated)
|
|
|
|
MSVCRT_operator_delete(this->base);
|
|
|
|
DeleteCriticalSection(&this->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ??4streambuf@@QAEAAV0@ABV0@@Z */
|
|
|
|
/* ??4streambuf@@QEAAAEAV0@AEBV0@@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_assign, 8)
|
|
|
|
streambuf* __thiscall streambuf_assign(streambuf *this, const streambuf *rhs)
|
|
|
|
{
|
|
|
|
streambuf_dtor(this);
|
|
|
|
return streambuf_copy_ctor(this, rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ??_Estreambuf@@UAEPAXI@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_vector_dtor, 8)
|
2015-07-08 10:28:59 +02:00
|
|
|
#define call_streambuf_vector_dtor(this, flags) CALL_VTBL_FUNC(this, 0,\
|
|
|
|
streambuf*, (streambuf*, unsigned int), (this, flags))
|
2015-06-03 21:10:23 +02:00
|
|
|
streambuf* __thiscall streambuf_vector_dtor(streambuf *this, unsigned int flags)
|
|
|
|
{
|
|
|
|
TRACE("(%p %x)\n", this, flags);
|
|
|
|
if (flags & 2) {
|
|
|
|
/* we have an array, with the number of elements stored before the first object */
|
|
|
|
INT_PTR i, *ptr = (INT_PTR *)this-1;
|
|
|
|
|
|
|
|
for (i = *ptr-1; i >= 0; i--)
|
|
|
|
streambuf_dtor(this+i);
|
|
|
|
MSVCRT_operator_delete(ptr);
|
|
|
|
} else {
|
|
|
|
streambuf_dtor(this);
|
|
|
|
if (flags & 1)
|
|
|
|
MSVCRT_operator_delete(this);
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ??_Gstreambuf@@UAEPAXI@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_scalar_dtor, 8)
|
|
|
|
streambuf* __thiscall streambuf_scalar_dtor(streambuf *this, unsigned int flags)
|
|
|
|
{
|
|
|
|
TRACE("(%p %x)\n", this, flags);
|
|
|
|
streambuf_dtor(this);
|
|
|
|
if (flags & 1) MSVCRT_operator_delete(this);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?doallocate@streambuf@@MAEHXZ */
|
|
|
|
/* ?doallocate@streambuf@@MEAAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_doallocate, 4)
|
2015-06-08 21:26:21 +02:00
|
|
|
#define call_streambuf_doallocate(this) CALL_VTBL_FUNC(this, 40, int, (streambuf*), (this))
|
2015-06-03 21:10:23 +02:00
|
|
|
int __thiscall streambuf_doallocate(streambuf *this)
|
|
|
|
{
|
2015-06-08 21:26:21 +02:00
|
|
|
char *reserve;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
reserve = MSVCRT_operator_new(RESERVE_SIZE);
|
|
|
|
if (!reserve)
|
|
|
|
return EOF;
|
|
|
|
|
|
|
|
streambuf_setb(this, reserve, reserve + RESERVE_SIZE, 1);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?allocate@streambuf@@IAEHXZ */
|
|
|
|
/* ?allocate@streambuf@@IEAAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_allocate, 4)
|
|
|
|
int __thiscall streambuf_allocate(streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
if (this->base != NULL || this->unbuffered)
|
|
|
|
return 0;
|
|
|
|
return call_streambuf_doallocate(this);
|
2015-06-03 21:10:23 +02:00
|
|
|
}
|
|
|
|
|
2015-06-08 21:26:28 +02:00
|
|
|
/* ?base@streambuf@@IBEPADXZ */
|
|
|
|
/* ?base@streambuf@@IEBAPEADXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_base, 4)
|
|
|
|
char* __thiscall streambuf_base(const streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->base;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?blen@streambuf@@IBEHXZ */
|
|
|
|
/* ?blen@streambuf@@IEBAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_blen, 4)
|
|
|
|
int __thiscall streambuf_blen(const streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->ebuf - this->base;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?eback@streambuf@@IBEPADXZ */
|
|
|
|
/* ?eback@streambuf@@IEBAPEADXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_eback, 4)
|
|
|
|
char* __thiscall streambuf_eback(const streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->eback;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?ebuf@streambuf@@IBEPADXZ */
|
|
|
|
/* ?ebuf@streambuf@@IEBAPEADXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_ebuf, 4)
|
|
|
|
char* __thiscall streambuf_ebuf(const streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->ebuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?egptr@streambuf@@IBEPADXZ */
|
|
|
|
/* ?egptr@streambuf@@IEBAPEADXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_egptr, 4)
|
|
|
|
char* __thiscall streambuf_egptr(const streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->egptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?epptr@streambuf@@IBEPADXZ */
|
|
|
|
/* ?epptr@streambuf@@IEBAPEADXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_epptr, 4)
|
|
|
|
char* __thiscall streambuf_epptr(const streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->epptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?gptr@streambuf@@IBEPADXZ */
|
|
|
|
/* ?gptr@streambuf@@IEBAPEADXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_gptr, 4)
|
|
|
|
char* __thiscall streambuf_gptr(const streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->gptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?pbase@streambuf@@IBEPADXZ */
|
|
|
|
/* ?pbase@streambuf@@IEBAPEADXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_pbase, 4)
|
|
|
|
char* __thiscall streambuf_pbase(const streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->pbase;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?pptr@streambuf@@IBEPADXZ */
|
|
|
|
/* ?pptr@streambuf@@IEBAPEADXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_pptr, 4)
|
|
|
|
char* __thiscall streambuf_pptr(const streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->pptr;
|
|
|
|
}
|
|
|
|
|
2015-06-08 21:26:43 +02:00
|
|
|
/* ?clrlock@streambuf@@QAEXXZ */
|
|
|
|
/* ?clrlock@streambuf@@QEAAXXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_clrlock, 4)
|
|
|
|
void __thiscall streambuf_clrlock(streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
if (this->do_lock <= 0)
|
|
|
|
this->do_lock++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?lock@streambuf@@QAEXXZ */
|
|
|
|
/* ?lock@streambuf@@QEAAXXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_lock, 4)
|
|
|
|
void __thiscall streambuf_lock(streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
if (this->do_lock < 0)
|
|
|
|
EnterCriticalSection(&this->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?lockptr@streambuf@@IAEPAU_CRT_CRITICAL_SECTION@@XZ */
|
|
|
|
/* ?lockptr@streambuf@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_lockptr, 4)
|
|
|
|
CRITICAL_SECTION* __thiscall streambuf_lockptr(streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return &this->lock;
|
|
|
|
}
|
|
|
|
|
2015-06-08 21:26:51 +02:00
|
|
|
/* ?gbump@streambuf@@IAEXH@Z */
|
|
|
|
/* ?gbump@streambuf@@IEAAXH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_gbump, 8)
|
|
|
|
void __thiscall streambuf_gbump(streambuf *this, int count)
|
|
|
|
{
|
|
|
|
TRACE("(%p %d)\n", this, count);
|
|
|
|
this->gptr += count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?pbump@streambuf@@IAEXH@Z */
|
|
|
|
/* ?pbump@streambuf@@IEAAXH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_pbump, 8)
|
|
|
|
void __thiscall streambuf_pbump(streambuf *this, int count)
|
|
|
|
{
|
|
|
|
TRACE("(%p %d)\n", this, count);
|
|
|
|
this->pptr += count;
|
|
|
|
}
|
|
|
|
|
2015-06-09 19:40:49 +02:00
|
|
|
/* ?in_avail@streambuf@@QBEHXZ */
|
|
|
|
/* ?in_avail@streambuf@@QEBAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_in_avail, 4)
|
|
|
|
int __thiscall streambuf_in_avail(const streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->egptr - this->gptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?out_waiting@streambuf@@QBEHXZ */
|
|
|
|
/* ?out_waiting@streambuf@@QEBAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_out_waiting, 4)
|
|
|
|
int __thiscall streambuf_out_waiting(const streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->pptr - this->pbase;
|
|
|
|
}
|
|
|
|
|
2015-06-03 21:10:23 +02:00
|
|
|
/* Unexported */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_overflow, 8)
|
2015-06-16 11:32:29 +02:00
|
|
|
#define call_streambuf_overflow(this, c) CALL_VTBL_FUNC(this, 28, int, (streambuf*, int), (this, c))
|
2015-06-03 21:10:23 +02:00
|
|
|
int __thiscall streambuf_overflow(streambuf *this, int c)
|
|
|
|
{
|
2015-06-16 11:32:37 +02:00
|
|
|
ERR("overflow is not implemented in streambuf\n");
|
2015-06-03 21:10:23 +02:00
|
|
|
return EOF;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?pbackfail@streambuf@@UAEHH@Z */
|
|
|
|
/* ?pbackfail@streambuf@@UEAAHH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_pbackfail, 8)
|
2015-06-29 10:01:53 +02:00
|
|
|
#define call_streambuf_pbackfail(this, c) CALL_VTBL_FUNC(this, 36, int, (streambuf*, int), (this, c))
|
2015-06-03 21:10:23 +02:00
|
|
|
int __thiscall streambuf_pbackfail(streambuf *this, int c)
|
|
|
|
{
|
2015-06-29 10:01:48 +02:00
|
|
|
TRACE("(%p %d)\n", this, c);
|
|
|
|
if (this->gptr <= this->eback)
|
|
|
|
return EOF;
|
|
|
|
return *--this->gptr = c;
|
2015-06-03 21:10:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?seekoff@streambuf@@UAEJJW4seek_dir@ios@@H@Z */
|
|
|
|
/* ?seekoff@streambuf@@UEAAJJW4seek_dir@ios@@H@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_seekoff, 16)
|
2015-06-09 19:40:40 +02:00
|
|
|
#define call_streambuf_seekoff(this, off, dir, mode) CALL_VTBL_FUNC(this, 12, streampos, (streambuf*, streamoff, ios_seek_dir, int), (this, off, dir, mode))
|
|
|
|
streampos __thiscall streambuf_seekoff(streambuf *this, streamoff offset, ios_seek_dir dir, int mode)
|
2015-06-03 21:10:23 +02:00
|
|
|
{
|
2015-06-09 19:40:40 +02:00
|
|
|
TRACE("(%p %d %d %d)\n", this, offset, dir, mode);
|
2015-06-03 21:10:23 +02:00
|
|
|
return EOF;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?seekpos@streambuf@@UAEJJH@Z */
|
|
|
|
/* ?seekpos@streambuf@@UEAAJJH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_seekpos, 12)
|
|
|
|
streampos __thiscall streambuf_seekpos(streambuf *this, streampos pos, int mode)
|
|
|
|
{
|
2015-06-09 19:40:40 +02:00
|
|
|
TRACE("(%p %d %d)\n", this, pos, mode);
|
|
|
|
return call_streambuf_seekoff(this, pos, SEEKDIR_beg, mode);
|
2015-06-03 21:10:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?setb@streambuf@@IAEXPAD0H@Z */
|
|
|
|
/* ?setb@streambuf@@IEAAXPEAD0H@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_setb, 16)
|
|
|
|
void __thiscall streambuf_setb(streambuf *this, char *ba, char *eb, int delete)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p %p %d)\n", this, ba, eb, delete);
|
|
|
|
if (this->allocated)
|
|
|
|
MSVCRT_operator_delete(this->base);
|
|
|
|
this->allocated = delete;
|
|
|
|
this->base = ba;
|
|
|
|
this->ebuf = eb;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?setbuf@streambuf@@UAEPAV1@PADH@Z */
|
|
|
|
/* ?setbuf@streambuf@@UEAAPEAV1@PEADH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_setbuf, 12)
|
|
|
|
streambuf* __thiscall streambuf_setbuf(streambuf *this, char *buffer, int length)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p %d)\n", this, buffer, length);
|
|
|
|
if (this->base != NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (buffer == NULL || !length) {
|
|
|
|
this->unbuffered = 1;
|
|
|
|
this->base = this->ebuf = NULL;
|
|
|
|
} else {
|
|
|
|
this->unbuffered = 0;
|
|
|
|
this->base = buffer;
|
|
|
|
this->ebuf = buffer + length;
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?setg@streambuf@@IAEXPAD00@Z */
|
|
|
|
/* ?setg@streambuf@@IEAAXPEAD00@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_setg, 16)
|
|
|
|
void __thiscall streambuf_setg(streambuf *this, char *ek, char *gp, char *eg)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p %p %p)\n", this, ek, gp, eg);
|
|
|
|
this->eback = ek;
|
|
|
|
this->gptr = gp;
|
|
|
|
this->egptr = eg;
|
|
|
|
}
|
|
|
|
|
2015-06-08 21:26:43 +02:00
|
|
|
/* ?setlock@streambuf@@QAEXXZ */
|
|
|
|
/* ?setlock@streambuf@@QEAAXXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_setlock, 4)
|
|
|
|
void __thiscall streambuf_setlock(streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
this->do_lock--;
|
|
|
|
}
|
|
|
|
|
2015-06-03 21:10:23 +02:00
|
|
|
/* ?setp@streambuf@@IAEXPAD0@Z */
|
|
|
|
/* ?setp@streambuf@@IEAAXPEAD0@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_setp, 12)
|
|
|
|
void __thiscall streambuf_setp(streambuf *this, char *pb, char *ep)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p %p)\n", this, pb, ep);
|
|
|
|
this->pbase = this->pptr = pb;
|
|
|
|
this->epptr = ep;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?sync@streambuf@@UAEHXZ */
|
|
|
|
/* ?sync@streambuf@@UEAAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_sync, 4)
|
2015-08-05 20:32:29 +02:00
|
|
|
#define call_streambuf_sync(this) CALL_VTBL_FUNC(this, 4, int, (streambuf*), (this))
|
2015-06-03 21:10:23 +02:00
|
|
|
int __thiscall streambuf_sync(streambuf *this)
|
|
|
|
{
|
2015-06-09 19:40:33 +02:00
|
|
|
TRACE("(%p)\n", this);
|
2015-06-12 11:51:54 +02:00
|
|
|
return (this->gptr >= this->egptr && this->pbase >= this->pptr) ? 0 : EOF;
|
2015-06-03 21:10:23 +02:00
|
|
|
}
|
|
|
|
|
2015-06-08 21:26:36 +02:00
|
|
|
/* ?unbuffered@streambuf@@IAEXH@Z */
|
|
|
|
/* ?unbuffered@streambuf@@IEAAXH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_unbuffered_set, 8)
|
|
|
|
void __thiscall streambuf_unbuffered_set(streambuf *this, int buf)
|
|
|
|
{
|
|
|
|
TRACE("(%p %d)\n", this, buf);
|
|
|
|
this->unbuffered = buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?unbuffered@streambuf@@IBEHXZ */
|
|
|
|
/* ?unbuffered@streambuf@@IEBAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_unbuffered_get, 4)
|
|
|
|
int __thiscall streambuf_unbuffered_get(const streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->unbuffered;
|
|
|
|
}
|
|
|
|
|
2015-06-03 21:10:23 +02:00
|
|
|
/* Unexported */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_underflow, 4)
|
2015-06-16 11:32:19 +02:00
|
|
|
#define call_streambuf_underflow(this) CALL_VTBL_FUNC(this, 32, int, (streambuf*), (this))
|
2015-06-03 21:10:23 +02:00
|
|
|
int __thiscall streambuf_underflow(streambuf *this)
|
|
|
|
{
|
2015-06-16 11:32:37 +02:00
|
|
|
ERR("underflow is not implemented in streambuf\n");
|
2015-06-03 21:10:23 +02:00
|
|
|
return EOF;
|
|
|
|
}
|
|
|
|
|
2015-06-08 21:26:43 +02:00
|
|
|
/* ?unlock@streambuf@@QAEXXZ */
|
|
|
|
/* ?unlock@streambuf@@QEAAXXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_unlock, 4)
|
|
|
|
void __thiscall streambuf_unlock(streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
if (this->do_lock < 0)
|
|
|
|
LeaveCriticalSection(&this->lock);
|
|
|
|
}
|
|
|
|
|
2015-06-03 21:10:23 +02:00
|
|
|
/* ?xsgetn@streambuf@@UAEHPADH@Z */
|
|
|
|
/* ?xsgetn@streambuf@@UEAAHPEADH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_xsgetn, 12)
|
2015-06-20 16:40:21 +02:00
|
|
|
#define call_streambuf_xsgetn(this, buffer, count) CALL_VTBL_FUNC(this, 24, int, (streambuf*, char*, int), (this, buffer, count))
|
2015-06-03 21:10:23 +02:00
|
|
|
int __thiscall streambuf_xsgetn(streambuf *this, char *buffer, int count)
|
|
|
|
{
|
2015-06-20 16:40:06 +02:00
|
|
|
int copied = 0, chunk;
|
|
|
|
|
|
|
|
TRACE("(%p %p %d)\n", this, buffer, count);
|
|
|
|
|
|
|
|
if (this->unbuffered) {
|
|
|
|
if (this->stored_char == EOF)
|
|
|
|
this->stored_char = call_streambuf_underflow(this);
|
|
|
|
while (copied < count && this->stored_char != EOF) {
|
|
|
|
buffer[copied++] = this->stored_char;
|
|
|
|
this->stored_char = call_streambuf_underflow(this);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
while (copied < count) {
|
|
|
|
if (call_streambuf_underflow(this) == EOF)
|
|
|
|
break;
|
|
|
|
chunk = this->egptr - this->gptr;
|
|
|
|
if (chunk > count - copied)
|
|
|
|
chunk = count - copied;
|
|
|
|
memcpy(buffer+copied, this->gptr, chunk);
|
|
|
|
this->gptr += chunk;
|
|
|
|
copied += chunk;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return copied;
|
2015-06-03 21:10:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?xsputn@streambuf@@UAEHPBDH@Z */
|
|
|
|
/* ?xsputn@streambuf@@UEAAHPEBDH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_xsputn, 12)
|
2015-06-20 16:40:21 +02:00
|
|
|
#define call_streambuf_xsputn(this, data, length) CALL_VTBL_FUNC(this, 20, int, (streambuf*, const char*, int), (this, data, length))
|
2015-06-03 21:10:23 +02:00
|
|
|
int __thiscall streambuf_xsputn(streambuf *this, const char *data, int length)
|
|
|
|
{
|
2015-06-20 16:40:15 +02:00
|
|
|
int copied = 0, chunk;
|
|
|
|
|
|
|
|
TRACE("(%p %p %d)\n", this, data, length);
|
|
|
|
|
|
|
|
while (copied < length) {
|
|
|
|
if (this->unbuffered || this->pptr == this->epptr) {
|
|
|
|
if (call_streambuf_overflow(this, data[copied]) == EOF)
|
|
|
|
break;
|
|
|
|
copied++;
|
|
|
|
} else {
|
|
|
|
chunk = this->epptr - this->pptr;
|
|
|
|
if (chunk > length - copied)
|
|
|
|
chunk = length - copied;
|
|
|
|
memcpy(this->pptr, data+copied, chunk);
|
|
|
|
this->pptr += chunk;
|
|
|
|
copied += chunk;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return copied;
|
2015-06-03 21:10:23 +02:00
|
|
|
}
|
|
|
|
|
2015-06-16 11:32:19 +02:00
|
|
|
/* ?sgetc@streambuf@@QAEHXZ */
|
|
|
|
/* ?sgetc@streambuf@@QEAAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_sgetc, 4)
|
|
|
|
int __thiscall streambuf_sgetc(streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
if (this->unbuffered) {
|
|
|
|
if (this->stored_char == EOF)
|
|
|
|
this->stored_char = call_streambuf_underflow(this);
|
|
|
|
return this->stored_char;
|
|
|
|
} else
|
|
|
|
return call_streambuf_underflow(this);
|
|
|
|
}
|
|
|
|
|
2015-06-16 11:32:29 +02:00
|
|
|
/* ?sputc@streambuf@@QAEHH@Z */
|
|
|
|
/* ?sputc@streambuf@@QEAAHH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_sputc, 8)
|
|
|
|
int __thiscall streambuf_sputc(streambuf *this, int ch)
|
|
|
|
{
|
|
|
|
TRACE("(%p %d)\n", this, ch);
|
|
|
|
return (this->pptr < this->epptr) ? *this->pptr++ = ch : call_streambuf_overflow(this, ch);
|
|
|
|
}
|
|
|
|
|
2015-06-20 16:40:21 +02:00
|
|
|
/* ?sgetn@streambuf@@QAEHPADH@Z */
|
|
|
|
/* ?sgetn@streambuf@@QEAAHPEADH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_sgetn, 12)
|
|
|
|
int __thiscall streambuf_sgetn(streambuf *this, char *buffer, int count)
|
|
|
|
{
|
|
|
|
return call_streambuf_xsgetn(this, buffer, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?sputn@streambuf@@QAEHPBDH@Z */
|
|
|
|
/* ?sputn@streambuf@@QEAAHPEBDH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_sputn, 12)
|
|
|
|
int __thiscall streambuf_sputn(streambuf *this, const char *data, int length)
|
|
|
|
{
|
|
|
|
return call_streambuf_xsputn(this, data, length);
|
|
|
|
}
|
|
|
|
|
2015-06-25 19:02:05 +02:00
|
|
|
/* ?snextc@streambuf@@QAEHXZ */
|
|
|
|
/* ?snextc@streambuf@@QEAAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_snextc, 4)
|
|
|
|
int __thiscall streambuf_snextc(streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
if (this->unbuffered) {
|
|
|
|
if (this->stored_char == EOF)
|
|
|
|
call_streambuf_underflow(this);
|
|
|
|
return this->stored_char = call_streambuf_underflow(this);
|
|
|
|
} else {
|
|
|
|
if (this->gptr >= this->egptr)
|
|
|
|
call_streambuf_underflow(this);
|
|
|
|
this->gptr++;
|
|
|
|
return (this->gptr < this->egptr) ? *this->gptr : call_streambuf_underflow(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-25 19:02:11 +02:00
|
|
|
/* ?sbumpc@streambuf@@QAEHXZ */
|
|
|
|
/* ?sbumpc@streambuf@@QEAAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_sbumpc, 4)
|
|
|
|
int __thiscall streambuf_sbumpc(streambuf *this)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
|
|
|
|
if (this->unbuffered) {
|
|
|
|
ret = this->stored_char;
|
|
|
|
this->stored_char = EOF;
|
|
|
|
if (ret == EOF)
|
|
|
|
ret = call_streambuf_underflow(this);
|
|
|
|
} else {
|
|
|
|
ret = (this->gptr < this->egptr) ? *this->gptr : call_streambuf_underflow(this);
|
|
|
|
this->gptr++;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-06-25 19:02:17 +02:00
|
|
|
/* ?stossc@streambuf@@QAEXXZ */
|
|
|
|
/* ?stossc@streambuf@@QEAAXXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_stossc, 4)
|
|
|
|
void __thiscall streambuf_stossc(streambuf *this)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
if (this->unbuffered) {
|
|
|
|
if (this->stored_char == EOF)
|
|
|
|
call_streambuf_underflow(this);
|
|
|
|
else
|
|
|
|
this->stored_char = EOF;
|
|
|
|
} else {
|
|
|
|
if (this->gptr >= this->egptr)
|
|
|
|
call_streambuf_underflow(this);
|
|
|
|
if (this->gptr < this->egptr)
|
|
|
|
this->gptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-29 10:01:53 +02:00
|
|
|
/* ?sputbackc@streambuf@@QAEHD@Z */
|
|
|
|
/* ?sputbackc@streambuf@@QEAAHD@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_sputbackc, 8)
|
|
|
|
int __thiscall streambuf_sputbackc(streambuf *this, char ch)
|
|
|
|
{
|
|
|
|
TRACE("(%p %d)\n", this, ch);
|
|
|
|
return call_streambuf_pbackfail(this, ch);
|
|
|
|
}
|
|
|
|
|
2015-06-29 10:01:58 +02:00
|
|
|
/* ?dbp@streambuf@@QAEXXZ */
|
|
|
|
/* ?dbp@streambuf@@QEAAXXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(streambuf_dbp, 4)
|
|
|
|
void __thiscall streambuf_dbp(streambuf *this)
|
|
|
|
{
|
|
|
|
printf("\nSTREAMBUF DEBUG INFO: this=%p, ", this);
|
|
|
|
if (this->unbuffered) {
|
|
|
|
printf("unbuffered\n");
|
|
|
|
} else {
|
|
|
|
printf("_fAlloc=%d\n", this->allocated);
|
|
|
|
printf(" base()=%p, ebuf()=%p, blen()=%d\n", this->base, this->ebuf, streambuf_blen(this));
|
|
|
|
printf("pbase()=%p, pptr()=%p, epptr()=%d\n", this->pbase, this->pptr, this->epptr);
|
|
|
|
printf("eback()=%p, gptr()=%p, egptr()=%d\n", this->eback, this->gptr, this->egptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-03 16:48:37 +02:00
|
|
|
/* ??0filebuf@@QAE@ABV0@@Z */
|
|
|
|
/* ??0filebuf@@QEAA@AEBV0@@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_copy_ctor, 8)
|
|
|
|
filebuf* __thiscall filebuf_copy_ctor(filebuf* this, const filebuf *copy)
|
|
|
|
{
|
2015-08-03 16:48:53 +02:00
|
|
|
TRACE("(%p %p)\n", this, copy);
|
|
|
|
*this = *copy;
|
|
|
|
this->base.vtable = &MSVCP_filebuf_vtable;
|
2015-08-03 16:48:37 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ??0filebuf@@QAE@HPADH@Z */
|
|
|
|
/* ??0filebuf@@QEAA@HPEADH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_fd_reserve_ctor, 16)
|
|
|
|
filebuf* __thiscall filebuf_fd_reserve_ctor(filebuf* this, filedesc fd, char *buffer, int length)
|
|
|
|
{
|
2015-08-03 16:48:53 +02:00
|
|
|
TRACE("(%p %d %p %d)\n", this, fd, buffer, length);
|
|
|
|
streambuf_reserve_ctor(&this->base, buffer, length);
|
|
|
|
this->base.vtable = &MSVCP_filebuf_vtable;
|
|
|
|
this->fd = fd;
|
|
|
|
this->close = 0;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ??0filebuf@@QAE@H@Z */
|
|
|
|
/* ??0filebuf@@QEAA@H@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_fd_ctor, 8)
|
|
|
|
filebuf* __thiscall filebuf_fd_ctor(filebuf* this, filedesc fd)
|
|
|
|
{
|
|
|
|
filebuf_fd_reserve_ctor(this, fd, NULL, 0);
|
|
|
|
this->base.unbuffered = 0;
|
2015-08-03 16:48:37 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ??0filebuf@@QAE@XZ */
|
|
|
|
/* ??0filebuf@@QEAA@XZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_ctor, 4)
|
|
|
|
filebuf* __thiscall filebuf_ctor(filebuf* this)
|
|
|
|
{
|
2015-08-03 16:48:53 +02:00
|
|
|
return filebuf_fd_ctor(this, -1);
|
2015-08-03 16:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ??1filebuf@@UAE@XZ */
|
|
|
|
/* ??1filebuf@@UEAA@XZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_dtor, 4)
|
|
|
|
void __thiscall filebuf_dtor(filebuf* this)
|
|
|
|
{
|
2015-08-03 16:48:53 +02:00
|
|
|
TRACE("(%p)\n", this);
|
2015-08-05 20:32:29 +02:00
|
|
|
if (this->close)
|
|
|
|
filebuf_close(this);
|
2015-08-03 16:48:53 +02:00
|
|
|
streambuf_dtor(&this->base);
|
2015-08-03 16:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ??4filebuf@@QAEAAV0@ABV0@@Z */
|
|
|
|
/* ??4filebuf@@QEAAAEAV0@AEBV0@@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_assign, 8)
|
|
|
|
filebuf* __thiscall filebuf_assign(filebuf* this, const filebuf *rhs)
|
|
|
|
{
|
2015-08-03 16:48:53 +02:00
|
|
|
filebuf_dtor(this);
|
|
|
|
return filebuf_copy_ctor(this, rhs);
|
2015-08-03 16:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ??_Efilebuf@@UAEPAXI@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_vector_dtor, 8)
|
|
|
|
filebuf* __thiscall filebuf_vector_dtor(filebuf *this, unsigned int flags)
|
|
|
|
{
|
|
|
|
TRACE("(%p %x)\n", this, flags);
|
|
|
|
if (flags & 2) {
|
|
|
|
/* we have an array, with the number of elements stored before the first object */
|
|
|
|
INT_PTR i, *ptr = (INT_PTR *)this-1;
|
|
|
|
|
|
|
|
for (i = *ptr-1; i >= 0; i--)
|
|
|
|
filebuf_dtor(this+i);
|
|
|
|
MSVCRT_operator_delete(ptr);
|
|
|
|
} else {
|
|
|
|
filebuf_dtor(this);
|
|
|
|
if (flags & 1)
|
|
|
|
MSVCRT_operator_delete(this);
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ??_Gfilebuf@@UAEPAXI@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_scalar_dtor, 8)
|
|
|
|
filebuf* __thiscall filebuf_scalar_dtor(filebuf *this, unsigned int flags)
|
|
|
|
{
|
|
|
|
TRACE("(%p %x)\n", this, flags);
|
|
|
|
filebuf_dtor(this);
|
|
|
|
if (flags & 1) MSVCRT_operator_delete(this);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?attach@filebuf@@QAEPAV1@H@Z */
|
|
|
|
/* ?attach@filebuf@@QEAAPEAV1@H@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_attach, 8)
|
|
|
|
filebuf* __thiscall filebuf_attach(filebuf *this, filedesc fd)
|
|
|
|
{
|
2015-08-03 16:49:01 +02:00
|
|
|
TRACE("(%p %d)\n", this, fd);
|
|
|
|
if (this->fd != -1)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
streambuf_lock(&this->base);
|
|
|
|
this->fd = fd;
|
|
|
|
streambuf_allocate(&this->base);
|
|
|
|
streambuf_unlock(&this->base);
|
|
|
|
return this;
|
2015-08-03 16:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?close@filebuf@@QAEPAV1@XZ */
|
|
|
|
/* ?close@filebuf@@QEAAPEAV1@XZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_close, 4)
|
|
|
|
filebuf* __thiscall filebuf_close(filebuf *this)
|
|
|
|
{
|
2015-08-05 20:32:29 +02:00
|
|
|
filebuf *ret;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
if (this->fd == -1)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
streambuf_lock(&this->base);
|
|
|
|
if (call_streambuf_sync(&this->base) == EOF || _close(this->fd) < 0) {
|
|
|
|
ret = NULL;
|
|
|
|
} else {
|
|
|
|
this->fd = -1;
|
|
|
|
ret = this;
|
|
|
|
}
|
|
|
|
streambuf_unlock(&this->base);
|
|
|
|
return ret;
|
2015-08-03 16:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?fd@filebuf@@QBEHXZ */
|
|
|
|
/* ?fd@filebuf@@QEBAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_fd, 4)
|
|
|
|
filedesc __thiscall filebuf_fd(const filebuf *this)
|
|
|
|
{
|
2015-08-05 20:32:35 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->fd;
|
2015-08-03 16:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?is_open@filebuf@@QBEHXZ */
|
|
|
|
/* ?is_open@filebuf@@QEBAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_is_open, 4)
|
|
|
|
int __thiscall filebuf_is_open(const filebuf *this)
|
|
|
|
{
|
2015-08-05 20:32:35 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->fd != -1;
|
2015-08-03 16:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?open@filebuf@@QAEPAV1@PBDHH@Z */
|
|
|
|
/* ?open@filebuf@@QEAAPEAV1@PEBDHH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_open, 16)
|
|
|
|
filebuf* __thiscall filebuf_open(filebuf *this, const char *name, ios_open_mode mode, int protection)
|
|
|
|
{
|
2015-08-05 20:32:29 +02:00
|
|
|
const int inout_mode[4] = {-1, _O_RDONLY, _O_WRONLY, _O_RDWR};
|
|
|
|
const int share_mode[4] = {_SH_DENYRW, _SH_DENYWR, _SH_DENYRD, _SH_DENYNO};
|
|
|
|
int op_flags, sh_flags, fd;
|
|
|
|
|
|
|
|
TRACE("(%p %s %x %x)\n", this, name, mode, protection);
|
|
|
|
if (this->fd != -1)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* mode */
|
|
|
|
if (mode & (OPENMODE_app|OPENMODE_trunc))
|
|
|
|
mode |= OPENMODE_out;
|
|
|
|
op_flags = inout_mode[mode & (OPENMODE_in|OPENMODE_out)];
|
|
|
|
if (op_flags < 0)
|
|
|
|
return NULL;
|
|
|
|
if (mode & OPENMODE_app)
|
|
|
|
op_flags |= _O_APPEND;
|
|
|
|
if ((mode & OPENMODE_trunc) ||
|
|
|
|
((mode & OPENMODE_out) && !(mode & (OPENMODE_in|OPENMODE_app|OPENMODE_ate))))
|
|
|
|
op_flags |= _O_TRUNC;
|
|
|
|
if (!(mode & OPENMODE_nocreate))
|
|
|
|
op_flags |= _O_CREAT;
|
|
|
|
if (mode & OPENMODE_noreplace)
|
|
|
|
op_flags |= _O_EXCL;
|
|
|
|
op_flags |= (mode & OPENMODE_binary) ? _O_BINARY : _O_TEXT;
|
|
|
|
|
|
|
|
/* share protection */
|
|
|
|
sh_flags = (protection & filebuf_sh_none) ? share_mode[(protection >> 9) & 3] : _SH_DENYNO;
|
|
|
|
|
|
|
|
TRACE("op_flags %x, sh_flags %x\n", op_flags, sh_flags);
|
|
|
|
fd = _sopen(name, op_flags, sh_flags, _S_IREAD|_S_IWRITE);
|
|
|
|
if (fd < 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
streambuf_lock(&this->base);
|
|
|
|
this->close = 1;
|
2015-08-10 20:09:30 +02:00
|
|
|
this->fd = fd;
|
2015-08-05 20:32:29 +02:00
|
|
|
if ((mode & OPENMODE_ate) &&
|
|
|
|
call_streambuf_seekoff(&this->base, 0, SEEKDIR_end, mode & (OPENMODE_in|OPENMODE_out)) == EOF) {
|
|
|
|
_close(fd);
|
2015-08-10 20:09:30 +02:00
|
|
|
this->fd = -1;
|
|
|
|
}
|
2015-08-10 20:08:54 +02:00
|
|
|
streambuf_allocate(&this->base);
|
2015-08-05 20:32:29 +02:00
|
|
|
streambuf_unlock(&this->base);
|
|
|
|
return (this->fd == -1) ? NULL : this;
|
2015-08-03 16:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?overflow@filebuf@@UAEHH@Z */
|
|
|
|
/* ?overflow@filebuf@@UEAAHH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_overflow, 8)
|
|
|
|
int __thiscall filebuf_overflow(filebuf *this, int c)
|
|
|
|
{
|
2015-08-10 20:09:20 +02:00
|
|
|
TRACE("(%p %d)\n", this, c);
|
|
|
|
if (call_streambuf_sync(&this->base) == EOF)
|
|
|
|
return EOF;
|
|
|
|
if (this->base.unbuffered)
|
|
|
|
return (c == EOF) ? 1 : _write(this->fd, &c, 1);
|
|
|
|
if (streambuf_allocate(&this->base) == EOF)
|
|
|
|
return EOF;
|
|
|
|
|
|
|
|
this->base.pbase = this->base.pptr = this->base.base;
|
|
|
|
this->base.epptr = this->base.ebuf;
|
|
|
|
if (c != EOF)
|
|
|
|
*this->base.pptr++ = c;
|
|
|
|
return 1;
|
2015-08-03 16:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?seekoff@filebuf@@UAEJJW4seek_dir@ios@@H@Z */
|
|
|
|
/* ?seekoff@filebuf@@UEAAJJW4seek_dir@ios@@H@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_seekoff, 16)
|
|
|
|
streampos __thiscall filebuf_seekoff(filebuf *this, streamoff offset, ios_seek_dir dir, int mode)
|
|
|
|
{
|
2015-08-10 20:09:30 +02:00
|
|
|
TRACE("(%p %d %d %d)\n", this, offset, dir, mode);
|
|
|
|
if (call_streambuf_sync(&this->base) == EOF)
|
|
|
|
return EOF;
|
|
|
|
return _lseek(this->fd, offset, dir);
|
2015-08-03 16:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?setbuf@filebuf@@UAEPAVstreambuf@@PADH@Z */
|
|
|
|
/* ?setbuf@filebuf@@UEAAPEAVstreambuf@@PEADH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_setbuf, 12)
|
|
|
|
streambuf* __thiscall filebuf_setbuf(filebuf *this, char *buffer, int length)
|
|
|
|
{
|
2015-08-10 20:09:07 +02:00
|
|
|
streambuf *ret;
|
|
|
|
|
|
|
|
TRACE("(%p %p %d)\n", this, buffer, length);
|
|
|
|
if (this->base.base != NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
streambuf_lock(&this->base);
|
|
|
|
ret = streambuf_setbuf(&this->base, buffer, length);
|
|
|
|
streambuf_unlock(&this->base);
|
|
|
|
return ret;
|
2015-08-03 16:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?setmode@filebuf@@QAEHH@Z */
|
|
|
|
/* ?setmode@filebuf@@QEAAHH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_setmode, 8)
|
|
|
|
int __thiscall filebuf_setmode(filebuf *this, int mode)
|
|
|
|
{
|
2015-08-10 20:09:01 +02:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
TRACE("(%p %d)\n", this, mode);
|
|
|
|
if (mode != filebuf_text && mode != filebuf_binary)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
streambuf_lock(&this->base);
|
|
|
|
ret = (call_streambuf_sync(&this->base) == EOF) ? -1 : _setmode(this->fd, mode);
|
|
|
|
streambuf_unlock(&this->base);
|
|
|
|
return ret;
|
2015-08-03 16:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?sync@filebuf@@UAEHXZ */
|
|
|
|
/* ?sync@filebuf@@UEAAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_sync, 4)
|
|
|
|
int __thiscall filebuf_sync(filebuf *this)
|
|
|
|
{
|
2015-08-10 20:09:14 +02:00
|
|
|
int count, mode;
|
|
|
|
char *ptr;
|
|
|
|
LONG offset;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
if (this->fd == -1)
|
|
|
|
return EOF;
|
|
|
|
if (this->base.unbuffered)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* flush output buffer */
|
|
|
|
if (this->base.pptr != NULL) {
|
|
|
|
count = this->base.pptr - this->base.pbase;
|
|
|
|
if (count > 0 && _write(this->fd, this->base.pbase, count) != count)
|
|
|
|
return EOF;
|
|
|
|
this->base.pbase = this->base.pptr = this->base.epptr = NULL;
|
|
|
|
}
|
|
|
|
/* flush input buffer */
|
|
|
|
if (this->base.egptr != NULL) {
|
|
|
|
offset = this->base.egptr - this->base.gptr;
|
|
|
|
if (offset > 0) {
|
|
|
|
mode = _setmode(this->fd, _O_TEXT);
|
|
|
|
_setmode(this->fd, mode);
|
|
|
|
if (mode & _O_TEXT) {
|
|
|
|
/* in text mode, '\n' in the buffer means '\r\n' in the file */
|
|
|
|
for (ptr = this->base.gptr; ptr < this->base.egptr; ptr++)
|
|
|
|
if (*ptr == '\n')
|
|
|
|
offset++;
|
|
|
|
}
|
|
|
|
if (_lseek(this->fd, -offset, SEEK_CUR) < 0)
|
|
|
|
return EOF;
|
|
|
|
}
|
|
|
|
this->base.eback = this->base.gptr = this->base.egptr = NULL;
|
|
|
|
}
|
2015-08-05 20:32:29 +02:00
|
|
|
return 0;
|
2015-08-03 16:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?underflow@filebuf@@UAEHXZ */
|
|
|
|
/* ?underflow@filebuf@@UEAAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(filebuf_underflow, 4)
|
|
|
|
int __thiscall filebuf_underflow(filebuf *this)
|
|
|
|
{
|
2015-08-10 20:09:26 +02:00
|
|
|
int buffer_size, read_bytes;
|
|
|
|
char c;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
|
|
|
|
if (this->base.unbuffered)
|
|
|
|
return (_read(this->fd, &c, 1) < 1) ? EOF : c;
|
|
|
|
|
|
|
|
if (this->base.gptr >= this->base.egptr) {
|
|
|
|
if (call_streambuf_sync(&this->base) == EOF)
|
|
|
|
return EOF;
|
|
|
|
buffer_size = this->base.ebuf - this->base.base;
|
|
|
|
read_bytes = _read(this->fd, this->base.base, buffer_size);
|
|
|
|
if (read_bytes <= 0)
|
|
|
|
return EOF;
|
|
|
|
this->base.eback = this->base.gptr = this->base.base;
|
|
|
|
this->base.egptr = this->base.base + read_bytes;
|
|
|
|
}
|
|
|
|
return *this->base.gptr;
|
2015-08-03 16:48:37 +02:00
|
|
|
}
|
|
|
|
|
2015-07-04 16:24:37 +02:00
|
|
|
/* ??0ios@@IAE@ABV0@@Z */
|
|
|
|
/* ??0ios@@IEAA@AEBV0@@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_copy_ctor, 8)
|
|
|
|
ios* __thiscall ios_copy_ctor(ios *this, const ios *copy)
|
2010-07-31 10:11:44 +02:00
|
|
|
{
|
2015-07-04 16:24:53 +02:00
|
|
|
TRACE("(%p %p)\n", this, copy);
|
2015-07-17 16:37:24 +02:00
|
|
|
ios_fLockcInit++;
|
2015-07-04 16:24:53 +02:00
|
|
|
this->vtable = &MSVCP_ios_vtable;
|
|
|
|
this->sb = NULL;
|
|
|
|
this->delbuf = 0;
|
|
|
|
InitializeCriticalSection(&this->lock);
|
|
|
|
return ios_assign(this, copy);
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ??0ios@@QAE@PAVstreambuf@@@Z */
|
|
|
|
/* ??0ios@@QEAA@PEAVstreambuf@@@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_sb_ctor, 8)
|
|
|
|
ios* __thiscall ios_sb_ctor(ios *this, streambuf *sb)
|
|
|
|
{
|
2015-07-04 16:24:53 +02:00
|
|
|
TRACE("(%p %p)\n", this, sb);
|
2015-07-17 16:37:24 +02:00
|
|
|
ios_fLockcInit++;
|
2015-07-04 16:24:53 +02:00
|
|
|
this->vtable = &MSVCP_ios_vtable;
|
|
|
|
this->sb = sb;
|
|
|
|
this->state = sb ? IOSTATE_goodbit : IOSTATE_badbit;
|
|
|
|
this->special[0] = this->special[1] = 0;
|
|
|
|
this->delbuf = 0;
|
|
|
|
this->tie = NULL;
|
|
|
|
this->flags = 0;
|
|
|
|
this->precision = 6;
|
|
|
|
this->fill = ' ';
|
|
|
|
this->width = 0;
|
|
|
|
this->do_lock = -1;
|
|
|
|
InitializeCriticalSection(&this->lock);
|
2015-07-04 16:24:37 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2015-07-04 16:24:53 +02:00
|
|
|
/* ??0ios@@IAE@XZ */
|
|
|
|
/* ??0ios@@IEAA@XZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_ctor, 4)
|
|
|
|
ios* __thiscall ios_ctor(ios *this)
|
|
|
|
{
|
|
|
|
return ios_sb_ctor(this, NULL);
|
|
|
|
}
|
|
|
|
|
2015-07-04 16:24:37 +02:00
|
|
|
/* ??1ios@@UAE@XZ */
|
|
|
|
/* ??1ios@@UEAA@XZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_dtor, 4)
|
|
|
|
void __thiscall ios_dtor(ios *this)
|
|
|
|
{
|
2015-07-04 16:24:53 +02:00
|
|
|
TRACE("(%p)\n", this);
|
2015-07-17 16:37:24 +02:00
|
|
|
ios_fLockcInit--;
|
2015-07-04 16:24:53 +02:00
|
|
|
if (this->delbuf && this->sb)
|
2015-07-08 10:28:59 +02:00
|
|
|
call_streambuf_vector_dtor(this->sb, 1);
|
2015-07-04 16:24:53 +02:00
|
|
|
this->sb = NULL;
|
|
|
|
this->state = IOSTATE_badbit;
|
|
|
|
DeleteCriticalSection(&this->lock);
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ??4ios@@IAEAAV0@ABV0@@Z */
|
|
|
|
/* ??4ios@@IEAAAEAV0@AEBV0@@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_assign, 8)
|
|
|
|
ios* __thiscall ios_assign(ios *this, const ios *rhs)
|
|
|
|
{
|
2015-07-04 16:24:53 +02:00
|
|
|
TRACE("(%p %p)\n", this, rhs);
|
|
|
|
this->state = rhs->state;
|
|
|
|
if (!this->sb)
|
|
|
|
this->state |= IOSTATE_badbit;
|
|
|
|
this->tie = rhs->tie;
|
|
|
|
this->flags = rhs->flags;
|
|
|
|
this->precision = (char) rhs->precision;
|
|
|
|
this->fill = rhs->fill;
|
|
|
|
this->width = (char) rhs->width;
|
2015-07-04 16:24:37 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ??7ios@@QBEHXZ */
|
|
|
|
/* ??7ios@@QEBAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_op_not, 4)
|
|
|
|
int __thiscall ios_op_not(const ios *this)
|
|
|
|
{
|
2015-07-17 16:37:00 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return ios_fail(this);
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ??Bios@@QBEPAXXZ */
|
|
|
|
/* ??Bios@@QEBAPEAXXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_op_void, 4)
|
|
|
|
void* __thiscall ios_op_void(const ios *this)
|
|
|
|
{
|
2015-07-17 16:37:00 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return ios_fail(this) ? NULL : (void*)this;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ??_Eios@@UAEPAXI@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_vector_dtor, 8)
|
|
|
|
ios* __thiscall ios_vector_dtor(ios *this, unsigned int flags)
|
|
|
|
{
|
|
|
|
TRACE("(%p %x)\n", this, flags);
|
|
|
|
if (flags & 2) {
|
|
|
|
/* we have an array, with the number of elements stored before the first object */
|
|
|
|
INT_PTR i, *ptr = (INT_PTR *)this-1;
|
|
|
|
|
|
|
|
for (i = *ptr-1; i >= 0; i--)
|
|
|
|
ios_dtor(this+i);
|
|
|
|
MSVCRT_operator_delete(ptr);
|
|
|
|
} else {
|
|
|
|
ios_dtor(this);
|
|
|
|
if (flags & 1)
|
|
|
|
MSVCRT_operator_delete(this);
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ??_Gios@@UAEPAXI@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_scalar_dtor, 8)
|
|
|
|
ios* __thiscall ios_scalar_dtor(ios *this, unsigned int flags)
|
|
|
|
{
|
|
|
|
TRACE("(%p %x)\n", this, flags);
|
|
|
|
ios_dtor(this);
|
|
|
|
if (flags & 1) MSVCRT_operator_delete(this);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?bad@ios@@QBEHXZ */
|
|
|
|
/* ?bad@ios@@QEBAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_bad, 4)
|
|
|
|
int __thiscall ios_bad(const ios *this)
|
|
|
|
{
|
2015-07-17 16:36:55 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return (this->state & IOSTATE_badbit);
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?bitalloc@ios@@SAJXZ */
|
|
|
|
LONG __cdecl ios_bitalloc(void)
|
|
|
|
{
|
2015-07-17 16:37:14 +02:00
|
|
|
TRACE("()\n");
|
|
|
|
ios_lockc();
|
|
|
|
ios_maxbit <<= 1;
|
|
|
|
ios_unlockc();
|
|
|
|
return ios_maxbit;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?clear@ios@@QAEXH@Z */
|
|
|
|
/* ?clear@ios@@QEAAXH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_clear, 8)
|
|
|
|
void __thiscall ios_clear(ios *this, int state)
|
|
|
|
{
|
2015-07-17 16:36:55 +02:00
|
|
|
TRACE("(%p %d)\n", this, state);
|
|
|
|
ios_lock(this);
|
|
|
|
this->state = state;
|
|
|
|
ios_unlock(this);
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?clrlock@ios@@QAAXXZ */
|
|
|
|
/* ?clrlock@ios@@QEAAXXZ */
|
|
|
|
void __cdecl ios_clrlock(ios *this)
|
|
|
|
{
|
2015-07-13 21:39:00 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
if (this->do_lock <= 0)
|
|
|
|
this->do_lock++;
|
|
|
|
if (this->sb)
|
|
|
|
streambuf_clrlock(this->sb);
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?delbuf@ios@@QAEXH@Z */
|
|
|
|
/* ?delbuf@ios@@QEAAXH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_delbuf_set, 8)
|
|
|
|
void __thiscall ios_delbuf_set(ios *this, int delete)
|
|
|
|
{
|
2015-07-17 16:36:50 +02:00
|
|
|
TRACE("(%p %d)\n", this, delete);
|
|
|
|
this->delbuf = delete;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?delbuf@ios@@QBEHXZ */
|
|
|
|
/* ?delbuf@ios@@QEBAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_delbuf_get, 4)
|
|
|
|
int __thiscall ios_delbuf_get(const ios *this)
|
|
|
|
{
|
2015-07-17 16:36:50 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->delbuf;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?dec@@YAAAVios@@AAV1@@Z */
|
|
|
|
/* ?dec@@YAAEAVios@@AEAV1@@Z */
|
|
|
|
ios* __cdecl ios_dec(ios *this)
|
|
|
|
{
|
2015-07-17 16:37:09 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
ios_setf_mask(this, FLAGS_dec, ios_basefield);
|
2015-07-04 16:24:37 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?eof@ios@@QBEHXZ */
|
|
|
|
/* ?eof@ios@@QEBAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_eof, 4)
|
|
|
|
int __thiscall ios_eof(const ios *this)
|
|
|
|
{
|
2015-07-17 16:36:55 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return (this->state & IOSTATE_eofbit);
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?fail@ios@@QBEHXZ */
|
|
|
|
/* ?fail@ios@@QEBAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_fail, 4)
|
|
|
|
int __thiscall ios_fail(const ios *this)
|
|
|
|
{
|
2015-07-17 16:36:55 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return (this->state & (IOSTATE_failbit|IOSTATE_badbit));
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?fill@ios@@QAEDD@Z */
|
|
|
|
/* ?fill@ios@@QEAADD@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_fill_set, 8)
|
|
|
|
char __thiscall ios_fill_set(ios *this, char fill)
|
|
|
|
{
|
2015-07-17 16:36:22 +02:00
|
|
|
char prev = this->fill;
|
|
|
|
|
|
|
|
TRACE("(%p %d)\n", this, fill);
|
|
|
|
|
|
|
|
this->fill = fill;
|
|
|
|
return prev;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?fill@ios@@QBEDXZ */
|
|
|
|
/* ?fill@ios@@QEBADXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_fill_get, 4)
|
|
|
|
char __thiscall ios_fill_get(const ios *this)
|
|
|
|
{
|
2015-07-17 16:36:22 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->fill;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?flags@ios@@QAEJJ@Z */
|
|
|
|
/* ?flags@ios@@QEAAJJ@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_flags_set, 8)
|
|
|
|
LONG __thiscall ios_flags_set(ios *this, LONG flags)
|
|
|
|
{
|
2015-07-16 13:12:35 +02:00
|
|
|
LONG prev = this->flags;
|
|
|
|
|
|
|
|
TRACE("(%p %x)\n", this, flags);
|
|
|
|
|
|
|
|
this->flags = flags;
|
|
|
|
return prev;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?flags@ios@@QBEJXZ */
|
|
|
|
/* ?flags@ios@@QEBAJXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_flags_get, 4)
|
|
|
|
LONG __thiscall ios_flags_get(const ios *this)
|
|
|
|
{
|
2015-07-16 13:12:35 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->flags;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?good@ios@@QBEHXZ */
|
|
|
|
/* ?good@ios@@QEBAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_good, 4)
|
|
|
|
int __thiscall ios_good(const ios *this)
|
|
|
|
{
|
2015-07-17 16:36:55 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->state == IOSTATE_goodbit;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?hex@@YAAAVios@@AAV1@@Z */
|
|
|
|
/* ?hex@@YAAEAVios@@AEAV1@@Z */
|
|
|
|
ios* __cdecl ios_hex(ios *this)
|
|
|
|
{
|
2015-07-17 16:37:09 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
ios_setf_mask(this, FLAGS_hex, ios_basefield);
|
2015-07-04 16:24:37 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?init@ios@@IAEXPAVstreambuf@@@Z */
|
|
|
|
/* ?init@ios@@IEAAXPEAVstreambuf@@@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_init, 8)
|
|
|
|
void __thiscall ios_init(ios *this, streambuf *sb)
|
|
|
|
{
|
2015-07-04 16:24:53 +02:00
|
|
|
TRACE("(%p %p)\n", this, sb);
|
|
|
|
if (this->delbuf && this->sb)
|
2015-07-08 10:28:59 +02:00
|
|
|
call_streambuf_vector_dtor(this->sb, 1);
|
2015-07-04 16:24:53 +02:00
|
|
|
this->sb = sb;
|
|
|
|
if (sb == NULL)
|
|
|
|
this->state |= IOSTATE_badbit;
|
|
|
|
else
|
|
|
|
this->state &= ~IOSTATE_badbit;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?iword@ios@@QBEAAJH@Z */
|
|
|
|
/* ?iword@ios@@QEBAAEAJH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_iword, 8)
|
|
|
|
LONG* __thiscall ios_iword(const ios *this, int index)
|
|
|
|
{
|
2015-07-17 16:37:18 +02:00
|
|
|
TRACE("(%p %d)\n", this, index);
|
|
|
|
return &ios_statebuf[index];
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?lock@ios@@QAAXXZ */
|
|
|
|
/* ?lock@ios@@QEAAXXZ */
|
|
|
|
void __cdecl ios_lock(ios *this)
|
|
|
|
{
|
2015-07-13 21:39:04 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
if (this->do_lock < 0)
|
|
|
|
EnterCriticalSection(&this->lock);
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?lockbuf@ios@@QAAXXZ */
|
|
|
|
/* ?lockbuf@ios@@QEAAXXZ */
|
|
|
|
void __cdecl ios_lockbuf(ios *this)
|
|
|
|
{
|
2015-07-13 21:39:09 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
streambuf_lock(this->sb);
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?lockc@ios@@KAXXZ */
|
|
|
|
void __cdecl ios_lockc(void)
|
|
|
|
{
|
2015-07-16 13:12:30 +02:00
|
|
|
TRACE("()\n");
|
|
|
|
EnterCriticalSection(&ios_static_lock);
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?lockptr@ios@@IAEPAU_CRT_CRITICAL_SECTION@@XZ */
|
|
|
|
/* ?lockptr@ios@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_lockptr, 4)
|
|
|
|
CRITICAL_SECTION* __thiscall ios_lockptr(ios *this)
|
|
|
|
{
|
2015-07-13 21:39:00 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return &this->lock;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?oct@@YAAAVios@@AAV1@@Z */
|
|
|
|
/* ?oct@@YAAEAVios@@AEAV1@@Z */
|
|
|
|
ios* __cdecl ios_oct(ios *this)
|
|
|
|
{
|
2015-07-17 16:37:09 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
ios_setf_mask(this, FLAGS_oct, ios_basefield);
|
2015-07-04 16:24:37 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?precision@ios@@QAEHH@Z */
|
|
|
|
/* ?precision@ios@@QEAAHH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_precision_set, 8)
|
|
|
|
int __thiscall ios_precision_set(ios *this, int prec)
|
|
|
|
{
|
2015-07-17 16:36:27 +02:00
|
|
|
int prev = this->precision;
|
|
|
|
|
|
|
|
TRACE("(%p %d)\n", this, prec);
|
|
|
|
|
|
|
|
this->precision = prec;
|
|
|
|
return prev;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?precision@ios@@QBEHXZ */
|
|
|
|
/* ?precision@ios@@QEBAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_precision_get, 4)
|
|
|
|
int __thiscall ios_precision_get(const ios *this)
|
|
|
|
{
|
2015-07-17 16:36:27 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->precision;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?pword@ios@@QBEAAPAXH@Z */
|
|
|
|
/* ?pword@ios@@QEBAAEAPEAXH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_pword, 8)
|
|
|
|
void** __thiscall ios_pword(const ios *this, int index)
|
|
|
|
{
|
2015-07-17 16:37:18 +02:00
|
|
|
TRACE("(%p %d)\n", this, index);
|
|
|
|
return (void**)&ios_statebuf[index];
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?rdbuf@ios@@QBEPAVstreambuf@@XZ */
|
|
|
|
/* ?rdbuf@ios@@QEBAPEAVstreambuf@@XZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_rdbuf, 4)
|
|
|
|
streambuf* __thiscall ios_rdbuf(const ios *this)
|
|
|
|
{
|
2015-07-17 16:36:46 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->sb;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?rdstate@ios@@QBEHXZ */
|
|
|
|
/* ?rdstate@ios@@QEBAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_rdstate, 4)
|
|
|
|
int __thiscall ios_rdstate(const ios *this)
|
|
|
|
{
|
2015-07-17 16:36:55 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->state;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?setf@ios@@QAEJJ@Z */
|
|
|
|
/* ?setf@ios@@QEAAJJ@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_setf, 8)
|
|
|
|
LONG __thiscall ios_setf(ios *this, LONG flags)
|
|
|
|
{
|
2015-07-16 13:12:40 +02:00
|
|
|
LONG prev = this->flags;
|
|
|
|
|
|
|
|
TRACE("(%p %x)\n", this, flags);
|
|
|
|
|
|
|
|
ios_lock(this);
|
|
|
|
this->flags |= flags;
|
|
|
|
ios_unlock(this);
|
|
|
|
return prev;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?setf@ios@@QAEJJJ@Z */
|
|
|
|
/* ?setf@ios@@QEAAJJJ@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_setf_mask, 12)
|
|
|
|
LONG __thiscall ios_setf_mask(ios *this, LONG flags, LONG mask)
|
|
|
|
{
|
2015-07-16 13:12:40 +02:00
|
|
|
LONG prev = this->flags;
|
|
|
|
|
|
|
|
TRACE("(%p %x %x)\n", this, flags, mask);
|
|
|
|
|
|
|
|
ios_lock(this);
|
|
|
|
this->flags = (this->flags & (~mask)) | (flags & mask);
|
|
|
|
ios_unlock(this);
|
|
|
|
return prev;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?setlock@ios@@QAAXXZ */
|
|
|
|
/* ?setlock@ios@@QEAAXXZ */
|
|
|
|
void __cdecl ios_setlock(ios *this)
|
|
|
|
{
|
2015-07-13 21:39:00 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
this->do_lock--;
|
|
|
|
if (this->sb)
|
|
|
|
streambuf_setlock(this->sb);
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?sync_with_stdio@ios@@SAXXZ */
|
|
|
|
void __cdecl ios_sync_with_stdio(void)
|
|
|
|
{
|
|
|
|
FIXME("() stub\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?tie@ios@@QAEPAVostream@@PAV2@@Z */
|
|
|
|
/* ?tie@ios@@QEAAPEAVostream@@PEAV2@@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_tie_set, 8)
|
|
|
|
ostream* __thiscall ios_tie_set(ios *this, ostream *ostr)
|
|
|
|
{
|
2015-07-17 16:36:40 +02:00
|
|
|
ostream *prev = this->tie;
|
|
|
|
|
|
|
|
TRACE("(%p %p)\n", this, ostr);
|
|
|
|
|
|
|
|
this->tie = ostr;
|
|
|
|
return prev;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?tie@ios@@QBEPAVostream@@XZ */
|
|
|
|
/* ?tie@ios@@QEBAPEAVostream@@XZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_tie_get, 4)
|
|
|
|
ostream* __thiscall ios_tie_get(const ios *this)
|
|
|
|
{
|
2015-07-17 16:36:40 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->tie;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?unlock@ios@@QAAXXZ */
|
|
|
|
/* ?unlock@ios@@QEAAXXZ */
|
|
|
|
void __cdecl ios_unlock(ios *this)
|
|
|
|
{
|
2015-07-13 21:39:04 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
if (this->do_lock < 0)
|
|
|
|
LeaveCriticalSection(&this->lock);
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?unlockbuf@ios@@QAAXXZ */
|
|
|
|
/* ?unlockbuf@ios@@QEAAXXZ */
|
|
|
|
void __cdecl ios_unlockbuf(ios *this)
|
|
|
|
{
|
2015-07-13 21:39:09 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
streambuf_unlock(this->sb);
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?unlockc@ios@@KAXXZ */
|
|
|
|
void __cdecl ios_unlockc(void)
|
|
|
|
{
|
2015-07-16 13:12:30 +02:00
|
|
|
TRACE("()\n");
|
|
|
|
LeaveCriticalSection(&ios_static_lock);
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?unsetf@ios@@QAEJJ@Z */
|
|
|
|
/* ?unsetf@ios@@QEAAJJ@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_unsetf, 8)
|
|
|
|
LONG __thiscall ios_unsetf(ios *this, LONG flags)
|
|
|
|
{
|
2015-07-16 13:12:45 +02:00
|
|
|
LONG prev = this->flags;
|
|
|
|
|
|
|
|
TRACE("(%p %x)\n", this, flags);
|
|
|
|
|
|
|
|
ios_lock(this);
|
|
|
|
this->flags &= ~flags;
|
|
|
|
ios_unlock(this);
|
|
|
|
return prev;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?width@ios@@QAEHH@Z */
|
|
|
|
/* ?width@ios@@QEAAHH@Z */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_width_set, 8)
|
|
|
|
int __thiscall ios_width_set(ios *this, int width)
|
|
|
|
{
|
2015-07-17 16:36:32 +02:00
|
|
|
int prev = this->width;
|
|
|
|
|
|
|
|
TRACE("(%p %d)\n", this, width);
|
|
|
|
|
|
|
|
this->width = width;
|
|
|
|
return prev;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?width@ios@@QBEHXZ */
|
|
|
|
/* ?width@ios@@QEBAHXZ */
|
|
|
|
DEFINE_THISCALL_WRAPPER(ios_width_get, 4)
|
|
|
|
int __thiscall ios_width_get(const ios *this)
|
|
|
|
{
|
2015-07-17 16:36:32 +02:00
|
|
|
TRACE("(%p)\n", this);
|
|
|
|
return this->width;
|
2015-07-04 16:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ?xalloc@ios@@SAHXZ */
|
|
|
|
int __cdecl ios_xalloc(void)
|
|
|
|
{
|
2015-07-17 16:37:18 +02:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
TRACE("()\n");
|
|
|
|
|
|
|
|
ios_lockc();
|
|
|
|
ret = (ios_curindex < STATEBUF_SIZE-1) ? ++ios_curindex : -1;
|
|
|
|
ios_unlockc();
|
|
|
|
return ret;
|
2010-07-31 10:11:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* ??0ostrstream@@QAE@XZ (MSVCRTI.@)
|
|
|
|
*/
|
2015-06-29 10:22:07 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCIRT_ostrstream_ctor,8)
|
2015-07-04 16:24:37 +02:00
|
|
|
void * __thiscall MSVCIRT_ostrstream_ctor(ostream *this, BOOL virt_init)
|
2010-07-31 10:11:44 +02:00
|
|
|
{
|
2015-06-29 10:22:07 +02:00
|
|
|
FIXME("(%p %x) stub\n", this, virt_init);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* ??1ostrstream@@UAE@XZ (MSVCRTI.@)
|
|
|
|
*/
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCIRT_ostrstream_dtor,4)
|
2015-07-04 16:24:37 +02:00
|
|
|
void __thiscall MSVCIRT_ostrstream_dtor(ios *base)
|
2015-06-29 10:22:07 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p) stub\n", base);
|
2010-07-31 10:11:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* ??6ostream@@QAEAAV0@E@Z (MSVCRTI.@)
|
|
|
|
* class ostream & __thiscall ostream::operator<<(unsigned char)
|
|
|
|
*/
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCIRT_operator_sl_uchar,8)
|
2015-07-04 16:24:37 +02:00
|
|
|
void * __thiscall MSVCIRT_operator_sl_uchar(ostream * _this, unsigned char ch)
|
2010-07-31 10:11:44 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p)->(%c) stub\n", _this, ch);
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
2008-08-20 10:18:58 +02:00
|
|
|
/******************************************************************
|
|
|
|
* ??6ostream@@QAEAAV0@H@Z (MSVCRTI.@)
|
|
|
|
* class ostream & __thiscall ostream::operator<<(int)
|
|
|
|
*/
|
2009-06-14 15:34:14 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCIRT_operator_sl_int,8)
|
2015-07-04 16:24:37 +02:00
|
|
|
void * __thiscall MSVCIRT_operator_sl_int(ostream * _this, int integer)
|
2008-08-20 10:18:58 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p)->(%d) stub\n", _this, integer);
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* ??6ostream@@QAEAAV0@PBD@Z (MSVCRTI.@)
|
|
|
|
* class ostream & __thiscall ostream::operator<<(char const *)
|
|
|
|
*/
|
2009-06-14 15:34:14 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCIRT_operator_sl_pchar,8)
|
2015-07-04 16:24:37 +02:00
|
|
|
void * __thiscall MSVCIRT_operator_sl_pchar(ostream * _this, const char * string)
|
2008-08-20 10:18:58 +02:00
|
|
|
{
|
2009-10-31 20:13:49 +01:00
|
|
|
FIXME("(%p)->(%s) stub\n", _this, debugstr_a(string));
|
2008-08-20 10:18:58 +02:00
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
2009-10-25 22:15:28 +01:00
|
|
|
/******************************************************************
|
|
|
|
* ??6ostream@@QAEAAV0@P6AAAV0@AAV0@@Z@Z (MSVCRTI.@)
|
|
|
|
* class ostream & __thiscall ostream::operator<<(class ostream & (__cdecl*)(class ostream &))
|
|
|
|
*/
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCIRT_operator_sl_callback,8)
|
2015-07-04 16:24:37 +02:00
|
|
|
void * __thiscall MSVCIRT_operator_sl_callback(ostream * _this, ostream * (__cdecl*func)(ostream*))
|
2009-10-25 22:15:28 +01:00
|
|
|
{
|
|
|
|
TRACE("%p, %p\n", _this, func);
|
|
|
|
return func(_this);
|
|
|
|
}
|
|
|
|
|
2008-08-20 10:18:58 +02:00
|
|
|
/******************************************************************
|
|
|
|
* ?endl@@YAAAVostream@@AAV1@@Z (MSVCRTI.@)
|
|
|
|
* class ostream & __cdecl endl(class ostream &)
|
|
|
|
*/
|
2015-07-04 16:24:37 +02:00
|
|
|
void * CDECL MSVCIRT_endl(ostream * _this)
|
2008-08-20 10:18:58 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p)->() stub\n", _this);
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
2010-07-31 10:11:44 +02:00
|
|
|
/******************************************************************
|
|
|
|
* ?ends@@YAAAVostream@@AAV1@@Z (MSVCRTI.@)
|
|
|
|
* class ostream & __cdecl ends(class ostream &)
|
|
|
|
*/
|
2015-07-04 16:24:37 +02:00
|
|
|
void * CDECL MSVCIRT_ends(ostream * _this)
|
2010-07-31 10:11:44 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p)->() stub\n", _this);
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* ?str@strstreambuf@@QAEPADXZ (MSVCRTI.@)
|
|
|
|
* class strstreambuf & __thiscall strstreambuf::str(class strstreambuf &)
|
|
|
|
*/
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCIRT_str_sl_void,4)
|
2010-08-24 16:31:25 +02:00
|
|
|
char * __thiscall MSVCIRT_str_sl_void(class_strstreambuf * _this)
|
2010-07-31 10:11:44 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p)->() stub\n", _this);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-08 21:26:21 +02:00
|
|
|
#ifdef __i386__
|
|
|
|
|
|
|
|
#define DEFINE_VTBL_WRAPPER(off) \
|
|
|
|
__ASM_GLOBAL_FUNC(vtbl_wrapper_ ## off, \
|
|
|
|
"popl %eax\n\t" \
|
|
|
|
"popl %ecx\n\t" \
|
|
|
|
"pushl %eax\n\t" \
|
|
|
|
"movl 0(%ecx), %eax\n\t" \
|
|
|
|
"jmp *" #off "(%eax)\n\t")
|
|
|
|
|
|
|
|
DEFINE_VTBL_WRAPPER(0);
|
|
|
|
DEFINE_VTBL_WRAPPER(4);
|
|
|
|
DEFINE_VTBL_WRAPPER(8);
|
|
|
|
DEFINE_VTBL_WRAPPER(12);
|
|
|
|
DEFINE_VTBL_WRAPPER(16);
|
|
|
|
DEFINE_VTBL_WRAPPER(20);
|
|
|
|
DEFINE_VTBL_WRAPPER(24);
|
|
|
|
DEFINE_VTBL_WRAPPER(28);
|
|
|
|
DEFINE_VTBL_WRAPPER(32);
|
|
|
|
DEFINE_VTBL_WRAPPER(36);
|
|
|
|
DEFINE_VTBL_WRAPPER(40);
|
|
|
|
DEFINE_VTBL_WRAPPER(44);
|
|
|
|
DEFINE_VTBL_WRAPPER(48);
|
|
|
|
DEFINE_VTBL_WRAPPER(52);
|
|
|
|
DEFINE_VTBL_WRAPPER(56);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void* (__cdecl *MSVCRT_operator_new)(SIZE_T);
|
2015-05-26 13:08:39 +02:00
|
|
|
void (__cdecl *MSVCRT_operator_delete)(void*);
|
|
|
|
|
|
|
|
static void init_cxx_funcs(void)
|
|
|
|
{
|
|
|
|
HMODULE hmod = GetModuleHandleA("msvcrt.dll");
|
|
|
|
|
|
|
|
if (sizeof(void *) > sizeof(int)) /* 64-bit has different names */
|
|
|
|
{
|
2015-06-08 21:26:21 +02:00
|
|
|
MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2@YAPEAX_K@Z");
|
2015-05-26 13:08:39 +02:00
|
|
|
MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPEAX@Z");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-08 21:26:21 +02:00
|
|
|
MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2@YAPAXI@Z");
|
2015-05-26 13:08:39 +02:00
|
|
|
MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPAX@Z");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-03 21:10:23 +02:00
|
|
|
static void init_io(void *base)
|
|
|
|
{
|
|
|
|
#ifdef __x86_64__
|
|
|
|
init_streambuf_rtti(base);
|
2015-08-03 16:48:37 +02:00
|
|
|
init_filebuf_rtti(base);
|
2015-07-04 16:24:37 +02:00
|
|
|
init_ios_rtti(base);
|
2015-06-03 21:10:23 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-09-28 20:43:43 +02:00
|
|
|
BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
|
|
|
|
{
|
|
|
|
switch (reason)
|
|
|
|
{
|
|
|
|
case DLL_WINE_PREATTACH:
|
|
|
|
return FALSE; /* prefer native version */
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2015-05-26 13:08:39 +02:00
|
|
|
init_cxx_funcs();
|
|
|
|
init_exception(inst);
|
2015-06-03 21:10:23 +02:00
|
|
|
init_io(inst);
|
2007-09-28 20:43:43 +02:00
|
|
|
DisableThreadLibraryCalls( inst );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|