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