vbscript: Added parser support for equality expression.
[wine] / dlls / msvcp90 / 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 "msvcp90.h"
25
26 #include "windef.h"
27 #include "winbase.h"
28
29 /* ??0_Mutex@std@@QAE@XZ */
30 /* ??0_Mutex@std@@QEAA@XZ */
31 DEFINE_THISCALL_WRAPPER(mutex_ctor, 4)
32 mutex* __thiscall mutex_ctor(mutex *this)
33 {
34     this->mutex = CreateMutexW(NULL, FALSE, NULL);
35     return this;
36 }
37
38 /* ??1_Mutex@std@@QAE@XZ */
39 /* ??1_Mutex@std@@QEAA@XZ */
40 DEFINE_THISCALL_WRAPPER(mutex_dtor, 4)
41 void __thiscall mutex_dtor(mutex *this)
42 {
43     CloseHandle(this->mutex);
44 }
45
46 /* ?_Lock@_Mutex@std@@QAEXXZ */
47 /* ?_Lock@_Mutex@std@@QEAAXXZ */
48 DEFINE_THISCALL_WRAPPER(mutex_lock, 4)
49 void __thiscall mutex_lock(mutex *this)
50 {
51     WaitForSingleObject(this->mutex, INFINITE);
52 }
53
54 /* ?_Unlock@_Mutex@std@@QAEXXZ */
55 /* ?_Unlock@_Mutex@std@@QEAAXXZ */
56 DEFINE_THISCALL_WRAPPER(mutex_unlock, 4)
57 void __thiscall mutex_unlock(mutex *this)
58 {
59     ReleaseMutex(this->mutex);
60 }
61
62 /* ?_Mutex_Lock@_Mutex@std@@CAXPAV12@@Z */
63 /* ?_Mutex_Lock@_Mutex@std@@CAXPEAV12@@Z */
64 void CDECL mutex_mutex_lock(mutex *m)
65 {
66     mutex_lock(m);
67 }
68
69 /* ?_Mutex_Unlock@_Mutex@std@@CAXPAV12@@Z */
70 /* ?_Mutex_Unlock@_Mutex@std@@CAXPEAV12@@Z */
71 void CDECL mutex_mutex_unlock(mutex *m)
72 {
73     mutex_unlock(m);
74 }
75
76 /* ?_Mutex_ctor@_Mutex@std@@CAXPAV12@@Z */
77 /* ?_Mutex_ctor@_Mutex@std@@CAXPEAV12@@Z */
78 void CDECL mutex_mutex_ctor(mutex *m)
79 {
80     mutex_ctor(m);
81 }
82
83 /* ?_Mutex_dtor@_Mutex@std@@CAXPAV12@@Z */
84 /* ?_Mutex_dtor@_Mutex@std@@CAXPEAV12@@Z */
85 void CDECL mutex_mutex_dtor(mutex *m)
86 {
87     mutex_dtor(m);
88 }
89
90 static CRITICAL_SECTION lockit_cs[_MAX_LOCK];
91
92 /* ?_Lockit_ctor@_Lockit@std@@SAXH@Z */
93 void __cdecl _Lockit_init(int locktype) {
94     InitializeCriticalSection(&lockit_cs[locktype]);
95     lockit_cs[locktype].DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": _Lockit critical section");
96 }
97
98 /* ?_Lockit_dtor@_Lockit@std@@SAXH@Z */
99 void __cdecl _Lockit_free(int locktype)
100 {
101     lockit_cs[locktype].DebugInfo->Spare[0] = (DWORD_PTR)0;
102     DeleteCriticalSection(&lockit_cs[locktype]);
103 }
104
105 void init_lockit(void) {
106     int i;
107
108     for(i=0; i<_MAX_LOCK; i++)
109         _Lockit_init(i);
110 }
111
112 void free_lockit(void) {
113     int i;
114
115     for(i=0; i<_MAX_LOCK; i++)
116         _Lockit_free(i);
117 }
118
119 /* ?_Lockit_ctor@_Lockit@std@@CAXPAV12@H@Z */
120 /* ?_Lockit_ctor@_Lockit@std@@CAXPEAV12@H@Z */
121 void __cdecl _Lockit__Lockit_ctor_locktype(_Lockit *lockit, int locktype)
122 {
123     lockit->locktype = locktype;
124     EnterCriticalSection(&lockit_cs[locktype]);
125 }
126
127 /* ?_Lockit_ctor@_Lockit@std@@CAXPAV12@@Z */
128 /* ?_Lockit_ctor@_Lockit@std@@CAXPEAV12@@Z */
129 void __cdecl _Lockit__Lockit_ctor(_Lockit *lockit)
130 {
131     _Lockit__Lockit_ctor_locktype(lockit, 0);
132 }
133
134 /* ??0_Lockit@std@@QAE@H@Z */
135 /* ??0_Lockit@std@@QEAA@H@Z */
136 DEFINE_THISCALL_WRAPPER(_Lockit_ctor_locktype, 8)
137 _Lockit* __thiscall _Lockit_ctor_locktype(_Lockit *this, int locktype)
138 {
139     _Lockit__Lockit_ctor_locktype(this, locktype);
140     return this;
141 }
142
143 /* ??0_Lockit@std@@QAE@XZ */
144 /* ??0_Lockit@std@@QEAA@XZ */
145 DEFINE_THISCALL_WRAPPER(_Lockit_ctor, 4)
146 _Lockit* __thiscall _Lockit_ctor(_Lockit *this)
147 {
148     _Lockit__Lockit_ctor_locktype(this, 0);
149     return this;
150 }
151
152 /* ?_Lockit_dtor@_Lockit@std@@CAXPAV12@@Z */
153 /* ?_Lockit_dtor@_Lockit@std@@CAXPEAV12@@Z */
154 void __cdecl _Lockit__Lockit_dtor(_Lockit *lockit)
155 {
156     LeaveCriticalSection(&lockit_cs[lockit->locktype]);
157 }
158
159 /* ??1_Lockit@std@@QAE@XZ */
160 /* ??1_Lockit@std@@QEAA@XZ */
161 DEFINE_THISCALL_WRAPPER(_Lockit_dtor, 4)
162 void __thiscall _Lockit_dtor(_Lockit *this)
163 {
164     _Lockit__Lockit_dtor(this);
165 }
166
167 /* wctype */
168 unsigned short __cdecl wctype(const char *property)
169 {
170     static const struct {
171         const char *name;
172         unsigned short mask;
173     } properties[] = {
174         { "alnum", _DIGIT|_ALPHA },
175         { "alpha", _ALPHA },
176         { "cntrl", _CONTROL },
177         { "digit", _DIGIT },
178         { "graph", _DIGIT|_PUNCT|_ALPHA },
179         { "lower", _LOWER },
180         { "print", _DIGIT|_PUNCT|_BLANK|_ALPHA },
181         { "punct", _PUNCT },
182         { "space", _SPACE },
183         { "upper", _UPPER },
184         { "xdigit", _HEX }
185     };
186     int i;
187
188     for(i=0; i<sizeof(properties)/sizeof(properties[0]); i++)
189         if(!strcmp(property, properties[i].name))
190             return properties[i].mask;
191
192     return 0;
193 }