Browse Source

MinGW: Override gai_strerror

pull/1997/head
Linus Yang 6 years ago
parent
commit
e02ad6b1bc
2 changed files with 20 additions and 0 deletions
  1. 14
      src/winsock.c
  2. 6
      src/winsock.h

14
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 static BOOL
get_conattr(HANDLE console, WORD *out_attr) get_conattr(HANDLE console, WORD *out_attr)
{ {

6
src/winsock.h

@ -98,6 +98,12 @@
#endif #endif
#define ERROR(s) ss_error(s) #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 // Missing Unix functions
#define sleep(x) Sleep((x) * 1000) #define sleep(x) Sleep((x) * 1000)
#define bzero(s,n) memset(s,0,n) #define bzero(s,n) memset(s,0,n)

Loading…
Cancel
Save