wininet/tests: Add even more optional COOKIE_SENT messages.
[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
24 #include "msvcp90.h"
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(msvcp90);
29
30 typedef enum {
31     IOSTATE_goodbit   = 0x00,
32     IOSTATE_eofbit    = 0x01,
33     IOSTATE_failbit   = 0x02,
34     IOSTATE_badbit    = 0x04,
35     IOSTATE__Hardfail = 0x10,
36     IOSTATE_mask      = 0x17
37 } IOSB_iostate;
38
39 typedef enum {
40     FMTFLAG_skipws      = 0x0001,
41     FMTFLAG_unitbuf     = 0x0002,
42     FMTFLAG_uppercase   = 0x0004,
43     FMTFLAG_showbase    = 0x0008,
44     FMTFLAG_showpoint   = 0x0010,
45     FMTFLAG_showpos     = 0x0020,
46     FMTFLAG_left        = 0x0040,
47     FMTFLAG_right       = 0x0080,
48     FMTFLAG_internal    = 0x0100,
49     FMTFLAG_dec         = 0x0200,
50     FMTFLAG_oct         = 0x0400,
51     FMTFLAG_hex         = 0x0800,
52     FMTFLAG_scientific  = 0x1000,
53     FMTFLAG_fixed       = 0x2000,
54     FMTFLAG_hexfloat    = 0x3000,
55     FMTFLAG_boolalpha   = 0x4000,
56     FMTFLAG_stdio       = 0x8000,
57     FMTFLAG_adjustfield = FMTFLAG_left|FMTFLAG_right|FMTFLAG_internal,
58     FMTFLAG_basefield   = FMTFLAG_dec|FMTFLAG_oct|FMTFLAG_hex,
59     FMTFLAG_floadfield  = FMTFLAG_scientific|FMTFLAG_fixed,
60     FMTFLAG_mask        = 0xffff
61 } IOSB_fmtflags;
62
63 typedef struct _iosarray {
64     struct _iosarray *next;
65     int index;
66     int long_val;
67     void *ptr_val;
68 } IOS_BASE_iosarray;
69
70 typedef enum {
71     EVENT_erase_event,
72     EVENT_imbue_event,
73     EVENT_copyfmt_event
74 } IOS_BASE_event;
75
76 struct _ios_base;
77 typedef void (CDECL *IOS_BASE_event_callback)(IOS_BASE_event, struct _ios_base*, int);
78 typedef struct _fnarray {
79     struct _fnarray *next;
80     int index;
81     IOS_BASE_event_callback event_handler;
82 } IOS_BASE_fnarray;
83
84 /* ?_Index@ios_base@std@@0HA */
85 int ios_base_Index = 0;
86 /* ?_Sync@ios_base@std@@0_NA */
87 MSVCP_bool ios_base_Sync = FALSE;
88
89 typedef struct _ios_base {
90     const vtable_ptr *vtable;
91     MSVCP_size_t stdstr;
92     IOSB_iostate state;
93     IOSB_iostate except;
94     IOSB_fmtflags fmtfl;
95     MSVCP_size_t prec;
96     MSVCP_size_t wide;
97     IOS_BASE_iosarray *arr;
98     IOS_BASE_fnarray *calls;
99     locale *loc;
100 } ios_base;
101
102 typedef struct {
103     streamoff off;
104     __int64 DECLSPEC_ALIGN(8) pos;
105     int state;
106 } fpos_int;
107
108 static inline const char* debugstr_fpos_int(fpos_int *fpos)
109 {
110     return wine_dbg_sprintf("fpos(%lu %s %d)", fpos->off, wine_dbgstr_longlong(fpos->pos), fpos->state);
111 }
112
113 typedef struct {
114     const vtable_ptr *vtable;
115     mutex lock;
116     char *rbuf;
117     char *wbuf;
118     char **prbuf;
119     char **pwbuf;
120     char *rpos;
121     char *wpos;
122     char **prpos;
123     char **pwpos;
124     int rsize;
125     int wsize;
126     int *prsize;
127     int *pwsize;
128     locale *loc;
129 } basic_streambuf_char;
130
131 typedef struct {
132     const vtable_ptr *vtable;
133     mutex lock;
134     wchar_t *rbuf;
135     wchar_t *wbuf;
136     wchar_t **prbuf;
137     wchar_t **pwbuf;
138     wchar_t *rpos;
139     wchar_t *wpos;
140     wchar_t **prpos;
141     wchar_t **pwpos;
142     int rsize;
143     int wsize;
144     int *prsize;
145     int *pwsize;
146     locale *loc;
147 } basic_streambuf_wchar;
148
149 typedef struct {
150     ios_base base;
151     basic_streambuf_char *strbuf;
152     struct _basic_ostream_char *stream;
153     char fillch;
154 } basic_ios_char;
155
156 typedef struct {
157     ios_base base;
158     basic_streambuf_wchar *strbuf;
159     struct _basic_ostream_wchar *stream;
160     wchar_t fillch;
161 } basic_ios_wchar;
162
163 typedef struct _basic_ostream_char {
164     const int *vbtable;
165     basic_ios_char base;
166 } basic_ostream_char;
167
168 typedef struct _basic_ostream_wchar {
169     const int *vbtable;
170     basic_ios_char base;
171 } basic_ostream_wchar;
172
173 extern const vtable_ptr MSVCP_iosb_vtable;
174
175 /* ??_7ios_base@std@@6B@ */
176 extern const vtable_ptr MSVCP_ios_base_vtable;
177
178 /* ??_7?$basic_ios@DU?$char_traits@D@std@@@std@@6B@ */
179 extern const vtable_ptr MSVCP_basic_ios_char_vtable;
180
181 /* ??_7?$basic_ios@_WU?$char_traits@_W@std@@@std@@6B@ */
182 extern const vtable_ptr MSVCP_basic_ios_wchar_vtable;
183
184 /* ??_7?$basic_ios@GU?$char_traits@G@std@@@std@@6B@ */
185 extern const vtable_ptr MSVCP_basic_ios_short_vtable;
186
187 /* ??_7?$basic_streambuf@DU?$char_traits@D@std@@@std@@6B@ */
188 extern const vtable_ptr MSVCP_basic_streambuf_char_vtable;
189
190 /* ??_7?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@6B@ */
191 extern const vtable_ptr MSVCP_basic_streambuf_wchar_vtable;
192
193 /* ??_7?$basic_streambuf@GU?$char_traits@G@std@@@std@@6B@ */
194 extern const vtable_ptr MSVCP_basic_streambuf_short_vtable;
195
196 /* ??_7?$basic_ostream@DU?$char_traits@D@std@@@std@@6B@ */
197 extern const vtable_ptr MSVCP_basic_ostream_char_vtable;
198
199 DEFINE_RTTI_DATA(iosb, 0, 0, NULL, NULL, NULL, ".?AV?$_Iosb@H@std@@");
200 DEFINE_RTTI_DATA(ios_base, 0, 1, &iosb_rtti_base_descriptor, NULL, NULL, ".?AV?$_Iosb@H@std@@");
201 DEFINE_RTTI_DATA(basic_ios_char, 0, 2, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
202         NULL, ".?AV?$basic_ios@DU?$char_traits@D@std@@@std@@");
203 DEFINE_RTTI_DATA(basic_ios_wchar, 0, 2, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
204         NULL, ".?AV?$basic_ios@_WU?$char_traits@_W@std@@@std@@");
205 DEFINE_RTTI_DATA(basic_ios_short, 0, 2, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
206         NULL, ".?AV?$basic_ios@GU?$char_traits@G@std@@@std@@");
207 DEFINE_RTTI_DATA(basic_streambuf_char, 0, 0, NULL, NULL, NULL,
208         ".?AV?$basic_streambuf@DU?$char_traits@D@std@@@std@@");
209 DEFINE_RTTI_DATA(basic_streambuf_wchar, 0, 0, NULL, NULL, NULL,
210         ".?AV?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@");
211 DEFINE_RTTI_DATA(basic_streambuf_short, 0, 0, NULL, NULL, NULL,
212         ".?AV?$basic_streambuf@GU?$char_traits@G@std@@@std@@");
213 DEFINE_RTTI_DATA(basic_ostream_char, 4, 3, &basic_ios_char_rtti_base_descriptor, &ios_base_rtti_base_descriptor,
214         &iosb_rtti_base_descriptor, ".?AV?$basic_ostream@DU?$char_traits@D@std@@@std@@");
215
216 #ifndef __GNUC__
217 void __asm_dummy_vtables(void) {
218 #endif
219     __ASM_VTABLE(iosb, "");
220     __ASM_VTABLE(ios_base, "");
221     __ASM_VTABLE(basic_ios_char, "");
222     __ASM_VTABLE(basic_ios_wchar, "");
223     __ASM_VTABLE(basic_ios_short, "");
224     __ASM_VTABLE(basic_streambuf_char,
225             VTABLE_ADD_FUNC(basic_streambuf_char_overflow)
226             VTABLE_ADD_FUNC(basic_streambuf_char_pbackfail)
227             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
228             VTABLE_ADD_FUNC(basic_streambuf_char_underflow)
229             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
230             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
231             VTABLE_ADD_FUNC(basic_streambuf_char__Xsgetn_s)
232             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
233             VTABLE_ADD_FUNC(basic_streambuf_char_seekoff)
234             VTABLE_ADD_FUNC(basic_streambuf_char_seekpos)
235             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
236             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
237             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
238     __ASM_VTABLE(basic_streambuf_wchar,
239             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
240             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
241             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
242             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
243             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
244             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
245             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
246             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
247             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
248             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
249             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
250             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
251             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
252     __ASM_VTABLE(basic_streambuf_short,
253             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
254             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
255             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
256             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
257             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
258             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
259             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
260             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
261             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
262             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
263             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
264             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
265             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
266     __ASM_VTABLE(basic_ostream_char, "");
267 #ifndef __GNUC__
268 }
269 #endif
270
271 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
272 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
273 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp_next, 16)
274 void __thiscall basic_streambuf_char_setp_next(basic_streambuf_char *this, char *first, char *next, char *last)
275 {
276     TRACE("(%p %p %p %p)\n", this, first, next, last);
277
278     this->wbuf = first;
279     this->wpos = next;
280     this->wsize = last-next;
281 }
282
283 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD0@Z */
284 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD0@Z */
285 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp, 12)
286 void __thiscall basic_streambuf_char_setp(basic_streambuf_char *this, char *first, char *last)
287 {
288     basic_streambuf_char_setp_next(this, first, first, last);
289 }
290
291 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
292 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
293 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setg, 16)
294 void __thiscall basic_streambuf_char_setg(basic_streambuf_char *this, char *first, char *next, char *last)
295 {
296     TRACE("(%p %p %p %p)\n", this, first, next, last);
297
298     this->rbuf = first;
299     this->rpos = next;
300     this->rsize = last-next;
301 }
302
303 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXXZ */
304 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXXZ */
305 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init_empty, 4)
306 void __thiscall basic_streambuf_char__Init_empty(basic_streambuf_char *this)
307 {
308     TRACE("(%p)\n", this);
309
310     this->prbuf = &this->rbuf;
311     this->pwbuf = &this->wbuf;
312     this->prpos = &this->rpos;
313     this->pwpos = &this->wpos;
314     this->prsize = &this->rsize;
315     this->pwsize = &this->wsize;
316
317     basic_streambuf_char_setp(this, NULL, NULL);
318     basic_streambuf_char_setg(this, NULL, NULL, NULL);
319 }
320
321 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@W4_Uninitialized@1@@Z */
322 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
323 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor_uninitialized, 8)
324 basic_streambuf_char* __thiscall basic_streambuf_char_ctor_uninitialized(basic_streambuf_char *this, int uninitialized)
325 {
326     TRACE("(%p %d)\n", this, uninitialized);
327     this->vtable = &MSVCP_basic_streambuf_char_vtable;
328     mutex_ctor(&this->lock);
329     return this;
330 }
331
332 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ */
333 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@XZ */
334 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor, 4)
335 basic_streambuf_char* __thiscall basic_streambuf_char_ctor(basic_streambuf_char *this)
336 {
337     TRACE("(%p)\n", this);
338
339     this->vtable = &MSVCP_basic_streambuf_char_vtable;
340     mutex_ctor(&this->lock);
341     this->loc = MSVCRT_operator_new(sizeof(locale));
342     locale_ctor(this->loc);
343     basic_streambuf_char__Init_empty(this);
344
345     return this;
346 }
347
348 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
349 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
350 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_dtor, 4)
351 void __thiscall basic_streambuf_char_dtor(basic_streambuf_char *this)
352 {
353     TRACE("(%p)\n", this);
354
355     mutex_dtor(&this->lock);
356     locale_dtor(this->loc);
357     MSVCRT_operator_delete(this->loc);
358 }
359
360 DEFINE_THISCALL_WRAPPER(MSVCP_basic_streambuf_char_vector_dtor, 8)
361 basic_streambuf_char* __thiscall MSVCP_basic_streambuf_char_vector_dtor(basic_streambuf_char *this, unsigned int flags)
362 {
363     TRACE("(%p %x)\n", this, flags);
364     if(flags & 2) {
365         /* we have an array, with the number of elements stored before the first object */
366         int i, *ptr = (int *)this-1;
367
368         for(i=*ptr-1; i>=0; i--)
369             basic_streambuf_char_dtor(this+i);
370         MSVCRT_operator_delete(ptr);
371     } else {
372         basic_streambuf_char_dtor(this);
373         if(flags & 1)
374             MSVCRT_operator_delete(this);
375     }
376
377     return this;
378 }
379
380 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
381 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
382 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gnavail, 4)
383 streamsize __thiscall basic_streambuf_char__Gnavail(const basic_streambuf_char *this)
384 {
385     TRACE("(%p)\n", this);
386     return *this->prpos ? *this->prsize : 0;
387 }
388
389 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
390 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
391 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gndec, 4)
392 char* __thiscall basic_streambuf_char__Gndec(basic_streambuf_char *this)
393 {
394     TRACE("(%p)\n", this);
395     (*this->prsize)++;
396     (*this->prpos)--;
397     return *this->prpos;
398 }
399
400 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
401 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
402 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gninc, 4)
403 char* __thiscall basic_streambuf_char__Gninc(basic_streambuf_char *this)
404 {
405     TRACE("(%p)\n", this);
406     (*this->prsize)--;
407     return (*this->prpos)++;
408 }
409
410 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
411 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
412 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gnpreinc, 4)
413 char* __thiscall basic_streambuf_char__Gnpreinc(basic_streambuf_char *this)
414 {
415     TRACE("(%p)\n", this);
416     (*this->prsize)--;
417     (*this->prpos)++;
418     return *this->prpos;
419 }
420
421 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAPAD0PAH001@Z */
422 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAPEAD0PEAH001@Z */
423 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init, 28)
424 void __thiscall basic_streambuf_char__Init(basic_streambuf_char *this, char **gf, char **gn, int *gc, char **pf, char **pn, int *pc)
425 {
426     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
427
428     this->prbuf = gf;
429     this->pwbuf = pf;
430     this->prpos = gn;
431     this->pwpos = pn;
432     this->prsize = gc;
433     this->pwsize = pc;
434 }
435
436 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
437 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
438 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Lock, 4)
439 void __thiscall basic_streambuf_char__Lock(basic_streambuf_char *this)
440 {
441     TRACE("(%p)\n", this);
442     mutex_lock(&this->lock);
443 }
444
445 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
446 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
447 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pnavail, 4)
448 streamsize __thiscall basic_streambuf_char__Pnavail(const basic_streambuf_char *this)
449 {
450     TRACE("(%p)\n", this);
451     return *this->pwpos ? *this->pwsize : 0;
452 }
453
454 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
455 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
456 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pninc, 4)
457 char* __thiscall basic_streambuf_char__Pninc(basic_streambuf_char *this)
458 {
459     TRACE("(%p)\n", this);
460     (*this->pwsize)--;
461     return (*this->pwpos)++;
462 }
463
464 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
465 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
466 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_underflow, 4)
467 #define call_basic_streambuf_char_underflow(this) CALL_VTBL_FUNC(this, 16, \
468         int, (basic_streambuf_char*), (this))
469 int __thiscall basic_streambuf_char_underflow(basic_streambuf_char *this)
470 {
471     TRACE("(%p)\n", this);
472     return EOF;
473 }
474
475 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
476 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
477 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_uflow, 4)
478 #define call_basic_streambuf_char_uflow(this) CALL_VTBL_FUNC(this, 20, \
479         int, (basic_streambuf_char*), (this))
480 int __thiscall basic_streambuf_char_uflow(basic_streambuf_char *this)
481 {
482     int ret;
483
484     TRACE("(%p)\n", this);
485
486     if(call_basic_streambuf_char_underflow(this)==EOF)
487         return EOF;
488
489     ret = **this->prpos;
490     (*this->prsize)--;
491     (*this->prpos)++;
492     return ret;
493 }
494
495 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADIH@Z */
496 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_K_J@Z */
497 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Xsgetn_s, 16)
498 #define call_basic_streambuf_char__Xsgetn_s(this, ptr, size, count) CALL_VTBL_FUNC(this, 28, \
499         streamsize, (basic_streambuf_char*, char*, MSVCP_size_t, streamsize), (this, ptr, size, count))
500 streamsize __thiscall basic_streambuf_char__Xsgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
501 {
502     streamsize copied, chunk;
503
504     TRACE("(%p %p %lu %lu)\n", this, ptr, size, count);
505
506     for(copied=0; copied<count && size;) {
507         chunk = basic_streambuf_char__Gnavail(this);
508         if(chunk > count-copied)
509             chunk = count-copied;
510
511         if(chunk) {
512             memcpy_s(ptr+copied, size, *this->prpos, chunk);
513             *this->prpos += chunk;
514             *this->prsize -= chunk;
515             copied += chunk;
516             size -= chunk;
517         }else if((ptr[copied] = call_basic_streambuf_char_uflow(this)) != EOF) {
518             copied++;
519             size--;
520         }else {
521             break;
522         }
523     }
524
525     return copied;
526 }
527
528 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
529 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
530 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Sgetn_s, 16)
531 streamsize __thiscall basic_streambuf_char__Sgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
532 {
533     TRACE("(%p %p %lu %lu)\n", this, ptr, size, count);
534     return call_basic_streambuf_char__Xsgetn_s(this, ptr, size, count);
535 }
536
537 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
538 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
539 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Unlock, 4)
540 void __thiscall basic_streambuf_char__Unlock(basic_streambuf_char *this)
541 {
542     TRACE("(%p)\n", this);
543     mutex_unlock(&this->lock);
544 }
545
546 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
547 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
548 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_eback, 4)
549 char* __thiscall basic_streambuf_char_eback(const basic_streambuf_char *this)
550 {
551     TRACE("(%p)\n", this);
552     return *this->prbuf;
553 }
554
555 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
556 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
557 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gptr, 4)
558 char* __thiscall basic_streambuf_char_gptr(const basic_streambuf_char *this)
559 {
560     TRACE("(%p)\n", this);
561     return *this->prpos;
562 }
563
564 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
565 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
566 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_egptr, 4)
567 char* __thiscall basic_streambuf_char_egptr(const basic_streambuf_char *this)
568 {
569     TRACE("(%p)\n", this);
570     return *this->prpos+*this->prsize;
571 }
572
573 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
574 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
575 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_epptr, 4)
576 char* __thiscall basic_streambuf_char_epptr(const basic_streambuf_char *this)
577 {
578     TRACE("(%p)\n", this);
579     return *this->pwpos+*this->pwsize;
580 }
581
582 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
583 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
584 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gbump, 8)
585 void __thiscall basic_streambuf_char_gbump(basic_streambuf_char *this, int off)
586 {
587     TRACE("(%p %d)\n", this, off);
588     *this->prpos += off;
589     *this->prsize -= off;
590 }
591
592 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QBE?AVlocale@2@XZ */
593 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEBA?AVlocale@2@XZ */
594 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_getloc, 8)
595 locale* __thiscall basic_streambuf_char_getloc(const basic_streambuf_char *this, locale *ret)
596 {
597     TRACE("(%p)\n", this);
598     return locale_copy_ctor(ret, this->loc);
599 }
600
601 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
602 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
603 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_imbue, 8)
604 #define call_basic_streambuf_char_imbue(this, loc) CALL_VTBL_FUNC(this, 52, \
605         void, (basic_streambuf_char*, const locale*), (this, loc))
606 void __thiscall basic_streambuf_char_imbue(basic_streambuf_char *this, const locale *loc)
607 {
608     TRACE("(%p %p)\n", this, loc);
609 }
610
611 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
612 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
613 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_overflow, 8)
614 #define call_basic_streambuf_char_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
615         int, (basic_streambuf_char*, int), (this, ch))
616 int __thiscall basic_streambuf_char_overflow(basic_streambuf_char *this, int ch)
617 {
618     TRACE("(%p %d)\n", this, ch);
619     return EOF;
620 }
621
622 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
623 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
624 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbackfail, 8)
625 #define call_basic_streambuf_char_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
626         int, (basic_streambuf_char*, int), (this, ch))
627 int __thiscall basic_streambuf_char_pbackfail(basic_streambuf_char *this, int ch)
628 {
629     TRACE("(%p %d)\n", this, ch);
630     return EOF;
631 }
632
633 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
634 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
635 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbase, 4)
636 char* __thiscall basic_streambuf_char_pbase(const basic_streambuf_char *this)
637 {
638     TRACE("(%p)\n", this);
639     return *this->pwbuf;
640 }
641
642 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
643 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
644 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbump, 8)
645 void __thiscall basic_streambuf_char_pbump(basic_streambuf_char *this, int off)
646 {
647     TRACE("(%p %d)\n", this, off);
648     *this->pwpos += off;
649     *this->pwsize -= off;
650 }
651
652 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
653 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
654 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pptr, 4)
655 char* __thiscall basic_streambuf_char_pptr(const basic_streambuf_char *this)
656 {
657     TRACE("(%p)\n", this);
658     return *this->pwpos;
659 }
660
661 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
662 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
663 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubimbue, 12)
664 locale* __thiscall basic_streambuf_char_pubimbue(basic_streambuf_char *this, locale *ret, const locale *loc)
665 {
666     TRACE("(%p %p)\n", this, loc);
667     memcpy(ret, this->loc, sizeof(locale));
668     call_basic_streambuf_char_imbue(this, loc);
669     locale_copy_ctor(this->loc, loc);
670     return ret;
671 }
672
673 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
674 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
675 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekoff, 20)
676 #define call_basic_streambuf_char_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 36, \
677         fpos_int*, (basic_streambuf_char*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
678 fpos_int* __thiscall basic_streambuf_char_seekoff(basic_streambuf_char *this,
679         fpos_int *ret, streamoff off, int way, int mode)
680 {
681     TRACE("(%p %lu %d %d)\n", this, off, way, mode);
682     ret->off = 0;
683     ret->pos = -1;
684     ret->state = 0;
685     return ret;
686 }
687
688 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
689 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
690 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff, 20)
691 fpos_int* __thiscall basic_streambuf_char_pubseekoff(basic_streambuf_char *this,
692         fpos_int *ret, streamoff off, int way, int mode)
693 {
694     TRACE("(%p %lu %d %d)\n", this, off, way, mode);
695     return call_basic_streambuf_char_seekoff(this, ret, off, way, mode);
696 }
697
698 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
699 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
700 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff_old, 20)
701 fpos_int* __thiscall basic_streambuf_char_pubseekoff_old(basic_streambuf_char *this,
702         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
703 {
704     TRACE("(%p %lu %d %d)\n", this, off, way, mode);
705     return basic_streambuf_char_pubseekoff(this, ret, off, way, mode);
706 }
707
708 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
709 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
710 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekpos, 36)
711 #define call_basic_streambuf_char_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 40, \
712         fpos_int*, (basic_streambuf_char*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
713 fpos_int* __thiscall basic_streambuf_char_seekpos(basic_streambuf_char *this,
714         fpos_int *ret, fpos_int pos, int mode)
715 {
716     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
717     ret->off = 0;
718     ret->pos = -1;
719     ret->state = 0;
720     return ret;
721 }
722
723 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
724 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
725 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos, 36)
726 fpos_int* __thiscall basic_streambuf_char_pubseekpos(basic_streambuf_char *this,
727         fpos_int *ret, fpos_int pos, int mode)
728 {
729     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
730     return call_basic_streambuf_char_seekpos(this, ret, pos, mode);
731 }
732
733 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
734 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
735 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos_old, 36)
736 fpos_int* __thiscall basic_streambuf_char_pubseekpos_old(basic_streambuf_char *this,
737         fpos_int *ret, fpos_int pos, unsigned int mode)
738 {
739     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
740     return basic_streambuf_char_pubseekpos(this, ret, pos, mode);
741 }
742
743 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEPAV12@PADH@Z */
744 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAPEAV12@PEAD_J@Z */
745 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setbuf, 12)
746 #define call_basic_streambuf_char_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 44, \
747         basic_streambuf_char*, (basic_streambuf_char*, char*, streamsize), (this, buf, count))
748 basic_streambuf_char* __thiscall basic_streambuf_char_setbuf(basic_streambuf_char *this, char *buf, streamsize count)
749 {
750     TRACE("(%p %p %lu)\n", this, buf, count);
751     return this;
752 }
753
754 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PADH@Z */
755 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEAD_J@Z */
756 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsetbuf, 12)
757 basic_streambuf_char* __thiscall basic_streambuf_char_pubsetbuf(basic_streambuf_char *this, char *buf, streamsize count)
758 {
759     TRACE("(%p %p %lu)\n", this, buf, count);
760     return call_basic_streambuf_char_setbuf(this, buf, count);
761 }
762
763 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
764 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
765 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sync, 4)
766 #define call_basic_streambuf_char_sync(this) CALL_VTBL_FUNC(this, 48, \
767         int, (basic_streambuf_char*), (this))
768 int __thiscall basic_streambuf_char_sync(basic_streambuf_char *this)
769 {
770     TRACE("(%p)\n", this);
771     return 0;
772 }
773
774 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
775 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
776 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsync, 4)
777 int __thiscall basic_streambuf_char_pubsync(basic_streambuf_char *this)
778 {
779     TRACE("(%p)\n", this);
780     return call_basic_streambuf_char_sync(this);
781 }
782
783 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
784 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
785 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetn, 12)
786 streamsize __thiscall basic_streambuf_char_sgetn(basic_streambuf_char *this, char *ptr, streamsize count)
787 {
788     TRACE("(%p %p %lu)\n", this, ptr, count);
789     return call_basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
790 }
791
792 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
793 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JXZ */
794 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_showmanyc, 4)
795 #define call_basic_streambuf_char_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
796         streamsize, (basic_streambuf_char*), (this))
797 streamsize __thiscall basic_streambuf_char_showmanyc(basic_streambuf_char *this)
798 {
799     TRACE("(%p)\n", this);
800     return 0;
801 }
802
803 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
804 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JXZ */
805 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_in_avail, 4)
806 streamsize __thiscall basic_streambuf_char_in_avail(basic_streambuf_char *this)
807 {
808     streamsize ret;
809
810     TRACE("(%p)\n", this);
811
812     ret = basic_streambuf_char__Gnavail(this);
813     return ret ? ret : call_basic_streambuf_char_showmanyc(this);
814 }
815
816 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
817 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
818 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputbackc, 8)
819 int __thiscall basic_streambuf_char_sputbackc(basic_streambuf_char *this, char ch)
820 {
821     TRACE("(%p %d)\n", this, ch);
822     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
823         (*this->prsize)++;
824         (*this->prpos)--;
825         return ch;
826     }
827
828     return call_basic_streambuf_char_pbackfail(this, ch);
829 }
830
831 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
832 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
833 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputc, 8)
834 int __thiscall basic_streambuf_char_sputc(basic_streambuf_char *this, char ch)
835 {
836     TRACE("(%p %d)\n", this, ch);
837     return basic_streambuf_char__Pnavail(this) ?
838         (*basic_streambuf_char__Pninc(this) = ch) :
839         call_basic_streambuf_char_overflow(this, ch);
840 }
841
842 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
843 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
844 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sungetc, 4)
845 int __thiscall basic_streambuf_char_sungetc(basic_streambuf_char *this)
846 {
847     TRACE("(%p)\n", this);
848     if(*this->prpos && *this->prpos>*this->prbuf) {
849         (*this->prsize)++;
850         (*this->prpos)--;
851         return **this->prpos;
852     }
853
854     return call_basic_streambuf_char_pbackfail(this, EOF);
855 }
856
857 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
858 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
859 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_stossc, 4)
860 void __thiscall basic_streambuf_char_stossc(basic_streambuf_char *this)
861 {
862     TRACE("(%p)\n", this);
863     if(basic_streambuf_char__Gnavail(this))
864         basic_streambuf_char__Gninc(this);
865     else
866         call_basic_streambuf_char_uflow(this);
867 }
868
869 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
870 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
871 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sbumpc, 4)
872 int __thiscall basic_streambuf_char_sbumpc(basic_streambuf_char *this)
873 {
874     TRACE("(%p)\n", this);
875     return basic_streambuf_char__Gnavail(this) ?
876         *basic_streambuf_char__Gninc(this) : call_basic_streambuf_char_uflow(this);
877 }
878
879 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
880 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
881 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetc, 4)
882 int __thiscall basic_streambuf_char_sgetc(basic_streambuf_char *this)
883 {
884     TRACE("(%p)\n", this);
885     return basic_streambuf_char__Gnavail(this) ?
886         *basic_streambuf_char_gptr(this) : call_basic_streambuf_char_underflow(this);
887 }
888
889 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
890 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
891 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_snextc, 4)
892 int __thiscall basic_streambuf_char_snextc(basic_streambuf_char *this)
893 {
894     TRACE("(%p)\n", this);
895
896     if(basic_streambuf_char__Gnavail(this) > 1)
897         return *basic_streambuf_char__Gnpreinc(this);
898     return basic_streambuf_char_sbumpc(this)==EOF ?
899         EOF : basic_streambuf_char_sgetc(this);
900 }
901
902 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADH@Z */
903 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_J@Z */
904 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsgetn, 12)
905 #define call_basic_streambuf_char_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
906         streamsize, (basic_streambuf_char*, char*, streamsize), (this, ptr, count))
907 streamsize __thiscall basic_streambuf_char_xsgetn(basic_streambuf_char *this, char *ptr, streamsize count)
908 {
909     TRACE("(%p %p %lu)\n", this, ptr, count);
910     return call_basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
911 }
912
913 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPBDH@Z */
914 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEBD_J@Z */
915 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsputn, 12)
916 #define call_basic_streambuf_char_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 32, \
917         streamsize, (basic_streambuf_char*, const char*, streamsize), (this, ptr, count))
918 streamsize __thiscall basic_streambuf_char_xsputn(basic_streambuf_char *this, const char *ptr, streamsize count)
919 {
920     streamsize copied, chunk;
921
922     TRACE("(%p %p %lu)\n", this, ptr, count);
923
924     for(copied=0; copied<count;) {
925         chunk = basic_streambuf_char__Pnavail(this);
926         if(chunk > count-copied)
927             chunk = count-copied;
928
929         if(chunk) {
930             memcpy(*this->pwpos, ptr+copied, chunk);
931             *this->pwpos += chunk;
932             *this->pwsize -= chunk;
933             copied += chunk;
934         }else if(call_basic_streambuf_char_overflow(this, ptr[copied]) != EOF) {
935             copied++;
936         }else {
937             break;
938         }
939     }
940
941     return copied;
942 }
943
944 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z */
945 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z */
946 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputn, 12)
947 streamsize __thiscall basic_streambuf_char_sputn(basic_streambuf_char *this, const char *ptr, streamsize count)
948 {
949     TRACE("(%p %p %lu)\n", this, ptr, count);
950     return call_basic_streambuf_char_xsputn(this, ptr, count);
951 }
952
953 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
954 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
955 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
956 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
957 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp_next, 16)
958 void __thiscall basic_streambuf_wchar_setp_next(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
959 {
960     TRACE("(%p %p %p %p)\n", this, first, next, last);
961
962     this->wbuf = first;
963     this->wpos = next;
964     this->wsize = last-next;
965 }
966
967 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W0@Z */
968 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W0@Z */
969 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG0@Z */
970 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG0@Z */
971 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp, 12)
972 void __thiscall basic_streambuf_wchar_setp(basic_streambuf_wchar *this, wchar_t *first, wchar_t *last)
973 {
974     basic_streambuf_wchar_setp_next(this, first, first, last);
975 }
976
977 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
978 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
979 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
980 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
981 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setg, 16)
982 void __thiscall basic_streambuf_wchar_setg(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
983 {
984     TRACE("(%p %p %p %p)\n", this, first, next, last);
985
986     this->rbuf = first;
987     this->rpos = next;
988     this->rsize = last-next;
989 }
990
991 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXXZ */
992 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXXZ */
993 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXXZ */
994 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXXZ */
995 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init_empty, 4)
996 void __thiscall basic_streambuf_wchar__Init_empty(basic_streambuf_wchar *this)
997 {
998     TRACE("(%p)\n", this);
999
1000     this->prbuf = &this->rbuf;
1001     this->pwbuf = &this->wbuf;
1002     this->prpos = &this->rpos;
1003     this->pwpos = &this->wpos;
1004     this->prsize = &this->rsize;
1005     this->pwsize = &this->wsize;
1006
1007     basic_streambuf_wchar_setp(this, NULL, NULL);
1008     basic_streambuf_wchar_setg(this, NULL, NULL, NULL);
1009 }
1010
1011 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1012 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1013 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor_uninitialized, 8)
1014 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1015 {
1016     TRACE("(%p %d)\n", this, uninitialized);
1017     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1018     mutex_ctor(&this->lock);
1019     return this;
1020 }
1021
1022 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1023 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1024 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor_uninitialized, 8)
1025 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1026 {
1027     TRACE("(%p %d)\n", this, uninitialized);
1028     basic_streambuf_wchar_ctor_uninitialized(this, uninitialized);
1029     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1030     return this;
1031 }
1032
1033 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
1034 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
1035 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor, 4)
1036 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor(basic_streambuf_wchar *this)
1037 {
1038     TRACE("(%p)\n", this);
1039
1040     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1041     mutex_ctor(&this->lock);
1042     this->loc = MSVCRT_operator_new(sizeof(locale));
1043     locale_ctor(this->loc);
1044     basic_streambuf_wchar__Init_empty(this);
1045
1046     return this;
1047 }
1048
1049 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@XZ */
1050 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@XZ */
1051 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor, 4)
1052 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor(basic_streambuf_wchar *this)
1053 {
1054     TRACE("(%p)\n", this);
1055     basic_streambuf_wchar_ctor(this);
1056     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1057     return this;
1058 }
1059
1060 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
1061 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
1062 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
1063 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
1064 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_dtor, 4)
1065 void __thiscall basic_streambuf_wchar_dtor(basic_streambuf_wchar *this)
1066 {
1067     TRACE("(%p)\n", this);
1068
1069     mutex_dtor(&this->lock);
1070     locale_dtor(this->loc);
1071     MSVCRT_operator_delete(this->loc);
1072 }
1073
1074 DEFINE_THISCALL_WRAPPER(MSVCP_basic_streambuf_wchar_vector_dtor, 8)
1075 basic_streambuf_wchar* __thiscall MSVCP_basic_streambuf_wchar_vector_dtor(basic_streambuf_wchar *this, unsigned int flags)
1076 {
1077     TRACE("(%p %x)\n", this, flags);
1078     if(flags & 2) {
1079         /* we have an array, with the number of elements stored before the first object */
1080         int i, *ptr = (int *)this-1;
1081
1082         for(i=*ptr-1; i>=0; i--)
1083             basic_streambuf_wchar_dtor(this+i);
1084         MSVCRT_operator_delete(ptr);
1085     } else {
1086         basic_streambuf_wchar_dtor(this);
1087         if(flags & 1)
1088             MSVCRT_operator_delete(this);
1089     }
1090
1091     return this;
1092 }
1093
1094 DEFINE_THISCALL_WRAPPER(MSVCP_basic_streambuf_short_vector_dtor, 8)
1095 basic_streambuf_wchar* __thiscall MSVCP_basic_streambuf_short_vector_dtor(basic_streambuf_wchar *this, unsigned int flags)
1096 {
1097     TRACE("(%p %x)\n", this, flags);
1098     return MSVCP_basic_streambuf_wchar_vector_dtor(this, flags);
1099 }
1100
1101 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1102 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1103 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1104 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1105 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gnavail, 4)
1106 streamsize __thiscall basic_streambuf_wchar__Gnavail(const basic_streambuf_wchar *this)
1107 {
1108     TRACE("(%p)\n", this);
1109     return *this->prpos ? *this->prsize : 0;
1110 }
1111
1112 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1113 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1114 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1115 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1116 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gndec, 4)
1117 wchar_t* __thiscall basic_streambuf_wchar__Gndec(basic_streambuf_wchar *this)
1118 {
1119     TRACE("(%p)\n", this);
1120     (*this->prsize)++;
1121     (*this->prpos)--;
1122     return *this->prpos;
1123 }
1124
1125 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1126 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1127 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1128 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1129 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gninc, 4)
1130 wchar_t* __thiscall basic_streambuf_wchar__Gninc(basic_streambuf_wchar *this)
1131 {
1132     TRACE("(%p)\n", this);
1133     (*this->prsize)--;
1134     return (*this->prpos)++;
1135 }
1136
1137 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1138 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1139 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1140 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1141 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gnpreinc, 4)
1142 wchar_t* __thiscall basic_streambuf_wchar__Gnpreinc(basic_streambuf_wchar *this)
1143 {
1144     TRACE("(%p)\n", this);
1145     (*this->prsize)--;
1146     (*this->prpos)++;
1147     return *this->prpos;
1148 }
1149
1150 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPAPA_W0PAH001@Z */
1151 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAPEA_W0PEAH001@Z */
1152 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAPAG0PAH001@Z */
1153 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAPEAG0PEAH001@Z */
1154 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init, 28)
1155 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)
1156 {
1157     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1158
1159     this->prbuf = gf;
1160     this->pwbuf = pf;
1161     this->prpos = gn;
1162     this->pwpos = pn;
1163     this->prsize = gc;
1164     this->pwsize = pc;
1165 }
1166
1167 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1168 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1169 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1170 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1171 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Lock, 4)
1172 void __thiscall basic_streambuf_wchar__Lock(basic_streambuf_wchar *this)
1173 {
1174     TRACE("(%p)\n", this);
1175     mutex_lock(&this->lock);
1176 }
1177
1178 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1179 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1180 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1181 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1182 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pnavail, 4)
1183 streamsize __thiscall basic_streambuf_wchar__Pnavail(const basic_streambuf_wchar *this)
1184 {
1185     TRACE("(%p)\n", this);
1186     return *this->pwpos ? *this->pwsize : 0;
1187 }
1188
1189 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1190 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1191 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1192 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1193 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pninc, 4)
1194 wchar_t* __thiscall basic_streambuf_wchar__Pninc(basic_streambuf_wchar *this)
1195 {
1196     TRACE("(%p)\n", this);
1197     (*this->pwsize)--;
1198     return (*this->pwpos)++;
1199 }
1200
1201 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1202 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1203 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1204 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1205 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_underflow, 4)
1206 #define call_basic_streambuf_wchar_underflow(this) CALL_VTBL_FUNC(this, 16, \
1207         unsigned short, (basic_streambuf_wchar*), (this))
1208 unsigned short __thiscall basic_streambuf_wchar_underflow(basic_streambuf_wchar *this)
1209 {
1210     TRACE("(%p)\n", this);
1211     return WEOF;
1212 }
1213
1214 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1215 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1216 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1217 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1218 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_uflow, 4)
1219 #define call_basic_streambuf_wchar_uflow(this) CALL_VTBL_FUNC(this, 20, \
1220         unsigned short, (basic_streambuf_wchar*), (this))
1221 unsigned short __thiscall basic_streambuf_wchar_uflow(basic_streambuf_wchar *this)
1222 {
1223     int ret;
1224
1225     TRACE("(%p)\n", this);
1226
1227     if(call_basic_streambuf_wchar_underflow(this)==WEOF)
1228         return WEOF;
1229
1230     ret = **this->prpos;
1231     (*this->prsize)--;
1232     (*this->prpos)++;
1233     return ret;
1234 }
1235
1236 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WIH@Z */
1237 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_K_J@Z */
1238 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGIH@Z */
1239 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_K_J@Z */
1240 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Xsgetn_s, 16)
1241 #define call_basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count) CALL_VTBL_FUNC(this, 28, \
1242         streamsize, (basic_streambuf_wchar*, wchar_t*, MSVCP_size_t, streamsize), (this, ptr, size, count))
1243 streamsize __thiscall basic_streambuf_wchar__Xsgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1244 {
1245     streamsize copied, chunk;
1246
1247     TRACE("(%p %p %lu %lu)\n", this, ptr, size, count);
1248
1249     for(copied=0; copied<count && size;) {
1250         chunk = basic_streambuf_wchar__Gnavail(this);
1251         if(chunk > count-copied)
1252             chunk = count-copied;
1253
1254         if(chunk) {
1255             memcpy_s(ptr+copied, size, *this->prpos, chunk);
1256             *this->prpos += chunk;
1257             *this->prsize -= chunk;
1258             copied += chunk;
1259             size -= chunk;
1260         }else if((ptr[copied] = call_basic_streambuf_wchar_uflow(this)) != WEOF) {
1261             copied++;
1262             size--;
1263         }else {
1264             break;
1265         }
1266     }
1267
1268     return copied;
1269 }
1270
1271 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
1272 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
1273 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
1274 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
1275 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Sgetn_s, 16)
1276 streamsize __thiscall basic_streambuf_wchar__Sgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1277 {
1278     TRACE("(%p %p %lu %lu)\n", this, ptr, size, count);
1279     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count);
1280 }
1281
1282 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1283 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1284 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1285 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1286 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Unlock, 4)
1287 void __thiscall basic_streambuf_wchar__Unlock(basic_streambuf_wchar *this)
1288 {
1289     TRACE("(%p)\n", this);
1290     mutex_unlock(&this->lock);
1291 }
1292
1293 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1294 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1295 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1296 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1297 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_eback, 4)
1298 wchar_t* __thiscall basic_streambuf_wchar_eback(const basic_streambuf_wchar *this)
1299 {
1300     TRACE("(%p)\n", this);
1301     return *this->prbuf;
1302 }
1303
1304 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1305 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1306 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1307 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1308 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gptr, 4)
1309 wchar_t* __thiscall basic_streambuf_wchar_gptr(const basic_streambuf_wchar *this)
1310 {
1311     TRACE("(%p)\n", this);
1312     return *this->prpos;
1313 }
1314
1315 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1316 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1317 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1318 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1319 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_egptr, 4)
1320 wchar_t* __thiscall basic_streambuf_wchar_egptr(const basic_streambuf_wchar *this)
1321 {
1322     TRACE("(%p)\n", this);
1323     return *this->prpos+*this->prsize;
1324 }
1325
1326 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1327 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1328 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1329 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1330 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_epptr, 4)
1331 wchar_t* __thiscall basic_streambuf_wchar_epptr(const basic_streambuf_wchar *this)
1332 {
1333     TRACE("(%p)\n", this);
1334     return *this->pwpos+*this->pwsize;
1335 }
1336
1337 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1338 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1339 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1340 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1341 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gbump, 8)
1342 void __thiscall basic_streambuf_wchar_gbump(basic_streambuf_wchar *this, int off)
1343 {
1344     TRACE("(%p %d)\n", this, off);
1345     *this->prpos += off;
1346     *this->prsize -= off;
1347 }
1348
1349 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QBE?AVlocale@2@XZ */
1350 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEBA?AVlocale@2@XZ */
1351 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QBE?AVlocale@2@XZ */
1352 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEBA?AVlocale@2@XZ */
1353 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_getloc, 8)
1354 locale* __thiscall basic_streambuf_wchar_getloc(const basic_streambuf_wchar *this, locale *ret)
1355 {
1356     TRACE("(%p)\n", this);
1357     return locale_copy_ctor(ret, this->loc);
1358 }
1359
1360 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
1361 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
1362 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
1363 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
1364 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_imbue, 8)
1365 #define call_basic_streambuf_wchar_imbue(this, loc) CALL_VTBL_FUNC(this, 52, \
1366         void, (basic_streambuf_wchar*, const locale*), (this, loc))
1367 void __thiscall basic_streambuf_wchar_imbue(basic_streambuf_wchar *this, const locale *loc)
1368 {
1369     TRACE("(%p %p)\n", this, loc);
1370 }
1371
1372 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1373 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1374 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1375 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1376 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_overflow, 8)
1377 #define call_basic_streambuf_wchar_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1378         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1379 unsigned short __thiscall basic_streambuf_wchar_overflow(basic_streambuf_wchar *this, unsigned short ch)
1380 {
1381     TRACE("(%p %d)\n", this, ch);
1382     return WEOF;
1383 }
1384
1385 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1386 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1387 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1388 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1389 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbackfail, 8)
1390 #define call_basic_streambuf_wchar_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1391         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1392 unsigned short __thiscall basic_streambuf_wchar_pbackfail(basic_streambuf_wchar *this, unsigned short ch)
1393 {
1394     TRACE("(%p %d)\n", this, ch);
1395     return WEOF;
1396 }
1397
1398 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1399 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1400 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1401 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1402 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbase, 4)
1403 wchar_t* __thiscall basic_streambuf_wchar_pbase(const basic_streambuf_wchar *this)
1404 {
1405     TRACE("(%p)\n", this);
1406     return *this->pwbuf;
1407 }
1408
1409 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1410 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1411 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1412 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1413 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbump, 8)
1414 void __thiscall basic_streambuf_wchar_pbump(basic_streambuf_wchar *this, int off)
1415 {
1416     TRACE("(%p %d)\n", this, off);
1417     *this->pwpos += off;
1418     *this->pwsize -= off;
1419 }
1420
1421 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1422 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1423 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1424 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1425 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pptr, 4)
1426 wchar_t* __thiscall basic_streambuf_wchar_pptr(const basic_streambuf_wchar *this)
1427 {
1428     TRACE("(%p)\n", this);
1429     return *this->pwpos;
1430 }
1431
1432 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1433 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1434 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1435 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1436 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubimbue, 12)
1437 locale* __thiscall basic_streambuf_wchar_pubimbue(basic_streambuf_wchar *this, locale *ret, const locale *loc)
1438 {
1439     TRACE("(%p %p)\n", this, loc);
1440     memcpy(ret, this->loc, sizeof(locale));
1441     call_basic_streambuf_wchar_imbue(this, loc);
1442     locale_copy_ctor(this->loc, loc);
1443     return ret;
1444 }
1445
1446 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1447 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1448 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1449 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1450 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekoff, 20)
1451 #define call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 36, \
1452         fpos_int*, (basic_streambuf_wchar*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1453 fpos_int* __thiscall basic_streambuf_wchar_seekoff(basic_streambuf_wchar *this,
1454         fpos_int *ret, streamoff off, int way, int mode)
1455 {
1456     TRACE("(%p %lu %d %d)\n", this, off, way, mode);
1457     ret->off = 0;
1458     ret->pos = -1;
1459     ret->state = 0;
1460     return ret;
1461 }
1462
1463 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1464 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1465 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1466 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1467 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff, 20)
1468 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff(basic_streambuf_wchar *this,
1469         fpos_int *ret, streamoff off, int way, int mode)
1470 {
1471     TRACE("(%p %lu %d %d)\n", this, off, way, mode);
1472     return call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode);
1473 }
1474
1475 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
1476 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
1477 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
1478 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
1479 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff_old, 20)
1480 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff_old(basic_streambuf_wchar *this,
1481         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
1482 {
1483     TRACE("(%p %lu %d %d)\n", this, off, way, mode);
1484     return basic_streambuf_wchar_pubseekoff(this, ret, off, way, mode);
1485 }
1486
1487 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1488 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1489 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1490 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1491 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekpos, 36)
1492 #define call_basic_streambuf_wchar_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 40, \
1493         fpos_int*, (basic_streambuf_wchar*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
1494 fpos_int* __thiscall basic_streambuf_wchar_seekpos(basic_streambuf_wchar *this,
1495         fpos_int *ret, fpos_int pos, int mode)
1496 {
1497     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1498     ret->off = 0;
1499     ret->pos = -1;
1500     ret->state = 0;
1501     return ret;
1502 }
1503
1504 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1505 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1506 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1507 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1508 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos, 36)
1509 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos(basic_streambuf_wchar *this,
1510         fpos_int *ret, fpos_int pos, int mode)
1511 {
1512     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1513     return call_basic_streambuf_wchar_seekpos(this, ret, pos, mode);
1514 }
1515
1516 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
1517 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
1518 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
1519 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
1520 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos_old, 36)
1521 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos_old(basic_streambuf_wchar *this,
1522         fpos_int *ret, fpos_int pos, unsigned int mode)
1523 {
1524     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1525     return basic_streambuf_wchar_pubseekpos(this, ret, pos, mode);
1526 }
1527
1528 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEPAV12@PA_WH@Z */
1529 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV12@PEA_W_J@Z */
1530 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEPAV12@PAGH@Z */
1531 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAPEAV12@PEAG_J@Z */
1532 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setbuf, 12)
1533 #define call_basic_streambuf_wchar_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 44, \
1534         basic_streambuf_wchar*, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, buf, count))
1535 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_setbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
1536 {
1537     TRACE("(%p %p %lu)\n", this, buf, count);
1538     return this;
1539 }
1540
1541 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PA_WH@Z */
1542 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEA_W_J@Z */
1543 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PAGH@Z */
1544 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEAG_J@Z */
1545 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsetbuf, 12)
1546 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_pubsetbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
1547 {
1548     TRACE("(%p %p %lu)\n", this, buf, count);
1549     return call_basic_streambuf_wchar_setbuf(this, buf, count);
1550 }
1551
1552 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
1553 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
1554 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
1555 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
1556 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sync, 4)
1557 #define call_basic_streambuf_wchar_sync(this) CALL_VTBL_FUNC(this, 48, \
1558         int, (basic_streambuf_wchar*), (this))
1559 int __thiscall basic_streambuf_wchar_sync(basic_streambuf_wchar *this)
1560 {
1561     TRACE("(%p)\n", this);
1562     return 0;
1563 }
1564
1565 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
1566 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
1567 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
1568 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHXZ */
1569 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsync, 4)
1570 int __thiscall basic_streambuf_wchar_pubsync(basic_streambuf_wchar *this)
1571 {
1572     TRACE("(%p)\n", this);
1573     return call_basic_streambuf_wchar_sync(this);
1574 }
1575
1576 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
1577 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
1578 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
1579 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
1580 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetn, 12)
1581 streamsize __thiscall basic_streambuf_wchar_sgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
1582 {
1583     TRACE("(%p %p %lu)\n", this, ptr, count);
1584     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
1585 }
1586
1587 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
1588 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JXZ */
1589 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
1590 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JXZ */
1591 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_showmanyc, 4)
1592 #define call_basic_streambuf_wchar_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
1593         streamsize, (basic_streambuf_wchar*), (this))
1594 streamsize __thiscall basic_streambuf_wchar_showmanyc(basic_streambuf_wchar *this)
1595 {
1596     TRACE("(%p)\n", this);
1597     return 0;
1598 }
1599
1600 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
1601 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JXZ */
1602 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
1603 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JXZ */
1604 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_in_avail, 4)
1605 streamsize __thiscall basic_streambuf_wchar_in_avail(basic_streambuf_wchar *this)
1606 {
1607     streamsize ret;
1608
1609     TRACE("(%p)\n", this);
1610
1611     ret = basic_streambuf_wchar__Gnavail(this);
1612     return ret ? ret : call_basic_streambuf_wchar_showmanyc(this);
1613 }
1614
1615 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
1616 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
1617 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
1618 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
1619 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputbackc, 8)
1620 unsigned short __thiscall basic_streambuf_wchar_sputbackc(basic_streambuf_wchar *this, wchar_t ch)
1621 {
1622     TRACE("(%p %d)\n", this, ch);
1623     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
1624         (*this->prsize)++;
1625         (*this->prpos)--;
1626         return ch;
1627     }
1628
1629     return call_basic_streambuf_wchar_pbackfail(this, ch);
1630 }
1631
1632 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
1633 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
1634 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
1635 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHG@Z */
1636 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputc, 8)
1637 unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar *this, wchar_t ch)
1638 {
1639     TRACE("(%p %d)\n", this, ch);
1640     return basic_streambuf_wchar__Pnavail(this) ?
1641         (*basic_streambuf_wchar__Pninc(this) = ch) :
1642         call_basic_streambuf_wchar_overflow(this, ch);
1643 }
1644
1645 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1646 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1647 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1648 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1649 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sungetc, 4)
1650 unsigned short __thiscall basic_streambuf_wchar_sungetc(basic_streambuf_wchar *this)
1651 {
1652     TRACE("(%p)\n", this);
1653     if(*this->prpos && *this->prpos>*this->prbuf) {
1654         (*this->prsize)++;
1655         (*this->prpos)--;
1656         return **this->prpos;
1657     }
1658
1659     return call_basic_streambuf_wchar_pbackfail(this, WEOF);
1660 }
1661
1662 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1663 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1664 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1665 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1666 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_stossc, 4)
1667 void __thiscall basic_streambuf_wchar_stossc(basic_streambuf_wchar *this)
1668 {
1669     TRACE("(%p)\n", this);
1670     if(basic_streambuf_wchar__Gnavail(this))
1671         basic_streambuf_wchar__Gninc(this);
1672     else
1673         call_basic_streambuf_wchar_uflow(this);
1674 }
1675
1676 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1677 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1678 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1679 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1680 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sbumpc, 4)
1681 unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar *this)
1682 {
1683     TRACE("(%p)\n", this);
1684     return basic_streambuf_wchar__Gnavail(this) ?
1685         *basic_streambuf_wchar__Gninc(this) : call_basic_streambuf_wchar_uflow(this);
1686 }
1687
1688 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1689 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1690 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1691 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1692 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetc, 4)
1693 unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar *this)
1694 {
1695     TRACE("(%p)\n", this);
1696     return basic_streambuf_wchar__Gnavail(this) ?
1697         *basic_streambuf_wchar_gptr(this) : call_basic_streambuf_wchar_underflow(this);
1698 }
1699
1700 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1701 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1702 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1703 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1704 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_snextc, 4)
1705 unsigned short __thiscall basic_streambuf_wchar_snextc(basic_streambuf_wchar *this)
1706 {
1707     TRACE("(%p)\n", this);
1708
1709     if(basic_streambuf_wchar__Gnavail(this) > 1)
1710         return *basic_streambuf_wchar__Gnpreinc(this);
1711     return basic_streambuf_wchar_sbumpc(this)==WEOF ?
1712         WEOF : basic_streambuf_wchar_sgetc(this);
1713 }
1714
1715 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WH@Z */
1716 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_J@Z */
1717 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGH@Z */
1718 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_J@Z */
1719 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsgetn, 12)
1720 #define call_basic_streambuf_wchar_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
1721         streamsize, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, ptr, count))
1722 streamsize __thiscall basic_streambuf_wchar_xsgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
1723 {
1724     TRACE("(%p %p %lu)\n", this, ptr, count);
1725     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
1726 }
1727
1728 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPB_WH@Z */
1729 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEB_W_J@Z */
1730 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPBGH@Z */
1731 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEBG_J@Z */
1732 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsputn, 12)
1733 #define call_basic_streambuf_wchar_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 32, \
1734         streamsize, (basic_streambuf_wchar*, const wchar_t*, streamsize), (this, ptr, count))
1735 streamsize __thiscall basic_streambuf_wchar_xsputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
1736 {
1737     streamsize copied, chunk;
1738
1739     TRACE("(%p %p %lu)\n", this, ptr, count);
1740
1741     for(copied=0; copied<count;) {
1742         chunk = basic_streambuf_wchar__Pnavail(this);
1743         if(chunk > count-copied)
1744             chunk = count-copied;
1745
1746         if(chunk) {
1747             memcpy(*this->pwpos, ptr+copied, chunk);
1748             *this->pwpos += chunk;
1749             *this->pwsize -= chunk;
1750             copied += chunk;
1751         }else if(call_basic_streambuf_wchar_overflow(this, ptr[copied]) != WEOF) {
1752             copied++;
1753         }else {
1754             break;
1755         }
1756     }
1757
1758     return copied;
1759 }
1760
1761 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPB_WH@Z */
1762 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEB_W_J@Z */
1763 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPBGH@Z */
1764 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEBG_J@Z */
1765 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputn, 12)
1766 streamsize __thiscall basic_streambuf_wchar_sputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
1767 {
1768     TRACE("(%p %p %lu)\n", this, ptr, count);
1769     return call_basic_streambuf_wchar_xsputn(this, ptr, count);
1770 }
1771
1772 /* ??0ios_base@std@@IAE@XZ */
1773 /* ??0ios_base@std@@IEAA@XZ */
1774 DEFINE_THISCALL_WRAPPER(ios_base_ctor, 4)
1775 ios_base* __thiscall ios_base_ctor(ios_base *this)
1776 {
1777     TRACE("(%p)\n", this);
1778     this->vtable = &MSVCP_ios_base_vtable;
1779     return this;
1780 }
1781
1782 /* ??0ios_base@std@@QAE@ABV01@@Z */
1783 /* ??0ios_base@std@@QEAA@AEBV01@@Z */
1784 DEFINE_THISCALL_WRAPPER(ios_base_copy_ctor, 8)
1785 ios_base* __thiscall ios_base_copy_ctor(ios_base *this, const ios_base *copy)
1786 {
1787     TRACE("(%p %p)\n", this, copy);
1788     *this = *copy;
1789     this->vtable = &MSVCP_ios_base_vtable;
1790     return this;
1791 }
1792
1793 /* ?_Callfns@ios_base@std@@AAEXW4event@12@@Z */
1794 /* ?_Callfns@ios_base@std@@AEAAXW4event@12@@Z */
1795 DEFINE_THISCALL_WRAPPER(ios_base_Callfns, 8)
1796 void __thiscall ios_base_Callfns(ios_base *this, IOS_BASE_event event)
1797 {
1798     IOS_BASE_fnarray *cur;
1799
1800     TRACE("(%p %x)\n", this, event);
1801
1802     for(cur=this->calls; cur; cur=cur->next)
1803         cur->event_handler(event, this, cur->index);
1804 }
1805
1806 /* ?_Tidy@ios_base@std@@AAAXXZ */
1807 /* ?_Tidy@ios_base@std@@AEAAXXZ */
1808 void CDECL ios_base_Tidy(ios_base *this)
1809 {
1810     IOS_BASE_iosarray *arr_cur, *arr_next;
1811     IOS_BASE_fnarray *event_cur, *event_next;
1812
1813     TRACE("(%p)\n", this);
1814
1815     ios_base_Callfns(this, EVENT_erase_event);
1816
1817     for(arr_cur=this->arr; arr_cur; arr_cur=arr_next) {
1818         arr_next = arr_cur->next;
1819         MSVCRT_operator_delete(arr_cur);
1820     }
1821     this->arr = NULL;
1822
1823     for(event_cur=this->calls; event_cur; event_cur=event_next) {
1824         event_next = event_cur->next;
1825         MSVCRT_operator_delete(event_cur);
1826     }
1827     this->calls = NULL;
1828 }
1829
1830 /* ?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z */
1831 /* ?_Ios_base_dtor@ios_base@std@@CAXPEAV12@@Z */
1832 void CDECL ios_base_Ios_base_dtor(ios_base *obj)
1833 {
1834     TRACE("(%p)\n", obj);
1835     if(obj->loc) {
1836         locale_dtor(obj->loc);
1837         MSVCRT_operator_delete(obj->loc);
1838     }
1839     ios_base_Tidy(obj);
1840 }
1841
1842 /* ??1ios_base@std@@UAE@XZ */
1843 /* ??1ios_base@std@@UEAA@XZ */
1844 DEFINE_THISCALL_WRAPPER(ios_base_dtor, 4)
1845 void __thiscall ios_base_dtor(ios_base *this)
1846 {
1847     ios_base_Ios_base_dtor(this);
1848 }
1849
1850 DEFINE_THISCALL_WRAPPER(MSVCP_ios_base_vector_dtor, 8)
1851 ios_base* __thiscall MSVCP_ios_base_vector_dtor(ios_base *this, unsigned int flags)
1852 {
1853     TRACE("(%p %x)\n", this, flags);
1854     if(flags & 2) {
1855         /* we have an array, with the number of elements stored before the first object */
1856         int i, *ptr = (int *)this-1;
1857
1858         for(i=*ptr-1; i>=0; i--)
1859             ios_base_dtor(this+i);
1860         MSVCRT_operator_delete(ptr);
1861     } else {
1862         ios_base_dtor(this);
1863         if(flags & 1)
1864             MSVCRT_operator_delete(this);
1865     }
1866
1867     return this;
1868 }
1869
1870 DEFINE_THISCALL_WRAPPER(MSVCP_iosb_vector_dtor, 8)
1871 void* __thiscall MSVCP_iosb_vector_dtor(void *this, unsigned int flags)
1872 {
1873     TRACE("(%p %x)\n", this, flags);
1874     if(flags & 2) {
1875         int *ptr = (int *)this-1;
1876         MSVCRT_operator_delete(ptr);
1877     } else {
1878         if(flags & 1)
1879             MSVCRT_operator_delete(this);
1880     }
1881
1882     return this;
1883 }
1884
1885 /* ?_Findarr@ios_base@std@@AAEAAU_Iosarray@12@H@Z */
1886 /* ?_Findarr@ios_base@std@@AEAAAEAU_Iosarray@12@H@Z */
1887 DEFINE_THISCALL_WRAPPER(ios_base_Findarr, 8)
1888 IOS_BASE_iosarray* __thiscall ios_base_Findarr(ios_base *this, int index)
1889 {
1890     IOS_BASE_iosarray *p;
1891
1892     TRACE("(%p %d)\n", this, index);
1893
1894     for(p=this->arr; p; p=p->next) {
1895         if(p->index == index)
1896             return p;
1897     }
1898
1899     for(p=this->arr; p; p=p->next) {
1900         if(!p->long_val && !p->ptr_val) {
1901             p->index = index;
1902             return p;
1903         }
1904     }
1905
1906     p = MSVCRT_operator_new(sizeof(IOS_BASE_iosarray));
1907     p->next = this->arr;
1908     p->index = index;
1909     p->long_val = 0;
1910     p->ptr_val = NULL;
1911     this->arr = p;
1912     return p;
1913 }
1914
1915 /* ?iword@ios_base@std@@QAEAAJH@Z */
1916 /* ?iword@ios_base@std@@QEAAAEAJH@Z */
1917 DEFINE_THISCALL_WRAPPER(ios_base_iword, 8)
1918 LONG* __thiscall ios_base_iword(ios_base *this, int index)
1919 {
1920     TRACE("(%p %d)\n", this, index);
1921     return &ios_base_Findarr(this, index)->long_val;
1922 }
1923
1924 /* ?pword@ios_base@std@@QAEAAPAXH@Z */
1925 /* ?pword@ios_base@std@@QEAAAEAPEAXH@Z */
1926 DEFINE_THISCALL_WRAPPER(ios_base_pword, 8)
1927 void** __thiscall ios_base_pword(ios_base *this, int index)
1928 {
1929     TRACE("(%p %d)\n", this, index);
1930     return &ios_base_Findarr(this, index)->ptr_val;
1931 }
1932
1933 /* ?register_callback@ios_base@std@@QAEXP6AXW4event@12@AAV12@H@ZH@Z */
1934 /* ?register_callback@ios_base@std@@QEAAXP6AXW4event@12@AEAV12@H@ZH@Z */
1935 DEFINE_THISCALL_WRAPPER(ios_base_register_callback, 12)
1936 void __thiscall ios_base_register_callback(ios_base *this, IOS_BASE_event_callback callback, int index)
1937 {
1938     IOS_BASE_fnarray *event;
1939
1940     TRACE("(%p %p %d)\n", this, callback, index);
1941
1942     event = MSVCRT_operator_new(sizeof(IOS_BASE_fnarray));
1943     event->next = this->calls;
1944     event->index = index;
1945     event->event_handler = callback;
1946     this->calls = event;
1947 }
1948
1949 /* ?clear@ios_base@std@@QAEXH_N@Z */
1950 /* ?clear@ios_base@std@@QEAAXH_N@Z */
1951 DEFINE_THISCALL_WRAPPER(ios_base_clear_reraise, 12)
1952 void __thiscall ios_base_clear_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
1953 {
1954     TRACE("(%p %x %x)\n", this, state, reraise);
1955
1956     this->state = state & IOSTATE_mask;
1957     if(!(this->state & this->except))
1958         return;
1959
1960     if(reraise)
1961         throw_exception(EXCEPTION_RERAISE, NULL);
1962     else if(this->state & this->except & IOSTATE_eofbit)
1963         throw_exception(EXCEPTION_FAILURE, "eofbit is set");
1964     else if(this->state & this->except & IOSTATE_failbit)
1965         throw_exception(EXCEPTION_FAILURE, "failbit is set");
1966     else if(this->state & this->except & IOSTATE_badbit)
1967         throw_exception(EXCEPTION_FAILURE, "badbit is set");
1968     else if(this->state & this->except & IOSTATE__Hardfail)
1969         throw_exception(EXCEPTION_FAILURE, "_Hardfail is set");
1970 }
1971
1972 /* ?clear@ios_base@std@@QAEXH@Z */
1973 /* ?clear@ios_base@std@@QEAAXH@Z */
1974 DEFINE_THISCALL_WRAPPER(ios_base_clear, 8)
1975 void __thiscall ios_base_clear(ios_base *this, IOSB_iostate state)
1976 {
1977     ios_base_clear_reraise(this, state, FALSE);
1978 }
1979
1980 /* ?clear@ios_base@std@@QAEXI@Z */
1981 /* ?clear@ios_base@std@@QEAAXI@Z */
1982 DEFINE_THISCALL_WRAPPER(ios_base_clear_unsigned, 8)
1983 void __thiscall ios_base_clear_unsigned(ios_base *this, unsigned int state)
1984 {
1985     ios_base_clear_reraise(this, (IOSB_iostate)state, FALSE);
1986 }
1987
1988 /* ?exceptions@ios_base@std@@QAEXH@Z */
1989 /* ?exceptions@ios_base@std@@QEAAXH@Z */
1990 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set, 8)
1991 void __thiscall ios_base_exceptions_set(ios_base *this, IOSB_iostate state)
1992 {
1993     TRACE("(%p %x)\n", this, state);
1994     this->except = state & IOSTATE_mask;
1995     ios_base_clear(this, this->state);
1996 }
1997
1998 /* ?exceptions@ios_base@std@@QAEXI@Z */
1999 /* ?exceptions@ios_base@std@@QEAAXI@Z */
2000 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set_unsigned, 8)
2001 void __thiscall ios_base_exceptions_set_unsigned(ios_base *this, unsigned int state)
2002 {
2003     TRACE("(%p %x)\n", this, state);
2004     ios_base_exceptions_set(this, state);
2005 }
2006
2007 /* ?exceptions@ios_base@std@@QBEHXZ */
2008 /* ?exceptions@ios_base@std@@QEBAHXZ */
2009 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_get, 4)
2010 IOSB_iostate __thiscall ios_base_exceptions_get(ios_base *this)
2011 {
2012     TRACE("(%p)\n", this);
2013     return this->except;
2014 }
2015
2016 /* ?copyfmt@ios_base@std@@QAEAAV12@ABV12@@Z */
2017 /* ?copyfmt@ios_base@std@@QEAAAEAV12@AEBV12@@Z */
2018 DEFINE_THISCALL_WRAPPER(ios_base_copyfmt, 8)
2019 ios_base* __thiscall ios_base_copyfmt(ios_base *this, const ios_base *rhs)
2020 {
2021     TRACE("(%p %p)\n", this, rhs);
2022
2023     if(this != rhs) {
2024         IOS_BASE_iosarray *arr_cur;
2025         IOS_BASE_fnarray *event_cur;
2026
2027         ios_base_Tidy(this);
2028
2029         for(arr_cur=rhs->arr; arr_cur; arr_cur=arr_cur->next) {
2030             if(arr_cur->long_val)
2031                 *ios_base_iword(this, arr_cur->index) = arr_cur->long_val;
2032             if(arr_cur->ptr_val)
2033                 *ios_base_pword(this, arr_cur->index) = arr_cur->ptr_val;
2034         }
2035         this->stdstr = rhs->stdstr;
2036         this->fmtfl = rhs->fmtfl;
2037         this->prec = rhs->prec;
2038         this->wide = rhs->wide;
2039         locale_operator_assign(this->loc, rhs->loc);
2040
2041         for(event_cur=rhs->calls; event_cur; event_cur=event_cur->next)
2042             ios_base_register_callback(this, event_cur->event_handler, event_cur->index);
2043
2044         ios_base_Callfns(this, EVENT_copyfmt_event);
2045         ios_base_exceptions_set(this, rhs->except);
2046     }
2047
2048     return this;
2049 }
2050
2051 /* ??4ios_base@std@@QAEAAV01@ABV01@@Z */
2052 /* ??4ios_base@std@@QEAAAEAV01@AEBV01@@Z */
2053 DEFINE_THISCALL_WRAPPER(ios_base_assign, 8)
2054 ios_base* __thiscall ios_base_assign(ios_base *this, const ios_base *right)
2055 {
2056     TRACE("(%p %p)\n", this, right);
2057
2058     if(this != right) {
2059         this->state = right->state;
2060         ios_base_copyfmt(this, right);
2061     }
2062
2063     return this;
2064 }
2065
2066 /* ?fail@ios_base@std@@QBE_NXZ */
2067 /* ?fail@ios_base@std@@QEBA_NXZ */
2068 DEFINE_THISCALL_WRAPPER(ios_base_fail, 4)
2069 MSVCP_bool __thiscall ios_base_fail(const ios_base *this)
2070 {
2071     TRACE("(%p)\n", this);
2072     return (this->state & (IOSTATE_failbit|IOSTATE_badbit)) != 0;
2073 }
2074
2075 /* ??7ios_base@std@@QBE_NXZ */
2076 /* ??7ios_base@std@@QEBA_NXZ */
2077 DEFINE_THISCALL_WRAPPER(ios_base_op_succ, 4)
2078 MSVCP_bool __thiscall ios_base_op_succ(const ios_base *this)
2079 {
2080     TRACE("(%p)\n", this);
2081     return ios_base_fail(this);
2082 }
2083
2084 /* ??Bios_base@std@@QBEPAXXZ */
2085 /* ??Bios_base@std@@QEBAPEAXXZ */
2086 DEFINE_THISCALL_WRAPPER(ios_base_op_fail, 4)
2087 void* __thiscall ios_base_op_fail(const ios_base *this)
2088 {
2089     TRACE("(%p)\n", this);
2090     return ios_base_fail(this) ? NULL : (void*)this;
2091 }
2092
2093 /* ?_Addstd@ios_base@std@@SAXPAV12@@Z */
2094 /* ?_Addstd@ios_base@std@@SAXPEAV12@@Z */
2095 void CDECL ios_base_Addstd(ios_base *add)
2096 {
2097     FIXME("(%p) stub\n", add);
2098 }
2099
2100 /* ?_Index_func@ios_base@std@@CAAAHXZ */
2101 /* ?_Index_func@ios_base@std@@CAAEAHXZ */
2102 int* CDECL ios_base_Index_func(void)
2103 {
2104     TRACE("\n");
2105     return &ios_base_Index;
2106 }
2107
2108 /* ?_Init@ios_base@std@@IAEXXZ */
2109 /* ?_Init@ios_base@std@@IEAAXXZ */
2110 DEFINE_THISCALL_WRAPPER(ios_base_Init, 4)
2111 void __thiscall ios_base_Init(ios_base *this)
2112 {
2113     TRACE("(%p)\n", this);
2114
2115     this->stdstr = 0;
2116     this->state = this->except = IOSTATE_goodbit;
2117     this->fmtfl = FMTFLAG_skipws | FMTFLAG_dec;
2118     this->prec = 6;
2119     this->wide = ' ';
2120     this->arr = NULL;
2121     this->calls = NULL;
2122     this->loc = MSVCRT_operator_new(sizeof(locale));
2123     locale_ctor(this->loc);
2124 }
2125
2126 /* ?_Sync_func@ios_base@std@@CAAA_NXZ */
2127 /* ?_Sync_func@ios_base@std@@CAAEA_NXZ */
2128 MSVCP_bool* CDECL ios_base_Sync_func(void)
2129 {
2130     TRACE("\n");
2131     return &ios_base_Sync;
2132 }
2133
2134 /* ?bad@ios_base@std@@QBE_NXZ */
2135 /* ?bad@ios_base@std@@QEBA_NXZ */
2136 DEFINE_THISCALL_WRAPPER(ios_base_bad, 4)
2137 MSVCP_bool __thiscall ios_base_bad(const ios_base *this)
2138 {
2139     TRACE("(%p)\n", this);
2140     return (this->state & IOSTATE_badbit) != 0;
2141 }
2142
2143 /* ?eof@ios_base@std@@QBE_NXZ */
2144 /* ?eof@ios_base@std@@QEBA_NXZ */
2145 DEFINE_THISCALL_WRAPPER(ios_base_eof, 4)
2146 MSVCP_bool __thiscall ios_base_eof(const ios_base *this)
2147 {
2148     TRACE("(%p)\n", this);
2149     return (this->state & IOSTATE_eofbit) != 0;
2150 }
2151
2152 /* ?flags@ios_base@std@@QAEHH@Z */
2153 /* ?flags@ios_base@std@@QEAAHH@Z */
2154 DEFINE_THISCALL_WRAPPER(ios_base_flags_set, 8)
2155 IOSB_fmtflags __thiscall ios_base_flags_set(ios_base *this, IOSB_fmtflags flags)
2156 {
2157     IOSB_fmtflags ret = this->fmtfl;
2158
2159     TRACE("(%p %x)\n", this, flags);
2160
2161     this->fmtfl = flags & FMTFLAG_mask;
2162     return ret;
2163 }
2164
2165 /* ?flags@ios_base@std@@QBEHXZ */
2166 /* ?flags@ios_base@std@@QEBAHXZ */
2167 DEFINE_THISCALL_WRAPPER(ios_base_flags_get, 4)
2168 IOSB_fmtflags __thiscall ios_base_flags_get(const ios_base *this)
2169 {
2170     TRACE("(%p)\n", this);
2171     return this->fmtfl;
2172 }
2173
2174 /* ?getloc@ios_base@std@@QBE?AVlocale@2@XZ */
2175 /* ?getloc@ios_base@std@@QEBA?AVlocale@2@XZ */
2176 DEFINE_THISCALL_WRAPPER(ios_base_getloc, 8)
2177 locale* __thiscall ios_base_getloc(const ios_base *this, locale *ret)
2178 {
2179     TRACE("(%p)\n", this);
2180     return locale_copy_ctor(ret, this->loc);
2181 }
2182
2183 /* ?good@ios_base@std@@QBE_NXZ */
2184 /* ?good@ios_base@std@@QEBA_NXZ */
2185 DEFINE_THISCALL_WRAPPER(ios_base_good, 4)
2186 MSVCP_bool __thiscall ios_base_good(const ios_base *this)
2187 {
2188     TRACE("(%p)\n", this);
2189     return this->state == IOSTATE_goodbit;
2190 }
2191
2192 /* ?imbue@ios_base@std@@QAE?AVlocale@2@ABV32@@Z */
2193 /* ?imbue@ios_base@std@@QEAA?AVlocale@2@AEBV32@@Z */
2194 DEFINE_THISCALL_WRAPPER(ios_base_imbue, 12)
2195 locale* __thiscall ios_base_imbue(ios_base *this, locale *ret, const locale *loc)
2196 {
2197     TRACE("(%p %p)\n", this, loc);
2198     *ret = *this->loc;
2199     locale_copy_ctor(this->loc, loc);
2200     return ret;
2201 }
2202
2203 /* ?precision@ios_base@std@@QAEHH@Z */
2204 /* ?precision@ios_base@std@@QEAA_J_J@Z */
2205 DEFINE_THISCALL_WRAPPER(ios_base_precision_set, 8)
2206 MSVCP_size_t __thiscall ios_base_precision_set(ios_base *this, MSVCP_size_t precision)
2207 {
2208     MSVCP_size_t ret = this->prec;
2209
2210     TRACE("(%p %lu)\n", this, precision);
2211
2212     this->prec = precision;
2213     return ret;
2214 }
2215
2216 /* ?precision@ios_base@std@@QBEHXZ */
2217 /* ?precision@ios_base@std@@QEBA_JXZ */
2218 DEFINE_THISCALL_WRAPPER(ios_base_precision_get, 4)
2219 MSVCP_size_t __thiscall ios_base_precision_get(const ios_base *this)
2220 {
2221     TRACE("(%p)\n", this);
2222     return this->prec;
2223 }
2224
2225 /* ?rdstate@ios_base@std@@QBEHXZ */
2226 /* ?rdstate@ios_base@std@@QEBAHXZ */
2227 DEFINE_THISCALL_WRAPPER(ios_base_rdstate, 4)
2228 IOSB_iostate __thiscall ios_base_rdstate(const ios_base *this)
2229 {
2230     TRACE("(%p)\n", this);
2231     return this->state;
2232 }
2233
2234 /* ?setf@ios_base@std@@QAEHHH@Z */
2235 /* ?setf@ios_base@std@@QEAAHHH@Z */
2236 DEFINE_THISCALL_WRAPPER(ios_base_setf_mask, 12)
2237 IOSB_fmtflags __thiscall ios_base_setf_mask(ios_base *this, IOSB_fmtflags flags, IOSB_fmtflags mask)
2238 {
2239     IOSB_fmtflags ret = this->fmtfl;
2240
2241     TRACE("(%p %x %x)\n", this, flags, mask);
2242
2243     this->fmtfl = (this->fmtfl & (~mask)) | (flags & mask & FMTFLAG_mask);
2244     return ret;
2245 }
2246
2247 /* ?setf@ios_base@std@@QAEHH@Z */
2248 /* ?setf@ios_base@std@@QEAAHH@Z */
2249 DEFINE_THISCALL_WRAPPER(ios_base_setf, 8)
2250 IOSB_fmtflags __thiscall ios_base_setf(ios_base *this, IOSB_fmtflags flags)
2251 {
2252     return ios_base_setf_mask(this, flags, ~0);
2253 }
2254
2255 /* ?setstate@ios_base@std@@QAEXH_N@Z */
2256 /* ?setstate@ios_base@std@@QEAAXH_N@Z */
2257 DEFINE_THISCALL_WRAPPER(ios_base_setstate_reraise, 12)
2258 void __thiscall ios_base_setstate_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
2259 {
2260     TRACE("(%p %x %x)\n", this, state, reraise);
2261
2262     if(state != IOSTATE_goodbit)
2263         ios_base_clear_reraise(this, this->state | state, reraise);
2264 }
2265
2266 /* ?setstate@ios_base@std@@QAEXH@Z */
2267 /* ?setstate@ios_base@std@@QEAAXH@Z */
2268 DEFINE_THISCALL_WRAPPER(ios_base_setstate, 8)
2269 void __thiscall ios_base_setstate(ios_base *this, IOSB_iostate state)
2270 {
2271     ios_base_setstate_reraise(this, state, FALSE);
2272 }
2273
2274 /* ?setstate@ios_base@std@@QAEXI@Z */
2275 /* ?setstate@ios_base@std@@QEAAXI@Z */
2276 DEFINE_THISCALL_WRAPPER(ios_base_setstate_unsigned, 8)
2277 void __thiscall ios_base_setstate_unsigned(ios_base *this, unsigned int state)
2278 {
2279     ios_base_setstate_reraise(this, (IOSB_iostate)state, FALSE);
2280 }
2281
2282 /* ?sync_with_stdio@ios_base@std@@SA_N_N@Z */
2283 MSVCP_bool CDECL ios_base_sync_with_stdio(MSVCP_bool sync)
2284 {
2285     _Lockit lock;
2286     MSVCP_bool ret;
2287
2288     TRACE("(%x)\n", sync);
2289
2290     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
2291     ret = ios_base_Sync;
2292     ios_base_Sync = sync;
2293     _Lockit_dtor(&lock);
2294     return ret;
2295 }
2296
2297 /* ?unsetf@ios_base@std@@QAEXH@Z */
2298 /* ?unsetf@ios_base@std@@QEAAXH@Z */
2299 DEFINE_THISCALL_WRAPPER(ios_base_unsetf, 8)
2300 void __thiscall ios_base_unsetf(ios_base *this, IOSB_fmtflags flags)
2301 {
2302     TRACE("(%p %x)\n", this, flags);
2303     this->fmtfl &= ~flags;
2304 }
2305
2306 /* ?width@ios_base@std@@QAEHH@Z */
2307 /* ?width@ios_base@std@@QEAA_J_J@Z */
2308 DEFINE_THISCALL_WRAPPER(ios_base_width_set, 8)
2309 MSVCP_size_t __thiscall ios_base_width_set(ios_base *this, MSVCP_size_t width)
2310 {
2311     MSVCP_size_t ret = this->wide;
2312
2313     TRACE("(%p %lu)\n", this, width);
2314
2315     this->wide = width;
2316     return ret;
2317 }
2318
2319 /* ?width@ios_base@std@@QBEHXZ */
2320 /* ?width@ios_base@std@@QEBA_JXZ */
2321 DEFINE_THISCALL_WRAPPER(ios_base_width_get, 4)
2322 MSVCP_size_t __thiscall ios_base_width_get(ios_base *this)
2323 {
2324     TRACE("(%p)\n", this);
2325     return this->wide;
2326 }
2327
2328 /* ?xalloc@ios_base@std@@SAHXZ */
2329 int CDECL ios_base_xalloc(void)
2330 {
2331     _Lockit lock;
2332     int ret;
2333
2334     TRACE("\n");
2335
2336     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
2337     ret = ios_base_Index++;
2338     _Lockit_dtor(&lock);
2339     return ret;
2340 }
2341
2342 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ */
2343 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IEAA@XZ */
2344 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor, 4)
2345 basic_ios_char* __thiscall basic_ios_char_ctor(basic_ios_char *this)
2346 {
2347     TRACE("(%p)\n", this);
2348
2349     ios_base_ctor(&this->base);
2350     this->base.vtable = &MSVCP_basic_ios_char_vtable;
2351     return this;
2352 }
2353
2354 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IAEXPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
2355 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
2356 DEFINE_THISCALL_WRAPPER(basic_ios_char_init, 12)
2357 void __thiscall basic_ios_char_init(basic_ios_char *this, basic_streambuf_char *streambuf, MSVCP_bool isstd)
2358 {
2359     TRACE("(%p %p %x)\n", this, streambuf, isstd);
2360     ios_base_Init(&this->base);
2361     this->strbuf = streambuf;
2362     this->stream = NULL;
2363     this->fillch = ' ';
2364
2365     if(!streambuf)
2366         ios_base_setstate(&this->base, IOSTATE_badbit);
2367
2368     if(isstd)
2369         FIXME("standard streams not handled yet\n");
2370 }
2371
2372 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
2373 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
2374 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor_streambuf, 8)
2375 basic_ios_char* __thiscall basic_ios_char_ctor_streambuf(basic_ios_char *this, basic_streambuf_char *strbuf)
2376 {
2377     TRACE("(%p %p)\n", this, strbuf);
2378
2379     basic_ios_char_ctor(this);
2380     basic_ios_char_init(this, strbuf, FALSE);
2381     return this;
2382 }
2383
2384 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ */
2385 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ */
2386 DEFINE_THISCALL_WRAPPER(basic_ios_char_dtor, 4)
2387 void __thiscall basic_ios_char_dtor(basic_ios_char *this)
2388 {
2389     TRACE("(%p)\n", this);
2390     ios_base_dtor(&this->base);
2391 }
2392
2393 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ios_char_vector_dtor, 8)
2394 basic_ios_char* __thiscall MSVCP_basic_ios_char_vector_dtor(basic_ios_char *this, unsigned int flags)
2395 {
2396     TRACE("(%p %x) stub\n", this, flags);
2397     if(flags & 2) {
2398         /* we have an array, with the number of elements stored before the first object */
2399         int i, *ptr = (int *)this-1;
2400
2401         for(i=*ptr-1; i>=0; i--)
2402             basic_ios_char_dtor(this+i);
2403         MSVCRT_operator_delete(ptr);
2404     } else {
2405         basic_ios_char_dtor(this);
2406         if(flags & 1)
2407             MSVCRT_operator_delete(this);
2408     }
2409
2410     return this;
2411 }
2412
2413 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
2414 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
2415 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear_reraise, 12)
2416 void __thiscall basic_ios_char_clear_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
2417 {
2418     TRACE("(%p %x %x)\n", this, state, reraise);
2419     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
2420 }
2421
2422 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
2423 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
2424 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear, 8)
2425 void __thiscall basic_ios_char_clear(basic_ios_char *this, unsigned int state)
2426 {
2427     basic_ios_char_clear_reraise(this, (IOSB_iostate)state, FALSE);
2428 }
2429
2430 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEAAV12@ABV12@@Z */
2431 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEBV12@@Z */
2432 DEFINE_THISCALL_WRAPPER(basic_ios_char_copyfmt, 8)
2433 basic_ios_char* __thiscall basic_ios_char_copyfmt(basic_ios_char *this, basic_ios_char *copy)
2434 {
2435     TRACE("(%p %p)\n", this, copy);
2436     if(this == copy)
2437         return this;
2438
2439     this->stream = copy->stream;
2440     this->fillch = copy->fillch;
2441     ios_base_copyfmt(&this->base, &copy->base);
2442     return this;
2443 }
2444
2445 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEDD@Z */
2446 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAADD@Z */
2447 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_set, 8)
2448 char __thiscall basic_ios_char_fill_set(basic_ios_char *this, char fill)
2449 {
2450     char ret = this->fillch;
2451
2452     TRACE("(%p %c)\n", this, fill);
2453
2454     this->fillch = fill;
2455     return ret;
2456 }
2457
2458 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ */
2459 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADXZ */
2460 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_get, 4)
2461 char __thiscall basic_ios_char_fill_get(basic_ios_char *this)
2462 {
2463     TRACE("(%p)\n", this);
2464     return this->fillch;
2465 }
2466
2467 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
2468 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
2469 DEFINE_THISCALL_WRAPPER(basic_ios_char_imbue, 12)
2470 locale *__thiscall basic_ios_char_imbue(basic_ios_char *this, locale *ret, const locale *loc)
2471 {
2472     TRACE("(%p %p %p)\n", this, ret, loc);
2473
2474     if(this->strbuf)
2475         return basic_streambuf_char_pubimbue(this->strbuf, ret, loc);
2476
2477     locale_copy_ctor(ret, loc);
2478     return ret;
2479 }
2480
2481 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDDD@Z */
2482 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADDD@Z */
2483 DEFINE_THISCALL_WRAPPER(basic_ios_char_narrow, 12)
2484 char __thiscall basic_ios_char_narrow(basic_ios_char *this, char ch, char def)
2485 {
2486     FIXME("(%p %c %c) stub\n", this, ch, def);
2487     return def;
2488 }
2489
2490 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PAV32@@Z */
2491 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAV32@@Z */
2492 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_set, 8)
2493 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_set(basic_ios_char *this, basic_streambuf_char *streambuf)
2494 {
2495     basic_streambuf_char *ret = this->strbuf;
2496
2497     TRACE("(%p %p)\n", this, streambuf);
2498
2499     this->strbuf = streambuf;
2500     basic_ios_char_clear(this, IOSTATE_goodbit);
2501     return ret;
2502 }
2503
2504 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
2505 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
2506 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_get, 4)
2507 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_get(const basic_ios_char *this)
2508 {
2509     TRACE("(%p)\n", this);
2510     return this->strbuf;
2511 }
2512
2513 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
2514 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
2515 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate_reraise, 12)
2516 void __thiscall basic_ios_char_setstate_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
2517 {
2518     TRACE("(%p %x %x)\n", this, state, reraise);
2519
2520     if(state != IOSTATE_goodbit)
2521         basic_ios_char_clear_reraise(this, this->base.state | state, reraise);
2522 }
2523
2524 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
2525 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
2526 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate, 8)
2527 void __thiscall basic_ios_char_setstate(basic_ios_char *this, unsigned int state)
2528 {
2529     basic_ios_char_setstate_reraise(this, (IOSB_iostate)state, FALSE);
2530 }
2531
2532 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@PAV32@@Z */
2533 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@PEAV32@@Z */
2534 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_set, 8)
2535 basic_ostream_char* __thiscall basic_ios_char_tie_set(basic_ios_char *this, basic_ostream_char *ostream)
2536 {
2537     basic_ostream_char *ret = this->stream;
2538
2539     TRACE("(%p %p)\n", this, ostream);
2540
2541     this->stream = ostream;
2542     return ret;
2543 }
2544
2545 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
2546 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
2547 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_get, 4)
2548 basic_ostream_char* __thiscall basic_ios_char_tie_get(const basic_ios_char *this)
2549 {
2550     TRACE("(%p)\n", this);
2551     return this->stream;
2552 }
2553
2554 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDD@Z */
2555 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADD@Z */
2556 DEFINE_THISCALL_WRAPPER(basic_ios_char_widen, 8)
2557 char __thiscall basic_ios_char_widen(basic_ios_char *this, char ch)
2558 {
2559     FIXME("(%p %c) stub\n", this, ch);
2560     return 0;
2561 }
2562
2563
2564 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
2565 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
2566 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor, 4)
2567 basic_ios_wchar* __thiscall basic_ios_wchar_ctor(basic_ios_wchar *this)
2568 {
2569         TRACE("(%p)\n", this);
2570
2571         ios_base_ctor(&this->base);
2572         this->base.vtable = &MSVCP_basic_ios_wchar_vtable;
2573         return this;
2574 }
2575
2576 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IAE@XZ */
2577 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IEAA@XZ */
2578 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor, 4)
2579 basic_ios_wchar* __thiscall basic_ios_short_ctor(basic_ios_wchar *this)
2580 {
2581     basic_ios_wchar_ctor(this);
2582     this->base.vtable = &MSVCP_basic_ios_short_vtable;
2583     return this;
2584 }
2585
2586 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
2587 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
2588 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IAEXPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
2589 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
2590 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_init, 12)
2591 void __thiscall basic_ios_wchar_init(basic_ios_wchar *this, basic_streambuf_wchar *streambuf, MSVCP_bool isstd)
2592 {
2593     TRACE("(%p %p %x)\n", this, streambuf, isstd);
2594     ios_base_Init(&this->base);
2595     this->strbuf = streambuf;
2596     this->stream = NULL;
2597     this->fillch = ' ';
2598
2599     if(!streambuf)
2600         ios_base_setstate(&this->base, IOSTATE_badbit);
2601
2602     if(isstd)
2603         FIXME("standard streams not handled yet\n");
2604 }
2605
2606 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
2607 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
2608 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor_streambuf, 8)
2609 basic_ios_wchar* __thiscall basic_ios_wchar_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
2610 {
2611     TRACE("(%p %p)\n", this, strbuf);
2612
2613     basic_ios_wchar_ctor(this);
2614     basic_ios_wchar_init(this, strbuf, FALSE);
2615     return this;
2616 }
2617
2618 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
2619 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
2620 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor_streambuf, 8)
2621 basic_ios_wchar* __thiscall basic_ios_short_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
2622 {
2623     basic_ios_wchar_ctor_streambuf(this, strbuf);
2624     this->base.vtable = &MSVCP_basic_ios_short_vtable;
2625     return this;
2626 }
2627
2628 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
2629 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
2630 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UAE@XZ */
2631 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UEAA@XZ */
2632 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_dtor, 4)
2633 void __thiscall basic_ios_wchar_dtor(basic_ios_wchar *this)
2634 {
2635     TRACE("(%p)\n", this);
2636     ios_base_dtor(&this->base);
2637 }
2638
2639 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ios_wchar_vector_dtor, 8)
2640 basic_ios_wchar* __thiscall MSVCP_basic_ios_wchar_vector_dtor(basic_ios_wchar *this, unsigned int flags)
2641 {
2642     TRACE("(%p %x) stub\n", this, flags);
2643     if(flags & 2) {
2644         /* we have an array, with the number of elements stored before the first object */
2645         int i, *ptr = (int *)this-1;
2646
2647         for(i=*ptr-1; i>=0; i--)
2648             basic_ios_wchar_dtor(this+i);
2649         MSVCRT_operator_delete(ptr);
2650     } else {
2651         basic_ios_wchar_dtor(this);
2652         if(flags & 1)
2653             MSVCRT_operator_delete(this);
2654     }
2655
2656     return this;
2657 }
2658
2659 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ios_short_vector_dtor, 8)
2660 basic_ios_wchar* __thiscall MSVCP_basic_ios_short_vector_dtor(basic_ios_wchar *this, unsigned int flags)
2661 {
2662     return MSVCP_basic_ios_wchar_vector_dtor(this, flags);
2663 }
2664
2665 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
2666 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
2667 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
2668 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
2669 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear_reraise, 12)
2670 void __thiscall basic_ios_wchar_clear_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
2671 {
2672     TRACE("(%p %x %x)\n", this, state, reraise);
2673     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
2674 }
2675
2676 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
2677 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
2678 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
2679 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
2680 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear, 8)
2681 void __thiscall basic_ios_wchar_clear(basic_ios_wchar *this, unsigned int state)
2682 {
2683     basic_ios_wchar_clear_reraise(this, (IOSB_iostate)state, FALSE);
2684 }
2685
2686 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEAAV12@ABV12@@Z */
2687 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEBV12@@Z */
2688 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEAAV12@ABV12@@Z */
2689 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEBV12@@Z */
2690 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_copyfmt, 8)
2691 basic_ios_wchar* __thiscall basic_ios_wchar_copyfmt(basic_ios_wchar *this, basic_ios_wchar *copy)
2692 {
2693     TRACE("(%p %p)\n", this, copy);
2694     if(this == copy)
2695         return this;
2696
2697     this->stream = copy->stream;
2698     this->fillch = copy->fillch;
2699     ios_base_copyfmt(&this->base, &copy->base);
2700     return this;
2701 }
2702
2703 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE_W_W@Z */
2704 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA_W_W@Z */
2705 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2706 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
2707 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_set, 8)
2708 wchar_t __thiscall basic_ios_wchar_fill_set(basic_ios_wchar *this, wchar_t fill)
2709 {
2710     wchar_t ret = this->fillch;
2711
2712     TRACE("(%p %c)\n", this, fill);
2713
2714     this->fillch = fill;
2715     return ret;
2716 }
2717
2718 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WXZ */
2719 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WXZ */
2720 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGXZ */
2721 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGXZ */
2722 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_get, 4)
2723 wchar_t __thiscall basic_ios_wchar_fill_get(basic_ios_wchar *this)
2724 {
2725     TRACE("(%p)\n", this);
2726     return this->fillch;
2727 }
2728
2729 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
2730 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
2731 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
2732 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
2733 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_imbue, 12)
2734 locale *__thiscall basic_ios_wchar_imbue(basic_ios_wchar *this, locale *ret, const locale *loc)
2735 {
2736     TRACE("(%p %p %p)\n", this, ret, loc);
2737
2738     if(this->strbuf)
2739         return basic_streambuf_wchar_pubimbue(this->strbuf, ret, loc);
2740
2741     locale_copy_ctor(ret, loc);
2742     return ret;
2743 }
2744
2745 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBED_WD@Z */
2746 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAD_WD@Z */
2747 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEDGD@Z */
2748 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBADGD@Z */
2749 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_narrow, 12)
2750 char __thiscall basic_ios_wchar_narrow(basic_ios_wchar *this, wchar_t ch, char def)
2751 {
2752     FIXME("(%p %c %c) stub\n", this, ch, def);
2753     return def;
2754 }
2755
2756 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
2757 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
2758 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAV32@@Z */
2759 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAV32@@Z */
2760 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_set, 8)
2761 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_set(basic_ios_wchar *this, basic_streambuf_wchar *streambuf)
2762 {
2763     basic_streambuf_wchar *ret = this->strbuf;
2764
2765     TRACE("(%p %p)\n", this, streambuf);
2766
2767     this->strbuf = streambuf;
2768     basic_ios_wchar_clear(this, IOSTATE_goodbit);
2769     return ret;
2770 }
2771
2772 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
2773 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
2774 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
2775 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
2776 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_get, 4)
2777 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_get(const basic_ios_wchar *this)
2778 {
2779     TRACE("(%p)\n", this);
2780     return this->strbuf;
2781 }
2782
2783 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
2784 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
2785 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
2786 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
2787 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate_reraise, 12)
2788 void __thiscall basic_ios_wchar_setstate_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
2789 {
2790     TRACE("(%p %x %x)\n", this, state, reraise);
2791
2792     if(state != IOSTATE_goodbit)
2793         basic_ios_wchar_clear_reraise(this, this->base.state | state, reraise);
2794 }
2795
2796 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
2797 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
2798 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
2799 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
2800 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate, 8)
2801 void __thiscall basic_ios_wchar_setstate(basic_ios_wchar *this, IOSB_iostate state)
2802 {
2803     basic_ios_wchar_setstate_reraise(this, state, FALSE);
2804 }
2805
2806 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
2807 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
2808 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@PAV32@@Z */
2809 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@PEAV32@@Z */
2810 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_set, 8)
2811 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_set(basic_ios_wchar *this, basic_ostream_wchar *ostream)
2812 {
2813     basic_ostream_wchar *ret = this->stream;
2814
2815     TRACE("(%p %p)\n", this, ostream);
2816
2817     this->stream = ostream;
2818     return ret;
2819 }
2820
2821 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
2822 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
2823 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
2824 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
2825 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_get, 4)
2826 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_get(const basic_ios_wchar *this)
2827 {
2828     TRACE("(%p)\n", this);
2829     return this->stream;
2830 }
2831
2832 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WD@Z */
2833 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WD@Z */
2834 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGD@Z */
2835 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGD@Z */
2836 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_widen, 8)
2837 wchar_t __thiscall basic_ios_wchar_widen(basic_ios_wchar *this, char ch)
2838 {
2839     FIXME("(%p %c)\n", this, ch);
2840     return 0;
2841 }
2842
2843 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
2844 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
2845 DEFINE_THISCALL_WRAPPER(basic_ostream_char_ctor, 12)
2846 basic_ostream_char* __thiscall basic_ostream_char_ctor(basic_ostream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd)
2847 {
2848     FIXME("(%p %p %d) stub\n", this, strbuf, isstd);
2849     return NULL;
2850 }
2851
2852 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
2853 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
2854 DEFINE_THISCALL_WRAPPER(basic_ostream_char_uninitialized, 12)
2855 basic_ostream_char* __thiscall basic_ostream_char_uninitialized(basic_ostream_char *this, int uninitialized, MSVCP_bool addstd)
2856 {
2857     FIXME("(%p %d %x) stub\n", this, uninitialized, addstd);
2858     return NULL;
2859 }
2860
2861 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
2862 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
2863 DEFINE_THISCALL_WRAPPER(basic_ostream_char_dtor, 4)
2864 void __thiscall basic_ostream_char_dtor(basic_ostream_char *this)
2865 {
2866     FIXME("(%p) stub\n", this);
2867 }
2868
2869 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ostream_char_vector_dtor, 8)
2870 basic_ostream_char* __thiscall MSVCP_basic_ostream_char_vector_dtor(basic_ostream_char *this, unsigned int flags)
2871 {
2872     TRACE("(%p %x) stub\n", this, flags);
2873     if(flags & 2) {
2874         /* we have an array, with the number of elements stored before the first object */
2875         int i, *ptr = (int *)this-1;
2876
2877         for(i=*ptr-1; i>=0; i--)
2878             basic_ostream_char_dtor(this+i);
2879         MSVCRT_operator_delete(ptr);
2880     } else {
2881         basic_ostream_char_dtor(this);
2882         if(flags & 1)
2883             MSVCRT_operator_delete(this);
2884     }
2885
2886     return this;
2887 }
2888
2889 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@F@Z */
2890 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@F@Z */
2891 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_short, 8)
2892 basic_ostream_char* __thiscall basic_ostream_char_print_short(basic_ostream_char *this, short val)
2893 {
2894     FIXME("(%p %d) stub\n", this, val);
2895     return NULL;
2896 }
2897
2898 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@G@Z */
2899 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@G@Z */
2900 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ushort, 8)
2901 basic_ostream_char* __thiscall basic_ostream_char_print_ushort(basic_ostream_char *this, unsigned short val)
2902 {
2903     FIXME("(%p %d) stub\n", this, val);
2904     return NULL;
2905 }
2906
2907 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z */
2908 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z */
2909 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int, 8)
2910 basic_ostream_char* __thiscall basic_ostream_char_print_int(basic_ostream_char *this, int val)
2911 {
2912     FIXME("(%p %d) stub\n", this, val);
2913     return NULL;
2914 }
2915
2916 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z */
2917 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@I@Z */
2918 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint, 8)
2919 basic_ostream_char* __thiscall basic_ostream_char_print_uint(basic_ostream_char *this, unsigned int val)
2920 {
2921     FIXME("(%p %d) stub\n", this, val);
2922     return NULL;
2923 }
2924
2925 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z */
2926 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z */
2927 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_long, 8)
2928 basic_ostream_char* __thiscall basic_ostream_char_print_long(basic_ostream_char *this, LONG val)
2929 {
2930     FIXME("(%p %d) stub\n", this, val);
2931     return NULL;
2932 }
2933
2934 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z */
2935 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z */
2936 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ulong, 8)
2937 basic_ostream_char* __thiscall basic_ostream_char_print_ulong(basic_ostream_char *this, ULONG val)
2938 {
2939     FIXME("(%p %d) stub\n", this, val);
2940     return NULL;
2941 }
2942
2943 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z */
2944 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z */
2945 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_float, 8)
2946 basic_ostream_char* __thiscall basic_ostream_char_print_float(basic_ostream_char *this, float val)
2947 {
2948     FIXME("(%p %f) stub\n", this, val);
2949     return NULL;
2950 }
2951
2952 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z */
2953 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z */
2954 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_double, 12)
2955 basic_ostream_char* __thiscall basic_ostream_char_print_double(basic_ostream_char *this, double val)
2956 {
2957     FIXME("(%p %lf) stub\n", this, val);
2958     return NULL;
2959 }
2960
2961 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
2962 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
2963 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_streambuf, 8)
2964 basic_ostream_char* __thiscall basic_ostream_char_print_streambuf(basic_ostream_char *this, basic_streambuf_char *val)
2965 {
2966     FIXME("(%p %p) stub\n", this, val);
2967     return NULL;
2968 }
2969
2970 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z */
2971 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z */
2972 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ptr, 8)
2973 basic_ostream_char* __thiscall basic_ostream_char_print_ptr(basic_ostream_char *this, const void *val)
2974 {
2975     FIXME("(%p %p) stub\n", this, val);
2976     return NULL;
2977 }
2978
2979 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_J@Z */
2980 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_J@Z */
2981 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int64, 12)
2982 basic_ostream_char* __thiscall basic_ostream_char_print_int64(basic_ostream_char *this, __int64 val)
2983 {
2984     FIXME("(%p) stub\n", this);
2985     return NULL;
2986 }
2987
2988 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_K@Z */
2989 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_K@Z */
2990 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint64, 12)
2991 basic_ostream_char* __thiscall basic_ostream_char_print_uint64(basic_ostream_char *this, unsigned __int64 val)
2992 {
2993     FIXME("(%p) stub\n", this);
2994     return NULL;
2995 }
2996
2997 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_N@Z */
2998 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_N@Z */
2999 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_bool, 8)
3000 basic_ostream_char* __thiscall basic_ostream_char_print_bool(basic_ostream_char *this, MSVCP_bool val)
3001 {
3002     FIXME("(%p %x) stub\n", this, val);
3003     return NULL;
3004 }
3005
3006 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
3007 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
3008 DEFINE_THISCALL_WRAPPER(basic_ostream_char__Osfx, 4)
3009 void __thiscall basic_ostream_char__Osfx(basic_ostream_char *this)
3010 {
3011     FIXME("(%p) stub\n", this);
3012 }
3013
3014 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
3015 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
3016 DEFINE_THISCALL_WRAPPER(basic_ostream_char_flush, 4)
3017 basic_ostream_char* __thiscall basic_ostream_char_flush(basic_ostream_char *this)
3018 {
3019     FIXME("(%p) stub\n", this);
3020     return NULL;
3021 }
3022
3023 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE_NXZ */
3024 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA_NXZ */
3025 DEFINE_THISCALL_WRAPPER(basic_ostream_char_opfx, 4)
3026 MSVCP_bool __thiscall basic_ostream_char_opfx(basic_ostream_char *this)
3027 {
3028     FIXME("(%p) stub\n", this);
3029     return 0;
3030 }
3031
3032 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
3033 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
3034 DEFINE_THISCALL_WRAPPER(basic_ostream_char_osfx, 4)
3035 void __thiscall basic_ostream_char_osfx(basic_ostream_char *this)
3036 {
3037     FIXME("(%p) stub\n", this);
3038 }
3039
3040 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
3041 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
3042 DEFINE_THISCALL_WRAPPER(basic_ostream_char_put, 8)
3043 basic_ostream_char* __thiscall basic_ostream_char_put(basic_ostream_char *this, char ch)
3044 {
3045     FIXME("(%p %c) stub\n", this, ch);
3046     return NULL;
3047 }
3048
3049 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
3050 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
3051 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp, 12)
3052 basic_ostream_char* __thiscall basic_ostream_char_seekp(basic_ostream_char *this, streamoff off, int way)
3053 {
3054     FIXME("(%p %lu %d) stub\n", this, off, way);
3055     return NULL;
3056 }
3057
3058 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
3059 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
3060 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp_fpos, 28)
3061 basic_ostream_char* __thiscall basic_ostream_char_seekp_fpos(basic_ostream_char *this, fpos_int pos)
3062 {
3063     FIXME("(%p %s) stub\n", this, debugstr_fpos_int(&pos));
3064     return NULL;
3065 }
3066
3067 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
3068 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
3069 DEFINE_THISCALL_WRAPPER(basic_ostream_char_tellp, 8)
3070 fpos_int* __thiscall basic_ostream_char_tellp(basic_ostream_char *this, fpos_int *ret)
3071 {
3072     FIXME("(%p) stub\n", this);
3073     return ret;
3074 }
3075
3076 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@PBDH@Z */
3077 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEBD_J@Z */
3078 DEFINE_THISCALL_WRAPPER(basic_ostream_char_write, 12)
3079 basic_ostream_char* __thiscall basic_ostream_char_write(basic_ostream_char *this, const char *str, streamsize count)
3080 {
3081     FIXME("(%p %s %lu) stub\n", this, debugstr_a(str), count);
3082     return NULL;
3083 }