]> Nishi Git Mirror - libw3.git/commitdiff
winsock support
authornishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Wed, 17 Jan 2024 09:27:43 +0000 (09:27 +0000)
committernishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Wed, 17 Jan 2024 09:27:43 +0000 (09:27 +0000)
git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@13 d27a3e52-49c5-7645-884c-6793ebffc270

Library/Core.c
Library/DNS.c
Library/Util.c
Makefile
config.mk

index 6ddcca0fd78d1cd664f728a4ccc1dce500267579..9becfa76e9f801137877ae0a33d897c70f1d0281 100644 (file)
@@ -8,6 +8,13 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdbool.h>
+#include <stdlib.h>
+
+
+#ifdef __MINGW32__
+#include <windows.h>
+#include <winsock.h>
+#endif
 
 #ifdef SSL_SUPPORT
 #include <openssl/ssl.h>
@@ -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
index e4d73fca244d6ee06dd8af7da19efd3bbb35416f..9e47dac13014e0f6ddfe06f34d008a4d4751293b 100644 (file)
@@ -5,8 +5,16 @@
 
 #include <stdlib.h>
 #include <string.h>
+
+#ifdef __MINGW32__
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <windows.h>
+#else
 #include <sys/socket.h>
 #include <netdb.h>
+#endif
+
 #include <stdint.h>
 #include <stdio.h>
 #include <stdbool.h>
 #include <openssl/ssl.h>
 #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));
index 8d87cd45debb721838055659881ae7d0ad80baab..de0055d28f7011eecb9181042bd7b3a0845d20e5 100644 (file)
@@ -5,6 +5,15 @@
 #include <string.h>
 #include <stdlib.h>
 
+#ifdef __MINGW32__
+#include <windows.h>
+#include <winsock.h>
+#else
+#include <netdb.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#endif
+
 #define __DEBUG_LEN 12
 
 void __W3_Debug(const char* title, const char* message){
index b1b18b5b6c0c403c5e8ea18297b2eb3a98307174..810cafb4fc6fd2cf122c0c2f7cf2d6f28cd4f4a8 100644 (file)
--- 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
index 4452ff45177521cc8eb79289895f719d086891b6..9ed53397e0f9ecb331a52642db6c88bab099b852 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -1,2 +1,2 @@
-SSL=YES
+#SSL=YES
 DEBUG=YES