From 4230a9ae3283c99bdd5d388eb951fd1827f7350a Mon Sep 17 00:00:00 2001 From: bol-van Date: Fri, 17 Jun 2022 14:57:20 +0300 Subject: [PATCH] mdig: mingw build --- mdig/mdig.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/mdig/mdig.c b/mdig/mdig.c index 9728789..823d8a1 100644 --- a/mdig/mdig.c +++ b/mdig/mdig.c @@ -4,9 +4,12 @@ // errors, verbose >stderr // transparent for valid ip or ip/subnet of allowed address family +// can be compiled in mingw using posix thread compiler version + #define _GNU_SOURCE #include +#include #include #include #include @@ -14,10 +17,18 @@ #include #include #include +#ifdef _WIN32 +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x600 +#include +#include +#include +#else #include #include #include #include +#endif #include #define RESOLVER_EAGAIN_ATTEMPTS 2 @@ -56,8 +67,10 @@ static const char* eai_str(int r) return "EAI_SERVICE"; case EAI_SOCKTYPE: return "EAI_SOCKTYPE"; +#ifdef EAI_SYSTEM case EAI_SYSTEM: return "EAI_SYSTEM"; +#endif default: return "UNKNOWN"; } @@ -362,5 +375,13 @@ int main(int argc, char **argv) break; } } +#ifdef _WIN32 + WSADATA wsaData; + if (WSAStartup(MAKEWORD(2, 2), &wsaData)) + { + fprintf(stderr,"WSAStartup failed. error %u\n",GetLastError()); + return 1; + } +#endif return run_threads(); }