summaryrefslogtreecommitdiff
path: root/libguile/socket.c
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2007-06-12 21:55:11 +0000
committerLudovic Courtès <ludo@gnu.org>2007-06-12 21:55:11 +0000
commit7a5fb79613d0d5d865d1429432ce124d00e9a6b6 (patch)
tree8ae420cc5b9187d085fd38b027a9d6860ae2e6c2 /libguile/socket.c
parenta1ef7406369b25054c0084c50e920ee9a4072ec3 (diff)
downloadguile-7a5fb79613d0d5d865d1429432ce124d00e9a6b6.tar.gz
Changes from arch/CVS synchronization
Diffstat (limited to 'libguile/socket.c')
-rw-r--r--libguile/socket.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/libguile/socket.c b/libguile/socket.c
index 5d09c615b..4ee8a84e5 100644
--- a/libguile/socket.c
+++ b/libguile/socket.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996,1997,1998,2000,2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1996,1997,1998,2000,2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -386,16 +386,28 @@ SCM_DEFINE (scm_inet_ntop, "inet-ntop", 2, 0, 0,
#else
char dst[46];
#endif
- char addr6[16];
+ const char *result;
af = scm_to_int (family);
SCM_ASSERT_RANGE (1, family, af == AF_INET || af == AF_INET6);
if (af == AF_INET)
- *(scm_t_uint32 *) addr6 = htonl (SCM_NUM2ULONG (2, address));
+ {
+ scm_t_uint32 addr4;
+
+ addr4 = htonl (SCM_NUM2ULONG (2, address));
+ result = inet_ntop (af, &addr4, dst, sizeof (dst));
+ }
else
- scm_to_ipv6 ((scm_t_uint8 *) addr6, address);
- if (inet_ntop (af, &addr6, dst, sizeof dst) == NULL)
+ {
+ char addr6[16];
+
+ scm_to_ipv6 ((scm_t_uint8 *) addr6, address);
+ result = inet_ntop (af, &addr6, dst, sizeof (dst));
+ }
+
+ if (result == NULL)
SCM_SYSERROR;
+
return scm_from_locale_string (dst);
}
#undef FUNC_NAME