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