1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: ReactOS WinSock 2 API 4 * FILE: dll/win32/ws2_32/src/event.c 5 * PURPOSE: Socket Events 6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net) 7 */ 8 9 /* INCLUDES ******************************************************************/ 10 11 #include <ws2_32.h> 12 13 #define NDEBUG 14 #include <debug.h> 15 16 /* FUNCTIONS *****************************************************************/ 17 18 /* 19 * @implemented 20 */ 21 BOOL 22 WSAAPI 23 WSACloseEvent(IN WSAEVENT hEvent) 24 { 25 BOOL Success; 26 27 /* Let the OS handle it */ 28 Success = CloseHandle(hEvent); 29 30 /* We need a special WSA return error */ 31 if (!Success) WSASetLastError(WSA_INVALID_HANDLE); 32 33 /* Return the Win32 Error */ 34 return Success; 35 } 36 37 /* 38 * @implemented 39 */ 40 WSAEVENT 41 WSAAPI 42 WSACreateEvent(VOID) 43 { 44 /* CreateEventW can only return the Event or 0 (WSA_INVALID_EVENT) */ 45 return CreateEventW(NULL, TRUE, FALSE, NULL); 46 } 47 48 /* 49 * @implemented 50 */ 51 BOOL 52 WSAAPI 53 WSAResetEvent(IN WSAEVENT hEvent) 54 { 55 /* Call Win32 */ 56 return ResetEvent(hEvent); 57 } 58 59 /* 60 * @implemented 61 */ 62 BOOL 63 WSAAPI 64 WSASetEvent(IN WSAEVENT hEvent) 65 { 66 /* Call Win32 */ 67 return SetEvent(hEvent); 68 } 69 70 /* 71 * @implemented 72 */ 73 DWORD 74 WSAAPI 75 WSAWaitForMultipleEvents(IN DWORD cEvents, 76 IN CONST WSAEVENT FAR* lphEvents, 77 IN BOOL fWaitAll, 78 IN DWORD dwTimeout, 79 IN BOOL fAlertable) 80 { 81 /* Call Win32 */ 82 return WaitForMultipleObjectsEx(cEvents, 83 lphEvents, 84 fWaitAll, 85 dwTimeout, 86 fAlertable); 87 } 88 89 /* 90 * @implemented 91 */ 92 INT 93 WSAAPI 94 WSAEnumNetworkEvents(IN SOCKET s, 95 IN WSAEVENT hEventObject, 96 OUT LPWSANETWORKEVENTS lpNetworkEvents) 97 { 98 PWSSOCKET Socket; 99 INT Status; 100 INT ErrorCode; 101 DPRINT("WSAEnumNetworkEvents: %lx\n", s); 102 103 /* Check for WSAStartup */ 104 if ((ErrorCode = WsQuickProlog()) == ERROR_SUCCESS) 105 { 106 /* Get the Socket Context */ 107 if ((Socket = WsSockGetSocket(s))) 108 { 109 /* Make the call */ 110 Status = Socket->Provider->Service.lpWSPEnumNetworkEvents(s, 111 hEventObject, 112 lpNetworkEvents, 113 &ErrorCode); 114 /* Deference the Socket Context */ 115 WsSockDereference(Socket); 116 117 /* Return Provider Value */ 118 if (Status == ERROR_SUCCESS) return Status; 119 } 120 else 121 { 122 /* No Socket Context Found */ 123 ErrorCode = WSAENOTSOCK; 124 } 125 } 126 127 /* Return with an Error */ 128 SetLastError(ErrorCode); 129 return SOCKET_ERROR; 130 } 131 132