Merge pull request #1130 from nghttp2/avoid-inet_pton-macro
src: Define nghttp2_inet_pton wrapper to avoid inet_pton macro
This commit is contained in:
commit
fe51e7fa1a
16
src/util.cc
16
src/util.cc
|
@ -70,9 +70,16 @@ namespace nghttp2 {
|
||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifndef _WIN32
|
||||||
|
namespace {
|
||||||
|
int nghttp2_inet_pton(int af, const char *src, void *dst) {
|
||||||
|
return inet_pton(af, src, dst);
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
#else // _WIN32
|
||||||
|
namespace {
|
||||||
// inet_pton-wrapper for Windows
|
// inet_pton-wrapper for Windows
|
||||||
static int inet_pton(int af, const char *src, void *dst) {
|
int nghttp2_inet_pton(int af, const char *src, void *dst) {
|
||||||
#if _WIN32_WINNT >= 0x0600
|
#if _WIN32_WINNT >= 0x0600
|
||||||
return InetPtonA(af, src, dst);
|
return InetPtonA(af, src, dst);
|
||||||
#else
|
#else
|
||||||
|
@ -88,6 +95,7 @@ static int inet_pton(int af, const char *src, void *dst) {
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
const char UPPER_XDIGITS[] = "0123456789ABCDEF";
|
const char UPPER_XDIGITS[] = "0123456789ABCDEF";
|
||||||
|
@ -662,7 +670,7 @@ bool numeric_host(const char *hostname, int family) {
|
||||||
int rv;
|
int rv;
|
||||||
std::array<uint8_t, sizeof(struct in6_addr)> dst;
|
std::array<uint8_t, sizeof(struct in6_addr)> dst;
|
||||||
|
|
||||||
rv = inet_pton(family, hostname, dst.data());
|
rv = nghttp2_inet_pton(family, hostname, dst.data());
|
||||||
|
|
||||||
return rv == 1;
|
return rv == 1;
|
||||||
}
|
}
|
||||||
|
@ -959,7 +967,7 @@ int get_socket_error(int fd) {
|
||||||
|
|
||||||
bool ipv6_numeric_addr(const char *host) {
|
bool ipv6_numeric_addr(const char *host) {
|
||||||
uint8_t dst[16];
|
uint8_t dst[16];
|
||||||
return inet_pton(AF_INET6, host, dst) == 1;
|
return nghttp2_inet_pton(AF_INET6, host, dst) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
Loading…
Reference in New Issue