Created
January 6, 2017 10:01
-
-
Save pcan/7303c7cd5ee75cf93e6ea0e7b8997fb8 to your computer and use it in GitHub Desktop.
gai_strerror Shim for Luasocket static lib (compiled with MinGW)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Specify the following options for the linker: | |
-Wl,--enable-stdcall-fixup | |
*/ | |
#include "ws2tcpip.h" | |
char * | |
gai_strerrorA( | |
_In_ int ecode) | |
{ | |
DWORD dwMsgLen; | |
static char buff[GAI_STRERROR_BUFFER_SIZE + 1]; | |
dwMsgLen = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | |
|FORMAT_MESSAGE_IGNORE_INSERTS | |
|FORMAT_MESSAGE_MAX_WIDTH_MASK, | |
NULL, | |
ecode, | |
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | |
(LPSTR)buff, | |
GAI_STRERROR_BUFFER_SIZE, | |
NULL); | |
return buff; | |
} | |
WCHAR * | |
gai_strerrorW( | |
_In_ int ecode | |
) | |
{ | |
DWORD dwMsgLen; | |
static WCHAR buff[GAI_STRERROR_BUFFER_SIZE + 1]; | |
dwMsgLen = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | |
|FORMAT_MESSAGE_IGNORE_INSERTS | |
|FORMAT_MESSAGE_MAX_WIDTH_MASK, | |
NULL, | |
ecode, | |
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | |
(LPWSTR)buff, | |
GAI_STRERROR_BUFFER_SIZE, | |
NULL); | |
return buff; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment