vibe.core.drivers.utils 0/1(0%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
330
340
350
360
370
380
390
400
410
420
430
440
450
460
470
480
490
500
510
520
530
540
550
/** Utility definitions for socket handling. Copyright: © 2013 RejectedSoftware e.K. Authors: Sönke Ludwig License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. */ module vibe.core.drivers.utils; import std.exception; version (Windows) { import core.sys.windows.windows; import core.sys.windows.winsock2; alias EWOULDBLOCK = WSAEWOULDBLOCK; extern(System) DWORD FormatMessageW(DWORD dwFlags, const(void)* lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, void* Arguments); class WSAErrorException : Exception { int error; this(string message, string file = __FILE__, size_t line = __LINE__) { error = WSAGetLastError(); this(message, error, file, line); } this(string message, int error, string file = __FILE__, size_t line = __LINE__) { import std.string : format; ushort* errmsg; FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, null, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), cast(LPWSTR)&errmsg, 0, null); size_t len = 0; while (errmsg[len]) len++; auto errmsgd = (cast(wchar[])errmsg[0 .. len]).idup; LocalFree(errmsg); super(format("%s: %s (%s)", message, errmsgd, error), file, line); } } alias SystemSocketException = WSAErrorException; } else alias SystemSocketException = ErrnoException; import core.sys.posix.sys.socket; static if (!is(typeof(SO_REUSEPORT))) { version (linux) enum SO_REUSEPORT = 15; else enum SO_REUSEPORT = 0x200; } T socketEnforce(T)(T value, lazy string msg = null, string file = __FILE__, size_t line = __LINE__) @trusted { return enforceEx!SystemSocketException(value, msg, file, line); }