po: Update Polish translation.
[wine/multimedia.git] / dlls / msvcp90 / locale.c
blob27687ba5ddd0e8ff9130d72a8f7ddbd99d0fcca8
1 /*
2 * Copyright 2010 Piotr Caban for CodeWeavers
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.
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.
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
19 #include "config.h"
21 #include <stdarg.h>
23 #include "msvcp90.h"
24 #include "locale.h"
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(msvcp90);
31 char* __cdecl _Getdays(void);
32 char* __cdecl _Getmonths(void);
33 void* __cdecl _Gettnames(void);
35 typedef int category;
37 typedef struct _locale_id {
38 MSVCP_size_t id;
39 } locale_id;
41 typedef struct _locale_facet {
42 const vtable_ptr *vtable;
43 MSVCP_size_t refs;
44 } locale_facet;
46 typedef struct _locale__Locimp {
47 locale_facet facet;
48 locale_facet **facetvec;
49 MSVCP_size_t facet_cnt;
50 category catmask;
51 MSVCP_bool transparent;
52 basic_string_char name;
53 } locale__Locimp;
55 typedef struct {
56 void *timeptr;
57 } _Timevec;
59 typedef struct {
60 _Lockit lock;
61 basic_string_char days;
62 basic_string_char months;
63 basic_string_char oldlocname;
64 basic_string_char newlocname;
65 } _Locinfo;
67 typedef struct {
68 LCID handle;
69 unsigned page;
70 } _Collvec;
72 typedef struct {
73 LCID handle;
74 unsigned page;
75 short *table;
76 int delfl;
77 } _Ctypevec;
79 typedef struct {
80 LCID handle;
81 unsigned page;
82 } _Cvtvec;
84 /* ?_Id_cnt@id@locale@std@@0HA */
85 int locale_id__Id_cnt = 0;
87 /* ?_Clocptr@_Locimp@locale@std@@0PAV123@A */
88 /* ?_Clocptr@_Locimp@locale@std@@0PEAV123@EA */
89 locale__Locimp *locale__Locimp__Clocptr = NULL;
91 /* ??1facet@locale@std@@UAE@XZ */
92 /* ??1facet@locale@std@@UEAA@XZ */
93 DEFINE_THISCALL_WRAPPER(locale_facet_dtor, 4)
94 void __thiscall locale_facet_dtor(locale_facet *this)
96 TRACE("(%p)\n", this);
99 DEFINE_THISCALL_WRAPPER(MSVCP_locale_facet_vector_dtor, 8)
100 locale_facet* __thiscall MSVCP_locale_facet_vector_dtor(locale_facet *this, unsigned int flags)
102 TRACE("(%p %x)\n", this, flags);
103 if(flags & 2) {
104 /* we have an array, with the number of elements stored before the first object */
105 int i, *ptr = (int *)this-1;
107 for(i=*ptr-1; i>=0; i--)
108 locale_facet_dtor(this+i);
109 MSVCRT_operator_delete(ptr);
110 } else {
111 locale_facet_dtor(this);
112 if(flags & 1)
113 MSVCRT_operator_delete(this);
116 return this;
119 static const vtable_ptr MSVCP_locale_facet_vtable[] = {
120 (vtable_ptr)THISCALL_NAME(MSVCP_locale_facet_vector_dtor)
122 #ifdef __i386__
123 static inline locale_facet* call_locale_facet_vector_dtor(locale_facet *this, unsigned int flags)
125 locale_facet *ret;
126 void *dummy;
128 __asm__ __volatile__ ("pushl %3\n\tcall *%2"
129 : "=a" (ret), "=c" (dummy)
130 : "r" (this->vtable[0]), "r" (flags), "1" (this)
131 : "edx", "memory" );
132 return ret;
134 #else
135 static inline locale_facet* call_locale_facet_vector_dtor(locale_facet *this, unsigned int flags)
137 locale_facet * (__thiscall *dtor)(locale_facet *, unsigned int) = (void *)this->vtable[0];
138 return dtor(this, flags);
140 #endif
142 /* ??0id@locale@std@@QAE@I@Z */
143 /* ??0id@locale@std@@QEAA@_K@Z */
144 DEFINE_THISCALL_WRAPPER(locale_id_ctor_id, 8)
145 locale_id* __thiscall locale_id_ctor_id(locale_id *this, MSVCP_size_t id)
147 TRACE("(%p %lu)\n", this, id);
149 this->id = id;
150 return this;
153 /* ??_Fid@locale@std@@QAEXXZ */
154 /* ??_Fid@locale@std@@QEAAXXZ */
155 DEFINE_THISCALL_WRAPPER(locale_id_ctor, 4)
156 locale_id* __thiscall locale_id_ctor(locale_id *this)
158 TRACE("(%p)\n", this);
160 this->id = 0;
161 return this;
164 /* ??Bid@locale@std@@QAEIXZ */
165 /* ??Bid@locale@std@@QEAA_KXZ */
166 DEFINE_THISCALL_WRAPPER(locale_id_operator_size_t, 4)
167 MSVCP_size_t __thiscall locale_id_operator_size_t(locale_id *this)
169 _Lockit lock;
171 TRACE("(%p)\n", this);
173 if(!this->id) {
174 _Lockit_ctor_locktype(&lock, _LOCK_LOCALE);
175 this->id = ++locale_id__Id_cnt;
176 _Lockit_dtor(&lock);
179 return this->id;
182 /* ?_Id_cnt_func@id@locale@std@@CAAAHXZ */
183 /* ?_Id_cnt_func@id@locale@std@@CAAEAHXZ */
184 int* __cdecl locale_id__Id_cnt_func(void)
186 TRACE("\n");
187 return &locale_id__Id_cnt;
190 /* ??_Ffacet@locale@std@@QAEXXZ */
191 /* ??_Ffacet@locale@std@@QEAAXXZ */
192 DEFINE_THISCALL_WRAPPER(locale_facet_ctor, 4)
193 locale_facet* __thiscall locale_facet_ctor(locale_facet *this)
195 TRACE("(%p)\n", this);
196 this->vtable = MSVCP_locale_facet_vtable;
197 this->refs = 0;
198 return this;
201 /* ??0facet@locale@std@@IAE@I@Z */
202 /* ??0facet@locale@std@@IEAA@_K@Z */
203 DEFINE_THISCALL_WRAPPER(locale_facet_ctor_refs, 8)
204 locale_facet* __thiscall locale_facet_ctor_refs(locale_facet *this, MSVCP_size_t refs)
206 TRACE("(%p %lu)\n", this, refs);
207 this->vtable = MSVCP_locale_facet_vtable;
208 this->refs = refs;
209 return this;
212 /* ?_Incref@facet@locale@std@@QAEXXZ */
213 /* ?_Incref@facet@locale@std@@QEAAXXZ */
214 DEFINE_THISCALL_WRAPPER(locale_facet__Incref, 4)
215 void __thiscall locale_facet__Incref(locale_facet *this)
217 _Lockit lock;
219 TRACE("(%p)\n", this);
221 _Lockit_ctor_locktype(&lock, _LOCK_LOCALE);
222 this->refs++;
223 _Lockit_dtor(&lock);
226 /* ?_Decref@facet@locale@std@@QAEPAV123@XZ */
227 /* ?_Decref@facet@locale@std@@QEAAPEAV123@XZ */
228 DEFINE_THISCALL_WRAPPER(locale_facet__Decref, 4)
229 locale_facet* __thiscall locale_facet__Decref(locale_facet *this)
231 _Lockit lock;
232 locale_facet *ret;
234 TRACE("(%p)\n", this);
236 _Lockit_ctor_locktype(&lock, _LOCK_LOCALE);
237 if(this->refs)
238 this->refs--;
240 ret = this->refs ? NULL : this;
241 _Lockit_dtor(&lock);
243 return ret;
246 /* ?_Getcat@facet@locale@std@@SAIPAPBV123@PBV23@@Z */
247 /* ?_Getcat@facet@locale@std@@SA_KPEAPEBV123@PEBV23@@Z */
248 MSVCP_size_t __cdecl locale_facet__Getcat(const locale_facet **facet, const locale *loc)
250 TRACE("(%p %p)\n", facet, loc);
251 return -1;
254 /* ??0_Locimp@locale@std@@AAE@_N@Z */
255 /* ??0_Locimp@locale@std@@AEAA@_N@Z */
256 DEFINE_THISCALL_WRAPPER(locale__Locimp_ctor_transparent, 8)
257 locale__Locimp* __thiscall locale__Locimp_ctor_transparent(locale__Locimp *this, MSVCP_bool transparent)
259 TRACE("(%p %d)\n", this, transparent);
261 memset(this, 0, sizeof(locale__Locimp));
262 locale_facet_ctor_refs(&this->facet, 1);
263 this->transparent = transparent;
264 MSVCP_basic_string_char_ctor_cstr(&this->name, "*");
265 return this;
268 /* ??_F_Locimp@locale@std@@QAEXXZ */
269 /* ??_F_Locimp@locale@std@@QEAAXXZ */
270 DEFINE_THISCALL_WRAPPER(locale__Locimp_ctor, 4)
271 locale__Locimp* __thiscall locale__Locimp_ctor(locale__Locimp *this)
273 return locale__Locimp_ctor_transparent(this, FALSE);
276 /* ??0_Locimp@locale@std@@AAE@ABV012@@Z */
277 /* ??0_Locimp@locale@std@@AEAA@AEBV012@@Z */
278 DEFINE_THISCALL_WRAPPER(locale__Locimp_copy_ctor, 8)
279 locale__Locimp* __thiscall locale__Locimp_copy_ctor(locale__Locimp *this, const locale__Locimp *copy)
281 _Lockit lock;
282 MSVCP_size_t i;
284 TRACE("(%p %p)\n", this, copy);
286 _Lockit_ctor_locktype(&lock, _LOCK_LOCALE);
287 memcpy(this, copy, sizeof(locale__Locimp));
288 locale_facet_ctor_refs(&this->facet, 1);
289 if(copy->facetvec) {
290 this->facetvec = MSVCRT_operator_new(copy->facet_cnt*sizeof(locale_facet*));
291 if(!this->facetvec) {
292 _Lockit_dtor(&lock);
293 ERR("Out of memory\n");
294 throw_exception(EXCEPTION_BAD_ALLOC, NULL);
295 return NULL;
297 for(i=0; i<this->facet_cnt; i++)
298 if(this->facetvec[i])
299 locale_facet__Incref(this->facetvec[i]);
301 MSVCP_basic_string_char_copy_ctor(&this->name, &copy->name);
302 _Lockit_dtor(&lock);
303 return this;
306 /* ?_Locimp_ctor@_Locimp@locale@std@@CAXPAV123@ABV123@@Z */
307 /* ?_Locimp_ctor@_Locimp@locale@std@@CAXPEAV123@AEBV123@@Z */
308 locale__Locimp* __cdecl locale__Locimp__Locimp_ctor(locale__Locimp *this, const locale__Locimp *copy)
310 return locale__Locimp_copy_ctor(this, copy);
313 /* ??1_Locimp@locale@std@@MAE@XZ */
314 /* ??1_Locimp@locale@std@@MEAA@XZ */
315 DEFINE_THISCALL_WRAPPER(locale__Locimp_dtor, 4)
316 void __thiscall locale__Locimp_dtor(locale__Locimp *this)
318 TRACE("(%p)\n", this);
320 if(locale_facet__Decref(&this->facet)) {
321 MSVCP_size_t i;
322 for(i=0; i<this->facet_cnt; i++)
323 if(this->facetvec[i] && locale_facet__Decref(this->facetvec[i]))
324 call_locale_facet_vector_dtor(this->facetvec[i], 0);
326 MSVCRT_operator_delete(this->facetvec);
327 MSVCP_basic_string_char_dtor(&this->name);
331 /* ?_Locimp_dtor@_Locimp@locale@std@@CAXPAV123@@Z */
332 /* ?_Locimp_dtor@_Locimp@locale@std@@CAXPEAV123@@Z */
333 void __cdecl locale__Locimp__Locimp_dtor(locale__Locimp *this)
335 locale__Locimp_dtor(this);
338 DEFINE_THISCALL_WRAPPER(MSVCP_locale__Locimp_vector_dtor, 8)
339 locale__Locimp* __thiscall MSVCP_locale__Locimp_vector_dtor(locale__Locimp *this, unsigned int flags)
341 TRACE("(%p %x)\n", this, flags);
342 if(flags & 2) {
343 /* we have an array, with the number of elements stored before the first object */
344 int i, *ptr = (int *)this-1;
346 for(i=*ptr-1; i>=0; i--)
347 locale__Locimp_dtor(this+i);
348 MSVCRT_operator_delete(ptr);
349 } else {
350 locale__Locimp_dtor(this);
351 if(flags & 1)
352 MSVCRT_operator_delete(this);
355 return this;
358 /* ?_Locimp_Addfac@_Locimp@locale@std@@CAXPAV123@PAVfacet@23@I@Z */
359 /* ?_Locimp_Addfac@_Locimp@locale@std@@CAXPEAV123@PEAVfacet@23@_K@Z */
360 void __cdecl locale__Locimp__Locimp_Addfac(locale__Locimp *locimp, locale_facet *facet, MSVCP_size_t id)
362 _Lockit lock;
364 TRACE("(%p %p %lu)\n", locimp, facet, id);
366 _Lockit_ctor_locktype(&lock, _LOCK_LOCALE);
367 if(id >= locimp->facet_cnt) {
368 MSVCP_size_t new_size = id+1;
369 locale_facet **new_facetvec;
371 if(new_size < locale_id__Id_cnt+1)
372 new_size = locale_id__Id_cnt+1;
374 new_facetvec = MSVCRT_operator_new(sizeof(locale_facet*)*new_size);
375 if(!new_facetvec) {
376 _Lockit_dtor(&lock);
377 ERR("Out of memory\n");
378 throw_exception(EXCEPTION_BAD_ALLOC, NULL);
379 return;
382 memset(new_facetvec, 0, sizeof(locale_facet*)*new_size);
383 memcpy(new_facetvec, locimp->facetvec, sizeof(locale_facet*)*locimp->facet_cnt);
384 MSVCRT_operator_delete(locimp->facetvec);
385 locimp->facetvec = new_facetvec;
386 locimp->facet_cnt = new_size;
389 if(locimp->facetvec[id] && locale_facet__Decref(locimp->facetvec[id]))
390 call_locale_facet_vector_dtor(locimp->facetvec[id], 0);
392 locimp->facetvec[id] = facet;
393 if(facet)
394 locale_facet__Incref(facet);
395 _Lockit_dtor(&lock);
398 /* ?_Addfac@_Locimp@locale@std@@AAEXPAVfacet@23@I@Z */
399 /* ?_Addfac@_Locimp@locale@std@@AEAAXPEAVfacet@23@_K@Z */
400 DEFINE_THISCALL_WRAPPER(locale__Locimp__Addfac, 12)
401 void __thiscall locale__Locimp__Addfac(locale__Locimp *this, locale_facet *facet, MSVCP_size_t id)
403 locale__Locimp__Locimp_Addfac(this, facet, id);
406 /* ?_Clocptr_func@_Locimp@locale@std@@CAAAPAV123@XZ */
407 /* ?_Clocptr_func@_Locimp@locale@std@@CAAEAPEAV123@XZ */
408 locale__Locimp** __cdecl locale__Locimp__Clocptr_func(void)
410 FIXME("stub\n");
411 return NULL;
414 /* ?_Makeloc@_Locimp@locale@std@@CAPAV123@ABV_Locinfo@3@HPAV123@PBV23@@Z */
415 /* ?_Makeloc@_Locimp@locale@std@@CAPEAV123@AEBV_Locinfo@3@HPEAV123@PEBV23@@Z */
416 locale__Locimp* __cdecl locale__Locimp__Makeloc(const _Locinfo *locinfo, category cat, locale__Locimp *locimp, const locale *loc)
418 FIXME("(%p %d %p %p) stub\n", locinfo, cat, locimp, loc);
419 return NULL;
422 /* ?_Makeushloc@_Locimp@locale@std@@CAXABV_Locinfo@3@HPAV123@PBV23@@Z */
423 /* ?_Makeushloc@_Locimp@locale@std@@CAXAEBV_Locinfo@3@HPEAV123@PEBV23@@Z */
424 void __cdecl locale__Locimp__Makeushloc(const _Locinfo *locinfo, category cat, locale__Locimp *locimp, const locale *loc)
426 FIXME("(%p %d %p %p) stub\n", locinfo, cat, locimp, loc);
429 /* ?_Makewloc@_Locimp@locale@std@@CAXABV_Locinfo@3@HPAV123@PBV23@@Z */
430 /* ?_Makewloc@_Locimp@locale@std@@CAXAEBV_Locinfo@3@HPEAV123@PEBV23@@Z */
431 void __cdecl locale__Locimp__Makewloc(const _Locinfo *locinfo, category cat, locale__Locimp *locimp, const locale *loc)
433 FIXME("(%p %d %p %p) stub\n", locinfo, cat, locimp, loc);
436 /* ?_Makexloc@_Locimp@locale@std@@CAXABV_Locinfo@3@HPAV123@PBV23@@Z */
437 /* ?_Makexloc@_Locimp@locale@std@@CAXAEBV_Locinfo@3@HPEAV123@PEBV23@@Z */
438 void __cdecl locale__Locimp__Makexloc(const _Locinfo *locinfo, category cat, locale__Locimp *locimp, const locale *loc)
440 FIXME("(%p %d %p %p) stub\n", locinfo, cat, locimp, loc);
443 /* ??_7_Locimp@locale@std@@6B@ */
444 const vtable_ptr MSVCP_locale__Locimp_vtable[] = {
445 (vtable_ptr)THISCALL_NAME(MSVCP_locale__Locimp_vector_dtor)
448 /* ??0locale@std@@AAE@PAV_Locimp@01@@Z */
449 /* ??0locale@std@@AEAA@PEAV_Locimp@01@@Z */
450 DEFINE_THISCALL_WRAPPER(locale_ctor_locimp, 8)
451 locale* __thiscall locale_ctor_locimp(locale *this, locale__Locimp *locimp)
453 TRACE("(%p %p)\n", this, locimp);
454 /* Don't change locimp reference counter */
455 this->ptr = locimp;
456 return this;
459 /* ??0locale@std@@QAE@ABV01@0H@Z */
460 /* ??0locale@std@@QEAA@AEBV01@0H@Z */
461 DEFINE_THISCALL_WRAPPER(locale_ctor_locale_locale, 16)
462 locale* __thiscall locale_ctor_locale_locale(locale *this, const locale *loc, const locale *other, category cat)
464 FIXME("(%p %p %p %d) stub\n", this, loc, other, cat);
465 return NULL;
468 /* ??0locale@std@@QAE@ABV01@@Z */
469 /* ??0locale@std@@QEAA@AEBV01@@Z */
470 DEFINE_THISCALL_WRAPPER(locale_copy_ctor, 8)
471 locale* __thiscall locale_copy_ctor(locale *this, const locale *copy)
473 TRACE("(%p %p)\n", this, copy);
474 this->ptr = copy->ptr;
475 locale_facet__Incref(&this->ptr->facet);
476 return this;
479 /* ??0locale@std@@QAE@ABV01@PBDH@Z */
480 /* ??0locale@std@@QEAA@AEBV01@PEBDH@Z */
481 DEFINE_THISCALL_WRAPPER(locale_ctor_locale_cstr, 16)
482 locale* __thiscall locale_ctor_locale_cstr(locale *this, const locale *loc, const char *locname, category cat)
484 FIXME("(%p %p %s %d) stub\n", this, loc, locname, cat);
485 return NULL;
488 /* ??0locale@std@@QAE@PBDH@Z */
489 /* ??0locale@std@@QEAA@PEBDH@Z */
490 DEFINE_THISCALL_WRAPPER(locale_ctor_cstr, 12)
491 locale* __thiscall locale_ctor_cstr(locale *this, const char *locname, category cat)
493 FIXME("(%p %s %d) stub\n", this, locname, cat);
494 return NULL;
497 /* ??0locale@std@@QAE@W4_Uninitialized@1@@Z */
498 /* ??0locale@std@@QEAA@W4_Uninitialized@1@@Z */
499 DEFINE_THISCALL_WRAPPER(locale_ctor_uninitialized, 8)
500 locale* __thiscall locale_ctor_uninitialized(locale *this, int uninitialized)
502 TRACE("(%p)\n", this);
503 this->ptr = NULL;
504 return this;
507 /* ??0locale@std@@QAE@XZ */
508 /* ??0locale@std@@QEAA@XZ */
509 DEFINE_THISCALL_WRAPPER(locale_ctor, 4)
510 locale* __thiscall locale_ctor(locale *this)
512 TRACE("(%p)\n", this);
513 this->ptr = MSVCRT_operator_new(sizeof(locale__Locimp));
514 if(!this->ptr) {
515 ERR("Out of memory\n");
516 throw_exception(EXCEPTION_BAD_ALLOC, NULL);
517 return NULL;
520 locale__Locimp_ctor(this->ptr);
521 return this;
524 /* ??1locale@std@@QAE@XZ */
525 /* ??1locale@std@@QEAA@XZ */
526 DEFINE_THISCALL_WRAPPER(locale_dtor, 4)
527 void __thiscall locale_dtor(locale *this)
529 TRACE("(%p)\n", this);
530 if(this->ptr)
531 locale__Locimp_dtor(this->ptr);
534 DEFINE_THISCALL_WRAPPER(MSVCP_locale_vector_dtor, 8)
535 locale* __thiscall MSVCP_locale_vector_dtor(locale *this, unsigned int flags)
537 TRACE("(%p %x)\n", this, flags);
538 if(flags & 2) {
539 /* we have an array, with the number of elements stored before the first object */
540 int i, *ptr = (int *)this-1;
542 for(i=*ptr-1; i>=0; i--)
543 locale_dtor(this+i);
544 MSVCRT_operator_delete(ptr);
545 } else {
546 locale_dtor(this);
547 if(flags & 1)
548 MSVCRT_operator_delete(this);
551 return this;
554 /* ??4locale@std@@QAEAAV01@ABV01@@Z */
555 /* ??4locale@std@@QEAAAEAV01@AEBV01@@Z */
556 DEFINE_THISCALL_WRAPPER(locale_operator_assign, 8)
557 locale* __thiscall locale_operator_assign(locale *this, const locale *loc)
559 FIXME("(%p %p) stub\n", this, loc);
560 return NULL;
563 /* ??8locale@std@@QBE_NABV01@@Z */
564 /* ??8locale@std@@QEBA_NAEBV01@@Z */
565 DEFINE_THISCALL_WRAPPER(locale_operator_equal, 8)
566 MSVCP_bool __thiscall locale_operator_equal(const locale *this, const locale *loc)
568 FIXME("(%p %p) stub\n", this, loc);
569 return 0;
572 /* ??9locale@std@@QBE_NABV01@@Z */
573 /* ??9locale@std@@QEBA_NAEBV01@@Z */
574 DEFINE_THISCALL_WRAPPER(locale_operator_not_equal, 8)
575 MSVCP_bool __thiscall locale_operator_not_equal(const locale *this, locale const *loc)
577 FIXME("(%p %p) stub\n", this, loc);
578 return 0;
581 /* ?_Addfac@locale@std@@QAEAAV12@PAVfacet@12@II@Z */
582 /* ?_Addfac@locale@std@@QEAAAEAV12@PEAVfacet@12@_K1@Z */
583 DEFINE_THISCALL_WRAPPER(locale__Addfac, 16)
584 locale* __thiscall locale__Addfac(locale *this, locale_facet *facet, MSVCP_size_t id, MSVCP_size_t catmask)
586 TRACE("(%p %p %lu %lu)\n", this, facet, id, catmask);
588 if(this->ptr->facet.refs > 1) {
589 locale__Locimp *new_ptr = MSVCRT_operator_new(sizeof(locale__Locimp));
590 if(!new_ptr) {
591 ERR("Out of memory\n");
592 throw_exception(EXCEPTION_BAD_ALLOC, NULL);
593 return NULL;
595 locale__Locimp_copy_ctor(new_ptr, this->ptr);
596 locale_facet__Decref(&this->ptr->facet);
597 this->ptr = new_ptr;
600 locale__Locimp__Addfac(this->ptr, facet, id);
602 if(catmask) {
603 MSVCP_basic_string_char_dtor(&this->ptr->name);
604 MSVCP_basic_string_char_ctor_cstr(&this->ptr->name, "*");
606 return this;
609 /* ?_Getfacet@locale@std@@QBEPBVfacet@12@I@Z */
610 /* ?_Getfacet@locale@std@@QEBAPEBVfacet@12@_K@Z */
611 DEFINE_THISCALL_WRAPPER(locale__Getfacet, 8)
612 const locale_facet* __thiscall locale__Getfacet(const locale *this, MSVCP_size_t id)
614 FIXME("(%p %lu) stub\n", this, id);
615 return NULL;
618 /* ?_Init@locale@std@@CAPAV_Locimp@12@XZ */
619 /* ?_Init@locale@std@@CAPEAV_Locimp@12@XZ */
620 locale__Locimp* __cdecl locale__Init(void)
622 FIXME("stub\n");
623 return NULL;
626 /* ?_Getgloballocale@locale@std@@CAPAV_Locimp@12@XZ */
627 /* ?_Getgloballocale@locale@std@@CAPEAV_Locimp@12@XZ */
628 locale__Locimp* __cdecl locale__Getgloballocale(void)
630 FIXME("stub\n");
631 return NULL;
634 /* ?_Setgloballocale@locale@std@@CAXPAX@Z */
635 /* ?_Setgloballocale@locale@std@@CAXPEAX@Z */
636 void __cdecl locale__Setgloballocale(void *locimp)
638 FIXME("(%p) stub\n", locimp);
641 /* ?classic@locale@std@@SAABV12@XZ */
642 /* ?classic@locale@std@@SAAEBV12@XZ */
643 const locale* __cdecl locale_classic(void)
645 FIXME("stub\n");
646 return NULL;
649 /* ?name@locale@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
650 /* ?name@locale@std@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
651 DEFINE_THISCALL_WRAPPER_RETPTR(locale_name, 4)
652 basic_string_char __thiscall locale_name(const locale *this)
654 TRACE( "(%p)\n", this);
655 return this->ptr->name;
658 /* ??0_Timevec@std@@QAE@ABV01@@Z */
659 /* ??0_Timevec@std@@QEAA@AEBV01@@Z */
660 /* This copy constructor modifies copied object */
661 DEFINE_THISCALL_WRAPPER(_Timevec_copy_ctor, 8)
662 _Timevec* __thiscall _Timevec_copy_ctor(_Timevec *this, _Timevec *copy)
664 TRACE("(%p %p)\n", this, copy);
665 this->timeptr = copy->timeptr;
666 copy->timeptr = NULL;
667 return this;
670 /* ??0_Timevec@std@@QAE@PAX@Z */
671 /* ??0_Timevec@std@@QEAA@PEAX@Z */
672 DEFINE_THISCALL_WRAPPER(_Timevec_ctor_timeptr, 8)
673 _Timevec* __thiscall _Timevec_ctor_timeptr(_Timevec *this, void *timeptr)
675 TRACE("(%p %p)\n", this, timeptr);
676 this->timeptr = timeptr;
677 return this;
680 /* ??_F_Timevec@std@@QAEXXZ */
681 /* ??_F_Timevec@std@@QEAAXXZ */
682 DEFINE_THISCALL_WRAPPER(_Timevec_ctor, 4)
683 _Timevec* __thiscall _Timevec_ctor(_Timevec *this)
685 TRACE("(%p)\n", this);
686 this->timeptr = NULL;
687 return this;
690 /* ??1_Timevec@std@@QAE@XZ */
691 /* ??1_Timevec@std@@QEAA@XZ */
692 DEFINE_THISCALL_WRAPPER(_Timevec_dtor, 4)
693 void __thiscall _Timevec_dtor(_Timevec *this)
695 TRACE("(%p)\n", this);
696 free(this->timeptr);
699 /* ??4_Timevec@std@@QAEAAV01@ABV01@@Z */
700 /* ??4_Timevec@std@@QEAAAEAV01@AEBV01@@Z */
701 DEFINE_THISCALL_WRAPPER(_Timevec_op_assign, 8)
702 _Timevec* __thiscall _Timevec_op_assign(_Timevec *this, _Timevec *right)
704 TRACE("(%p %p)\n", this, right);
705 this->timeptr = right->timeptr;
706 right->timeptr = NULL;
707 return this;
710 /* ?_Getptr@_Timevec@std@@QBEPAXXZ */
711 /* ?_Getptr@_Timevec@std@@QEBAPEAXXZ */
712 DEFINE_THISCALL_WRAPPER(_Timevec__Getptr, 4)
713 void* __thiscall _Timevec__Getptr(_Timevec *this)
715 TRACE("(%p)\n", this);
716 return this->timeptr;
719 /* ?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@HPBD@Z */
720 /* ?_Locinfo_ctor@_Locinfo@std@@SAXPEAV12@HPEBD@Z */
721 _Locinfo* __cdecl _Locinfo__Locinfo_ctor_cat_cstr(_Locinfo *locinfo, int category, const char *locstr)
723 const char *locale = NULL;
725 /* This function is probably modifying more global objects */
726 FIXME("(%p %d %s) semi-stub\n", locinfo, category, locstr);
728 if(!locstr)
729 throw_exception(EXCEPTION_RUNTIME_ERROR, "bad locale name");
731 _Lockit_ctor_locktype(&locinfo->lock, _LOCK_LOCALE);
732 MSVCP_basic_string_char_ctor_cstr(&locinfo->days, "");
733 MSVCP_basic_string_char_ctor_cstr(&locinfo->months, "");
734 MSVCP_basic_string_char_ctor_cstr(&locinfo->oldlocname, setlocale(LC_ALL, NULL));
736 if(category)
737 locale = setlocale(LC_ALL, locstr);
738 else
739 locale = setlocale(LC_ALL, NULL);
741 if(locale)
742 MSVCP_basic_string_char_ctor_cstr(&locinfo->newlocname, locale);
743 else
744 MSVCP_basic_string_char_ctor_cstr(&locinfo->newlocname, "*");
745 _Lockit_dtor(&locinfo->lock);
747 return locinfo;
750 /* ??0_Locinfo@std@@QAE@HPBD@Z */
751 /* ??0_Locinfo@std@@QEAA@HPEBD@Z */
752 DEFINE_THISCALL_WRAPPER(_Locinfo_ctor_cat_cstr, 12)
753 _Locinfo* __thiscall _Locinfo_ctor_cat_cstr(_Locinfo *this, int category, const char *locstr)
755 return _Locinfo__Locinfo_ctor_cat_cstr(this, category, locstr);
758 /* ?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z */
759 /* ?_Locinfo_ctor@_Locinfo@std@@SAXPEAV12@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z */
760 _Locinfo* __cdecl _Locinfo__Locinfo_ctor_bstr(_Locinfo *locinfo, const basic_string_char *locstr)
762 return _Locinfo__Locinfo_ctor_cat_cstr(locinfo, 1/*FIXME*/, MSVCP_basic_string_char_c_str(locstr));
765 /* ??0_Locinfo@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
766 /* ??0_Locinfo@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
767 DEFINE_THISCALL_WRAPPER(_Locinfo_ctor_bstr, 8)
768 _Locinfo* __thiscall _Locinfo_ctor_bstr(_Locinfo *this, const basic_string_char *locstr)
770 return _Locinfo__Locinfo_ctor_cat_cstr(this, 1/*FIXME*/, MSVCP_basic_string_char_c_str(locstr));
773 /* ?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@PBD@Z */
774 /* ?_Locinfo_ctor@_Locinfo@std@@SAXPEAV12@PEBD@Z */
775 _Locinfo* __cdecl _Locinfo__Locinfo_ctor_cstr(_Locinfo *locinfo, const char *locstr)
777 return _Locinfo__Locinfo_ctor_cat_cstr(locinfo, 1/*FIXME*/, locstr);
780 /* ??0_Locinfo@std@@QAE@PBD@Z */
781 /* ??0_Locinfo@std@@QEAA@PEBD@Z */
782 DEFINE_THISCALL_WRAPPER(_Locinfo_ctor_cstr, 8)
783 _Locinfo* __thiscall _Locinfo_ctor_cstr(_Locinfo *this, const char *locstr)
785 return _Locinfo__Locinfo_ctor_cat_cstr(this, 1/*FIXME*/, locstr);
788 /* ?_Locinfo_dtor@_Locinfo@std@@SAXPAV12@@Z */
789 /* ?_Locinfo_dtor@_Locinfo@std@@SAXPEAV12@@Z */
790 void __cdecl _Locinfo__Locinfo_dtor(_Locinfo *locinfo)
792 TRACE("(%p)\n", locinfo);
794 setlocale(LC_ALL, MSVCP_basic_string_char_c_str(&locinfo->oldlocname));
795 MSVCP_basic_string_char_dtor(&locinfo->days);
796 MSVCP_basic_string_char_dtor(&locinfo->months);
797 MSVCP_basic_string_char_dtor(&locinfo->oldlocname);
798 MSVCP_basic_string_char_dtor(&locinfo->newlocname);
801 /* ??_F_Locinfo@std@@QAEXXZ */
802 /* ??_F_Locinfo@std@@QEAAXXZ */
803 DEFINE_THISCALL_WRAPPER(_Locinfo_ctor, 4)
804 _Locinfo* __thiscall _Locinfo_ctor(_Locinfo *this)
806 return _Locinfo__Locinfo_ctor_cat_cstr(this, 1/*FIXME*/, "C");
809 /* ??1_Locinfo@std@@QAE@XZ */
810 /* ??1_Locinfo@std@@QEAA@XZ */
811 DEFINE_THISCALL_WRAPPER(_Locinfo_dtor, 4)
812 void __thiscall _Locinfo_dtor(_Locinfo *this)
814 _Locinfo__Locinfo_dtor(this);
817 /* ?_Locinfo_Addcats@_Locinfo@std@@SAAAV12@PAV12@HPBD@Z */
818 /* ?_Locinfo_Addcats@_Locinfo@std@@SAAEAV12@PEAV12@HPEBD@Z */
819 _Locinfo* __cdecl _Locinfo__Locinfo_Addcats(_Locinfo *locinfo, int category, const char *locstr)
821 const char *locale = NULL;
823 /* This function is probably modifying more global objects */
824 FIXME("(%p %d %s) semi-stub\n", locinfo, category, locstr);
825 if(!locstr)
826 throw_exception(EXCEPTION_RUNTIME_ERROR, "bad locale name");
828 _Lockit_ctor_locktype(&locinfo->lock, _LOCK_LOCALE);
829 MSVCP_basic_string_char_dtor(&locinfo->newlocname);
831 if(category)
832 locale = setlocale(LC_ALL, locstr);
833 else
834 locale = setlocale(LC_ALL, NULL);
836 if(locale)
837 MSVCP_basic_string_char_ctor_cstr(&locinfo->newlocname, locale);
838 else
839 MSVCP_basic_string_char_ctor_cstr(&locinfo->newlocname, "*");
840 _Lockit_dtor(&locinfo->lock);
842 return locinfo;
845 /* ?_Addcats@_Locinfo@std@@QAEAAV12@HPBD@Z */
846 /* ?_Addcats@_Locinfo@std@@QEAAAEAV12@HPEBD@Z */
847 DEFINE_THISCALL_WRAPPER(_Locinfo__Addcats, 12)
848 _Locinfo* __thiscall _Locinfo__Addcats(_Locinfo *this, int category, const char *locstr)
850 return _Locinfo__Locinfo_Addcats(this, category, locstr);
853 /* _Getcoll */
854 _Collvec __cdecl _Getcoll(void)
856 _Collvec ret;
857 _locale_t locale = _get_current_locale();
859 TRACE("\n");
861 ret.page = locale->locinfo->lc_collate_cp;
862 ret.handle = locale->locinfo->lc_handle[LC_COLLATE];
863 _free_locale(locale);
864 return ret;
867 /* ?_Getcoll@_Locinfo@std@@QBE?AU_Collvec@@XZ */
868 /* ?_Getcoll@_Locinfo@std@@QEBA?AU_Collvec@@XZ */
869 DEFINE_THISCALL_WRAPPER(_Locinfo__Getcoll, 4)
870 _Collvec __thiscall _Locinfo__Getcoll(const _Locinfo *this)
872 return _Getcoll();
875 /* _Getctype */
876 _Ctypevec __cdecl _Getctype(void)
878 _Ctypevec ret;
879 _locale_t locale = _get_current_locale();
881 TRACE("\n");
883 ret.page = locale->locinfo->lc_codepage;
884 ret.handle = locale->locinfo->lc_handle[LC_COLLATE];
885 ret.delfl = TRUE;
886 ret.table = malloc(sizeof(short[256]));
887 if(!ret.table) {
888 _free_locale(locale);
889 throw_exception(EXCEPTION_BAD_ALLOC, NULL);
891 memcpy(ret.table, locale->locinfo->pctype, sizeof(short[256]));
892 _free_locale(locale);
893 return ret;
896 /* ?_Getctype@_Locinfo@std@@QBE?AU_Ctypevec@@XZ */
897 /* ?_Getctype@_Locinfo@std@@QEBA?AU_Ctypevec@@XZ */
898 DEFINE_THISCALL_WRAPPER_RETPTR(_Locinfo__Getctype, 4)
899 _Ctypevec __thiscall _Locinfo__Getctype(const _Locinfo *this)
901 return _Getctype();
904 /* _Getcvt */
905 _Cvtvec __cdecl _Getcvt(void)
907 _Cvtvec ret;
908 _locale_t locale = _get_current_locale();
910 TRACE("\n");
912 ret.page = locale->locinfo->lc_codepage;
913 ret.handle = locale->locinfo->lc_handle[LC_CTYPE];
914 _free_locale(locale);
915 return ret;
918 /* ?_Getcvt@_Locinfo@std@@QBE?AU_Cvtvec@@XZ */
919 /* ?_Getcvt@_Locinfo@std@@QEBA?AU_Cvtvec@@XZ */
920 DEFINE_THISCALL_WRAPPER(_Locinfo__Getcvt, 4)
921 _Cvtvec __thiscall _Locinfo__Getcvt(const _Locinfo *this)
923 return _Getcvt();
926 /* ?_Getdateorder@_Locinfo@std@@QBEHXZ */
927 /* ?_Getdateorder@_Locinfo@std@@QEBAHXZ */
928 DEFINE_THISCALL_WRAPPER(_Locinfo__Getdateorder, 4)
929 int __thiscall _Locinfo__Getdateorder(const _Locinfo *this)
931 FIXME("(%p) stub\n", this);
932 return 0;
935 /* ?_Getdays@_Locinfo@std@@QBEPBDXZ */
936 /* ?_Getdays@_Locinfo@std@@QEBAPEBDXZ */
937 DEFINE_THISCALL_WRAPPER(_Locinfo__Getdays, 4)
938 const char* __thiscall _Locinfo__Getdays(_Locinfo *this)
940 char *days = _Getdays();
942 TRACE("(%p)\n", this);
944 if(days) {
945 MSVCP_basic_string_char_dtor(&this->days);
946 MSVCP_basic_string_char_ctor_cstr(&this->days, days);
947 free(days);
950 return this->days.size ? MSVCP_basic_string_char_c_str(&this->days) :
951 ":Sun:Sunday:Mon:Monday:Tue:Tuesday:Wed:Wednesday:Thu:Thursday:Fri:Friday:Sat:Saturday";
954 /* ?_Getmonths@_Locinfo@std@@QBEPBDXZ */
955 /* ?_Getmonths@_Locinfo@std@@QEBAPEBDXZ */
956 DEFINE_THISCALL_WRAPPER(_Locinfo__Getmonths, 4)
957 const char* __thiscall _Locinfo__Getmonths(_Locinfo *this)
959 char *months = _Getmonths();
961 TRACE("(%p)\n", this);
963 if(months) {
964 MSVCP_basic_string_char_dtor(&this->months);
965 MSVCP_basic_string_char_ctor_cstr(&this->months, months);
966 free(months);
969 return this->months.size ? MSVCP_basic_string_char_c_str(&this->months) :
970 ":Jan:January:Feb:February:Mar:March:Apr:April:May:May:Jun:June:Jul:July"
971 ":Aug:August:Sep:September:Oct:October:Nov:November:Dec:December";
974 /* ?_Getfalse@_Locinfo@std@@QBEPBDXZ */
975 /* ?_Getfalse@_Locinfo@std@@QEBAPEBDXZ */
976 DEFINE_THISCALL_WRAPPER(_Locinfo__Getfalse, 4)
977 const char* __thiscall _Locinfo__Getfalse(const _Locinfo *this)
979 TRACE("(%p)\n", this);
980 return "false";
983 /* ?_Gettrue@_Locinfo@std@@QBEPBDXZ */
984 /* ?_Gettrue@_Locinfo@std@@QEBAPEBDXZ */
985 DEFINE_THISCALL_WRAPPER(_Locinfo__Gettrue, 4)
986 const char* __thiscall _Locinfo__Gettrue(const _Locinfo *this)
988 TRACE("(%p)\n", this);
989 return "true";
992 /* ?_Getlconv@_Locinfo@std@@QBEPBUlconv@@XZ */
993 /* ?_Getlconv@_Locinfo@std@@QEBAPEBUlconv@@XZ */
994 DEFINE_THISCALL_WRAPPER(_Locinfo__Getlconv, 4)
995 const struct lconv* __thiscall _Locinfo__Getlconv(const _Locinfo *this)
997 TRACE("(%p)\n", this);
998 return localeconv();
1001 /* ?_Getname@_Locinfo@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
1002 /* ?_Getname@_Locinfo@std@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
1003 DEFINE_THISCALL_WRAPPER_RETPTR(_Locinfo__Getname, 4)
1004 basic_string_char __thiscall _Locinfo__Getname(const _Locinfo *this)
1006 basic_string_char ret;
1008 TRACE("(%p)\n", this);
1010 MSVCP_basic_string_char_copy_ctor(&ret, &this->newlocname);
1011 return ret;
1014 /* ?_Gettnames@_Locinfo@std@@QBE?AV_Timevec@2@XZ */
1015 /* ?_Gettnames@_Locinfo@std@@QEBA?AV_Timevec@2@XZ */
1016 DEFINE_THISCALL_WRAPPER(_Locinfo__Gettnames, 4)
1017 _Timevec __thiscall _Locinfo__Gettnames(const _Locinfo *this)
1019 _Timevec ret;
1021 TRACE("(%p)\n", this);
1023 _Timevec_ctor_timeptr(&ret, _Gettnames());
1024 return ret;