mshtml: Properly report history update for location.replace call.
[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 /* ??0_Mutex@std@@QAE@XZ */
31 /* ??0_Mutex@std@@QEAA@XZ */
32 mutex* mutex_ctor(mutex *this)
33 {
34     CRITICAL_SECTION *cs = MSVCRT_operator_new(sizeof(*cs));
35     if(!cs)
36         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
37
38     InitializeCriticalSection(cs);
39     cs->DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": _Mutex critical section");
40     this->mutex = cs;
41     return this;
42 }
43
44 /* ??1_Mutex@std@@QAE@XZ */
45 /* ??1_Mutex@std@@QEAA@XZ */
46 void mutex_dtor(mutex *this)
47 {
48     ((CRITICAL_SECTION*)this->mutex)->DebugInfo->Spare[0] = 0;
49     DeleteCriticalSection(this->mutex);
50     MSVCRT_operator_delete(this->mutex);
51 }
52
53 /* ?_Lock@_Mutex@std@@QAEXXZ */
54 /* ?_Lock@_Mutex@std@@QEAAXXZ */
55 void mutex_lock(mutex *this)
56 {
57     EnterCriticalSection(this->mutex);
58 }
59
60 /* ?_Unlock@_Mutex@std@@QAEXXZ */
61 /* ?_Unlock@_Mutex@std@@QEAAXXZ */
62 void mutex_unlock(mutex *this)
63 {
64     LeaveCriticalSection(this->mutex);
65 }
66
67 static CRITICAL_SECTION lockit_cs;
68
69 void init_lockit(void) {
70     InitializeCriticalSection(&lockit_cs);
71     lockit_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": _Lockit critical section");
72 }
73
74 void free_lockit(void) {
75     lockit_cs.DebugInfo->Spare[0] = 0;
76     DeleteCriticalSection(&lockit_cs);
77 }
78
79 _Lockit* __thiscall _Lockit_ctor_locktype(_Lockit *this, int locktype)
80 {
81     EnterCriticalSection(&lockit_cs);
82     return this;
83 }
84
85 /* ??0_Lockit@std@@QAE@XZ */
86 /* ??0_Lockit@std@@QEAA@XZ */
87 DEFINE_THISCALL_WRAPPER(_Lockit_ctor, 4)
88 _Lockit* __thiscall _Lockit_ctor(_Lockit *this)
89 {
90     return _Lockit_ctor_locktype(this, 0);
91 }
92
93 /* ??1_Lockit@std@@QAE@XZ */
94 /* ??1_Lockit@std@@QEAA@XZ */
95 DEFINE_THISCALL_WRAPPER(_Lockit_dtor, 4)
96 void __thiscall _Lockit_dtor(_Lockit *this)
97 {
98     LeaveCriticalSection(&lockit_cs);
99 }
100
101 /* wctype */
102 unsigned short __cdecl wctype(const char *property)
103 {
104     static const struct {
105         const char *name;
106         unsigned short mask;
107     } properties[] = {
108         { "alnum", _DIGIT|_ALPHA },
109         { "alpha", _ALPHA },
110         { "cntrl", _CONTROL },
111         { "digit", _DIGIT },
112         { "graph", _DIGIT|_PUNCT|_ALPHA },
113         { "lower", _LOWER },
114         { "print", _DIGIT|_PUNCT|_BLANK|_ALPHA },
115         { "punct", _PUNCT },
116         { "space", _SPACE },
117         { "upper", _UPPER },
118         { "xdigit", _HEX }
119     };
120     int i;
121
122     for(i=0; i<sizeof(properties)/sizeof(properties[0]); i++)
123         if(!strcmp(property, properties[i].name))
124             return properties[i].mask;
125
126     return 0;
127 }