summaryrefslogtreecommitdiffstats
path: root/Utilities/cmcurl/lib/inet_ntop.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-03-20 20:40:49 (GMT)
committerBrad King <brad.king@kitware.com>2023-03-20 20:40:49 (GMT)
commite3dc4df9b95272037d27be25ae5ef030ffd83fa4 (patch)
tree6132bc02d5204bd988b32ee8ab06053ec7c0e4c4 /Utilities/cmcurl/lib/inet_ntop.c
parent4e6c3cd93bc870f44442e6d7e59896bc6d86ce25 (diff)
parente8bff971d9d835a65bcb1711e7214afe37b238e0 (diff)
downloadCMake-e3dc4df9b95272037d27be25ae5ef030ffd83fa4.zip
CMake-e3dc4df9b95272037d27be25ae5ef030ffd83fa4.tar.gz
CMake-e3dc4df9b95272037d27be25ae5ef030ffd83fa4.tar.bz2
Merge branch 'upstream-curl' into update-curl
* upstream-curl: curl 2023-03-20 (b16d1fa8)
Diffstat (limited to 'Utilities/cmcurl/lib/inet_ntop.c')
-rw-r--r--Utilities/cmcurl/lib/inet_ntop.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/Utilities/cmcurl/lib/inet_ntop.c b/Utilities/cmcurl/lib/inet_ntop.c
index 024f8da..770ed3a 100644
--- a/Utilities/cmcurl/lib/inet_ntop.c
+++ b/Utilities/cmcurl/lib/inet_ntop.c
@@ -42,6 +42,15 @@
#define INT16SZ 2
/*
+ * If ENABLE_IPV6 is disabled, we still want to parse IPv6 addresses, so make
+ * sure we have _some_ value for AF_INET6 without polluting our fake value
+ * everywhere.
+ */
+#if !defined(ENABLE_IPV6) && !defined(AF_INET6)
+#define AF_INET6 (AF_INET + 1)
+#endif
+
+/*
* Format an IPv4 address, more or less like inet_ntop().
*
* Returns `dst' (as a const)
@@ -72,7 +81,6 @@ static char *inet_ntop4 (const unsigned char *src, char *dst, size_t size)
return dst;
}
-#ifdef ENABLE_IPV6
/*
* Convert IPv6 binary address into presentation (printable) format.
*/
@@ -168,7 +176,6 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
strcpy(dst, tmp);
return dst;
}
-#endif /* ENABLE_IPV6 */
/*
* Convert a network format address to presentation format.
@@ -187,10 +194,8 @@ char *Curl_inet_ntop(int af, const void *src, char *buf, size_t size)
switch(af) {
case AF_INET:
return inet_ntop4((const unsigned char *)src, buf, size);
-#ifdef ENABLE_IPV6
case AF_INET6:
return inet_ntop6((const unsigned char *)src, buf, size);
-#endif
default:
errno = EAFNOSUPPORT;
return NULL;