| OLD | NEW |
| 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 /* This Source Code Form is subject to the terms of the Mozilla Public | 2 /* This Source Code Form is subject to the terms of the Mozilla Public |
| 3 * License, v. 2.0. If a copy of the MPL was not distributed with this | 3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 5 | 5 |
| 6 #include "primpl.h" | 6 #include "primpl.h" |
| 7 | 7 |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 /* | 10 /* |
| (...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2221 | 2221 |
| 2222 if (!addr || !string || !*string) | 2222 if (!addr || !string || !*string) |
| 2223 { | 2223 { |
| 2224 PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); | 2224 PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); |
| 2225 return PR_FAILURE; | 2225 return PR_FAILURE; |
| 2226 } | 2226 } |
| 2227 | 2227 |
| 2228 #if !defined(_PR_HAVE_GETADDRINFO) | 2228 #if !defined(_PR_HAVE_GETADDRINFO) |
| 2229 return pr_StringToNetAddrFB(string, addr); | 2229 return pr_StringToNetAddrFB(string, addr); |
| 2230 #else | 2230 #else |
| 2231 #if defined(_PR_INET6_PROBE) | |
| 2232 if (!_pr_ipv6_is_present()) | |
| 2233 return pr_StringToNetAddrFB(string, addr); | |
| 2234 #endif | |
| 2235 /* | 2231 /* |
| 2236 * getaddrinfo with AI_NUMERICHOST is much slower than pr_inet_aton on some | 2232 * getaddrinfo with AI_NUMERICHOST is much slower than pr_inet_aton on some |
| 2237 * platforms, such as Mac OS X (bug 404399), Linux glibc 2.10 (bug 344809), | 2233 * platforms, such as Mac OS X (bug 404399), Linux glibc 2.10 (bug 344809), |
| 2238 * and most likely others. So we only use it to convert literal IP addresses | 2234 * and most likely others. So we only use it to convert literal IP addresses |
| 2239 * that contain IPv6 scope IDs, which pr_inet_aton cannot convert. | 2235 * that contain IPv6 scope IDs, which pr_inet_aton cannot convert. |
| 2240 */ | 2236 */ |
| 2241 if (!strchr(string, '%')) | 2237 if (!strchr(string, '%')) |
| 2242 return pr_StringToNetAddrFB(string, addr); | 2238 return pr_StringToNetAddrFB(string, addr); |
| 2243 | 2239 |
| 2240 #if defined(_PR_INET6_PROBE) |
| 2241 if (!_pr_ipv6_is_present()) |
| 2242 return pr_StringToNetAddrFB(string, addr); |
| 2243 #endif |
| 2244 |
| 2244 return pr_StringToNetAddrGAI(string, addr); | 2245 return pr_StringToNetAddrGAI(string, addr); |
| 2245 #endif | 2246 #endif |
| 2246 } | 2247 } |
| 2247 | 2248 |
| 2248 #if defined(_PR_HAVE_GETADDRINFO) | 2249 #if defined(_PR_HAVE_GETADDRINFO) |
| 2249 static PRStatus pr_NetAddrToStringGNI( | 2250 static PRStatus pr_NetAddrToStringGNI( |
| 2250 const PRNetAddr *addr, char *string, PRUint32 size) | 2251 const PRNetAddr *addr, char *string, PRUint32 size) |
| 2251 { | 2252 { |
| 2252 int addrlen; | 2253 int addrlen; |
| 2253 const PRNetAddr *addrp = addr; | 2254 const PRNetAddr *addrp = addr; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2333 #if !defined(_PR_HAVE_GETADDRINFO) | 2334 #if !defined(_PR_HAVE_GETADDRINFO) |
| 2334 return pr_NetAddrToStringFB(addr, string, size); | 2335 return pr_NetAddrToStringFB(addr, string, size); |
| 2335 #else | 2336 #else |
| 2336 #if defined(_PR_INET6_PROBE) | 2337 #if defined(_PR_INET6_PROBE) |
| 2337 if (!_pr_ipv6_is_present()) | 2338 if (!_pr_ipv6_is_present()) |
| 2338 return pr_NetAddrToStringFB(addr, string, size); | 2339 return pr_NetAddrToStringFB(addr, string, size); |
| 2339 #endif | 2340 #endif |
| 2340 return pr_NetAddrToStringGNI(addr, string, size); | 2341 return pr_NetAddrToStringGNI(addr, string, size); |
| 2341 #endif | 2342 #endif |
| 2342 } /* PR_NetAddrToString */ | 2343 } /* PR_NetAddrToString */ |
| OLD | NEW |