summaryrefslogtreecommitdiff
path: root/src/compat/compat-inet_pton.c
diff options
context:
space:
mode:
authorAlberto Gonzalez Iniesta <agi@inittab.org>2016-12-27 18:25:47 +0100
committerAlberto Gonzalez Iniesta <agi@inittab.org>2016-12-27 18:25:47 +0100
commit3a2bbdb05ca6a6996e424c9fb225cb0d53804125 (patch)
treef29063da5bec4caf3853d49a22a09c8619eebd21 /src/compat/compat-inet_pton.c
parentd53dba59e78da865c4fe820386ff2f4f76925f3b (diff)
New upstream version 2.4.0upstream/2.4.0
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 */