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