Added Russian translation.
[wine.git] / scheduler / event.c
blob1004ead09a727160d63a984cf311f6f46c49034f
1 /*
2 * Win32 events
4 * Copyright 1998 Alexandre Julliard
5 */
7 #include <assert.h>
8 #include <string.h>
9 #include "winerror.h"
10 #include "syslevel.h"
11 #include "server.h"
14 /***********************************************************************
15 * CreateEvent32A (KERNEL32.156)
17 HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
18 BOOL initial_state, LPCSTR name )
20 struct create_event_request *req = get_req_buffer();
22 req->manual_reset = manual_reset;
23 req->initial_state = initial_state;
24 req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
25 server_strcpyAtoW( req->name, name );
26 SetLastError(0);
27 server_call( REQ_CREATE_EVENT );
28 if (req->handle == -1) return 0;
29 return req->handle;
33 /***********************************************************************
34 * CreateEvent32W (KERNEL32.157)
36 HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
37 BOOL initial_state, LPCWSTR name )
39 struct create_event_request *req = get_req_buffer();
41 req->manual_reset = manual_reset;
42 req->initial_state = initial_state;
43 req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
44 server_strcpyW( req->name, name );
45 SetLastError(0);
46 server_call( REQ_CREATE_EVENT );
47 if (req->handle == -1) return 0;
48 return req->handle;
51 /***********************************************************************
52 * WIN16_CreateEvent (KERNEL.457)
54 HANDLE WINAPI WIN16_CreateEvent( BOOL manual_reset, BOOL initial_state )
56 return CreateEventA( NULL, manual_reset, initial_state, NULL );
60 /***********************************************************************
61 * OpenEvent32A (KERNEL32.536)
63 HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name )
65 struct open_event_request *req = get_req_buffer();
67 req->access = access;
68 req->inherit = inherit;
69 server_strcpyAtoW( req->name, name );
70 server_call( REQ_OPEN_EVENT );
71 if (req->handle == -1) return 0; /* must return 0 on failure, not -1 */
72 return req->handle;
76 /***********************************************************************
77 * OpenEvent32W (KERNEL32.537)
79 HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name )
81 struct open_event_request *req = get_req_buffer();
83 req->access = access;
84 req->inherit = inherit;
85 server_strcpyW( req->name, name );
86 server_call( REQ_OPEN_EVENT );
87 if (req->handle == -1) return 0; /* must return 0 on failure, not -1 */
88 return req->handle;
92 /***********************************************************************
93 * EVENT_Operation
95 * Execute an event operation (set,reset,pulse).
97 static BOOL EVENT_Operation( HANDLE handle, enum event_op op )
99 struct event_op_request *req = get_req_buffer();
100 req->handle = handle;
101 req->op = op;
102 return !server_call( REQ_EVENT_OP );
106 /***********************************************************************
107 * PulseEvent (KERNEL32.557)
109 BOOL WINAPI PulseEvent( HANDLE handle )
111 return EVENT_Operation( handle, PULSE_EVENT );
115 /***********************************************************************
116 * SetEvent (KERNEL32.644)
118 BOOL WINAPI SetEvent( HANDLE handle )
120 return EVENT_Operation( handle, SET_EVENT );
124 /***********************************************************************
125 * ResetEvent (KERNEL32.586)
127 BOOL WINAPI ResetEvent( HANDLE handle )
129 return EVENT_Operation( handle, RESET_EVENT );
133 /***********************************************************************
134 * NOTE: The Win95 VWin32_Event routines given below are really low-level
135 * routines implemented directly by VWin32. The user-mode libraries
136 * implement Win32 synchronisation routines on top of these low-level
137 * primitives. We do it the other way around here :-)
140 /***********************************************************************
141 * VWin32_EventCreate (KERNEL.442)
143 HANDLE WINAPI VWin32_EventCreate(VOID)
145 HANDLE hEvent = CreateEventA( NULL, FALSE, 0, NULL );
146 return ConvertToGlobalHandle( hEvent );
149 /***********************************************************************
150 * VWin32_EventDestroy (KERNEL.443)
152 VOID WINAPI VWin32_EventDestroy(HANDLE event)
154 CloseHandle( event );
157 /***********************************************************************
158 * VWin32_EventWait (KERNEL.450)
160 VOID WINAPI VWin32_EventWait(HANDLE event)
162 SYSLEVEL_ReleaseWin16Lock();
163 WaitForSingleObject( event, INFINITE );
164 SYSLEVEL_RestoreWin16Lock();
167 /***********************************************************************
168 * VWin32_EventSet (KERNEL.451)
170 VOID WINAPI VWin32_EventSet(HANDLE event)
172 SetEvent( event );