aboutsummaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2019-05-28 22:07:33 +0100
committerSteve Holme <steve_holme@hotmail.com>2019-05-29 07:19:20 +0100
commit09eef8af18c7cc1a20f132843880f60f692d76c8 (patch)
treed62fe94b2986af1108ca71329c73238a3f092d4b /lib/url.c
parent5908009e318d070e5ba6765e47a96c61b100c273 (diff)
url: Load if_nametoindex() dynamically from iphlpapi.dll on Windows
This fixes the static dependency on iphlpapi.lib and allows curl to build for targets prior to Windows Vista. This partially reverts 170bd047. Fixes #3960 Closes #3958
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/url.c b/lib/url.c
index 086e214e4..eb22dcc37 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -95,6 +95,7 @@ bool curl_win32_idn_to_ascii(const char *in, char **out);
#include "inet_pton.h"
#include "getinfo.h"
#include "urlapi-int.h"
+#include "system_win32.h"
/* And now for the protocols */
#include "ftp.h"
@@ -1903,18 +1904,28 @@ static void zonefrom_url(CURLU *uh, struct connectdata *conn)
if(!*endp && (scope < UINT_MAX))
/* A plain number, use it directly as a scope id. */
conn->scope_id = (unsigned int)scope;
-#ifdef HAVE_IF_NAMETOINDEX
+#if defined(HAVE_IF_NAMETOINDEX)
else {
+#elif defined(WIN32)
+ else if(Curl_if_nametoindex) {
+#endif
+
+#if defined(HAVE_IF_NAMETOINDEX) || defined(WIN32)
/* Zone identifier is not numeric */
unsigned int scopeidx = 0;
+#if defined(WIN32)
+ scopeidx = Curl_if_nametoindex(zoneid);
+#else
scopeidx = if_nametoindex(zoneid);
+#endif
if(!scopeidx)
infof(conn->data, "Invalid zoneid: %s; %s\n", zoneid,
strerror(errno));
else
conn->scope_id = scopeidx;
}
-#endif /* HAVE_IF_NAMETOINDEX */
+#endif /* HAVE_IF_NAMETOINDEX || WIN32 */
+
free(zoneid);
}
}