winemac: Implement SetWindowRgn.
[wine] / dlls / msvcp60 / misc.c
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 "config.h"
20
21 #include <stdarg.h>
22 #include <limits.h>
23
24 #include "msvcp.h"
25
26 #include "windef.h"
27 #include "winbase.h"
28
29
30 static CRITICAL_SECTION lockit_cs;
31
32 void init_lockit(void) {
33     InitializeCriticalSection(&lockit_cs);
34     lockit_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": _Lockit critical section");
35 }
36
37 void free_lockit(void) {
38     lockit_cs.DebugInfo->Spare[0] = 0;
39     DeleteCriticalSection(&lockit_cs);
40 }
41
42 _Lockit* __thiscall _Lockit_ctor_locktype(_Lockit *this, int locktype)
43 {
44     EnterCriticalSection(&lockit_cs);
45     return this;
46 }
47
48 /* ??0_Lockit@std@@QAE@XZ */
49 /* ??0_Lockit@std@@QEAA@XZ */
50 DEFINE_THISCALL_WRAPPER(_Lockit_ctor, 4)
51 _Lockit* __thiscall _Lockit_ctor(_Lockit *this)
52 {
53     return _Lockit_ctor_locktype(this, 0);
54 }
55
56 /* ??1_Lockit@std@@QAE@XZ */
57 /* ??1_Lockit@std@@QEAA@XZ */
58 DEFINE_THISCALL_WRAPPER(_Lockit_dtor, 4)
59 void __thiscall _Lockit_dtor(_Lockit *this)
60 {
61     LeaveCriticalSection(&lockit_cs);
62 }
63
64 /* wctype */
65 unsigned short __cdecl wctype(const char *property)
66 {
67     static const struct {
68         const char *name;
69         unsigned short mask;
70     } properties[] = {
71         { "alnum", _DIGIT|_ALPHA },
72         { "alpha", _ALPHA },
73         { "cntrl", _CONTROL },
74         { "digit", _DIGIT },
75         { "graph", _DIGIT|_PUNCT|_ALPHA },
76         { "lower", _LOWER },
77         { "print", _DIGIT|_PUNCT|_BLANK|_ALPHA },
78         { "punct", _PUNCT },
79         { "space", _SPACE },
80         { "upper", _UPPER },
81         { "xdigit", _HEX }
82     };
83     int i;
84
85     for(i=0; i<sizeof(properties)/sizeof(properties[0]); i++)
86         if(!strcmp(property, properties[i].name))
87             return properties[i].mask;
88
89     return 0;
90 }