Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenevent.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS WinSock 2 DLL 00004 * FILE: misc/event.c 00005 * PURPOSE: Event handling 00006 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net) 00007 * REVISIONS: 00008 * CSH 01/09-2000 Created 00009 */ 00010 00011 #include "ws2_32.h" 00012 00013 /* 00014 * @implemented 00015 */ 00016 BOOL 00017 EXPORT 00018 WSACloseEvent(IN WSAEVENT hEvent) 00019 { 00020 BOOL Success; 00021 00022 if (!WSAINITIALIZED) 00023 { 00024 WSASetLastError(WSANOTINITIALISED); 00025 return FALSE; 00026 } 00027 00028 Success = CloseHandle((HANDLE)hEvent); 00029 00030 if (!Success) 00031 WSASetLastError(WSA_INVALID_HANDLE); 00032 00033 return Success; 00034 } 00035 00036 00037 /* 00038 * @implemented 00039 */ 00040 WSAEVENT 00041 EXPORT 00042 WSACreateEvent(VOID) 00043 { 00044 HANDLE Event; 00045 00046 if (!WSAINITIALIZED) 00047 { 00048 WSASetLastError(WSANOTINITIALISED); 00049 return FALSE; 00050 } 00051 00052 Event = CreateEventW(NULL, TRUE, FALSE, NULL); 00053 00054 if (Event == INVALID_HANDLE_VALUE) 00055 WSASetLastError(WSA_INVALID_HANDLE); 00056 00057 return (WSAEVENT)Event; 00058 } 00059 00060 00061 /* 00062 * @implemented 00063 */ 00064 BOOL 00065 EXPORT 00066 WSAResetEvent(IN WSAEVENT hEvent) 00067 { 00068 BOOL Success; 00069 00070 if (!WSAINITIALIZED) 00071 { 00072 WSASetLastError(WSANOTINITIALISED); 00073 return FALSE; 00074 } 00075 00076 Success = ResetEvent((HANDLE)hEvent); 00077 00078 if (!Success) 00079 WSASetLastError(WSA_INVALID_HANDLE); 00080 00081 return Success; 00082 } 00083 00084 00085 /* 00086 * @implemented 00087 */ 00088 BOOL 00089 EXPORT 00090 WSASetEvent(IN WSAEVENT hEvent) 00091 { 00092 BOOL Success; 00093 00094 if (!WSAINITIALIZED) 00095 { 00096 WSASetLastError(WSANOTINITIALISED); 00097 return FALSE; 00098 } 00099 00100 Success = SetEvent((HANDLE)hEvent); 00101 00102 if (!Success) 00103 WSASetLastError(WSA_INVALID_HANDLE); 00104 00105 return Success; 00106 } 00107 00108 00109 /* 00110 * @implemented 00111 */ 00112 DWORD 00113 EXPORT 00114 WSAWaitForMultipleEvents(IN DWORD cEvents, 00115 IN CONST WSAEVENT FAR* lphEvents, 00116 IN BOOL fWaitAll, 00117 IN DWORD dwTimeout, 00118 IN BOOL fAlertable) 00119 { 00120 DWORD Status; 00121 00122 if (!WSAINITIALIZED) 00123 { 00124 WSASetLastError(WSANOTINITIALISED); 00125 return FALSE; 00126 } 00127 00128 Status = WaitForMultipleObjectsEx(cEvents, 00129 lphEvents, 00130 fWaitAll, 00131 dwTimeout, 00132 fAlertable); 00133 if (Status == WAIT_FAILED) 00134 { 00135 Status = GetLastError(); 00136 00137 if (Status == ERROR_NOT_ENOUGH_MEMORY) 00138 WSASetLastError(WSA_NOT_ENOUGH_MEMORY); 00139 else if (Status == ERROR_INVALID_HANDLE) 00140 WSASetLastError(WSA_INVALID_HANDLE); 00141 else 00142 WSASetLastError(WSA_INVALID_PARAMETER); 00143 00144 return WSA_WAIT_FAILED; 00145 } 00146 00147 return Status; 00148 } 00149 00150 00151 /* 00152 * @implemented 00153 */ 00154 INT 00155 EXPORT 00156 WSAEnumNetworkEvents(IN SOCKET s, 00157 IN WSAEVENT hEventObject, 00158 OUT LPWSANETWORKEVENTS lpNetworkEvents) 00159 { 00160 PCATALOG_ENTRY Provider; 00161 INT Status; 00162 INT Errno; 00163 00164 WS_DbgPrint(MID_TRACE,("Called (Socket %x, hEventObject %x, " 00165 "lpNetworkEvents %x)\n", 00166 s, 00167 hEventObject, 00168 lpNetworkEvents)); 00169 00170 if (!lpNetworkEvents) 00171 { 00172 WSASetLastError(WSAEINVAL); 00173 return SOCKET_ERROR; 00174 } 00175 00176 if (!WSAINITIALIZED) 00177 { 00178 WSASetLastError(WSANOTINITIALISED); 00179 return SOCKET_ERROR; 00180 } 00181 00182 if (!ReferenceProviderByHandle((HANDLE)s, 00183 &Provider)) 00184 { 00185 WSASetLastError(WSAENOTSOCK); 00186 return SOCKET_ERROR; 00187 } 00188 00189 Status = Provider->ProcTable.lpWSPEnumNetworkEvents(s, 00190 hEventObject, 00191 lpNetworkEvents, 00192 &Errno); 00193 00194 DereferenceProviderByPointer(Provider); 00195 00196 if (Status == SOCKET_ERROR) 00197 WSASetLastError(Errno); 00198 00199 WS_DbgPrint(MID_TRACE,("Leaving %x\n", Status)); 00200 00201 return Status; 00202 } 00203 00204 00205 /* 00206 * @implemented 00207 */ 00208 INT 00209 EXPORT 00210 WSAEventSelect(IN SOCKET s, 00211 IN WSAEVENT hEventObject, 00212 IN LONG lNetworkEvents) 00213 { 00214 PCATALOG_ENTRY Provider; 00215 INT Status; 00216 INT Errno; 00217 00218 if (!WSAINITIALIZED) 00219 { 00220 WSASetLastError(WSANOTINITIALISED); 00221 return SOCKET_ERROR; 00222 } 00223 00224 if (!ReferenceProviderByHandle((HANDLE)s, &Provider)) 00225 { 00226 WSASetLastError(WSAENOTSOCK); 00227 return SOCKET_ERROR; 00228 } 00229 00230 Status = Provider->ProcTable.lpWSPEventSelect(s, 00231 hEventObject, 00232 lNetworkEvents, 00233 &Errno); 00234 00235 DereferenceProviderByPointer(Provider); 00236 00237 if (Status == SOCKET_ERROR) 00238 WSASetLastError(Errno); 00239 00240 return Status; 00241 } 00242 00243 /* EOF */ Generated on Sat May 26 2012 04:23:19 for ReactOS by
1.7.6.1
|