| 1 | /* | 
|---|
| 2 | * based on Windows Sockets 1.1 specs | 
|---|
| 3 | * (ftp.microsoft.com:/Advsys/winsock/spec11/WINSOCK.TXT) | 
|---|
| 4 | * | 
|---|
| 5 | * (C) 1993,1994,1996,1997 John Brezak, Erik Bos, Alex Korobka. | 
|---|
| 6 | * | 
|---|
| 7 | * NOTE: If you make any changes to fix a particular app, make sure | 
|---|
| 8 | * they don't break something else like Netscape or telnet and ftp | 
|---|
| 9 | * clients and servers (www.winsite.com got a lot of those). | 
|---|
| 10 | * | 
|---|
| 11 | * NOTE 2: Many winsock structs such as servent, hostent, protoent, ... | 
|---|
| 12 | * are used with 1-byte alignment for Win16 programs and 4-byte alignment | 
|---|
| 13 | * for Win32 programs in winsock.h. winsock2.h uses forced 4-byte alignment. | 
|---|
| 14 | * So we have non-forced (just as MSDN) ws_XXXXent (winsock.h), 4-byte forced | 
|---|
| 15 | * ws_XXXXent32 (winsock2.h) and 1-byte forced ws_XXXXent16 (winsock16.h). | 
|---|
| 16 | */ | 
|---|
| 17 |  | 
|---|
| 18 | #include <odin.h> | 
|---|
| 19 | #include <winsock2.h> | 
|---|
| 20 | #include <debugtools.h> | 
|---|
| 21 |  | 
|---|
| 22 | /*********************************************************************** | 
|---|
| 23 | *      WSACreateEvent()          (WS2_32.???) | 
|---|
| 24 | * | 
|---|
| 25 | */ | 
|---|
| 26 | WSAEVENT WINAPI WSACreateEvent(void) | 
|---|
| 27 | { | 
|---|
| 28 | /* Create a manual-reset event, with initial state: unsignealed */ | 
|---|
| 29 | TRACE("WSACreateEvent"); | 
|---|
| 30 |  | 
|---|
| 31 | return CreateEventA(NULL, TRUE, FALSE, NULL); | 
|---|
| 32 | } | 
|---|
| 33 |  | 
|---|
| 34 | BOOL WINAPI WSASetEvent(WSAEVENT hEvent) | 
|---|
| 35 | { | 
|---|
| 36 | TRACE("WSASetEvent"); | 
|---|
| 37 | return SetEvent(hEvent); | 
|---|
| 38 | } | 
|---|
| 39 |  | 
|---|
| 40 | /*********************************************************************** | 
|---|
| 41 | *      WSACloseEvent()          (WS2_32.???) | 
|---|
| 42 | * | 
|---|
| 43 | */ | 
|---|
| 44 | BOOL WINAPI WSACloseEvent(WSAEVENT event) | 
|---|
| 45 | { | 
|---|
| 46 | TRACE ("WSACloseEvent event=0x%x\n", event); | 
|---|
| 47 |  | 
|---|
| 48 | return CloseHandle(event); | 
|---|
| 49 | } | 
|---|
| 50 |  | 
|---|
| 51 | /*********************************************************************** | 
|---|
| 52 | *      WSASocketA()          (WS2_32.???) | 
|---|
| 53 | * | 
|---|
| 54 | */ | 
|---|
| 55 | SOCKET WINAPI WSASocketA(int af, int type, int protocol, | 
|---|
| 56 | LPWSAPROTOCOL_INFOA lpProtocolInfo, | 
|---|
| 57 | GROUP g, DWORD dwFlags) | 
|---|
| 58 | { | 
|---|
| 59 | /* | 
|---|
| 60 | FIXME: The "advanced" parameters of WSASocketA (lpProtocolInfo, | 
|---|
| 61 | g, dwFlags) are ignored. | 
|---|
| 62 | */ | 
|---|
| 63 |  | 
|---|
| 64 | TRACE("WSASocketA af=%d type=%d protocol=%d protocol_info=%p group=%d flags=0x%lx\n", | 
|---|
| 65 | af, type, protocol, lpProtocolInfo, g, dwFlags ); | 
|---|
| 66 |  | 
|---|
| 67 | return ( socket (af, type, protocol) ); | 
|---|
| 68 | } | 
|---|
| 69 |  | 
|---|
| 70 | /*********************************************************************** | 
|---|
| 71 | *      WSASocketA()          (WS2_32.???) | 
|---|
| 72 | * | 
|---|
| 73 | */ | 
|---|
| 74 | SOCKET WINAPI WSASocketW(int af, int type, int protocol, | 
|---|
| 75 | LPWSAPROTOCOL_INFOW lpProtocolInfo, | 
|---|
| 76 | GROUP g, DWORD dwFlags) | 
|---|
| 77 | { | 
|---|
| 78 | /* | 
|---|
| 79 | FIXME: The "advanced" parameters of WSASocketA (lpProtocolInfo, | 
|---|
| 80 | g, dwFlags) are ignored. | 
|---|
| 81 | */ | 
|---|
| 82 |  | 
|---|
| 83 | TRACE("WSASocketW af=%d type=%d protocol=%d protocol_info=%p group=%d flags=0x%lx\n", | 
|---|
| 84 | af, type, protocol, lpProtocolInfo, g, dwFlags ); | 
|---|
| 85 |  | 
|---|
| 86 | return ( socket (af, type, protocol) ); | 
|---|
| 87 | } | 
|---|
| 88 |  | 
|---|
| 89 | /*********************************************************************** | 
|---|
| 90 | *              WSAEnumNetworkEvents | 
|---|
| 91 | */ | 
|---|
| 92 | int WINAPI WSAEnumNetworkEvents(SOCKET s, WSAEVENT hEvent, LPWSANETWORKEVENTS lpEvent) | 
|---|
| 93 | { | 
|---|
| 94 | dprintf(("WSAEnumNetworkEvents %x %x %x NOT IMPLEMENTED", s, hEvent, lpEvent)); | 
|---|
| 95 | SetLastError(WSAEINVAL); | 
|---|
| 96 | return SOCKET_ERROR; | 
|---|
| 97 | } | 
|---|
| 98 |  | 
|---|
| 99 | /*********************************************************************** | 
|---|
| 100 | *              WSAEventSelect | 
|---|
| 101 | */ | 
|---|
| 102 | int WINAPI WSAEventSelect(SOCKET s, WSAEVENT hEvent, LONG lEvent) | 
|---|
| 103 | { | 
|---|
| 104 | TRACE("WSAEventSelect %08x, hEvent %08x, event %08x\n", s, hEvent, (unsigned)lEvent ); | 
|---|
| 105 | SetLastError(WSAEINVAL); | 
|---|
| 106 | return SOCKET_ERROR; | 
|---|
| 107 | } | 
|---|
| 108 |  | 
|---|