authorgravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2019-11-13 18:23:21+11:00
committergravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2019-11-14 17:09:22+11:00
log4cf535a01b06c301239fb888dbdf87831c568867
tree90f6e4275f1f870589a937581f6dd722d85d0646
parentd9d3268cc1fe6b581ccb44606346cb6847d557a5
signaturelock-open Commit is signed but in an unrecognized format.

std: add WSASocketW for windows


1 files changed, 25 insertions(+), 0 deletions(-)

lib/std/os/windows.zig+25
......@@ -608,6 +608,27 @@ pub fn GetFileAttributesW(lpFileName: [*]const u16) GetFileAttributesError!DWORD
608608 return rc;
609609}
610610
611pub fn WSASocketW(
612 af: i32,
613 socket_type: i32,
614 protocol: i32,
615 protocolInfo: ?*ws2_32.WSAPROTOCOL_INFOW,
616 g: ws2_32.GROUP,
617 dwFlags: DWORD,
618) !ws2_32.SOCKET {
619 const rc = ws2_32.WSASocketW(af, socket_type, protocol, protocolInfo, g, dwFlags);
620 if (rc == ws2_32.INVALID_SOCKET) {
621 switch (ws2_32.WSAGetLastError()) {
622 ws2_32.WSAEAFNOSUPPORT => return error.AddressFamilyNotSupported,
623 ws2_32.WSAEMFILE => return error.ProcessFdQuotaExceeded,
624 ws2_32.WSAENOBUFS => return error.SystemResources,
625 ws2_32.WSAEPROTONOSUPPORT => return error.ProtocolNotSupported,
626 else => |err| return unexpectedWSAError(err),
627 }
628 }
629 return rc;
630}
631
611632const GetModuleFileNameError = error{Unexpected};
612633
613634pub fn GetModuleFileNameW(hModule: ?HMODULE, buf_ptr: [*]u16, buf_len: DWORD) GetModuleFileNameError![]u16 {
......@@ -905,6 +926,10 @@ pub fn unexpectedError(err: DWORD) std.os.UnexpectedError {
905926 return error.Unexpected;
906927}
907928
929pub fn unexpectedWSAError(err: c_int) std.os.UnexpectedError {
930 return unexpectedError(@intCast(DWORD, err));
931}
932
908933/// Call this when you made a windows NtDll call
909934/// and you get an unexpected status.
910935pub fn unexpectedStatus(status: NTSTATUS) std.os.UnexpectedError {