summaryrefslogtreecommitdiff
path: root/src/compat/compat-inet_ntop.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
commit79f3537f69e125f19f59c36aa090120a63186a54 (patch)
tree2089a3b7dac990841dbc2e4d9b2f535b82dbb0af /src/compat/compat-inet_ntop.c
parentf2137fedb30cb87448eb03b2f288920df6187571 (diff)
parent3a2bbdb05ca6a6996e424c9fb225cb0d53804125 (diff)
Merge tag 'upstream/2.4.0'
Upstream version 2.4.0
Diffstat (limited to 'src/compat/compat-inet_ntop.c')
-rw-r--r--src/compat/compat-inet_ntop.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/compat/compat-inet_ntop.c b/src/compat/compat-inet_ntop.c
index 786c973..dd7abb5 100644
--- a/src/compat/compat-inet_ntop.c
+++ b/src/compat/compat-inet_ntop.c
@@ -46,31 +46,33 @@
const char *
inet_ntop(int af, const void *src, char *dst, socklen_t size)
{
- struct sockaddr_storage ss;
- unsigned long s = size;
+ struct sockaddr_storage ss;
+ unsigned long s = size;
- ZeroMemory(&ss, sizeof(ss));
- ss.ss_family = af;
+ ZeroMemory(&ss, sizeof(ss));
+ ss.ss_family = af;
- switch(af) {
- case AF_INET:
- ((struct sockaddr_in *)&ss)->sin_addr = *(struct in_addr *)src;
- break;
- case AF_INET6:
- ((struct sockaddr_in6 *)&ss)->sin6_addr = *(struct in6_addr *)src;
- break;
- default:
- return NULL;
- }
- /* cannot direclty use &size because of strict aliasing rules */
- return (WSAAddressToString((struct sockaddr *)&ss, sizeof(ss), NULL, dst, &s) == 0)?
- dst : NULL;
+ switch (af) {
+ case AF_INET:
+ ((struct sockaddr_in *)&ss)->sin_addr = *(struct in_addr *)src;
+ break;
+
+ case AF_INET6:
+ ((struct sockaddr_in6 *)&ss)->sin6_addr = *(struct in6_addr *)src;
+ break;
+
+ default:
+ return NULL;
+ }
+ /* cannot direclty use &size because of strict aliasing rules */
+ return (WSAAddressToString((struct sockaddr *)&ss, sizeof(ss), NULL, dst, &s) == 0) ?
+ dst : NULL;
}
-#else
+#else /* ifdef _WIN32 */
#error no emulation for inet_ntop
-#endif
+#endif /* ifdef _WIN32 */
-#endif
+#endif /* ifndef HAVE_INET_NTOP */