msvcp90: Use codecvt<char>::is in basic_istream_char__Ipfx function.
[wine] / dlls / msvcp90 / ios.c
1 /*
2  * Copyright 2011 Piotr Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <limits.h>
24 #include <share.h>
25
26 #include "msvcp90.h"
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(msvcp90);
31
32 typedef enum {
33     IOSTATE_goodbit   = 0x00,
34     IOSTATE_eofbit    = 0x01,
35     IOSTATE_failbit   = 0x02,
36     IOSTATE_badbit    = 0x04,
37     IOSTATE__Hardfail = 0x10,
38     IOSTATE_mask      = 0x17
39 } IOSB_iostate;
40
41 typedef enum {
42     FMTFLAG_skipws      = 0x0001,
43     FMTFLAG_unitbuf     = 0x0002,
44     FMTFLAG_uppercase   = 0x0004,
45     FMTFLAG_showbase    = 0x0008,
46     FMTFLAG_showpoint   = 0x0010,
47     FMTFLAG_showpos     = 0x0020,
48     FMTFLAG_left        = 0x0040,
49     FMTFLAG_right       = 0x0080,
50     FMTFLAG_internal    = 0x0100,
51     FMTFLAG_dec         = 0x0200,
52     FMTFLAG_oct         = 0x0400,
53     FMTFLAG_hex         = 0x0800,
54     FMTFLAG_scientific  = 0x1000,
55     FMTFLAG_fixed       = 0x2000,
56     FMTFLAG_hexfloat    = 0x3000,
57     FMTFLAG_boolalpha   = 0x4000,
58     FMTFLAG_stdio       = 0x8000,
59     FMTFLAG_adjustfield = FMTFLAG_left|FMTFLAG_right|FMTFLAG_internal,
60     FMTFLAG_basefield   = FMTFLAG_dec|FMTFLAG_oct|FMTFLAG_hex,
61     FMTFLAG_floadfield  = FMTFLAG_scientific|FMTFLAG_fixed,
62     FMTFLAG_mask        = 0xffff
63 } IOSB_fmtflags;
64
65 typedef enum {
66     OPENMODE_in         = 0x01,
67     OPENMODE_out        = 0x02,
68     OPENMODE_ate        = 0x04,
69     OPENMODE_app        = 0x08,
70     OPENMODE_trunc      = 0x10,
71     OPENMODE__Nocreate  = 0x40,
72     OPENMODE__Noreplace = 0x80,
73     OPENMODE_binary     = 0x20,
74     OPENMODE_mask       = 0xff
75 } IOSB_openmode;
76
77 typedef enum {
78     SEEKDIR_beg  = 0x1,
79     SEEKDIR_cur  = 0x2,
80     SEEKDIR_end  = 0x3,
81     SEEKDIR_mask = 0x3
82 } IOSB_seekdir;
83
84 typedef struct _iosarray {
85     struct _iosarray *next;
86     int index;
87     int long_val;
88     void *ptr_val;
89 } IOS_BASE_iosarray;
90
91 typedef enum {
92     EVENT_erase_event,
93     EVENT_imbue_event,
94     EVENT_copyfmt_event
95 } IOS_BASE_event;
96
97 struct _ios_base;
98 typedef void (CDECL *IOS_BASE_event_callback)(IOS_BASE_event, struct _ios_base*, int);
99 typedef struct _fnarray {
100     struct _fnarray *next;
101     int index;
102     IOS_BASE_event_callback event_handler;
103 } IOS_BASE_fnarray;
104
105 /* ?_Index@ios_base@std@@0HA */
106 int ios_base_Index = 0;
107 /* ?_Sync@ios_base@std@@0_NA */
108 MSVCP_bool ios_base_Sync = FALSE;
109
110 typedef struct _ios_base {
111     const vtable_ptr *vtable;
112     MSVCP_size_t stdstr;
113     IOSB_iostate state;
114     IOSB_iostate except;
115     IOSB_fmtflags fmtfl;
116     streamsize prec;
117     streamsize wide;
118     IOS_BASE_iosarray *arr;
119     IOS_BASE_fnarray *calls;
120     locale *loc;
121 } ios_base;
122
123 typedef struct {
124     streamoff off;
125     __int64 DECLSPEC_ALIGN(8) pos;
126     int state;
127 } fpos_int;
128
129 static inline const char* debugstr_fpos_int(fpos_int *fpos)
130 {
131     return wine_dbg_sprintf("fpos(%ld %s %d)", fpos->off, wine_dbgstr_longlong(fpos->pos), fpos->state);
132 }
133
134 typedef struct {
135     const vtable_ptr *vtable;
136     mutex lock;
137     char *rbuf;
138     char *wbuf;
139     char **prbuf;
140     char **pwbuf;
141     char *rpos;
142     char *wpos;
143     char **prpos;
144     char **pwpos;
145     int rsize;
146     int wsize;
147     int *prsize;
148     int *pwsize;
149     locale *loc;
150 } basic_streambuf_char;
151
152 typedef struct {
153     const vtable_ptr *vtable;
154     mutex lock;
155     wchar_t *rbuf;
156     wchar_t *wbuf;
157     wchar_t **prbuf;
158     wchar_t **pwbuf;
159     wchar_t *rpos;
160     wchar_t *wpos;
161     wchar_t **prpos;
162     wchar_t **pwpos;
163     int rsize;
164     int wsize;
165     int *prsize;
166     int *pwsize;
167     locale *loc;
168 } basic_streambuf_wchar;
169
170 typedef enum {
171     INITFL_new   = 0,
172     INITFL_open  = 1,
173     INITFL_close = 2
174 } basic_filebuf__Initfl;
175
176 typedef struct {
177     basic_streambuf_char base;
178     codecvt_char *cvt;
179     char putback;
180     MSVCP_bool wrotesome;
181     int state;
182     MSVCP_bool close;
183     FILE *file;
184 } basic_filebuf_char;
185
186 typedef struct {
187     ios_base base;
188     basic_streambuf_char *strbuf;
189     struct _basic_ostream_char *stream;
190     char fillch;
191 } basic_ios_char;
192
193 typedef struct {
194     ios_base base;
195     basic_streambuf_wchar *strbuf;
196     struct _basic_ostream_wchar *stream;
197     wchar_t fillch;
198 } basic_ios_wchar;
199
200 typedef struct _basic_ostream_char {
201     const int *vbtable;
202     /* virtual inheritance
203      * basic_ios_char basic_ios;
204      */
205 } basic_ostream_char;
206
207 typedef struct _basic_ostream_wchar {
208     const int *vbtable;
209     /* virtual inheritance
210      * basic_ios_char basic_ios;
211      */
212 } basic_ostream_wchar;
213
214 typedef struct {
215     const int *vbtable;
216     streamsize count;
217     /* virtual inheritance
218      * basic_ios_char basic_ios;
219      */
220 } basic_istream_char;
221
222 typedef struct {
223     basic_istream_char base1;
224     basic_ostream_char base2;
225     /* virtual inheritance
226      * basic_ios_char basic_ios;
227      */
228 } basic_iostream_char;
229
230 typedef struct {
231     basic_ostream_char base;
232     basic_filebuf_char filebuf;
233     /* virtual inheritance
234      * basic_ios_char basic_ios;
235      */
236 } basic_ofstream_char;
237
238 typedef struct {
239     basic_istream_char base;
240     basic_filebuf_char filebuf;
241     /* virtual inheritance
242      * basic_ios_char basic_ios;
243      */
244 } basic_ifstream_char;
245
246 typedef struct {
247     basic_iostream_char base;
248     basic_filebuf_char filebuf;
249     /* virtual inheritance
250      * basic_ios_char basic_ios;
251      */
252 } basic_fstream_char;
253
254 extern const vtable_ptr MSVCP_iosb_vtable;
255
256 /* ??_7ios_base@std@@6B@ */
257 extern const vtable_ptr MSVCP_ios_base_vtable;
258
259 /* ??_7?$basic_ios@DU?$char_traits@D@std@@@std@@6B@ */
260 extern const vtable_ptr MSVCP_basic_ios_char_vtable;
261
262 /* ??_7?$basic_ios@_WU?$char_traits@_W@std@@@std@@6B@ */
263 extern const vtable_ptr MSVCP_basic_ios_wchar_vtable;
264
265 /* ??_7?$basic_ios@GU?$char_traits@G@std@@@std@@6B@ */
266 extern const vtable_ptr MSVCP_basic_ios_short_vtable;
267
268 /* ??_7?$basic_streambuf@DU?$char_traits@D@std@@@std@@6B@ */
269 extern const vtable_ptr MSVCP_basic_streambuf_char_vtable;
270
271 /* ??_7?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@6B@ */
272 extern const vtable_ptr MSVCP_basic_streambuf_wchar_vtable;
273
274 /* ??_7?$basic_streambuf@GU?$char_traits@G@std@@@std@@6B@ */
275 extern const vtable_ptr MSVCP_basic_streambuf_short_vtable;
276
277 /* ??_7?$basic_filebuf@DU?$char_traits@D@std@@@std@@6B@ */
278 extern const vtable_ptr MSVCP_basic_filebuf_char_vtable;
279
280 /* ??_8?$basic_ostream@DU?$char_traits@D@std@@@std@@7B@ */
281 const int basic_ostream_char_vbtable[] = {0, sizeof(basic_ostream_char)};
282 /* ??_7?$basic_ostream@DU?$char_traits@D@std@@@std@@6B@ */
283 extern const vtable_ptr MSVCP_basic_ostream_char_vtable;
284
285 /* ??_8?$basic_istream@DU?$char_traits@D@std@@@std@@7B@ */
286 const int basic_istream_char_vbtable[] = {0, sizeof(basic_istream_char)};
287 /* ??_7?$basic_istream@DU?$char_traits@D@std@@@std@@6B@ */
288 extern const vtable_ptr MSVCP_basic_istream_char_vtable;
289
290 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
291 const int basic_iostream_char_vbtable1[] = {0, sizeof(basic_iostream_char)};
292 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
293 const int basic_iostream_char_vbtable2[] = {0, sizeof(basic_iostream_char)-FIELD_OFFSET(basic_iostream_char, base2)};
294 /* ??_7?$basic_iostream@DU?$char_traits@D@std@@@std@@6B@ */
295 extern const vtable_ptr MSVCP_basic_iostream_char_vtable;
296
297 /* ??_8?$basic_ofstream@DU?$char_traits@D@std@@@std@@7B@ */
298 const int basic_ofstream_char_vbtable[] = {0, sizeof(basic_ofstream_char)};
299 /* ??_7?$basic_ofstream@DU?$char_traits@D@std@@@std@@6B@ */
300 extern const vtable_ptr MSVCP_basic_ofstream_char_vtable;
301
302 /*??_8?$basic_ifstream@DU?$char_traits@D@std@@@std@@7B@ */
303 const int basic_ifstream_char_vbtable[] = {0, sizeof(basic_ifstream_char)};
304 /* ??_7?$basic_ifstream@DU?$char_traits@D@std@@@std@@6B@ */
305 extern const vtable_ptr MSVCP_basic_ifstream_char_vtable;
306
307 /* ??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
308 const int basic_fstream_char_vbtable1[] = {0, sizeof(basic_fstream_char)};
309 /* ??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
310 const int basic_fstream_char_vbtable2[] = {0, sizeof(basic_fstream_char)-FIELD_OFFSET(basic_fstream_char, base.base2)};
311 /* ??_7?$basic_fstream@DU?$char_traits@D@std@@@std@@6B@ */
312 extern const vtable_ptr MSVCP_basic_fstream_char_vtable;
313
314 DEFINE_RTTI_DATA0(iosb, 0, ".?AV?$_Iosb@H@std@@");
315 DEFINE_RTTI_DATA1(ios_base, 0, &iosb_rtti_base_descriptor, ".?AV?$_Iosb@H@std@@");
316 DEFINE_RTTI_DATA2(basic_ios_char, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
317         ".?AV?$basic_ios@DU?$char_traits@D@std@@@std@@");
318 DEFINE_RTTI_DATA2(basic_ios_wchar, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
319         ".?AV?$basic_ios@_WU?$char_traits@_W@std@@@std@@");
320 DEFINE_RTTI_DATA2(basic_ios_short, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
321         ".?AV?$basic_ios@GU?$char_traits@G@std@@@std@@");
322 DEFINE_RTTI_DATA0(basic_streambuf_char, 0,
323         ".?AV?$basic_streambuf@DU?$char_traits@D@std@@@std@@");
324 DEFINE_RTTI_DATA0(basic_streambuf_wchar, 0,
325         ".?AV?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@");
326 DEFINE_RTTI_DATA0(basic_streambuf_short, 0,
327         ".?AV?$basic_streambuf@GU?$char_traits@G@std@@@std@@");
328 DEFINE_RTTI_DATA1(basic_filebuf_char, 0, &basic_streambuf_char_rtti_base_descriptor,
329         ".?AV?$basic_filebuf@DU?$char_traits@D@std@@@std@@");
330 DEFINE_RTTI_DATA3(basic_ostream_char, sizeof(basic_ostream_char), &basic_ios_char_rtti_base_descriptor,
331         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
332         ".?AV?$basic_ostream@DU?$char_traits@D@std@@@std@@");
333 DEFINE_RTTI_DATA3(basic_istream_char, sizeof(basic_istream_char), &basic_ios_char_rtti_base_descriptor,
334         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
335         ".?AV?$basic_istream@DU?$char_traits@D@std@@@std@@");
336 DEFINE_RTTI_DATA8(basic_iostream_char, sizeof(basic_iostream_char),
337         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
338         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
339         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
340         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
341         ".?AV?$basic_iostream@DU?$char_traits@D@std@@@std@@");
342 DEFINE_RTTI_DATA4(basic_ofstream_char, sizeof(basic_ofstream_char),
343         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
344         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
345         ".?AV?$basic_ofstream@DU?$char_traits@D@std@@@std@@");
346 DEFINE_RTTI_DATA4(basic_ifstream_char, sizeof(basic_ifstream_char),
347         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
348         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
349         ".?AV?$basic_ifstream@DU?$char_traits@D@std@@@std@@");
350 DEFINE_RTTI_DATA9(basic_fstream_char, sizeof(basic_fstream_char), &basic_istream_char_rtti_base_descriptor,
351         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
352         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
353         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
354         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
355         ".?AV?$basic_fstream@DU?$char_traits@D@std@@@std@@");
356
357 #ifndef __GNUC__
358 void __asm_dummy_vtables(void) {
359 #endif
360     __ASM_VTABLE(iosb, "");
361     __ASM_VTABLE(ios_base, "");
362     __ASM_VTABLE(basic_ios_char, "");
363     __ASM_VTABLE(basic_ios_wchar, "");
364     __ASM_VTABLE(basic_ios_short, "");
365     __ASM_VTABLE(basic_streambuf_char,
366             VTABLE_ADD_FUNC(basic_streambuf_char_overflow)
367             VTABLE_ADD_FUNC(basic_streambuf_char_pbackfail)
368             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
369             VTABLE_ADD_FUNC(basic_streambuf_char_underflow)
370             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
371             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
372             VTABLE_ADD_FUNC(basic_streambuf_char__Xsgetn_s)
373             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
374             VTABLE_ADD_FUNC(basic_streambuf_char_seekoff)
375             VTABLE_ADD_FUNC(basic_streambuf_char_seekpos)
376             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
377             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
378             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
379     __ASM_VTABLE(basic_streambuf_wchar,
380             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
381             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
382             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
383             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
384             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
385             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
386             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
387             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
388             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
389             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
390             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
391             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
392             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
393     __ASM_VTABLE(basic_streambuf_short,
394             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
395             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
396             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
397             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
398             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
399             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
400             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
401             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
402             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
403             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
404             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
405             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
406             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
407     __ASM_VTABLE(basic_filebuf_char,
408             VTABLE_ADD_FUNC(basic_filebuf_char_overflow)
409             VTABLE_ADD_FUNC(basic_filebuf_char_pbackfail)
410             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
411             VTABLE_ADD_FUNC(basic_filebuf_char_underflow)
412             VTABLE_ADD_FUNC(basic_filebuf_char_uflow)
413             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
414             VTABLE_ADD_FUNC(basic_streambuf_char__Xsgetn_s)
415             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
416             VTABLE_ADD_FUNC(basic_filebuf_char_seekoff)
417             VTABLE_ADD_FUNC(basic_filebuf_char_seekpos)
418             VTABLE_ADD_FUNC(basic_filebuf_char_setbuf)
419             VTABLE_ADD_FUNC(basic_filebuf_char_sync)
420             VTABLE_ADD_FUNC(basic_filebuf_char_imbue));
421     __ASM_VTABLE(basic_ostream_char, "");
422     __ASM_VTABLE(basic_istream_char, "");
423     __ASM_VTABLE(basic_iostream_char, "");
424     __ASM_VTABLE(basic_ofstream_char, "");
425     __ASM_VTABLE(basic_ifstream_char, "");
426     __ASM_VTABLE(basic_fstream_char, "");
427 #ifndef __GNUC__
428 }
429 #endif
430
431 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
432 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
433 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp_next, 16)
434 void __thiscall basic_streambuf_char_setp_next(basic_streambuf_char *this, char *first, char *next, char *last)
435 {
436     TRACE("(%p %p %p %p)\n", this, first, next, last);
437
438     this->wbuf = first;
439     this->wpos = next;
440     this->wsize = last-next;
441 }
442
443 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD0@Z */
444 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD0@Z */
445 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp, 12)
446 void __thiscall basic_streambuf_char_setp(basic_streambuf_char *this, char *first, char *last)
447 {
448     basic_streambuf_char_setp_next(this, first, first, last);
449 }
450
451 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
452 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
453 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setg, 16)
454 void __thiscall basic_streambuf_char_setg(basic_streambuf_char *this, char *first, char *next, char *last)
455 {
456     TRACE("(%p %p %p %p)\n", this, first, next, last);
457
458     this->rbuf = first;
459     this->rpos = next;
460     this->rsize = last-next;
461 }
462
463 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXXZ */
464 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXXZ */
465 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init_empty, 4)
466 void __thiscall basic_streambuf_char__Init_empty(basic_streambuf_char *this)
467 {
468     TRACE("(%p)\n", this);
469
470     this->prbuf = &this->rbuf;
471     this->pwbuf = &this->wbuf;
472     this->prpos = &this->rpos;
473     this->pwpos = &this->wpos;
474     this->prsize = &this->rsize;
475     this->pwsize = &this->wsize;
476
477     basic_streambuf_char_setp(this, NULL, NULL);
478     basic_streambuf_char_setg(this, NULL, NULL, NULL);
479 }
480
481 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@W4_Uninitialized@1@@Z */
482 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
483 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor_uninitialized, 8)
484 basic_streambuf_char* __thiscall basic_streambuf_char_ctor_uninitialized(basic_streambuf_char *this, int uninitialized)
485 {
486     TRACE("(%p %d)\n", this, uninitialized);
487     this->vtable = &MSVCP_basic_streambuf_char_vtable;
488     mutex_ctor(&this->lock);
489     return this;
490 }
491
492 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ */
493 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@XZ */
494 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor, 4)
495 basic_streambuf_char* __thiscall basic_streambuf_char_ctor(basic_streambuf_char *this)
496 {
497     TRACE("(%p)\n", this);
498
499     this->vtable = &MSVCP_basic_streambuf_char_vtable;
500     mutex_ctor(&this->lock);
501     this->loc = MSVCRT_operator_new(sizeof(locale));
502     locale_ctor(this->loc);
503     basic_streambuf_char__Init_empty(this);
504
505     return this;
506 }
507
508 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
509 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
510 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_dtor, 4)
511 void __thiscall basic_streambuf_char_dtor(basic_streambuf_char *this)
512 {
513     TRACE("(%p)\n", this);
514
515     mutex_dtor(&this->lock);
516     locale_dtor(this->loc);
517     MSVCRT_operator_delete(this->loc);
518 }
519
520 DEFINE_THISCALL_WRAPPER(MSVCP_basic_streambuf_char_vector_dtor, 8)
521 basic_streambuf_char* __thiscall MSVCP_basic_streambuf_char_vector_dtor(basic_streambuf_char *this, unsigned int flags)
522 {
523     TRACE("(%p %x)\n", this, flags);
524     if(flags & 2) {
525         /* we have an array, with the number of elements stored before the first object */
526         int i, *ptr = (int *)this-1;
527
528         for(i=*ptr-1; i>=0; i--)
529             basic_streambuf_char_dtor(this+i);
530         MSVCRT_operator_delete(ptr);
531     } else {
532         basic_streambuf_char_dtor(this);
533         if(flags & 1)
534             MSVCRT_operator_delete(this);
535     }
536
537     return this;
538 }
539
540 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
541 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
542 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gnavail, 4)
543 streamsize __thiscall basic_streambuf_char__Gnavail(const basic_streambuf_char *this)
544 {
545     TRACE("(%p)\n", this);
546     return *this->prpos ? *this->prsize : 0;
547 }
548
549 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
550 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
551 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gndec, 4)
552 char* __thiscall basic_streambuf_char__Gndec(basic_streambuf_char *this)
553 {
554     TRACE("(%p)\n", this);
555     (*this->prsize)++;
556     (*this->prpos)--;
557     return *this->prpos;
558 }
559
560 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
561 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
562 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gninc, 4)
563 char* __thiscall basic_streambuf_char__Gninc(basic_streambuf_char *this)
564 {
565     TRACE("(%p)\n", this);
566     (*this->prsize)--;
567     return (*this->prpos)++;
568 }
569
570 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
571 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
572 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gnpreinc, 4)
573 char* __thiscall basic_streambuf_char__Gnpreinc(basic_streambuf_char *this)
574 {
575     TRACE("(%p)\n", this);
576     (*this->prsize)--;
577     (*this->prpos)++;
578     return *this->prpos;
579 }
580
581 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAPAD0PAH001@Z */
582 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAPEAD0PEAH001@Z */
583 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init, 28)
584 void __thiscall basic_streambuf_char__Init(basic_streambuf_char *this, char **gf, char **gn, int *gc, char **pf, char **pn, int *pc)
585 {
586     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
587
588     this->prbuf = gf;
589     this->pwbuf = pf;
590     this->prpos = gn;
591     this->pwpos = pn;
592     this->prsize = gc;
593     this->pwsize = pc;
594 }
595
596 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
597 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
598 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Lock, 4)
599 void __thiscall basic_streambuf_char__Lock(basic_streambuf_char *this)
600 {
601     TRACE("(%p)\n", this);
602     mutex_lock(&this->lock);
603 }
604
605 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
606 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
607 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pnavail, 4)
608 streamsize __thiscall basic_streambuf_char__Pnavail(const basic_streambuf_char *this)
609 {
610     TRACE("(%p)\n", this);
611     return *this->pwpos ? *this->pwsize : 0;
612 }
613
614 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
615 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
616 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pninc, 4)
617 char* __thiscall basic_streambuf_char__Pninc(basic_streambuf_char *this)
618 {
619     TRACE("(%p)\n", this);
620     (*this->pwsize)--;
621     return (*this->pwpos)++;
622 }
623
624 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
625 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
626 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_underflow, 4)
627 #define call_basic_streambuf_char_underflow(this) CALL_VTBL_FUNC(this, 16, \
628         int, (basic_streambuf_char*), (this))
629 int __thiscall basic_streambuf_char_underflow(basic_streambuf_char *this)
630 {
631     TRACE("(%p)\n", this);
632     return EOF;
633 }
634
635 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
636 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
637 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_uflow, 4)
638 #define call_basic_streambuf_char_uflow(this) CALL_VTBL_FUNC(this, 20, \
639         int, (basic_streambuf_char*), (this))
640 int __thiscall basic_streambuf_char_uflow(basic_streambuf_char *this)
641 {
642     int ret;
643
644     TRACE("(%p)\n", this);
645
646     if(call_basic_streambuf_char_underflow(this)==EOF)
647         return EOF;
648
649     ret = **this->prpos;
650     (*this->prsize)--;
651     (*this->prpos)++;
652     return ret;
653 }
654
655 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADIH@Z */
656 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_K_J@Z */
657 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Xsgetn_s, 16)
658 #define call_basic_streambuf_char__Xsgetn_s(this, ptr, size, count) CALL_VTBL_FUNC(this, 28, \
659         streamsize, (basic_streambuf_char*, char*, MSVCP_size_t, streamsize), (this, ptr, size, count))
660 streamsize __thiscall basic_streambuf_char__Xsgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
661 {
662     streamsize copied, chunk;
663
664     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
665
666     for(copied=0; copied<count && size;) {
667         chunk = basic_streambuf_char__Gnavail(this);
668         if(chunk > count-copied)
669             chunk = count-copied;
670
671         if(chunk) {
672             memcpy_s(ptr+copied, size, *this->prpos, chunk);
673             *this->prpos += chunk;
674             *this->prsize -= chunk;
675             copied += chunk;
676             size -= chunk;
677         }else if((ptr[copied] = call_basic_streambuf_char_uflow(this)) != EOF) {
678             copied++;
679             size--;
680         }else {
681             break;
682         }
683     }
684
685     return copied;
686 }
687
688 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
689 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
690 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Sgetn_s, 16)
691 streamsize __thiscall basic_streambuf_char__Sgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
692 {
693     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
694     return call_basic_streambuf_char__Xsgetn_s(this, ptr, size, count);
695 }
696
697 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
698 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
699 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Unlock, 4)
700 void __thiscall basic_streambuf_char__Unlock(basic_streambuf_char *this)
701 {
702     TRACE("(%p)\n", this);
703     mutex_unlock(&this->lock);
704 }
705
706 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
707 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
708 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_eback, 4)
709 char* __thiscall basic_streambuf_char_eback(const basic_streambuf_char *this)
710 {
711     TRACE("(%p)\n", this);
712     return *this->prbuf;
713 }
714
715 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
716 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
717 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gptr, 4)
718 char* __thiscall basic_streambuf_char_gptr(const basic_streambuf_char *this)
719 {
720     TRACE("(%p)\n", this);
721     return *this->prpos;
722 }
723
724 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
725 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
726 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_egptr, 4)
727 char* __thiscall basic_streambuf_char_egptr(const basic_streambuf_char *this)
728 {
729     TRACE("(%p)\n", this);
730     return *this->prpos+*this->prsize;
731 }
732
733 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
734 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
735 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_epptr, 4)
736 char* __thiscall basic_streambuf_char_epptr(const basic_streambuf_char *this)
737 {
738     TRACE("(%p)\n", this);
739     return *this->pwpos+*this->pwsize;
740 }
741
742 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
743 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
744 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gbump, 8)
745 void __thiscall basic_streambuf_char_gbump(basic_streambuf_char *this, int off)
746 {
747     TRACE("(%p %d)\n", this, off);
748     *this->prpos += off;
749     *this->prsize -= off;
750 }
751
752 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QBE?AVlocale@2@XZ */
753 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEBA?AVlocale@2@XZ */
754 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_getloc, 8)
755 locale* __thiscall basic_streambuf_char_getloc(const basic_streambuf_char *this, locale *ret)
756 {
757     TRACE("(%p)\n", this);
758     return locale_copy_ctor(ret, this->loc);
759 }
760
761 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
762 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
763 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_imbue, 8)
764 #define call_basic_streambuf_char_imbue(this, loc) CALL_VTBL_FUNC(this, 52, \
765         void, (basic_streambuf_char*, const locale*), (this, loc))
766 void __thiscall basic_streambuf_char_imbue(basic_streambuf_char *this, const locale *loc)
767 {
768     TRACE("(%p %p)\n", this, loc);
769 }
770
771 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
772 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
773 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_overflow, 8)
774 #define call_basic_streambuf_char_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
775         int, (basic_streambuf_char*, int), (this, ch))
776 int __thiscall basic_streambuf_char_overflow(basic_streambuf_char *this, int ch)
777 {
778     TRACE("(%p %d)\n", this, ch);
779     return EOF;
780 }
781
782 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
783 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
784 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbackfail, 8)
785 #define call_basic_streambuf_char_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
786         int, (basic_streambuf_char*, int), (this, ch))
787 int __thiscall basic_streambuf_char_pbackfail(basic_streambuf_char *this, int ch)
788 {
789     TRACE("(%p %d)\n", this, ch);
790     return EOF;
791 }
792
793 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
794 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
795 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbase, 4)
796 char* __thiscall basic_streambuf_char_pbase(const basic_streambuf_char *this)
797 {
798     TRACE("(%p)\n", this);
799     return *this->pwbuf;
800 }
801
802 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
803 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
804 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbump, 8)
805 void __thiscall basic_streambuf_char_pbump(basic_streambuf_char *this, int off)
806 {
807     TRACE("(%p %d)\n", this, off);
808     *this->pwpos += off;
809     *this->pwsize -= off;
810 }
811
812 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
813 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
814 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pptr, 4)
815 char* __thiscall basic_streambuf_char_pptr(const basic_streambuf_char *this)
816 {
817     TRACE("(%p)\n", this);
818     return *this->pwpos;
819 }
820
821 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
822 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
823 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubimbue, 12)
824 locale* __thiscall basic_streambuf_char_pubimbue(basic_streambuf_char *this, locale *ret, const locale *loc)
825 {
826     TRACE("(%p %p)\n", this, loc);
827     memcpy(ret, this->loc, sizeof(locale));
828     call_basic_streambuf_char_imbue(this, loc);
829     locale_copy_ctor(this->loc, loc);
830     return ret;
831 }
832
833 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
834 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
835 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekoff, 20)
836 #define call_basic_streambuf_char_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 36, \
837         fpos_int*, (basic_streambuf_char*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
838 fpos_int* __thiscall basic_streambuf_char_seekoff(basic_streambuf_char *this,
839         fpos_int *ret, streamoff off, int way, int mode)
840 {
841     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
842     ret->off = 0;
843     ret->pos = -1;
844     ret->state = 0;
845     return ret;
846 }
847
848 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
849 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
850 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff, 20)
851 fpos_int* __thiscall basic_streambuf_char_pubseekoff(basic_streambuf_char *this,
852         fpos_int *ret, streamoff off, int way, int mode)
853 {
854     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
855     return call_basic_streambuf_char_seekoff(this, ret, off, way, mode);
856 }
857
858 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
859 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
860 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff_old, 20)
861 fpos_int* __thiscall basic_streambuf_char_pubseekoff_old(basic_streambuf_char *this,
862         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
863 {
864     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
865     return basic_streambuf_char_pubseekoff(this, ret, off, way, mode);
866 }
867
868 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
869 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
870 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekpos, 36)
871 #define call_basic_streambuf_char_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 40, \
872         fpos_int*, (basic_streambuf_char*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
873 fpos_int* __thiscall basic_streambuf_char_seekpos(basic_streambuf_char *this,
874         fpos_int *ret, fpos_int pos, int mode)
875 {
876     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
877     ret->off = 0;
878     ret->pos = -1;
879     ret->state = 0;
880     return ret;
881 }
882
883 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
884 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
885 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos, 36)
886 fpos_int* __thiscall basic_streambuf_char_pubseekpos(basic_streambuf_char *this,
887         fpos_int *ret, fpos_int pos, int mode)
888 {
889     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
890     return call_basic_streambuf_char_seekpos(this, ret, pos, mode);
891 }
892
893 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
894 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
895 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos_old, 36)
896 fpos_int* __thiscall basic_streambuf_char_pubseekpos_old(basic_streambuf_char *this,
897         fpos_int *ret, fpos_int pos, unsigned int mode)
898 {
899     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
900     return basic_streambuf_char_pubseekpos(this, ret, pos, mode);
901 }
902
903 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEPAV12@PADH@Z */
904 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAPEAV12@PEAD_J@Z */
905 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setbuf, 12)
906 #define call_basic_streambuf_char_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 44, \
907         basic_streambuf_char*, (basic_streambuf_char*, char*, streamsize), (this, buf, count))
908 basic_streambuf_char* __thiscall basic_streambuf_char_setbuf(basic_streambuf_char *this, char *buf, streamsize count)
909 {
910     TRACE("(%p %p %ld)\n", this, buf, count);
911     return this;
912 }
913
914 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PADH@Z */
915 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEAD_J@Z */
916 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsetbuf, 12)
917 basic_streambuf_char* __thiscall basic_streambuf_char_pubsetbuf(basic_streambuf_char *this, char *buf, streamsize count)
918 {
919     TRACE("(%p %p %ld)\n", this, buf, count);
920     return call_basic_streambuf_char_setbuf(this, buf, count);
921 }
922
923 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
924 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
925 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sync, 4)
926 #define call_basic_streambuf_char_sync(this) CALL_VTBL_FUNC(this, 48, \
927         int, (basic_streambuf_char*), (this))
928 int __thiscall basic_streambuf_char_sync(basic_streambuf_char *this)
929 {
930     TRACE("(%p)\n", this);
931     return 0;
932 }
933
934 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
935 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
936 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsync, 4)
937 int __thiscall basic_streambuf_char_pubsync(basic_streambuf_char *this)
938 {
939     TRACE("(%p)\n", this);
940     return call_basic_streambuf_char_sync(this);
941 }
942
943 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
944 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
945 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetn, 12)
946 streamsize __thiscall basic_streambuf_char_sgetn(basic_streambuf_char *this, char *ptr, streamsize count)
947 {
948     TRACE("(%p %p %ld)\n", this, ptr, count);
949     return call_basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
950 }
951
952 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
953 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JXZ */
954 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_showmanyc, 4)
955 #define call_basic_streambuf_char_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
956         streamsize, (basic_streambuf_char*), (this))
957 streamsize __thiscall basic_streambuf_char_showmanyc(basic_streambuf_char *this)
958 {
959     TRACE("(%p)\n", this);
960     return 0;
961 }
962
963 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
964 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JXZ */
965 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_in_avail, 4)
966 streamsize __thiscall basic_streambuf_char_in_avail(basic_streambuf_char *this)
967 {
968     streamsize ret;
969
970     TRACE("(%p)\n", this);
971
972     ret = basic_streambuf_char__Gnavail(this);
973     return ret ? ret : call_basic_streambuf_char_showmanyc(this);
974 }
975
976 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
977 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
978 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputbackc, 8)
979 int __thiscall basic_streambuf_char_sputbackc(basic_streambuf_char *this, char ch)
980 {
981     TRACE("(%p %d)\n", this, ch);
982     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
983         (*this->prsize)++;
984         (*this->prpos)--;
985         return ch;
986     }
987
988     return call_basic_streambuf_char_pbackfail(this, ch);
989 }
990
991 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
992 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
993 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputc, 8)
994 int __thiscall basic_streambuf_char_sputc(basic_streambuf_char *this, char ch)
995 {
996     TRACE("(%p %d)\n", this, ch);
997     return basic_streambuf_char__Pnavail(this) ?
998         (*basic_streambuf_char__Pninc(this) = ch) :
999         call_basic_streambuf_char_overflow(this, ch);
1000 }
1001
1002 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1003 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1004 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sungetc, 4)
1005 int __thiscall basic_streambuf_char_sungetc(basic_streambuf_char *this)
1006 {
1007     TRACE("(%p)\n", this);
1008     if(*this->prpos && *this->prpos>*this->prbuf) {
1009         (*this->prsize)++;
1010         (*this->prpos)--;
1011         return **this->prpos;
1012     }
1013
1014     return call_basic_streambuf_char_pbackfail(this, EOF);
1015 }
1016
1017 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1018 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1019 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_stossc, 4)
1020 void __thiscall basic_streambuf_char_stossc(basic_streambuf_char *this)
1021 {
1022     TRACE("(%p)\n", this);
1023     if(basic_streambuf_char__Gnavail(this))
1024         basic_streambuf_char__Gninc(this);
1025     else
1026         call_basic_streambuf_char_uflow(this);
1027 }
1028
1029 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1030 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1031 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sbumpc, 4)
1032 int __thiscall basic_streambuf_char_sbumpc(basic_streambuf_char *this)
1033 {
1034     TRACE("(%p)\n", this);
1035     return basic_streambuf_char__Gnavail(this) ?
1036         *basic_streambuf_char__Gninc(this) : call_basic_streambuf_char_uflow(this);
1037 }
1038
1039 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1040 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1041 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetc, 4)
1042 int __thiscall basic_streambuf_char_sgetc(basic_streambuf_char *this)
1043 {
1044     TRACE("(%p)\n", this);
1045     return basic_streambuf_char__Gnavail(this) ?
1046         *basic_streambuf_char_gptr(this) : call_basic_streambuf_char_underflow(this);
1047 }
1048
1049 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1050 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1051 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_snextc, 4)
1052 int __thiscall basic_streambuf_char_snextc(basic_streambuf_char *this)
1053 {
1054     TRACE("(%p)\n", this);
1055
1056     if(basic_streambuf_char__Gnavail(this) > 1)
1057         return *basic_streambuf_char__Gnpreinc(this);
1058     return basic_streambuf_char_sbumpc(this)==EOF ?
1059         EOF : basic_streambuf_char_sgetc(this);
1060 }
1061
1062 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADH@Z */
1063 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_J@Z */
1064 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsgetn, 12)
1065 #define call_basic_streambuf_char_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
1066         streamsize, (basic_streambuf_char*, char*, streamsize), (this, ptr, count))
1067 streamsize __thiscall basic_streambuf_char_xsgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1068 {
1069     TRACE("(%p %p %ld)\n", this, ptr, count);
1070     return call_basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1071 }
1072
1073 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPBDH@Z */
1074 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEBD_J@Z */
1075 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsputn, 12)
1076 #define call_basic_streambuf_char_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 32, \
1077         streamsize, (basic_streambuf_char*, const char*, streamsize), (this, ptr, count))
1078 streamsize __thiscall basic_streambuf_char_xsputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1079 {
1080     streamsize copied, chunk;
1081
1082     TRACE("(%p %p %ld)\n", this, ptr, count);
1083
1084     for(copied=0; copied<count;) {
1085         chunk = basic_streambuf_char__Pnavail(this);
1086         if(chunk > count-copied)
1087             chunk = count-copied;
1088
1089         if(chunk) {
1090             memcpy(*this->pwpos, ptr+copied, chunk);
1091             *this->pwpos += chunk;
1092             *this->pwsize -= chunk;
1093             copied += chunk;
1094         }else if(call_basic_streambuf_char_overflow(this, ptr[copied]) != EOF) {
1095             copied++;
1096         }else {
1097             break;
1098         }
1099     }
1100
1101     return copied;
1102 }
1103
1104 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z */
1105 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z */
1106 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputn, 12)
1107 streamsize __thiscall basic_streambuf_char_sputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1108 {
1109     TRACE("(%p %p %ld)\n", this, ptr, count);
1110     return call_basic_streambuf_char_xsputn(this, ptr, count);
1111 }
1112
1113 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1114 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1115 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1116 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1117 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp_next, 16)
1118 void __thiscall basic_streambuf_wchar_setp_next(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1119 {
1120     TRACE("(%p %p %p %p)\n", this, first, next, last);
1121
1122     this->wbuf = first;
1123     this->wpos = next;
1124     this->wsize = last-next;
1125 }
1126
1127 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W0@Z */
1128 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W0@Z */
1129 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG0@Z */
1130 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG0@Z */
1131 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp, 12)
1132 void __thiscall basic_streambuf_wchar_setp(basic_streambuf_wchar *this, wchar_t *first, wchar_t *last)
1133 {
1134     basic_streambuf_wchar_setp_next(this, first, first, last);
1135 }
1136
1137 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1138 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1139 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1140 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1141 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setg, 16)
1142 void __thiscall basic_streambuf_wchar_setg(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1143 {
1144     TRACE("(%p %p %p %p)\n", this, first, next, last);
1145
1146     this->rbuf = first;
1147     this->rpos = next;
1148     this->rsize = last-next;
1149 }
1150
1151 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXXZ */
1152 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXXZ */
1153 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXXZ */
1154 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXXZ */
1155 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init_empty, 4)
1156 void __thiscall basic_streambuf_wchar__Init_empty(basic_streambuf_wchar *this)
1157 {
1158     TRACE("(%p)\n", this);
1159
1160     this->prbuf = &this->rbuf;
1161     this->pwbuf = &this->wbuf;
1162     this->prpos = &this->rpos;
1163     this->pwpos = &this->wpos;
1164     this->prsize = &this->rsize;
1165     this->pwsize = &this->wsize;
1166
1167     basic_streambuf_wchar_setp(this, NULL, NULL);
1168     basic_streambuf_wchar_setg(this, NULL, NULL, NULL);
1169 }
1170
1171 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1172 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1173 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor_uninitialized, 8)
1174 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1175 {
1176     TRACE("(%p %d)\n", this, uninitialized);
1177     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1178     mutex_ctor(&this->lock);
1179     return this;
1180 }
1181
1182 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1183 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1184 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor_uninitialized, 8)
1185 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1186 {
1187     TRACE("(%p %d)\n", this, uninitialized);
1188     basic_streambuf_wchar_ctor_uninitialized(this, uninitialized);
1189     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1190     return this;
1191 }
1192
1193 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
1194 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
1195 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor, 4)
1196 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor(basic_streambuf_wchar *this)
1197 {
1198     TRACE("(%p)\n", this);
1199
1200     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1201     mutex_ctor(&this->lock);
1202     this->loc = MSVCRT_operator_new(sizeof(locale));
1203     locale_ctor(this->loc);
1204     basic_streambuf_wchar__Init_empty(this);
1205
1206     return this;
1207 }
1208
1209 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@XZ */
1210 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@XZ */
1211 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor, 4)
1212 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor(basic_streambuf_wchar *this)
1213 {
1214     TRACE("(%p)\n", this);
1215     basic_streambuf_wchar_ctor(this);
1216     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1217     return this;
1218 }
1219
1220 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
1221 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
1222 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
1223 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
1224 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_dtor, 4)
1225 void __thiscall basic_streambuf_wchar_dtor(basic_streambuf_wchar *this)
1226 {
1227     TRACE("(%p)\n", this);
1228
1229     mutex_dtor(&this->lock);
1230     locale_dtor(this->loc);
1231     MSVCRT_operator_delete(this->loc);
1232 }
1233
1234 DEFINE_THISCALL_WRAPPER(MSVCP_basic_streambuf_wchar_vector_dtor, 8)
1235 basic_streambuf_wchar* __thiscall MSVCP_basic_streambuf_wchar_vector_dtor(basic_streambuf_wchar *this, unsigned int flags)
1236 {
1237     TRACE("(%p %x)\n", this, flags);
1238     if(flags & 2) {
1239         /* we have an array, with the number of elements stored before the first object */
1240         int i, *ptr = (int *)this-1;
1241
1242         for(i=*ptr-1; i>=0; i--)
1243             basic_streambuf_wchar_dtor(this+i);
1244         MSVCRT_operator_delete(ptr);
1245     } else {
1246         basic_streambuf_wchar_dtor(this);
1247         if(flags & 1)
1248             MSVCRT_operator_delete(this);
1249     }
1250
1251     return this;
1252 }
1253
1254 DEFINE_THISCALL_WRAPPER(MSVCP_basic_streambuf_short_vector_dtor, 8)
1255 basic_streambuf_wchar* __thiscall MSVCP_basic_streambuf_short_vector_dtor(basic_streambuf_wchar *this, unsigned int flags)
1256 {
1257     TRACE("(%p %x)\n", this, flags);
1258     return MSVCP_basic_streambuf_wchar_vector_dtor(this, flags);
1259 }
1260
1261 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1262 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1263 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1264 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1265 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gnavail, 4)
1266 streamsize __thiscall basic_streambuf_wchar__Gnavail(const basic_streambuf_wchar *this)
1267 {
1268     TRACE("(%p)\n", this);
1269     return *this->prpos ? *this->prsize : 0;
1270 }
1271
1272 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1273 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1274 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1275 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1276 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gndec, 4)
1277 wchar_t* __thiscall basic_streambuf_wchar__Gndec(basic_streambuf_wchar *this)
1278 {
1279     TRACE("(%p)\n", this);
1280     (*this->prsize)++;
1281     (*this->prpos)--;
1282     return *this->prpos;
1283 }
1284
1285 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1286 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1287 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1288 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1289 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gninc, 4)
1290 wchar_t* __thiscall basic_streambuf_wchar__Gninc(basic_streambuf_wchar *this)
1291 {
1292     TRACE("(%p)\n", this);
1293     (*this->prsize)--;
1294     return (*this->prpos)++;
1295 }
1296
1297 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1298 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1299 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1300 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1301 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gnpreinc, 4)
1302 wchar_t* __thiscall basic_streambuf_wchar__Gnpreinc(basic_streambuf_wchar *this)
1303 {
1304     TRACE("(%p)\n", this);
1305     (*this->prsize)--;
1306     (*this->prpos)++;
1307     return *this->prpos;
1308 }
1309
1310 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPAPA_W0PAH001@Z */
1311 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAPEA_W0PEAH001@Z */
1312 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAPAG0PAH001@Z */
1313 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAPEAG0PEAH001@Z */
1314 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init, 28)
1315 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)
1316 {
1317     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1318
1319     this->prbuf = gf;
1320     this->pwbuf = pf;
1321     this->prpos = gn;
1322     this->pwpos = pn;
1323     this->prsize = gc;
1324     this->pwsize = pc;
1325 }
1326
1327 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1328 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1329 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1330 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1331 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Lock, 4)
1332 void __thiscall basic_streambuf_wchar__Lock(basic_streambuf_wchar *this)
1333 {
1334     TRACE("(%p)\n", this);
1335     mutex_lock(&this->lock);
1336 }
1337
1338 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1339 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1340 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1341 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1342 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pnavail, 4)
1343 streamsize __thiscall basic_streambuf_wchar__Pnavail(const basic_streambuf_wchar *this)
1344 {
1345     TRACE("(%p)\n", this);
1346     return *this->pwpos ? *this->pwsize : 0;
1347 }
1348
1349 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1350 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1351 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1352 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1353 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pninc, 4)
1354 wchar_t* __thiscall basic_streambuf_wchar__Pninc(basic_streambuf_wchar *this)
1355 {
1356     TRACE("(%p)\n", this);
1357     (*this->pwsize)--;
1358     return (*this->pwpos)++;
1359 }
1360
1361 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1362 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1363 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1364 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1365 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_underflow, 4)
1366 #define call_basic_streambuf_wchar_underflow(this) CALL_VTBL_FUNC(this, 16, \
1367         unsigned short, (basic_streambuf_wchar*), (this))
1368 unsigned short __thiscall basic_streambuf_wchar_underflow(basic_streambuf_wchar *this)
1369 {
1370     TRACE("(%p)\n", this);
1371     return WEOF;
1372 }
1373
1374 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1375 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1376 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1377 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1378 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_uflow, 4)
1379 #define call_basic_streambuf_wchar_uflow(this) CALL_VTBL_FUNC(this, 20, \
1380         unsigned short, (basic_streambuf_wchar*), (this))
1381 unsigned short __thiscall basic_streambuf_wchar_uflow(basic_streambuf_wchar *this)
1382 {
1383     int ret;
1384
1385     TRACE("(%p)\n", this);
1386
1387     if(call_basic_streambuf_wchar_underflow(this)==WEOF)
1388         return WEOF;
1389
1390     ret = **this->prpos;
1391     (*this->prsize)--;
1392     (*this->prpos)++;
1393     return ret;
1394 }
1395
1396 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WIH@Z */
1397 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_K_J@Z */
1398 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGIH@Z */
1399 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_K_J@Z */
1400 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Xsgetn_s, 16)
1401 #define call_basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count) CALL_VTBL_FUNC(this, 28, \
1402         streamsize, (basic_streambuf_wchar*, wchar_t*, MSVCP_size_t, streamsize), (this, ptr, size, count))
1403 streamsize __thiscall basic_streambuf_wchar__Xsgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1404 {
1405     streamsize copied, chunk;
1406
1407     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1408
1409     for(copied=0; copied<count && size;) {
1410         chunk = basic_streambuf_wchar__Gnavail(this);
1411         if(chunk > count-copied)
1412             chunk = count-copied;
1413
1414         if(chunk) {
1415             memcpy_s(ptr+copied, size, *this->prpos, chunk);
1416             *this->prpos += chunk;
1417             *this->prsize -= chunk;
1418             copied += chunk;
1419             size -= chunk;
1420         }else if((ptr[copied] = call_basic_streambuf_wchar_uflow(this)) != WEOF) {
1421             copied++;
1422             size--;
1423         }else {
1424             break;
1425         }
1426     }
1427
1428     return copied;
1429 }
1430
1431 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
1432 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
1433 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
1434 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
1435 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Sgetn_s, 16)
1436 streamsize __thiscall basic_streambuf_wchar__Sgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1437 {
1438     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1439     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count);
1440 }
1441
1442 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1443 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1444 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1445 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1446 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Unlock, 4)
1447 void __thiscall basic_streambuf_wchar__Unlock(basic_streambuf_wchar *this)
1448 {
1449     TRACE("(%p)\n", this);
1450     mutex_unlock(&this->lock);
1451 }
1452
1453 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1454 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1455 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1456 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1457 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_eback, 4)
1458 wchar_t* __thiscall basic_streambuf_wchar_eback(const basic_streambuf_wchar *this)
1459 {
1460     TRACE("(%p)\n", this);
1461     return *this->prbuf;
1462 }
1463
1464 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1465 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1466 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1467 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1468 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gptr, 4)
1469 wchar_t* __thiscall basic_streambuf_wchar_gptr(const basic_streambuf_wchar *this)
1470 {
1471     TRACE("(%p)\n", this);
1472     return *this->prpos;
1473 }
1474
1475 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1476 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1477 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1478 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1479 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_egptr, 4)
1480 wchar_t* __thiscall basic_streambuf_wchar_egptr(const basic_streambuf_wchar *this)
1481 {
1482     TRACE("(%p)\n", this);
1483     return *this->prpos+*this->prsize;
1484 }
1485
1486 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1487 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1488 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1489 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1490 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_epptr, 4)
1491 wchar_t* __thiscall basic_streambuf_wchar_epptr(const basic_streambuf_wchar *this)
1492 {
1493     TRACE("(%p)\n", this);
1494     return *this->pwpos+*this->pwsize;
1495 }
1496
1497 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1498 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1499 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1500 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1501 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gbump, 8)
1502 void __thiscall basic_streambuf_wchar_gbump(basic_streambuf_wchar *this, int off)
1503 {
1504     TRACE("(%p %d)\n", this, off);
1505     *this->prpos += off;
1506     *this->prsize -= off;
1507 }
1508
1509 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QBE?AVlocale@2@XZ */
1510 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEBA?AVlocale@2@XZ */
1511 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QBE?AVlocale@2@XZ */
1512 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEBA?AVlocale@2@XZ */
1513 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_getloc, 8)
1514 locale* __thiscall basic_streambuf_wchar_getloc(const basic_streambuf_wchar *this, locale *ret)
1515 {
1516     TRACE("(%p)\n", this);
1517     return locale_copy_ctor(ret, this->loc);
1518 }
1519
1520 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
1521 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
1522 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
1523 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
1524 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_imbue, 8)
1525 #define call_basic_streambuf_wchar_imbue(this, loc) CALL_VTBL_FUNC(this, 52, \
1526         void, (basic_streambuf_wchar*, const locale*), (this, loc))
1527 void __thiscall basic_streambuf_wchar_imbue(basic_streambuf_wchar *this, const locale *loc)
1528 {
1529     TRACE("(%p %p)\n", this, loc);
1530 }
1531
1532 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1533 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1534 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1535 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1536 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_overflow, 8)
1537 #define call_basic_streambuf_wchar_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1538         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1539 unsigned short __thiscall basic_streambuf_wchar_overflow(basic_streambuf_wchar *this, unsigned short ch)
1540 {
1541     TRACE("(%p %d)\n", this, ch);
1542     return WEOF;
1543 }
1544
1545 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1546 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1547 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1548 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1549 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbackfail, 8)
1550 #define call_basic_streambuf_wchar_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1551         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1552 unsigned short __thiscall basic_streambuf_wchar_pbackfail(basic_streambuf_wchar *this, unsigned short ch)
1553 {
1554     TRACE("(%p %d)\n", this, ch);
1555     return WEOF;
1556 }
1557
1558 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1559 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1560 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1561 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1562 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbase, 4)
1563 wchar_t* __thiscall basic_streambuf_wchar_pbase(const basic_streambuf_wchar *this)
1564 {
1565     TRACE("(%p)\n", this);
1566     return *this->pwbuf;
1567 }
1568
1569 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1570 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1571 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1572 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1573 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbump, 8)
1574 void __thiscall basic_streambuf_wchar_pbump(basic_streambuf_wchar *this, int off)
1575 {
1576     TRACE("(%p %d)\n", this, off);
1577     *this->pwpos += off;
1578     *this->pwsize -= off;
1579 }
1580
1581 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1582 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1583 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1584 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1585 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pptr, 4)
1586 wchar_t* __thiscall basic_streambuf_wchar_pptr(const basic_streambuf_wchar *this)
1587 {
1588     TRACE("(%p)\n", this);
1589     return *this->pwpos;
1590 }
1591
1592 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1593 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1594 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1595 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1596 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubimbue, 12)
1597 locale* __thiscall basic_streambuf_wchar_pubimbue(basic_streambuf_wchar *this, locale *ret, const locale *loc)
1598 {
1599     TRACE("(%p %p)\n", this, loc);
1600     memcpy(ret, this->loc, sizeof(locale));
1601     call_basic_streambuf_wchar_imbue(this, loc);
1602     locale_copy_ctor(this->loc, loc);
1603     return ret;
1604 }
1605
1606 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1607 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1608 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1609 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1610 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekoff, 20)
1611 #define call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 36, \
1612         fpos_int*, (basic_streambuf_wchar*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1613 fpos_int* __thiscall basic_streambuf_wchar_seekoff(basic_streambuf_wchar *this,
1614         fpos_int *ret, streamoff off, int way, int mode)
1615 {
1616     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1617     ret->off = 0;
1618     ret->pos = -1;
1619     ret->state = 0;
1620     return ret;
1621 }
1622
1623 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1624 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1625 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1626 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1627 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff, 20)
1628 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff(basic_streambuf_wchar *this,
1629         fpos_int *ret, streamoff off, int way, int mode)
1630 {
1631     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1632     return call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode);
1633 }
1634
1635 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
1636 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
1637 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
1638 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
1639 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff_old, 20)
1640 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff_old(basic_streambuf_wchar *this,
1641         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
1642 {
1643     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1644     return basic_streambuf_wchar_pubseekoff(this, ret, off, way, mode);
1645 }
1646
1647 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1648 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1649 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1650 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1651 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekpos, 36)
1652 #define call_basic_streambuf_wchar_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 40, \
1653         fpos_int*, (basic_streambuf_wchar*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
1654 fpos_int* __thiscall basic_streambuf_wchar_seekpos(basic_streambuf_wchar *this,
1655         fpos_int *ret, fpos_int pos, int mode)
1656 {
1657     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1658     ret->off = 0;
1659     ret->pos = -1;
1660     ret->state = 0;
1661     return ret;
1662 }
1663
1664 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1665 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1666 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1667 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1668 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos, 36)
1669 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos(basic_streambuf_wchar *this,
1670         fpos_int *ret, fpos_int pos, int mode)
1671 {
1672     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1673     return call_basic_streambuf_wchar_seekpos(this, ret, pos, mode);
1674 }
1675
1676 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
1677 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
1678 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
1679 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
1680 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos_old, 36)
1681 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos_old(basic_streambuf_wchar *this,
1682         fpos_int *ret, fpos_int pos, unsigned int mode)
1683 {
1684     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1685     return basic_streambuf_wchar_pubseekpos(this, ret, pos, mode);
1686 }
1687
1688 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEPAV12@PA_WH@Z */
1689 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV12@PEA_W_J@Z */
1690 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEPAV12@PAGH@Z */
1691 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAPEAV12@PEAG_J@Z */
1692 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setbuf, 12)
1693 #define call_basic_streambuf_wchar_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 44, \
1694         basic_streambuf_wchar*, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, buf, count))
1695 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_setbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
1696 {
1697     TRACE("(%p %p %ld)\n", this, buf, count);
1698     return this;
1699 }
1700
1701 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PA_WH@Z */
1702 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEA_W_J@Z */
1703 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PAGH@Z */
1704 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEAG_J@Z */
1705 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsetbuf, 12)
1706 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_pubsetbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
1707 {
1708     TRACE("(%p %p %ld)\n", this, buf, count);
1709     return call_basic_streambuf_wchar_setbuf(this, buf, count);
1710 }
1711
1712 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
1713 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
1714 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
1715 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
1716 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sync, 4)
1717 #define call_basic_streambuf_wchar_sync(this) CALL_VTBL_FUNC(this, 48, \
1718         int, (basic_streambuf_wchar*), (this))
1719 int __thiscall basic_streambuf_wchar_sync(basic_streambuf_wchar *this)
1720 {
1721     TRACE("(%p)\n", this);
1722     return 0;
1723 }
1724
1725 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
1726 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
1727 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
1728 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHXZ */
1729 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsync, 4)
1730 int __thiscall basic_streambuf_wchar_pubsync(basic_streambuf_wchar *this)
1731 {
1732     TRACE("(%p)\n", this);
1733     return call_basic_streambuf_wchar_sync(this);
1734 }
1735
1736 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
1737 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
1738 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
1739 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
1740 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetn, 12)
1741 streamsize __thiscall basic_streambuf_wchar_sgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
1742 {
1743     TRACE("(%p %p %ld)\n", this, ptr, count);
1744     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
1745 }
1746
1747 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
1748 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JXZ */
1749 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
1750 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JXZ */
1751 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_showmanyc, 4)
1752 #define call_basic_streambuf_wchar_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
1753         streamsize, (basic_streambuf_wchar*), (this))
1754 streamsize __thiscall basic_streambuf_wchar_showmanyc(basic_streambuf_wchar *this)
1755 {
1756     TRACE("(%p)\n", this);
1757     return 0;
1758 }
1759
1760 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
1761 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JXZ */
1762 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
1763 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JXZ */
1764 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_in_avail, 4)
1765 streamsize __thiscall basic_streambuf_wchar_in_avail(basic_streambuf_wchar *this)
1766 {
1767     streamsize ret;
1768
1769     TRACE("(%p)\n", this);
1770
1771     ret = basic_streambuf_wchar__Gnavail(this);
1772     return ret ? ret : call_basic_streambuf_wchar_showmanyc(this);
1773 }
1774
1775 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
1776 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
1777 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
1778 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
1779 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputbackc, 8)
1780 unsigned short __thiscall basic_streambuf_wchar_sputbackc(basic_streambuf_wchar *this, wchar_t ch)
1781 {
1782     TRACE("(%p %d)\n", this, ch);
1783     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
1784         (*this->prsize)++;
1785         (*this->prpos)--;
1786         return ch;
1787     }
1788
1789     return call_basic_streambuf_wchar_pbackfail(this, ch);
1790 }
1791
1792 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
1793 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
1794 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
1795 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHG@Z */
1796 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputc, 8)
1797 unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar *this, wchar_t ch)
1798 {
1799     TRACE("(%p %d)\n", this, ch);
1800     return basic_streambuf_wchar__Pnavail(this) ?
1801         (*basic_streambuf_wchar__Pninc(this) = ch) :
1802         call_basic_streambuf_wchar_overflow(this, ch);
1803 }
1804
1805 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1806 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1807 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1808 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1809 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sungetc, 4)
1810 unsigned short __thiscall basic_streambuf_wchar_sungetc(basic_streambuf_wchar *this)
1811 {
1812     TRACE("(%p)\n", this);
1813     if(*this->prpos && *this->prpos>*this->prbuf) {
1814         (*this->prsize)++;
1815         (*this->prpos)--;
1816         return **this->prpos;
1817     }
1818
1819     return call_basic_streambuf_wchar_pbackfail(this, WEOF);
1820 }
1821
1822 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1823 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1824 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1825 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1826 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_stossc, 4)
1827 void __thiscall basic_streambuf_wchar_stossc(basic_streambuf_wchar *this)
1828 {
1829     TRACE("(%p)\n", this);
1830     if(basic_streambuf_wchar__Gnavail(this))
1831         basic_streambuf_wchar__Gninc(this);
1832     else
1833         call_basic_streambuf_wchar_uflow(this);
1834 }
1835
1836 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1837 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1838 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1839 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1840 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sbumpc, 4)
1841 unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar *this)
1842 {
1843     TRACE("(%p)\n", this);
1844     return basic_streambuf_wchar__Gnavail(this) ?
1845         *basic_streambuf_wchar__Gninc(this) : call_basic_streambuf_wchar_uflow(this);
1846 }
1847
1848 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1849 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1850 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1851 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1852 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetc, 4)
1853 unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar *this)
1854 {
1855     TRACE("(%p)\n", this);
1856     return basic_streambuf_wchar__Gnavail(this) ?
1857         *basic_streambuf_wchar_gptr(this) : call_basic_streambuf_wchar_underflow(this);
1858 }
1859
1860 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1861 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1862 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1863 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1864 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_snextc, 4)
1865 unsigned short __thiscall basic_streambuf_wchar_snextc(basic_streambuf_wchar *this)
1866 {
1867     TRACE("(%p)\n", this);
1868
1869     if(basic_streambuf_wchar__Gnavail(this) > 1)
1870         return *basic_streambuf_wchar__Gnpreinc(this);
1871     return basic_streambuf_wchar_sbumpc(this)==WEOF ?
1872         WEOF : basic_streambuf_wchar_sgetc(this);
1873 }
1874
1875 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WH@Z */
1876 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_J@Z */
1877 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGH@Z */
1878 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_J@Z */
1879 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsgetn, 12)
1880 #define call_basic_streambuf_wchar_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
1881         streamsize, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, ptr, count))
1882 streamsize __thiscall basic_streambuf_wchar_xsgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
1883 {
1884     TRACE("(%p %p %ld)\n", this, ptr, count);
1885     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
1886 }
1887
1888 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPB_WH@Z */
1889 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEB_W_J@Z */
1890 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPBGH@Z */
1891 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEBG_J@Z */
1892 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsputn, 12)
1893 #define call_basic_streambuf_wchar_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 32, \
1894         streamsize, (basic_streambuf_wchar*, const wchar_t*, streamsize), (this, ptr, count))
1895 streamsize __thiscall basic_streambuf_wchar_xsputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
1896 {
1897     streamsize copied, chunk;
1898
1899     TRACE("(%p %p %ld)\n", this, ptr, count);
1900
1901     for(copied=0; copied<count;) {
1902         chunk = basic_streambuf_wchar__Pnavail(this);
1903         if(chunk > count-copied)
1904             chunk = count-copied;
1905
1906         if(chunk) {
1907             memcpy(*this->pwpos, ptr+copied, chunk);
1908             *this->pwpos += chunk;
1909             *this->pwsize -= chunk;
1910             copied += chunk;
1911         }else if(call_basic_streambuf_wchar_overflow(this, ptr[copied]) != WEOF) {
1912             copied++;
1913         }else {
1914             break;
1915         }
1916     }
1917
1918     return copied;
1919 }
1920
1921 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPB_WH@Z */
1922 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEB_W_J@Z */
1923 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPBGH@Z */
1924 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEBG_J@Z */
1925 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputn, 12)
1926 streamsize __thiscall basic_streambuf_wchar_sputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
1927 {
1928     TRACE("(%p %p %ld)\n", this, ptr, count);
1929     return call_basic_streambuf_wchar_xsputn(this, ptr, count);
1930 }
1931
1932 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
1933 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
1934 int basic_filebuf_char__Init__Stinit = 0;
1935
1936 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
1937 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
1938 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Init, 12)
1939 void __thiscall basic_filebuf_char__Init(basic_filebuf_char *this, FILE *file, basic_filebuf__Initfl which)
1940 {
1941     TRACE("(%p %p %d)\n", this, file, which);
1942
1943     this->cvt = NULL;
1944     this->wrotesome = FALSE;
1945     this->state = basic_filebuf_char__Init__Stinit;
1946     this->close = (which == INITFL_open);
1947     this->file = file;
1948
1949     basic_streambuf_char__Init_empty(&this->base);
1950     if(file)
1951         basic_streambuf_char__Init(&this->base, &file->_base, &file->_ptr,
1952                 &file->_cnt, &file->_base, &file->_ptr, &file->_cnt);
1953 }
1954
1955 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAV?$codecvt@DDH@2@@Z */
1956 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$codecvt@DDH@2@@Z */
1957 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Initcvt, 8)
1958 void __thiscall basic_filebuf_char__Initcvt(basic_filebuf_char *this, codecvt_char *cvt)
1959 {
1960     TRACE("(%p %p)\n", this, cvt);
1961
1962     if(codecvt_base_always_noconv(&cvt->base)) {
1963         this->cvt = NULL;
1964     }else {
1965         basic_streambuf_char__Init_empty(&this->base);
1966         this->cvt = cvt;
1967     }
1968 }
1969
1970 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAE_NXZ */
1971 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAA_NXZ */
1972 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Endwrite, 4)
1973 MSVCP_bool __thiscall basic_filebuf_char__Endwrite(basic_filebuf_char *this)
1974 {
1975     TRACE("(%p)\n", this);
1976
1977     if(!this->wrotesome || !this->cvt)
1978         return TRUE;
1979
1980
1981     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
1982         return FALSE;
1983
1984     while(1) {
1985         /* TODO: check if we need a dynamic buffer here */
1986         char buf[128];
1987         char *next;
1988         int ret;
1989
1990         ret = codecvt_char_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
1991         switch(ret) {
1992         case CODECVT_ok:
1993             this->wrotesome = FALSE;
1994             /* fall through */
1995         case CODECVT_partial:
1996             if(!fwrite(buf, next-buf, 1, this->file))
1997                 return FALSE;
1998             if(this->wrotesome)
1999                 break;
2000             /* fall through */
2001         case CODECVT_noconv:
2002             if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2003                 return FALSE;
2004             return TRUE;
2005         default:
2006             return FALSE;
2007         }
2008     }
2009 }
2010
2011 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@XZ */
2012 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@XZ */
2013 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_close, 4)
2014 basic_filebuf_char* __thiscall basic_filebuf_char_close(basic_filebuf_char *this)
2015 {
2016     basic_filebuf_char *ret = this;
2017
2018     TRACE("(%p)\n", this);
2019
2020     if(!this->file)
2021         return NULL;
2022
2023     /* TODO: handle exceptions */
2024     if(!basic_filebuf_char__Endwrite(this))
2025         ret = NULL;
2026     if(!fclose(this->file))
2027         ret  = NULL;
2028
2029     basic_filebuf_char__Init(this, NULL, INITFL_close);
2030     return ret;
2031 }
2032
2033 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
2034 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2035 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_file, 8)
2036 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_file(basic_filebuf_char *this, FILE *file)
2037 {
2038     TRACE("(%p %p)\n", this, file);
2039
2040     basic_streambuf_char_ctor(&this->base);
2041     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2042
2043     basic_filebuf_char__Init(this, file, INITFL_new);
2044     return this;
2045 }
2046
2047 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
2048 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
2049 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor, 4)
2050 basic_filebuf_char* __thiscall basic_filebuf_char_ctor(basic_filebuf_char *this)
2051 {
2052     return basic_filebuf_char_ctor_file(this, NULL);
2053 }
2054
2055 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
2056 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
2057 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_uninitialized, 8)
2058 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_uninitialized(basic_filebuf_char *this, int uninitialized)
2059 {
2060     TRACE("(%p %d)\n", this, uninitialized);
2061
2062     basic_streambuf_char_ctor(&this->base);
2063     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2064     return this;
2065 }
2066
2067 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
2068 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
2069 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_dtor, 4)
2070 void __thiscall basic_filebuf_char_dtor(basic_filebuf_char *this)
2071 {
2072     TRACE("(%p)\n", this);
2073
2074     if(this->close)
2075         basic_filebuf_char_close(this);
2076     basic_streambuf_char_dtor(&this->base);
2077 }
2078
2079 DEFINE_THISCALL_WRAPPER(MSVCP_basic_filebuf_char_vector_dtor, 8)
2080 basic_filebuf_char* __thiscall MSVCP_basic_filebuf_char_vector_dtor(basic_filebuf_char *this, unsigned int flags)
2081 {
2082     TRACE("(%p %x)\n", this, flags);
2083     if(flags & 2) {
2084         /* we have an array, with the number of elements stored before the first object */
2085         int i, *ptr = (int *)this-1;
2086
2087         for(i=*ptr-1; i>=0; i--)
2088             basic_filebuf_char_dtor(this+i);
2089         MSVCRT_operator_delete(ptr);
2090     } else {
2091         basic_filebuf_char_dtor(this);
2092         if(flags & 1)
2093             MSVCRT_operator_delete(this);
2094     }
2095
2096     return this;
2097 }
2098
2099 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QBE_NXZ */
2100 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
2101 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_is_open, 4)
2102 MSVCP_bool __thiscall basic_filebuf_char_is_open(const basic_filebuf_char *this)
2103 {
2104     TRACE("(%p)\n", this);
2105     return this->file != NULL;
2106 }
2107
2108 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PB_WHH@Z */
2109 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
2110 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBGHH@Z */
2111 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBGHH@Z */
2112 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_wchar, 16)
2113 basic_filebuf_char* __thiscall basic_filebuf_char_open_wchar(basic_filebuf_char *this, const wchar_t *name, int mode, int prot)
2114 {
2115     static const wchar_t rW[] = {'r',0};
2116     static const struct {
2117         int mode;
2118         const wchar_t str[4];
2119         const wchar_t str_bin[4];
2120     } str_mode[] = {
2121         {OPENMODE_out,                            {'w',0},     {'w','b',0}},
2122         {OPENMODE_out|OPENMODE_app,               {'a',0},     {'a','b',0}},
2123         {OPENMODE_app,                            {'a',0},     {'a','b',0}},
2124         {OPENMODE_out|OPENMODE_trunc,             {'w',0},     {'w','b',0}},
2125         {OPENMODE_in,                             {'r',0},     {'r','b',0}},
2126         {OPENMODE_in|OPENMODE_out,                {'r','+',0}, {'r','+','b',0}},
2127         {OPENMODE_in|OPENMODE_out|OPENMODE_trunc, {'w','+',0}, {'w','+','b',0}},
2128         {OPENMODE_in|OPENMODE_out|OPENMODE_app,   {'a','+',0}, {'a','+','b',0}},
2129         {OPENMODE_in|OPENMODE_app,                {'a','+',0}, {'a','+','b',0}}
2130     };
2131
2132     int real_mode = mode & ~(OPENMODE_ate|OPENMODE__Nocreate|OPENMODE__Noreplace|OPENMODE_binary);
2133     int mode_idx;
2134     FILE *f = NULL;
2135
2136     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
2137
2138     if(basic_filebuf_char_is_open(this))
2139         return NULL;
2140
2141     for(mode_idx=0; mode_idx<sizeof(str_mode)/sizeof(str_mode[0]); mode_idx++)
2142         if(str_mode[mode_idx].mode == real_mode)
2143             break;
2144     if(mode_idx == sizeof(str_mode)/sizeof(str_mode[0]))
2145         return NULL;
2146
2147     if((mode & OPENMODE__Nocreate) && !(f = _wfopen(name, rW)))
2148         return NULL;
2149     else if(f)
2150         fclose(f);
2151
2152     if((mode & OPENMODE__Noreplace) && (mode & (OPENMODE_out|OPENMODE_app))
2153             && (f = _wfopen(name, rW))) {
2154         fclose(f);
2155         return NULL;
2156     }
2157
2158     f = _wfsopen(name, (mode & OPENMODE_binary) ? str_mode[mode_idx].str_bin
2159             : str_mode[mode_idx].str, prot);
2160     if(!f)
2161         return NULL;
2162
2163     if((mode & OPENMODE_ate) && fseek(f, 0, SEEK_END)) {
2164         fclose(f);
2165         return NULL;
2166     }
2167
2168     basic_filebuf_char__Init(this, f, INITFL_open);
2169     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(this->base.loc));
2170     return this;
2171 }
2172
2173 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PB_WI@Z */
2174 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEB_WI@Z */
2175 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBGI@Z */
2176 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBGI@Z */
2177 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_wchar_mode, 12)
2178 basic_filebuf_char* __thiscall basic_filebuf_char_open_wchar_mode(basic_filebuf_char *this, const wchar_t *name, unsigned int mode)
2179 {
2180     return basic_filebuf_char_open_wchar(this, name, mode, SH_DENYNO);
2181 }
2182
2183 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDHH@Z */
2184 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDHH@Z */
2185 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open, 16)
2186 basic_filebuf_char* __thiscall basic_filebuf_char_open(basic_filebuf_char *this, const char *name, int mode, int prot)
2187 {
2188     wchar_t nameW[FILENAME_MAX];
2189
2190     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
2191
2192     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2193         return NULL;
2194     return basic_filebuf_char_open_wchar(this, nameW, mode, prot);
2195 }
2196
2197 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDI@Z */
2198 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDI@Z */
2199 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_mode, 12)
2200 basic_filebuf_char* __thiscall basic_filebuf_char_open_mode(basic_filebuf_char *this, const char *name, unsigned int mode)
2201 {
2202     return basic_filebuf_char_open(this, name, mode, SH_DENYNO);
2203 }
2204
2205 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2206 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2207 #define call_basic_filebuf_char_overflow(this, c) CALL_VTBL_FUNC(this, 4, \
2208         int, (basic_filebuf_char*, int), (this, c))
2209 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_overflow, 8)
2210 int __thiscall basic_filebuf_char_overflow(basic_filebuf_char *this, int c)
2211 {
2212     char buf[8], *dyn_buf;
2213     char ch = c, *to_next;
2214     const char *from_next;
2215     int ret, max_size;
2216
2217
2218     TRACE("(%p %d)\n", this, c);
2219
2220     if(!basic_filebuf_char_is_open(this))
2221         return EOF;
2222     if(c == EOF)
2223         return !c;
2224
2225     if(!this->cvt)
2226         return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2227
2228     from_next = &ch;
2229     do {
2230         ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2231                 &from_next, buf, buf+sizeof(buf), &to_next);
2232
2233         switch(ret) {
2234         case CODECVT_partial:
2235             if(to_next == buf)
2236                 break;
2237             /* fall through */
2238         case CODECVT_ok:
2239             if(!fwrite(buf, to_next-buf, 1, this->file))
2240                 return EOF;
2241             if(ret == CODECVT_partial)
2242                 continue;
2243             return c;
2244         case CODECVT_noconv:
2245             return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2246         default:
2247             return EOF;
2248         }
2249     } while(0);
2250
2251     max_size = codecvt_base_max_length(&this->cvt->base);
2252     dyn_buf = malloc(max_size);
2253     if(!dyn_buf)
2254         return EOF;
2255
2256     ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2257             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
2258
2259     switch(ret) {
2260     case CODECVT_ok:
2261         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
2262         free(dyn_buf);
2263         return ret ? c : EOF;
2264     case CODECVT_partial:
2265         ERR("buffer should be big enough to store all output\n");
2266         /* fall through */
2267     default:
2268         free(dyn_buf);
2269         return EOF;
2270     }
2271 }
2272
2273 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2274 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2275 #define call_basic_filebuf_char_pbackfail(this, c) CALL_VTBL_FUNC(this, 8, \
2276         int, (basic_filebuf_char*, int), (this, c))
2277 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_pbackfail, 8)
2278 int __thiscall basic_filebuf_char_pbackfail(basic_filebuf_char *this, int c)
2279 {
2280     TRACE("(%p %d)\n", this, c);
2281
2282     if(!basic_filebuf_char_is_open(this))
2283         return EOF;
2284
2285     if(basic_streambuf_char_gptr(&this->base)>basic_streambuf_char_eback(&this->base)
2286             && (c==EOF || basic_streambuf_char_gptr(&this->base)[-1]==(char)c)) {
2287         basic_streambuf_char__Gndec(&this->base);
2288         return c==EOF ? !c : c;
2289     }else if(c!=EOF && !this->cvt) {
2290         return ungetc(c, this->file);
2291     }
2292
2293     return EOF;
2294 }
2295
2296 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2297 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2298 #define call_basic_filebuf_char_uflow(this) CALL_VTBL_FUNC(this, 20, \
2299         int, (basic_filebuf_char*), (this))
2300 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_uflow, 4)
2301 int __thiscall basic_filebuf_char_uflow(basic_filebuf_char *this)
2302 {
2303     char ch, buf[128], *to_next;
2304     const char *buf_next;
2305     int c, i;
2306
2307     TRACE("(%p)\n", this);
2308
2309     if(!basic_filebuf_char_is_open(this))
2310         return EOF;
2311
2312     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2313         return *basic_streambuf_char__Gninc(&this->base);
2314
2315     c = fgetc(this->file);
2316     if(!this->cvt || !c)
2317         return c;
2318
2319     buf_next = buf;
2320     for(i=0; i < sizeof(buf)/sizeof(char); i++) {
2321         buf[i] = c;
2322
2323         switch(codecvt_char_in(this->cvt, &this->state, buf_next,
2324                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
2325         case CODECVT_partial:
2326         case CODECVT_ok:
2327             if(to_next == &ch) {
2328                 c = fgetc(this->file);
2329                 if(!c)
2330                     return EOF;
2331                 continue;
2332             }
2333
2334             for(i--; i>=buf_next-buf; i--)
2335                 ungetc(buf[i], this->file);
2336             return ch;
2337         case CODECVT_noconv:
2338             return buf[0];
2339         default:
2340             return EOF;
2341         }
2342     }
2343
2344     FIXME("buffer is to small\n");
2345     return EOF;
2346 }
2347
2348 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2349 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2350 #define call_basic_filebuf_char_underflow(this) CALL_VTBL_FUNC(this, 16, \
2351         int, (basic_filebuf_char*), (this))
2352 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_underflow, 4)
2353 int __thiscall basic_filebuf_char_underflow(basic_filebuf_char *this)
2354 {
2355     int ret;
2356
2357     TRACE("(%p)\n", this);
2358
2359     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2360         return *basic_streambuf_char_gptr(&this->base);
2361
2362     ret = call_basic_filebuf_char_uflow(this);
2363     if(ret)
2364         ret = call_basic_filebuf_char_pbackfail(this, ret);
2365     return ret;
2366 }
2367
2368 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2369 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2370 #define call_basic_filebuf_char_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 36, \
2371         fpos_int*, (basic_filebuf_char*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
2372 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekoff, 20)
2373 fpos_int* __thiscall basic_filebuf_char_seekoff(basic_filebuf_char *this,
2374         fpos_int *ret, streamoff off, int way, int mode)
2375 {
2376     fpos_t pos;
2377
2378     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
2379
2380     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2381             || fseek(this->file, off, way)) {
2382         ret->off = 0;
2383         ret->pos = -1;
2384         ret->state = 0;
2385         return ret;
2386     }
2387
2388     fgetpos(this->file, &pos);
2389     ret->off = 0;
2390     ret->pos = pos;
2391     ret->state = this->state;
2392     return ret;
2393 }
2394
2395 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2396 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2397 #define call_basic_filebuf_char_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 40, \
2398         fpos_int*, (basic_filebuf_char*, fpos_int*, fpos_int, mode), (this, ret, pos, mode))
2399 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekpos, 36)
2400 fpos_int* __thiscall basic_filebuf_char_seekpos(basic_filebuf_char *this,
2401         fpos_int *ret, fpos_int pos, int mode)
2402 {
2403     fpos_t fpos;
2404
2405     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
2406
2407     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2408             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
2409             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
2410         ret->off = 0;
2411         ret->pos = -1;
2412         ret->state = 0;
2413         return ret;
2414     }
2415
2416     fgetpos(this->file, &fpos);
2417     ret->off = 0;
2418     ret->pos = fpos;
2419     ret->state = this->state;
2420     return ret;
2421 }
2422
2423 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PADH@Z */
2424 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAD_J@Z */
2425 #define call_basic_filebuf_char_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 44, \
2426         basic_streambuf_char*, (basic_filebuf_char*, char*, streamsize), (this, buf, count))
2427 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_setbuf, 12)
2428 basic_streambuf_char* __thiscall basic_filebuf_char_setbuf(basic_filebuf_char *this, char *buf, streamsize count)
2429 {
2430     TRACE("(%p %p %ld)\n", this, buf, count);
2431
2432     if(!basic_filebuf_char_is_open(this))
2433         return NULL;
2434
2435     if(setvbuf(this->file, buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count))
2436         return NULL;
2437
2438     basic_filebuf_char__Init(this, this->file, INITFL_open);
2439     return &this->base;
2440 }
2441
2442 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2443 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2444 #define call_basic_filebuf_char_sync(this) CALL_VTBL_FUNC(this, 48, \
2445         int, (basic_filebuf_char*), (this))
2446 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_sync, 4)
2447 int __thiscall basic_filebuf_char_sync(basic_filebuf_char *this)
2448 {
2449     TRACE("(%p)\n", this);
2450
2451     if(!basic_filebuf_char_is_open(this))
2452         return 0;
2453
2454     if(call_basic_filebuf_char_overflow(this, EOF) == EOF)
2455         return 0;
2456     return fflush(this->file);
2457 }
2458
2459 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
2460 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
2461 #define call_basic_filebuf_char_imbue(this, loc) CALL_VTBL_FUNC(this, 52, \
2462         void, (basic_filebuf_char*, const locale*), (this, loc))
2463 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_imbue, 8)
2464 void __thiscall basic_filebuf_char_imbue(basic_filebuf_char *this, const locale *loc)
2465 {
2466     TRACE("(%p %p)\n", this, loc);
2467     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(loc));
2468 }
2469
2470 /* ??0ios_base@std@@IAE@XZ */
2471 /* ??0ios_base@std@@IEAA@XZ */
2472 DEFINE_THISCALL_WRAPPER(ios_base_ctor, 4)
2473 ios_base* __thiscall ios_base_ctor(ios_base *this)
2474 {
2475     TRACE("(%p)\n", this);
2476     this->vtable = &MSVCP_ios_base_vtable;
2477     return this;
2478 }
2479
2480 /* ??0ios_base@std@@QAE@ABV01@@Z */
2481 /* ??0ios_base@std@@QEAA@AEBV01@@Z */
2482 DEFINE_THISCALL_WRAPPER(ios_base_copy_ctor, 8)
2483 ios_base* __thiscall ios_base_copy_ctor(ios_base *this, const ios_base *copy)
2484 {
2485     TRACE("(%p %p)\n", this, copy);
2486     *this = *copy;
2487     this->vtable = &MSVCP_ios_base_vtable;
2488     return this;
2489 }
2490
2491 /* ?_Callfns@ios_base@std@@AAEXW4event@12@@Z */
2492 /* ?_Callfns@ios_base@std@@AEAAXW4event@12@@Z */
2493 DEFINE_THISCALL_WRAPPER(ios_base_Callfns, 8)
2494 void __thiscall ios_base_Callfns(ios_base *this, IOS_BASE_event event)
2495 {
2496     IOS_BASE_fnarray *cur;
2497
2498     TRACE("(%p %x)\n", this, event);
2499
2500     for(cur=this->calls; cur; cur=cur->next)
2501         cur->event_handler(event, this, cur->index);
2502 }
2503
2504 /* ?_Tidy@ios_base@std@@AAAXXZ */
2505 /* ?_Tidy@ios_base@std@@AEAAXXZ */
2506 void CDECL ios_base_Tidy(ios_base *this)
2507 {
2508     IOS_BASE_iosarray *arr_cur, *arr_next;
2509     IOS_BASE_fnarray *event_cur, *event_next;
2510
2511     TRACE("(%p)\n", this);
2512
2513     ios_base_Callfns(this, EVENT_erase_event);
2514
2515     for(arr_cur=this->arr; arr_cur; arr_cur=arr_next) {
2516         arr_next = arr_cur->next;
2517         MSVCRT_operator_delete(arr_cur);
2518     }
2519     this->arr = NULL;
2520
2521     for(event_cur=this->calls; event_cur; event_cur=event_next) {
2522         event_next = event_cur->next;
2523         MSVCRT_operator_delete(event_cur);
2524     }
2525     this->calls = NULL;
2526 }
2527
2528 /* ?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z */
2529 /* ?_Ios_base_dtor@ios_base@std@@CAXPEAV12@@Z */
2530 void CDECL ios_base_Ios_base_dtor(ios_base *obj)
2531 {
2532     TRACE("(%p)\n", obj);
2533     if(obj->loc) {
2534         locale_dtor(obj->loc);
2535         MSVCRT_operator_delete(obj->loc);
2536     }
2537     ios_base_Tidy(obj);
2538 }
2539
2540 /* ??1ios_base@std@@UAE@XZ */
2541 /* ??1ios_base@std@@UEAA@XZ */
2542 DEFINE_THISCALL_WRAPPER(ios_base_dtor, 4)
2543 void __thiscall ios_base_dtor(ios_base *this)
2544 {
2545     ios_base_Ios_base_dtor(this);
2546 }
2547
2548 DEFINE_THISCALL_WRAPPER(MSVCP_ios_base_vector_dtor, 8)
2549 ios_base* __thiscall MSVCP_ios_base_vector_dtor(ios_base *this, unsigned int flags)
2550 {
2551     TRACE("(%p %x)\n", this, flags);
2552     if(flags & 2) {
2553         /* we have an array, with the number of elements stored before the first object */
2554         int i, *ptr = (int *)this-1;
2555
2556         for(i=*ptr-1; i>=0; i--)
2557             ios_base_dtor(this+i);
2558         MSVCRT_operator_delete(ptr);
2559     } else {
2560         ios_base_dtor(this);
2561         if(flags & 1)
2562             MSVCRT_operator_delete(this);
2563     }
2564
2565     return this;
2566 }
2567
2568 DEFINE_THISCALL_WRAPPER(MSVCP_iosb_vector_dtor, 8)
2569 void* __thiscall MSVCP_iosb_vector_dtor(void *this, unsigned int flags)
2570 {
2571     TRACE("(%p %x)\n", this, flags);
2572     if(flags & 2) {
2573         int *ptr = (int *)this-1;
2574         MSVCRT_operator_delete(ptr);
2575     } else {
2576         if(flags & 1)
2577             MSVCRT_operator_delete(this);
2578     }
2579
2580     return this;
2581 }
2582
2583 /* ?_Findarr@ios_base@std@@AAEAAU_Iosarray@12@H@Z */
2584 /* ?_Findarr@ios_base@std@@AEAAAEAU_Iosarray@12@H@Z */
2585 DEFINE_THISCALL_WRAPPER(ios_base_Findarr, 8)
2586 IOS_BASE_iosarray* __thiscall ios_base_Findarr(ios_base *this, int index)
2587 {
2588     IOS_BASE_iosarray *p;
2589
2590     TRACE("(%p %d)\n", this, index);
2591
2592     for(p=this->arr; p; p=p->next) {
2593         if(p->index == index)
2594             return p;
2595     }
2596
2597     for(p=this->arr; p; p=p->next) {
2598         if(!p->long_val && !p->ptr_val) {
2599             p->index = index;
2600             return p;
2601         }
2602     }
2603
2604     p = MSVCRT_operator_new(sizeof(IOS_BASE_iosarray));
2605     p->next = this->arr;
2606     p->index = index;
2607     p->long_val = 0;
2608     p->ptr_val = NULL;
2609     this->arr = p;
2610     return p;
2611 }
2612
2613 /* ?iword@ios_base@std@@QAEAAJH@Z */
2614 /* ?iword@ios_base@std@@QEAAAEAJH@Z */
2615 DEFINE_THISCALL_WRAPPER(ios_base_iword, 8)
2616 LONG* __thiscall ios_base_iword(ios_base *this, int index)
2617 {
2618     TRACE("(%p %d)\n", this, index);
2619     return &ios_base_Findarr(this, index)->long_val;
2620 }
2621
2622 /* ?pword@ios_base@std@@QAEAAPAXH@Z */
2623 /* ?pword@ios_base@std@@QEAAAEAPEAXH@Z */
2624 DEFINE_THISCALL_WRAPPER(ios_base_pword, 8)
2625 void** __thiscall ios_base_pword(ios_base *this, int index)
2626 {
2627     TRACE("(%p %d)\n", this, index);
2628     return &ios_base_Findarr(this, index)->ptr_val;
2629 }
2630
2631 /* ?register_callback@ios_base@std@@QAEXP6AXW4event@12@AAV12@H@ZH@Z */
2632 /* ?register_callback@ios_base@std@@QEAAXP6AXW4event@12@AEAV12@H@ZH@Z */
2633 DEFINE_THISCALL_WRAPPER(ios_base_register_callback, 12)
2634 void __thiscall ios_base_register_callback(ios_base *this, IOS_BASE_event_callback callback, int index)
2635 {
2636     IOS_BASE_fnarray *event;
2637
2638     TRACE("(%p %p %d)\n", this, callback, index);
2639
2640     event = MSVCRT_operator_new(sizeof(IOS_BASE_fnarray));
2641     event->next = this->calls;
2642     event->index = index;
2643     event->event_handler = callback;
2644     this->calls = event;
2645 }
2646
2647 /* ?clear@ios_base@std@@QAEXH_N@Z */
2648 /* ?clear@ios_base@std@@QEAAXH_N@Z */
2649 DEFINE_THISCALL_WRAPPER(ios_base_clear_reraise, 12)
2650 void __thiscall ios_base_clear_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
2651 {
2652     TRACE("(%p %x %x)\n", this, state, reraise);
2653
2654     this->state = state & IOSTATE_mask;
2655     if(!(this->state & this->except))
2656         return;
2657
2658     if(reraise)
2659         throw_exception(EXCEPTION_RERAISE, NULL);
2660     else if(this->state & this->except & IOSTATE_eofbit)
2661         throw_exception(EXCEPTION_FAILURE, "eofbit is set");
2662     else if(this->state & this->except & IOSTATE_failbit)
2663         throw_exception(EXCEPTION_FAILURE, "failbit is set");
2664     else if(this->state & this->except & IOSTATE_badbit)
2665         throw_exception(EXCEPTION_FAILURE, "badbit is set");
2666     else if(this->state & this->except & IOSTATE__Hardfail)
2667         throw_exception(EXCEPTION_FAILURE, "_Hardfail is set");
2668 }
2669
2670 /* ?clear@ios_base@std@@QAEXH@Z */
2671 /* ?clear@ios_base@std@@QEAAXH@Z */
2672 DEFINE_THISCALL_WRAPPER(ios_base_clear, 8)
2673 void __thiscall ios_base_clear(ios_base *this, IOSB_iostate state)
2674 {
2675     ios_base_clear_reraise(this, state, FALSE);
2676 }
2677
2678 /* ?clear@ios_base@std@@QAEXI@Z */
2679 /* ?clear@ios_base@std@@QEAAXI@Z */
2680 DEFINE_THISCALL_WRAPPER(ios_base_clear_unsigned, 8)
2681 void __thiscall ios_base_clear_unsigned(ios_base *this, unsigned int state)
2682 {
2683     ios_base_clear_reraise(this, (IOSB_iostate)state, FALSE);
2684 }
2685
2686 /* ?exceptions@ios_base@std@@QAEXH@Z */
2687 /* ?exceptions@ios_base@std@@QEAAXH@Z */
2688 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set, 8)
2689 void __thiscall ios_base_exceptions_set(ios_base *this, IOSB_iostate state)
2690 {
2691     TRACE("(%p %x)\n", this, state);
2692     this->except = state & IOSTATE_mask;
2693     ios_base_clear(this, this->state);
2694 }
2695
2696 /* ?exceptions@ios_base@std@@QAEXI@Z */
2697 /* ?exceptions@ios_base@std@@QEAAXI@Z */
2698 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set_unsigned, 8)
2699 void __thiscall ios_base_exceptions_set_unsigned(ios_base *this, unsigned int state)
2700 {
2701     TRACE("(%p %x)\n", this, state);
2702     ios_base_exceptions_set(this, state);
2703 }
2704
2705 /* ?exceptions@ios_base@std@@QBEHXZ */
2706 /* ?exceptions@ios_base@std@@QEBAHXZ */
2707 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_get, 4)
2708 IOSB_iostate __thiscall ios_base_exceptions_get(ios_base *this)
2709 {
2710     TRACE("(%p)\n", this);
2711     return this->except;
2712 }
2713
2714 /* ?copyfmt@ios_base@std@@QAEAAV12@ABV12@@Z */
2715 /* ?copyfmt@ios_base@std@@QEAAAEAV12@AEBV12@@Z */
2716 DEFINE_THISCALL_WRAPPER(ios_base_copyfmt, 8)
2717 ios_base* __thiscall ios_base_copyfmt(ios_base *this, const ios_base *rhs)
2718 {
2719     TRACE("(%p %p)\n", this, rhs);
2720
2721     if(this != rhs) {
2722         IOS_BASE_iosarray *arr_cur;
2723         IOS_BASE_fnarray *event_cur;
2724
2725         ios_base_Tidy(this);
2726
2727         for(arr_cur=rhs->arr; arr_cur; arr_cur=arr_cur->next) {
2728             if(arr_cur->long_val)
2729                 *ios_base_iword(this, arr_cur->index) = arr_cur->long_val;
2730             if(arr_cur->ptr_val)
2731                 *ios_base_pword(this, arr_cur->index) = arr_cur->ptr_val;
2732         }
2733         this->stdstr = rhs->stdstr;
2734         this->fmtfl = rhs->fmtfl;
2735         this->prec = rhs->prec;
2736         this->wide = rhs->wide;
2737         locale_operator_assign(this->loc, rhs->loc);
2738
2739         for(event_cur=rhs->calls; event_cur; event_cur=event_cur->next)
2740             ios_base_register_callback(this, event_cur->event_handler, event_cur->index);
2741
2742         ios_base_Callfns(this, EVENT_copyfmt_event);
2743         ios_base_exceptions_set(this, rhs->except);
2744     }
2745
2746     return this;
2747 }
2748
2749 /* ??4ios_base@std@@QAEAAV01@ABV01@@Z */
2750 /* ??4ios_base@std@@QEAAAEAV01@AEBV01@@Z */
2751 DEFINE_THISCALL_WRAPPER(ios_base_assign, 8)
2752 ios_base* __thiscall ios_base_assign(ios_base *this, const ios_base *right)
2753 {
2754     TRACE("(%p %p)\n", this, right);
2755
2756     if(this != right) {
2757         this->state = right->state;
2758         ios_base_copyfmt(this, right);
2759     }
2760
2761     return this;
2762 }
2763
2764 /* ?fail@ios_base@std@@QBE_NXZ */
2765 /* ?fail@ios_base@std@@QEBA_NXZ */
2766 DEFINE_THISCALL_WRAPPER(ios_base_fail, 4)
2767 MSVCP_bool __thiscall ios_base_fail(const ios_base *this)
2768 {
2769     TRACE("(%p)\n", this);
2770     return (this->state & (IOSTATE_failbit|IOSTATE_badbit)) != 0;
2771 }
2772
2773 /* ??7ios_base@std@@QBE_NXZ */
2774 /* ??7ios_base@std@@QEBA_NXZ */
2775 DEFINE_THISCALL_WRAPPER(ios_base_op_succ, 4)
2776 MSVCP_bool __thiscall ios_base_op_succ(const ios_base *this)
2777 {
2778     TRACE("(%p)\n", this);
2779     return ios_base_fail(this);
2780 }
2781
2782 /* ??Bios_base@std@@QBEPAXXZ */
2783 /* ??Bios_base@std@@QEBAPEAXXZ */
2784 DEFINE_THISCALL_WRAPPER(ios_base_op_fail, 4)
2785 void* __thiscall ios_base_op_fail(const ios_base *this)
2786 {
2787     TRACE("(%p)\n", this);
2788     return ios_base_fail(this) ? NULL : (void*)this;
2789 }
2790
2791 /* ?_Addstd@ios_base@std@@SAXPAV12@@Z */
2792 /* ?_Addstd@ios_base@std@@SAXPEAV12@@Z */
2793 void CDECL ios_base_Addstd(ios_base *add)
2794 {
2795     FIXME("(%p) stub\n", add);
2796 }
2797
2798 /* ?_Index_func@ios_base@std@@CAAAHXZ */
2799 /* ?_Index_func@ios_base@std@@CAAEAHXZ */
2800 int* CDECL ios_base_Index_func(void)
2801 {
2802     TRACE("\n");
2803     return &ios_base_Index;
2804 }
2805
2806 /* ?_Init@ios_base@std@@IAEXXZ */
2807 /* ?_Init@ios_base@std@@IEAAXXZ */
2808 DEFINE_THISCALL_WRAPPER(ios_base_Init, 4)
2809 void __thiscall ios_base_Init(ios_base *this)
2810 {
2811     TRACE("(%p)\n", this);
2812
2813     this->stdstr = 0;
2814     this->state = this->except = IOSTATE_goodbit;
2815     this->fmtfl = FMTFLAG_skipws | FMTFLAG_dec;
2816     this->prec = 6;
2817     this->wide = 0;
2818     this->arr = NULL;
2819     this->calls = NULL;
2820     this->loc = MSVCRT_operator_new(sizeof(locale));
2821     locale_ctor(this->loc);
2822 }
2823
2824 /* ?_Sync_func@ios_base@std@@CAAA_NXZ */
2825 /* ?_Sync_func@ios_base@std@@CAAEA_NXZ */
2826 MSVCP_bool* CDECL ios_base_Sync_func(void)
2827 {
2828     TRACE("\n");
2829     return &ios_base_Sync;
2830 }
2831
2832 /* ?bad@ios_base@std@@QBE_NXZ */
2833 /* ?bad@ios_base@std@@QEBA_NXZ */
2834 DEFINE_THISCALL_WRAPPER(ios_base_bad, 4)
2835 MSVCP_bool __thiscall ios_base_bad(const ios_base *this)
2836 {
2837     TRACE("(%p)\n", this);
2838     return (this->state & IOSTATE_badbit) != 0;
2839 }
2840
2841 /* ?eof@ios_base@std@@QBE_NXZ */
2842 /* ?eof@ios_base@std@@QEBA_NXZ */
2843 DEFINE_THISCALL_WRAPPER(ios_base_eof, 4)
2844 MSVCP_bool __thiscall ios_base_eof(const ios_base *this)
2845 {
2846     TRACE("(%p)\n", this);
2847     return (this->state & IOSTATE_eofbit) != 0;
2848 }
2849
2850 /* ?flags@ios_base@std@@QAEHH@Z */
2851 /* ?flags@ios_base@std@@QEAAHH@Z */
2852 DEFINE_THISCALL_WRAPPER(ios_base_flags_set, 8)
2853 IOSB_fmtflags __thiscall ios_base_flags_set(ios_base *this, IOSB_fmtflags flags)
2854 {
2855     IOSB_fmtflags ret = this->fmtfl;
2856
2857     TRACE("(%p %x)\n", this, flags);
2858
2859     this->fmtfl = flags & FMTFLAG_mask;
2860     return ret;
2861 }
2862
2863 /* ?flags@ios_base@std@@QBEHXZ */
2864 /* ?flags@ios_base@std@@QEBAHXZ */
2865 DEFINE_THISCALL_WRAPPER(ios_base_flags_get, 4)
2866 IOSB_fmtflags __thiscall ios_base_flags_get(const ios_base *this)
2867 {
2868     TRACE("(%p)\n", this);
2869     return this->fmtfl;
2870 }
2871
2872 /* ?getloc@ios_base@std@@QBE?AVlocale@2@XZ */
2873 /* ?getloc@ios_base@std@@QEBA?AVlocale@2@XZ */
2874 DEFINE_THISCALL_WRAPPER(ios_base_getloc, 8)
2875 locale* __thiscall ios_base_getloc(const ios_base *this, locale *ret)
2876 {
2877     TRACE("(%p)\n", this);
2878     return locale_copy_ctor(ret, this->loc);
2879 }
2880
2881 /* ?good@ios_base@std@@QBE_NXZ */
2882 /* ?good@ios_base@std@@QEBA_NXZ */
2883 DEFINE_THISCALL_WRAPPER(ios_base_good, 4)
2884 MSVCP_bool __thiscall ios_base_good(const ios_base *this)
2885 {
2886     TRACE("(%p)\n", this);
2887     return this->state == IOSTATE_goodbit;
2888 }
2889
2890 /* ?imbue@ios_base@std@@QAE?AVlocale@2@ABV32@@Z */
2891 /* ?imbue@ios_base@std@@QEAA?AVlocale@2@AEBV32@@Z */
2892 DEFINE_THISCALL_WRAPPER(ios_base_imbue, 12)
2893 locale* __thiscall ios_base_imbue(ios_base *this, locale *ret, const locale *loc)
2894 {
2895     TRACE("(%p %p)\n", this, loc);
2896     *ret = *this->loc;
2897     locale_copy_ctor(this->loc, loc);
2898     return ret;
2899 }
2900
2901 /* ?precision@ios_base@std@@QAEHH@Z */
2902 /* ?precision@ios_base@std@@QEAA_J_J@Z */
2903 DEFINE_THISCALL_WRAPPER(ios_base_precision_set, 8)
2904 streamsize __thiscall ios_base_precision_set(ios_base *this, streamsize precision)
2905 {
2906     streamsize ret = this->prec;
2907
2908     TRACE("(%p %ld)\n", this, precision);
2909
2910     this->prec = precision;
2911     return ret;
2912 }
2913
2914 /* ?precision@ios_base@std@@QBEHXZ */
2915 /* ?precision@ios_base@std@@QEBA_JXZ */
2916 DEFINE_THISCALL_WRAPPER(ios_base_precision_get, 4)
2917 streamsize __thiscall ios_base_precision_get(const ios_base *this)
2918 {
2919     TRACE("(%p)\n", this);
2920     return this->prec;
2921 }
2922
2923 /* ?rdstate@ios_base@std@@QBEHXZ */
2924 /* ?rdstate@ios_base@std@@QEBAHXZ */
2925 DEFINE_THISCALL_WRAPPER(ios_base_rdstate, 4)
2926 IOSB_iostate __thiscall ios_base_rdstate(const ios_base *this)
2927 {
2928     TRACE("(%p)\n", this);
2929     return this->state;
2930 }
2931
2932 /* ?setf@ios_base@std@@QAEHHH@Z */
2933 /* ?setf@ios_base@std@@QEAAHHH@Z */
2934 DEFINE_THISCALL_WRAPPER(ios_base_setf_mask, 12)
2935 IOSB_fmtflags __thiscall ios_base_setf_mask(ios_base *this, IOSB_fmtflags flags, IOSB_fmtflags mask)
2936 {
2937     IOSB_fmtflags ret = this->fmtfl;
2938
2939     TRACE("(%p %x %x)\n", this, flags, mask);
2940
2941     this->fmtfl = (this->fmtfl & (~mask)) | (flags & mask & FMTFLAG_mask);
2942     return ret;
2943 }
2944
2945 /* ?setf@ios_base@std@@QAEHH@Z */
2946 /* ?setf@ios_base@std@@QEAAHH@Z */
2947 DEFINE_THISCALL_WRAPPER(ios_base_setf, 8)
2948 IOSB_fmtflags __thiscall ios_base_setf(ios_base *this, IOSB_fmtflags flags)
2949 {
2950     return ios_base_setf_mask(this, flags, ~0);
2951 }
2952
2953 /* ?setstate@ios_base@std@@QAEXH_N@Z */
2954 /* ?setstate@ios_base@std@@QEAAXH_N@Z */
2955 DEFINE_THISCALL_WRAPPER(ios_base_setstate_reraise, 12)
2956 void __thiscall ios_base_setstate_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
2957 {
2958     TRACE("(%p %x %x)\n", this, state, reraise);
2959
2960     if(state != IOSTATE_goodbit)
2961         ios_base_clear_reraise(this, this->state | state, reraise);
2962 }
2963
2964 /* ?setstate@ios_base@std@@QAEXH@Z */
2965 /* ?setstate@ios_base@std@@QEAAXH@Z */
2966 DEFINE_THISCALL_WRAPPER(ios_base_setstate, 8)
2967 void __thiscall ios_base_setstate(ios_base *this, IOSB_iostate state)
2968 {
2969     ios_base_setstate_reraise(this, state, FALSE);
2970 }
2971
2972 /* ?setstate@ios_base@std@@QAEXI@Z */
2973 /* ?setstate@ios_base@std@@QEAAXI@Z */
2974 DEFINE_THISCALL_WRAPPER(ios_base_setstate_unsigned, 8)
2975 void __thiscall ios_base_setstate_unsigned(ios_base *this, unsigned int state)
2976 {
2977     ios_base_setstate_reraise(this, (IOSB_iostate)state, FALSE);
2978 }
2979
2980 /* ?sync_with_stdio@ios_base@std@@SA_N_N@Z */
2981 MSVCP_bool CDECL ios_base_sync_with_stdio(MSVCP_bool sync)
2982 {
2983     _Lockit lock;
2984     MSVCP_bool ret;
2985
2986     TRACE("(%x)\n", sync);
2987
2988     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
2989     ret = ios_base_Sync;
2990     ios_base_Sync = sync;
2991     _Lockit_dtor(&lock);
2992     return ret;
2993 }
2994
2995 /* ?unsetf@ios_base@std@@QAEXH@Z */
2996 /* ?unsetf@ios_base@std@@QEAAXH@Z */
2997 DEFINE_THISCALL_WRAPPER(ios_base_unsetf, 8)
2998 void __thiscall ios_base_unsetf(ios_base *this, IOSB_fmtflags flags)
2999 {
3000     TRACE("(%p %x)\n", this, flags);
3001     this->fmtfl &= ~flags;
3002 }
3003
3004 /* ?width@ios_base@std@@QAEHH@Z */
3005 /* ?width@ios_base@std@@QEAA_J_J@Z */
3006 DEFINE_THISCALL_WRAPPER(ios_base_width_set, 8)
3007 streamsize __thiscall ios_base_width_set(ios_base *this, streamsize width)
3008 {
3009     streamsize ret = this->wide;
3010
3011     TRACE("(%p %ld)\n", this, width);
3012
3013     this->wide = width;
3014     return ret;
3015 }
3016
3017 /* ?width@ios_base@std@@QBEHXZ */
3018 /* ?width@ios_base@std@@QEBA_JXZ */
3019 DEFINE_THISCALL_WRAPPER(ios_base_width_get, 4)
3020 streamsize __thiscall ios_base_width_get(ios_base *this)
3021 {
3022     TRACE("(%p)\n", this);
3023     return this->wide;
3024 }
3025
3026 /* ?xalloc@ios_base@std@@SAHXZ */
3027 int CDECL ios_base_xalloc(void)
3028 {
3029     _Lockit lock;
3030     int ret;
3031
3032     TRACE("\n");
3033
3034     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
3035     ret = ios_base_Index++;
3036     _Lockit_dtor(&lock);
3037     return ret;
3038 }
3039
3040 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ */
3041 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IEAA@XZ */
3042 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor, 4)
3043 basic_ios_char* __thiscall basic_ios_char_ctor(basic_ios_char *this)
3044 {
3045     TRACE("(%p)\n", this);
3046
3047     ios_base_ctor(&this->base);
3048     this->base.vtable = &MSVCP_basic_ios_char_vtable;
3049     return this;
3050 }
3051
3052 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IAEXPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
3053 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
3054 DEFINE_THISCALL_WRAPPER(basic_ios_char_init, 12)
3055 void __thiscall basic_ios_char_init(basic_ios_char *this, basic_streambuf_char *streambuf, MSVCP_bool isstd)
3056 {
3057     TRACE("(%p %p %x)\n", this, streambuf, isstd);
3058     ios_base_Init(&this->base);
3059     this->strbuf = streambuf;
3060     this->stream = NULL;
3061     this->fillch = ' ';
3062
3063     if(!streambuf)
3064         ios_base_setstate(&this->base, IOSTATE_badbit);
3065
3066     if(isstd)
3067         FIXME("standard streams not handled yet\n");
3068 }
3069
3070 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
3071 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
3072 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor_streambuf, 8)
3073 basic_ios_char* __thiscall basic_ios_char_ctor_streambuf(basic_ios_char *this, basic_streambuf_char *strbuf)
3074 {
3075     TRACE("(%p %p)\n", this, strbuf);
3076
3077     basic_ios_char_ctor(this);
3078     basic_ios_char_init(this, strbuf, FALSE);
3079     return this;
3080 }
3081
3082 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ */
3083 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ */
3084 DEFINE_THISCALL_WRAPPER(basic_ios_char_dtor, 4)
3085 void __thiscall basic_ios_char_dtor(basic_ios_char *this)
3086 {
3087     TRACE("(%p)\n", this);
3088     ios_base_dtor(&this->base);
3089 }
3090
3091 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ios_char_vector_dtor, 8)
3092 basic_ios_char* __thiscall MSVCP_basic_ios_char_vector_dtor(basic_ios_char *this, unsigned int flags)
3093 {
3094     TRACE("(%p %x)\n", this, flags);
3095     if(flags & 2) {
3096         /* we have an array, with the number of elements stored before the first object */
3097         int i, *ptr = (int *)this-1;
3098
3099         for(i=*ptr-1; i>=0; i--)
3100             basic_ios_char_dtor(this+i);
3101         MSVCRT_operator_delete(ptr);
3102     } else {
3103         basic_ios_char_dtor(this);
3104         if(flags & 1)
3105             MSVCRT_operator_delete(this);
3106     }
3107
3108     return this;
3109 }
3110
3111 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
3112 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
3113 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear_reraise, 12)
3114 void __thiscall basic_ios_char_clear_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
3115 {
3116     TRACE("(%p %x %x)\n", this, state, reraise);
3117     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
3118 }
3119
3120 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
3121 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
3122 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear, 8)
3123 void __thiscall basic_ios_char_clear(basic_ios_char *this, unsigned int state)
3124 {
3125     basic_ios_char_clear_reraise(this, (IOSB_iostate)state, FALSE);
3126 }
3127
3128 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEAAV12@ABV12@@Z */
3129 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEBV12@@Z */
3130 DEFINE_THISCALL_WRAPPER(basic_ios_char_copyfmt, 8)
3131 basic_ios_char* __thiscall basic_ios_char_copyfmt(basic_ios_char *this, basic_ios_char *copy)
3132 {
3133     TRACE("(%p %p)\n", this, copy);
3134     if(this == copy)
3135         return this;
3136
3137     this->stream = copy->stream;
3138     this->fillch = copy->fillch;
3139     ios_base_copyfmt(&this->base, &copy->base);
3140     return this;
3141 }
3142
3143 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEDD@Z */
3144 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAADD@Z */
3145 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_set, 8)
3146 char __thiscall basic_ios_char_fill_set(basic_ios_char *this, char fill)
3147 {
3148     char ret = this->fillch;
3149
3150     TRACE("(%p %c)\n", this, fill);
3151
3152     this->fillch = fill;
3153     return ret;
3154 }
3155
3156 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ */
3157 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADXZ */
3158 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_get, 4)
3159 char __thiscall basic_ios_char_fill_get(basic_ios_char *this)
3160 {
3161     TRACE("(%p)\n", this);
3162     return this->fillch;
3163 }
3164
3165 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
3166 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
3167 DEFINE_THISCALL_WRAPPER(basic_ios_char_imbue, 12)
3168 locale *__thiscall basic_ios_char_imbue(basic_ios_char *this, locale *ret, const locale *loc)
3169 {
3170     TRACE("(%p %p %p)\n", this, ret, loc);
3171
3172     if(this->strbuf)
3173         return basic_streambuf_char_pubimbue(this->strbuf, ret, loc);
3174
3175     locale_copy_ctor(ret, loc);
3176     return ret;
3177 }
3178
3179 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDDD@Z */
3180 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADDD@Z */
3181 DEFINE_THISCALL_WRAPPER(basic_ios_char_narrow, 12)
3182 char __thiscall basic_ios_char_narrow(basic_ios_char *this, char ch, char def)
3183 {
3184     FIXME("(%p %c %c) stub\n", this, ch, def);
3185     return def;
3186 }
3187
3188 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PAV32@@Z */
3189 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAV32@@Z */
3190 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_set, 8)
3191 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_set(basic_ios_char *this, basic_streambuf_char *streambuf)
3192 {
3193     basic_streambuf_char *ret = this->strbuf;
3194
3195     TRACE("(%p %p)\n", this, streambuf);
3196
3197     this->strbuf = streambuf;
3198     basic_ios_char_clear(this, IOSTATE_goodbit);
3199     return ret;
3200 }
3201
3202 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
3203 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
3204 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_get, 4)
3205 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_get(const basic_ios_char *this)
3206 {
3207     TRACE("(%p)\n", this);
3208     return this->strbuf;
3209 }
3210
3211 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
3212 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
3213 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate_reraise, 12)
3214 void __thiscall basic_ios_char_setstate_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
3215 {
3216     TRACE("(%p %x %x)\n", this, state, reraise);
3217
3218     if(state != IOSTATE_goodbit)
3219         basic_ios_char_clear_reraise(this, this->base.state | state, reraise);
3220 }
3221
3222 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
3223 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
3224 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate, 8)
3225 void __thiscall basic_ios_char_setstate(basic_ios_char *this, unsigned int state)
3226 {
3227     basic_ios_char_setstate_reraise(this, (IOSB_iostate)state, FALSE);
3228 }
3229
3230 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@PAV32@@Z */
3231 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@PEAV32@@Z */
3232 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_set, 8)
3233 basic_ostream_char* __thiscall basic_ios_char_tie_set(basic_ios_char *this, basic_ostream_char *ostream)
3234 {
3235     basic_ostream_char *ret = this->stream;
3236
3237     TRACE("(%p %p)\n", this, ostream);
3238
3239     this->stream = ostream;
3240     return ret;
3241 }
3242
3243 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
3244 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
3245 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_get, 4)
3246 basic_ostream_char* __thiscall basic_ios_char_tie_get(const basic_ios_char *this)
3247 {
3248     TRACE("(%p)\n", this);
3249     return this->stream;
3250 }
3251
3252 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDD@Z */
3253 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADD@Z */
3254 DEFINE_THISCALL_WRAPPER(basic_ios_char_widen, 8)
3255 char __thiscall basic_ios_char_widen(basic_ios_char *this, char ch)
3256 {
3257     FIXME("(%p %c) stub\n", this, ch);
3258     return 0;
3259 }
3260
3261
3262 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
3263 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
3264 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor, 4)
3265 basic_ios_wchar* __thiscall basic_ios_wchar_ctor(basic_ios_wchar *this)
3266 {
3267     TRACE("(%p)\n", this);
3268
3269     ios_base_ctor(&this->base);
3270     this->base.vtable = &MSVCP_basic_ios_wchar_vtable;
3271     return this;
3272 }
3273
3274 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IAE@XZ */
3275 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IEAA@XZ */
3276 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor, 4)
3277 basic_ios_wchar* __thiscall basic_ios_short_ctor(basic_ios_wchar *this)
3278 {
3279     basic_ios_wchar_ctor(this);
3280     this->base.vtable = &MSVCP_basic_ios_short_vtable;
3281     return this;
3282 }
3283
3284 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
3285 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
3286 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IAEXPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
3287 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
3288 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_init, 12)
3289 void __thiscall basic_ios_wchar_init(basic_ios_wchar *this, basic_streambuf_wchar *streambuf, MSVCP_bool isstd)
3290 {
3291     TRACE("(%p %p %x)\n", this, streambuf, isstd);
3292     ios_base_Init(&this->base);
3293     this->strbuf = streambuf;
3294     this->stream = NULL;
3295     this->fillch = ' ';
3296
3297     if(!streambuf)
3298         ios_base_setstate(&this->base, IOSTATE_badbit);
3299
3300     if(isstd)
3301         FIXME("standard streams not handled yet\n");
3302 }
3303
3304 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
3305 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
3306 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor_streambuf, 8)
3307 basic_ios_wchar* __thiscall basic_ios_wchar_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
3308 {
3309     TRACE("(%p %p)\n", this, strbuf);
3310
3311     basic_ios_wchar_ctor(this);
3312     basic_ios_wchar_init(this, strbuf, FALSE);
3313     return this;
3314 }
3315
3316 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
3317 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
3318 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor_streambuf, 8)
3319 basic_ios_wchar* __thiscall basic_ios_short_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
3320 {
3321     basic_ios_wchar_ctor_streambuf(this, strbuf);
3322     this->base.vtable = &MSVCP_basic_ios_short_vtable;
3323     return this;
3324 }
3325
3326 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
3327 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
3328 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UAE@XZ */
3329 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UEAA@XZ */
3330 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_dtor, 4)
3331 void __thiscall basic_ios_wchar_dtor(basic_ios_wchar *this)
3332 {
3333     TRACE("(%p)\n", this);
3334     ios_base_dtor(&this->base);
3335 }
3336
3337 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ios_wchar_vector_dtor, 8)
3338 basic_ios_wchar* __thiscall MSVCP_basic_ios_wchar_vector_dtor(basic_ios_wchar *this, unsigned int flags)
3339 {
3340     TRACE("(%p %x)\n", this, flags);
3341     if(flags & 2) {
3342         /* we have an array, with the number of elements stored before the first object */
3343         int i, *ptr = (int *)this-1;
3344
3345         for(i=*ptr-1; i>=0; i--)
3346             basic_ios_wchar_dtor(this+i);
3347         MSVCRT_operator_delete(ptr);
3348     } else {
3349         basic_ios_wchar_dtor(this);
3350         if(flags & 1)
3351             MSVCRT_operator_delete(this);
3352     }
3353
3354     return this;
3355 }
3356
3357 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ios_short_vector_dtor, 8)
3358 basic_ios_wchar* __thiscall MSVCP_basic_ios_short_vector_dtor(basic_ios_wchar *this, unsigned int flags)
3359 {
3360     return MSVCP_basic_ios_wchar_vector_dtor(this, flags);
3361 }
3362
3363 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
3364 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
3365 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
3366 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
3367 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear_reraise, 12)
3368 void __thiscall basic_ios_wchar_clear_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
3369 {
3370     TRACE("(%p %x %x)\n", this, state, reraise);
3371     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
3372 }
3373
3374 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
3375 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
3376 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
3377 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
3378 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear, 8)
3379 void __thiscall basic_ios_wchar_clear(basic_ios_wchar *this, unsigned int state)
3380 {
3381     basic_ios_wchar_clear_reraise(this, (IOSB_iostate)state, FALSE);
3382 }
3383
3384 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEAAV12@ABV12@@Z */
3385 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEBV12@@Z */
3386 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEAAV12@ABV12@@Z */
3387 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEBV12@@Z */
3388 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_copyfmt, 8)
3389 basic_ios_wchar* __thiscall basic_ios_wchar_copyfmt(basic_ios_wchar *this, basic_ios_wchar *copy)
3390 {
3391     TRACE("(%p %p)\n", this, copy);
3392     if(this == copy)
3393         return this;
3394
3395     this->stream = copy->stream;
3396     this->fillch = copy->fillch;
3397     ios_base_copyfmt(&this->base, &copy->base);
3398     return this;
3399 }
3400
3401 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE_W_W@Z */
3402 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA_W_W@Z */
3403 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEGG@Z */
3404 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
3405 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_set, 8)
3406 wchar_t __thiscall basic_ios_wchar_fill_set(basic_ios_wchar *this, wchar_t fill)
3407 {
3408     wchar_t ret = this->fillch;
3409
3410     TRACE("(%p %c)\n", this, fill);
3411
3412     this->fillch = fill;
3413     return ret;
3414 }
3415
3416 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WXZ */
3417 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WXZ */
3418 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGXZ */
3419 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGXZ */
3420 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_get, 4)
3421 wchar_t __thiscall basic_ios_wchar_fill_get(basic_ios_wchar *this)
3422 {
3423     TRACE("(%p)\n", this);
3424     return this->fillch;
3425 }
3426
3427 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
3428 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
3429 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
3430 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
3431 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_imbue, 12)
3432 locale *__thiscall basic_ios_wchar_imbue(basic_ios_wchar *this, locale *ret, const locale *loc)
3433 {
3434     TRACE("(%p %p %p)\n", this, ret, loc);
3435
3436     if(this->strbuf)
3437         return basic_streambuf_wchar_pubimbue(this->strbuf, ret, loc);
3438
3439     locale_copy_ctor(ret, loc);
3440     return ret;
3441 }
3442
3443 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBED_WD@Z */
3444 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAD_WD@Z */
3445 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEDGD@Z */
3446 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBADGD@Z */
3447 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_narrow, 12)
3448 char __thiscall basic_ios_wchar_narrow(basic_ios_wchar *this, wchar_t ch, char def)
3449 {
3450     FIXME("(%p %c %c) stub\n", this, ch, def);
3451     return def;
3452 }
3453
3454 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
3455 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
3456 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAV32@@Z */
3457 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAV32@@Z */
3458 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_set, 8)
3459 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_set(basic_ios_wchar *this, basic_streambuf_wchar *streambuf)
3460 {
3461     basic_streambuf_wchar *ret = this->strbuf;
3462
3463     TRACE("(%p %p)\n", this, streambuf);
3464
3465     this->strbuf = streambuf;
3466     basic_ios_wchar_clear(this, IOSTATE_goodbit);
3467     return ret;
3468 }
3469
3470 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
3471 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
3472 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
3473 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
3474 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_get, 4)
3475 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_get(const basic_ios_wchar *this)
3476 {
3477     TRACE("(%p)\n", this);
3478     return this->strbuf;
3479 }
3480
3481 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
3482 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
3483 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
3484 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
3485 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate_reraise, 12)
3486 void __thiscall basic_ios_wchar_setstate_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
3487 {
3488     TRACE("(%p %x %x)\n", this, state, reraise);
3489
3490     if(state != IOSTATE_goodbit)
3491         basic_ios_wchar_clear_reraise(this, this->base.state | state, reraise);
3492 }
3493
3494 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
3495 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
3496 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
3497 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
3498 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate, 8)
3499 void __thiscall basic_ios_wchar_setstate(basic_ios_wchar *this, IOSB_iostate state)
3500 {
3501     basic_ios_wchar_setstate_reraise(this, state, FALSE);
3502 }
3503
3504 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
3505 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
3506 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@PAV32@@Z */
3507 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@PEAV32@@Z */
3508 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_set, 8)
3509 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_set(basic_ios_wchar *this, basic_ostream_wchar *ostream)
3510 {
3511     basic_ostream_wchar *ret = this->stream;
3512
3513     TRACE("(%p %p)\n", this, ostream);
3514
3515     this->stream = ostream;
3516     return ret;
3517 }
3518
3519 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
3520 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
3521 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
3522 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
3523 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_get, 4)
3524 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_get(const basic_ios_wchar *this)
3525 {
3526     TRACE("(%p)\n", this);
3527     return this->stream;
3528 }
3529
3530 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WD@Z */
3531 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WD@Z */
3532 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGD@Z */
3533 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGD@Z */
3534 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_widen, 8)
3535 wchar_t __thiscall basic_ios_wchar_widen(basic_ios_wchar *this, char ch)
3536 {
3537     FIXME("(%p %c)\n", this, ch);
3538     return 0;
3539 }
3540
3541 /* Caution: basic_ostream uses virtual inheritance.
3542  * All constructors have additional parameter that says if base class should be initialized.
3543  * Base class needs to be accessed using vbtable.
3544  */
3545 static inline basic_ios_char* basic_ostream_char_get_basic_ios(basic_ostream_char *this)
3546 {
3547     return (basic_ios_char*)((char*)this+this->vbtable[1]);
3548 }
3549
3550 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
3551 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
3552 DEFINE_THISCALL_WRAPPER(basic_ostream_char_ctor, 16)
3553 basic_ostream_char* __thiscall basic_ostream_char_ctor(basic_ostream_char *this,
3554         basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
3555 {
3556     basic_ios_char *base;
3557
3558     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
3559
3560     if(virt_init) {
3561         this->vbtable = basic_ostream_char_vbtable;
3562         base = basic_ostream_char_get_basic_ios(this);
3563         basic_ios_char_ctor(base);
3564     }else {
3565         base = basic_ostream_char_get_basic_ios(this);
3566     }
3567
3568     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
3569     basic_ios_char_init(base, strbuf, isstd);
3570     return this;
3571 }
3572
3573 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
3574 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
3575 DEFINE_THISCALL_WRAPPER(basic_ostream_char_ctor_uninitialized, 16)
3576 basic_ostream_char* __thiscall basic_ostream_char_ctor_uninitialized(basic_ostream_char *this,
3577         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
3578 {
3579     basic_ios_char *base;
3580
3581     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
3582
3583     if(virt_init) {
3584         this->vbtable = basic_ostream_char_vbtable;
3585         base = basic_ostream_char_get_basic_ios(this);
3586         basic_ios_char_ctor(base);
3587     }else {
3588         base = basic_ostream_char_get_basic_ios(this);
3589     }
3590
3591     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
3592     if(addstd)
3593         ios_base_Addstd(&base->base);
3594     return this;
3595 }
3596
3597 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
3598 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
3599 DEFINE_THISCALL_WRAPPER(basic_ostream_char_dtor, 4)
3600 void __thiscall basic_ostream_char_dtor(basic_ostream_char *this)
3601 {
3602     /* don't destroy virtual base here */
3603     TRACE("(%p)\n", this);
3604 }
3605
3606 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
3607 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
3608 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vbase_dtor, 4)
3609 void __thiscall basic_ostream_char_vbase_dtor(basic_ostream_char *this)
3610 {
3611     TRACE("(%p)\n", this);
3612     basic_ostream_char_dtor(this);
3613     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(this));
3614 }
3615
3616 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ostream_char_vector_dtor, 8)
3617 basic_ostream_char* __thiscall MSVCP_basic_ostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
3618 {
3619     basic_ostream_char *this = (basic_ostream_char *)((char*)base - basic_ostream_char_vbtable[1] + basic_ostream_char_vbtable[0]);
3620
3621     TRACE("(%p %x)\n", this, flags);
3622
3623     if(flags & 2) {
3624         /* we have an array, with the number of elements stored before the first object */
3625         int i, *ptr = (int *)this-1;
3626
3627         for(i=*ptr-1; i>=0; i--)
3628             basic_ostream_char_vbase_dtor(this+i);
3629         MSVCRT_operator_delete(ptr);
3630     } else {
3631         basic_ostream_char_vbase_dtor(this);
3632         if(flags & 1)
3633             MSVCRT_operator_delete(this);
3634     }
3635
3636     return this;
3637 }
3638
3639 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
3640 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
3641 DEFINE_THISCALL_WRAPPER(basic_ostream_char_flush, 4)
3642 basic_ostream_char* __thiscall basic_ostream_char_flush(basic_ostream_char *this)
3643 {
3644     /* this function is not matching C++ specification */
3645     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
3646
3647     TRACE("(%p)\n", this);
3648
3649     if(basic_ios_char_rdbuf_get(base) && ios_base_good(&base->base)
3650             && basic_streambuf_char_pubsync(basic_ios_char_rdbuf_get(base))==-1)
3651         basic_ios_char_setstate(base, IOSTATE_badbit);
3652     return this;
3653 }
3654
3655 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
3656 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
3657 DEFINE_THISCALL_WRAPPER(basic_ostream_char__Osfx, 4)
3658 void __thiscall basic_ostream_char__Osfx(basic_ostream_char *this)
3659 {
3660     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
3661
3662     TRACE("(%p)\n", this);
3663
3664     if(base->base.fmtfl & FMTFLAG_unitbuf)
3665         basic_ostream_char_flush(this);
3666 }
3667
3668 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
3669 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
3670 DEFINE_THISCALL_WRAPPER(basic_ostream_char_osfx, 4)
3671 void __thiscall basic_ostream_char_osfx(basic_ostream_char *this)
3672 {
3673     TRACE("(%p)\n", this);
3674     basic_ostream_char__Osfx(this);
3675 }
3676
3677 static BOOL basic_ostream_char_sentry_create(basic_ostream_char *ostr)
3678 {
3679     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
3680
3681     if(basic_ios_char_rdbuf_get(base))
3682         basic_streambuf_char__Lock(base->strbuf);
3683
3684     if(ios_base_good(&base->base) && base->stream)
3685         basic_ostream_char_flush(base->stream);
3686
3687     return ios_base_good(&base->base);
3688 }
3689
3690 static void basic_ostream_char_sentry_destroy(basic_ostream_char *ostr)
3691 {
3692     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
3693
3694     if(ios_base_good(&base->base) && !__uncaught_exception())
3695         basic_ostream_char_osfx(ostr);
3696
3697     if(basic_ios_char_rdbuf_get(base))
3698         basic_streambuf_char__Unlock(base->strbuf);
3699 }
3700
3701 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE_NXZ */
3702 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA_NXZ */
3703 DEFINE_THISCALL_WRAPPER(basic_ostream_char_opfx, 4)
3704 MSVCP_bool __thiscall basic_ostream_char_opfx(basic_ostream_char *this)
3705 {
3706     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
3707
3708     TRACE("(%p)\n", this);
3709
3710     if(ios_base_good(&base->base) && base->stream)
3711         basic_ostream_char_flush(base->stream);
3712     return ios_base_good(&base->base);
3713 }
3714
3715 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
3716 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
3717 DEFINE_THISCALL_WRAPPER(basic_ostream_char_put, 8)
3718 basic_ostream_char* __thiscall basic_ostream_char_put(basic_ostream_char *this, char ch)
3719 {
3720     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
3721
3722     TRACE("(%p %c)\n", this, ch);
3723
3724     if(!basic_ostream_char_sentry_create(this)
3725             || basic_streambuf_char_sputc(base->strbuf, ch)==EOF) {
3726         basic_ostream_char_sentry_destroy(this);
3727         basic_ios_char_setstate(base, IOSTATE_badbit);
3728         return this;
3729     }
3730
3731     basic_ostream_char_sentry_destroy(this);
3732     return this;
3733 }
3734
3735 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
3736 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
3737 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp, 12)
3738 basic_ostream_char* __thiscall basic_ostream_char_seekp(basic_ostream_char *this, streamoff off, int way)
3739 {
3740     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
3741
3742     TRACE("(%p %ld %d)\n", this, off, way);
3743
3744     if(!ios_base_fail(&base->base)) {
3745         fpos_int seek;
3746
3747         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
3748                 &seek, off, way, OPENMODE_out);
3749         if(seek.off==0 && seek.pos==-1 && seek.state==0)
3750             basic_ios_char_setstate(base, IOSTATE_failbit);
3751     }
3752     return this;
3753 }
3754
3755 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
3756 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
3757 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp_fpos, 28)
3758 basic_ostream_char* __thiscall basic_ostream_char_seekp_fpos(basic_ostream_char *this, fpos_int pos)
3759 {
3760     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
3761
3762     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
3763
3764     if(!ios_base_fail(&base->base)) {
3765         fpos_int seek;
3766
3767         basic_streambuf_char_pubseekpos(basic_ios_char_rdbuf_get(base),
3768                 &seek, pos, OPENMODE_out);
3769         if(seek.off==0 && seek.pos==-1 && seek.state==0)
3770             basic_ios_char_setstate(base, IOSTATE_failbit);
3771     }
3772     return this;
3773 }
3774
3775 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
3776 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
3777 DEFINE_THISCALL_WRAPPER(basic_ostream_char_tellp, 8)
3778 fpos_int* __thiscall basic_ostream_char_tellp(basic_ostream_char *this, fpos_int *ret)
3779 {
3780     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
3781
3782     TRACE("(%p)\n", this);
3783
3784     if(!ios_base_fail(&base->base)) {
3785         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
3786                 ret, 0, SEEKDIR_cur, OPENMODE_out);
3787     }else {
3788         ret->off = 0;
3789         ret->pos = -1;
3790         ret->state = 0;
3791     }
3792     return ret;
3793 }
3794
3795 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@PBDH@Z */
3796 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEBD_J@Z */
3797 DEFINE_THISCALL_WRAPPER(basic_ostream_char_write, 12)
3798 basic_ostream_char* __thiscall basic_ostream_char_write(basic_ostream_char *this, const char *str, streamsize count)
3799 {
3800     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
3801
3802     TRACE("(%p %s %ld)\n", this, debugstr_a(str), count);
3803
3804     if(!basic_ostream_char_sentry_create(this)
3805             || basic_streambuf_char_sputn(base->strbuf, str, count)!=count) {
3806         basic_ostream_char_sentry_destroy(this);
3807         basic_ios_char_setstate(base, IOSTATE_badbit);
3808         return this;
3809     }
3810
3811     basic_ostream_char_sentry_destroy(this);
3812     return this;
3813 }
3814
3815 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@F@Z */
3816 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@F@Z */
3817 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_short, 8)
3818 basic_ostream_char* __thiscall basic_ostream_char_print_short(basic_ostream_char *this, short val)
3819 {
3820     FIXME("(%p %d) stub\n", this, val);
3821     return NULL;
3822 }
3823
3824 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@G@Z */
3825 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@G@Z */
3826 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ushort, 8)
3827 basic_ostream_char* __thiscall basic_ostream_char_print_ushort(basic_ostream_char *this, unsigned short val)
3828 {
3829     FIXME("(%p %d) stub\n", this, val);
3830     return NULL;
3831 }
3832
3833 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z */
3834 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z */
3835 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int, 8)
3836 basic_ostream_char* __thiscall basic_ostream_char_print_int(basic_ostream_char *this, int val)
3837 {
3838     FIXME("(%p %d) stub\n", this, val);
3839     return NULL;
3840 }
3841
3842 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z */
3843 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@I@Z */
3844 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint, 8)
3845 basic_ostream_char* __thiscall basic_ostream_char_print_uint(basic_ostream_char *this, unsigned int val)
3846 {
3847     FIXME("(%p %d) stub\n", this, val);
3848     return NULL;
3849 }
3850
3851 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z */
3852 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z */
3853 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_long, 8)
3854 basic_ostream_char* __thiscall basic_ostream_char_print_long(basic_ostream_char *this, LONG val)
3855 {
3856     FIXME("(%p %d) stub\n", this, val);
3857     return NULL;
3858 }
3859
3860 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z */
3861 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z */
3862 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ulong, 8)
3863 basic_ostream_char* __thiscall basic_ostream_char_print_ulong(basic_ostream_char *this, ULONG val)
3864 {
3865     FIXME("(%p %d) stub\n", this, val);
3866     return NULL;
3867 }
3868
3869 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z */
3870 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z */
3871 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_float, 8)
3872 basic_ostream_char* __thiscall basic_ostream_char_print_float(basic_ostream_char *this, float val)
3873 {
3874     FIXME("(%p %f) stub\n", this, val);
3875     return NULL;
3876 }
3877
3878 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z */
3879 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z */
3880 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_double, 12)
3881 basic_ostream_char* __thiscall basic_ostream_char_print_double(basic_ostream_char *this, double val)
3882 {
3883     FIXME("(%p %lf) stub\n", this, val);
3884     return NULL;
3885 }
3886
3887 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
3888 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
3889 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_streambuf, 8)
3890 basic_ostream_char* __thiscall basic_ostream_char_print_streambuf(basic_ostream_char *this, basic_streambuf_char *val)
3891 {
3892     FIXME("(%p %p) stub\n", this, val);
3893     return NULL;
3894 }
3895
3896 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z */
3897 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z */
3898 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ptr, 8)
3899 basic_ostream_char* __thiscall basic_ostream_char_print_ptr(basic_ostream_char *this, const void *val)
3900 {
3901     FIXME("(%p %p) stub\n", this, val);
3902     return NULL;
3903 }
3904
3905 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_J@Z */
3906 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_J@Z */
3907 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int64, 12)
3908 basic_ostream_char* __thiscall basic_ostream_char_print_int64(basic_ostream_char *this, __int64 val)
3909 {
3910     FIXME("(%p) stub\n", this);
3911     return NULL;
3912 }
3913
3914 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_K@Z */
3915 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_K@Z */
3916 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint64, 12)
3917 basic_ostream_char* __thiscall basic_ostream_char_print_uint64(basic_ostream_char *this, unsigned __int64 val)
3918 {
3919     FIXME("(%p) stub\n", this);
3920     return NULL;
3921 }
3922
3923 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_N@Z */
3924 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_N@Z */
3925 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_bool, 8)
3926 basic_ostream_char* __thiscall basic_ostream_char_print_bool(basic_ostream_char *this, MSVCP_bool val)
3927 {
3928     FIXME("(%p %x) stub\n", this, val);
3929     return NULL;
3930 }
3931
3932 /* ?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
3933 /* ?endl@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
3934 basic_ostream_char* __cdecl basic_ostream_char_endl(basic_ostream_char *ostr)
3935 {
3936     TRACE("(%p)\n", ostr);
3937
3938     basic_ostream_char_put(ostr, '\n');
3939     basic_ostream_char_flush(ostr);
3940     return ostr;
3941 }
3942
3943 /* Caution: basic_istream uses virtual inheritance. */
3944 static inline basic_ios_char* basic_istream_char_get_basic_ios(basic_istream_char *this)
3945 {
3946     return (basic_ios_char*)((char*)this+this->vbtable[1]);
3947 }
3948
3949 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
3950 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
3951 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_init, 20)
3952 basic_istream_char* __thiscall basic_istream_char_ctor_init(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
3953 {
3954     basic_ios_char *base;
3955
3956     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
3957
3958     if(virt_init) {
3959         this->vbtable = basic_istream_char_vbtable;
3960         base = basic_istream_char_get_basic_ios(this);
3961         basic_ios_char_ctor(base);
3962     }else {
3963         base = basic_istream_char_get_basic_ios(this);
3964     }
3965
3966     base->base.vtable = &MSVCP_basic_istream_char_vtable;
3967     this->count = 0;
3968     if(!noinit)
3969         basic_ios_char_init(base, strbuf, isstd);
3970     return this;
3971 }
3972
3973 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
3974 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
3975 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor, 16)
3976 basic_istream_char* __thiscall basic_istream_char_ctor(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
3977 {
3978     return basic_istream_char_ctor_init(this, strbuf, isstd, FALSE, virt_init);
3979 }
3980
3981 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
3982 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
3983 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_uninitialized, 12)
3984 basic_istream_char* __thiscall basic_istream_char_ctor_uninitialized(basic_istream_char *this, int uninitialized, MSVCP_bool virt_init)
3985 {
3986     basic_ios_char *base;
3987
3988     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
3989
3990     if(virt_init) {
3991         this->vbtable = basic_istream_char_vbtable;
3992         base = basic_istream_char_get_basic_ios(this);
3993         basic_ios_char_ctor(base);
3994     }else {
3995         base = basic_istream_char_get_basic_ios(this);
3996     }
3997
3998     base->base.vtable = &MSVCP_basic_istream_char_vtable;
3999     ios_base_Addstd(&base->base);
4000     return this;
4001 }
4002
4003 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UAE@XZ */
4004 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
4005 DEFINE_THISCALL_WRAPPER(basic_istream_char_dtor, 4)
4006 void __thiscall basic_istream_char_dtor(basic_istream_char *this)
4007 {
4008     /* don't destroy virtual base here */
4009     TRACE("(%p)\n", this);
4010 }
4011
4012 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
4013 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
4014 DEFINE_THISCALL_WRAPPER(basic_istream_char_vbase_dtor, 4)
4015 void __thiscall basic_istream_char_vbase_dtor(basic_istream_char *this)
4016 {
4017     TRACE("(%p)\n", this);
4018     basic_istream_char_dtor(this);
4019     basic_ios_char_dtor(basic_istream_char_get_basic_ios(this));
4020 }
4021
4022 DEFINE_THISCALL_WRAPPER(MSVCP_basic_istream_char_vector_dtor, 8)
4023 basic_istream_char* __thiscall MSVCP_basic_istream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
4024 {
4025     basic_istream_char *this = (basic_istream_char *)((char*)base - basic_istream_char_vbtable[1] + basic_istream_char_vbtable[0]);
4026
4027     TRACE("(%p %x)\n", this, flags);
4028
4029     if(flags & 2) {
4030         /* we have an array, with the number of elements stored before the first object */
4031         int i, *ptr = (int *)this-1;
4032
4033         for(i=*ptr-1; i>=0; i--)
4034             basic_istream_char_vbase_dtor(this+i);
4035         MSVCRT_operator_delete(ptr);
4036     } else {
4037         basic_istream_char_vbase_dtor(this);
4038         if(flags & 1)
4039             MSVCRT_operator_delete(this);
4040     }
4041
4042     return this;
4043 }
4044
4045 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
4046 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
4047 DEFINE_THISCALL_WRAPPER(basic_istream_char__Ipfx, 8)
4048 MSVCP_bool __thiscall basic_istream_char__Ipfx(basic_istream_char *this, MSVCP_bool noskip)
4049 {
4050     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4051
4052     TRACE("(%p %d)\n", this, noskip);
4053
4054     if(!ios_base_good(&base->base)) {
4055         basic_ios_char_setstate(base, IOSTATE_failbit);
4056         return FALSE;
4057     }
4058
4059     if(basic_ios_char_tie_get(base))
4060         basic_ostream_char_flush(basic_ios_char_tie_get(base));
4061
4062     if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
4063         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4064         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
4065         int ch;
4066
4067         for(ch = basic_streambuf_char_sgetc(strbuf); ;
4068                 ch = basic_streambuf_char_snextc(strbuf)) {
4069             if(ch == EOF) {
4070                 basic_ios_char_setstate(base, IOSTATE_eofbit);
4071                 return FALSE;
4072             }
4073
4074             if(!ctype_char_is_ch(ctype, _SPACE|_BLANK, ch))
4075                 break;
4076         }
4077     }
4078
4079     return TRUE;
4080 }
4081
4082 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
4083 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
4084 DEFINE_THISCALL_WRAPPER(basic_istream_char_ipfx, 8)
4085 MSVCP_bool __thiscall basic_istream_char_ipfx(basic_istream_char *this, MSVCP_bool noskip)
4086 {
4087     return basic_istream_char__Ipfx(this, noskip);
4088 }
4089
4090 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
4091 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
4092 DEFINE_THISCALL_WRAPPER(basic_istream_char_isfx, 4)
4093 void __thiscall basic_istream_char_isfx(basic_istream_char *this)
4094 {
4095     TRACE("(%p)\n", this);
4096 }
4097
4098 static BOOL basic_istream_char_sentry_create(basic_istream_char *istr, MSVCP_bool noskip)
4099 {
4100     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
4101
4102     if(basic_ios_char_rdbuf_get(base))
4103         basic_streambuf_char__Lock(base->strbuf);
4104
4105     return basic_istream_char_ipfx(istr, noskip);
4106 }
4107
4108 static void basic_istream_char_sentry_destroy(basic_istream_char *istr)
4109 {
4110     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
4111
4112     if(basic_ios_char_rdbuf_get(base))
4113         basic_streambuf_char__Unlock(base->strbuf);
4114 }
4115
4116 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QBEHXZ */
4117 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QEBA_JXZ */
4118 DEFINE_THISCALL_WRAPPER(basic_istream_char_gcount, 4)
4119 int __thiscall basic_istream_char_gcount(const basic_istream_char *this)
4120 {
4121     TRACE("(%p)\n", this);
4122     return this->count;
4123 }
4124
4125 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
4126 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
4127 DEFINE_THISCALL_WRAPPER(basic_istream_char_get, 4)
4128 int __thiscall basic_istream_char_get(basic_istream_char *this)
4129 {
4130     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4131     int ret;
4132
4133     TRACE("(%p)\n", this);
4134
4135     this->count = 0;
4136
4137     if(!basic_istream_char_sentry_create(this, TRUE)) {
4138         basic_istream_char_sentry_destroy(this);
4139         return EOF;
4140     }
4141
4142     ret = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(base));
4143     basic_istream_char_sentry_destroy(this);
4144     if(ret == EOF)
4145         basic_ios_char_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
4146     else
4147         this->count++;
4148
4149     return ret;
4150 }
4151
4152 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAD@Z */
4153 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAD@Z */
4154 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_ch, 8)
4155 basic_istream_char* __thiscall basic_istream_char_get_ch(basic_istream_char *this, char *ch)
4156 {
4157     int ret;
4158
4159     TRACE("(%p %p)\n", this, ch);
4160
4161     ret = basic_istream_char_get(this);
4162     if(ret != EOF)
4163         *ch = (char)ret;
4164     return this;
4165 }
4166
4167 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
4168 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
4169 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str_delim, 16)
4170 basic_istream_char* __thiscall basic_istream_char_get_str_delim(basic_istream_char *this, char *str, streamsize count, char delim)
4171 {
4172     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4173     int ch = delim;
4174
4175     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
4176
4177     this->count = 0;
4178
4179     if(basic_istream_char_sentry_create(this, TRUE)) {
4180         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4181
4182         for(ch = basic_streambuf_char_sgetc(strbuf); count>1;
4183                 ch = basic_streambuf_char_snextc(strbuf)) {
4184             if(ch==EOF || ch==delim)
4185                 break;
4186
4187             *str++ = ch;
4188             this->count++;
4189             count--;
4190         }
4191     }
4192     basic_istream_char_sentry_destroy(this);
4193
4194     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
4195             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
4196     if(count > 0)
4197         *str = 0;
4198     return this;
4199 }
4200
4201 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
4202 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
4203 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str, 12)
4204 basic_istream_char* __thiscall basic_istream_char_get_str(basic_istream_char *this, char *str, streamsize count)
4205 {
4206     return basic_istream_char_get_str_delim(this, str, count, '\n');
4207 }
4208
4209 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
4210 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
4211 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf_delim, 12)
4212 basic_istream_char* __thiscall basic_istream_char_get_streambuf_delim(basic_istream_char *this, basic_streambuf_char *strbuf, char delim)
4213 {
4214     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4215     int ch = delim;
4216
4217     TRACE("(%p %p %c)\n", this, strbuf, delim);
4218
4219     this->count = 0;
4220
4221     if(basic_istream_char_sentry_create(this, TRUE)) {
4222         basic_streambuf_char *strbuf_read = basic_ios_char_rdbuf_get(base);
4223
4224         for(ch = basic_streambuf_char_sgetc(strbuf_read); ;
4225                 ch = basic_streambuf_char_snextc(strbuf_read)) {
4226             if(ch==EOF || ch==delim)
4227                 break;
4228
4229             if(basic_streambuf_char_sputc(strbuf, ch) == EOF)
4230                 break;
4231             this->count++;
4232         }
4233     }
4234     basic_istream_char_sentry_destroy(this);
4235
4236     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
4237             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
4238     return this;
4239 }
4240
4241 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
4242 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
4243 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf, 8)
4244 basic_istream_char* __thiscall basic_istream_char_get_streambuf(basic_istream_char *this, basic_streambuf_char *strbuf)
4245 {
4246     return basic_istream_char_get_streambuf_delim(this, strbuf, '\n');
4247 }
4248
4249 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
4250 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
4251 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline_delim, 16)
4252 basic_istream_char* __thiscall basic_istream_char_getline_delim(basic_istream_char *this, char *str, streamsize count, char delim)
4253 {
4254     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4255     int ch = delim;
4256
4257     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
4258
4259     this->count = 0;
4260
4261     if(basic_istream_char_sentry_create(this, TRUE) && count>0) {
4262         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4263
4264         while(count > 1) {
4265             ch = basic_streambuf_char_sbumpc(strbuf);
4266
4267             if(ch==EOF || ch==delim)
4268                 break;
4269
4270             *str++ = ch;
4271             this->count++;
4272             count--;
4273         }
4274
4275         if(ch == delim)
4276             this->count++;
4277         else if(ch != EOF) {
4278             ch = basic_streambuf_char_sgetc(strbuf);
4279
4280             if(ch == delim) {
4281                 basic_streambuf_char__Gninc(strbuf);
4282                 this->count++;
4283             }
4284         }
4285     }
4286     basic_istream_char_sentry_destroy(this);
4287
4288     basic_ios_char_setstate(base, (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
4289             (!this->count || (ch!=delim && ch!=EOF) ? IOSTATE_failbit : IOSTATE_goodbit));
4290     if(count > 0)
4291         *str = 0;
4292     return this;
4293 }
4294
4295 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
4296 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
4297 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline, 12)
4298 basic_istream_char* __thiscall basic_istream_char_getline(basic_istream_char *this, char *str, streamsize count)
4299 {
4300     return basic_istream_char_getline_delim(this, str, count, '\n');
4301 }
4302
4303 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z */
4304 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
4305 DEFINE_THISCALL_WRAPPER(basic_istream_char_ignore, 12)
4306 basic_istream_char* __thiscall basic_istream_char_ignore(basic_istream_char *this, streamsize count, int delim)
4307 {
4308     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4309     int ch = delim;
4310
4311     TRACE("(%p %ld %d)\n", this, count, delim);
4312
4313     this->count = 0;
4314
4315     if(basic_istream_char_sentry_create(this, TRUE)) {
4316         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4317
4318         while(count > 0) {
4319             ch = basic_streambuf_char_sbumpc(strbuf);
4320
4321             if(ch==EOF || ch==delim)
4322                 break;
4323
4324             this->count++;
4325             if(count != INT_MAX)
4326                 count--;
4327         }
4328     }
4329     basic_istream_char_sentry_destroy(this);
4330
4331     if(ch == EOF)
4332         basic_ios_char_setstate(base, IOSTATE_eofbit);
4333     return this;
4334 }
4335
4336 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
4337 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
4338 DEFINE_THISCALL_WRAPPER(basic_istream_char_peek, 4)
4339 int __thiscall basic_istream_char_peek(basic_istream_char *this)
4340 {
4341     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4342     int ret = EOF;
4343
4344     TRACE("(%p)\n", this);
4345
4346     this->count = 0;
4347
4348     if(basic_istream_char_sentry_create(this, TRUE))
4349         ret = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
4350     basic_istream_char_sentry_destroy(this);
4351     return ret;
4352 }
4353
4354 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADIH@Z */
4355 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_K_J@Z */
4356 DEFINE_THISCALL_WRAPPER(basic_istream_char__Read_s, 16)
4357 basic_istream_char* __thiscall basic_istream_char__Read_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
4358 {
4359     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4360     IOSB_iostate state = IOSTATE_goodbit;
4361
4362     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
4363
4364     if(basic_istream_char_sentry_create(this, TRUE)) {
4365         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4366
4367         this->count = basic_streambuf_char__Sgetn_s(strbuf, str, size, count);
4368         if(this->count != count)
4369             state |= IOSTATE_failbit | IOSTATE_eofbit;
4370     }else {
4371         this->count = 0;
4372     }
4373     basic_istream_char_sentry_destroy(this);
4374
4375     basic_ios_char_setstate(base, state);
4376     return this;
4377 }
4378
4379 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
4380 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
4381 DEFINE_THISCALL_WRAPPER(basic_istream_char_read, 12)
4382 basic_istream_char* __thiscall basic_istream_char_read(basic_istream_char *this, char *str, streamsize count)
4383 {
4384     return basic_istream_char__Read_s(this, str, count, count);
4385 }
4386
4387 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
4388 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
4389 DEFINE_THISCALL_WRAPPER(basic_istream_char__Readsome_s, 16)
4390 streamsize __thiscall basic_istream_char__Readsome_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
4391 {
4392     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4393     IOSB_iostate state = IOSTATE_goodbit;
4394
4395     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
4396
4397     this->count = 0;
4398
4399     if(basic_istream_char_sentry_create(this, TRUE)) {
4400         streamsize avail = basic_streambuf_char_in_avail(basic_ios_char_rdbuf_get(base));
4401         if(avail > count)
4402             avail = count;
4403
4404         if(avail == -1)
4405             state |= IOSTATE_eofbit;
4406         else if(avail > 0)
4407             basic_istream_char__Read_s(this, str, size, avail);
4408     }else {
4409         state |= IOSTATE_failbit;
4410     }
4411     basic_istream_char_sentry_destroy(this);
4412
4413     basic_ios_char_setstate(base, state);
4414     return this->count;
4415 }
4416
4417 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
4418 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
4419 DEFINE_THISCALL_WRAPPER(basic_istream_char_readsome, 12)
4420 streamsize __thiscall basic_istream_char_readsome(basic_istream_char *this, char *str, streamsize count)
4421 {
4422     return basic_istream_char__Readsome_s(this, str, count, count);
4423 }
4424
4425 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
4426 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
4427 DEFINE_THISCALL_WRAPPER(basic_istream_char_putback, 8)
4428 basic_istream_char* __thiscall basic_istream_char_putback(basic_istream_char *this, char ch)
4429 {
4430     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4431     IOSB_iostate state = IOSTATE_goodbit;
4432
4433     TRACE("(%p %c)\n", this, ch);
4434
4435     this->count = 0;
4436
4437     if(basic_istream_char_sentry_create(this, TRUE)) {
4438         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4439
4440         if(!ios_base_good(&base->base))
4441             state |= IOSTATE_failbit;
4442         else if(!strbuf || basic_streambuf_char_sputbackc(strbuf, ch)==EOF)
4443             state |= IOSTATE_badbit;
4444     }
4445     basic_istream_char_sentry_destroy(this);
4446
4447     basic_ios_char_setstate(base, state);
4448     return this;
4449 }
4450
4451 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
4452 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
4453 DEFINE_THISCALL_WRAPPER(basic_istream_char_unget, 4)
4454 basic_istream_char* __thiscall basic_istream_char_unget(basic_istream_char *this)
4455 {
4456     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4457     IOSB_iostate state = IOSTATE_goodbit;
4458
4459     TRACE("(%p)\n", this);
4460
4461     this->count = 0;
4462
4463     if(basic_istream_char_sentry_create(this, TRUE)) {
4464         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4465
4466         if(!ios_base_good(&base->base))
4467             state |= IOSTATE_failbit;
4468         else if(!strbuf || basic_streambuf_char_sungetc(strbuf)==EOF)
4469             state |= IOSTATE_badbit;
4470     }
4471     basic_istream_char_sentry_destroy(this);
4472
4473     basic_ios_char_setstate(base, state);
4474     return this;
4475 }
4476
4477 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
4478 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
4479 DEFINE_THISCALL_WRAPPER(basic_istream_char_sync, 4)
4480 int __thiscall basic_istream_char_sync(basic_istream_char *this)
4481 {
4482     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4483     basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4484
4485     TRACE("(%p)\n", this);
4486
4487     if(!strbuf)
4488         return -1;
4489
4490     if(basic_istream_char_sentry_create(this, TRUE)) {
4491         if(basic_streambuf_char_pubsync(strbuf) != -1) {
4492             basic_istream_char_sentry_destroy(this);
4493             return 0;
4494         }
4495     }
4496     basic_istream_char_sentry_destroy(this);
4497
4498     basic_ios_char_setstate(base, IOSTATE_badbit);
4499     return -1;
4500 }
4501
4502 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
4503 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
4504 DEFINE_THISCALL_WRAPPER(basic_istream_char_tellg, 8)
4505 fpos_int* __thiscall basic_istream_char_tellg(basic_istream_char *this, fpos_int *ret)
4506 {
4507     TRACE("(%p %p)\n", this, ret);
4508
4509     if(basic_istream_char_sentry_create(this, TRUE)) {
4510         basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4511         if(!ios_base_fail(&base->base)) {
4512             basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
4513                     ret, 0, SEEKDIR_cur, OPENMODE_in);
4514             basic_istream_char_sentry_destroy(this);
4515
4516             if(ret->off==0 && ret->pos==-1 && ret->state==0)
4517                 basic_ios_char_setstate(base, IOSTATE_failbit);
4518             return ret;
4519         }
4520     }
4521     basic_istream_char_sentry_destroy(this);
4522
4523     ret->off = 0;
4524     ret->pos = -1;
4525     ret->state = 0;
4526     return ret;
4527 }
4528
4529 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
4530 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
4531 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg, 12)
4532 basic_istream_char* __thiscall basic_istream_char_seekg(basic_istream_char *this, streamoff off, int dir)
4533 {
4534     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4535
4536     TRACE("(%p %ld %d)\n", this, off, dir);
4537
4538     if(basic_istream_char_sentry_create(this, TRUE)) {
4539         if(!ios_base_fail(&base->base)) {
4540             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4541             fpos_int ret;
4542
4543             basic_streambuf_char_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
4544             basic_istream_char_sentry_destroy(this);
4545
4546             if(ret.off==0 && ret.pos==-1 && ret.state==0)
4547                 basic_ios_char_setstate(base, IOSTATE_failbit);
4548             else
4549                 basic_ios_char_clear(base, IOSTATE_goodbit);
4550             return this;
4551         }
4552     }
4553     basic_istream_char_sentry_destroy(this);
4554
4555     basic_ios_char_setstate(base, IOSTATE_failbit);
4556     return this;
4557 }
4558
4559 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
4560 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
4561 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg_fpos, 28)
4562 basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char *this, fpos_int pos)
4563 {
4564     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4565
4566     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
4567
4568     if(basic_istream_char_sentry_create(this, TRUE)) {
4569         if(!ios_base_fail(&base->base)) {
4570             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4571             fpos_int ret;
4572
4573             basic_streambuf_char_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
4574             basic_istream_char_sentry_destroy(this);
4575
4576             if(ret.off==0 && ret.pos==-1 && ret.state==0)
4577                 basic_ios_char_setstate(base, IOSTATE_failbit);
4578             else
4579                 basic_ios_char_clear(base, IOSTATE_goodbit);
4580             return this;
4581         }
4582     }
4583     basic_istream_char_sentry_destroy(this);
4584
4585     basic_ios_char_setstate(base, IOSTATE_failbit);
4586     return this;
4587 }
4588
4589 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAF@Z */
4590 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAF@Z */
4591 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_short, 8)
4592 basic_istream_char* __thiscall basic_istream_char_read_short(basic_istream_char *this, short *arg1)
4593 {
4594     FIXME("(%p %p) stub\n", this, arg1);
4595     return NULL;
4596 }
4597
4598 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAG@Z */
4599 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAG@Z */
4600 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ushort, 8)
4601 basic_istream_char* __thiscall basic_istream_char_read_ushort(basic_istream_char *this, unsigned short *arg1)
4602 {
4603     FIXME("(%p %p) stub\n", this, arg1);
4604     return NULL;
4605 }
4606
4607 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z */
4608 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAH@Z */
4609 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int, 8)
4610 basic_istream_char* __thiscall basic_istream_char_read_int(basic_istream_char *this, int *arg1)
4611 {
4612     FIXME("(%p %p) stub\n", this, arg1);
4613     return NULL;
4614 }
4615
4616 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAI@Z */
4617 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAI@Z */
4618 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint, 8)
4619 basic_istream_char* __thiscall basic_istream_char_read_uint(basic_istream_char *this, unsigned int *arg1)
4620 {
4621     FIXME("(%p %p) stub\n", this, arg1);
4622     return NULL;
4623 }
4624
4625 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAJ@Z */
4626 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAJ@Z */
4627 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_long, 8)
4628 basic_istream_char* __thiscall basic_istream_char_read_long(basic_istream_char *this, LONG *arg1)
4629 {
4630     FIXME("(%p %p) stub\n", this, arg1);
4631     return NULL;
4632 }
4633
4634 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAK@Z */
4635 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAK@Z */
4636 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ulong, 8)
4637 basic_istream_char* __thiscall basic_istream_char_read_ulong(basic_istream_char *this, ULONG *arg1)
4638 {
4639     FIXME("(%p %p) stub\n", this, arg1);
4640     return NULL;
4641 }
4642
4643 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z */
4644 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAM@Z */
4645 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_float, 8)
4646 basic_istream_char* __thiscall basic_istream_char_read_float(basic_istream_char *this, float *arg1)
4647 {
4648     FIXME("(%p %p) stub\n", this, arg1);
4649     return NULL;
4650 }
4651
4652 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z */
4653 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z */
4654 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_double, 8)
4655 basic_istream_char* __thiscall basic_istream_char_read_double(basic_istream_char *this, double *arg1)
4656 {
4657     FIXME("(%p %p) stub\n", this, arg1);
4658     return NULL;
4659 }
4660
4661 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAO@Z */
4662 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAO@Z */
4663 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ldouble, 8)
4664 basic_istream_char* __thiscall basic_istream_char_read_ldouble(basic_istream_char *this, long double *arg1)
4665 {
4666     FIXME("(%p %p) stub\n", this, arg1);
4667     return NULL;
4668 }
4669
4670 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAPAX@Z */
4671 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
4672 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ptr, 8)
4673 basic_istream_char* __thiscall basic_istream_char_read_ptr(basic_istream_char *this, void **arg1)
4674 {
4675     FIXME("(%p %p) stub\n", this, arg1);
4676     return NULL;
4677 }
4678
4679 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_J@Z */
4680 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_J@Z */
4681 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int64, 8)
4682 basic_istream_char* __thiscall basic_istream_char_read_int64(basic_istream_char *this, __int64 *arg1)
4683 {
4684     FIXME("(%p %p) stub\n", this, arg1);
4685     return NULL;
4686 }
4687
4688 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z */
4689 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z */
4690 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint64, 8)
4691 basic_istream_char* __thiscall basic_istream_char_read_uint64(basic_istream_char *this, unsigned __int64 *arg1)
4692 {
4693     FIXME("(%p %p) stub\n", this, arg1);
4694     return NULL;
4695 }
4696
4697 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_N@Z */
4698 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_N@Z */
4699 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_bool, 8)
4700 basic_istream_char* __thiscall basic_istream_char_read_bool(basic_istream_char *this, MSVCP_bool *arg1)
4701 {
4702     FIXME("(%p %p) stub\n", this, arg1);
4703     return NULL;
4704 }
4705
4706 /* ??$getline@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@D@Z */
4707 /* ??$getline@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@D@Z */
4708 basic_istream_char* __cdecl basic_istream_char_getline_str_delim(
4709         basic_istream_char *istream, basic_string_char *str, char delim)
4710 {
4711     IOSB_iostate state = IOSTATE_failbit;
4712     int c;
4713
4714     TRACE("(%p %p %c)\n", istream, str, delim);
4715
4716     if(basic_istream_char_sentry_create(istream, TRUE)) {
4717         MSVCP_basic_string_char_clear(str);
4718
4719         for(c = basic_istream_char_get(istream); c!=delim && c!=EOF;
4720                 c = basic_istream_char_get(istream)) {
4721             state = IOSTATE_goodbit;
4722             MSVCP_basic_string_char_append_ch(str, c);
4723         }
4724     }
4725     basic_istream_char_sentry_destroy(istream);
4726
4727     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream), state);
4728     return istream;
4729 }
4730
4731 /* ??$getline@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z */
4732 /* ??$getline@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z */
4733 basic_istream_char* __cdecl basic_istream_char_getline_str(
4734         basic_istream_char *istream, basic_string_char *str)
4735 {
4736     return basic_istream_char_getline_str_delim(istream, str, '\n');
4737 }
4738
4739 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4740 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4741 DEFINE_THISCALL_WRAPPER(basic_iostream_char_ctor, 12)
4742 basic_iostream_char* __thiscall basic_iostream_char_ctor(basic_iostream_char *this, basic_streambuf_char *strbuf, MSVCP_bool virt_init)
4743 {
4744     basic_ios_char *basic_ios;
4745
4746     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
4747
4748     if(virt_init) {
4749         this->base1.vbtable = basic_iostream_char_vbtable1;
4750         this->base2.vbtable = basic_iostream_char_vbtable2;
4751         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
4752         basic_ios_char_ctor(basic_ios);
4753     }else {
4754         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
4755     }
4756
4757     basic_ios->base.vtable = &MSVCP_basic_iostream_char_vtable;
4758
4759     basic_istream_char_ctor(&this->base1, strbuf, FALSE, FALSE);
4760     basic_ostream_char_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
4761     return this;
4762 }
4763
4764 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
4765 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
4766 DEFINE_THISCALL_WRAPPER(basic_iostream_char_dtor, 4)
4767 void __thiscall basic_iostream_char_dtor(basic_iostream_char *this)
4768 {
4769     TRACE("(%p)\n", this);
4770     basic_ostream_char_dtor(&this->base2);
4771     basic_istream_char_dtor(&this->base1);
4772 }
4773
4774 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
4775 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
4776 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vbase_dtor, 4)
4777 void __thiscall basic_iostream_char_vbase_dtor(basic_iostream_char *this)
4778 {
4779     TRACE("(%p)\n", this);
4780     basic_iostream_char_dtor(this);
4781     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base1));
4782 }
4783
4784 DEFINE_THISCALL_WRAPPER(MSVCP_basic_iostream_char_vector_dtor, 8)
4785 basic_iostream_char* __thiscall MSVCP_basic_iostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
4786 {
4787     basic_iostream_char *this = (basic_iostream_char *)((char*)base - basic_iostream_char_vbtable1[1] + basic_iostream_char_vbtable1[0]);
4788
4789     TRACE("(%p %x)\n", this, flags);
4790
4791     if(flags & 2) {
4792         /* we have an array, with the number of elements stored before the first object */
4793         int i, *ptr = (int *)this-1;
4794
4795         for(i=*ptr-1; i>=0; i--)
4796             basic_iostream_char_vbase_dtor(this+i);
4797         MSVCRT_operator_delete(ptr);
4798     } else {
4799         basic_iostream_char_vbase_dtor(this);
4800         if(flags & 1)
4801             MSVCRT_operator_delete(this);
4802     }
4803
4804     return this;
4805 }
4806
4807 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
4808 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
4809 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor, 8)
4810 basic_ofstream_char* __thiscall basic_ofstream_char_ctor(basic_ofstream_char *this, MSVCP_bool virt_init)
4811 {
4812     basic_ios_char *basic_ios;
4813
4814     TRACE("(%p %d)\n", this, virt_init);
4815
4816     if(virt_init) {
4817         this->base.vbtable = basic_ofstream_char_vbtable;
4818         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
4819         basic_ios_char_ctor(basic_ios);
4820     }else {
4821         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
4822     }
4823
4824     basic_filebuf_char_ctor(&this->filebuf);
4825     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
4826     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
4827     return this;
4828 }
4829
4830 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
4831 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
4832 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_file, 12)
4833 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_file(
4834         basic_ofstream_char *this, FILE *file, MSVCP_bool virt_init)
4835 {
4836     basic_ios_char *basic_ios;
4837
4838     TRACE("(%p %p %d)\n", this, file, virt_init);
4839
4840     if(virt_init) {
4841         this->base.vbtable = basic_ofstream_char_vbtable;
4842         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
4843         basic_ios_char_ctor(basic_ios);
4844     }else {
4845         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
4846     }
4847
4848     basic_filebuf_char_ctor_file(&this->filebuf, file);
4849     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
4850     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
4851     return this;
4852 }
4853
4854 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
4855 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
4856 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_name, 20)
4857 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_name(basic_ofstream_char *this,
4858         const char *name, int mode, int prot, MSVCP_bool virt_init)
4859 {
4860     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
4861
4862     basic_ofstream_char_ctor(this, virt_init);
4863
4864     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
4865         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
4866         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
4867     }
4868     return this;
4869 }
4870
4871 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PBGHH@Z */
4872 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEBGHH@Z */
4873 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PB_WHH@Z */
4874 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEB_WHH@Z */
4875 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_name_wchar, 20)
4876 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_name_wchar(basic_ofstream_char *this,
4877         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
4878 {
4879     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
4880
4881     basic_ofstream_char_ctor(this, virt_init);
4882
4883     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
4884         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
4885         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
4886     }
4887     return this;
4888 }
4889
4890 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
4891 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
4892 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_dtor, 4)
4893 void __thiscall basic_ofstream_char_dtor(basic_ofstream_char *this)
4894 {
4895     TRACE("(%p)\n", this);
4896
4897     basic_ostream_char_dtor(&this->base);
4898     basic_filebuf_char_dtor(&this->filebuf);
4899 }
4900
4901 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
4902 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
4903 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vbase_dtor, 4)
4904 void __thiscall basic_ofstream_char_vbase_dtor(basic_ofstream_char *this)
4905 {
4906     TRACE("(%p)\n", this);
4907
4908     basic_ofstream_char_dtor(this);
4909     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
4910 }
4911
4912 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ofstream_char_vector_dtor, 8)
4913 basic_ofstream_char* __thiscall MSVCP_basic_ofstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
4914 {
4915     basic_ofstream_char *this = (basic_ofstream_char *)((char*)base - basic_ofstream_char_vbtable[1] + basic_ofstream_char_vbtable[0]);
4916
4917     TRACE("(%p %x)\n", this, flags);
4918
4919     if(flags & 2) {
4920         /* we have an array, with the number of elements stored before the first object */
4921         int i, *ptr = (int *)this-1;
4922
4923         for(i=*ptr-1; i>=0; i--)
4924             basic_ofstream_char_vbase_dtor(this+i);
4925         MSVCRT_operator_delete(ptr);
4926     } else {
4927         basic_ofstream_char_vbase_dtor(this);
4928         if(flags & 1)
4929             MSVCRT_operator_delete(this);
4930     }
4931
4932     return this;
4933 }
4934
4935 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
4936 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
4937 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_close, 4)
4938 void __thiscall basic_ofstream_char_close(basic_ofstream_char *this)
4939 {
4940     TRACE("(%p)\n", this);
4941
4942     if(!basic_filebuf_char_close(&this->filebuf)) {
4943         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
4944         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
4945     }
4946 }
4947
4948 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
4949 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
4950 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_is_open, 4)
4951 MSVCP_bool __thiscall basic_ofstream_char_is_open(const basic_ofstream_char *this)
4952 {
4953     TRACE("(%p)\n", this);
4954     return basic_filebuf_char_is_open(&this->filebuf);
4955 }
4956
4957 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
4958 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
4959 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open, 16)
4960 void __thiscall basic_ofstream_char_open(basic_ofstream_char *this,
4961         const char *name, int mode, int prot)
4962 {
4963     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
4964
4965     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
4966         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
4967         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
4968     }
4969 }
4970
4971 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
4972 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
4973 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_old, 12)
4974 void __thiscall basic_ofstream_char_open_old(basic_ofstream_char *this,
4975         const char *name, unsigned int mode)
4976 {
4977     basic_ofstream_char_open(this, name, mode, _SH_DENYNO);
4978 }
4979
4980 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBGHH@Z */
4981 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGHH@Z */
4982 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPB_WHH@Z */
4983 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WHH@Z */
4984 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_wchar, 16)
4985 void __thiscall basic_ofstream_char_open_wchar(basic_ofstream_char *this,
4986         const wchar_t *name, int mode, int prot)
4987 {
4988     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
4989
4990     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
4991         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
4992         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
4993     }
4994 }
4995
4996 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBGI@Z */
4997 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGI@Z */
4998 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPB_WI@Z */
4999 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WI@Z */
5000 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_wchar_old, 12)
5001 void __thiscall basic_ofstream_char_open_wchar_old(basic_ofstream_char *this,
5002         const wchar_t *name, unsigned int mode)
5003 {
5004     basic_ofstream_char_open_wchar(this, name, mode, _SH_DENYNO);
5005 }
5006
5007 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
5008 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
5009 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_rdbuf, 4)
5010 basic_filebuf_char* __thiscall basic_ofstream_char_rdbuf(const basic_ofstream_char *this)
5011 {
5012     TRACE("(%p)\n", this);
5013     return (basic_filebuf_char*)&this->filebuf;
5014 }
5015
5016 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
5017 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
5018 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor, 8)
5019 basic_ifstream_char* __thiscall basic_ifstream_char_ctor(basic_ifstream_char *this, MSVCP_bool virt_init)
5020 {
5021     basic_ios_char *basic_ios;
5022
5023     TRACE("(%p %d)\n", this, virt_init);
5024
5025     if(virt_init) {
5026         this->base.vbtable = basic_ifstream_char_vbtable;
5027         basic_ios = basic_istream_char_get_basic_ios(&this->base);
5028         basic_ios_char_ctor(basic_ios);
5029     }else {
5030         basic_ios = basic_istream_char_get_basic_ios(&this->base);
5031     }
5032
5033     basic_filebuf_char_ctor(&this->filebuf);
5034     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
5035     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
5036     return this;
5037 }
5038
5039 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
5040 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
5041 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_file, 12)
5042 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_file(
5043         basic_ifstream_char *this, FILE *file, MSVCP_bool virt_init)
5044 {
5045     basic_ios_char *basic_ios;
5046
5047     TRACE("(%p %p %d)\n", this, file, virt_init);
5048
5049     if(virt_init) {
5050         this->base.vbtable = basic_ifstream_char_vbtable;
5051         basic_ios = basic_istream_char_get_basic_ios(&this->base);
5052         basic_ios_char_ctor(basic_ios);
5053     }else {
5054         basic_ios = basic_istream_char_get_basic_ios(&this->base);
5055     }
5056
5057     basic_filebuf_char_ctor_file(&this->filebuf, file);
5058     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
5059     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
5060     return this;
5061 }
5062
5063 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
5064 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
5065 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_name, 20)
5066 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_name(basic_ifstream_char *this,
5067         const char *name, int mode, int prot, MSVCP_bool virt_init)
5068 {
5069     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
5070
5071     basic_ifstream_char_ctor(this, virt_init);
5072
5073     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
5074         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
5075         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5076     }
5077     return this;
5078 }
5079
5080 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBGHH@Z */
5081 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEBGHH@Z */
5082 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PB_WHH@Z */
5083 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEB_WHH@Z */
5084 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_name_wchar, 20)
5085 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_name_wchar(basic_ifstream_char *this,
5086         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
5087 {
5088     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
5089
5090     basic_ifstream_char_ctor(this, virt_init);
5091
5092     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
5093         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
5094         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5095     }
5096     return this;
5097 }
5098
5099 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
5100 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
5101 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_dtor, 4)
5102 void __thiscall basic_ifstream_char_dtor(basic_ifstream_char *this)
5103 {
5104     TRACE("(%p)\n", this);
5105
5106     basic_istream_char_dtor(&this->base);
5107     basic_filebuf_char_dtor(&this->filebuf);
5108 }
5109
5110 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5111 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5112 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vbase_dtor, 4)
5113 void __thiscall basic_ifstream_char_vbase_dtor(basic_ifstream_char *this)
5114 {
5115     TRACE("(%p)\n", this);
5116
5117     basic_ifstream_char_dtor(this);
5118     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
5119 }
5120
5121 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ifstream_char_vector_dtor, 8)
5122 basic_ifstream_char* __thiscall MSVCP_basic_ifstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
5123 {
5124     basic_ifstream_char *this = (basic_ifstream_char *)((char*)base - basic_ifstream_char_vbtable[1] + basic_ifstream_char_vbtable[0]);
5125
5126     TRACE("(%p %x)\n", this, flags);
5127
5128     if(flags & 2) {
5129         /* we have an array, with the number of elements stored before the first object */
5130         int i, *ptr = (int *)this-1;
5131
5132         for(i=*ptr-1; i>=0; i--)
5133             basic_ifstream_char_vbase_dtor(this+i);
5134         MSVCRT_operator_delete(ptr);
5135     } else {
5136         basic_ifstream_char_vbase_dtor(this);
5137         if(flags & 1)
5138             MSVCRT_operator_delete(this);
5139     }
5140
5141     return this;
5142 }
5143
5144 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5145 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5146 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_close, 4)
5147 void __thiscall basic_ifstream_char_close(basic_ifstream_char *this)
5148 {
5149     TRACE("(%p)\n", this);
5150
5151     if(!basic_filebuf_char_close(&this->filebuf)) {
5152         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
5153         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5154     }
5155 }
5156
5157 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
5158 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
5159 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_is_open, 4)
5160 MSVCP_bool __thiscall basic_ifstream_char_is_open(const basic_ifstream_char *this)
5161 {
5162     TRACE("(%p)\n", this);
5163     return basic_filebuf_char_is_open(&this->filebuf);
5164 }
5165
5166 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
5167 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
5168 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open, 16)
5169 void __thiscall basic_ifstream_char_open(basic_ifstream_char *this,
5170         const char *name, int mode, int prot)
5171 {
5172     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
5173
5174     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
5175         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
5176         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5177     }
5178 }
5179
5180 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
5181 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
5182 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_old, 12)
5183 void __thiscall basic_ifstream_char_open_old(basic_ifstream_char *this,
5184         const char *name, unsigned int mode)
5185 {
5186     basic_ifstream_char_open(this, name, mode, _SH_DENYNO);
5187 }
5188
5189 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBGHH@Z */
5190 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGHH@Z */
5191 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPB_WHH@Z */
5192 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WHH@Z */
5193 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_wchar, 16)
5194 void __thiscall basic_ifstream_char_open_wchar(basic_ifstream_char *this,
5195         const wchar_t *name, int mode, int prot)
5196 {
5197     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
5198
5199     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
5200         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
5201         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5202     }
5203 }
5204
5205 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBGI@Z */
5206 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGI@Z */
5207 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPB_WI@Z */
5208 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WI@Z */
5209 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_wchar_old, 12)
5210 void __thiscall basic_ifstream_char_open_wchar_old(basic_ifstream_char *this,
5211         const wchar_t *name, unsigned int mode)
5212 {
5213     basic_ifstream_char_open_wchar(this, name, mode, _SH_DENYNO);
5214 }
5215
5216 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
5217 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
5218 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_rdbuf, 4)
5219 basic_filebuf_char* __thiscall basic_ifstream_char_rdbuf(const basic_ifstream_char *this)
5220 {
5221     TRACE("(%p)\n", this);
5222     return (basic_filebuf_char*)&this->filebuf;
5223 }
5224
5225 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
5226 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
5227 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor, 8)
5228 basic_fstream_char* __thiscall basic_fstream_char_ctor(basic_fstream_char *this, MSVCP_bool virt_init)
5229 {
5230     basic_ios_char *basic_ios;
5231
5232     TRACE("(%p %d)\n", this, virt_init);
5233
5234     if(virt_init) {
5235         this->base.base1.vbtable = basic_fstream_char_vbtable1;
5236         this->base.base2.vbtable = basic_fstream_char_vbtable2;
5237         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5238         basic_ios_char_ctor(basic_ios);
5239     }else {
5240         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5241     }
5242
5243     basic_filebuf_char_ctor(&this->filebuf);
5244     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
5245     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
5246     return this;
5247 }
5248
5249 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
5250 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
5251 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_file, 12)
5252 basic_fstream_char* __thiscall basic_fstream_char_ctor_file(basic_fstream_char *this,
5253         FILE *file, MSVCP_bool virt_init)
5254 {
5255     basic_ios_char *basic_ios;
5256
5257     TRACE("(%p %p %d)\n", this, file, virt_init);
5258
5259     if(virt_init) {
5260         this->base.base1.vbtable = basic_fstream_char_vbtable1;
5261         this->base.base2.vbtable = basic_fstream_char_vbtable2;
5262         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5263         basic_ios_char_ctor(basic_ios);
5264     }else {
5265         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5266     }
5267
5268     basic_filebuf_char_ctor_file(&this->filebuf, file);
5269     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
5270     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
5271     return this;
5272 }
5273
5274 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
5275 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
5276 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_name, 20)
5277 basic_fstream_char* __thiscall basic_fstream_char_ctor_name(basic_fstream_char *this,
5278         const char *name, int mode, int prot, MSVCP_bool virt_init)
5279 {
5280     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
5281
5282     basic_fstream_char_ctor(this, virt_init);
5283
5284     if(!basic_filebuf_char_open(&this->filebuf, name, mode, prot)) {
5285         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5286         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5287     }
5288     return this;
5289 }
5290
5291 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBGHH@Z */
5292 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBGHH@Z */
5293 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PB_WHH@Z */
5294 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEB_WHH@Z */
5295 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_name_wchar, 20)
5296 basic_fstream_char* __thiscall basic_fstream_char_ctor_name_wchar(basic_fstream_char *this,
5297         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
5298 {
5299     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
5300
5301     basic_fstream_char_ctor(this, virt_init);
5302
5303     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode, prot)) {
5304         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5305         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5306     }
5307     return this;
5308 }
5309
5310 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
5311 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
5312 DEFINE_THISCALL_WRAPPER(basic_fstream_char_dtor, 4)
5313 void __thiscall basic_fstream_char_dtor(basic_fstream_char *this)
5314 {
5315     TRACE("(%p)\n", this);
5316
5317     basic_iostream_char_dtor(&this->base);
5318     basic_filebuf_char_dtor(&this->filebuf);
5319 }
5320
5321 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5322 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5323 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vbase_dtor, 4)
5324 void __thiscall basic_fstream_char_vbase_dtor(basic_fstream_char *this)
5325 {
5326     TRACE("(%p)\n", this);
5327
5328     basic_fstream_char_dtor(this);
5329     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
5330 }
5331
5332 DEFINE_THISCALL_WRAPPER(MSVCP_basic_fstream_char_vector_dtor, 8)
5333 basic_fstream_char* __thiscall MSVCP_basic_fstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
5334 {
5335     basic_fstream_char *this = (basic_fstream_char *)((char*)base - basic_fstream_char_vbtable1[1] + basic_fstream_char_vbtable1[0]);
5336
5337     TRACE("(%p %x)\n", this, flags);
5338
5339     if(flags & 2) {
5340         /* we have an array, with the number of elements stored before the first object */
5341         int i, *ptr = (int *)this-1;
5342
5343         for(i=*ptr-1; i>=0; i--)
5344             basic_fstream_char_vbase_dtor(this+i);
5345         MSVCRT_operator_delete(ptr);
5346     } else {
5347         basic_fstream_char_vbase_dtor(this);
5348         if(flags & 1)
5349             MSVCRT_operator_delete(this);
5350     }
5351
5352     return this;
5353 }
5354
5355 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5356 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5357 DEFINE_THISCALL_WRAPPER(basic_fstream_char_close, 4)
5358 void __thiscall basic_fstream_char_close(basic_fstream_char *this)
5359 {
5360     TRACE("(%p)\n", this);
5361
5362     if(!basic_filebuf_char_close(&this->filebuf)) {
5363         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5364         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5365     }
5366 }
5367
5368 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
5369 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
5370 DEFINE_THISCALL_WRAPPER(basic_fstream_char_is_open, 4)
5371 MSVCP_bool __thiscall basic_fstream_char_is_open(const basic_fstream_char *this)
5372 {
5373     TRACE("(%p)\n", this);
5374     return basic_filebuf_char_is_open(&this->filebuf);
5375 }
5376
5377 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
5378 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
5379 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open, 16)
5380 void __thiscall basic_fstream_char_open(basic_fstream_char *this,
5381         const char *name, int mode, int prot)
5382 {
5383     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
5384
5385     if(!basic_filebuf_char_open(&this->filebuf, name, mode, prot)) {
5386         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5387         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5388     }
5389 }
5390
5391 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
5392 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
5393 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_old, 12)
5394 void __thiscall basic_fstream_char_open_old(basic_fstream_char *this,
5395         const char *name, unsigned int mode)
5396 {
5397     basic_fstream_char_open(this, name, mode, _SH_DENYNO);
5398 }
5399
5400 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBGHH@Z */
5401 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGHH@Z */
5402 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPB_WHH@Z */
5403 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WHH@Z */
5404 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_wchar, 16)
5405 void __thiscall basic_fstream_char_open_wchar(basic_fstream_char *this,
5406         const wchar_t *name, int mode, int prot)
5407 {
5408     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
5409
5410     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode, prot)) {
5411         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5412         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5413     }
5414 }
5415
5416 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBGI@Z */
5417 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGI@Z */
5418 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPB_WI@Z */
5419 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WI@Z */
5420 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_wchar_old, 12)
5421 void __thiscall basic_fstream_char_open_wchar_old(basic_fstream_char *this,
5422         const wchar_t *name, unsigned int mode)
5423 {
5424     basic_fstream_char_open_wchar(this, name, mode, _SH_DENYNO);
5425 }
5426
5427 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
5428 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
5429 DEFINE_THISCALL_WRAPPER(basic_fstream_char_rdbuf, 4)
5430 basic_filebuf_char* __thiscall basic_fstream_char_rdbuf(const basic_fstream_char *this)
5431 {
5432     TRACE("(%p)\n", this);
5433     return (basic_filebuf_char*)&this->filebuf;
5434 }