From 66714e2c47bb0ff55e6f8360301af833f879b6ac Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Mon, 9 Nov 2020 11:46:01 +0100
Subject: [PATCH] wincompat: recent mingw has inet_ntop/inet_pton

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 src/wincompat/compat.h |  2 --
 src/wincompat/libc.c   | 36 ------------------------------------
 2 files changed, 38 deletions(-)

diff --git a/src/wincompat/compat.h b/src/wincompat/compat.h
index 643c11d..4c5b368 100644
--- a/src/wincompat/compat.h
+++ b/src/wincompat/compat.h
@@ -25,5 +25,3 @@
 char *strsep(char **str, const char *sep);
 ssize_t getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp);
 ssize_t getline(char **buf, size_t *bufsiz, FILE *fp);
-int inet_pton(int af, const char *src, void *dst);
-const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
diff --git a/src/wincompat/libc.c b/src/wincompat/libc.c
index 870d913..3138370 100644
--- a/src/wincompat/libc.c
+++ b/src/wincompat/libc.c
@@ -6,8 +6,6 @@
 #include <stdio.h>
 #include <stdbool.h>
 #include <stdint.h>
-#include <winsock2.h>
-#include <ws2tcpip.h>
 #include <windows.h>
 
 char *strsep(char **str, const char *sep)
@@ -69,37 +67,3 @@ ssize_t getline(char **buf, size_t *bufsiz, FILE *fp)
 {
 	return getdelim(buf, bufsiz, '\n', fp);
 }
-
-int inet_pton(int af, const char *src, void *dst)
-{
-	struct sockaddr_storage ss = { 0 };
-	int size = sizeof(ss);
-	char s[INET6_ADDRSTRLEN + 1];
-
-	strncpy(s, src, INET6_ADDRSTRLEN + 1);
-	s[INET6_ADDRSTRLEN] = '\0';
-
-	if (WSAStringToAddress(s, af, NULL, (struct sockaddr *)&ss, &size))
-		return 0;
-	if (af == AF_INET)
-		*(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr;
-	else if (af == AF_INET6)
-		*(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr;
-	else
-		return 0;
-	return 1;
-}
-
-const char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
-{
-	struct sockaddr_storage ss = { .ss_family = af };
-	unsigned long s = size;
-
-	if (af == AF_INET)
-		((struct sockaddr_in *)&ss)->sin_addr = *(struct in_addr *)src;
-	else if (af == AF_INET6)
-		((struct sockaddr_in6 *)&ss)->sin6_addr = *(struct in6_addr *)src;
-	else
-		return NULL;
-	return WSAAddressToString((struct sockaddr *)&ss, sizeof(ss), NULL, dst, &s) ? NULL : dst;
-}