diff --git a/src/winsock.c b/src/winsock.c index bcdebbd0..16197e38 100644 --- a/src/winsock.c +++ b/src/winsock.c @@ -109,6 +109,20 @@ ss_error(const char *s) } } +char * +ss_gai_strerror(int ecode) +{ + static TCHAR buff[GAI_STRERROR_BUFFER_SIZE + 1]; + FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS | + FORMAT_MESSAGE_MAX_WIDTH_MASK, + NULL, ecode, + MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), + (LPTSTR)buff, GAI_STRERROR_BUFFER_SIZE, NULL); + return (char *)buff; +} + static BOOL get_conattr(HANDLE console, WORD *out_attr) { diff --git a/src/winsock.h b/src/winsock.h index 10ea0e9d..dbb6d97e 100644 --- a/src/winsock.h +++ b/src/winsock.h @@ -98,6 +98,12 @@ #endif #define ERROR(s) ss_error(s) +#ifdef gai_strerror +#undef gai_strerror +#endif +#define gai_strerror(e) ss_gai_strerror(e) +char *ss_gai_strerror(int ecode); + // Missing Unix functions #define sleep(x) Sleep((x) * 1000) #define bzero(s,n) memset(s,0,n)