Commit fa05e80c authored by Martin Storsjö's avatar Martin Storsjö

contrib: upnp: Improve and generalize a patch for handling inet_pton

libupnp locally overrides the version of _WIN32_WINNT via
configure.ac and autoconfig.h (which is disabled by a vlc contrib
patch when targeting winrt though).

Make sure that autoconfig.h is included everywhere necessary, to
show/hide the relevant parts of winsock headers depending on the
chosen version of _WIN32_WINNT (either default or overridden).

This avoids including the system declarations of these functions if
the default target is >= vista but the build tries to override it
to a lower version.

On the other hand, if the override of _WIN32_WINNT is removed (as
when targeting winrt) and the default is >= vista, skip the local
version of inet_pton.

This should have the same effect as the previous patch, but
evaluated by the preprocessor instead of hardcoding commenting out
of certain source files.
parent a57dd51b
......@@ -31,10 +31,10 @@ ifdef HAVE_WIN32
$(APPLY) $(SRC)/upnp/libupnp-win32.patch
$(APPLY) $(SRC)/upnp/libupnp-win64.patch
$(APPLY) $(SRC)/upnp/windows-random.patch
$(APPLY) $(SRC)/upnp/windows-version-inet.patch
ifdef HAVE_WINSTORE
$(APPLY) $(SRC)/upnp/winrt-dont-force-win32-winnt.patch
$(APPLY) $(SRC)/upnp/no-getifinfo.patch
$(APPLY) $(SRC)/upnp/winrt-inet.patch
endif
endif
$(APPLY) $(SRC)/upnp/libpthread.patch
......
diff -urN upnp-orig/upnp/src/inc/inet_pton.h upnp/upnp/src/inc/inet_pton.h
--- upnp-orig/upnp/src/inc/inet_pton.h 2010-12-23 22:24:06.000000000 +0200
+++ upnp/upnp/src/inc/inet_pton.h 2018-02-24 23:44:22.359676036 +0200
@@ -3,6 +3,8 @@
#ifdef WIN32
+#include "autoconfig.h"
+
#ifdef IPV6_
#define INET_IPV6
#endif
@@ -13,6 +15,8 @@
#include <stdio.h>
#include <string.h>
+#if _WIN32_WINNT < 0x600
+
/*!
* \file
*
@@ -45,6 +49,8 @@
*/
extern int inet_pton(int af, const char *src, void *dst);
+#endif /* _WIN32_WINNT < 0x600 */
+
#endif /* WIN32 */
#endif /* INET_PTON */
diff -urN upnp-orig/upnp/src/inet_pton.c upnp/upnp/src/inet_pton.c
--- upnp-orig/upnp/src/inet_pton.c 2010-12-23 22:24:06.000000000 +0200
+++ upnp/upnp/src/inet_pton.c 2018-02-24 23:44:16.771807657 +0200
@@ -24,6 +24,8 @@
#include "inet_pton.h"
+#if _WIN32_WINNT < 0x600
+
/*!
* \brief format an IPv4 address
*
@@ -320,4 +322,6 @@
/* NOTREACHED */
}
+#endif /* _WIN32_WINNT < 0x600 */
+
#endif /* WIN32 */
--- upnp/upnp/Makefile.am 2013-11-15 17:01:35.000000000 +0100
+++ upnp.new/upnp/Makefile.am 2016-05-09 19:16:43.909558923 +0200
@@ -148,9 +148,9 @@
# inet_pton (needed on Win32, compiles to nothing elsewhere)
-libupnp_la_SOURCES += \
- src/inet_pton.c \
- src/inc/inet_pton.h
+#libupnp_la_SOURCES += \
+# src/inet_pton.c \
+# src/inc/inet_pton.h
# check / distcheck tests
diff -ruN upnp.new/upnp/src/inc/inet_pton.h upnp/upnp/src/inc/inet_pton.h
--- upnp.new/upnp/src/inc/inet_pton.h 2010-12-23 21:24:06.000000000 +0100
+++ upnp/upnp/src/inc/inet_pton.h 2016-05-09 20:25:37.765374740 +0200
@@ -31,6 +31,11 @@
* \return
* pointer to presentation format address (`dst'), or NULL (see errno).
*/
+#define inet_ntop InetNtopA
+
+#define inet_pton InetPtonA
+
+#if 0
extern const char *inet_ntop(int af, const void *src, char *dst,
socklen_t size);
@@ -47,4 +52,5 @@
#endif /* WIN32 */
+#endif
#endif /* INET_PTON */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment