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