From 02e326f18c173c68b4baa281966118ad41f6862f Mon Sep 17 00:00:00 2001 From: nishi Date: Wed, 17 Jan 2024 09:27:43 +0000 Subject: [PATCH] winsock support git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@13 d27a3e52-49c5-7645-884c-6793ebffc270 --- Library/Core.c | 11 +++++++++++ Library/DNS.c | 18 +++++++++++++++--- Library/Util.c | 9 +++++++++ Makefile | 4 ++++ config.mk | 2 +- 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/Library/Core.c b/Library/Core.c index 6ddcca0..9becfa7 100644 --- a/Library/Core.c +++ b/Library/Core.c @@ -8,6 +8,13 @@ #include #include #include +#include + + +#ifdef __MINGW32__ +#include +#include +#endif #ifdef SSL_SUPPORT #include @@ -22,6 +29,10 @@ int W3_Library_Init(void){ return 1; } #endif +#ifdef __MINGW32__ + WSADATA wsa; + WSAStartup(MAKEWORD(2, 2), &wsa); +#endif #ifdef SSL_SUPPORT __W3_Debug("LibW3", "This is LibW3, version " LIBW3_VERSION ", using " OPENSSL_VERSION_TEXT); #else diff --git a/Library/DNS.c b/Library/DNS.c index e4d73fc..9e47dac 100644 --- a/Library/DNS.c +++ b/Library/DNS.c @@ -5,8 +5,16 @@ #include #include + +#ifdef __MINGW32__ +#include +#include +#include +#else #include #include +#endif + #include #include #include @@ -16,6 +24,10 @@ #include #endif +#ifndef __MINGW32__ +#define ADDRINFO struct addrinfo +#endif + int __W3_DNS_Connect(const char* hostname, bool ssl, uint16_t port #ifdef SSL_SUPPORT , @@ -24,9 +36,9 @@ int __W3_DNS_Connect(const char* hostname, bool ssl, uint16_t port #endif ){ __W3_Debug("DNS-Connect", "Resolving"); - struct addrinfo hints; - struct addrinfo* result; - struct addrinfo* rp; + ADDRINFO hints; + ADDRINFO* result; + ADDRINFO* rp; int s; memset(&hints, 0, sizeof(hints)); diff --git a/Library/Util.c b/Library/Util.c index 8d87cd4..de0055d 100644 --- a/Library/Util.c +++ b/Library/Util.c @@ -5,6 +5,15 @@ #include #include +#ifdef __MINGW32__ +#include +#include +#else +#include +#include +#include +#endif + #define __DEBUG_LEN 12 void __W3_Debug(const char* title, const char* message){ diff --git a/Makefile b/Makefile index b1b18b5..810cafb 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,10 @@ CFLAGS += -DSSL_SUPPORT LIBS += -lssl -lcrypto endif +ifdef WINDOWS +LIBS += -lws2_32 +endif + ifdef DEBUG CFLAGS += -g -D__DEBUG__ endif diff --git a/config.mk b/config.mk index 4452ff4..9ed5339 100644 --- a/config.mk +++ b/config.mk @@ -1,2 +1,2 @@ -SSL=YES +#SSL=YES DEBUG=YES -- 2.43.0