summaryrefslogtreecommitdiff
path: root/src/compat/compat-inet_pton.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/compat/compat-inet_pton.c')
-rw-r--r--src/compat/compat-inet_pton.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/compat/compat-inet_pton.c b/src/compat/compat-inet_pton.c
index 5965f0d..1e41fa2 100644
--- a/src/compat/compat-inet_pton.c
+++ b/src/compat/compat-inet_pton.c
@@ -48,32 +48,34 @@
int
inet_pton(int af, const char *src, void *dst)
{
- struct sockaddr_storage ss;
- int size = sizeof(ss);
- char src_copy[INET6_ADDRSTRLEN+1];
+ struct sockaddr_storage ss;
+ int size = sizeof(ss);
+ char src_copy[INET6_ADDRSTRLEN+1];
- ZeroMemory(&ss, sizeof(ss));
- /* stupid non-const API */
- strncpy (src_copy, src, INET6_ADDRSTRLEN+1);
- src_copy[INET6_ADDRSTRLEN] = 0;
+ ZeroMemory(&ss, sizeof(ss));
+ /* stupid non-const API */
+ strncpy(src_copy, src, INET6_ADDRSTRLEN+1);
+ src_copy[INET6_ADDRSTRLEN] = 0;
- if (WSAStringToAddress(src_copy, af, NULL, (struct sockaddr *)&ss, &size) == 0) {
- switch(af) {
- case AF_INET:
- *(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr;
- return 1;
- case AF_INET6:
- *(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr;
- return 1;
+ if (WSAStringToAddress(src_copy, af, NULL, (struct sockaddr *)&ss, &size) == 0)
+ {
+ switch (af) {
+ case AF_INET:
+ *(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr;
+ return 1;
+
+ case AF_INET6:
+ *(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr;
+ return 1;
+ }
}
- }
- return 0;
+ return 0;
}
-#else
+#else /* ifdef _WIN32 */
#error no emulation for inet_ntop
-#endif
+#endif /* ifdef _WIN32 */
-#endif
+#endif /* ifndef HAVE_INET_PTON */