msvcp90: Added codecvt_base class implementation.
[wine] / dlls / msvcp90 / ios.c
1 /*
2  * Copyright 2011 Piotr Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <limits.h>
24
25 #include "msvcp90.h"
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(msvcp90);
30
31 typedef enum {
32     IOSTATE_goodbit   = 0x00,
33     IOSTATE_eofbit    = 0x01,
34     IOSTATE_failbit   = 0x02,
35     IOSTATE_badbit    = 0x04,
36     IOSTATE__Hardfail = 0x10,
37     IOSTATE_mask      = 0x17
38 } IOSB_iostate;
39
40 typedef enum {
41     FMTFLAG_skipws      = 0x0001,
42     FMTFLAG_unitbuf     = 0x0002,
43     FMTFLAG_uppercase   = 0x0004,
44     FMTFLAG_showbase    = 0x0008,
45     FMTFLAG_showpoint   = 0x0010,
46     FMTFLAG_showpos     = 0x0020,
47     FMTFLAG_left        = 0x0040,
48     FMTFLAG_right       = 0x0080,
49     FMTFLAG_internal    = 0x0100,
50     FMTFLAG_dec         = 0x0200,
51     FMTFLAG_oct         = 0x0400,
52     FMTFLAG_hex         = 0x0800,
53     FMTFLAG_scientific  = 0x1000,
54     FMTFLAG_fixed       = 0x2000,
55     FMTFLAG_hexfloat    = 0x3000,
56     FMTFLAG_boolalpha   = 0x4000,
57     FMTFLAG_stdio       = 0x8000,
58     FMTFLAG_adjustfield = FMTFLAG_left|FMTFLAG_right|FMTFLAG_internal,
59     FMTFLAG_basefield   = FMTFLAG_dec|FMTFLAG_oct|FMTFLAG_hex,
60     FMTFLAG_floadfield  = FMTFLAG_scientific|FMTFLAG_fixed,
61     FMTFLAG_mask        = 0xffff
62 } IOSB_fmtflags;
63
64 typedef enum {
65     OPENMODE_in         = 0x01,
66     OPENMODE_out        = 0x02,
67     OPENMODE_ate        = 0x04,
68     OPENMODE_app        = 0x08,
69     OPENMODE_trunc      = 0x10,
70     OPENMODE__Nocreate  = 0x40,
71     OPENMODE__Noreplace = 0x80,
72     OPENMODE_binray     = 0x20,
73     OPENMODE_mask       = 0xff
74 } IOSB_openmode;
75
76 typedef enum {
77     SEEKDIR_beg  = 0x1,
78     SEEKDIR_cur  = 0x2,
79     SEEKDIR_end  = 0x3,
80     SEEKDIR_mask = 0x3
81 } IOSB_seekdir;
82
83 typedef struct _iosarray {
84     struct _iosarray *next;
85     int index;
86     int long_val;
87     void *ptr_val;
88 } IOS_BASE_iosarray;
89
90 typedef enum {
91     EVENT_erase_event,
92     EVENT_imbue_event,
93     EVENT_copyfmt_event
94 } IOS_BASE_event;
95
96 struct _ios_base;
97 typedef void (CDECL *IOS_BASE_event_callback)(IOS_BASE_event, struct _ios_base*, int);
98 typedef struct _fnarray {
99     struct _fnarray *next;
100     int index;
101     IOS_BASE_event_callback event_handler;
102 } IOS_BASE_fnarray;
103
104 /* ?_Index@ios_base@std@@0HA */
105 int ios_base_Index = 0;
106 /* ?_Sync@ios_base@std@@0_NA */
107 MSVCP_bool ios_base_Sync = FALSE;
108
109 typedef struct _ios_base {
110     const vtable_ptr *vtable;
111     MSVCP_size_t stdstr;
112     IOSB_iostate state;
113     IOSB_iostate except;
114     IOSB_fmtflags fmtfl;
115     streamsize prec;
116     streamsize wide;
117     IOS_BASE_iosarray *arr;
118     IOS_BASE_fnarray *calls;
119     locale *loc;
120 } ios_base;
121
122 typedef struct {
123     streamoff off;
124     __int64 DECLSPEC_ALIGN(8) pos;
125     int state;
126 } fpos_int;
127
128 static inline const char* debugstr_fpos_int(fpos_int *fpos)
129 {
130     return wine_dbg_sprintf("fpos(%ld %s %d)", fpos->off, wine_dbgstr_longlong(fpos->pos), fpos->state);
131 }
132
133 typedef struct {
134     const vtable_ptr *vtable;
135     mutex lock;
136     char *rbuf;
137     char *wbuf;
138     char **prbuf;
139     char **pwbuf;
140     char *rpos;
141     char *wpos;
142     char **prpos;
143     char **pwpos;
144     int rsize;
145     int wsize;
146     int *prsize;
147     int *pwsize;
148     locale *loc;
149 } basic_streambuf_char;
150
151 typedef struct {
152     const vtable_ptr *vtable;
153     mutex lock;
154     wchar_t *rbuf;
155     wchar_t *wbuf;
156     wchar_t **prbuf;
157     wchar_t **pwbuf;
158     wchar_t *rpos;
159     wchar_t *wpos;
160     wchar_t **prpos;
161     wchar_t **pwpos;
162     int rsize;
163     int wsize;
164     int *prsize;
165     int *pwsize;
166     locale *loc;
167 } basic_streambuf_wchar;
168
169 typedef struct {
170     ios_base base;
171     basic_streambuf_char *strbuf;
172     struct _basic_ostream_char *stream;
173     char fillch;
174 } basic_ios_char;
175
176 typedef struct {
177     ios_base base;
178     basic_streambuf_wchar *strbuf;
179     struct _basic_ostream_wchar *stream;
180     wchar_t fillch;
181 } basic_ios_wchar;
182
183 typedef struct _basic_ostream_char {
184     const int *vbtable;
185     /* virtual inheritance
186      * basic_ios_char base;
187      */
188 } basic_ostream_char;
189
190 typedef struct _basic_ostream_wchar {
191     const int *vbtable;
192     /* virtual inheritance
193      * basic_ios_char base;
194      */
195 } basic_ostream_wchar;
196
197 typedef struct {
198     const int *vbtable;
199     streamsize count;
200     /* virtual inheritance
201      * basic_ios_char base;
202      */
203 } basic_istream_char;
204
205 extern const vtable_ptr MSVCP_iosb_vtable;
206
207 /* ??_7ios_base@std@@6B@ */
208 extern const vtable_ptr MSVCP_ios_base_vtable;
209
210 /* ??_7?$basic_ios@DU?$char_traits@D@std@@@std@@6B@ */
211 extern const vtable_ptr MSVCP_basic_ios_char_vtable;
212
213 /* ??_7?$basic_ios@_WU?$char_traits@_W@std@@@std@@6B@ */
214 extern const vtable_ptr MSVCP_basic_ios_wchar_vtable;
215
216 /* ??_7?$basic_ios@GU?$char_traits@G@std@@@std@@6B@ */
217 extern const vtable_ptr MSVCP_basic_ios_short_vtable;
218
219 /* ??_7?$basic_streambuf@DU?$char_traits@D@std@@@std@@6B@ */
220 extern const vtable_ptr MSVCP_basic_streambuf_char_vtable;
221
222 /* ??_7?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@6B@ */
223 extern const vtable_ptr MSVCP_basic_streambuf_wchar_vtable;
224
225 /* ??_7?$basic_streambuf@GU?$char_traits@G@std@@@std@@6B@ */
226 extern const vtable_ptr MSVCP_basic_streambuf_short_vtable;
227
228 /* ??_8?$basic_ostream@DU?$char_traits@D@std@@@std@@7B@ */
229 const int basic_ostream_char_vbtable[] = {0, sizeof(basic_ostream_char)};
230 /* ??_7?$basic_ostream@DU?$char_traits@D@std@@@std@@6B@ */
231 extern const vtable_ptr MSVCP_basic_ostream_char_vtable;
232
233 /* ??_8?$basic_istream@DU?$char_traits@D@std@@@std@@7B@ */
234 const int basic_istream_char_vbtable[] = {0, sizeof(basic_istream_char)};
235 /* ??_7?$basic_istream@DU?$char_traits@D@std@@@std@@6B@ */
236 extern const vtable_ptr MSVCP_basic_istream_char_vtable;
237
238 DEFINE_RTTI_DATA(iosb, 0, 0, NULL, NULL, NULL, ".?AV?$_Iosb@H@std@@");
239 DEFINE_RTTI_DATA(ios_base, 0, 1, &iosb_rtti_base_descriptor, NULL, NULL, ".?AV?$_Iosb@H@std@@");
240 DEFINE_RTTI_DATA(basic_ios_char, 0, 2, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
241         NULL, ".?AV?$basic_ios@DU?$char_traits@D@std@@@std@@");
242 DEFINE_RTTI_DATA(basic_ios_wchar, 0, 2, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
243         NULL, ".?AV?$basic_ios@_WU?$char_traits@_W@std@@@std@@");
244 DEFINE_RTTI_DATA(basic_ios_short, 0, 2, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
245         NULL, ".?AV?$basic_ios@GU?$char_traits@G@std@@@std@@");
246 DEFINE_RTTI_DATA(basic_streambuf_char, 0, 0, NULL, NULL, NULL,
247         ".?AV?$basic_streambuf@DU?$char_traits@D@std@@@std@@");
248 DEFINE_RTTI_DATA(basic_streambuf_wchar, 0, 0, NULL, NULL, NULL,
249         ".?AV?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@");
250 DEFINE_RTTI_DATA(basic_streambuf_short, 0, 0, NULL, NULL, NULL,
251         ".?AV?$basic_streambuf@GU?$char_traits@G@std@@@std@@");
252 DEFINE_RTTI_DATA(basic_ostream_char, sizeof(basic_ostream_char), 3, &basic_ios_char_rtti_base_descriptor,
253         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
254         ".?AV?$basic_ostream@DU?$char_traits@D@std@@@std@@");
255 DEFINE_RTTI_DATA(basic_istream_char, sizeof(basic_istream_char), 3, &basic_ios_char_rtti_base_descriptor,
256         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
257         ".?AV?$basic_istream@DU?$char_traits@D@std@@@std@@");
258
259 #ifndef __GNUC__
260 void __asm_dummy_vtables(void) {
261 #endif
262     __ASM_VTABLE(iosb, "");
263     __ASM_VTABLE(ios_base, "");
264     __ASM_VTABLE(basic_ios_char, "");
265     __ASM_VTABLE(basic_ios_wchar, "");
266     __ASM_VTABLE(basic_ios_short, "");
267     __ASM_VTABLE(basic_streambuf_char,
268             VTABLE_ADD_FUNC(basic_streambuf_char_overflow)
269             VTABLE_ADD_FUNC(basic_streambuf_char_pbackfail)
270             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
271             VTABLE_ADD_FUNC(basic_streambuf_char_underflow)
272             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
273             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
274             VTABLE_ADD_FUNC(basic_streambuf_char__Xsgetn_s)
275             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
276             VTABLE_ADD_FUNC(basic_streambuf_char_seekoff)
277             VTABLE_ADD_FUNC(basic_streambuf_char_seekpos)
278             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
279             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
280             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
281     __ASM_VTABLE(basic_streambuf_wchar,
282             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
283             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
284             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
285             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
286             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
287             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
288             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
289             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
290             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
291             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
292             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
293             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
294             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
295     __ASM_VTABLE(basic_streambuf_short,
296             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
297             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
298             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
299             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
300             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
301             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
302             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
303             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
304             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
305             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
306             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
307             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
308             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
309     __ASM_VTABLE(basic_ostream_char, "");
310     __ASM_VTABLE(basic_istream_char, "");
311 #ifndef __GNUC__
312 }
313 #endif
314
315 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
316 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
317 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp_next, 16)
318 void __thiscall basic_streambuf_char_setp_next(basic_streambuf_char *this, char *first, char *next, char *last)
319 {
320     TRACE("(%p %p %p %p)\n", this, first, next, last);
321
322     this->wbuf = first;
323     this->wpos = next;
324     this->wsize = last-next;
325 }
326
327 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD0@Z */
328 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD0@Z */
329 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp, 12)
330 void __thiscall basic_streambuf_char_setp(basic_streambuf_char *this, char *first, char *last)
331 {
332     basic_streambuf_char_setp_next(this, first, first, last);
333 }
334
335 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
336 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
337 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setg, 16)
338 void __thiscall basic_streambuf_char_setg(basic_streambuf_char *this, char *first, char *next, char *last)
339 {
340     TRACE("(%p %p %p %p)\n", this, first, next, last);
341
342     this->rbuf = first;
343     this->rpos = next;
344     this->rsize = last-next;
345 }
346
347 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXXZ */
348 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXXZ */
349 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init_empty, 4)
350 void __thiscall basic_streambuf_char__Init_empty(basic_streambuf_char *this)
351 {
352     TRACE("(%p)\n", this);
353
354     this->prbuf = &this->rbuf;
355     this->pwbuf = &this->wbuf;
356     this->prpos = &this->rpos;
357     this->pwpos = &this->wpos;
358     this->prsize = &this->rsize;
359     this->pwsize = &this->wsize;
360
361     basic_streambuf_char_setp(this, NULL, NULL);
362     basic_streambuf_char_setg(this, NULL, NULL, NULL);
363 }
364
365 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@W4_Uninitialized@1@@Z */
366 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
367 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor_uninitialized, 8)
368 basic_streambuf_char* __thiscall basic_streambuf_char_ctor_uninitialized(basic_streambuf_char *this, int uninitialized)
369 {
370     TRACE("(%p %d)\n", this, uninitialized);
371     this->vtable = &MSVCP_basic_streambuf_char_vtable;
372     mutex_ctor(&this->lock);
373     return this;
374 }
375
376 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ */
377 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@XZ */
378 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor, 4)
379 basic_streambuf_char* __thiscall basic_streambuf_char_ctor(basic_streambuf_char *this)
380 {
381     TRACE("(%p)\n", this);
382
383     this->vtable = &MSVCP_basic_streambuf_char_vtable;
384     mutex_ctor(&this->lock);
385     this->loc = MSVCRT_operator_new(sizeof(locale));
386     locale_ctor(this->loc);
387     basic_streambuf_char__Init_empty(this);
388
389     return this;
390 }
391
392 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
393 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
394 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_dtor, 4)
395 void __thiscall basic_streambuf_char_dtor(basic_streambuf_char *this)
396 {
397     TRACE("(%p)\n", this);
398
399     mutex_dtor(&this->lock);
400     locale_dtor(this->loc);
401     MSVCRT_operator_delete(this->loc);
402 }
403
404 DEFINE_THISCALL_WRAPPER(MSVCP_basic_streambuf_char_vector_dtor, 8)
405 basic_streambuf_char* __thiscall MSVCP_basic_streambuf_char_vector_dtor(basic_streambuf_char *this, unsigned int flags)
406 {
407     TRACE("(%p %x)\n", this, flags);
408     if(flags & 2) {
409         /* we have an array, with the number of elements stored before the first object */
410         int i, *ptr = (int *)this-1;
411
412         for(i=*ptr-1; i>=0; i--)
413             basic_streambuf_char_dtor(this+i);
414         MSVCRT_operator_delete(ptr);
415     } else {
416         basic_streambuf_char_dtor(this);
417         if(flags & 1)
418             MSVCRT_operator_delete(this);
419     }
420
421     return this;
422 }
423
424 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
425 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
426 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gnavail, 4)
427 streamsize __thiscall basic_streambuf_char__Gnavail(const basic_streambuf_char *this)
428 {
429     TRACE("(%p)\n", this);
430     return *this->prpos ? *this->prsize : 0;
431 }
432
433 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
434 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
435 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gndec, 4)
436 char* __thiscall basic_streambuf_char__Gndec(basic_streambuf_char *this)
437 {
438     TRACE("(%p)\n", this);
439     (*this->prsize)++;
440     (*this->prpos)--;
441     return *this->prpos;
442 }
443
444 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
445 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
446 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gninc, 4)
447 char* __thiscall basic_streambuf_char__Gninc(basic_streambuf_char *this)
448 {
449     TRACE("(%p)\n", this);
450     (*this->prsize)--;
451     return (*this->prpos)++;
452 }
453
454 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
455 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
456 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gnpreinc, 4)
457 char* __thiscall basic_streambuf_char__Gnpreinc(basic_streambuf_char *this)
458 {
459     TRACE("(%p)\n", this);
460     (*this->prsize)--;
461     (*this->prpos)++;
462     return *this->prpos;
463 }
464
465 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAPAD0PAH001@Z */
466 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAPEAD0PEAH001@Z */
467 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init, 28)
468 void __thiscall basic_streambuf_char__Init(basic_streambuf_char *this, char **gf, char **gn, int *gc, char **pf, char **pn, int *pc)
469 {
470     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
471
472     this->prbuf = gf;
473     this->pwbuf = pf;
474     this->prpos = gn;
475     this->pwpos = pn;
476     this->prsize = gc;
477     this->pwsize = pc;
478 }
479
480 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
481 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
482 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Lock, 4)
483 void __thiscall basic_streambuf_char__Lock(basic_streambuf_char *this)
484 {
485     TRACE("(%p)\n", this);
486     mutex_lock(&this->lock);
487 }
488
489 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
490 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
491 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pnavail, 4)
492 streamsize __thiscall basic_streambuf_char__Pnavail(const basic_streambuf_char *this)
493 {
494     TRACE("(%p)\n", this);
495     return *this->pwpos ? *this->pwsize : 0;
496 }
497
498 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
499 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
500 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pninc, 4)
501 char* __thiscall basic_streambuf_char__Pninc(basic_streambuf_char *this)
502 {
503     TRACE("(%p)\n", this);
504     (*this->pwsize)--;
505     return (*this->pwpos)++;
506 }
507
508 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
509 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
510 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_underflow, 4)
511 #define call_basic_streambuf_char_underflow(this) CALL_VTBL_FUNC(this, 16, \
512         int, (basic_streambuf_char*), (this))
513 int __thiscall basic_streambuf_char_underflow(basic_streambuf_char *this)
514 {
515     TRACE("(%p)\n", this);
516     return EOF;
517 }
518
519 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
520 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
521 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_uflow, 4)
522 #define call_basic_streambuf_char_uflow(this) CALL_VTBL_FUNC(this, 20, \
523         int, (basic_streambuf_char*), (this))
524 int __thiscall basic_streambuf_char_uflow(basic_streambuf_char *this)
525 {
526     int ret;
527
528     TRACE("(%p)\n", this);
529
530     if(call_basic_streambuf_char_underflow(this)==EOF)
531         return EOF;
532
533     ret = **this->prpos;
534     (*this->prsize)--;
535     (*this->prpos)++;
536     return ret;
537 }
538
539 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADIH@Z */
540 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_K_J@Z */
541 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Xsgetn_s, 16)
542 #define call_basic_streambuf_char__Xsgetn_s(this, ptr, size, count) CALL_VTBL_FUNC(this, 28, \
543         streamsize, (basic_streambuf_char*, char*, MSVCP_size_t, streamsize), (this, ptr, size, count))
544 streamsize __thiscall basic_streambuf_char__Xsgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
545 {
546     streamsize copied, chunk;
547
548     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
549
550     for(copied=0; copied<count && size;) {
551         chunk = basic_streambuf_char__Gnavail(this);
552         if(chunk > count-copied)
553             chunk = count-copied;
554
555         if(chunk) {
556             memcpy_s(ptr+copied, size, *this->prpos, chunk);
557             *this->prpos += chunk;
558             *this->prsize -= chunk;
559             copied += chunk;
560             size -= chunk;
561         }else if((ptr[copied] = call_basic_streambuf_char_uflow(this)) != EOF) {
562             copied++;
563             size--;
564         }else {
565             break;
566         }
567     }
568
569     return copied;
570 }
571
572 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
573 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
574 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Sgetn_s, 16)
575 streamsize __thiscall basic_streambuf_char__Sgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
576 {
577     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
578     return call_basic_streambuf_char__Xsgetn_s(this, ptr, size, count);
579 }
580
581 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
582 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
583 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Unlock, 4)
584 void __thiscall basic_streambuf_char__Unlock(basic_streambuf_char *this)
585 {
586     TRACE("(%p)\n", this);
587     mutex_unlock(&this->lock);
588 }
589
590 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
591 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
592 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_eback, 4)
593 char* __thiscall basic_streambuf_char_eback(const basic_streambuf_char *this)
594 {
595     TRACE("(%p)\n", this);
596     return *this->prbuf;
597 }
598
599 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
600 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
601 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gptr, 4)
602 char* __thiscall basic_streambuf_char_gptr(const basic_streambuf_char *this)
603 {
604     TRACE("(%p)\n", this);
605     return *this->prpos;
606 }
607
608 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
609 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
610 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_egptr, 4)
611 char* __thiscall basic_streambuf_char_egptr(const basic_streambuf_char *this)
612 {
613     TRACE("(%p)\n", this);
614     return *this->prpos+*this->prsize;
615 }
616
617 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
618 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
619 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_epptr, 4)
620 char* __thiscall basic_streambuf_char_epptr(const basic_streambuf_char *this)
621 {
622     TRACE("(%p)\n", this);
623     return *this->pwpos+*this->pwsize;
624 }
625
626 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
627 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
628 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gbump, 8)
629 void __thiscall basic_streambuf_char_gbump(basic_streambuf_char *this, int off)
630 {
631     TRACE("(%p %d)\n", this, off);
632     *this->prpos += off;
633     *this->prsize -= off;
634 }
635
636 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QBE?AVlocale@2@XZ */
637 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEBA?AVlocale@2@XZ */
638 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_getloc, 8)
639 locale* __thiscall basic_streambuf_char_getloc(const basic_streambuf_char *this, locale *ret)
640 {
641     TRACE("(%p)\n", this);
642     return locale_copy_ctor(ret, this->loc);
643 }
644
645 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
646 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
647 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_imbue, 8)
648 #define call_basic_streambuf_char_imbue(this, loc) CALL_VTBL_FUNC(this, 52, \
649         void, (basic_streambuf_char*, const locale*), (this, loc))
650 void __thiscall basic_streambuf_char_imbue(basic_streambuf_char *this, const locale *loc)
651 {
652     TRACE("(%p %p)\n", this, loc);
653 }
654
655 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
656 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
657 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_overflow, 8)
658 #define call_basic_streambuf_char_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
659         int, (basic_streambuf_char*, int), (this, ch))
660 int __thiscall basic_streambuf_char_overflow(basic_streambuf_char *this, int ch)
661 {
662     TRACE("(%p %d)\n", this, ch);
663     return EOF;
664 }
665
666 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
667 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
668 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbackfail, 8)
669 #define call_basic_streambuf_char_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
670         int, (basic_streambuf_char*, int), (this, ch))
671 int __thiscall basic_streambuf_char_pbackfail(basic_streambuf_char *this, int ch)
672 {
673     TRACE("(%p %d)\n", this, ch);
674     return EOF;
675 }
676
677 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
678 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
679 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbase, 4)
680 char* __thiscall basic_streambuf_char_pbase(const basic_streambuf_char *this)
681 {
682     TRACE("(%p)\n", this);
683     return *this->pwbuf;
684 }
685
686 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
687 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
688 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbump, 8)
689 void __thiscall basic_streambuf_char_pbump(basic_streambuf_char *this, int off)
690 {
691     TRACE("(%p %d)\n", this, off);
692     *this->pwpos += off;
693     *this->pwsize -= off;
694 }
695
696 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
697 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
698 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pptr, 4)
699 char* __thiscall basic_streambuf_char_pptr(const basic_streambuf_char *this)
700 {
701     TRACE("(%p)\n", this);
702     return *this->pwpos;
703 }
704
705 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
706 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
707 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubimbue, 12)
708 locale* __thiscall basic_streambuf_char_pubimbue(basic_streambuf_char *this, locale *ret, const locale *loc)
709 {
710     TRACE("(%p %p)\n", this, loc);
711     memcpy(ret, this->loc, sizeof(locale));
712     call_basic_streambuf_char_imbue(this, loc);
713     locale_copy_ctor(this->loc, loc);
714     return ret;
715 }
716
717 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
718 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
719 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekoff, 20)
720 #define call_basic_streambuf_char_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 36, \
721         fpos_int*, (basic_streambuf_char*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
722 fpos_int* __thiscall basic_streambuf_char_seekoff(basic_streambuf_char *this,
723         fpos_int *ret, streamoff off, int way, int mode)
724 {
725     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
726     ret->off = 0;
727     ret->pos = -1;
728     ret->state = 0;
729     return ret;
730 }
731
732 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
733 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
734 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff, 20)
735 fpos_int* __thiscall basic_streambuf_char_pubseekoff(basic_streambuf_char *this,
736         fpos_int *ret, streamoff off, int way, int mode)
737 {
738     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
739     return call_basic_streambuf_char_seekoff(this, ret, off, way, mode);
740 }
741
742 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
743 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
744 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff_old, 20)
745 fpos_int* __thiscall basic_streambuf_char_pubseekoff_old(basic_streambuf_char *this,
746         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
747 {
748     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
749     return basic_streambuf_char_pubseekoff(this, ret, off, way, mode);
750 }
751
752 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
753 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
754 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekpos, 36)
755 #define call_basic_streambuf_char_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 40, \
756         fpos_int*, (basic_streambuf_char*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
757 fpos_int* __thiscall basic_streambuf_char_seekpos(basic_streambuf_char *this,
758         fpos_int *ret, fpos_int pos, int mode)
759 {
760     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
761     ret->off = 0;
762     ret->pos = -1;
763     ret->state = 0;
764     return ret;
765 }
766
767 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
768 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
769 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos, 36)
770 fpos_int* __thiscall basic_streambuf_char_pubseekpos(basic_streambuf_char *this,
771         fpos_int *ret, fpos_int pos, int mode)
772 {
773     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
774     return call_basic_streambuf_char_seekpos(this, ret, pos, mode);
775 }
776
777 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
778 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
779 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos_old, 36)
780 fpos_int* __thiscall basic_streambuf_char_pubseekpos_old(basic_streambuf_char *this,
781         fpos_int *ret, fpos_int pos, unsigned int mode)
782 {
783     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
784     return basic_streambuf_char_pubseekpos(this, ret, pos, mode);
785 }
786
787 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEPAV12@PADH@Z */
788 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAPEAV12@PEAD_J@Z */
789 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setbuf, 12)
790 #define call_basic_streambuf_char_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 44, \
791         basic_streambuf_char*, (basic_streambuf_char*, char*, streamsize), (this, buf, count))
792 basic_streambuf_char* __thiscall basic_streambuf_char_setbuf(basic_streambuf_char *this, char *buf, streamsize count)
793 {
794     TRACE("(%p %p %ld)\n", this, buf, count);
795     return this;
796 }
797
798 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PADH@Z */
799 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEAD_J@Z */
800 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsetbuf, 12)
801 basic_streambuf_char* __thiscall basic_streambuf_char_pubsetbuf(basic_streambuf_char *this, char *buf, streamsize count)
802 {
803     TRACE("(%p %p %ld)\n", this, buf, count);
804     return call_basic_streambuf_char_setbuf(this, buf, count);
805 }
806
807 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
808 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
809 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sync, 4)
810 #define call_basic_streambuf_char_sync(this) CALL_VTBL_FUNC(this, 48, \
811         int, (basic_streambuf_char*), (this))
812 int __thiscall basic_streambuf_char_sync(basic_streambuf_char *this)
813 {
814     TRACE("(%p)\n", this);
815     return 0;
816 }
817
818 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
819 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
820 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsync, 4)
821 int __thiscall basic_streambuf_char_pubsync(basic_streambuf_char *this)
822 {
823     TRACE("(%p)\n", this);
824     return call_basic_streambuf_char_sync(this);
825 }
826
827 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
828 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
829 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetn, 12)
830 streamsize __thiscall basic_streambuf_char_sgetn(basic_streambuf_char *this, char *ptr, streamsize count)
831 {
832     TRACE("(%p %p %ld)\n", this, ptr, count);
833     return call_basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
834 }
835
836 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
837 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JXZ */
838 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_showmanyc, 4)
839 #define call_basic_streambuf_char_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
840         streamsize, (basic_streambuf_char*), (this))
841 streamsize __thiscall basic_streambuf_char_showmanyc(basic_streambuf_char *this)
842 {
843     TRACE("(%p)\n", this);
844     return 0;
845 }
846
847 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
848 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JXZ */
849 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_in_avail, 4)
850 streamsize __thiscall basic_streambuf_char_in_avail(basic_streambuf_char *this)
851 {
852     streamsize ret;
853
854     TRACE("(%p)\n", this);
855
856     ret = basic_streambuf_char__Gnavail(this);
857     return ret ? ret : call_basic_streambuf_char_showmanyc(this);
858 }
859
860 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
861 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
862 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputbackc, 8)
863 int __thiscall basic_streambuf_char_sputbackc(basic_streambuf_char *this, char ch)
864 {
865     TRACE("(%p %d)\n", this, ch);
866     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
867         (*this->prsize)++;
868         (*this->prpos)--;
869         return ch;
870     }
871
872     return call_basic_streambuf_char_pbackfail(this, ch);
873 }
874
875 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
876 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
877 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputc, 8)
878 int __thiscall basic_streambuf_char_sputc(basic_streambuf_char *this, char ch)
879 {
880     TRACE("(%p %d)\n", this, ch);
881     return basic_streambuf_char__Pnavail(this) ?
882         (*basic_streambuf_char__Pninc(this) = ch) :
883         call_basic_streambuf_char_overflow(this, ch);
884 }
885
886 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
887 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
888 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sungetc, 4)
889 int __thiscall basic_streambuf_char_sungetc(basic_streambuf_char *this)
890 {
891     TRACE("(%p)\n", this);
892     if(*this->prpos && *this->prpos>*this->prbuf) {
893         (*this->prsize)++;
894         (*this->prpos)--;
895         return **this->prpos;
896     }
897
898     return call_basic_streambuf_char_pbackfail(this, EOF);
899 }
900
901 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
902 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
903 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_stossc, 4)
904 void __thiscall basic_streambuf_char_stossc(basic_streambuf_char *this)
905 {
906     TRACE("(%p)\n", this);
907     if(basic_streambuf_char__Gnavail(this))
908         basic_streambuf_char__Gninc(this);
909     else
910         call_basic_streambuf_char_uflow(this);
911 }
912
913 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
914 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
915 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sbumpc, 4)
916 int __thiscall basic_streambuf_char_sbumpc(basic_streambuf_char *this)
917 {
918     TRACE("(%p)\n", this);
919     return basic_streambuf_char__Gnavail(this) ?
920         *basic_streambuf_char__Gninc(this) : call_basic_streambuf_char_uflow(this);
921 }
922
923 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
924 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
925 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetc, 4)
926 int __thiscall basic_streambuf_char_sgetc(basic_streambuf_char *this)
927 {
928     TRACE("(%p)\n", this);
929     return basic_streambuf_char__Gnavail(this) ?
930         *basic_streambuf_char_gptr(this) : call_basic_streambuf_char_underflow(this);
931 }
932
933 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
934 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
935 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_snextc, 4)
936 int __thiscall basic_streambuf_char_snextc(basic_streambuf_char *this)
937 {
938     TRACE("(%p)\n", this);
939
940     if(basic_streambuf_char__Gnavail(this) > 1)
941         return *basic_streambuf_char__Gnpreinc(this);
942     return basic_streambuf_char_sbumpc(this)==EOF ?
943         EOF : basic_streambuf_char_sgetc(this);
944 }
945
946 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADH@Z */
947 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_J@Z */
948 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsgetn, 12)
949 #define call_basic_streambuf_char_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
950         streamsize, (basic_streambuf_char*, char*, streamsize), (this, ptr, count))
951 streamsize __thiscall basic_streambuf_char_xsgetn(basic_streambuf_char *this, char *ptr, streamsize count)
952 {
953     TRACE("(%p %p %ld)\n", this, ptr, count);
954     return call_basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
955 }
956
957 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPBDH@Z */
958 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEBD_J@Z */
959 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsputn, 12)
960 #define call_basic_streambuf_char_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 32, \
961         streamsize, (basic_streambuf_char*, const char*, streamsize), (this, ptr, count))
962 streamsize __thiscall basic_streambuf_char_xsputn(basic_streambuf_char *this, const char *ptr, streamsize count)
963 {
964     streamsize copied, chunk;
965
966     TRACE("(%p %p %ld)\n", this, ptr, count);
967
968     for(copied=0; copied<count;) {
969         chunk = basic_streambuf_char__Pnavail(this);
970         if(chunk > count-copied)
971             chunk = count-copied;
972
973         if(chunk) {
974             memcpy(*this->pwpos, ptr+copied, chunk);
975             *this->pwpos += chunk;
976             *this->pwsize -= chunk;
977             copied += chunk;
978         }else if(call_basic_streambuf_char_overflow(this, ptr[copied]) != EOF) {
979             copied++;
980         }else {
981             break;
982         }
983     }
984
985     return copied;
986 }
987
988 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z */
989 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z */
990 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputn, 12)
991 streamsize __thiscall basic_streambuf_char_sputn(basic_streambuf_char *this, const char *ptr, streamsize count)
992 {
993     TRACE("(%p %p %ld)\n", this, ptr, count);
994     return call_basic_streambuf_char_xsputn(this, ptr, count);
995 }
996
997 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
998 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
999 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1000 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1001 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp_next, 16)
1002 void __thiscall basic_streambuf_wchar_setp_next(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1003 {
1004     TRACE("(%p %p %p %p)\n", this, first, next, last);
1005
1006     this->wbuf = first;
1007     this->wpos = next;
1008     this->wsize = last-next;
1009 }
1010
1011 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W0@Z */
1012 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W0@Z */
1013 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG0@Z */
1014 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG0@Z */
1015 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp, 12)
1016 void __thiscall basic_streambuf_wchar_setp(basic_streambuf_wchar *this, wchar_t *first, wchar_t *last)
1017 {
1018     basic_streambuf_wchar_setp_next(this, first, first, last);
1019 }
1020
1021 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1022 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1023 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1024 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1025 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setg, 16)
1026 void __thiscall basic_streambuf_wchar_setg(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1027 {
1028     TRACE("(%p %p %p %p)\n", this, first, next, last);
1029
1030     this->rbuf = first;
1031     this->rpos = next;
1032     this->rsize = last-next;
1033 }
1034
1035 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXXZ */
1036 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXXZ */
1037 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXXZ */
1038 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXXZ */
1039 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init_empty, 4)
1040 void __thiscall basic_streambuf_wchar__Init_empty(basic_streambuf_wchar *this)
1041 {
1042     TRACE("(%p)\n", this);
1043
1044     this->prbuf = &this->rbuf;
1045     this->pwbuf = &this->wbuf;
1046     this->prpos = &this->rpos;
1047     this->pwpos = &this->wpos;
1048     this->prsize = &this->rsize;
1049     this->pwsize = &this->wsize;
1050
1051     basic_streambuf_wchar_setp(this, NULL, NULL);
1052     basic_streambuf_wchar_setg(this, NULL, NULL, NULL);
1053 }
1054
1055 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1056 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1057 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor_uninitialized, 8)
1058 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1059 {
1060     TRACE("(%p %d)\n", this, uninitialized);
1061     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1062     mutex_ctor(&this->lock);
1063     return this;
1064 }
1065
1066 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1067 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1068 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor_uninitialized, 8)
1069 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1070 {
1071     TRACE("(%p %d)\n", this, uninitialized);
1072     basic_streambuf_wchar_ctor_uninitialized(this, uninitialized);
1073     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1074     return this;
1075 }
1076
1077 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
1078 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
1079 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor, 4)
1080 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor(basic_streambuf_wchar *this)
1081 {
1082     TRACE("(%p)\n", this);
1083
1084     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1085     mutex_ctor(&this->lock);
1086     this->loc = MSVCRT_operator_new(sizeof(locale));
1087     locale_ctor(this->loc);
1088     basic_streambuf_wchar__Init_empty(this);
1089
1090     return this;
1091 }
1092
1093 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@XZ */
1094 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@XZ */
1095 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor, 4)
1096 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor(basic_streambuf_wchar *this)
1097 {
1098     TRACE("(%p)\n", this);
1099     basic_streambuf_wchar_ctor(this);
1100     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1101     return this;
1102 }
1103
1104 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
1105 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
1106 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
1107 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
1108 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_dtor, 4)
1109 void __thiscall basic_streambuf_wchar_dtor(basic_streambuf_wchar *this)
1110 {
1111     TRACE("(%p)\n", this);
1112
1113     mutex_dtor(&this->lock);
1114     locale_dtor(this->loc);
1115     MSVCRT_operator_delete(this->loc);
1116 }
1117
1118 DEFINE_THISCALL_WRAPPER(MSVCP_basic_streambuf_wchar_vector_dtor, 8)
1119 basic_streambuf_wchar* __thiscall MSVCP_basic_streambuf_wchar_vector_dtor(basic_streambuf_wchar *this, unsigned int flags)
1120 {
1121     TRACE("(%p %x)\n", this, flags);
1122     if(flags & 2) {
1123         /* we have an array, with the number of elements stored before the first object */
1124         int i, *ptr = (int *)this-1;
1125
1126         for(i=*ptr-1; i>=0; i--)
1127             basic_streambuf_wchar_dtor(this+i);
1128         MSVCRT_operator_delete(ptr);
1129     } else {
1130         basic_streambuf_wchar_dtor(this);
1131         if(flags & 1)
1132             MSVCRT_operator_delete(this);
1133     }
1134
1135     return this;
1136 }
1137
1138 DEFINE_THISCALL_WRAPPER(MSVCP_basic_streambuf_short_vector_dtor, 8)
1139 basic_streambuf_wchar* __thiscall MSVCP_basic_streambuf_short_vector_dtor(basic_streambuf_wchar *this, unsigned int flags)
1140 {
1141     TRACE("(%p %x)\n", this, flags);
1142     return MSVCP_basic_streambuf_wchar_vector_dtor(this, flags);
1143 }
1144
1145 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1146 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1147 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1148 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1149 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gnavail, 4)
1150 streamsize __thiscall basic_streambuf_wchar__Gnavail(const basic_streambuf_wchar *this)
1151 {
1152     TRACE("(%p)\n", this);
1153     return *this->prpos ? *this->prsize : 0;
1154 }
1155
1156 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1157 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1158 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1159 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1160 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gndec, 4)
1161 wchar_t* __thiscall basic_streambuf_wchar__Gndec(basic_streambuf_wchar *this)
1162 {
1163     TRACE("(%p)\n", this);
1164     (*this->prsize)++;
1165     (*this->prpos)--;
1166     return *this->prpos;
1167 }
1168
1169 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1170 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1171 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1172 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1173 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gninc, 4)
1174 wchar_t* __thiscall basic_streambuf_wchar__Gninc(basic_streambuf_wchar *this)
1175 {
1176     TRACE("(%p)\n", this);
1177     (*this->prsize)--;
1178     return (*this->prpos)++;
1179 }
1180
1181 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1182 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1183 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1184 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1185 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gnpreinc, 4)
1186 wchar_t* __thiscall basic_streambuf_wchar__Gnpreinc(basic_streambuf_wchar *this)
1187 {
1188     TRACE("(%p)\n", this);
1189     (*this->prsize)--;
1190     (*this->prpos)++;
1191     return *this->prpos;
1192 }
1193
1194 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPAPA_W0PAH001@Z */
1195 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAPEA_W0PEAH001@Z */
1196 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAPAG0PAH001@Z */
1197 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAPEAG0PEAH001@Z */
1198 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init, 28)
1199 void __thiscall basic_streambuf_wchar__Init(basic_streambuf_wchar *this, wchar_t **gf, wchar_t **gn, int *gc, wchar_t **pf, wchar_t **pn, int *pc)
1200 {
1201     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1202
1203     this->prbuf = gf;
1204     this->pwbuf = pf;
1205     this->prpos = gn;
1206     this->pwpos = pn;
1207     this->prsize = gc;
1208     this->pwsize = pc;
1209 }
1210
1211 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1212 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1213 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1214 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1215 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Lock, 4)
1216 void __thiscall basic_streambuf_wchar__Lock(basic_streambuf_wchar *this)
1217 {
1218     TRACE("(%p)\n", this);
1219     mutex_lock(&this->lock);
1220 }
1221
1222 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1223 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1224 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1225 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1226 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pnavail, 4)
1227 streamsize __thiscall basic_streambuf_wchar__Pnavail(const basic_streambuf_wchar *this)
1228 {
1229     TRACE("(%p)\n", this);
1230     return *this->pwpos ? *this->pwsize : 0;
1231 }
1232
1233 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1234 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1235 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1236 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1237 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pninc, 4)
1238 wchar_t* __thiscall basic_streambuf_wchar__Pninc(basic_streambuf_wchar *this)
1239 {
1240     TRACE("(%p)\n", this);
1241     (*this->pwsize)--;
1242     return (*this->pwpos)++;
1243 }
1244
1245 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1246 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1247 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1248 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1249 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_underflow, 4)
1250 #define call_basic_streambuf_wchar_underflow(this) CALL_VTBL_FUNC(this, 16, \
1251         unsigned short, (basic_streambuf_wchar*), (this))
1252 unsigned short __thiscall basic_streambuf_wchar_underflow(basic_streambuf_wchar *this)
1253 {
1254     TRACE("(%p)\n", this);
1255     return WEOF;
1256 }
1257
1258 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1259 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1260 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1261 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1262 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_uflow, 4)
1263 #define call_basic_streambuf_wchar_uflow(this) CALL_VTBL_FUNC(this, 20, \
1264         unsigned short, (basic_streambuf_wchar*), (this))
1265 unsigned short __thiscall basic_streambuf_wchar_uflow(basic_streambuf_wchar *this)
1266 {
1267     int ret;
1268
1269     TRACE("(%p)\n", this);
1270
1271     if(call_basic_streambuf_wchar_underflow(this)==WEOF)
1272         return WEOF;
1273
1274     ret = **this->prpos;
1275     (*this->prsize)--;
1276     (*this->prpos)++;
1277     return ret;
1278 }
1279
1280 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WIH@Z */
1281 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_K_J@Z */
1282 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGIH@Z */
1283 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_K_J@Z */
1284 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Xsgetn_s, 16)
1285 #define call_basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count) CALL_VTBL_FUNC(this, 28, \
1286         streamsize, (basic_streambuf_wchar*, wchar_t*, MSVCP_size_t, streamsize), (this, ptr, size, count))
1287 streamsize __thiscall basic_streambuf_wchar__Xsgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1288 {
1289     streamsize copied, chunk;
1290
1291     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1292
1293     for(copied=0; copied<count && size;) {
1294         chunk = basic_streambuf_wchar__Gnavail(this);
1295         if(chunk > count-copied)
1296             chunk = count-copied;
1297
1298         if(chunk) {
1299             memcpy_s(ptr+copied, size, *this->prpos, chunk);
1300             *this->prpos += chunk;
1301             *this->prsize -= chunk;
1302             copied += chunk;
1303             size -= chunk;
1304         }else if((ptr[copied] = call_basic_streambuf_wchar_uflow(this)) != WEOF) {
1305             copied++;
1306             size--;
1307         }else {
1308             break;
1309         }
1310     }
1311
1312     return copied;
1313 }
1314
1315 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
1316 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
1317 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
1318 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
1319 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Sgetn_s, 16)
1320 streamsize __thiscall basic_streambuf_wchar__Sgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1321 {
1322     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1323     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count);
1324 }
1325
1326 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1327 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1328 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1329 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1330 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Unlock, 4)
1331 void __thiscall basic_streambuf_wchar__Unlock(basic_streambuf_wchar *this)
1332 {
1333     TRACE("(%p)\n", this);
1334     mutex_unlock(&this->lock);
1335 }
1336
1337 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1338 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1339 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1340 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1341 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_eback, 4)
1342 wchar_t* __thiscall basic_streambuf_wchar_eback(const basic_streambuf_wchar *this)
1343 {
1344     TRACE("(%p)\n", this);
1345     return *this->prbuf;
1346 }
1347
1348 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1349 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1350 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1351 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1352 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gptr, 4)
1353 wchar_t* __thiscall basic_streambuf_wchar_gptr(const basic_streambuf_wchar *this)
1354 {
1355     TRACE("(%p)\n", this);
1356     return *this->prpos;
1357 }
1358
1359 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1360 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1361 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1362 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1363 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_egptr, 4)
1364 wchar_t* __thiscall basic_streambuf_wchar_egptr(const basic_streambuf_wchar *this)
1365 {
1366     TRACE("(%p)\n", this);
1367     return *this->prpos+*this->prsize;
1368 }
1369
1370 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1371 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1372 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1373 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1374 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_epptr, 4)
1375 wchar_t* __thiscall basic_streambuf_wchar_epptr(const basic_streambuf_wchar *this)
1376 {
1377     TRACE("(%p)\n", this);
1378     return *this->pwpos+*this->pwsize;
1379 }
1380
1381 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1382 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1383 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1384 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1385 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gbump, 8)
1386 void __thiscall basic_streambuf_wchar_gbump(basic_streambuf_wchar *this, int off)
1387 {
1388     TRACE("(%p %d)\n", this, off);
1389     *this->prpos += off;
1390     *this->prsize -= off;
1391 }
1392
1393 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QBE?AVlocale@2@XZ */
1394 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEBA?AVlocale@2@XZ */
1395 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QBE?AVlocale@2@XZ */
1396 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEBA?AVlocale@2@XZ */
1397 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_getloc, 8)
1398 locale* __thiscall basic_streambuf_wchar_getloc(const basic_streambuf_wchar *this, locale *ret)
1399 {
1400     TRACE("(%p)\n", this);
1401     return locale_copy_ctor(ret, this->loc);
1402 }
1403
1404 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
1405 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
1406 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
1407 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
1408 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_imbue, 8)
1409 #define call_basic_streambuf_wchar_imbue(this, loc) CALL_VTBL_FUNC(this, 52, \
1410         void, (basic_streambuf_wchar*, const locale*), (this, loc))
1411 void __thiscall basic_streambuf_wchar_imbue(basic_streambuf_wchar *this, const locale *loc)
1412 {
1413     TRACE("(%p %p)\n", this, loc);
1414 }
1415
1416 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1417 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1418 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1419 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1420 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_overflow, 8)
1421 #define call_basic_streambuf_wchar_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1422         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1423 unsigned short __thiscall basic_streambuf_wchar_overflow(basic_streambuf_wchar *this, unsigned short ch)
1424 {
1425     TRACE("(%p %d)\n", this, ch);
1426     return WEOF;
1427 }
1428
1429 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1430 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1431 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1432 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1433 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbackfail, 8)
1434 #define call_basic_streambuf_wchar_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1435         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1436 unsigned short __thiscall basic_streambuf_wchar_pbackfail(basic_streambuf_wchar *this, unsigned short ch)
1437 {
1438     TRACE("(%p %d)\n", this, ch);
1439     return WEOF;
1440 }
1441
1442 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1443 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1444 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1445 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1446 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbase, 4)
1447 wchar_t* __thiscall basic_streambuf_wchar_pbase(const basic_streambuf_wchar *this)
1448 {
1449     TRACE("(%p)\n", this);
1450     return *this->pwbuf;
1451 }
1452
1453 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1454 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1455 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1456 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1457 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbump, 8)
1458 void __thiscall basic_streambuf_wchar_pbump(basic_streambuf_wchar *this, int off)
1459 {
1460     TRACE("(%p %d)\n", this, off);
1461     *this->pwpos += off;
1462     *this->pwsize -= off;
1463 }
1464
1465 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1466 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1467 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1468 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1469 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pptr, 4)
1470 wchar_t* __thiscall basic_streambuf_wchar_pptr(const basic_streambuf_wchar *this)
1471 {
1472     TRACE("(%p)\n", this);
1473     return *this->pwpos;
1474 }
1475
1476 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1477 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1478 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1479 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1480 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubimbue, 12)
1481 locale* __thiscall basic_streambuf_wchar_pubimbue(basic_streambuf_wchar *this, locale *ret, const locale *loc)
1482 {
1483     TRACE("(%p %p)\n", this, loc);
1484     memcpy(ret, this->loc, sizeof(locale));
1485     call_basic_streambuf_wchar_imbue(this, loc);
1486     locale_copy_ctor(this->loc, loc);
1487     return ret;
1488 }
1489
1490 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1491 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1492 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1493 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1494 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekoff, 20)
1495 #define call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 36, \
1496         fpos_int*, (basic_streambuf_wchar*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1497 fpos_int* __thiscall basic_streambuf_wchar_seekoff(basic_streambuf_wchar *this,
1498         fpos_int *ret, streamoff off, int way, int mode)
1499 {
1500     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1501     ret->off = 0;
1502     ret->pos = -1;
1503     ret->state = 0;
1504     return ret;
1505 }
1506
1507 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1508 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1509 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1510 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1511 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff, 20)
1512 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff(basic_streambuf_wchar *this,
1513         fpos_int *ret, streamoff off, int way, int mode)
1514 {
1515     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1516     return call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode);
1517 }
1518
1519 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
1520 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
1521 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
1522 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
1523 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff_old, 20)
1524 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff_old(basic_streambuf_wchar *this,
1525         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
1526 {
1527     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1528     return basic_streambuf_wchar_pubseekoff(this, ret, off, way, mode);
1529 }
1530
1531 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1532 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1533 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1534 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1535 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekpos, 36)
1536 #define call_basic_streambuf_wchar_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 40, \
1537         fpos_int*, (basic_streambuf_wchar*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
1538 fpos_int* __thiscall basic_streambuf_wchar_seekpos(basic_streambuf_wchar *this,
1539         fpos_int *ret, fpos_int pos, int mode)
1540 {
1541     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1542     ret->off = 0;
1543     ret->pos = -1;
1544     ret->state = 0;
1545     return ret;
1546 }
1547
1548 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1549 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1550 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1551 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1552 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos, 36)
1553 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos(basic_streambuf_wchar *this,
1554         fpos_int *ret, fpos_int pos, int mode)
1555 {
1556     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1557     return call_basic_streambuf_wchar_seekpos(this, ret, pos, mode);
1558 }
1559
1560 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
1561 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
1562 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
1563 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
1564 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos_old, 36)
1565 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos_old(basic_streambuf_wchar *this,
1566         fpos_int *ret, fpos_int pos, unsigned int mode)
1567 {
1568     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1569     return basic_streambuf_wchar_pubseekpos(this, ret, pos, mode);
1570 }
1571
1572 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEPAV12@PA_WH@Z */
1573 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV12@PEA_W_J@Z */
1574 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEPAV12@PAGH@Z */
1575 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAPEAV12@PEAG_J@Z */
1576 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setbuf, 12)
1577 #define call_basic_streambuf_wchar_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 44, \
1578         basic_streambuf_wchar*, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, buf, count))
1579 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_setbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
1580 {
1581     TRACE("(%p %p %ld)\n", this, buf, count);
1582     return this;
1583 }
1584
1585 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PA_WH@Z */
1586 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEA_W_J@Z */
1587 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PAGH@Z */
1588 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEAG_J@Z */
1589 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsetbuf, 12)
1590 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_pubsetbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
1591 {
1592     TRACE("(%p %p %ld)\n", this, buf, count);
1593     return call_basic_streambuf_wchar_setbuf(this, buf, count);
1594 }
1595
1596 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
1597 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
1598 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
1599 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
1600 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sync, 4)
1601 #define call_basic_streambuf_wchar_sync(this) CALL_VTBL_FUNC(this, 48, \
1602         int, (basic_streambuf_wchar*), (this))
1603 int __thiscall basic_streambuf_wchar_sync(basic_streambuf_wchar *this)
1604 {
1605     TRACE("(%p)\n", this);
1606     return 0;
1607 }
1608
1609 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
1610 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
1611 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
1612 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHXZ */
1613 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsync, 4)
1614 int __thiscall basic_streambuf_wchar_pubsync(basic_streambuf_wchar *this)
1615 {
1616     TRACE("(%p)\n", this);
1617     return call_basic_streambuf_wchar_sync(this);
1618 }
1619
1620 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
1621 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
1622 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
1623 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
1624 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetn, 12)
1625 streamsize __thiscall basic_streambuf_wchar_sgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
1626 {
1627     TRACE("(%p %p %ld)\n", this, ptr, count);
1628     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
1629 }
1630
1631 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
1632 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JXZ */
1633 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
1634 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JXZ */
1635 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_showmanyc, 4)
1636 #define call_basic_streambuf_wchar_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
1637         streamsize, (basic_streambuf_wchar*), (this))
1638 streamsize __thiscall basic_streambuf_wchar_showmanyc(basic_streambuf_wchar *this)
1639 {
1640     TRACE("(%p)\n", this);
1641     return 0;
1642 }
1643
1644 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
1645 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JXZ */
1646 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
1647 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JXZ */
1648 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_in_avail, 4)
1649 streamsize __thiscall basic_streambuf_wchar_in_avail(basic_streambuf_wchar *this)
1650 {
1651     streamsize ret;
1652
1653     TRACE("(%p)\n", this);
1654
1655     ret = basic_streambuf_wchar__Gnavail(this);
1656     return ret ? ret : call_basic_streambuf_wchar_showmanyc(this);
1657 }
1658
1659 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
1660 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
1661 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
1662 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
1663 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputbackc, 8)
1664 unsigned short __thiscall basic_streambuf_wchar_sputbackc(basic_streambuf_wchar *this, wchar_t ch)
1665 {
1666     TRACE("(%p %d)\n", this, ch);
1667     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
1668         (*this->prsize)++;
1669         (*this->prpos)--;
1670         return ch;
1671     }
1672
1673     return call_basic_streambuf_wchar_pbackfail(this, ch);
1674 }
1675
1676 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
1677 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
1678 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
1679 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHG@Z */
1680 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputc, 8)
1681 unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar *this, wchar_t ch)
1682 {
1683     TRACE("(%p %d)\n", this, ch);
1684     return basic_streambuf_wchar__Pnavail(this) ?
1685         (*basic_streambuf_wchar__Pninc(this) = ch) :
1686         call_basic_streambuf_wchar_overflow(this, ch);
1687 }
1688
1689 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1690 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1691 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1692 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1693 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sungetc, 4)
1694 unsigned short __thiscall basic_streambuf_wchar_sungetc(basic_streambuf_wchar *this)
1695 {
1696     TRACE("(%p)\n", this);
1697     if(*this->prpos && *this->prpos>*this->prbuf) {
1698         (*this->prsize)++;
1699         (*this->prpos)--;
1700         return **this->prpos;
1701     }
1702
1703     return call_basic_streambuf_wchar_pbackfail(this, WEOF);
1704 }
1705
1706 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1707 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1708 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1709 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1710 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_stossc, 4)
1711 void __thiscall basic_streambuf_wchar_stossc(basic_streambuf_wchar *this)
1712 {
1713     TRACE("(%p)\n", this);
1714     if(basic_streambuf_wchar__Gnavail(this))
1715         basic_streambuf_wchar__Gninc(this);
1716     else
1717         call_basic_streambuf_wchar_uflow(this);
1718 }
1719
1720 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1721 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1722 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1723 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1724 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sbumpc, 4)
1725 unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar *this)
1726 {
1727     TRACE("(%p)\n", this);
1728     return basic_streambuf_wchar__Gnavail(this) ?
1729         *basic_streambuf_wchar__Gninc(this) : call_basic_streambuf_wchar_uflow(this);
1730 }
1731
1732 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1733 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1734 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1735 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1736 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetc, 4)
1737 unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar *this)
1738 {
1739     TRACE("(%p)\n", this);
1740     return basic_streambuf_wchar__Gnavail(this) ?
1741         *basic_streambuf_wchar_gptr(this) : call_basic_streambuf_wchar_underflow(this);
1742 }
1743
1744 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1745 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1746 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1747 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1748 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_snextc, 4)
1749 unsigned short __thiscall basic_streambuf_wchar_snextc(basic_streambuf_wchar *this)
1750 {
1751     TRACE("(%p)\n", this);
1752
1753     if(basic_streambuf_wchar__Gnavail(this) > 1)
1754         return *basic_streambuf_wchar__Gnpreinc(this);
1755     return basic_streambuf_wchar_sbumpc(this)==WEOF ?
1756         WEOF : basic_streambuf_wchar_sgetc(this);
1757 }
1758
1759 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WH@Z */
1760 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_J@Z */
1761 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGH@Z */
1762 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_J@Z */
1763 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsgetn, 12)
1764 #define call_basic_streambuf_wchar_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
1765         streamsize, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, ptr, count))
1766 streamsize __thiscall basic_streambuf_wchar_xsgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
1767 {
1768     TRACE("(%p %p %ld)\n", this, ptr, count);
1769     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
1770 }
1771
1772 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPB_WH@Z */
1773 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEB_W_J@Z */
1774 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPBGH@Z */
1775 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEBG_J@Z */
1776 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsputn, 12)
1777 #define call_basic_streambuf_wchar_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 32, \
1778         streamsize, (basic_streambuf_wchar*, const wchar_t*, streamsize), (this, ptr, count))
1779 streamsize __thiscall basic_streambuf_wchar_xsputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
1780 {
1781     streamsize copied, chunk;
1782
1783     TRACE("(%p %p %ld)\n", this, ptr, count);
1784
1785     for(copied=0; copied<count;) {
1786         chunk = basic_streambuf_wchar__Pnavail(this);
1787         if(chunk > count-copied)
1788             chunk = count-copied;
1789
1790         if(chunk) {
1791             memcpy(*this->pwpos, ptr+copied, chunk);
1792             *this->pwpos += chunk;
1793             *this->pwsize -= chunk;
1794             copied += chunk;
1795         }else if(call_basic_streambuf_wchar_overflow(this, ptr[copied]) != WEOF) {
1796             copied++;
1797         }else {
1798             break;
1799         }
1800     }
1801
1802     return copied;
1803 }
1804
1805 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPB_WH@Z */
1806 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEB_W_J@Z */
1807 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPBGH@Z */
1808 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEBG_J@Z */
1809 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputn, 12)
1810 streamsize __thiscall basic_streambuf_wchar_sputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
1811 {
1812     TRACE("(%p %p %ld)\n", this, ptr, count);
1813     return call_basic_streambuf_wchar_xsputn(this, ptr, count);
1814 }
1815
1816 /* ??0ios_base@std@@IAE@XZ */
1817 /* ??0ios_base@std@@IEAA@XZ */
1818 DEFINE_THISCALL_WRAPPER(ios_base_ctor, 4)
1819 ios_base* __thiscall ios_base_ctor(ios_base *this)
1820 {
1821     TRACE("(%p)\n", this);
1822     this->vtable = &MSVCP_ios_base_vtable;
1823     return this;
1824 }
1825
1826 /* ??0ios_base@std@@QAE@ABV01@@Z */
1827 /* ??0ios_base@std@@QEAA@AEBV01@@Z */
1828 DEFINE_THISCALL_WRAPPER(ios_base_copy_ctor, 8)
1829 ios_base* __thiscall ios_base_copy_ctor(ios_base *this, const ios_base *copy)
1830 {
1831     TRACE("(%p %p)\n", this, copy);
1832     *this = *copy;
1833     this->vtable = &MSVCP_ios_base_vtable;
1834     return this;
1835 }
1836
1837 /* ?_Callfns@ios_base@std@@AAEXW4event@12@@Z */
1838 /* ?_Callfns@ios_base@std@@AEAAXW4event@12@@Z */
1839 DEFINE_THISCALL_WRAPPER(ios_base_Callfns, 8)
1840 void __thiscall ios_base_Callfns(ios_base *this, IOS_BASE_event event)
1841 {
1842     IOS_BASE_fnarray *cur;
1843
1844     TRACE("(%p %x)\n", this, event);
1845
1846     for(cur=this->calls; cur; cur=cur->next)
1847         cur->event_handler(event, this, cur->index);
1848 }
1849
1850 /* ?_Tidy@ios_base@std@@AAAXXZ */
1851 /* ?_Tidy@ios_base@std@@AEAAXXZ */
1852 void CDECL ios_base_Tidy(ios_base *this)
1853 {
1854     IOS_BASE_iosarray *arr_cur, *arr_next;
1855     IOS_BASE_fnarray *event_cur, *event_next;
1856
1857     TRACE("(%p)\n", this);
1858
1859     ios_base_Callfns(this, EVENT_erase_event);
1860
1861     for(arr_cur=this->arr; arr_cur; arr_cur=arr_next) {
1862         arr_next = arr_cur->next;
1863         MSVCRT_operator_delete(arr_cur);
1864     }
1865     this->arr = NULL;
1866
1867     for(event_cur=this->calls; event_cur; event_cur=event_next) {
1868         event_next = event_cur->next;
1869         MSVCRT_operator_delete(event_cur);
1870     }
1871     this->calls = NULL;
1872 }
1873
1874 /* ?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z */
1875 /* ?_Ios_base_dtor@ios_base@std@@CAXPEAV12@@Z */
1876 void CDECL ios_base_Ios_base_dtor(ios_base *obj)
1877 {
1878     TRACE("(%p)\n", obj);
1879     if(obj->loc) {
1880         locale_dtor(obj->loc);
1881         MSVCRT_operator_delete(obj->loc);
1882     }
1883     ios_base_Tidy(obj);
1884 }
1885
1886 /* ??1ios_base@std@@UAE@XZ */
1887 /* ??1ios_base@std@@UEAA@XZ */
1888 DEFINE_THISCALL_WRAPPER(ios_base_dtor, 4)
1889 void __thiscall ios_base_dtor(ios_base *this)
1890 {
1891     ios_base_Ios_base_dtor(this);
1892 }
1893
1894 DEFINE_THISCALL_WRAPPER(MSVCP_ios_base_vector_dtor, 8)
1895 ios_base* __thiscall MSVCP_ios_base_vector_dtor(ios_base *this, unsigned int flags)
1896 {
1897     TRACE("(%p %x)\n", this, flags);
1898     if(flags & 2) {
1899         /* we have an array, with the number of elements stored before the first object */
1900         int i, *ptr = (int *)this-1;
1901
1902         for(i=*ptr-1; i>=0; i--)
1903             ios_base_dtor(this+i);
1904         MSVCRT_operator_delete(ptr);
1905     } else {
1906         ios_base_dtor(this);
1907         if(flags & 1)
1908             MSVCRT_operator_delete(this);
1909     }
1910
1911     return this;
1912 }
1913
1914 DEFINE_THISCALL_WRAPPER(MSVCP_iosb_vector_dtor, 8)
1915 void* __thiscall MSVCP_iosb_vector_dtor(void *this, unsigned int flags)
1916 {
1917     TRACE("(%p %x)\n", this, flags);
1918     if(flags & 2) {
1919         int *ptr = (int *)this-1;
1920         MSVCRT_operator_delete(ptr);
1921     } else {
1922         if(flags & 1)
1923             MSVCRT_operator_delete(this);
1924     }
1925
1926     return this;
1927 }
1928
1929 /* ?_Findarr@ios_base@std@@AAEAAU_Iosarray@12@H@Z */
1930 /* ?_Findarr@ios_base@std@@AEAAAEAU_Iosarray@12@H@Z */
1931 DEFINE_THISCALL_WRAPPER(ios_base_Findarr, 8)
1932 IOS_BASE_iosarray* __thiscall ios_base_Findarr(ios_base *this, int index)
1933 {
1934     IOS_BASE_iosarray *p;
1935
1936     TRACE("(%p %d)\n", this, index);
1937
1938     for(p=this->arr; p; p=p->next) {
1939         if(p->index == index)
1940             return p;
1941     }
1942
1943     for(p=this->arr; p; p=p->next) {
1944         if(!p->long_val && !p->ptr_val) {
1945             p->index = index;
1946             return p;
1947         }
1948     }
1949
1950     p = MSVCRT_operator_new(sizeof(IOS_BASE_iosarray));
1951     p->next = this->arr;
1952     p->index = index;
1953     p->long_val = 0;
1954     p->ptr_val = NULL;
1955     this->arr = p;
1956     return p;
1957 }
1958
1959 /* ?iword@ios_base@std@@QAEAAJH@Z */
1960 /* ?iword@ios_base@std@@QEAAAEAJH@Z */
1961 DEFINE_THISCALL_WRAPPER(ios_base_iword, 8)
1962 LONG* __thiscall ios_base_iword(ios_base *this, int index)
1963 {
1964     TRACE("(%p %d)\n", this, index);
1965     return &ios_base_Findarr(this, index)->long_val;
1966 }
1967
1968 /* ?pword@ios_base@std@@QAEAAPAXH@Z */
1969 /* ?pword@ios_base@std@@QEAAAEAPEAXH@Z */
1970 DEFINE_THISCALL_WRAPPER(ios_base_pword, 8)
1971 void** __thiscall ios_base_pword(ios_base *this, int index)
1972 {
1973     TRACE("(%p %d)\n", this, index);
1974     return &ios_base_Findarr(this, index)->ptr_val;
1975 }
1976
1977 /* ?register_callback@ios_base@std@@QAEXP6AXW4event@12@AAV12@H@ZH@Z */
1978 /* ?register_callback@ios_base@std@@QEAAXP6AXW4event@12@AEAV12@H@ZH@Z */
1979 DEFINE_THISCALL_WRAPPER(ios_base_register_callback, 12)
1980 void __thiscall ios_base_register_callback(ios_base *this, IOS_BASE_event_callback callback, int index)
1981 {
1982     IOS_BASE_fnarray *event;
1983
1984     TRACE("(%p %p %d)\n", this, callback, index);
1985
1986     event = MSVCRT_operator_new(sizeof(IOS_BASE_fnarray));
1987     event->next = this->calls;
1988     event->index = index;
1989     event->event_handler = callback;
1990     this->calls = event;
1991 }
1992
1993 /* ?clear@ios_base@std@@QAEXH_N@Z */
1994 /* ?clear@ios_base@std@@QEAAXH_N@Z */
1995 DEFINE_THISCALL_WRAPPER(ios_base_clear_reraise, 12)
1996 void __thiscall ios_base_clear_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
1997 {
1998     TRACE("(%p %x %x)\n", this, state, reraise);
1999
2000     this->state = state & IOSTATE_mask;
2001     if(!(this->state & this->except))
2002         return;
2003
2004     if(reraise)
2005         throw_exception(EXCEPTION_RERAISE, NULL);
2006     else if(this->state & this->except & IOSTATE_eofbit)
2007         throw_exception(EXCEPTION_FAILURE, "eofbit is set");
2008     else if(this->state & this->except & IOSTATE_failbit)
2009         throw_exception(EXCEPTION_FAILURE, "failbit is set");
2010     else if(this->state & this->except & IOSTATE_badbit)
2011         throw_exception(EXCEPTION_FAILURE, "badbit is set");
2012     else if(this->state & this->except & IOSTATE__Hardfail)
2013         throw_exception(EXCEPTION_FAILURE, "_Hardfail is set");
2014 }
2015
2016 /* ?clear@ios_base@std@@QAEXH@Z */
2017 /* ?clear@ios_base@std@@QEAAXH@Z */
2018 DEFINE_THISCALL_WRAPPER(ios_base_clear, 8)
2019 void __thiscall ios_base_clear(ios_base *this, IOSB_iostate state)
2020 {
2021     ios_base_clear_reraise(this, state, FALSE);
2022 }
2023
2024 /* ?clear@ios_base@std@@QAEXI@Z */
2025 /* ?clear@ios_base@std@@QEAAXI@Z */
2026 DEFINE_THISCALL_WRAPPER(ios_base_clear_unsigned, 8)
2027 void __thiscall ios_base_clear_unsigned(ios_base *this, unsigned int state)
2028 {
2029     ios_base_clear_reraise(this, (IOSB_iostate)state, FALSE);
2030 }
2031
2032 /* ?exceptions@ios_base@std@@QAEXH@Z */
2033 /* ?exceptions@ios_base@std@@QEAAXH@Z */
2034 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set, 8)
2035 void __thiscall ios_base_exceptions_set(ios_base *this, IOSB_iostate state)
2036 {
2037     TRACE("(%p %x)\n", this, state);
2038     this->except = state & IOSTATE_mask;
2039     ios_base_clear(this, this->state);
2040 }
2041
2042 /* ?exceptions@ios_base@std@@QAEXI@Z */
2043 /* ?exceptions@ios_base@std@@QEAAXI@Z */
2044 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set_unsigned, 8)
2045 void __thiscall ios_base_exceptions_set_unsigned(ios_base *this, unsigned int state)
2046 {
2047     TRACE("(%p %x)\n", this, state);
2048     ios_base_exceptions_set(this, state);
2049 }
2050
2051 /* ?exceptions@ios_base@std@@QBEHXZ */
2052 /* ?exceptions@ios_base@std@@QEBAHXZ */
2053 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_get, 4)
2054 IOSB_iostate __thiscall ios_base_exceptions_get(ios_base *this)
2055 {
2056     TRACE("(%p)\n", this);
2057     return this->except;
2058 }
2059
2060 /* ?copyfmt@ios_base@std@@QAEAAV12@ABV12@@Z */
2061 /* ?copyfmt@ios_base@std@@QEAAAEAV12@AEBV12@@Z */
2062 DEFINE_THISCALL_WRAPPER(ios_base_copyfmt, 8)
2063 ios_base* __thiscall ios_base_copyfmt(ios_base *this, const ios_base *rhs)
2064 {
2065     TRACE("(%p %p)\n", this, rhs);
2066
2067     if(this != rhs) {
2068         IOS_BASE_iosarray *arr_cur;
2069         IOS_BASE_fnarray *event_cur;
2070
2071         ios_base_Tidy(this);
2072
2073         for(arr_cur=rhs->arr; arr_cur; arr_cur=arr_cur->next) {
2074             if(arr_cur->long_val)
2075                 *ios_base_iword(this, arr_cur->index) = arr_cur->long_val;
2076             if(arr_cur->ptr_val)
2077                 *ios_base_pword(this, arr_cur->index) = arr_cur->ptr_val;
2078         }
2079         this->stdstr = rhs->stdstr;
2080         this->fmtfl = rhs->fmtfl;
2081         this->prec = rhs->prec;
2082         this->wide = rhs->wide;
2083         locale_operator_assign(this->loc, rhs->loc);
2084
2085         for(event_cur=rhs->calls; event_cur; event_cur=event_cur->next)
2086             ios_base_register_callback(this, event_cur->event_handler, event_cur->index);
2087
2088         ios_base_Callfns(this, EVENT_copyfmt_event);
2089         ios_base_exceptions_set(this, rhs->except);
2090     }
2091
2092     return this;
2093 }
2094
2095 /* ??4ios_base@std@@QAEAAV01@ABV01@@Z */
2096 /* ??4ios_base@std@@QEAAAEAV01@AEBV01@@Z */
2097 DEFINE_THISCALL_WRAPPER(ios_base_assign, 8)
2098 ios_base* __thiscall ios_base_assign(ios_base *this, const ios_base *right)
2099 {
2100     TRACE("(%p %p)\n", this, right);
2101
2102     if(this != right) {
2103         this->state = right->state;
2104         ios_base_copyfmt(this, right);
2105     }
2106
2107     return this;
2108 }
2109
2110 /* ?fail@ios_base@std@@QBE_NXZ */
2111 /* ?fail@ios_base@std@@QEBA_NXZ */
2112 DEFINE_THISCALL_WRAPPER(ios_base_fail, 4)
2113 MSVCP_bool __thiscall ios_base_fail(const ios_base *this)
2114 {
2115     TRACE("(%p)\n", this);
2116     return (this->state & (IOSTATE_failbit|IOSTATE_badbit)) != 0;
2117 }
2118
2119 /* ??7ios_base@std@@QBE_NXZ */
2120 /* ??7ios_base@std@@QEBA_NXZ */
2121 DEFINE_THISCALL_WRAPPER(ios_base_op_succ, 4)
2122 MSVCP_bool __thiscall ios_base_op_succ(const ios_base *this)
2123 {
2124     TRACE("(%p)\n", this);
2125     return ios_base_fail(this);
2126 }
2127
2128 /* ??Bios_base@std@@QBEPAXXZ */
2129 /* ??Bios_base@std@@QEBAPEAXXZ */
2130 DEFINE_THISCALL_WRAPPER(ios_base_op_fail, 4)
2131 void* __thiscall ios_base_op_fail(const ios_base *this)
2132 {
2133     TRACE("(%p)\n", this);
2134     return ios_base_fail(this) ? NULL : (void*)this;
2135 }
2136
2137 /* ?_Addstd@ios_base@std@@SAXPAV12@@Z */
2138 /* ?_Addstd@ios_base@std@@SAXPEAV12@@Z */
2139 void CDECL ios_base_Addstd(ios_base *add)
2140 {
2141     FIXME("(%p) stub\n", add);
2142 }
2143
2144 /* ?_Index_func@ios_base@std@@CAAAHXZ */
2145 /* ?_Index_func@ios_base@std@@CAAEAHXZ */
2146 int* CDECL ios_base_Index_func(void)
2147 {
2148     TRACE("\n");
2149     return &ios_base_Index;
2150 }
2151
2152 /* ?_Init@ios_base@std@@IAEXXZ */
2153 /* ?_Init@ios_base@std@@IEAAXXZ */
2154 DEFINE_THISCALL_WRAPPER(ios_base_Init, 4)
2155 void __thiscall ios_base_Init(ios_base *this)
2156 {
2157     TRACE("(%p)\n", this);
2158
2159     this->stdstr = 0;
2160     this->state = this->except = IOSTATE_goodbit;
2161     this->fmtfl = FMTFLAG_skipws | FMTFLAG_dec;
2162     this->prec = 6;
2163     this->wide = 0;
2164     this->arr = NULL;
2165     this->calls = NULL;
2166     this->loc = MSVCRT_operator_new(sizeof(locale));
2167     locale_ctor(this->loc);
2168 }
2169
2170 /* ?_Sync_func@ios_base@std@@CAAA_NXZ */
2171 /* ?_Sync_func@ios_base@std@@CAAEA_NXZ */
2172 MSVCP_bool* CDECL ios_base_Sync_func(void)
2173 {
2174     TRACE("\n");
2175     return &ios_base_Sync;
2176 }
2177
2178 /* ?bad@ios_base@std@@QBE_NXZ */
2179 /* ?bad@ios_base@std@@QEBA_NXZ */
2180 DEFINE_THISCALL_WRAPPER(ios_base_bad, 4)
2181 MSVCP_bool __thiscall ios_base_bad(const ios_base *this)
2182 {
2183     TRACE("(%p)\n", this);
2184     return (this->state & IOSTATE_badbit) != 0;
2185 }
2186
2187 /* ?eof@ios_base@std@@QBE_NXZ */
2188 /* ?eof@ios_base@std@@QEBA_NXZ */
2189 DEFINE_THISCALL_WRAPPER(ios_base_eof, 4)
2190 MSVCP_bool __thiscall ios_base_eof(const ios_base *this)
2191 {
2192     TRACE("(%p)\n", this);
2193     return (this->state & IOSTATE_eofbit) != 0;
2194 }
2195
2196 /* ?flags@ios_base@std@@QAEHH@Z */
2197 /* ?flags@ios_base@std@@QEAAHH@Z */
2198 DEFINE_THISCALL_WRAPPER(ios_base_flags_set, 8)
2199 IOSB_fmtflags __thiscall ios_base_flags_set(ios_base *this, IOSB_fmtflags flags)
2200 {
2201     IOSB_fmtflags ret = this->fmtfl;
2202
2203     TRACE("(%p %x)\n", this, flags);
2204
2205     this->fmtfl = flags & FMTFLAG_mask;
2206     return ret;
2207 }
2208
2209 /* ?flags@ios_base@std@@QBEHXZ */
2210 /* ?flags@ios_base@std@@QEBAHXZ */
2211 DEFINE_THISCALL_WRAPPER(ios_base_flags_get, 4)
2212 IOSB_fmtflags __thiscall ios_base_flags_get(const ios_base *this)
2213 {
2214     TRACE("(%p)\n", this);
2215     return this->fmtfl;
2216 }
2217
2218 /* ?getloc@ios_base@std@@QBE?AVlocale@2@XZ */
2219 /* ?getloc@ios_base@std@@QEBA?AVlocale@2@XZ */
2220 DEFINE_THISCALL_WRAPPER(ios_base_getloc, 8)
2221 locale* __thiscall ios_base_getloc(const ios_base *this, locale *ret)
2222 {
2223     TRACE("(%p)\n", this);
2224     return locale_copy_ctor(ret, this->loc);
2225 }
2226
2227 /* ?good@ios_base@std@@QBE_NXZ */
2228 /* ?good@ios_base@std@@QEBA_NXZ */
2229 DEFINE_THISCALL_WRAPPER(ios_base_good, 4)
2230 MSVCP_bool __thiscall ios_base_good(const ios_base *this)
2231 {
2232     TRACE("(%p)\n", this);
2233     return this->state == IOSTATE_goodbit;
2234 }
2235
2236 /* ?imbue@ios_base@std@@QAE?AVlocale@2@ABV32@@Z */
2237 /* ?imbue@ios_base@std@@QEAA?AVlocale@2@AEBV32@@Z */
2238 DEFINE_THISCALL_WRAPPER(ios_base_imbue, 12)
2239 locale* __thiscall ios_base_imbue(ios_base *this, locale *ret, const locale *loc)
2240 {
2241     TRACE("(%p %p)\n", this, loc);
2242     *ret = *this->loc;
2243     locale_copy_ctor(this->loc, loc);
2244     return ret;
2245 }
2246
2247 /* ?precision@ios_base@std@@QAEHH@Z */
2248 /* ?precision@ios_base@std@@QEAA_J_J@Z */
2249 DEFINE_THISCALL_WRAPPER(ios_base_precision_set, 8)
2250 streamsize __thiscall ios_base_precision_set(ios_base *this, streamsize precision)
2251 {
2252     streamsize ret = this->prec;
2253
2254     TRACE("(%p %ld)\n", this, precision);
2255
2256     this->prec = precision;
2257     return ret;
2258 }
2259
2260 /* ?precision@ios_base@std@@QBEHXZ */
2261 /* ?precision@ios_base@std@@QEBA_JXZ */
2262 DEFINE_THISCALL_WRAPPER(ios_base_precision_get, 4)
2263 streamsize __thiscall ios_base_precision_get(const ios_base *this)
2264 {
2265     TRACE("(%p)\n", this);
2266     return this->prec;
2267 }
2268
2269 /* ?rdstate@ios_base@std@@QBEHXZ */
2270 /* ?rdstate@ios_base@std@@QEBAHXZ */
2271 DEFINE_THISCALL_WRAPPER(ios_base_rdstate, 4)
2272 IOSB_iostate __thiscall ios_base_rdstate(const ios_base *this)
2273 {
2274     TRACE("(%p)\n", this);
2275     return this->state;
2276 }
2277
2278 /* ?setf@ios_base@std@@QAEHHH@Z */
2279 /* ?setf@ios_base@std@@QEAAHHH@Z */
2280 DEFINE_THISCALL_WRAPPER(ios_base_setf_mask, 12)
2281 IOSB_fmtflags __thiscall ios_base_setf_mask(ios_base *this, IOSB_fmtflags flags, IOSB_fmtflags mask)
2282 {
2283     IOSB_fmtflags ret = this->fmtfl;
2284
2285     TRACE("(%p %x %x)\n", this, flags, mask);
2286
2287     this->fmtfl = (this->fmtfl & (~mask)) | (flags & mask & FMTFLAG_mask);
2288     return ret;
2289 }
2290
2291 /* ?setf@ios_base@std@@QAEHH@Z */
2292 /* ?setf@ios_base@std@@QEAAHH@Z */
2293 DEFINE_THISCALL_WRAPPER(ios_base_setf, 8)
2294 IOSB_fmtflags __thiscall ios_base_setf(ios_base *this, IOSB_fmtflags flags)
2295 {
2296     return ios_base_setf_mask(this, flags, ~0);
2297 }
2298
2299 /* ?setstate@ios_base@std@@QAEXH_N@Z */
2300 /* ?setstate@ios_base@std@@QEAAXH_N@Z */
2301 DEFINE_THISCALL_WRAPPER(ios_base_setstate_reraise, 12)
2302 void __thiscall ios_base_setstate_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
2303 {
2304     TRACE("(%p %x %x)\n", this, state, reraise);
2305
2306     if(state != IOSTATE_goodbit)
2307         ios_base_clear_reraise(this, this->state | state, reraise);
2308 }
2309
2310 /* ?setstate@ios_base@std@@QAEXH@Z */
2311 /* ?setstate@ios_base@std@@QEAAXH@Z */
2312 DEFINE_THISCALL_WRAPPER(ios_base_setstate, 8)
2313 void __thiscall ios_base_setstate(ios_base *this, IOSB_iostate state)
2314 {
2315     ios_base_setstate_reraise(this, state, FALSE);
2316 }
2317
2318 /* ?setstate@ios_base@std@@QAEXI@Z */
2319 /* ?setstate@ios_base@std@@QEAAXI@Z */
2320 DEFINE_THISCALL_WRAPPER(ios_base_setstate_unsigned, 8)
2321 void __thiscall ios_base_setstate_unsigned(ios_base *this, unsigned int state)
2322 {
2323     ios_base_setstate_reraise(this, (IOSB_iostate)state, FALSE);
2324 }
2325
2326 /* ?sync_with_stdio@ios_base@std@@SA_N_N@Z */
2327 MSVCP_bool CDECL ios_base_sync_with_stdio(MSVCP_bool sync)
2328 {
2329     _Lockit lock;
2330     MSVCP_bool ret;
2331
2332     TRACE("(%x)\n", sync);
2333
2334     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
2335     ret = ios_base_Sync;
2336     ios_base_Sync = sync;
2337     _Lockit_dtor(&lock);
2338     return ret;
2339 }
2340
2341 /* ?unsetf@ios_base@std@@QAEXH@Z */
2342 /* ?unsetf@ios_base@std@@QEAAXH@Z */
2343 DEFINE_THISCALL_WRAPPER(ios_base_unsetf, 8)
2344 void __thiscall ios_base_unsetf(ios_base *this, IOSB_fmtflags flags)
2345 {
2346     TRACE("(%p %x)\n", this, flags);
2347     this->fmtfl &= ~flags;
2348 }
2349
2350 /* ?width@ios_base@std@@QAEHH@Z */
2351 /* ?width@ios_base@std@@QEAA_J_J@Z */
2352 DEFINE_THISCALL_WRAPPER(ios_base_width_set, 8)
2353 streamsize __thiscall ios_base_width_set(ios_base *this, streamsize width)
2354 {
2355     streamsize ret = this->wide;
2356
2357     TRACE("(%p %ld)\n", this, width);
2358
2359     this->wide = width;
2360     return ret;
2361 }
2362
2363 /* ?width@ios_base@std@@QBEHXZ */
2364 /* ?width@ios_base@std@@QEBA_JXZ */
2365 DEFINE_THISCALL_WRAPPER(ios_base_width_get, 4)
2366 streamsize __thiscall ios_base_width_get(ios_base *this)
2367 {
2368     TRACE("(%p)\n", this);
2369     return this->wide;
2370 }
2371
2372 /* ?xalloc@ios_base@std@@SAHXZ */
2373 int CDECL ios_base_xalloc(void)
2374 {
2375     _Lockit lock;
2376     int ret;
2377
2378     TRACE("\n");
2379
2380     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
2381     ret = ios_base_Index++;
2382     _Lockit_dtor(&lock);
2383     return ret;
2384 }
2385
2386 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ */
2387 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IEAA@XZ */
2388 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor, 4)
2389 basic_ios_char* __thiscall basic_ios_char_ctor(basic_ios_char *this)
2390 {
2391     TRACE("(%p)\n", this);
2392
2393     ios_base_ctor(&this->base);
2394     this->base.vtable = &MSVCP_basic_ios_char_vtable;
2395     return this;
2396 }
2397
2398 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IAEXPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
2399 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
2400 DEFINE_THISCALL_WRAPPER(basic_ios_char_init, 12)
2401 void __thiscall basic_ios_char_init(basic_ios_char *this, basic_streambuf_char *streambuf, MSVCP_bool isstd)
2402 {
2403     TRACE("(%p %p %x)\n", this, streambuf, isstd);
2404     ios_base_Init(&this->base);
2405     this->strbuf = streambuf;
2406     this->stream = NULL;
2407     this->fillch = ' ';
2408
2409     if(!streambuf)
2410         ios_base_setstate(&this->base, IOSTATE_badbit);
2411
2412     if(isstd)
2413         FIXME("standard streams not handled yet\n");
2414 }
2415
2416 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
2417 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
2418 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor_streambuf, 8)
2419 basic_ios_char* __thiscall basic_ios_char_ctor_streambuf(basic_ios_char *this, basic_streambuf_char *strbuf)
2420 {
2421     TRACE("(%p %p)\n", this, strbuf);
2422
2423     basic_ios_char_ctor(this);
2424     basic_ios_char_init(this, strbuf, FALSE);
2425     return this;
2426 }
2427
2428 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ */
2429 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ */
2430 DEFINE_THISCALL_WRAPPER(basic_ios_char_dtor, 4)
2431 void __thiscall basic_ios_char_dtor(basic_ios_char *this)
2432 {
2433     TRACE("(%p)\n", this);
2434     ios_base_dtor(&this->base);
2435 }
2436
2437 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ios_char_vector_dtor, 8)
2438 basic_ios_char* __thiscall MSVCP_basic_ios_char_vector_dtor(basic_ios_char *this, unsigned int flags)
2439 {
2440     TRACE("(%p %x)\n", this, flags);
2441     if(flags & 2) {
2442         /* we have an array, with the number of elements stored before the first object */
2443         int i, *ptr = (int *)this-1;
2444
2445         for(i=*ptr-1; i>=0; i--)
2446             basic_ios_char_dtor(this+i);
2447         MSVCRT_operator_delete(ptr);
2448     } else {
2449         basic_ios_char_dtor(this);
2450         if(flags & 1)
2451             MSVCRT_operator_delete(this);
2452     }
2453
2454     return this;
2455 }
2456
2457 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
2458 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
2459 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear_reraise, 12)
2460 void __thiscall basic_ios_char_clear_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
2461 {
2462     TRACE("(%p %x %x)\n", this, state, reraise);
2463     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
2464 }
2465
2466 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
2467 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
2468 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear, 8)
2469 void __thiscall basic_ios_char_clear(basic_ios_char *this, unsigned int state)
2470 {
2471     basic_ios_char_clear_reraise(this, (IOSB_iostate)state, FALSE);
2472 }
2473
2474 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEAAV12@ABV12@@Z */
2475 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEBV12@@Z */
2476 DEFINE_THISCALL_WRAPPER(basic_ios_char_copyfmt, 8)
2477 basic_ios_char* __thiscall basic_ios_char_copyfmt(basic_ios_char *this, basic_ios_char *copy)
2478 {
2479     TRACE("(%p %p)\n", this, copy);
2480     if(this == copy)
2481         return this;
2482
2483     this->stream = copy->stream;
2484     this->fillch = copy->fillch;
2485     ios_base_copyfmt(&this->base, &copy->base);
2486     return this;
2487 }
2488
2489 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEDD@Z */
2490 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAADD@Z */
2491 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_set, 8)
2492 char __thiscall basic_ios_char_fill_set(basic_ios_char *this, char fill)
2493 {
2494     char ret = this->fillch;
2495
2496     TRACE("(%p %c)\n", this, fill);
2497
2498     this->fillch = fill;
2499     return ret;
2500 }
2501
2502 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ */
2503 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADXZ */
2504 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_get, 4)
2505 char __thiscall basic_ios_char_fill_get(basic_ios_char *this)
2506 {
2507     TRACE("(%p)\n", this);
2508     return this->fillch;
2509 }
2510
2511 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
2512 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
2513 DEFINE_THISCALL_WRAPPER(basic_ios_char_imbue, 12)
2514 locale *__thiscall basic_ios_char_imbue(basic_ios_char *this, locale *ret, const locale *loc)
2515 {
2516     TRACE("(%p %p %p)\n", this, ret, loc);
2517
2518     if(this->strbuf)
2519         return basic_streambuf_char_pubimbue(this->strbuf, ret, loc);
2520
2521     locale_copy_ctor(ret, loc);
2522     return ret;
2523 }
2524
2525 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDDD@Z */
2526 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADDD@Z */
2527 DEFINE_THISCALL_WRAPPER(basic_ios_char_narrow, 12)
2528 char __thiscall basic_ios_char_narrow(basic_ios_char *this, char ch, char def)
2529 {
2530     FIXME("(%p %c %c) stub\n", this, ch, def);
2531     return def;
2532 }
2533
2534 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PAV32@@Z */
2535 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAV32@@Z */
2536 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_set, 8)
2537 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_set(basic_ios_char *this, basic_streambuf_char *streambuf)
2538 {
2539     basic_streambuf_char *ret = this->strbuf;
2540
2541     TRACE("(%p %p)\n", this, streambuf);
2542
2543     this->strbuf = streambuf;
2544     basic_ios_char_clear(this, IOSTATE_goodbit);
2545     return ret;
2546 }
2547
2548 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
2549 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
2550 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_get, 4)
2551 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_get(const basic_ios_char *this)
2552 {
2553     TRACE("(%p)\n", this);
2554     return this->strbuf;
2555 }
2556
2557 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
2558 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
2559 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate_reraise, 12)
2560 void __thiscall basic_ios_char_setstate_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
2561 {
2562     TRACE("(%p %x %x)\n", this, state, reraise);
2563
2564     if(state != IOSTATE_goodbit)
2565         basic_ios_char_clear_reraise(this, this->base.state | state, reraise);
2566 }
2567
2568 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
2569 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
2570 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate, 8)
2571 void __thiscall basic_ios_char_setstate(basic_ios_char *this, unsigned int state)
2572 {
2573     basic_ios_char_setstate_reraise(this, (IOSB_iostate)state, FALSE);
2574 }
2575
2576 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@PAV32@@Z */
2577 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@PEAV32@@Z */
2578 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_set, 8)
2579 basic_ostream_char* __thiscall basic_ios_char_tie_set(basic_ios_char *this, basic_ostream_char *ostream)
2580 {
2581     basic_ostream_char *ret = this->stream;
2582
2583     TRACE("(%p %p)\n", this, ostream);
2584
2585     this->stream = ostream;
2586     return ret;
2587 }
2588
2589 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
2590 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
2591 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_get, 4)
2592 basic_ostream_char* __thiscall basic_ios_char_tie_get(const basic_ios_char *this)
2593 {
2594     TRACE("(%p)\n", this);
2595     return this->stream;
2596 }
2597
2598 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDD@Z */
2599 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADD@Z */
2600 DEFINE_THISCALL_WRAPPER(basic_ios_char_widen, 8)
2601 char __thiscall basic_ios_char_widen(basic_ios_char *this, char ch)
2602 {
2603     FIXME("(%p %c) stub\n", this, ch);
2604     return 0;
2605 }
2606
2607
2608 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
2609 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
2610 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor, 4)
2611 basic_ios_wchar* __thiscall basic_ios_wchar_ctor(basic_ios_wchar *this)
2612 {
2613     TRACE("(%p)\n", this);
2614
2615     ios_base_ctor(&this->base);
2616     this->base.vtable = &MSVCP_basic_ios_wchar_vtable;
2617     return this;
2618 }
2619
2620 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IAE@XZ */
2621 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IEAA@XZ */
2622 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor, 4)
2623 basic_ios_wchar* __thiscall basic_ios_short_ctor(basic_ios_wchar *this)
2624 {
2625     basic_ios_wchar_ctor(this);
2626     this->base.vtable = &MSVCP_basic_ios_short_vtable;
2627     return this;
2628 }
2629
2630 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
2631 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
2632 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IAEXPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
2633 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
2634 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_init, 12)
2635 void __thiscall basic_ios_wchar_init(basic_ios_wchar *this, basic_streambuf_wchar *streambuf, MSVCP_bool isstd)
2636 {
2637     TRACE("(%p %p %x)\n", this, streambuf, isstd);
2638     ios_base_Init(&this->base);
2639     this->strbuf = streambuf;
2640     this->stream = NULL;
2641     this->fillch = ' ';
2642
2643     if(!streambuf)
2644         ios_base_setstate(&this->base, IOSTATE_badbit);
2645
2646     if(isstd)
2647         FIXME("standard streams not handled yet\n");
2648 }
2649
2650 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
2651 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
2652 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor_streambuf, 8)
2653 basic_ios_wchar* __thiscall basic_ios_wchar_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
2654 {
2655     TRACE("(%p %p)\n", this, strbuf);
2656
2657     basic_ios_wchar_ctor(this);
2658     basic_ios_wchar_init(this, strbuf, FALSE);
2659     return this;
2660 }
2661
2662 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
2663 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
2664 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor_streambuf, 8)
2665 basic_ios_wchar* __thiscall basic_ios_short_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
2666 {
2667     basic_ios_wchar_ctor_streambuf(this, strbuf);
2668     this->base.vtable = &MSVCP_basic_ios_short_vtable;
2669     return this;
2670 }
2671
2672 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
2673 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
2674 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UAE@XZ */
2675 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UEAA@XZ */
2676 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_dtor, 4)
2677 void __thiscall basic_ios_wchar_dtor(basic_ios_wchar *this)
2678 {
2679     TRACE("(%p)\n", this);
2680     ios_base_dtor(&this->base);
2681 }
2682
2683 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ios_wchar_vector_dtor, 8)
2684 basic_ios_wchar* __thiscall MSVCP_basic_ios_wchar_vector_dtor(basic_ios_wchar *this, unsigned int flags)
2685 {
2686     TRACE("(%p %x)\n", this, flags);
2687     if(flags & 2) {
2688         /* we have an array, with the number of elements stored before the first object */
2689         int i, *ptr = (int *)this-1;
2690
2691         for(i=*ptr-1; i>=0; i--)
2692             basic_ios_wchar_dtor(this+i);
2693         MSVCRT_operator_delete(ptr);
2694     } else {
2695         basic_ios_wchar_dtor(this);
2696         if(flags & 1)
2697             MSVCRT_operator_delete(this);
2698     }
2699
2700     return this;
2701 }
2702
2703 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ios_short_vector_dtor, 8)
2704 basic_ios_wchar* __thiscall MSVCP_basic_ios_short_vector_dtor(basic_ios_wchar *this, unsigned int flags)
2705 {
2706     return MSVCP_basic_ios_wchar_vector_dtor(this, flags);
2707 }
2708
2709 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
2710 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
2711 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
2712 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
2713 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear_reraise, 12)
2714 void __thiscall basic_ios_wchar_clear_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
2715 {
2716     TRACE("(%p %x %x)\n", this, state, reraise);
2717     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
2718 }
2719
2720 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
2721 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
2722 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
2723 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
2724 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear, 8)
2725 void __thiscall basic_ios_wchar_clear(basic_ios_wchar *this, unsigned int state)
2726 {
2727     basic_ios_wchar_clear_reraise(this, (IOSB_iostate)state, FALSE);
2728 }
2729
2730 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEAAV12@ABV12@@Z */
2731 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEBV12@@Z */
2732 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEAAV12@ABV12@@Z */
2733 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEBV12@@Z */
2734 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_copyfmt, 8)
2735 basic_ios_wchar* __thiscall basic_ios_wchar_copyfmt(basic_ios_wchar *this, basic_ios_wchar *copy)
2736 {
2737     TRACE("(%p %p)\n", this, copy);
2738     if(this == copy)
2739         return this;
2740
2741     this->stream = copy->stream;
2742     this->fillch = copy->fillch;
2743     ios_base_copyfmt(&this->base, &copy->base);
2744     return this;
2745 }
2746
2747 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE_W_W@Z */
2748 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA_W_W@Z */
2749 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2750 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
2751 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_set, 8)
2752 wchar_t __thiscall basic_ios_wchar_fill_set(basic_ios_wchar *this, wchar_t fill)
2753 {
2754     wchar_t ret = this->fillch;
2755
2756     TRACE("(%p %c)\n", this, fill);
2757
2758     this->fillch = fill;
2759     return ret;
2760 }
2761
2762 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WXZ */
2763 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WXZ */
2764 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGXZ */
2765 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGXZ */
2766 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_get, 4)
2767 wchar_t __thiscall basic_ios_wchar_fill_get(basic_ios_wchar *this)
2768 {
2769     TRACE("(%p)\n", this);
2770     return this->fillch;
2771 }
2772
2773 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
2774 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
2775 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
2776 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
2777 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_imbue, 12)
2778 locale *__thiscall basic_ios_wchar_imbue(basic_ios_wchar *this, locale *ret, const locale *loc)
2779 {
2780     TRACE("(%p %p %p)\n", this, ret, loc);
2781
2782     if(this->strbuf)
2783         return basic_streambuf_wchar_pubimbue(this->strbuf, ret, loc);
2784
2785     locale_copy_ctor(ret, loc);
2786     return ret;
2787 }
2788
2789 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBED_WD@Z */
2790 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAD_WD@Z */
2791 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEDGD@Z */
2792 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBADGD@Z */
2793 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_narrow, 12)
2794 char __thiscall basic_ios_wchar_narrow(basic_ios_wchar *this, wchar_t ch, char def)
2795 {
2796     FIXME("(%p %c %c) stub\n", this, ch, def);
2797     return def;
2798 }
2799
2800 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
2801 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
2802 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAV32@@Z */
2803 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAV32@@Z */
2804 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_set, 8)
2805 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_set(basic_ios_wchar *this, basic_streambuf_wchar *streambuf)
2806 {
2807     basic_streambuf_wchar *ret = this->strbuf;
2808
2809     TRACE("(%p %p)\n", this, streambuf);
2810
2811     this->strbuf = streambuf;
2812     basic_ios_wchar_clear(this, IOSTATE_goodbit);
2813     return ret;
2814 }
2815
2816 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
2817 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
2818 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
2819 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
2820 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_get, 4)
2821 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_get(const basic_ios_wchar *this)
2822 {
2823     TRACE("(%p)\n", this);
2824     return this->strbuf;
2825 }
2826
2827 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
2828 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
2829 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
2830 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
2831 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate_reraise, 12)
2832 void __thiscall basic_ios_wchar_setstate_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
2833 {
2834     TRACE("(%p %x %x)\n", this, state, reraise);
2835
2836     if(state != IOSTATE_goodbit)
2837         basic_ios_wchar_clear_reraise(this, this->base.state | state, reraise);
2838 }
2839
2840 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
2841 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
2842 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
2843 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
2844 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate, 8)
2845 void __thiscall basic_ios_wchar_setstate(basic_ios_wchar *this, IOSB_iostate state)
2846 {
2847     basic_ios_wchar_setstate_reraise(this, state, FALSE);
2848 }
2849
2850 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
2851 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
2852 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@PAV32@@Z */
2853 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@PEAV32@@Z */
2854 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_set, 8)
2855 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_set(basic_ios_wchar *this, basic_ostream_wchar *ostream)
2856 {
2857     basic_ostream_wchar *ret = this->stream;
2858
2859     TRACE("(%p %p)\n", this, ostream);
2860
2861     this->stream = ostream;
2862     return ret;
2863 }
2864
2865 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
2866 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
2867 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
2868 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
2869 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_get, 4)
2870 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_get(const basic_ios_wchar *this)
2871 {
2872     TRACE("(%p)\n", this);
2873     return this->stream;
2874 }
2875
2876 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WD@Z */
2877 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WD@Z */
2878 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGD@Z */
2879 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGD@Z */
2880 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_widen, 8)
2881 wchar_t __thiscall basic_ios_wchar_widen(basic_ios_wchar *this, char ch)
2882 {
2883     FIXME("(%p %c)\n", this, ch);
2884     return 0;
2885 }
2886
2887 /* Caution: basic_ostream uses virtual inheritance.
2888  * All constructors have additional parameter that says if base class should be initialized.
2889  * Base class needs to be accessed using vbtable.
2890  */
2891 static inline basic_ios_char* basic_ostream_char_get_basic_ios(basic_ostream_char *this)
2892 {
2893     return (basic_ios_char*)((char*)this+this->vbtable[1]);
2894 }
2895
2896 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
2897 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
2898 DEFINE_THISCALL_WRAPPER(basic_ostream_char_ctor, 16)
2899 basic_ostream_char* __thiscall basic_ostream_char_ctor(basic_ostream_char *this,
2900         basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
2901 {
2902     basic_ios_char *base;
2903
2904     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
2905
2906     if(virt_init) {
2907         this->vbtable = basic_ostream_char_vbtable;
2908         base = basic_ostream_char_get_basic_ios(this);
2909         basic_ios_char_ctor(base);
2910     }else {
2911         base = basic_ostream_char_get_basic_ios(this);
2912     }
2913
2914     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
2915     basic_ios_char_init(base, strbuf, isstd);
2916     return this;
2917 }
2918
2919 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
2920 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
2921 DEFINE_THISCALL_WRAPPER(basic_ostream_char_uninitialized, 16)
2922 basic_ostream_char* __thiscall basic_ostream_char_uninitialized(basic_ostream_char *this,
2923         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
2924 {
2925     basic_ios_char *base;
2926
2927     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
2928
2929     if(virt_init) {
2930         this->vbtable = basic_ostream_char_vbtable;
2931         base = basic_ostream_char_get_basic_ios(this);
2932         basic_ios_char_ctor(base);
2933     }else {
2934         base = basic_ostream_char_get_basic_ios(this);
2935     }
2936
2937     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
2938     if(addstd)
2939         ios_base_Addstd(&base->base);
2940     return this;
2941 }
2942
2943 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
2944 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
2945 DEFINE_THISCALL_WRAPPER(basic_ostream_char_dtor, 4)
2946 void __thiscall basic_ostream_char_dtor(basic_ostream_char *this)
2947 {
2948     /* don't destroy virtual base here */
2949     TRACE("(%p)\n", this);
2950 }
2951
2952 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
2953 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
2954 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vbase_dtor, 4)
2955 void __thiscall basic_ostream_char_vbase_dtor(basic_ostream_char *this)
2956 {
2957     TRACE("(%p)\n", this);
2958     basic_ostream_char_dtor(this);
2959     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(this));
2960 }
2961
2962 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ostream_char_vector_dtor, 8)
2963 basic_ostream_char* __thiscall MSVCP_basic_ostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
2964 {
2965     basic_ostream_char *this = (basic_ostream_char *)((char*)base - basic_ostream_char_vbtable[1] + basic_ostream_char_vbtable[0]);
2966
2967     TRACE("(%p %x)\n", this, flags);
2968
2969     if(flags & 2) {
2970         /* we have an array, with the number of elements stored before the first object */
2971         int i, *ptr = (int *)this-1;
2972
2973         for(i=*ptr-1; i>=0; i--)
2974             basic_ostream_char_vbase_dtor(this+i);
2975         MSVCRT_operator_delete(ptr);
2976     } else {
2977         basic_ostream_char_vbase_dtor(this);
2978         if(flags & 1)
2979             MSVCRT_operator_delete(this);
2980     }
2981
2982     return this;
2983 }
2984
2985 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
2986 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
2987 DEFINE_THISCALL_WRAPPER(basic_ostream_char_flush, 4)
2988 basic_ostream_char* __thiscall basic_ostream_char_flush(basic_ostream_char *this)
2989 {
2990     /* this function is not matching C++ specification */
2991     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
2992
2993     TRACE("(%p)\n", this);
2994
2995     if(basic_ios_char_rdbuf_get(base) && ios_base_good(&base->base)
2996             && basic_streambuf_char_pubsync(basic_ios_char_rdbuf_get(base))==-1)
2997         basic_ios_char_setstate(base, IOSTATE_badbit);
2998     return this;
2999 }
3000
3001 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
3002 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
3003 DEFINE_THISCALL_WRAPPER(basic_ostream_char__Osfx, 4)
3004 void __thiscall basic_ostream_char__Osfx(basic_ostream_char *this)
3005 {
3006     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
3007
3008     TRACE("(%p)\n", this);
3009
3010     if(base->base.fmtfl & FMTFLAG_unitbuf)
3011         basic_ostream_char_flush(this);
3012 }
3013
3014 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
3015 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
3016 DEFINE_THISCALL_WRAPPER(basic_ostream_char_osfx, 4)
3017 void __thiscall basic_ostream_char_osfx(basic_ostream_char *this)
3018 {
3019     TRACE("(%p)\n", this);
3020     basic_ostream_char__Osfx(this);
3021 }
3022
3023 static BOOL basic_ostream_char_sentry_create(basic_ostream_char *ostr)
3024 {
3025     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
3026
3027     if(basic_ios_char_rdbuf_get(base))
3028         basic_streambuf_char__Lock(base->strbuf);
3029
3030     if(ios_base_good(&base->base) && base->stream)
3031         basic_ostream_char_flush(base->stream);
3032
3033     return ios_base_good(&base->base);
3034 }
3035
3036 static void basic_ostream_char_sentry_destroy(basic_ostream_char *ostr)
3037 {
3038     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
3039
3040     if(ios_base_good(&base->base) && !__uncaught_exception())
3041         basic_ostream_char_osfx(ostr);
3042
3043     if(basic_ios_char_rdbuf_get(base))
3044         basic_streambuf_char__Unlock(base->strbuf);
3045 }
3046
3047 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE_NXZ */
3048 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA_NXZ */
3049 DEFINE_THISCALL_WRAPPER(basic_ostream_char_opfx, 4)
3050 MSVCP_bool __thiscall basic_ostream_char_opfx(basic_ostream_char *this)
3051 {
3052     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
3053
3054     TRACE("(%p)\n", this);
3055
3056     if(ios_base_good(&base->base) && base->stream)
3057         basic_ostream_char_flush(base->stream);
3058     return ios_base_good(&base->base);
3059 }
3060
3061 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
3062 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
3063 DEFINE_THISCALL_WRAPPER(basic_ostream_char_put, 8)
3064 basic_ostream_char* __thiscall basic_ostream_char_put(basic_ostream_char *this, char ch)
3065 {
3066     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
3067
3068     TRACE("(%p %c)\n", this, ch);
3069
3070     if(!basic_ostream_char_sentry_create(this)
3071             || basic_streambuf_char_sputc(base->strbuf, ch)==EOF) {
3072         basic_ostream_char_sentry_destroy(this);
3073         basic_ios_char_setstate(base, IOSTATE_badbit);
3074         return this;
3075     }
3076
3077     basic_ostream_char_sentry_destroy(this);
3078     return this;
3079 }
3080
3081 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
3082 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
3083 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp, 12)
3084 basic_ostream_char* __thiscall basic_ostream_char_seekp(basic_ostream_char *this, streamoff off, int way)
3085 {
3086     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
3087
3088     TRACE("(%p %ld %d)\n", this, off, way);
3089
3090     if(!ios_base_fail(&base->base)) {
3091         fpos_int seek;
3092
3093         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
3094                 &seek, off, way, OPENMODE_out);
3095         if(seek.off==0 && seek.pos==-1 && seek.state==0)
3096             basic_ios_char_setstate(base, IOSTATE_failbit);
3097     }
3098     return this;
3099 }
3100
3101 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
3102 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
3103 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp_fpos, 28)
3104 basic_ostream_char* __thiscall basic_ostream_char_seekp_fpos(basic_ostream_char *this, fpos_int pos)
3105 {
3106     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
3107
3108     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
3109
3110     if(!ios_base_fail(&base->base)) {
3111         fpos_int seek;
3112
3113         basic_streambuf_char_pubseekpos(basic_ios_char_rdbuf_get(base),
3114                 &seek, pos, OPENMODE_out);
3115         if(seek.off==0 && seek.pos==-1 && seek.state==0)
3116             basic_ios_char_setstate(base, IOSTATE_failbit);
3117     }
3118     return this;
3119 }
3120
3121 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
3122 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
3123 DEFINE_THISCALL_WRAPPER(basic_ostream_char_tellp, 8)
3124 fpos_int* __thiscall basic_ostream_char_tellp(basic_ostream_char *this, fpos_int *ret)
3125 {
3126     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
3127
3128     TRACE("(%p)\n", this);
3129
3130     if(!ios_base_fail(&base->base)) {
3131         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
3132                 ret, 0, SEEKDIR_cur, OPENMODE_out);
3133     }else {
3134         ret->off = 0;
3135         ret->pos = -1;
3136         ret->state = 0;
3137     }
3138     return ret;
3139 }
3140
3141 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@PBDH@Z */
3142 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEBD_J@Z */
3143 DEFINE_THISCALL_WRAPPER(basic_ostream_char_write, 12)
3144 basic_ostream_char* __thiscall basic_ostream_char_write(basic_ostream_char *this, const char *str, streamsize count)
3145 {
3146     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
3147
3148     TRACE("(%p %s %ld)\n", this, debugstr_a(str), count);
3149
3150     if(!basic_ostream_char_sentry_create(this)
3151             || basic_streambuf_char_sputn(base->strbuf, str, count)!=count) {
3152         basic_ostream_char_sentry_destroy(this);
3153         basic_ios_char_setstate(base, IOSTATE_badbit);
3154         return this;
3155     }
3156
3157     basic_ostream_char_sentry_destroy(this);
3158     return this;
3159 }
3160
3161 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@F@Z */
3162 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@F@Z */
3163 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_short, 8)
3164 basic_ostream_char* __thiscall basic_ostream_char_print_short(basic_ostream_char *this, short val)
3165 {
3166     FIXME("(%p %d) stub\n", this, val);
3167     return NULL;
3168 }
3169
3170 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@G@Z */
3171 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@G@Z */
3172 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ushort, 8)
3173 basic_ostream_char* __thiscall basic_ostream_char_print_ushort(basic_ostream_char *this, unsigned short val)
3174 {
3175     FIXME("(%p %d) stub\n", this, val);
3176     return NULL;
3177 }
3178
3179 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z */
3180 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z */
3181 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int, 8)
3182 basic_ostream_char* __thiscall basic_ostream_char_print_int(basic_ostream_char *this, int val)
3183 {
3184     FIXME("(%p %d) stub\n", this, val);
3185     return NULL;
3186 }
3187
3188 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z */
3189 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@I@Z */
3190 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint, 8)
3191 basic_ostream_char* __thiscall basic_ostream_char_print_uint(basic_ostream_char *this, unsigned int val)
3192 {
3193     FIXME("(%p %d) stub\n", this, val);
3194     return NULL;
3195 }
3196
3197 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z */
3198 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z */
3199 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_long, 8)
3200 basic_ostream_char* __thiscall basic_ostream_char_print_long(basic_ostream_char *this, LONG val)
3201 {
3202     FIXME("(%p %d) stub\n", this, val);
3203     return NULL;
3204 }
3205
3206 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z */
3207 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z */
3208 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ulong, 8)
3209 basic_ostream_char* __thiscall basic_ostream_char_print_ulong(basic_ostream_char *this, ULONG val)
3210 {
3211     FIXME("(%p %d) stub\n", this, val);
3212     return NULL;
3213 }
3214
3215 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z */
3216 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z */
3217 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_float, 8)
3218 basic_ostream_char* __thiscall basic_ostream_char_print_float(basic_ostream_char *this, float val)
3219 {
3220     FIXME("(%p %f) stub\n", this, val);
3221     return NULL;
3222 }
3223
3224 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z */
3225 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z */
3226 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_double, 12)
3227 basic_ostream_char* __thiscall basic_ostream_char_print_double(basic_ostream_char *this, double val)
3228 {
3229     FIXME("(%p %lf) stub\n", this, val);
3230     return NULL;
3231 }
3232
3233 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
3234 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
3235 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_streambuf, 8)
3236 basic_ostream_char* __thiscall basic_ostream_char_print_streambuf(basic_ostream_char *this, basic_streambuf_char *val)
3237 {
3238     FIXME("(%p %p) stub\n", this, val);
3239     return NULL;
3240 }
3241
3242 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z */
3243 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z */
3244 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ptr, 8)
3245 basic_ostream_char* __thiscall basic_ostream_char_print_ptr(basic_ostream_char *this, const void *val)
3246 {
3247     FIXME("(%p %p) stub\n", this, val);
3248     return NULL;
3249 }
3250
3251 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_J@Z */
3252 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_J@Z */
3253 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int64, 12)
3254 basic_ostream_char* __thiscall basic_ostream_char_print_int64(basic_ostream_char *this, __int64 val)
3255 {
3256     FIXME("(%p) stub\n", this);
3257     return NULL;
3258 }
3259
3260 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_K@Z */
3261 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_K@Z */
3262 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint64, 12)
3263 basic_ostream_char* __thiscall basic_ostream_char_print_uint64(basic_ostream_char *this, unsigned __int64 val)
3264 {
3265     FIXME("(%p) stub\n", this);
3266     return NULL;
3267 }
3268
3269 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_N@Z */
3270 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_N@Z */
3271 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_bool, 8)
3272 basic_ostream_char* __thiscall basic_ostream_char_print_bool(basic_ostream_char *this, MSVCP_bool val)
3273 {
3274     FIXME("(%p %x) stub\n", this, val);
3275     return NULL;
3276 }
3277
3278 /* Caution: basic_istream uses virtual inheritance. */
3279 static inline basic_ios_char* basic_istream_char_get_basic_ios(basic_istream_char *this)
3280 {
3281     return (basic_ios_char*)((char*)this+this->vbtable[1]);
3282 }
3283
3284 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
3285 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
3286 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_init, 20)
3287 basic_istream_char* __thiscall basic_istream_char_ctor_init(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
3288 {
3289     basic_ios_char *base;
3290
3291     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
3292
3293     if(virt_init) {
3294         this->vbtable = basic_istream_char_vbtable;
3295         base = basic_istream_char_get_basic_ios(this);
3296         basic_ios_char_ctor(base);
3297     }else {
3298         base = basic_istream_char_get_basic_ios(this);
3299     }
3300
3301     base->base.vtable = &MSVCP_basic_istream_char_vtable;
3302     this->count = 0;
3303     if(!noinit)
3304         basic_ios_char_init(base, strbuf, isstd);
3305     return this;
3306 }
3307
3308 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
3309 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
3310 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor, 16)
3311 basic_istream_char* __thiscall basic_istream_char_ctor(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
3312 {
3313     return basic_istream_char_ctor_init(this, strbuf, isstd, FALSE, virt_init);
3314 }
3315
3316 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
3317 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
3318 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_uninitialized, 12)
3319 basic_istream_char* __thiscall basic_istream_char_ctor_uninitialized(basic_istream_char *this, int uninitialized, MSVCP_bool virt_init)
3320 {
3321     basic_ios_char *base;
3322
3323     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
3324
3325     if(virt_init) {
3326         this->vbtable = basic_istream_char_vbtable;
3327         base = basic_istream_char_get_basic_ios(this);
3328         basic_ios_char_ctor(base);
3329     }else {
3330         base = basic_istream_char_get_basic_ios(this);
3331     }
3332
3333     base->base.vtable = &MSVCP_basic_istream_char_vtable;
3334     ios_base_Addstd(&base->base);
3335     return this;
3336 }
3337
3338 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UAE@XZ */
3339 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
3340 DEFINE_THISCALL_WRAPPER(basic_istream_char_dtor, 4)
3341 void __thiscall basic_istream_char_dtor(basic_istream_char *this)
3342 {
3343     /* don't destroy virtual base here */
3344     TRACE("(%p)\n", this);
3345 }
3346
3347 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
3348 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
3349 DEFINE_THISCALL_WRAPPER(basic_istream_char_vbase_dtor, 4)
3350 void __thiscall basic_istream_char_vbase_dtor(basic_istream_char *this)
3351 {
3352     TRACE("(%p)\n", this);
3353     basic_istream_char_dtor(this);
3354     basic_ios_char_dtor(basic_istream_char_get_basic_ios(this));
3355 }
3356
3357 DEFINE_THISCALL_WRAPPER(MSVCP_basic_istream_char_vector_dtor, 8)
3358 basic_istream_char* __thiscall MSVCP_basic_istream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
3359 {
3360     basic_istream_char *this = (basic_istream_char *)((char*)base - basic_istream_char_vbtable[1] + basic_istream_char_vbtable[0]);
3361
3362     TRACE("(%p %x)\n", this, flags);
3363
3364     if(flags & 2) {
3365         /* we have an array, with the number of elements stored before the first object */
3366         int i, *ptr = (int *)this-1;
3367
3368         for(i=*ptr-1; i>=0; i--)
3369             basic_istream_char_vbase_dtor(this+i);
3370         MSVCRT_operator_delete(ptr);
3371     } else {
3372         basic_istream_char_vbase_dtor(this);
3373         if(flags & 1)
3374             MSVCRT_operator_delete(this);
3375     }
3376
3377     return this;
3378 }
3379
3380 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
3381 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
3382 DEFINE_THISCALL_WRAPPER(basic_istream_char__Ipfx, 8)
3383 MSVCP_bool __thiscall basic_istream_char__Ipfx(basic_istream_char *this, MSVCP_bool noskip)
3384 {
3385     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
3386
3387     TRACE("(%p %d)\n", this, noskip);
3388
3389     if(!ios_base_good(&base->base)) {
3390         basic_ios_char_setstate(base, IOSTATE_failbit);
3391         return FALSE;
3392     }
3393
3394     if(basic_ios_char_tie_get(base))
3395         basic_ostream_char_flush(basic_ios_char_tie_get(base));
3396
3397     if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
3398         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
3399         int ch;
3400
3401         for(ch = basic_streambuf_char_sgetc(strbuf); ;
3402                 ch = basic_streambuf_char_snextc(strbuf)) {
3403             if(ch == EOF) {
3404                 basic_ios_char_setstate(base, IOSTATE_eofbit);
3405                 return FALSE;
3406             }
3407
3408             /* TODO: use locale class instead of isspace */
3409             if(!isspace(ch))
3410                 break;
3411         }
3412     }
3413
3414     return TRUE;
3415 }
3416
3417 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
3418 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
3419 DEFINE_THISCALL_WRAPPER(basic_istream_char_ipfx, 8)
3420 MSVCP_bool __thiscall basic_istream_char_ipfx(basic_istream_char *this, MSVCP_bool noskip)
3421 {
3422     return basic_istream_char__Ipfx(this, noskip);
3423 }
3424
3425 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
3426 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
3427 DEFINE_THISCALL_WRAPPER(basic_istream_char_isfx, 4)
3428 void __thiscall basic_istream_char_isfx(basic_istream_char *this)
3429 {
3430     TRACE("(%p)\n", this);
3431 }
3432
3433 static BOOL basic_istream_char_sentry_create(basic_istream_char *istr, MSVCP_bool noskip)
3434 {
3435     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
3436
3437     if(basic_ios_char_rdbuf_get(base))
3438         basic_streambuf_char__Lock(base->strbuf);
3439
3440     return basic_istream_char_ipfx(istr, noskip);
3441 }
3442
3443 static void basic_istream_char_sentry_destroy(basic_istream_char *istr)
3444 {
3445     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
3446
3447     if(basic_ios_char_rdbuf_get(base))
3448         basic_streambuf_char__Unlock(base->strbuf);
3449 }
3450
3451 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QBEHXZ */
3452 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QEBA_JXZ */
3453 DEFINE_THISCALL_WRAPPER(basic_istream_char_gcount, 4)
3454 int __thiscall basic_istream_char_gcount(const basic_istream_char *this)
3455 {
3456     TRACE("(%p)\n", this);
3457     return this->count;
3458 }
3459
3460 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
3461 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
3462 DEFINE_THISCALL_WRAPPER(basic_istream_char_get, 4)
3463 int __thiscall basic_istream_char_get(basic_istream_char *this)
3464 {
3465     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
3466     int ret;
3467
3468     TRACE("(%p)\n", this);
3469
3470     this->count = 0;
3471
3472     if(!basic_istream_char_sentry_create(this, TRUE)) {
3473         basic_istream_char_sentry_destroy(this);
3474         return EOF;
3475     }
3476
3477     ret = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(base));
3478     basic_istream_char_sentry_destroy(this);
3479     if(ret == EOF)
3480         basic_ios_char_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
3481     else
3482         this->count++;
3483
3484     return ret;
3485 }
3486
3487 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAD@Z */
3488 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAD@Z */
3489 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_ch, 8)
3490 basic_istream_char* __thiscall basic_istream_char_get_ch(basic_istream_char *this, char *ch)
3491 {
3492     int ret;
3493
3494     TRACE("(%p %p)\n", this, ch);
3495
3496     ret = basic_istream_char_get(this);
3497     if(ret != EOF)
3498         *ch = (char)ret;
3499     return this;
3500 }
3501
3502 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
3503 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
3504 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str_delim, 16)
3505 basic_istream_char* __thiscall basic_istream_char_get_str_delim(basic_istream_char *this, char *str, streamsize count, char delim)
3506 {
3507     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
3508     int ch = delim;
3509
3510     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
3511
3512     this->count = 0;
3513
3514     if(basic_istream_char_sentry_create(this, TRUE)) {
3515         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
3516
3517         for(ch = basic_streambuf_char_sgetc(strbuf); count>1;
3518                 ch = basic_streambuf_char_snextc(strbuf)) {
3519             if(ch==EOF || ch==delim)
3520                 break;
3521
3522             *str++ = ch;
3523             this->count++;
3524             count--;
3525         }
3526     }
3527     basic_istream_char_sentry_destroy(this);
3528
3529     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
3530             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
3531     if(count > 0)
3532         *str = 0;
3533     return this;
3534 }
3535
3536 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
3537 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
3538 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str, 12)
3539 basic_istream_char* __thiscall basic_istream_char_get_str(basic_istream_char *this, char *str, streamsize count)
3540 {
3541     return basic_istream_char_get_str_delim(this, str, count, '\n');
3542 }
3543
3544 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
3545 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
3546 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf_delim, 12)
3547 basic_istream_char* __thiscall basic_istream_char_get_streambuf_delim(basic_istream_char *this, basic_streambuf_char *strbuf, char delim)
3548 {
3549     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
3550     int ch = delim;
3551
3552     TRACE("(%p %p %c)\n", this, strbuf, delim);
3553
3554     this->count = 0;
3555
3556     if(basic_istream_char_sentry_create(this, TRUE)) {
3557         basic_streambuf_char *strbuf_read = basic_ios_char_rdbuf_get(base);
3558
3559         for(ch = basic_streambuf_char_sgetc(strbuf_read); ;
3560                 ch = basic_streambuf_char_snextc(strbuf_read)) {
3561             if(ch==EOF || ch==delim)
3562                 break;
3563
3564             if(basic_streambuf_char_sputc(strbuf, ch) == EOF)
3565                 break;
3566             this->count++;
3567         }
3568     }
3569     basic_istream_char_sentry_destroy(this);
3570
3571     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
3572             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
3573     return this;
3574 }
3575
3576 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
3577 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
3578 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf, 8)
3579 basic_istream_char* __thiscall basic_istream_char_get_streambuf(basic_istream_char *this, basic_streambuf_char *strbuf)
3580 {
3581     return basic_istream_char_get_streambuf_delim(this, strbuf, '\n');
3582 }
3583
3584 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
3585 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
3586 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline_delim, 16)
3587 basic_istream_char* __thiscall basic_istream_char_getline_delim(basic_istream_char *this, char *str, streamsize count, char delim)
3588 {
3589     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
3590     int ch = delim;
3591
3592     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
3593
3594     this->count = 0;
3595
3596     if(basic_istream_char_sentry_create(this, TRUE) && count>0) {
3597         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
3598
3599         while(count > 1) {
3600             ch = basic_streambuf_char_sbumpc(strbuf);
3601
3602             if(ch==EOF || ch==delim)
3603                 break;
3604
3605             *str++ = ch;
3606             this->count++;
3607             count--;
3608         }
3609
3610         if(ch == delim)
3611             this->count++;
3612         else if(ch != EOF) {
3613             ch = basic_streambuf_char_sgetc(strbuf);
3614
3615             if(ch == delim) {
3616                 basic_streambuf_char__Gninc(strbuf);
3617                 this->count++;
3618             }
3619         }
3620     }
3621     basic_istream_char_sentry_destroy(this);
3622
3623     basic_ios_char_setstate(base, (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
3624             (!this->count || (ch!=delim && ch!=EOF) ? IOSTATE_failbit : IOSTATE_goodbit));
3625     if(count > 0)
3626         *str = 0;
3627     return this;
3628 }
3629
3630 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
3631 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
3632 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline, 12)
3633 basic_istream_char* __thiscall basic_istream_char_getline(basic_istream_char *this, char *str, streamsize count)
3634 {
3635     return basic_istream_char_getline_delim(this, str, count, '\n');
3636 }
3637
3638 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z */
3639 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
3640 DEFINE_THISCALL_WRAPPER(basic_istream_char_ignore, 12)
3641 basic_istream_char* __thiscall basic_istream_char_ignore(basic_istream_char *this, streamsize count, int delim)
3642 {
3643     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
3644     int ch = delim;
3645
3646     TRACE("(%p %ld %d)\n", this, count, delim);
3647
3648     this->count = 0;
3649
3650     if(basic_istream_char_sentry_create(this, TRUE)) {
3651         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
3652
3653         while(count > 0) {
3654             ch = basic_streambuf_char_sbumpc(strbuf);
3655
3656             if(ch==EOF || ch==delim)
3657                 break;
3658
3659             this->count++;
3660             if(count != INT_MAX)
3661                 count--;
3662         }
3663     }
3664     basic_istream_char_sentry_destroy(this);
3665
3666     if(ch == EOF)
3667         basic_ios_char_setstate(base, IOSTATE_eofbit);
3668     return this;
3669 }
3670
3671 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
3672 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
3673 DEFINE_THISCALL_WRAPPER(basic_istream_char_peek, 4)
3674 int __thiscall basic_istream_char_peek(basic_istream_char *this)
3675 {
3676     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
3677     int ret = EOF;
3678
3679     TRACE("(%p)\n", this);
3680
3681     this->count = 0;
3682
3683     if(basic_istream_char_sentry_create(this, TRUE))
3684         ret = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
3685     basic_istream_char_sentry_destroy(this);
3686     return ret;
3687 }
3688
3689 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADIH@Z */
3690 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_K_J@Z */
3691 DEFINE_THISCALL_WRAPPER(basic_istream_char__Read_s, 16)
3692 basic_istream_char* __thiscall basic_istream_char__Read_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
3693 {
3694     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
3695     IOSB_iostate state = IOSTATE_goodbit;
3696
3697     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
3698
3699     if(basic_istream_char_sentry_create(this, TRUE)) {
3700         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
3701
3702         this->count = basic_streambuf_char__Sgetn_s(strbuf, str, size, count);
3703         if(this->count != count)
3704             state |= IOSTATE_failbit | IOSTATE_eofbit;
3705     }else {
3706         this->count = 0;
3707     }
3708     basic_istream_char_sentry_destroy(this);
3709
3710     basic_ios_char_setstate(base, state);
3711     return this;
3712 }
3713
3714 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
3715 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
3716 DEFINE_THISCALL_WRAPPER(basic_istream_char_read, 12)
3717 basic_istream_char* __thiscall basic_istream_char_read(basic_istream_char *this, char *str, streamsize count)
3718 {
3719     return basic_istream_char__Read_s(this, str, count, count);
3720 }
3721
3722 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
3723 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
3724 DEFINE_THISCALL_WRAPPER(basic_istream_char__Readsome_s, 16)
3725 streamsize __thiscall basic_istream_char__Readsome_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
3726 {
3727     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
3728     IOSB_iostate state = IOSTATE_goodbit;
3729
3730     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
3731
3732     this->count = 0;
3733
3734     if(basic_istream_char_sentry_create(this, TRUE)) {
3735         streamsize avail = basic_streambuf_char_in_avail(basic_ios_char_rdbuf_get(base));
3736         if(avail > count)
3737             avail = count;
3738
3739         if(avail == -1)
3740             state |= IOSTATE_eofbit;
3741         else if(avail > 0)
3742             basic_istream_char__Read_s(this, str, size, avail);
3743     }else {
3744         state |= IOSTATE_failbit;
3745     }
3746     basic_istream_char_sentry_destroy(this);
3747
3748     basic_ios_char_setstate(base, state);
3749     return this->count;
3750 }
3751
3752 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
3753 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
3754 DEFINE_THISCALL_WRAPPER(basic_istream_char_readsome, 12)
3755 streamsize __thiscall basic_istream_char_readsome(basic_istream_char *this, char *str, streamsize count)
3756 {
3757     return basic_istream_char__Readsome_s(this, str, count, count);
3758 }
3759
3760 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
3761 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
3762 DEFINE_THISCALL_WRAPPER(basic_istream_char_putback, 8)
3763 basic_istream_char* __thiscall basic_istream_char_putback(basic_istream_char *this, char ch)
3764 {
3765     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
3766     IOSB_iostate state = IOSTATE_goodbit;
3767
3768     TRACE("(%p %c)\n", this, ch);
3769
3770     this->count = 0;
3771
3772     if(basic_istream_char_sentry_create(this, TRUE)) {
3773         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
3774
3775         if(!ios_base_good(&base->base))
3776             state |= IOSTATE_failbit;
3777         else if(!strbuf || basic_streambuf_char_sputbackc(strbuf, ch)==EOF)
3778             state |= IOSTATE_badbit;
3779     }
3780     basic_istream_char_sentry_destroy(this);
3781
3782     basic_ios_char_setstate(base, state);
3783     return this;
3784 }
3785
3786 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
3787 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
3788 DEFINE_THISCALL_WRAPPER(basic_istream_char_unget, 4)
3789 basic_istream_char* __thiscall basic_istream_char_unget(basic_istream_char *this)
3790 {
3791     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
3792     IOSB_iostate state = IOSTATE_goodbit;
3793
3794     TRACE("(%p)\n", this);
3795
3796     this->count = 0;
3797
3798     if(basic_istream_char_sentry_create(this, TRUE)) {
3799         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
3800
3801         if(!ios_base_good(&base->base))
3802             state |= IOSTATE_failbit;
3803         else if(!strbuf || basic_streambuf_char_sungetc(strbuf)==EOF)
3804             state |= IOSTATE_badbit;
3805     }
3806     basic_istream_char_sentry_destroy(this);
3807
3808     basic_ios_char_setstate(base, state);
3809     return this;
3810 }
3811
3812 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
3813 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
3814 DEFINE_THISCALL_WRAPPER(basic_istream_char_sync, 4)
3815 int __thiscall basic_istream_char_sync(basic_istream_char *this)
3816 {
3817     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
3818     basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
3819
3820     TRACE("(%p)\n", this);
3821
3822     if(!strbuf)
3823         return -1;
3824
3825     if(basic_istream_char_sentry_create(this, TRUE)) {
3826         if(basic_streambuf_char_pubsync(strbuf) != -1) {
3827             basic_istream_char_sentry_destroy(this);
3828             return 0;
3829         }
3830     }
3831     basic_istream_char_sentry_destroy(this);
3832
3833     basic_ios_char_setstate(base, IOSTATE_badbit);
3834     return -1;
3835 }
3836
3837 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
3838 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
3839 DEFINE_THISCALL_WRAPPER(basic_istream_char_tellg, 8)
3840 fpos_int* __thiscall basic_istream_char_tellg(basic_istream_char *this, fpos_int *ret)
3841 {
3842     TRACE("(%p %p)\n", this, ret);
3843
3844     if(basic_istream_char_sentry_create(this, TRUE)) {
3845         basic_ios_char *base = basic_istream_char_get_basic_ios(this);
3846         if(!ios_base_fail(&base->base)) {
3847             basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
3848                     ret, 0, SEEKDIR_cur, OPENMODE_in);
3849             basic_istream_char_sentry_destroy(this);
3850
3851             if(ret->off==0 && ret->pos==-1 && ret->state==0)
3852                 basic_ios_char_setstate(base, IOSTATE_failbit);
3853             return ret;
3854         }
3855     }
3856     basic_istream_char_sentry_destroy(this);
3857
3858     ret->off = 0;
3859     ret->pos = -1;
3860     ret->state = 0;
3861     return ret;
3862 }
3863
3864 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
3865 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
3866 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg, 12)
3867 basic_istream_char* __thiscall basic_istream_char_seekg(basic_istream_char *this, streamoff off, int dir)
3868 {
3869     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
3870
3871     TRACE("(%p %ld %d)\n", this, off, dir);
3872
3873     if(basic_istream_char_sentry_create(this, TRUE)) {
3874         if(!ios_base_fail(&base->base)) {
3875             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
3876             fpos_int ret;
3877
3878             basic_streambuf_char_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
3879             basic_istream_char_sentry_destroy(this);
3880
3881             if(ret.off==0 && ret.pos==-1 && ret.state==0)
3882                 basic_ios_char_setstate(base, IOSTATE_failbit);
3883             else
3884                 basic_ios_char_clear(base, IOSTATE_goodbit);
3885             return this;
3886         }
3887     }
3888     basic_istream_char_sentry_destroy(this);
3889
3890     basic_ios_char_setstate(base, IOSTATE_failbit);
3891     return this;
3892 }
3893
3894 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
3895 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
3896 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg_fpos, 28)
3897 basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char *this, fpos_int pos)
3898 {
3899     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
3900
3901     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
3902
3903     if(basic_istream_char_sentry_create(this, TRUE)) {
3904         if(!ios_base_fail(&base->base)) {
3905             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
3906             fpos_int ret;
3907
3908             basic_streambuf_char_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
3909             basic_istream_char_sentry_destroy(this);
3910
3911             if(ret.off==0 && ret.pos==-1 && ret.state==0)
3912                 basic_ios_char_setstate(base, IOSTATE_failbit);
3913             else
3914                 basic_ios_char_clear(base, IOSTATE_goodbit);
3915             return this;
3916         }
3917     }
3918     basic_istream_char_sentry_destroy(this);
3919
3920     basic_ios_char_setstate(base, IOSTATE_failbit);
3921     return this;
3922 }
3923
3924 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAF@Z */
3925 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAF@Z */
3926 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_short, 8)
3927 basic_istream_char* __thiscall basic_istream_char_read_short(basic_istream_char *this, short *arg1)
3928 {
3929     FIXME("(%p %p) stub\n", this, arg1);
3930     return NULL;
3931 }
3932
3933 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAG@Z */
3934 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAG@Z */
3935 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ushort, 8)
3936 basic_istream_char* __thiscall basic_istream_char_read_ushort(basic_istream_char *this, unsigned short *arg1)
3937 {
3938     FIXME("(%p %p) stub\n", this, arg1);
3939     return NULL;
3940 }
3941
3942 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z */
3943 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAH@Z */
3944 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int, 8)
3945 basic_istream_char* __thiscall basic_istream_char_read_int(basic_istream_char *this, int *arg1)
3946 {
3947     FIXME("(%p %p) stub\n", this, arg1);
3948     return NULL;
3949 }
3950
3951 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAI@Z */
3952 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAI@Z */
3953 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint, 8)
3954 basic_istream_char* __thiscall basic_istream_char_read_uint(basic_istream_char *this, unsigned int *arg1)
3955 {
3956     FIXME("(%p %p) stub\n", this, arg1);
3957     return NULL;
3958 }
3959
3960 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAJ@Z */
3961 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAJ@Z */
3962 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_long, 8)
3963 basic_istream_char* __thiscall basic_istream_char_read_long(basic_istream_char *this, LONG *arg1)
3964 {
3965     FIXME("(%p %p) stub\n", this, arg1);
3966     return NULL;
3967 }
3968
3969 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAK@Z */
3970 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAK@Z */
3971 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ulong, 8)
3972 basic_istream_char* __thiscall basic_istream_char_read_ulong(basic_istream_char *this, ULONG *arg1)
3973 {
3974     FIXME("(%p %p) stub\n", this, arg1);
3975     return NULL;
3976 }
3977
3978 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z */
3979 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAM@Z */
3980 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_float, 8)
3981 basic_istream_char* __thiscall basic_istream_char_read_float(basic_istream_char *this, float *arg1)
3982 {
3983     FIXME("(%p %p) stub\n", this, arg1);
3984     return NULL;
3985 }
3986
3987 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z */
3988 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z */
3989 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_double, 8)
3990 basic_istream_char* __thiscall basic_istream_char_read_double(basic_istream_char *this, double *arg1)
3991 {
3992     FIXME("(%p %p) stub\n", this, arg1);
3993     return NULL;
3994 }
3995
3996 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAO@Z */
3997 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAO@Z */
3998 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ldouble, 8)
3999 basic_istream_char* __thiscall basic_istream_char_read_ldouble(basic_istream_char *this, long double *arg1)
4000 {
4001     FIXME("(%p %p) stub\n", this, arg1);
4002     return NULL;
4003 }
4004
4005 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAPAX@Z */
4006 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
4007 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ptr, 8)
4008 basic_istream_char* __thiscall basic_istream_char_read_ptr(basic_istream_char *this, void **arg1)
4009 {
4010     FIXME("(%p %p) stub\n", this, arg1);
4011     return NULL;
4012 }
4013
4014 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_J@Z */
4015 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_J@Z */
4016 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int64, 8)
4017 basic_istream_char* __thiscall basic_istream_char_read_int64(basic_istream_char *this, __int64 *arg1)
4018 {
4019     FIXME("(%p %p) stub\n", this, arg1);
4020     return NULL;
4021 }
4022
4023 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z */
4024 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z */
4025 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint64, 8)
4026 basic_istream_char* __thiscall basic_istream_char_read_uint64(basic_istream_char *this, unsigned __int64 *arg1)
4027 {
4028     FIXME("(%p %p) stub\n", this, arg1);
4029     return NULL;
4030 }
4031
4032 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_N@Z */
4033 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_N@Z */
4034 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_bool, 8)
4035 basic_istream_char* __thiscall basic_istream_char_read_bool(basic_istream_char *this, MSVCP_bool *arg1)
4036 {
4037     FIXME("(%p %p) stub\n", this, arg1);
4038     return NULL;
4039 }