msvcp90: Added cin, cout and cerr objects.
[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 /* $?6DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z */
3944 /* ??$?6DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z */
3945 basic_ostream_char* __cdecl basic_ostream_char_print_bstr(basic_ostream_char *ostr, const basic_string_char *str)
3946 {
3947     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
3948     IOSB_iostate state = IOSTATE_goodbit;
3949
3950     TRACE("(%p %p)\n", ostr, str);
3951
3952     if(basic_ostream_char_sentry_create(ostr)) {
3953         MSVCP_size_t len = MSVCP_basic_string_char_length(str);
3954         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
3955
3956         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
3957             for(; pad!=0; pad--) {
3958                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
3959                     state = IOSTATE_badbit;
3960                     break;
3961                 }
3962             }
3963         }
3964
3965         if(state == IOSTATE_goodbit) {
3966             if(basic_streambuf_char_sputn(base->strbuf, MSVCP_basic_string_char_c_str(str), len) != len)
3967                     state = IOSTATE_badbit;
3968         }
3969
3970         for(; pad!=0; pad--) {
3971             if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
3972                 state = IOSTATE_badbit;
3973                 break;
3974             }
3975         }
3976
3977         base->base.wide = 0;
3978     }else {
3979         state = IOSTATE_badbit;
3980     }
3981     basic_ostream_char_sentry_destroy(ostr);
3982
3983     basic_ios_char_setstate(base, state);
3984     return ostr;
3985 }
3986
3987 /* Caution: basic_istream uses virtual inheritance. */
3988 static inline basic_ios_char* basic_istream_char_get_basic_ios(basic_istream_char *this)
3989 {
3990     return (basic_ios_char*)((char*)this+this->vbtable[1]);
3991 }
3992
3993 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
3994 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
3995 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_init, 20)
3996 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)
3997 {
3998     basic_ios_char *base;
3999
4000     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
4001
4002     if(virt_init) {
4003         this->vbtable = basic_istream_char_vbtable;
4004         base = basic_istream_char_get_basic_ios(this);
4005         basic_ios_char_ctor(base);
4006     }else {
4007         base = basic_istream_char_get_basic_ios(this);
4008     }
4009
4010     base->base.vtable = &MSVCP_basic_istream_char_vtable;
4011     this->count = 0;
4012     if(!noinit)
4013         basic_ios_char_init(base, strbuf, isstd);
4014     return this;
4015 }
4016
4017 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
4018 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
4019 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor, 16)
4020 basic_istream_char* __thiscall basic_istream_char_ctor(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
4021 {
4022     return basic_istream_char_ctor_init(this, strbuf, isstd, FALSE, virt_init);
4023 }
4024
4025 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
4026 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
4027 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_uninitialized, 12)
4028 basic_istream_char* __thiscall basic_istream_char_ctor_uninitialized(basic_istream_char *this, int uninitialized, MSVCP_bool virt_init)
4029 {
4030     basic_ios_char *base;
4031
4032     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
4033
4034     if(virt_init) {
4035         this->vbtable = basic_istream_char_vbtable;
4036         base = basic_istream_char_get_basic_ios(this);
4037         basic_ios_char_ctor(base);
4038     }else {
4039         base = basic_istream_char_get_basic_ios(this);
4040     }
4041
4042     base->base.vtable = &MSVCP_basic_istream_char_vtable;
4043     ios_base_Addstd(&base->base);
4044     return this;
4045 }
4046
4047 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UAE@XZ */
4048 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
4049 DEFINE_THISCALL_WRAPPER(basic_istream_char_dtor, 4)
4050 void __thiscall basic_istream_char_dtor(basic_istream_char *this)
4051 {
4052     /* don't destroy virtual base here */
4053     TRACE("(%p)\n", this);
4054 }
4055
4056 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
4057 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
4058 DEFINE_THISCALL_WRAPPER(basic_istream_char_vbase_dtor, 4)
4059 void __thiscall basic_istream_char_vbase_dtor(basic_istream_char *this)
4060 {
4061     TRACE("(%p)\n", this);
4062     basic_istream_char_dtor(this);
4063     basic_ios_char_dtor(basic_istream_char_get_basic_ios(this));
4064 }
4065
4066 DEFINE_THISCALL_WRAPPER(MSVCP_basic_istream_char_vector_dtor, 8)
4067 basic_istream_char* __thiscall MSVCP_basic_istream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
4068 {
4069     basic_istream_char *this = (basic_istream_char *)((char*)base - basic_istream_char_vbtable[1] + basic_istream_char_vbtable[0]);
4070
4071     TRACE("(%p %x)\n", this, flags);
4072
4073     if(flags & 2) {
4074         /* we have an array, with the number of elements stored before the first object */
4075         int i, *ptr = (int *)this-1;
4076
4077         for(i=*ptr-1; i>=0; i--)
4078             basic_istream_char_vbase_dtor(this+i);
4079         MSVCRT_operator_delete(ptr);
4080     } else {
4081         basic_istream_char_vbase_dtor(this);
4082         if(flags & 1)
4083             MSVCRT_operator_delete(this);
4084     }
4085
4086     return this;
4087 }
4088
4089 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
4090 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
4091 DEFINE_THISCALL_WRAPPER(basic_istream_char__Ipfx, 8)
4092 MSVCP_bool __thiscall basic_istream_char__Ipfx(basic_istream_char *this, MSVCP_bool noskip)
4093 {
4094     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4095
4096     TRACE("(%p %d)\n", this, noskip);
4097
4098     if(!ios_base_good(&base->base)) {
4099         basic_ios_char_setstate(base, IOSTATE_failbit);
4100         return FALSE;
4101     }
4102
4103     if(basic_ios_char_tie_get(base))
4104         basic_ostream_char_flush(basic_ios_char_tie_get(base));
4105
4106     if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
4107         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4108         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
4109         int ch;
4110
4111         for(ch = basic_streambuf_char_sgetc(strbuf); ;
4112                 ch = basic_streambuf_char_snextc(strbuf)) {
4113             if(ch == EOF) {
4114                 basic_ios_char_setstate(base, IOSTATE_eofbit);
4115                 return FALSE;
4116             }
4117
4118             if(!ctype_char_is_ch(ctype, _SPACE|_BLANK, ch))
4119                 break;
4120         }
4121     }
4122
4123     return TRUE;
4124 }
4125
4126 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
4127 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
4128 DEFINE_THISCALL_WRAPPER(basic_istream_char_ipfx, 8)
4129 MSVCP_bool __thiscall basic_istream_char_ipfx(basic_istream_char *this, MSVCP_bool noskip)
4130 {
4131     return basic_istream_char__Ipfx(this, noskip);
4132 }
4133
4134 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
4135 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
4136 DEFINE_THISCALL_WRAPPER(basic_istream_char_isfx, 4)
4137 void __thiscall basic_istream_char_isfx(basic_istream_char *this)
4138 {
4139     TRACE("(%p)\n", this);
4140 }
4141
4142 static BOOL basic_istream_char_sentry_create(basic_istream_char *istr, MSVCP_bool noskip)
4143 {
4144     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
4145
4146     if(basic_ios_char_rdbuf_get(base))
4147         basic_streambuf_char__Lock(base->strbuf);
4148
4149     return basic_istream_char_ipfx(istr, noskip);
4150 }
4151
4152 static void basic_istream_char_sentry_destroy(basic_istream_char *istr)
4153 {
4154     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
4155
4156     if(basic_ios_char_rdbuf_get(base))
4157         basic_streambuf_char__Unlock(base->strbuf);
4158 }
4159
4160 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QBEHXZ */
4161 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QEBA_JXZ */
4162 DEFINE_THISCALL_WRAPPER(basic_istream_char_gcount, 4)
4163 int __thiscall basic_istream_char_gcount(const basic_istream_char *this)
4164 {
4165     TRACE("(%p)\n", this);
4166     return this->count;
4167 }
4168
4169 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
4170 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
4171 DEFINE_THISCALL_WRAPPER(basic_istream_char_get, 4)
4172 int __thiscall basic_istream_char_get(basic_istream_char *this)
4173 {
4174     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4175     int ret;
4176
4177     TRACE("(%p)\n", this);
4178
4179     this->count = 0;
4180
4181     if(!basic_istream_char_sentry_create(this, TRUE)) {
4182         basic_istream_char_sentry_destroy(this);
4183         return EOF;
4184     }
4185
4186     ret = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(base));
4187     basic_istream_char_sentry_destroy(this);
4188     if(ret == EOF)
4189         basic_ios_char_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
4190     else
4191         this->count++;
4192
4193     return ret;
4194 }
4195
4196 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAD@Z */
4197 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAD@Z */
4198 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_ch, 8)
4199 basic_istream_char* __thiscall basic_istream_char_get_ch(basic_istream_char *this, char *ch)
4200 {
4201     int ret;
4202
4203     TRACE("(%p %p)\n", this, ch);
4204
4205     ret = basic_istream_char_get(this);
4206     if(ret != EOF)
4207         *ch = (char)ret;
4208     return this;
4209 }
4210
4211 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
4212 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
4213 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str_delim, 16)
4214 basic_istream_char* __thiscall basic_istream_char_get_str_delim(basic_istream_char *this, char *str, streamsize count, char delim)
4215 {
4216     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4217     int ch = delim;
4218
4219     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
4220
4221     this->count = 0;
4222
4223     if(basic_istream_char_sentry_create(this, TRUE)) {
4224         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4225
4226         for(ch = basic_streambuf_char_sgetc(strbuf); count>1;
4227                 ch = basic_streambuf_char_snextc(strbuf)) {
4228             if(ch==EOF || ch==delim)
4229                 break;
4230
4231             *str++ = ch;
4232             this->count++;
4233             count--;
4234         }
4235     }
4236     basic_istream_char_sentry_destroy(this);
4237
4238     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
4239             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
4240     if(count > 0)
4241         *str = 0;
4242     return this;
4243 }
4244
4245 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
4246 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
4247 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str, 12)
4248 basic_istream_char* __thiscall basic_istream_char_get_str(basic_istream_char *this, char *str, streamsize count)
4249 {
4250     return basic_istream_char_get_str_delim(this, str, count, '\n');
4251 }
4252
4253 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
4254 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
4255 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf_delim, 12)
4256 basic_istream_char* __thiscall basic_istream_char_get_streambuf_delim(basic_istream_char *this, basic_streambuf_char *strbuf, char delim)
4257 {
4258     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4259     int ch = delim;
4260
4261     TRACE("(%p %p %c)\n", this, strbuf, delim);
4262
4263     this->count = 0;
4264
4265     if(basic_istream_char_sentry_create(this, TRUE)) {
4266         basic_streambuf_char *strbuf_read = basic_ios_char_rdbuf_get(base);
4267
4268         for(ch = basic_streambuf_char_sgetc(strbuf_read); ;
4269                 ch = basic_streambuf_char_snextc(strbuf_read)) {
4270             if(ch==EOF || ch==delim)
4271                 break;
4272
4273             if(basic_streambuf_char_sputc(strbuf, ch) == EOF)
4274                 break;
4275             this->count++;
4276         }
4277     }
4278     basic_istream_char_sentry_destroy(this);
4279
4280     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
4281             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
4282     return this;
4283 }
4284
4285 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
4286 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
4287 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf, 8)
4288 basic_istream_char* __thiscall basic_istream_char_get_streambuf(basic_istream_char *this, basic_streambuf_char *strbuf)
4289 {
4290     return basic_istream_char_get_streambuf_delim(this, strbuf, '\n');
4291 }
4292
4293 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
4294 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
4295 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline_delim, 16)
4296 basic_istream_char* __thiscall basic_istream_char_getline_delim(basic_istream_char *this, char *str, streamsize count, char delim)
4297 {
4298     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4299     int ch = delim;
4300
4301     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
4302
4303     this->count = 0;
4304
4305     if(basic_istream_char_sentry_create(this, TRUE) && count>0) {
4306         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4307
4308         while(count > 1) {
4309             ch = basic_streambuf_char_sbumpc(strbuf);
4310
4311             if(ch==EOF || ch==delim)
4312                 break;
4313
4314             *str++ = ch;
4315             this->count++;
4316             count--;
4317         }
4318
4319         if(ch == delim)
4320             this->count++;
4321         else if(ch != EOF) {
4322             ch = basic_streambuf_char_sgetc(strbuf);
4323
4324             if(ch == delim) {
4325                 basic_streambuf_char__Gninc(strbuf);
4326                 this->count++;
4327             }
4328         }
4329     }
4330     basic_istream_char_sentry_destroy(this);
4331
4332     basic_ios_char_setstate(base, (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
4333             (!this->count || (ch!=delim && ch!=EOF) ? IOSTATE_failbit : IOSTATE_goodbit));
4334     if(count > 0)
4335         *str = 0;
4336     return this;
4337 }
4338
4339 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
4340 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
4341 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline, 12)
4342 basic_istream_char* __thiscall basic_istream_char_getline(basic_istream_char *this, char *str, streamsize count)
4343 {
4344     return basic_istream_char_getline_delim(this, str, count, '\n');
4345 }
4346
4347 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z */
4348 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
4349 DEFINE_THISCALL_WRAPPER(basic_istream_char_ignore, 12)
4350 basic_istream_char* __thiscall basic_istream_char_ignore(basic_istream_char *this, streamsize count, int delim)
4351 {
4352     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4353     int ch = delim;
4354
4355     TRACE("(%p %ld %d)\n", this, count, delim);
4356
4357     this->count = 0;
4358
4359     if(basic_istream_char_sentry_create(this, TRUE)) {
4360         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4361
4362         while(count > 0) {
4363             ch = basic_streambuf_char_sbumpc(strbuf);
4364
4365             if(ch==EOF || ch==delim)
4366                 break;
4367
4368             this->count++;
4369             if(count != INT_MAX)
4370                 count--;
4371         }
4372     }
4373     basic_istream_char_sentry_destroy(this);
4374
4375     if(ch == EOF)
4376         basic_ios_char_setstate(base, IOSTATE_eofbit);
4377     return this;
4378 }
4379
4380 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
4381 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
4382 DEFINE_THISCALL_WRAPPER(basic_istream_char_peek, 4)
4383 int __thiscall basic_istream_char_peek(basic_istream_char *this)
4384 {
4385     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4386     int ret = EOF;
4387
4388     TRACE("(%p)\n", this);
4389
4390     this->count = 0;
4391
4392     if(basic_istream_char_sentry_create(this, TRUE))
4393         ret = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
4394     basic_istream_char_sentry_destroy(this);
4395     return ret;
4396 }
4397
4398 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADIH@Z */
4399 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_K_J@Z */
4400 DEFINE_THISCALL_WRAPPER(basic_istream_char__Read_s, 16)
4401 basic_istream_char* __thiscall basic_istream_char__Read_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
4402 {
4403     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4404     IOSB_iostate state = IOSTATE_goodbit;
4405
4406     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
4407
4408     if(basic_istream_char_sentry_create(this, TRUE)) {
4409         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4410
4411         this->count = basic_streambuf_char__Sgetn_s(strbuf, str, size, count);
4412         if(this->count != count)
4413             state |= IOSTATE_failbit | IOSTATE_eofbit;
4414     }else {
4415         this->count = 0;
4416     }
4417     basic_istream_char_sentry_destroy(this);
4418
4419     basic_ios_char_setstate(base, state);
4420     return this;
4421 }
4422
4423 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
4424 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
4425 DEFINE_THISCALL_WRAPPER(basic_istream_char_read, 12)
4426 basic_istream_char* __thiscall basic_istream_char_read(basic_istream_char *this, char *str, streamsize count)
4427 {
4428     return basic_istream_char__Read_s(this, str, count, count);
4429 }
4430
4431 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
4432 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
4433 DEFINE_THISCALL_WRAPPER(basic_istream_char__Readsome_s, 16)
4434 streamsize __thiscall basic_istream_char__Readsome_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
4435 {
4436     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4437     IOSB_iostate state = IOSTATE_goodbit;
4438
4439     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
4440
4441     this->count = 0;
4442
4443     if(basic_istream_char_sentry_create(this, TRUE)) {
4444         streamsize avail = basic_streambuf_char_in_avail(basic_ios_char_rdbuf_get(base));
4445         if(avail > count)
4446             avail = count;
4447
4448         if(avail == -1)
4449             state |= IOSTATE_eofbit;
4450         else if(avail > 0)
4451             basic_istream_char__Read_s(this, str, size, avail);
4452     }else {
4453         state |= IOSTATE_failbit;
4454     }
4455     basic_istream_char_sentry_destroy(this);
4456
4457     basic_ios_char_setstate(base, state);
4458     return this->count;
4459 }
4460
4461 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
4462 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
4463 DEFINE_THISCALL_WRAPPER(basic_istream_char_readsome, 12)
4464 streamsize __thiscall basic_istream_char_readsome(basic_istream_char *this, char *str, streamsize count)
4465 {
4466     return basic_istream_char__Readsome_s(this, str, count, count);
4467 }
4468
4469 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
4470 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
4471 DEFINE_THISCALL_WRAPPER(basic_istream_char_putback, 8)
4472 basic_istream_char* __thiscall basic_istream_char_putback(basic_istream_char *this, char ch)
4473 {
4474     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4475     IOSB_iostate state = IOSTATE_goodbit;
4476
4477     TRACE("(%p %c)\n", this, ch);
4478
4479     this->count = 0;
4480
4481     if(basic_istream_char_sentry_create(this, TRUE)) {
4482         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4483
4484         if(!ios_base_good(&base->base))
4485             state |= IOSTATE_failbit;
4486         else if(!strbuf || basic_streambuf_char_sputbackc(strbuf, ch)==EOF)
4487             state |= IOSTATE_badbit;
4488     }
4489     basic_istream_char_sentry_destroy(this);
4490
4491     basic_ios_char_setstate(base, state);
4492     return this;
4493 }
4494
4495 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
4496 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
4497 DEFINE_THISCALL_WRAPPER(basic_istream_char_unget, 4)
4498 basic_istream_char* __thiscall basic_istream_char_unget(basic_istream_char *this)
4499 {
4500     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4501     IOSB_iostate state = IOSTATE_goodbit;
4502
4503     TRACE("(%p)\n", this);
4504
4505     this->count = 0;
4506
4507     if(basic_istream_char_sentry_create(this, TRUE)) {
4508         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4509
4510         if(!ios_base_good(&base->base))
4511             state |= IOSTATE_failbit;
4512         else if(!strbuf || basic_streambuf_char_sungetc(strbuf)==EOF)
4513             state |= IOSTATE_badbit;
4514     }
4515     basic_istream_char_sentry_destroy(this);
4516
4517     basic_ios_char_setstate(base, state);
4518     return this;
4519 }
4520
4521 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
4522 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
4523 DEFINE_THISCALL_WRAPPER(basic_istream_char_sync, 4)
4524 int __thiscall basic_istream_char_sync(basic_istream_char *this)
4525 {
4526     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4527     basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4528
4529     TRACE("(%p)\n", this);
4530
4531     if(!strbuf)
4532         return -1;
4533
4534     if(basic_istream_char_sentry_create(this, TRUE)) {
4535         if(basic_streambuf_char_pubsync(strbuf) != -1) {
4536             basic_istream_char_sentry_destroy(this);
4537             return 0;
4538         }
4539     }
4540     basic_istream_char_sentry_destroy(this);
4541
4542     basic_ios_char_setstate(base, IOSTATE_badbit);
4543     return -1;
4544 }
4545
4546 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
4547 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
4548 DEFINE_THISCALL_WRAPPER(basic_istream_char_tellg, 8)
4549 fpos_int* __thiscall basic_istream_char_tellg(basic_istream_char *this, fpos_int *ret)
4550 {
4551     TRACE("(%p %p)\n", this, ret);
4552
4553     if(basic_istream_char_sentry_create(this, TRUE)) {
4554         basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4555         if(!ios_base_fail(&base->base)) {
4556             basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
4557                     ret, 0, SEEKDIR_cur, OPENMODE_in);
4558             basic_istream_char_sentry_destroy(this);
4559
4560             if(ret->off==0 && ret->pos==-1 && ret->state==0)
4561                 basic_ios_char_setstate(base, IOSTATE_failbit);
4562             return ret;
4563         }
4564     }
4565     basic_istream_char_sentry_destroy(this);
4566
4567     ret->off = 0;
4568     ret->pos = -1;
4569     ret->state = 0;
4570     return ret;
4571 }
4572
4573 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
4574 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
4575 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg, 12)
4576 basic_istream_char* __thiscall basic_istream_char_seekg(basic_istream_char *this, streamoff off, int dir)
4577 {
4578     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4579
4580     TRACE("(%p %ld %d)\n", this, off, dir);
4581
4582     if(basic_istream_char_sentry_create(this, TRUE)) {
4583         if(!ios_base_fail(&base->base)) {
4584             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4585             fpos_int ret;
4586
4587             basic_streambuf_char_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
4588             basic_istream_char_sentry_destroy(this);
4589
4590             if(ret.off==0 && ret.pos==-1 && ret.state==0)
4591                 basic_ios_char_setstate(base, IOSTATE_failbit);
4592             else
4593                 basic_ios_char_clear(base, IOSTATE_goodbit);
4594             return this;
4595         }
4596     }
4597     basic_istream_char_sentry_destroy(this);
4598
4599     basic_ios_char_setstate(base, IOSTATE_failbit);
4600     return this;
4601 }
4602
4603 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
4604 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
4605 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg_fpos, 28)
4606 basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char *this, fpos_int pos)
4607 {
4608     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
4609
4610     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
4611
4612     if(basic_istream_char_sentry_create(this, TRUE)) {
4613         if(!ios_base_fail(&base->base)) {
4614             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4615             fpos_int ret;
4616
4617             basic_streambuf_char_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
4618             basic_istream_char_sentry_destroy(this);
4619
4620             if(ret.off==0 && ret.pos==-1 && ret.state==0)
4621                 basic_ios_char_setstate(base, IOSTATE_failbit);
4622             else
4623                 basic_ios_char_clear(base, IOSTATE_goodbit);
4624             return this;
4625         }
4626     }
4627     basic_istream_char_sentry_destroy(this);
4628
4629     basic_ios_char_setstate(base, IOSTATE_failbit);
4630     return this;
4631 }
4632
4633 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAF@Z */
4634 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAF@Z */
4635 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_short, 8)
4636 basic_istream_char* __thiscall basic_istream_char_read_short(basic_istream_char *this, short *arg1)
4637 {
4638     FIXME("(%p %p) stub\n", this, arg1);
4639     return NULL;
4640 }
4641
4642 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAG@Z */
4643 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAG@Z */
4644 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ushort, 8)
4645 basic_istream_char* __thiscall basic_istream_char_read_ushort(basic_istream_char *this, unsigned short *arg1)
4646 {
4647     FIXME("(%p %p) stub\n", this, arg1);
4648     return NULL;
4649 }
4650
4651 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z */
4652 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAH@Z */
4653 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int, 8)
4654 basic_istream_char* __thiscall basic_istream_char_read_int(basic_istream_char *this, int *arg1)
4655 {
4656     FIXME("(%p %p) stub\n", this, arg1);
4657     return NULL;
4658 }
4659
4660 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAI@Z */
4661 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAI@Z */
4662 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint, 8)
4663 basic_istream_char* __thiscall basic_istream_char_read_uint(basic_istream_char *this, unsigned int *arg1)
4664 {
4665     FIXME("(%p %p) stub\n", this, arg1);
4666     return NULL;
4667 }
4668
4669 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAJ@Z */
4670 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAJ@Z */
4671 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_long, 8)
4672 basic_istream_char* __thiscall basic_istream_char_read_long(basic_istream_char *this, LONG *arg1)
4673 {
4674     FIXME("(%p %p) stub\n", this, arg1);
4675     return NULL;
4676 }
4677
4678 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAK@Z */
4679 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAK@Z */
4680 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ulong, 8)
4681 basic_istream_char* __thiscall basic_istream_char_read_ulong(basic_istream_char *this, ULONG *arg1)
4682 {
4683     FIXME("(%p %p) stub\n", this, arg1);
4684     return NULL;
4685 }
4686
4687 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z */
4688 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAM@Z */
4689 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_float, 8)
4690 basic_istream_char* __thiscall basic_istream_char_read_float(basic_istream_char *this, float *arg1)
4691 {
4692     FIXME("(%p %p) stub\n", this, arg1);
4693     return NULL;
4694 }
4695
4696 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z */
4697 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z */
4698 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_double, 8)
4699 basic_istream_char* __thiscall basic_istream_char_read_double(basic_istream_char *this, double *arg1)
4700 {
4701     FIXME("(%p %p) stub\n", this, arg1);
4702     return NULL;
4703 }
4704
4705 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAO@Z */
4706 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAO@Z */
4707 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ldouble, 8)
4708 basic_istream_char* __thiscall basic_istream_char_read_ldouble(basic_istream_char *this, long double *arg1)
4709 {
4710     FIXME("(%p %p) stub\n", this, arg1);
4711     return NULL;
4712 }
4713
4714 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAPAX@Z */
4715 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
4716 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ptr, 8)
4717 basic_istream_char* __thiscall basic_istream_char_read_ptr(basic_istream_char *this, void **arg1)
4718 {
4719     FIXME("(%p %p) stub\n", this, arg1);
4720     return NULL;
4721 }
4722
4723 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_J@Z */
4724 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_J@Z */
4725 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int64, 8)
4726 basic_istream_char* __thiscall basic_istream_char_read_int64(basic_istream_char *this, __int64 *arg1)
4727 {
4728     FIXME("(%p %p) stub\n", this, arg1);
4729     return NULL;
4730 }
4731
4732 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z */
4733 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z */
4734 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint64, 8)
4735 basic_istream_char* __thiscall basic_istream_char_read_uint64(basic_istream_char *this, unsigned __int64 *arg1)
4736 {
4737     FIXME("(%p %p) stub\n", this, arg1);
4738     return NULL;
4739 }
4740
4741 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_N@Z */
4742 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_N@Z */
4743 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_bool, 8)
4744 basic_istream_char* __thiscall basic_istream_char_read_bool(basic_istream_char *this, MSVCP_bool *arg1)
4745 {
4746     FIXME("(%p %p) stub\n", this, arg1);
4747     return NULL;
4748 }
4749
4750 /* ??$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 */
4751 /* ??$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 */
4752 basic_istream_char* __cdecl basic_istream_char_getline_bstr_delim(
4753         basic_istream_char *istream, basic_string_char *str, char delim)
4754 {
4755     IOSB_iostate state = IOSTATE_failbit;
4756     int c = delim;
4757
4758     TRACE("(%p %p %c)\n", istream, str, delim);
4759
4760     if(basic_istream_char_sentry_create(istream, TRUE)) {
4761         MSVCP_basic_string_char_clear(str);
4762
4763         for(c = basic_istream_char_get(istream); c!=delim && c!=EOF;
4764                 c = basic_istream_char_get(istream)) {
4765             state = IOSTATE_goodbit;
4766             MSVCP_basic_string_char_append_ch(str, c);
4767         }
4768     }
4769     basic_istream_char_sentry_destroy(istream);
4770
4771     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
4772         state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
4773     return istream;
4774 }
4775
4776 /* ??$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 */
4777 /* ??$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 */
4778 basic_istream_char* __cdecl basic_istream_char_getline_bstr(
4779         basic_istream_char *istream, basic_string_char *str)
4780 {
4781     return basic_istream_char_getline_bstr_delim(istream, str, '\n');
4782 }
4783
4784 /* ??$?5DU?$char_traits@D@std@@V?$allocator@D@1@@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 */
4785 /* ??$?5DU?$char_traits@D@std@@V?$allocator@D@1@@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 */
4786 basic_istream_char* __cdecl basic_istream_char_get_bstr(
4787         basic_istream_char *istream, basic_string_char *str)
4788 {
4789     IOSB_iostate state = IOSTATE_failbit;
4790     int c = '\n';
4791
4792     TRACE("(%p %p)\n", istream, str);
4793
4794     if(basic_istream_char_sentry_create(istream, FALSE)) {
4795         basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
4796         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
4797
4798         MSVCP_basic_string_char_clear(str);
4799
4800         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
4801                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c);
4802                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base))) {
4803             state = IOSTATE_goodbit;
4804             MSVCP_basic_string_char_append_ch(str, c);
4805         }
4806     }
4807     basic_istream_char_sentry_destroy(istream);
4808
4809     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
4810         state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
4811     return istream;
4812 }
4813
4814 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4815 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4816 DEFINE_THISCALL_WRAPPER(basic_iostream_char_ctor, 12)
4817 basic_iostream_char* __thiscall basic_iostream_char_ctor(basic_iostream_char *this, basic_streambuf_char *strbuf, MSVCP_bool virt_init)
4818 {
4819     basic_ios_char *basic_ios;
4820
4821     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
4822
4823     if(virt_init) {
4824         this->base1.vbtable = basic_iostream_char_vbtable1;
4825         this->base2.vbtable = basic_iostream_char_vbtable2;
4826         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
4827         basic_ios_char_ctor(basic_ios);
4828     }else {
4829         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
4830     }
4831
4832     basic_ios->base.vtable = &MSVCP_basic_iostream_char_vtable;
4833
4834     basic_istream_char_ctor(&this->base1, strbuf, FALSE, FALSE);
4835     basic_ostream_char_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
4836     return this;
4837 }
4838
4839 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
4840 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
4841 DEFINE_THISCALL_WRAPPER(basic_iostream_char_dtor, 4)
4842 void __thiscall basic_iostream_char_dtor(basic_iostream_char *this)
4843 {
4844     TRACE("(%p)\n", this);
4845     basic_ostream_char_dtor(&this->base2);
4846     basic_istream_char_dtor(&this->base1);
4847 }
4848
4849 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
4850 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
4851 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vbase_dtor, 4)
4852 void __thiscall basic_iostream_char_vbase_dtor(basic_iostream_char *this)
4853 {
4854     TRACE("(%p)\n", this);
4855     basic_iostream_char_dtor(this);
4856     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base1));
4857 }
4858
4859 DEFINE_THISCALL_WRAPPER(MSVCP_basic_iostream_char_vector_dtor, 8)
4860 basic_iostream_char* __thiscall MSVCP_basic_iostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
4861 {
4862     basic_iostream_char *this = (basic_iostream_char *)((char*)base - basic_iostream_char_vbtable1[1] + basic_iostream_char_vbtable1[0]);
4863
4864     TRACE("(%p %x)\n", this, flags);
4865
4866     if(flags & 2) {
4867         /* we have an array, with the number of elements stored before the first object */
4868         int i, *ptr = (int *)this-1;
4869
4870         for(i=*ptr-1; i>=0; i--)
4871             basic_iostream_char_vbase_dtor(this+i);
4872         MSVCRT_operator_delete(ptr);
4873     } else {
4874         basic_iostream_char_vbase_dtor(this);
4875         if(flags & 1)
4876             MSVCRT_operator_delete(this);
4877     }
4878
4879     return this;
4880 }
4881
4882 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
4883 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
4884 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor, 8)
4885 basic_ofstream_char* __thiscall basic_ofstream_char_ctor(basic_ofstream_char *this, MSVCP_bool virt_init)
4886 {
4887     basic_ios_char *basic_ios;
4888
4889     TRACE("(%p %d)\n", this, virt_init);
4890
4891     if(virt_init) {
4892         this->base.vbtable = basic_ofstream_char_vbtable;
4893         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
4894         basic_ios_char_ctor(basic_ios);
4895     }else {
4896         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
4897     }
4898
4899     basic_filebuf_char_ctor(&this->filebuf);
4900     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
4901     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
4902     return this;
4903 }
4904
4905 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
4906 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
4907 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_file, 12)
4908 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_file(
4909         basic_ofstream_char *this, FILE *file, MSVCP_bool virt_init)
4910 {
4911     basic_ios_char *basic_ios;
4912
4913     TRACE("(%p %p %d)\n", this, file, virt_init);
4914
4915     if(virt_init) {
4916         this->base.vbtable = basic_ofstream_char_vbtable;
4917         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
4918         basic_ios_char_ctor(basic_ios);
4919     }else {
4920         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
4921     }
4922
4923     basic_filebuf_char_ctor_file(&this->filebuf, file);
4924     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
4925     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
4926     return this;
4927 }
4928
4929 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
4930 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
4931 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_name, 20)
4932 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_name(basic_ofstream_char *this,
4933         const char *name, int mode, int prot, MSVCP_bool virt_init)
4934 {
4935     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
4936
4937     basic_ofstream_char_ctor(this, virt_init);
4938
4939     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
4940         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
4941         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
4942     }
4943     return this;
4944 }
4945
4946 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PBGHH@Z */
4947 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEBGHH@Z */
4948 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PB_WHH@Z */
4949 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEB_WHH@Z */
4950 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_name_wchar, 20)
4951 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_name_wchar(basic_ofstream_char *this,
4952         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
4953 {
4954     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
4955
4956     basic_ofstream_char_ctor(this, virt_init);
4957
4958     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
4959         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
4960         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
4961     }
4962     return this;
4963 }
4964
4965 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
4966 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
4967 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_dtor, 4)
4968 void __thiscall basic_ofstream_char_dtor(basic_ofstream_char *this)
4969 {
4970     TRACE("(%p)\n", this);
4971
4972     basic_ostream_char_dtor(&this->base);
4973     basic_filebuf_char_dtor(&this->filebuf);
4974 }
4975
4976 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
4977 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
4978 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vbase_dtor, 4)
4979 void __thiscall basic_ofstream_char_vbase_dtor(basic_ofstream_char *this)
4980 {
4981     TRACE("(%p)\n", this);
4982
4983     basic_ofstream_char_dtor(this);
4984     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
4985 }
4986
4987 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ofstream_char_vector_dtor, 8)
4988 basic_ofstream_char* __thiscall MSVCP_basic_ofstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
4989 {
4990     basic_ofstream_char *this = (basic_ofstream_char *)((char*)base - basic_ofstream_char_vbtable[1] + basic_ofstream_char_vbtable[0]);
4991
4992     TRACE("(%p %x)\n", this, flags);
4993
4994     if(flags & 2) {
4995         /* we have an array, with the number of elements stored before the first object */
4996         int i, *ptr = (int *)this-1;
4997
4998         for(i=*ptr-1; i>=0; i--)
4999             basic_ofstream_char_vbase_dtor(this+i);
5000         MSVCRT_operator_delete(ptr);
5001     } else {
5002         basic_ofstream_char_vbase_dtor(this);
5003         if(flags & 1)
5004             MSVCRT_operator_delete(this);
5005     }
5006
5007     return this;
5008 }
5009
5010 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5011 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5012 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_close, 4)
5013 void __thiscall basic_ofstream_char_close(basic_ofstream_char *this)
5014 {
5015     TRACE("(%p)\n", this);
5016
5017     if(!basic_filebuf_char_close(&this->filebuf)) {
5018         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
5019         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5020     }
5021 }
5022
5023 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
5024 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
5025 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_is_open, 4)
5026 MSVCP_bool __thiscall basic_ofstream_char_is_open(const basic_ofstream_char *this)
5027 {
5028     TRACE("(%p)\n", this);
5029     return basic_filebuf_char_is_open(&this->filebuf);
5030 }
5031
5032 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
5033 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
5034 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open, 16)
5035 void __thiscall basic_ofstream_char_open(basic_ofstream_char *this,
5036         const char *name, int mode, int prot)
5037 {
5038     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
5039
5040     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
5041         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
5042         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5043     }
5044 }
5045
5046 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
5047 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
5048 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_old, 12)
5049 void __thiscall basic_ofstream_char_open_old(basic_ofstream_char *this,
5050         const char *name, unsigned int mode)
5051 {
5052     basic_ofstream_char_open(this, name, mode, _SH_DENYNO);
5053 }
5054
5055 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBGHH@Z */
5056 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGHH@Z */
5057 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPB_WHH@Z */
5058 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WHH@Z */
5059 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_wchar, 16)
5060 void __thiscall basic_ofstream_char_open_wchar(basic_ofstream_char *this,
5061         const wchar_t *name, int mode, int prot)
5062 {
5063     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
5064
5065     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
5066         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
5067         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5068     }
5069 }
5070
5071 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBGI@Z */
5072 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGI@Z */
5073 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPB_WI@Z */
5074 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WI@Z */
5075 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_wchar_old, 12)
5076 void __thiscall basic_ofstream_char_open_wchar_old(basic_ofstream_char *this,
5077         const wchar_t *name, unsigned int mode)
5078 {
5079     basic_ofstream_char_open_wchar(this, name, mode, _SH_DENYNO);
5080 }
5081
5082 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
5083 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
5084 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_rdbuf, 4)
5085 basic_filebuf_char* __thiscall basic_ofstream_char_rdbuf(const basic_ofstream_char *this)
5086 {
5087     TRACE("(%p)\n", this);
5088     return (basic_filebuf_char*)&this->filebuf;
5089 }
5090
5091 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
5092 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
5093 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor, 8)
5094 basic_ifstream_char* __thiscall basic_ifstream_char_ctor(basic_ifstream_char *this, MSVCP_bool virt_init)
5095 {
5096     basic_ios_char *basic_ios;
5097
5098     TRACE("(%p %d)\n", this, virt_init);
5099
5100     if(virt_init) {
5101         this->base.vbtable = basic_ifstream_char_vbtable;
5102         basic_ios = basic_istream_char_get_basic_ios(&this->base);
5103         basic_ios_char_ctor(basic_ios);
5104     }else {
5105         basic_ios = basic_istream_char_get_basic_ios(&this->base);
5106     }
5107
5108     basic_filebuf_char_ctor(&this->filebuf);
5109     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
5110     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
5111     return this;
5112 }
5113
5114 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
5115 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
5116 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_file, 12)
5117 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_file(
5118         basic_ifstream_char *this, FILE *file, MSVCP_bool virt_init)
5119 {
5120     basic_ios_char *basic_ios;
5121
5122     TRACE("(%p %p %d)\n", this, file, virt_init);
5123
5124     if(virt_init) {
5125         this->base.vbtable = basic_ifstream_char_vbtable;
5126         basic_ios = basic_istream_char_get_basic_ios(&this->base);
5127         basic_ios_char_ctor(basic_ios);
5128     }else {
5129         basic_ios = basic_istream_char_get_basic_ios(&this->base);
5130     }
5131
5132     basic_filebuf_char_ctor_file(&this->filebuf, file);
5133     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
5134     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
5135     return this;
5136 }
5137
5138 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
5139 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
5140 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_name, 20)
5141 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_name(basic_ifstream_char *this,
5142         const char *name, int mode, int prot, MSVCP_bool virt_init)
5143 {
5144     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
5145
5146     basic_ifstream_char_ctor(this, virt_init);
5147
5148     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
5149         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
5150         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5151     }
5152     return this;
5153 }
5154
5155 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBGHH@Z */
5156 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEBGHH@Z */
5157 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PB_WHH@Z */
5158 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEB_WHH@Z */
5159 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_name_wchar, 20)
5160 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_name_wchar(basic_ifstream_char *this,
5161         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
5162 {
5163     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
5164
5165     basic_ifstream_char_ctor(this, virt_init);
5166
5167     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
5168         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
5169         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5170     }
5171     return this;
5172 }
5173
5174 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
5175 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
5176 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_dtor, 4)
5177 void __thiscall basic_ifstream_char_dtor(basic_ifstream_char *this)
5178 {
5179     TRACE("(%p)\n", this);
5180
5181     basic_istream_char_dtor(&this->base);
5182     basic_filebuf_char_dtor(&this->filebuf);
5183 }
5184
5185 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5186 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5187 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vbase_dtor, 4)
5188 void __thiscall basic_ifstream_char_vbase_dtor(basic_ifstream_char *this)
5189 {
5190     TRACE("(%p)\n", this);
5191
5192     basic_ifstream_char_dtor(this);
5193     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
5194 }
5195
5196 DEFINE_THISCALL_WRAPPER(MSVCP_basic_ifstream_char_vector_dtor, 8)
5197 basic_ifstream_char* __thiscall MSVCP_basic_ifstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
5198 {
5199     basic_ifstream_char *this = (basic_ifstream_char *)((char*)base - basic_ifstream_char_vbtable[1] + basic_ifstream_char_vbtable[0]);
5200
5201     TRACE("(%p %x)\n", this, flags);
5202
5203     if(flags & 2) {
5204         /* we have an array, with the number of elements stored before the first object */
5205         int i, *ptr = (int *)this-1;
5206
5207         for(i=*ptr-1; i>=0; i--)
5208             basic_ifstream_char_vbase_dtor(this+i);
5209         MSVCRT_operator_delete(ptr);
5210     } else {
5211         basic_ifstream_char_vbase_dtor(this);
5212         if(flags & 1)
5213             MSVCRT_operator_delete(this);
5214     }
5215
5216     return this;
5217 }
5218
5219 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5220 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5221 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_close, 4)
5222 void __thiscall basic_ifstream_char_close(basic_ifstream_char *this)
5223 {
5224     TRACE("(%p)\n", this);
5225
5226     if(!basic_filebuf_char_close(&this->filebuf)) {
5227         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
5228         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5229     }
5230 }
5231
5232 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
5233 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
5234 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_is_open, 4)
5235 MSVCP_bool __thiscall basic_ifstream_char_is_open(const basic_ifstream_char *this)
5236 {
5237     TRACE("(%p)\n", this);
5238     return basic_filebuf_char_is_open(&this->filebuf);
5239 }
5240
5241 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
5242 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
5243 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open, 16)
5244 void __thiscall basic_ifstream_char_open(basic_ifstream_char *this,
5245         const char *name, int mode, int prot)
5246 {
5247     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
5248
5249     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
5250         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
5251         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5252     }
5253 }
5254
5255 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
5256 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
5257 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_old, 12)
5258 void __thiscall basic_ifstream_char_open_old(basic_ifstream_char *this,
5259         const char *name, unsigned int mode)
5260 {
5261     basic_ifstream_char_open(this, name, mode, _SH_DENYNO);
5262 }
5263
5264 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBGHH@Z */
5265 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGHH@Z */
5266 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPB_WHH@Z */
5267 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WHH@Z */
5268 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_wchar, 16)
5269 void __thiscall basic_ifstream_char_open_wchar(basic_ifstream_char *this,
5270         const wchar_t *name, int mode, int prot)
5271 {
5272     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
5273
5274     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
5275         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
5276         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5277     }
5278 }
5279
5280 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBGI@Z */
5281 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGI@Z */
5282 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPB_WI@Z */
5283 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WI@Z */
5284 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_wchar_old, 12)
5285 void __thiscall basic_ifstream_char_open_wchar_old(basic_ifstream_char *this,
5286         const wchar_t *name, unsigned int mode)
5287 {
5288     basic_ifstream_char_open_wchar(this, name, mode, _SH_DENYNO);
5289 }
5290
5291 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
5292 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
5293 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_rdbuf, 4)
5294 basic_filebuf_char* __thiscall basic_ifstream_char_rdbuf(const basic_ifstream_char *this)
5295 {
5296     TRACE("(%p)\n", this);
5297     return (basic_filebuf_char*)&this->filebuf;
5298 }
5299
5300 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
5301 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
5302 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor, 8)
5303 basic_fstream_char* __thiscall basic_fstream_char_ctor(basic_fstream_char *this, MSVCP_bool virt_init)
5304 {
5305     basic_ios_char *basic_ios;
5306
5307     TRACE("(%p %d)\n", this, virt_init);
5308
5309     if(virt_init) {
5310         this->base.base1.vbtable = basic_fstream_char_vbtable1;
5311         this->base.base2.vbtable = basic_fstream_char_vbtable2;
5312         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5313         basic_ios_char_ctor(basic_ios);
5314     }else {
5315         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5316     }
5317
5318     basic_filebuf_char_ctor(&this->filebuf);
5319     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
5320     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
5321     return this;
5322 }
5323
5324 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
5325 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
5326 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_file, 12)
5327 basic_fstream_char* __thiscall basic_fstream_char_ctor_file(basic_fstream_char *this,
5328         FILE *file, MSVCP_bool virt_init)
5329 {
5330     basic_ios_char *basic_ios;
5331
5332     TRACE("(%p %p %d)\n", this, file, virt_init);
5333
5334     if(virt_init) {
5335         this->base.base1.vbtable = basic_fstream_char_vbtable1;
5336         this->base.base2.vbtable = basic_fstream_char_vbtable2;
5337         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5338         basic_ios_char_ctor(basic_ios);
5339     }else {
5340         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5341     }
5342
5343     basic_filebuf_char_ctor_file(&this->filebuf, file);
5344     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
5345     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
5346     return this;
5347 }
5348
5349 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
5350 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
5351 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_name, 20)
5352 basic_fstream_char* __thiscall basic_fstream_char_ctor_name(basic_fstream_char *this,
5353         const char *name, int mode, int prot, MSVCP_bool virt_init)
5354 {
5355     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
5356
5357     basic_fstream_char_ctor(this, virt_init);
5358
5359     if(!basic_filebuf_char_open(&this->filebuf, name, mode, prot)) {
5360         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5361         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5362     }
5363     return this;
5364 }
5365
5366 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBGHH@Z */
5367 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBGHH@Z */
5368 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PB_WHH@Z */
5369 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEB_WHH@Z */
5370 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_name_wchar, 20)
5371 basic_fstream_char* __thiscall basic_fstream_char_ctor_name_wchar(basic_fstream_char *this,
5372         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
5373 {
5374     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
5375
5376     basic_fstream_char_ctor(this, virt_init);
5377
5378     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode, prot)) {
5379         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5380         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5381     }
5382     return this;
5383 }
5384
5385 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
5386 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
5387 DEFINE_THISCALL_WRAPPER(basic_fstream_char_dtor, 4)
5388 void __thiscall basic_fstream_char_dtor(basic_fstream_char *this)
5389 {
5390     TRACE("(%p)\n", this);
5391
5392     basic_iostream_char_dtor(&this->base);
5393     basic_filebuf_char_dtor(&this->filebuf);
5394 }
5395
5396 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5397 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5398 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vbase_dtor, 4)
5399 void __thiscall basic_fstream_char_vbase_dtor(basic_fstream_char *this)
5400 {
5401     TRACE("(%p)\n", this);
5402
5403     basic_fstream_char_dtor(this);
5404     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
5405 }
5406
5407 DEFINE_THISCALL_WRAPPER(MSVCP_basic_fstream_char_vector_dtor, 8)
5408 basic_fstream_char* __thiscall MSVCP_basic_fstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
5409 {
5410     basic_fstream_char *this = (basic_fstream_char *)((char*)base - basic_fstream_char_vbtable1[1] + basic_fstream_char_vbtable1[0]);
5411
5412     TRACE("(%p %x)\n", this, flags);
5413
5414     if(flags & 2) {
5415         /* we have an array, with the number of elements stored before the first object */
5416         int i, *ptr = (int *)this-1;
5417
5418         for(i=*ptr-1; i>=0; i--)
5419             basic_fstream_char_vbase_dtor(this+i);
5420         MSVCRT_operator_delete(ptr);
5421     } else {
5422         basic_fstream_char_vbase_dtor(this);
5423         if(flags & 1)
5424             MSVCRT_operator_delete(this);
5425     }
5426
5427     return this;
5428 }
5429
5430 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5431 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5432 DEFINE_THISCALL_WRAPPER(basic_fstream_char_close, 4)
5433 void __thiscall basic_fstream_char_close(basic_fstream_char *this)
5434 {
5435     TRACE("(%p)\n", this);
5436
5437     if(!basic_filebuf_char_close(&this->filebuf)) {
5438         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5439         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5440     }
5441 }
5442
5443 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
5444 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
5445 DEFINE_THISCALL_WRAPPER(basic_fstream_char_is_open, 4)
5446 MSVCP_bool __thiscall basic_fstream_char_is_open(const basic_fstream_char *this)
5447 {
5448     TRACE("(%p)\n", this);
5449     return basic_filebuf_char_is_open(&this->filebuf);
5450 }
5451
5452 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
5453 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
5454 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open, 16)
5455 void __thiscall basic_fstream_char_open(basic_fstream_char *this,
5456         const char *name, int mode, int prot)
5457 {
5458     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
5459
5460     if(!basic_filebuf_char_open(&this->filebuf, name, mode, prot)) {
5461         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5462         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5463     }
5464 }
5465
5466 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
5467 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
5468 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_old, 12)
5469 void __thiscall basic_fstream_char_open_old(basic_fstream_char *this,
5470         const char *name, unsigned int mode)
5471 {
5472     basic_fstream_char_open(this, name, mode, _SH_DENYNO);
5473 }
5474
5475 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBGHH@Z */
5476 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGHH@Z */
5477 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPB_WHH@Z */
5478 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WHH@Z */
5479 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_wchar, 16)
5480 void __thiscall basic_fstream_char_open_wchar(basic_fstream_char *this,
5481         const wchar_t *name, int mode, int prot)
5482 {
5483     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
5484
5485     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode, prot)) {
5486         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
5487         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
5488     }
5489 }
5490
5491 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBGI@Z */
5492 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGI@Z */
5493 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPB_WI@Z */
5494 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WI@Z */
5495 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_wchar_old, 12)
5496 void __thiscall basic_fstream_char_open_wchar_old(basic_fstream_char *this,
5497         const wchar_t *name, unsigned int mode)
5498 {
5499     basic_fstream_char_open_wchar(this, name, mode, _SH_DENYNO);
5500 }
5501
5502 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
5503 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
5504 DEFINE_THISCALL_WRAPPER(basic_fstream_char_rdbuf, 4)
5505 basic_filebuf_char* __thiscall basic_fstream_char_rdbuf(const basic_fstream_char *this)
5506 {
5507     TRACE("(%p)\n", this);
5508     return (basic_filebuf_char*)&this->filebuf;
5509 }
5510
5511 static basic_filebuf_char filebuf_stdin;
5512 /* ?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A */
5513 struct {
5514     basic_istream_char obj;
5515     basic_ios_char vbase;
5516 } cin = { { 0 } };
5517 /* ?_Ptr_cin@std@@3PAV?$basic_istream@DU?$char_traits@D@std@@@1@A */
5518 /* ?_Ptr_cin@std@@3PEAV?$basic_istream@DU?$char_traits@D@std@@@1@EA */
5519 basic_istream_char *_Ptr_cin = &cin.obj;
5520
5521 static basic_filebuf_char filebuf_stdout;
5522 /* ?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
5523 struct {
5524     basic_ostream_char obj;
5525     basic_ios_char vbase;
5526 } cout = { { 0 } };
5527 /* ?_Ptr_cout@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
5528 /* ?_Ptr_cout@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
5529 basic_ostream_char *_Ptr_cout = &cout.obj;
5530
5531 static basic_filebuf_char filebuf_stderr;
5532 /* ?cerr@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
5533 struct {
5534     basic_ostream_char obj;
5535     basic_ios_char vbase;
5536 } cerr = { { 0 } };
5537 /* ?_Ptr_cerr@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
5538 /* ?_Ptr_cerr@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
5539 basic_ostream_char *_Ptr_cerr = &cerr.obj;
5540
5541 void init_io(void)
5542 {
5543     basic_filebuf_char_ctor_file(&filebuf_stdin, stdin);
5544     basic_istream_char_ctor(&cin.obj, &filebuf_stdin.base, FALSE/*FIXME*/, TRUE);
5545
5546     basic_filebuf_char_ctor_file(&filebuf_stdout, stdout);
5547     basic_ostream_char_ctor(&cout.obj, &filebuf_stdout.base, FALSE/*FIXME*/, TRUE);
5548
5549     basic_filebuf_char_ctor_file(&filebuf_stderr, stderr);
5550     basic_ostream_char_ctor(&cerr.obj, &filebuf_stderr.base, FALSE/*FIXME*/, TRUE);
5551 }
5552
5553 void free_io(void)
5554 {
5555     basic_istream_char_dtor(&cin.obj);
5556     basic_filebuf_char_dtor(&filebuf_stdin);
5557
5558     basic_ostream_char_dtor(&cout.obj);
5559     basic_filebuf_char_dtor(&filebuf_stdout);
5560
5561     basic_ostream_char_dtor(&cerr.obj);
5562     basic_filebuf_char_dtor(&filebuf_stderr);
5563 }