Mercurial > vim
comparison src/channel.c @ 20077:128963cd954f v8.2.0594
patch 8.2.0594: MS-Windows: cannot build with WINVER set to 0x0501
Commit: https://github.com/vim/vim/commit/b6fb0516ec862a18fdffe06c9400d507a7193835
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 18 18:24:18 2020 +0200
patch 8.2.0594: MS-Windows: cannot build with WINVER set to 0x0501
Problem: MS-Windows: cannot build with WINVER set to 0x0501.
Solution: Only use inet_ntop() when available. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/5946)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 18 Apr 2020 18:30:03 +0200 |
parents | aadd1cae2ff5 |
children | 456c3b98d4c8 |
comparison
equal
deleted
inserted
replaced
20076:023d3226e727 | 20077:128963cd954f |
---|---|
994 return NULL; | 994 return NULL; |
995 } | 995 } |
996 | 996 |
997 for (addr = res; addr != NULL; addr = addr->ai_next) | 997 for (addr = res; addr != NULL; addr = addr->ai_next) |
998 { | 998 { |
999 const char *dst = hostname; | 999 const char *dst = hostname; |
1000 const void *src = NULL; | 1000 const void *src = NULL; |
1001 char buf[NUMBUFLEN]; | 1001 # ifdef HAVE_INET_NTOP |
1002 char buf[NUMBUFLEN]; | |
1003 # endif | |
1002 | 1004 |
1003 if (addr->ai_family == AF_INET6) | 1005 if (addr->ai_family == AF_INET6) |
1004 { | 1006 { |
1005 struct sockaddr_in6 *sai = (struct sockaddr_in6 *)addr->ai_addr; | 1007 struct sockaddr_in6 *sai = (struct sockaddr_in6 *)addr->ai_addr; |
1006 | 1008 |
1012 struct sockaddr_in *sai = (struct sockaddr_in *)addr->ai_addr; | 1014 struct sockaddr_in *sai = (struct sockaddr_in *)addr->ai_addr; |
1013 | 1015 |
1014 sai->sin_port = htons(port); | 1016 sai->sin_port = htons(port); |
1015 src = &sai->sin_addr; | 1017 src = &sai->sin_addr; |
1016 } | 1018 } |
1019 # ifdef HAVE_INET_NTOP | |
1017 if (src != NULL) | 1020 if (src != NULL) |
1018 { | 1021 { |
1019 dst = inet_ntop(addr->ai_family, src, buf, sizeof(buf)); | 1022 dst = inet_ntop(addr->ai_family, src, buf, sizeof(buf)); |
1020 if (dst != NULL && STRCMP(hostname, dst) != 0) | 1023 if (dst == NULL) |
1024 dst = hostname; | |
1025 else if (STRCMP(hostname, dst) != 0) | |
1021 ch_log(channel, "Resolved %s to %s", hostname, dst); | 1026 ch_log(channel, "Resolved %s to %s", hostname, dst); |
1022 } | 1027 } |
1028 # endif | |
1023 | 1029 |
1024 ch_log(channel, "Trying to connect to %s port %d", dst, port); | 1030 ch_log(channel, "Trying to connect to %s port %d", dst, port); |
1025 | 1031 |
1026 // On Mac and Solaris a zero timeout almost never works. At least wait | 1032 // On Mac and Solaris a zero timeout almost never works. At least wait |
1027 // one millisecond. Let's do it for all systems, because we don't know | 1033 // one millisecond. Let's do it for all systems, because we don't know |