diff options
Diffstat (limited to 'libguile/socket.c')
-rw-r--r-- | libguile/socket.c | 106 |
1 files changed, 52 insertions, 54 deletions
diff --git a/libguile/socket.c b/libguile/socket.c index 71c17e892..64354f1f1 100644 --- a/libguile/socket.c +++ b/libguile/socket.c @@ -1,21 +1,21 @@ -/* Copyright (C) 1996-1998, 2000-2007, 2009, 2011-2015 - * 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 License - * as published by the Free Software Foundation; either version 3 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ +/* Copyright 1996-1998,2000-2007,2009,2011-2015,2018 + Free Software Foundation, Inc. + + This file is part of Guile. + + Guile is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Guile is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with Guile. If not, see + <https://www.gnu.org/licenses/>. */ @@ -34,8 +34,8 @@ #include <string.h> #endif #include <unistd.h> -#include <sys/types.h> #include <sys/socket.h> +#include <sys/types.h> #ifdef HAVE_UNIX_DOMAIN_SOCKETS #include <sys/un.h> #endif @@ -46,22 +46,24 @@ #include <gmp.h> -#include "libguile/_scm.h" -#include "libguile/arrays.h" -#include "libguile/feature.h" -#include "libguile/fports.h" -#include "libguile/strings.h" -#include "libguile/vectors.h" -#include "libguile/dynwind.h" -#include "libguile/srfi-13.h" - -#include "libguile/validate.h" -#include "libguile/socket.h" - -#if SCM_ENABLE_DEPRECATED == 1 -# include "libguile/deprecation.h" -#endif - +#include "arrays.h" +#include "async.h" +#include "bytevectors.h" +#include "dynwind.h" +#include "feature.h" +#include "fports.h" +#include "gsubr.h" +#include "list.h" +#include "modules.h" +#include "numbers.h" +#include "pairs.h" +#include "srfi-13.h" +#include "strings.h" +#include "symbols.h" +#include "syscalls.h" +#include "vectors.h" + +#include "socket.h" #if defined (HAVE_UNIX_DOMAIN_SOCKETS) && !defined (SUN_LEN) @@ -161,7 +163,7 @@ SCM_DEFINE (scm_inet_makeaddr, "inet-makeaddr", 2, 0, 0, \ for (i = 0; i < 8; i++)\ {\ - scm_t_uint8 c = (addr)[i];\ + uint8_t c = (addr)[i];\ \ (addr)[i] = (addr)[15 - i];\ (addr)[15 - i] = c;\ @@ -174,8 +176,8 @@ SCM_DEFINE (scm_inet_makeaddr, "inet-makeaddr", 2, 0, 0, #else #define FLIPCPY_NET_HOST_128(dest, src) \ { \ - const scm_t_uint8 *tmp_srcp = (src) + 15; \ - scm_t_uint8 *tmp_destp = (dest); \ + const uint8_t *tmp_srcp = (src) + 15; \ + uint8_t *tmp_destp = (dest); \ \ do { \ *tmp_destp++ = *tmp_srcp--; \ @@ -184,8 +186,8 @@ SCM_DEFINE (scm_inet_makeaddr, "inet-makeaddr", 2, 0, 0, #endif -#if (SIZEOF_SCM_T_BITS * SCM_CHAR_BIT) > 128 -#error "Assumption that scm_t_bits <= 128 bits has been violated." +#if (SIZEOF_UINTPTR_T * SCM_CHAR_BIT) > 128 +#error "Assumption that uintptr_t <= 128 bits has been violated." #endif #if (SIZEOF_UNSIGNED_LONG * SCM_CHAR_BIT) > 128 @@ -199,7 +201,7 @@ SCM_DEFINE (scm_inet_makeaddr, "inet-makeaddr", 2, 0, 0, /* convert a 128 bit IPv6 address in network order to a host ordered SCM integer. */ static SCM -scm_from_ipv6 (const scm_t_uint8 *src) +scm_from_ipv6 (const uint8_t *src) { SCM result = scm_i_mkbig (); mpz_import (SCM_I_BIG_MPZ (result), @@ -215,7 +217,7 @@ scm_from_ipv6 (const scm_t_uint8 *src) /* convert a host ordered SCM integer to a 128 bit IPv6 address in network order. */ static void -scm_to_ipv6 (scm_t_uint8 dst[16], SCM src) +scm_to_ipv6 (uint8_t dst[16], SCM src) { if (SCM_I_INUMP (src)) { @@ -293,7 +295,7 @@ SCM_DEFINE (scm_inet_ntop, "inet-ntop", 2, 0, 0, ); if (af == AF_INET) { - scm_t_uint32 addr4; + uint32_t addr4; addr4 = htonl (SCM_NUM2ULONG (2, address)); result = inet_ntop (af, &addr4, dst, sizeof (dst)); @@ -303,7 +305,7 @@ SCM_DEFINE (scm_inet_ntop, "inet-ntop", 2, 0, 0, { char addr6[16]; - scm_to_ipv6 ((scm_t_uint8 *) addr6, address); + scm_to_ipv6 ((uint8_t *) addr6, address); result = inet_ntop (af, &addr6, dst, sizeof (dst)); } #endif @@ -332,7 +334,7 @@ SCM_DEFINE (scm_inet_pton, "inet-pton", 2, 0, 0, { int af; char *src; - scm_t_uint32 dst[4]; + uint32_t dst[4]; int rv, eno; af = scm_to_int (family); @@ -357,7 +359,7 @@ SCM_DEFINE (scm_inet_pton, "inet-pton", 2, 0, 0, return scm_from_ulong (ntohl (*dst)); #ifdef HAVE_IPV6 else if (af == AF_INET6) - return scm_from_ipv6 ((scm_t_uint8 *) dst); + return scm_from_ipv6 ((uint8_t *) dst); #endif else SCM_MISC_ERROR ("unsupported address family", family); @@ -715,6 +717,8 @@ SCM_DEFINE (scm_shutdown, "shutdown", 2, 0, 0, proc is the name of the original procedure. size returns the size of the structure allocated. */ +#define MAX(A, B) ((A) >= (B) ? (A) : (B)) + static struct sockaddr * scm_fill_sockaddr (int fam, SCM address, SCM *args, int which_arg, const char *proc, size_t *size) @@ -802,7 +806,7 @@ scm_fill_sockaddr (int fam, SCM address, SCM *args, int which_arg, connect/bind etc., to fail. sun_path is always the last member of the structure. */ addr_size = sizeof (struct sockaddr_un) - + max (0, strlen (c_address) + 1 - (sizeof soka->sun_path)); + + MAX (0, strlen (c_address) + 1 - (sizeof soka->sun_path)); soka = (struct sockaddr_un *) scm_malloc (addr_size); memset (soka, 0, addr_size); /* for sun_len: see sin_len above. */ soka->sun_family = AF_UNIX; @@ -1766,12 +1770,6 @@ scm_init_socket () scm_add_feature ("socket"); -#include "libguile/socket.x" +#include "socket.x" } - -/* - Local Variables: - c-file-style: "gnu" - End: -*/ |