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
commit3a2bbdb05ca6a6996e424c9fb225cb0d53804125 (patch)
treef29063da5bec4caf3853d49a22a09c8619eebd21 /src/compat/compat-inet_ntop.c
parentd53dba59e78da865c4fe820386ff2f4f76925f3b (diff)
New upstream version 2.4.0upstream/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 */