d3d8/tests: Merge d3d8_main.c into device.c.
[wine] / dlls / msvcp60 / msvcp.h
1 /*
2  * Copyright 2010 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 "stdlib.h"
20 #include "windef.h"
21 #include "cxx.h"
22
23 typedef unsigned char MSVCP_bool;
24 typedef SIZE_T MSVCP_size_t;
25 typedef SSIZE_T streamoff;
26 typedef SSIZE_T streamsize;
27
28 void __cdecl _invalid_parameter(const wchar_t*, const wchar_t*,
29         const wchar_t*, unsigned int, uintptr_t);
30 BOOL __cdecl __uncaught_exception(void);
31
32 extern void* (__cdecl *MSVCRT_operator_new)(MSVCP_size_t);
33 extern void (__cdecl *MSVCRT_operator_delete)(void*);
34
35 /* basic_string<char, char_traits<char>, allocator<char>> */
36 typedef struct
37 {
38     void *allocator;
39     char *ptr;
40     MSVCP_size_t size;
41     MSVCP_size_t res;
42 } basic_string_char;
43
44 basic_string_char* __thiscall basic_string_char_ctor(basic_string_char*);
45 basic_string_char* basic_string_char_ctor_cstr(basic_string_char*, const char*);
46 basic_string_char* basic_string_char_ctor_cstr_len(basic_string_char*, const char*, MSVCP_size_t);
47 basic_string_char* __thiscall basic_string_char_copy_ctor(basic_string_char*, const basic_string_char*);
48 void __thiscall basic_string_char_dtor(basic_string_char*);
49 const char* __thiscall basic_string_char_c_str(const basic_string_char*);
50 void basic_string_char_clear(basic_string_char*);
51 basic_string_char* __thiscall basic_string_char_append_ch(basic_string_char*, char);
52 MSVCP_size_t __thiscall basic_string_char_length(const basic_string_char*);
53 basic_string_char* __thiscall basic_string_char_append_len_ch(basic_string_char*, MSVCP_size_t, char);
54
55 typedef struct
56 {
57     void *allocator;
58     wchar_t *ptr;
59     MSVCP_size_t size;
60     MSVCP_size_t res;
61 } basic_string_wchar;
62
63 basic_string_wchar* __thiscall basic_string_wchar_ctor(basic_string_wchar*);
64 basic_string_wchar* basic_string_wchar_ctor_cstr(basic_string_wchar*, const wchar_t*);
65 basic_string_wchar* basic_string_wchar_ctor_cstr_len(basic_string_wchar*, const wchar_t*, MSVCP_size_t);
66 void __thiscall basic_string_wchar_dtor(basic_string_wchar*);
67 const wchar_t* __thiscall basic_string_wchar_c_str(const basic_string_wchar*);
68 void basic_string_wchar_clear(basic_string_wchar*);
69 basic_string_wchar* __thiscall basic_string_wchar_append_ch(basic_string_wchar*, wchar_t);
70 MSVCP_size_t __thiscall basic_string_wchar_length(const basic_string_wchar*);
71
72 char* MSVCP_allocator_char_allocate(void*, MSVCP_size_t);
73 void MSVCP_allocator_char_deallocate(void*, char*, MSVCP_size_t);
74 MSVCP_size_t MSVCP_allocator_char_max_size(void*);
75 wchar_t* MSVCP_allocator_wchar_allocate(void*, MSVCP_size_t);
76 void MSVCP_allocator_wchar_deallocate(void*, wchar_t*, MSVCP_size_t);
77 MSVCP_size_t MSVCP_allocator_wchar_max_size(void*);
78
79 /* class locale::facet */
80 typedef struct {
81     const vtable_ptr *vtable;
82     MSVCP_size_t refs;
83 } locale_facet;
84
85 typedef enum {
86     CODECVT_ok      = 0,
87     CODECVT_partial = 1,
88     CODECVT_error   = 2,
89     CODECVT_noconv  = 3
90 } codecvt_base_result;
91
92 typedef struct {
93     LCID handle;
94     unsigned page;
95     const short *table;
96     int delfl;
97 } _Ctypevec;
98
99 /* class codecvt_base */
100 typedef struct {
101     locale_facet facet;
102 } codecvt_base;
103
104 /* class codecvt<char> */
105 typedef struct {
106     codecvt_base base;
107 } codecvt_char;
108
109 MSVCP_bool __thiscall codecvt_base_always_noconv(const codecvt_base*);
110 int __thiscall codecvt_char_out(const codecvt_char*, int*, const char*,
111         const char*, const char**, char*, char*, char**);
112 int __thiscall codecvt_char_in(const codecvt_char*, int*, const char*,
113         const char*, const char**, char*, char*, char**);
114 int __thiscall codecvt_base_max_length(const codecvt_base*);
115
116 typedef struct {
117     LCID handle;
118     unsigned page;
119 } _Cvtvec;
120
121 /* class codecvt<wchar> */
122 typedef struct {
123     codecvt_base base;
124     _Cvtvec cvt;
125 } codecvt_wchar;
126
127 int __thiscall codecvt_wchar_out(const codecvt_wchar*, int*, const wchar_t*,
128         const wchar_t*, const wchar_t**, char*, char*, char**);
129 int __thiscall codecvt_wchar_in(const codecvt_wchar*, int*, const char*,
130         const char*, const char**, wchar_t*, wchar_t*, wchar_t**);
131
132 /* class ctype_base */
133 typedef struct {
134     locale_facet facet;
135 } ctype_base;
136
137 /* class ctype<char> */
138 typedef struct {
139     ctype_base base;
140     _Ctypevec ctype;
141 } ctype_char;
142
143 MSVCP_bool __thiscall ctype_char_is_ch(const ctype_char*, short, char);
144 char __thiscall ctype_char_narrow_ch(const ctype_char*, char, char);
145 char __thiscall ctype_char_widen_ch(const ctype_char*, char);
146
147 /* class ctype<wchar> */
148 typedef struct {
149     ctype_base base;
150     _Ctypevec ctype;
151     _Cvtvec cvt;
152 } ctype_wchar;
153
154 MSVCP_bool __thiscall ctype_wchar_is_ch(const ctype_wchar*, short, wchar_t);
155 char __thiscall ctype_wchar_narrow_ch(const ctype_wchar*, wchar_t, char);
156 wchar_t __thiscall ctype_wchar_widen_ch(const ctype_wchar*, char);
157
158 /* class locale */
159 typedef struct
160 {
161     struct _locale__Locimp *ptr;
162 } locale;
163
164 locale* __thiscall locale_ctor(locale*);
165 locale* __thiscall locale_copy_ctor(locale*, const locale*);
166 locale* __thiscall locale_ctor_uninitialized(locale *, int);
167 locale* __thiscall locale_operator_assign(locale*, const locale*);
168 void __thiscall locale_dtor(locale*);
169 void free_locale(void);
170 locale* __thiscall locale__Addfac(locale*, locale_facet*, MSVCP_size_t, MSVCP_size_t);
171 codecvt_char* codecvt_char_use_facet(const locale*);
172 codecvt_wchar* codecvt_short_use_facet(const locale*);
173 ctype_char* ctype_char_use_facet(const locale*);
174 ctype_wchar* ctype_wchar_use_facet(const locale*);
175 ctype_wchar* ctype_short_use_facet(const locale*);
176
177 typedef struct {
178     MSVCP_size_t id;
179 } locale_id;
180 extern locale_id codecvt_char_id;
181 extern locale_id codecvt_short_id;
182
183 /* class _Lockit */
184 typedef struct {
185     char empty_struct;
186 } _Lockit;
187
188 #define _LOCK_LOCALE 0
189 #define _LOCK_MALLOC 1
190 #define _LOCK_STREAM 2
191 #define _LOCK_DEBUG 3
192 #define _MAX_LOCK 4
193
194 void init_lockit(void);
195 void free_lockit(void);
196 _Lockit* __thiscall _Lockit_ctor_locktype(_Lockit*, int);
197 void __thiscall _Lockit_dtor(_Lockit*);
198
199 typedef enum {
200     FMTFLAG_skipws      = 0x0001,
201     FMTFLAG_unitbuf     = 0x0002,
202     FMTFLAG_uppercase   = 0x0004,
203     FMTFLAG_showbase    = 0x0008,
204     FMTFLAG_showpoint   = 0x0010,
205     FMTFLAG_showpos     = 0x0020,
206     FMTFLAG_left        = 0x0040,
207     FMTFLAG_right       = 0x0080,
208     FMTFLAG_internal    = 0x0100,
209     FMTFLAG_dec         = 0x0200,
210     FMTFLAG_oct         = 0x0400,
211     FMTFLAG_hex         = 0x0800,
212     FMTFLAG_scientific  = 0x1000,
213     FMTFLAG_fixed       = 0x2000,
214     FMTFLAG_hexfloat    = 0x3000,
215     FMTFLAG_boolalpha   = 0x4000,
216     FMTFLAG_stdio       = 0x8000,
217     FMTFLAG_adjustfield = FMTFLAG_left|FMTFLAG_right|FMTFLAG_internal,
218     FMTFLAG_basefield   = FMTFLAG_dec|FMTFLAG_oct|FMTFLAG_hex,
219     FMTFLAG_floatfield  = FMTFLAG_scientific|FMTFLAG_fixed,
220     FMTFLAG_mask        = 0xffff
221 } IOSB_fmtflags;
222
223 typedef enum {
224     OPENMODE_in         = 0x01,
225     OPENMODE_out        = 0x02,
226     OPENMODE_ate        = 0x04,
227     OPENMODE_app        = 0x08,
228     OPENMODE_trunc      = 0x10,
229     OPENMODE__Nocreate  = 0x40,
230     OPENMODE__Noreplace = 0x80,
231     OPENMODE_binary     = 0x20,
232     OPENMODE_mask       = 0xff
233 } IOSB_openmode;
234
235 typedef enum {
236     SEEKDIR_beg  = 0x0,
237     SEEKDIR_cur  = 0x1,
238     SEEKDIR_end  = 0x2,
239     SEEKDIR_mask = 0x3
240 } IOSB_seekdir;
241
242 typedef enum {
243     IOSTATE_goodbit   = 0x00,
244     IOSTATE_eofbit    = 0x01,
245     IOSTATE_failbit   = 0x02,
246     IOSTATE_badbit    = 0x04,
247     IOSTATE__Hardfail = 0x10,
248     IOSTATE_mask      = 0x17
249 } IOSB_iostate;
250
251 typedef struct _iosarray {
252     struct _iosarray *next;
253     int index;
254     int long_val;
255     void *ptr_val;
256 } IOS_BASE_iosarray;
257
258 typedef enum {
259     EVENT_erase_event,
260     EVENT_imbue_event,
261     EVENT_copyfmt_event
262 } IOS_BASE_event;
263
264 struct _ios_base;
265 typedef void (CDECL *IOS_BASE_event_callback)(IOS_BASE_event, struct _ios_base*, int);
266 typedef struct _fnarray {
267     struct _fnarray *next;
268     int index;
269     IOS_BASE_event_callback event_handler;
270 } IOS_BASE_fnarray;
271
272 /* class ios_base */
273 typedef struct _ios_base {
274     const vtable_ptr *vtable;
275     IOSB_iostate state;
276     IOSB_iostate except;
277     IOSB_fmtflags fmtfl;
278     streamsize prec;
279     streamsize wide;
280     IOS_BASE_iosarray *arr;
281     IOS_BASE_fnarray *calls;
282     locale loc;
283     MSVCP_size_t stdstr;
284 } ios_base;
285
286 /* class basic_streambuf<char> */
287 typedef struct {
288     const vtable_ptr *vtable;
289     char *rbuf;
290     char *wbuf;
291     char **prbuf;
292     char **pwbuf;
293     char *rpos;
294     char *wpos;
295     char **prpos;
296     char **pwpos;
297     int rsize;
298     int wsize;
299     int *prsize;
300     int *pwsize;
301     locale loc;
302 } basic_streambuf_char;
303
304 typedef struct {
305     basic_streambuf_char *strbuf;
306     MSVCP_bool      got;
307     char            val;
308 } istreambuf_iterator_char;
309
310 typedef struct {
311     MSVCP_bool failed;
312     basic_streambuf_char *strbuf;
313 } ostreambuf_iterator_char;
314
315 int __thiscall basic_streambuf_char_sgetc(basic_streambuf_char*);
316 int __thiscall basic_streambuf_char_sbumpc(basic_streambuf_char*);
317 int __thiscall basic_streambuf_char_sputc(basic_streambuf_char*, char);
318
319 /* class basic_streambuf<wchar> */
320 typedef struct {
321     const vtable_ptr *vtable;
322     wchar_t *rbuf;
323     wchar_t *wbuf;
324     wchar_t **prbuf;
325     wchar_t **pwbuf;
326     wchar_t *rpos;
327     wchar_t *wpos;
328     wchar_t **prpos;
329     wchar_t **pwpos;
330     int rsize;
331     int wsize;
332     int *prsize;
333     int *pwsize;
334     locale loc;
335 } basic_streambuf_wchar;
336
337 typedef struct {
338     basic_streambuf_wchar *strbuf;
339     MSVCP_bool got;
340     wchar_t val;
341 } istreambuf_iterator_wchar;
342
343 typedef struct {
344     MSVCP_bool failed;
345     basic_streambuf_wchar *strbuf;
346 } ostreambuf_iterator_wchar;
347
348 unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar*);
349 unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar*);
350 unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar*, wchar_t);
351
352 /* class num_get<char> */
353 typedef struct {
354     locale_facet facet;
355     _Cvtvec cvt;
356 } num_get;
357
358 num_get* num_get_char_use_facet(const locale*);
359 istreambuf_iterator_char* __thiscall num_get_char_get_long(const num_get*, istreambuf_iterator_char*,
360         istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, LONG*);
361 istreambuf_iterator_char* __thiscall num_get_char_get_ushort(const num_get*, istreambuf_iterator_char*,
362         istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, unsigned short*);
363 istreambuf_iterator_char* __thiscall num_get_char_get_uint(const num_get*, istreambuf_iterator_char*,
364         istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, unsigned int*);
365 istreambuf_iterator_char* __thiscall num_get_char_get_ulong(const num_get*, istreambuf_iterator_char*,
366         istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, ULONG*);
367 istreambuf_iterator_char* __thiscall num_get_char_get_float(const num_get*, istreambuf_iterator_char*,
368         istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, float*);
369 istreambuf_iterator_char *__thiscall num_get_char_get_double(const num_get*, istreambuf_iterator_char*,
370         istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, double*);
371 istreambuf_iterator_char *__thiscall num_get_char_get_ldouble(const num_get*, istreambuf_iterator_char*,
372         istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, double*);
373 istreambuf_iterator_char *__thiscall num_get_char_get_void(const num_get*, istreambuf_iterator_char*,
374         istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, void**);
375 istreambuf_iterator_char *__thiscall num_get_char_get_int64(const num_get*, istreambuf_iterator_char*,
376         istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, LONGLONG*);
377 istreambuf_iterator_char *__thiscall num_get_char_get_uint64(const num_get*, istreambuf_iterator_char*,
378         istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, ULONGLONG*);
379 istreambuf_iterator_char *__thiscall num_get_char_get_bool(const num_get*, istreambuf_iterator_char*,
380         istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, MSVCP_bool*);
381
382 num_get* num_get_short_use_facet(const locale*);
383 istreambuf_iterator_wchar* __thiscall num_get_wchar_get_long(const num_get*, istreambuf_iterator_wchar*,
384         istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, LONG*);
385 istreambuf_iterator_wchar* __thiscall num_get_wchar_get_ushort(const num_get*, istreambuf_iterator_wchar*,
386         istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, unsigned short*);
387 istreambuf_iterator_wchar* __thiscall num_get_wchar_get_uint(const num_get*, istreambuf_iterator_wchar*,
388         istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, unsigned int*);
389 istreambuf_iterator_wchar* __thiscall num_get_wchar_get_ulong(const num_get*, istreambuf_iterator_wchar*,
390         istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, ULONG*);
391 istreambuf_iterator_wchar* __thiscall num_get_wchar_get_float(const num_get*, istreambuf_iterator_wchar*,
392         istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, float*);
393 istreambuf_iterator_wchar *__thiscall num_get_wchar_get_double(const num_get*, istreambuf_iterator_wchar*,
394         istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, double*);
395 istreambuf_iterator_wchar *__thiscall num_get_wchar_get_ldouble(const num_get*, istreambuf_iterator_wchar*,
396         istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, double*);
397 istreambuf_iterator_wchar *__thiscall num_get_wchar_get_void(const num_get*, istreambuf_iterator_wchar*,
398         istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, void**);
399 istreambuf_iterator_wchar *__thiscall num_get_wchar_get_int64(const num_get*, istreambuf_iterator_wchar*,
400         istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, LONGLONG*);
401 istreambuf_iterator_wchar *__thiscall num_get_wchar_get_uint64(const num_get*, istreambuf_iterator_wchar*,
402         istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, ULONGLONG*);
403 istreambuf_iterator_wchar *__thiscall num_get_wchar_get_bool(const num_get*, istreambuf_iterator_wchar*,
404         istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, MSVCP_bool*);
405
406 /* class num_put<char> */
407 /* class num_put<wchar> */
408 typedef struct {
409     locale_facet facet;
410     _Cvtvec cvt;
411 } num_put;
412
413 num_put* num_put_char_use_facet(const locale*);
414 ostreambuf_iterator_char* __thiscall num_put_char_put_long(const num_put*, ostreambuf_iterator_char*,
415         ostreambuf_iterator_char, ios_base*, char, LONG);
416 ostreambuf_iterator_char* __thiscall num_put_char_put_ulong(const num_put*, ostreambuf_iterator_char*,
417         ostreambuf_iterator_char, ios_base*, char, ULONG);
418 ostreambuf_iterator_char* __thiscall num_put_char_put_double(const num_put*, ostreambuf_iterator_char*,
419         ostreambuf_iterator_char, ios_base*, char, double);
420 ostreambuf_iterator_char* __thiscall num_put_char_put_ldouble(const num_put*, ostreambuf_iterator_char*,
421         ostreambuf_iterator_char, ios_base*, char, double);
422 ostreambuf_iterator_char* __thiscall num_put_char_put_ptr(const num_put*, ostreambuf_iterator_char*,
423         ostreambuf_iterator_char, ios_base*, char, const void*);
424 ostreambuf_iterator_char* __thiscall num_put_char_put_int64(const num_put*, ostreambuf_iterator_char*,
425         ostreambuf_iterator_char, ios_base*, char, __int64);
426 ostreambuf_iterator_char* __thiscall num_put_char_put_uint64(const num_put*, ostreambuf_iterator_char*,
427         ostreambuf_iterator_char, ios_base*, char, unsigned __int64);
428 ostreambuf_iterator_char* __thiscall num_put_char_put_bool(const num_put*, ostreambuf_iterator_char*,
429         ostreambuf_iterator_char, ios_base*, char, MSVCP_bool);
430
431 num_put* num_put_short_use_facet(const locale*);
432 ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_long(const num_put*, ostreambuf_iterator_wchar*,
433         ostreambuf_iterator_wchar, ios_base*, wchar_t, LONG);
434 ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_ulong(const num_put*, ostreambuf_iterator_wchar*,
435         ostreambuf_iterator_wchar, ios_base*, wchar_t, ULONG);
436 ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_double(const num_put*, ostreambuf_iterator_wchar*,
437         ostreambuf_iterator_wchar, ios_base*, wchar_t, double);
438 ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_ldouble(const num_put*, ostreambuf_iterator_wchar*,
439         ostreambuf_iterator_wchar, ios_base*, wchar_t, double);
440 ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_ptr(const num_put*, ostreambuf_iterator_wchar*,
441         ostreambuf_iterator_wchar, ios_base*, wchar_t, const void*);
442 ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_int64(const num_put*, ostreambuf_iterator_wchar*,
443         ostreambuf_iterator_wchar, ios_base*, wchar_t, __int64);
444 ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_uint64(const num_put*, ostreambuf_iterator_wchar*,
445         ostreambuf_iterator_wchar, ios_base*, wchar_t, unsigned __int64);
446 ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_bool(const num_put*, ostreambuf_iterator_wchar*,
447         ostreambuf_iterator_wchar, ios_base*, wchar_t, MSVCP_bool);
448
449 void init_exception(void*);
450 void init_locale(void*);
451 void init_io(void*);
452 void free_io(void);