Diff

Not logged in

Differences From Artifact [81fbdf8d3c153cba]:

To Artifact [96d84048875125a5]:


3 3 * * 4 4 * Windows API header module * 5 5 * * 6 6 * Translated from MinGW Windows headers * 7 7 * by Daniel Keep * 8 8 \***********************************************************************/ 9 9 module win32.winsock2; 10 -pragma(lib, "Ws2_32.lib"); 10 +pragma(lib, "Ws2_32"); 11 11 12 12 /* 13 13 Definitions for winsock 2 14 14 15 15 Contributed by the WINE project. 16 16 17 17 Portions Copyright (c) 1980, 1983, 1988, 1993 ................................................................................ 606 606 NO_RECOVERY = WSANO_RECOVERY, 607 607 NO_DATA = WSANO_DATA, 608 608 NO_ADDRESS = WSANO_ADDRESS 609 609 } 610 610 611 611 extern (Windows) { 612 612 SOCKET accept(SOCKET, SOCKADDR*, int*); 613 - int bind(SOCKET, CPtr!(SOCKADDR), int); 613 + int bind(SOCKET, const(SOCKADDR)*, int); 614 614 int closesocket(SOCKET); 615 - int connect(SOCKET, CPtr!(SOCKADDR), int); 615 + int connect(SOCKET, const(SOCKADDR)*, int); 616 616 int ioctlsocket(SOCKET, int, u_long*); 617 617 int getpeername(SOCKET, SOCKADDR*, int*); 618 618 int getsockname(SOCKET, SOCKADDR*, int*); 619 619 int getsockopt(SOCKET, int, int, void*, int*); 620 - uint inet_addr(CPtr!(char)); 620 + uint inet_addr(const(char)*); 621 621 int listen(SOCKET, int); 622 622 int recv(SOCKET, ubyte*, int, int); 623 623 int recvfrom(SOCKET, ubyte*, int, int, SOCKADDR*, int*); 624 - int send(SOCKET, CPtr!(ubyte), int, int); 625 - int sendto(SOCKET, CPtr!(ubyte), int, int, CPtr!(SOCKADDR), int); 626 - int setsockopt(SOCKET, int, int, CPtr!(void), int); 624 + int send(SOCKET, const(ubyte)*, int, int); 625 + int sendto(SOCKET, const(ubyte)*, int, int, const(SOCKADDR)*, int); 626 + int setsockopt(SOCKET, int, int, const(void)*, int); 627 627 int shutdown(SOCKET, int); 628 628 SOCKET socket(int, int, int); 629 629 630 630 alias typeof(&accept) LPFN_ACCEPT; 631 631 alias typeof(&bind) LPFN_BIND; 632 632 alias typeof(&closesocket) LPFN_CLOSESOCKET; 633 633 alias typeof(&connect) LPFN_CONNECT; ................................................................................ 644 644 alias typeof(&setsockopt) LPFN_SETSOCKOPT; 645 645 alias typeof(&shutdown) LPFN_SHUTDOWN; 646 646 alias typeof(&socket) LPFN_SOCKET; 647 647 } 648 648 649 649 extern(Windows) { 650 650 char* inet_ntoa(IN_ADDR); 651 - HOSTENT* gethostbyaddr(CPtr!(char), int, int); 652 - HOSTENT* gethostbyname(CPtr!(char)); 653 - SERVENT* getservbyport(int, CPtr!(char)); 654 - SERVENT* getservbyname(CPtr!(char), CPtr!(char)); 651 + HOSTENT* gethostbyaddr(const(char)*, int, int); 652 + HOSTENT* gethostbyname(const(char)*); 653 + SERVENT* getservbyport(int, const(char)*); 654 + SERVENT* getservbyname(const(char)*, const(char)*); 655 655 PROTOENT* getprotobynumber(int); 656 - PROTOENT* getprotobyname(CPtr!(char)); 656 + PROTOENT* getprotobyname(const(char)*); 657 657 658 658 /* NOTE: DK: in the original headers, these were declared with 659 659 PASCAL linkage. Since this is at odds with the definition 660 660 of the functions themselves, and also since MinGW seems to 661 661 treat the two interchangably, I have moved them here. */ 662 662 alias typeof(&inet_ntoa) LPFN_INET_NTOA; 663 663 alias typeof(&gethostbyaddr) LPFN_GETHOSTBYADDR; ................................................................................ 693 693 alias typeof(&WSAIsBlocking) LPFN_WSAISBLOCKING; 694 694 alias typeof(&WSAUnhookBlockingHook) LPFN_WSAUNHOOKBLOCKINGHOOK; 695 695 alias typeof(&WSASetBlockingHook) LPFN_WSASETBLOCKINGHOOK; 696 696 alias typeof(&WSACancelBlockingCall) LPFN_WSACANCELBLOCKINGCALL; 697 697 } 698 698 699 699 extern(Windows) { 700 - HANDLE WSAAsyncGetServByName(HWND, u_int, CPtr!(char), CPtr!(char), char*, int); 701 - HANDLE WSAAsyncGetServByPort(HWND, u_int, int, CPtr!(char), char*, int); 702 - HANDLE WSAAsyncGetProtoByName(HWND, u_int, CPtr!(char), char*, int); 700 + HANDLE WSAAsyncGetServByName(HWND, u_int, const(char)*, const(char)*, char*, int); 701 + HANDLE WSAAsyncGetServByPort(HWND, u_int, int, const(char)*, char*, int); 702 + HANDLE WSAAsyncGetProtoByName(HWND, u_int, const(char)*, char*, int); 703 703 HANDLE WSAAsyncGetProtoByNumber(HWND, u_int, int, char*, int); 704 - HANDLE WSAAsyncGetHostByName(HWND, u_int, CPtr!(char), char*, int); 705 - HANDLE WSAAsyncGetHostByAddr(HWND, u_int, CPtr!(char), int, int, char*, int); 704 + HANDLE WSAAsyncGetHostByName(HWND, u_int, const(char)*, char*, int); 705 + HANDLE WSAAsyncGetHostByAddr(HWND, u_int, const(char)*, int, int, char*, int); 706 706 int WSACancelAsyncRequest(HANDLE); 707 707 int WSAAsyncSelect(SOCKET, HWND, u_int, long); 708 708 709 709 alias typeof(&WSAAsyncGetServByName) LPFN_WSAAsyncGetServByName; 710 710 alias typeof(&WSAAsyncGetServByPort) LPFN_WSAASYNCGETSERVBYPORT; 711 711 alias typeof(&WSAAsyncGetProtoByName) LPFN_WSAASYNCGETPROTOBYNAME; 712 712 alias typeof(&WSAAsyncGetProtoByNumber) LPFN_WSAASYNCGETPROTOBYNUMBER; ................................................................................ 717 717 } 718 718 719 719 extern(Windows) { 720 720 u_long htonl(u_long); 721 721 u_long ntohl(u_long); 722 722 u_short htons(u_short); 723 723 u_short ntohs(u_short); 724 - int select(int nfds, fd_set*, fd_set*, fd_set*, CPtr!(TIMEVAL)); 724 + int select(int nfds, fd_set*, fd_set*, fd_set*, const(TIMEVAL)*); 725 725 726 726 alias typeof(&htonl) LPFN_HTONL; 727 727 alias typeof(&ntohl) LPFN_NTOHL; 728 728 alias typeof(&htons) LPFN_HTONS; 729 729 alias typeof(&ntohs) LPFN_NTOHS; 730 730 alias typeof(&select) LPFN_SELECT; 731 731 ................................................................................ 765 765 const int SO_PROTOCOL_INFO = SO_PROTOCOL_INFOA; 766 766 767 767 const PVD_CONFIG = 0x3001; 768 768 769 769 const MSG_INTERRUPT = 0x10; 770 770 //const MSG_MAXIOVLEN = 16; // Already declared above 771 771 772 -alias HANDLE WSAEVENT; 773 -alias LPHANDLE LPWSAEVENT; 772 +mixin DECLARE_HANDLE!("WSAEVENT"); 773 +alias WSAEVENT* LPWSAEVENT; 774 774 alias OVERLAPPED WSAOVERLAPPED; 775 775 alias OVERLAPPED* LPWSAOVERLAPPED; 776 776 777 777 private import win32.winerror; 778 778 private import win32.winbase; 779 779 780 780 enum { ................................................................................ 782 782 WSA_IO_INCOMPLETE = ERROR_IO_INCOMPLETE, 783 783 WSA_INVALID_HANDLE = ERROR_INVALID_HANDLE, 784 784 WSA_INVALID_PARAMETER = ERROR_INVALID_PARAMETER, 785 785 WSA_NOT_ENOUGH_MEMORY = ERROR_NOT_ENOUGH_MEMORY, 786 786 WSA_OPERATION_ABORTED = ERROR_OPERATION_ABORTED 787 787 } 788 788 789 -const WSA_INVALID_EVENT = cast(WSAEVENT)null; 789 +const WSA_INVALID_EVENT = cast(WSAEVENT)HANDLE.init; 790 790 const WSA_MAXIMUM_WAIT_EVENTS = MAXIMUM_WAIT_OBJECTS; 791 791 const WSA_WAIT_FAILED = cast(DWORD)-1; 792 792 const WSA_WAIT_EVENT_0 = WAIT_OBJECT_0; 793 793 const WSA_WAIT_IO_COMPLETION = WAIT_IO_COMPLETION; 794 794 const WSA_WAIT_TIMEOUT = WAIT_TIMEOUT; 795 795 const WSA_INFINITE = INFINITE; 796 796 ................................................................................ 1308 1308 1309 1309 1310 1310 extern(Windows) { 1311 1311 SOCKET WSAAccept(SOCKET, SOCKADDR*, LPINT, LPCONDITIONPROC, DWORD); 1312 1312 INT WSAAddressToStringA(LPSOCKADDR, DWORD, LPWSAPROTOCOL_INFOA, LPSTR, LPDWORD); 1313 1313 INT WSAAddressToStringW(LPSOCKADDR, DWORD, LPWSAPROTOCOL_INFOW, LPWSTR, LPDWORD); 1314 1314 BOOL WSACloseEvent(WSAEVENT); 1315 - int WSAConnect(SOCKET, CPtr!(SOCKADDR), int, LPWSABUF, LPWSABUF, LPQOS, LPQOS); 1315 + int WSAConnect(SOCKET, const(SOCKADDR)*, int, LPWSABUF, LPWSABUF, LPQOS, LPQOS); 1316 1316 WSAEVENT WSACreateEvent(); 1317 1317 int WSADuplicateSocketA(SOCKET, DWORD, LPWSAPROTOCOL_INFOA); 1318 1318 int WSADuplicateSocketW(SOCKET, DWORD, LPWSAPROTOCOL_INFOW); 1319 1319 INT WSAEnumNameSpaceProvidersA(LPDWORD, LPWSANAMESPACE_INFOA); 1320 1320 INT WSAEnumNameSpaceProvidersW(LPDWORD, LPWSANAMESPACE_INFOW); 1321 1321 int WSAEnumNetworkEvents(SOCKET, WSAEVENT, LPWSANETWORKEVENTS); 1322 1322 int WSAEnumProtocolsA(LPINT, LPWSAPROTOCOL_INFOA, LPDWORD); ................................................................................ 1329 1329 INT WSAGetServiceClassNameByClassIdA(LPGUID, LPSTR, LPDWORD); 1330 1330 INT WSAGetServiceClassNameByClassIdW(LPGUID, LPWSTR, LPDWORD); 1331 1331 int WSAHtonl(SOCKET, uint, uint*); 1332 1332 int WSAHtons(SOCKET, ushort, ushort*); 1333 1333 INT WSAInstallServiceClassA(LPWSASERVICECLASSINFOA); 1334 1334 INT WSAInstallServiceClassW(LPWSASERVICECLASSINFOW); 1335 1335 int WSAIoctl(SOCKET, DWORD, LPVOID, DWORD, LPVOID, DWORD, LPDWORD, LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE); 1336 - SOCKET WSAJoinLeaf(SOCKET, CPtr!(SOCKADDR), int, LPWSABUF, LPWSABUF, LPQOS, LPQOS, DWORD); 1336 + SOCKET WSAJoinLeaf(SOCKET, const(SOCKADDR)*, int, LPWSABUF, LPWSABUF, LPQOS, LPQOS, DWORD); 1337 1337 INT WSALookupServiceBeginA(LPWSAQUERYSETA, DWORD, LPHANDLE); 1338 1338 INT WSALookupServiceBeginW(LPWSAQUERYSETW lpqsRestrictions, DWORD, LPHANDLE); 1339 1339 INT WSALookupServiceNextA(HANDLE, DWORD, LPDWORD, LPWSAQUERYSETA); 1340 1340 INT WSALookupServiceNextW(HANDLE, DWORD, LPDWORD, LPWSAQUERYSETW); 1341 1341 INT WSALookupServiceEnd(HANDLE); 1342 1342 int WSANSPIoctl(HANDLE,DWORD,LPVOID,DWORD,LPVOID,DWORD,LPDWORD,LPWSACOMPLETION); /* XP or .NET Server */ 1343 1343 int WSANtohl(SOCKET, uint, uint*); ................................................................................ 1345 1345 int WSARecv(SOCKET, LPWSABUF, DWORD, LPDWORD, LPDWORD, LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE); 1346 1346 int WSARecvDisconnect(SOCKET, LPWSABUF); 1347 1347 int WSARecvFrom(SOCKET, LPWSABUF, DWORD, LPDWORD, LPDWORD, SOCKADDR*, LPINT, LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE); 1348 1348 INT WSARemoveServiceClass(LPGUID); 1349 1349 BOOL WSAResetEvent(WSAEVENT); 1350 1350 int WSASend(SOCKET, LPWSABUF, DWORD, LPDWORD, DWORD, LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE); 1351 1351 int WSASendDisconnect(SOCKET, LPWSABUF); 1352 - int WSASendTo(SOCKET, LPWSABUF, DWORD, LPDWORD, DWORD, CPtr!(SOCKADDR), int, LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE); 1352 + int WSASendTo(SOCKET, LPWSABUF, DWORD, LPDWORD, DWORD, const(SOCKADDR)*, int, LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE); 1353 1353 BOOL WSASetEvent(WSAEVENT); 1354 1354 INT WSASetServiceA(LPWSAQUERYSETA, WSAESETSERVICEOP, DWORD); // NB: was declared with "WSAAPI" linkage 1355 1355 INT WSASetServiceW(LPWSAQUERYSETW, WSAESETSERVICEOP, DWORD); 1356 1356 SOCKET WSASocketA(int, int, int, LPWSAPROTOCOL_INFOA, GROUP, DWORD); 1357 1357 SOCKET WSASocketW(int, int, int, LPWSAPROTOCOL_INFOW, GROUP, DWORD); 1358 1358 INT WSAStringToAddressA(LPSTR, INT, LPWSAPROTOCOL_INFOA, LPSOCKADDR, LPINT); 1359 1359 INT WSAStringToAddressW(LPWSTR, INT, LPWSAPROTOCOL_INFOW, LPSOCKADDR, LPINT); 1360 - DWORD WSAWaitForMultipleEvents(DWORD, CPtr!(WSAEVENT), BOOL, DWORD, BOOL); 1360 + DWORD WSAWaitForMultipleEvents(DWORD, const(WSAEVENT)*, BOOL, DWORD, BOOL); 1361 1361 1362 1362 alias typeof(&WSAAccept) LPFN_WSAACCEPT; 1363 1363 alias typeof(&WSAAddressToStringA) LPFN_WSAADDRESSTOSTRINGA; 1364 1364 alias typeof(&WSAAddressToStringW) LPFN_WSAADDRESSTOSTRINGW; 1365 1365 alias typeof(&WSACloseEvent) LPFN_WSACLOSEEVENT; 1366 1366 alias typeof(&WSAConnect) LPFN_WSACONNECT; 1367 1367 alias typeof(&WSACreateEvent) LPFN_WSACREATEEVENT;