summaryrefslogtreecommitdiff
path: root/src/netops.c
diff options
context:
space:
mode:
authorEduardo Bart <edub4rt@gmail.com>2012-11-07 16:10:57 -0200
committerEduardo Bart <edub4rt@gmail.com>2012-11-07 16:15:09 -0200
commit345eef23741b98636ab7ac3b1a12fa5178d5912b (patch)
tree489bcfa38bf8d4365d5dc8c77ca8acecbe739a7b /src/netops.c
parentd1a69d0fff03dcd4326adb63aee6464be0cad83f (diff)
downloadlibgit2-345eef23741b98636ab7ac3b1a12fa5178d5912b.tar.gz
Move inet_pton to posix platform-compatibility layer
Diffstat (limited to 'src/netops.c')
-rw-r--r--src/netops.c52
1 files changed, 2 insertions, 50 deletions
diff --git a/src/netops.c b/src/netops.c
index 6d7d2c1c1..fa4a729bd 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -274,11 +274,11 @@ static int verify_server_cert(gitno_ssl *ssl, const char *host)
}
/* Try to parse the host as an IP address to see if it is */
- if (gitno_inet_pton(AF_INET, host, &addr4)) {
+ if (p_inet_pton(AF_INET, host, &addr4)) {
type = GEN_IPADD;
addr = &addr4;
} else {
- if(gitno_inet_pton(AF_INET6, host, &addr6)) {
+ if(p_inet_pton(AF_INET6, host, &addr6)) {
type = GEN_IPADD;
addr = &addr6;
}
@@ -597,51 +597,3 @@ int gitno_extract_host_and_port(char **host, char **port, const char *url, const
return 0;
}
-
-int gitno_inet_pton(int af, const char* src, void* dst)
-{
- /* inet_pton is only available in Windows Vista or later
- * mingw32 and cygwin give compile errors */
-#ifndef GIT_WIN32
- return inet_pton(af, src, dst);
-#else
- union {
- struct sockaddr_in6 sin6;
- struct sockaddr_in sin;
- } sa;
- size_t srcsize;
-
- switch(af)
- {
- case AF_INET:
- sa.sin.sin_family = AF_INET;
- srcsize = sizeof (sa.sin);
- break;
- case AF_INET6:
- sa.sin6.sin6_family = AF_INET6;
- srcsize = sizeof (sa.sin6);
- break;
- default:
- errno = WSAEPFNOSUPPORT;
- return -1;
- }
-
- if (WSAStringToAddress(src, af, NULL, (struct sockaddr *) &sa, &srcsize) != 0)
- {
- errno = WSAGetLastError();
- return -1;
- }
-
- switch(af)
- {
- case AF_INET:
- memcpy(dst, &sa.sin.sin_addr, sizeof(sa.sin.sin_addr));
- break;
- case AF_INET6:
- memcpy(dst, &sa.sin6.sin6_addr, sizeof(sa.sin6.sin6_addr));
- break;
- }
-
- return 1;
-#endif
-}