mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 11:50:28 +02:00
newline. A bit faster, and definitely hairier. (scm_read_line): Count newlines here instead. * strings.c (scm_take_str): New function. (scm_take0str): Reimplement in terms of scm_take_str. * strings.h (scm_take_str): New declaration. * ioext.c (scm_read_line): Use scm_take_str, to avoid copying the string. Add some simple-minded support for line buffered ports. * ports.h (SCM_BUFLINE): New flag for ports. * init.c (scm_init_standard_ports): Request line-buffering on the standard output port. * * ports.c (scm_mode_bits): Recognize 'l' as a request for line buffering. (scm_putc, scm_puts, scm_lfwrite): If the port is line-buffered, and there's a newline to be written, flush the port. * ports.c: (scm_lseek): clear buffers even if just reading current position. * fports.c (local_fclose): call local_fflush unconditionally. (various): don't use the scm_must... memory procs. * ports.h (scm_port): make read_pos a pointer to const. strports.c: take care of rw_active and rw_randow. fports.c: scm_fport_drain_input: removed. do it all in ports.c. strports.c (scm_mkstrport): check that pos is reasonable. ioext.c (scm_ftell, scm_fseek): use lseek. (SCM_CLEAR_BUFFERS): macro deleted. ioext.c (redirect_port: use ptob fflush, read_flush. ports.h (scm_ptobfuns): add ftruncate. ports.c (scm_newptob): set ftruncate. adjust ptob tables. * ports.c (scm_ftruncate): new procedure. fports.c (local_ftrunate), strports.c (str_ftruncate): new procs. strports.c (st_seek, st_grow_port): new procs. fports.h (scm_port): change size types from int to off_t. ports.c (scm_init_ports): initialise the seek symbols here instead of in ioext.c. strports.c (scm_call_with_output_string): start with an empty string, so seek and ftruncate can be used. * ports.h (scm_ptobfuns): add a read_flush procedure which is the equivalent to fflush for the read buffer. * ports.c (scm_newptob): set read_flush. ports.c (void_port_ptob): set read_flush. fports.c (local_read_flush): new proc. add to ptob. strport.c (st_read_flush): likewise. vport.c (sf_read_flush): likewise. fports.h (struct scm_fport): remove random member. there's nothing left but fdes. leaving it as a struct to allow for future changes. fports.c: replace usage of scm_fport::random with scm_port::rw_random. ports.c: (scm_putc, scm_puts, scm_lfwrite): call the read_flush ptob proc if the read buffer is filled. * ports.h (scm_port): add a rw_random member and replace reading and writing members with rw_active member. SCM_PORT_READ/SCM_PORT_WRITE: new values. * ports.h (struct scm_port_table): add writing and reading members to replace write_needs_seek: it isn't good enough for non-fports. ports.c, ioext.c, fports.c: corresponding changes. (struct scm_port_table): give it a typedef and rename to scm_port. ports.c, fports.c, strports.c, vports.c, ioext.c, ports.h: corresponding changes. * ports.c (scm_newptob): bugfix: set seek member. * * (scm_lseek): new procedure, using code from ioext.c:scm_fseek and generalised to all port types. * scmsigs.c (scm_init_scmsigs): set the SA_RESTART flag for all signals (it was only being done for handlers installed from Scheme). Otherwise (for example) SIGSTOP followed by SIGCONT on an interpreter waiting for input caused an EINTR error from read. * ports.h (struct scm_port_table): make all the char members unsigned, so they convert to int without becoming negative if large. * fports.c (scm_fdes_wait_for_input): forgot to check compilation with threads enabled. rename this procedure to fport_wait_for_input and take a port instead of a fdes. use scm_fport_input_waiting_p instead of scm_fdes_waiting_p. * readline.c (scm_readline): Applied a patch from Greg Harvey to get readline support working again: use fdopen to get FILE objects. * gc.c (scm_init_storage): install an atexit proc to flush the ports. (cleanup): the new proc. it sets a global variable which can be checked by the ptob flush procs to avoid trying to throw exceptions during exit. not very pleasant but it seems more reliable. * fports.c (local_fflush): check terminating variable and if set don't throw exception. * CHECKME: that the atexit proc is installed if unexec used. * throw.c (scm_handle_by_message): don't flush all ports here. it still causes bus errors. * fports.h (SCM_FPORT_CLEAR_BUFFERS): rename to SCM_CLEAR_BUFFERS and move to ioext.c. * fports.c (scm_fdes_waiting_p): merged into fport_input_waiting_p. * ports.c (scm_char_ready_p): check the port buffer and call the ptob entry if needed. * ports.h (scm_ptobfuns): input_waiting_p added. change all the ptob initialisers. use it in char-ready * ioext.c (scm_do_read_line): moved from ports.c. make it static. * vports.c (sfflush): modified to write a char (since softports currently use shortbuf.) * fports.c (scm_standard_stream_to_port): moved to init.c and made static. * init.c (scm_init_standard_ports): make stdout and stderr unbuffered if connected to a terminal. with stdio they were line-buffered by default. * ports.h (scm_ptobfuns): change fflush return to void. change flush proc definitions. * strports.c (scm_call_with_output_string): get size from buffer instead of port stream. (scm_strprint_obj): likewise. (st_flush): new proc. * ports.h (struct scm_port_table): added write_end member, as an optimisation. set it where write_buf_size is set. * ports.h (struct scm_port_table): change stream from void * back to SCM. SCM presumably must be large enough to hold a pointer (and probably vice versa but who knows.) (SCM_SSTREAM): deleted. change users back to SCM_STREAM. (scm_puts): rewritten * fports.c (local_ffwrite, local_fputs): removed. * strports.c (stputc, stputs, stwrite): dyked out (FIXME) * vports.c (sfputc, sfputs, sfwrite) likewise. * ports.c (write_void_port, puts_void_port): removed. (putc_void_port, getc_void_port, fgets_void_port): likewise. * ports.c (scm_lfwrite): rewritten using fport.c version. * fports.c (local_fputc): deleted. * ports.c (scm_add_to_port_table): initialise write_needs_seek. * ports.h (scm_ptobfuns): add seek function pointer. * fports.c: set it to local_seek, new procedure. * fports.h (SCM_MAYBE_DRAIN_INPUT): moved to ports.c. use ptob for seek. take ptob instead of fport arg. * ports.h (struct scm_port_table): new member write_needs_seek, replaces reading member in fport struct. * vports.c (sfgetc): store the getted char into the buffer. rename to sf_fill_buffer and install it for fill-buffer in ptob. the Scheme interface is still a procedure that gets a char. (scm_make_soft_port): set up the port buffer (shortbuf). * fports.c (local_fgetc, local_fgets): deleted. * strports.c (stgetc): likewise. * ports.c: scm_generic_fgets: likewise. * ports.h (scm_ptobfuns): add fill_buffer. * ports.c (scm_newptob): assign it. * strports.c (scm_mkstrport): set up the buffer. put just the string into the stream, not cons (pos stream). (stfill_buffer): new proc. * ports.h: fport buffer moved into port table: to be used for all port types. * throw.c (scm_handle_by_message): flush ports at exit. * socket.c (scm_sock_fd_to_port): use scm_fdes_to_port. (scm_getsockopt, scm_setsockopt, scm_shutdown, scm_connect, scm_bind, scm_listen, scm_accept, scm_getsockname, scm_getpeername, scm_recv, scm_send, scm_recvfrom, scm_sendto, use SCM_FPORT_FDES. use SCM_OPFPORTP not SCM_FPORTP. * posix.c (scm_getgroups): use SCM_ALLOW/DEFER_INTS. (scm_ttyname): use SCM_FPORT_FDES. (scm_tcgetpgrp, scm_tcsetpgrp): likewise. * ioext.c (scm_isatty_p): use SCM_FPORT_FDES. (scm_fdes_to_ports): modified. (scm_fdopen): use scm_fdes_to_port. * ports.c (scm_init_ports): don't try to flush ports using atexit(). it's too late, errors will cause SEGV. * fports.c (scm_fport_buffer_add): new procedure. * fports.h (SCM_FDES_RANDOM_P): new macro. use it in scm_fdes_to_port and scm_redirect_port. * ioext.c (scm_redirect_port): use setvbuf to set buffers in the new port. reset fp->random. * fports.c (scm_fdes_to_port), ports.c (scm_void_port), filesys.c (scm_opendir): restore defer interrupts while the port is constructed. * (scm_setvbuf): if mode is _IOFBF and size is not supplied, derive buffer size from fdes or use a default. (scm_fdes_to_port): use setvbuf instead of creating the buffers directly. vports.c (various places): use SCM_SSTREAM. strports.c: likewise. * gdbint.c: likewise. * ports.h (SCM_SSTREAM): new macro. * fports.c (scm_input_waiting_p): use scm_return_first, since port may be removed from the stack by the tail call to scm_fdes_waiting_p. * fports.h (SCM_CLEAR_BUFFERS): new macro. * ports.c (scm_force_output): call scm_fflush. * print.c (scm_newline): don't check errno for EPIPE (it wouldn't * reach this point.) don't flush port (if scm_cur_outp). * fports.h (SCM_FPORT_FDES): new macro. * vports.c (sfflush): don't need to set errno. * ports.c: install scm_flush_all_ports to be run on exit. ports.c fports.c ioext.c posix.c socket.c net_db.c filesys.c: removed all uses of SCM_DEFER/ALLOW ints for now. they were mainly just protecting errno. some may need to be put back. * scmsigs.c (take_signal): save and restore errno while this proc runs. *fports.c (print_pipe_port, local_pclose, scm_pipob): deleted. * open-pipe, close-pipe are emulated in (ice-9 popen) ports.c (scm_ports_prehistory): don't init scm_pipob. ports.h (scm_tc16_pipe): deleted. posix.c (scm_open_pipe, scm_close_pipe): deleted. * ioext.c (scm_primitive_move_to_fdes): use fport. * fport.c (scm_fport_fill_buffer): flush write buffer if needed. change arg type from scm_fport to SCM port. fport.h (SCM_SETFDES): removed. (SCM_MAYBE_DRAIN_INPUT): new macro. * ioext.c (scm_dup_to_fdes): use SCM_FSTREAM. (scm_ftell): always use lseek and account for the buffer. (scm_fileno): use fport buffer. (scm_fseek): clear fport buffers. always use lseek. * posix.c (scm_pipe): use fport buffer. * unif.c: include fports.h instead of genio.h. * fports.c (scm_fdes_wait_for_input, scm_fport_fill_buffer): new procedures. (local_fgetc): use them. (local_ffwrite): use buffer. (local_fgets): use buffer. (scm_setbuf0): deleted. (scm_setvbuf): set the buffer. (scm_setfileno): deleted. (scm_evict_ports): set fdes directly. * (scm_freopen): deleted. doesn't seem useful in Guile. (scm_stdio_to_port): deleted. fports.h (struct scm_fport): add shortbuf member to avoid separate code for unbuffered ports. (SCM_FPORTP, SCM_OPFPORTP, SCM_OPINFPORTP, SCM_OPOUTFPORTP): moved from ports.h. * genio.c, genio.h: move contents into ports.c, ports.h. The division wasn't useful. * fports.c, fports.h (scm_fport_drain_input): new procedure. * ports.c (scm_drain_input): call scm_fport_drain_input. * scm_fdes_waiting_p: new procedure. * fports.c (scm_fdes_to_port): allocate read and/or write buffers. (scm_input_waiting_p): check the buffer. (local_fgetc, local_fflush, local_fputc): likewise. * fports.h (scm_fport): read/write_buf,_pos,_buf_end,,_buf_size: new members. * init.c (scm_init_standard_ports): pass fdes instead of FILE *. * * ports.c (scm_drain_input): new procedure. ports.h: prototype. * fports.c (FPORT_READ_SAFE, FPORT_WRITE_SAFE, FPORT_ALL_OKAY, pre_read, pre_write): removed. (local_fputc, local_fputs, local_ffwrite): use write, not stdio. (scm_standard_stream_to_port): change first arg from FILE * to int fdes. (local_fflush): flush fdes, not FILE *. * fports.h (SCM_NOFTELL): removed. * genio.c, ports.c: don't include filesys.h. * genio.c (scm_getc): don't use scm_internal_select if FPORT. do it in fports.c:local_fgetc. * genio.c: don't use SCM_SYSCALL when calling ptob procedures. do it where it's needed in the port smobs. * filesys.c (scm_input_waiting_p): moved to fports.c, stdio buffer support removed. take SCM arg, not FILE *. * filesys.h: prototype moved too. * fports.c (scm_fdes_to_port): new procedure. (local_fgetc): use read not fgetc. (local_fclose): use close, not fclose. (local_fgets): use read, not fgets * fports.h: prototype for scm_fdes_to_port. * fports.h (scm_fport): new struct. * fports.c (scm_open_file): use open, not fopen. #include fcntl.h * ports.h (struct scm_port_table): change stream from SCM to void *. * ports.c (scm_add_to_port_table): check for memory allocation error. (scm_prinport): remove MSDOS hair. (scm_void_port): set stream to 0 instead of SCM_BOOL_F. (scm_close_port): don't throw errors: do it in fports.c.
837 lines
22 KiB
C
837 lines
22 KiB
C
/* Copyright (C) 1996,1997,1998 Free Software Foundation, Inc.
|
||
*
|
||
* This program is free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2, or (at your option)
|
||
* any later version.
|
||
*
|
||
* This program 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 General Public License for more details.
|
||
*
|
||
* You should have received a copy of the GNU General Public License
|
||
* along with this software; see the file COPYING. If not, write to
|
||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||
* Boston, MA 02111-1307 USA
|
||
*
|
||
* As a special exception, the Free Software Foundation gives permission
|
||
* for additional uses of the text contained in its release of GUILE.
|
||
*
|
||
* The exception is that, if you link the GUILE library with other files
|
||
* to produce an executable, this does not by itself cause the
|
||
* resulting executable to be covered by the GNU General Public License.
|
||
* Your use of that executable is in no way restricted on account of
|
||
* linking the GUILE library code into it.
|
||
*
|
||
* This exception does not however invalidate any other reasons why
|
||
* the executable file might be covered by the GNU General Public License.
|
||
*
|
||
* This exception applies only to the code released by the
|
||
* Free Software Foundation under the name GUILE. If you copy
|
||
* code from other Free Software Foundation releases into a copy of
|
||
* GUILE, as the General Public License permits, the exception does
|
||
* not apply to the code that you add in this way. To avoid misleading
|
||
* anyone as to the status of such modified files, you must delete
|
||
* this exception notice from them.
|
||
*
|
||
* If you write modifications of your own for GUILE, it is your choice
|
||
* whether to permit this exception to apply to your modifications.
|
||
* If you do not wish that, delete this exception notice. */
|
||
|
||
|
||
#include <stdio.h>
|
||
|
||
#include "_scm.h"
|
||
#include "unif.h"
|
||
#include "feature.h"
|
||
#include "fports.h"
|
||
|
||
#include "socket.h"
|
||
|
||
#ifdef HAVE_STRING_H
|
||
#include <string.h>
|
||
#endif
|
||
#ifdef HAVE_UNISTD_H
|
||
#include <unistd.h>
|
||
#endif
|
||
#include <sys/types.h>
|
||
#include <sys/socket.h>
|
||
#ifdef HAVE_UNIX_DOMAIN_SOCKETS
|
||
#include <sys/un.h>
|
||
#endif
|
||
#include <netinet/in.h>
|
||
#include <netdb.h>
|
||
#include <arpa/inet.h>
|
||
|
||
|
||
|
||
SCM_SYMBOL (sym_socket, "socket");
|
||
static SCM scm_sock_fd_to_port SCM_P ((int fd, const char *proc));
|
||
|
||
static SCM
|
||
scm_sock_fd_to_port (fd, proc)
|
||
int fd;
|
||
const char *proc;
|
||
{
|
||
SCM result;
|
||
|
||
if (fd == -1)
|
||
scm_syserror (proc);
|
||
result = scm_fdes_to_port (fd, "r+0", sym_socket);
|
||
return result;
|
||
}
|
||
|
||
SCM_PROC (s_socket, "socket", 3, 0, 0, scm_socket);
|
||
|
||
SCM
|
||
scm_socket (family, style, proto)
|
||
SCM family;
|
||
SCM style;
|
||
SCM proto;
|
||
{
|
||
int fd;
|
||
SCM result;
|
||
|
||
SCM_ASSERT (SCM_INUMP (family), family, SCM_ARG1, s_socket);
|
||
SCM_ASSERT (SCM_INUMP (style), style, SCM_ARG2, s_socket);
|
||
SCM_ASSERT (SCM_INUMP (proto), proto, SCM_ARG3, s_socket);
|
||
fd = socket (SCM_INUM (family), SCM_INUM (style), SCM_INUM (proto));
|
||
result = scm_sock_fd_to_port (fd, s_socket);
|
||
return result;
|
||
}
|
||
|
||
|
||
|
||
#ifdef HAVE_SOCKETPAIR
|
||
SCM_PROC (s_socketpair, "socketpair", 3, 0, 0, scm_socketpair);
|
||
|
||
SCM
|
||
scm_socketpair (family, style, proto)
|
||
SCM family;
|
||
SCM style;
|
||
SCM proto;
|
||
{
|
||
int fam;
|
||
int fd[2];
|
||
SCM a;
|
||
SCM b;
|
||
|
||
SCM_ASSERT (SCM_INUMP (family), family, SCM_ARG1, s_socketpair);
|
||
SCM_ASSERT (SCM_INUMP (style), style, SCM_ARG2, s_socketpair);
|
||
SCM_ASSERT (SCM_INUMP (proto), proto, SCM_ARG3, s_socketpair);
|
||
|
||
fam = SCM_INUM (family);
|
||
|
||
if (socketpair (fam, SCM_INUM (style), SCM_INUM (proto), fd) == -1)
|
||
scm_syserror (s_socketpair);
|
||
|
||
a = scm_sock_fd_to_port (fd[0], s_socketpair);
|
||
b = scm_sock_fd_to_port (fd[1], s_socketpair);
|
||
return scm_cons (a, b);
|
||
}
|
||
#endif
|
||
|
||
SCM_PROC (s_getsockopt, "getsockopt", 3, 0, 0, scm_getsockopt);
|
||
|
||
SCM
|
||
scm_getsockopt (sock, level, optname)
|
||
SCM sock;
|
||
SCM level;
|
||
SCM optname;
|
||
{
|
||
int fd;
|
||
int optlen;
|
||
#ifdef HAVE_STRUCT_LINGER
|
||
char optval[sizeof (struct linger)];
|
||
#else
|
||
char optval[sizeof (scm_sizet)];
|
||
#endif
|
||
int ilevel;
|
||
int ioptname;
|
||
|
||
#ifdef HAVE_STRUCT_LINGER
|
||
optlen = (int) sizeof (struct linger);
|
||
#else
|
||
optlen = (int) sizeof (scm_sizet);
|
||
#endif
|
||
|
||
sock = SCM_COERCE_OUTPORT (sock);
|
||
SCM_ASSERT (SCM_NIMP (sock) && SCM_OPFPORTP (sock), sock, SCM_ARG1,
|
||
s_getsockopt);
|
||
SCM_ASSERT (SCM_INUMP (level), level, SCM_ARG2, s_getsockopt);
|
||
SCM_ASSERT (SCM_INUMP (optname), optname, SCM_ARG3, s_getsockopt);
|
||
|
||
fd = SCM_FPORT_FDES (sock);
|
||
ilevel = SCM_INUM (level);
|
||
ioptname = SCM_INUM (optname);
|
||
if (getsockopt (fd, ilevel, ioptname, (void *) optval, &optlen) == -1)
|
||
scm_syserror (s_getsockopt);
|
||
|
||
#ifdef SO_LINGER
|
||
if (ilevel == SOL_SOCKET && ioptname == SO_LINGER)
|
||
{
|
||
#ifdef HAVE_STRUCT_LINGER
|
||
struct linger *ling = (struct linger *) optval;
|
||
return scm_cons (SCM_MAKINUM (ling->l_onoff),
|
||
SCM_MAKINUM (ling->l_linger));
|
||
#else
|
||
scm_sizet *ling = (scm_sizet *) optval;
|
||
return scm_cons (SCM_MAKINUM (*ling),
|
||
SCM_MAKINUM (0));
|
||
#endif
|
||
}
|
||
#endif
|
||
#ifdef SO_SNDBUF
|
||
if (ilevel == SOL_SOCKET && ioptname == SO_SNDBUF)
|
||
{
|
||
scm_sizet *bufsize = (scm_sizet *) optval;
|
||
return SCM_MAKINUM (*bufsize);
|
||
}
|
||
#endif
|
||
#ifdef SO_RCVBUF
|
||
if (ilevel == SOL_SOCKET && ioptname == SO_RCVBUF)
|
||
{
|
||
scm_sizet *bufsize = (scm_sizet *) optval;
|
||
return SCM_MAKINUM (*bufsize);
|
||
}
|
||
#endif
|
||
return SCM_MAKINUM (*(int *) optval);
|
||
}
|
||
|
||
SCM_PROC (s_setsockopt, "setsockopt", 4, 0, 0, scm_setsockopt);
|
||
|
||
SCM
|
||
scm_setsockopt (sock, level, optname, value)
|
||
SCM sock;
|
||
SCM level;
|
||
SCM optname;
|
||
SCM value;
|
||
{
|
||
int fd;
|
||
int optlen;
|
||
#ifdef HAVE_STRUCT_LINGER
|
||
char optval[sizeof (struct linger)]; /* Biggest option :-( */
|
||
#else
|
||
char optval[sizeof (scm_sizet)];
|
||
#endif
|
||
int ilevel, ioptname;
|
||
sock = SCM_COERCE_OUTPORT (sock);
|
||
SCM_ASSERT (SCM_NIMP (sock) && SCM_OPFPORTP (sock), sock, SCM_ARG1,
|
||
s_setsockopt);
|
||
SCM_ASSERT (SCM_INUMP (level), level, SCM_ARG2, s_setsockopt);
|
||
SCM_ASSERT (SCM_INUMP (optname), optname, SCM_ARG3, s_setsockopt);
|
||
fd = SCM_FPORT_FDES (sock);
|
||
ilevel = SCM_INUM (level);
|
||
ioptname = SCM_INUM (optname);
|
||
if (0);
|
||
#ifdef SO_LINGER
|
||
else if (ilevel == SOL_SOCKET && ioptname == SO_LINGER)
|
||
{
|
||
#ifdef HAVE_STRUCT_LINGER
|
||
struct linger ling;
|
||
SCM_ASSERT (SCM_NIMP (value) && SCM_CONSP (value)
|
||
&& SCM_INUMP (SCM_CAR (value))
|
||
&& SCM_INUMP (SCM_CDR (value)),
|
||
value, SCM_ARG4, s_setsockopt);
|
||
ling.l_onoff = SCM_INUM (SCM_CAR (value));
|
||
ling.l_linger = SCM_INUM (SCM_CDR (value));
|
||
optlen = (int) sizeof (struct linger);
|
||
memcpy (optval, (void *) &ling, optlen);
|
||
#else
|
||
scm_sizet ling;
|
||
SCM_ASSERT (SCM_NIMP (value) && SCM_CONSP (value)
|
||
&& SCM_INUMP (SCM_CAR (value))
|
||
&& SCM_INUMP (SCM_CDR (value)),
|
||
value, SCM_ARG4, s_setsockopt);
|
||
ling = SCM_INUM (SCM_CAR (value));
|
||
optlen = (int) sizeof (scm_sizet);
|
||
(*(scm_sizet *) optval) = (scm_sizet) SCM_INUM (value);
|
||
#endif
|
||
}
|
||
#endif
|
||
#ifdef SO_SNDBUF
|
||
else if (ilevel == SOL_SOCKET && ioptname == SO_SNDBUF)
|
||
{
|
||
SCM_ASSERT (SCM_INUMP (value), value, SCM_ARG4, s_setsockopt);
|
||
optlen = (int) sizeof (scm_sizet);
|
||
(*(scm_sizet *) optval) = (scm_sizet) SCM_INUM (value);
|
||
}
|
||
#endif
|
||
#ifdef SO_RCVBUF
|
||
else if (ilevel == SOL_SOCKET && ioptname == SO_RCVBUF)
|
||
{
|
||
SCM_ASSERT (SCM_INUMP (value), value, SCM_ARG4, s_setsockopt);
|
||
optlen = (int) sizeof (scm_sizet);
|
||
(*(scm_sizet *) optval) = (scm_sizet) SCM_INUM (value);
|
||
}
|
||
#endif
|
||
else
|
||
{
|
||
/* Most options just take an int. */
|
||
SCM_ASSERT (SCM_INUMP (value), value, SCM_ARG4, s_setsockopt);
|
||
optlen = (int) sizeof (int);
|
||
(*(int *) optval) = (int) SCM_INUM (value);
|
||
}
|
||
if (setsockopt (fd, ilevel, ioptname, (void *) optval, optlen) == -1)
|
||
scm_syserror (s_setsockopt);
|
||
return SCM_UNSPECIFIED;
|
||
}
|
||
|
||
SCM_PROC (s_shutdown, "shutdown", 2, 0, 0, scm_shutdown);
|
||
|
||
SCM
|
||
scm_shutdown (sock, how)
|
||
SCM sock;
|
||
SCM how;
|
||
{
|
||
int fd;
|
||
sock = SCM_COERCE_OUTPORT (sock);
|
||
SCM_ASSERT (SCM_NIMP (sock) && SCM_OPFPORTP (sock), sock, SCM_ARG1,
|
||
s_shutdown);
|
||
SCM_ASSERT (SCM_INUMP (how) && 0 <= SCM_INUM (how) && 2 >= SCM_INUM (how),
|
||
how, SCM_ARG2, s_shutdown);
|
||
fd = SCM_FPORT_FDES (sock);
|
||
if (shutdown (fd, SCM_INUM (how)) == -1)
|
||
scm_syserror (s_shutdown);
|
||
return SCM_UNSPECIFIED;
|
||
}
|
||
|
||
/* convert fam/address/args into a sockaddr of the appropriate type.
|
||
args is modified by removing the arguments actually used.
|
||
which_arg and proc are used when reporting errors:
|
||
which_arg is the position of address in the original argument list.
|
||
proc is the name of the original procedure.
|
||
size returns the size of the structure allocated. */
|
||
|
||
|
||
static struct sockaddr * scm_fill_sockaddr SCM_P ((int fam, SCM address, SCM *args, int which_arg, const char *proc, scm_sizet *size));
|
||
|
||
static struct sockaddr *
|
||
scm_fill_sockaddr (fam, address, args, which_arg, proc, size)
|
||
int fam;
|
||
SCM address;
|
||
SCM *args;
|
||
int which_arg;
|
||
const char *proc;
|
||
scm_sizet *size;
|
||
{
|
||
switch (fam)
|
||
{
|
||
case AF_INET:
|
||
{
|
||
SCM isport;
|
||
struct sockaddr_in *soka;
|
||
|
||
soka = (struct sockaddr_in *)
|
||
scm_must_malloc (sizeof (struct sockaddr_in), proc);
|
||
soka->sin_family = AF_INET;
|
||
soka->sin_addr.s_addr =
|
||
htonl (scm_num2ulong (address, (char *) which_arg, proc));
|
||
SCM_ASSERT (SCM_NIMP (*args) && SCM_CONSP (*args), *args,
|
||
which_arg + 1, proc);
|
||
isport = SCM_CAR (*args);
|
||
*args = SCM_CDR (*args);
|
||
SCM_ASSERT (SCM_INUMP (isport), isport, which_arg + 1, proc);
|
||
soka->sin_port = htons (SCM_INUM (isport));
|
||
*size = sizeof (struct sockaddr_in);
|
||
return (struct sockaddr *) soka;
|
||
}
|
||
#ifdef HAVE_UNIX_DOMAIN_SOCKETS
|
||
case AF_UNIX:
|
||
{
|
||
struct sockaddr_un *soka;
|
||
|
||
soka = (struct sockaddr_un *)
|
||
scm_must_malloc (sizeof (struct sockaddr_un), proc);
|
||
soka->sun_family = AF_UNIX;
|
||
SCM_ASSERT (SCM_NIMP (address) && SCM_ROSTRINGP (address), address,
|
||
which_arg, proc);
|
||
memcpy (soka->sun_path, SCM_ROCHARS (address),
|
||
1 + SCM_ROLENGTH (address));
|
||
*size = sizeof (struct sockaddr_un);
|
||
return (struct sockaddr *) soka;
|
||
}
|
||
#endif
|
||
default:
|
||
scm_out_of_range (proc, SCM_MAKINUM (fam));
|
||
}
|
||
}
|
||
|
||
SCM_PROC (s_connect, "connect", 3, 0, 1, scm_connect);
|
||
|
||
SCM
|
||
scm_connect (sock, fam, address, args)
|
||
|
||
SCM sock;
|
||
SCM fam;
|
||
SCM address;
|
||
SCM args;
|
||
{
|
||
int fd;
|
||
struct sockaddr *soka;
|
||
scm_sizet size;
|
||
|
||
sock = SCM_COERCE_OUTPORT (sock);
|
||
SCM_ASSERT (SCM_NIMP (sock) && SCM_OPFPORTP (sock), sock, SCM_ARG1, s_connect);
|
||
SCM_ASSERT (SCM_INUMP (fam), fam, SCM_ARG2, s_connect);
|
||
fd = SCM_FPORT_FDES (sock);
|
||
soka = scm_fill_sockaddr (SCM_INUM (fam), address, &args, 3, s_connect, &size);
|
||
if (connect (fd, soka, size) == -1)
|
||
scm_syserror (s_connect);
|
||
scm_must_free ((char *) soka);
|
||
return SCM_UNSPECIFIED;
|
||
}
|
||
|
||
SCM_PROC (s_bind, "bind", 3, 0, 1, scm_bind);
|
||
|
||
SCM
|
||
scm_bind (sock, fam, address, args)
|
||
SCM sock;
|
||
SCM fam;
|
||
SCM address;
|
||
SCM args;
|
||
{
|
||
int rv;
|
||
struct sockaddr *soka;
|
||
scm_sizet size;
|
||
int fd;
|
||
|
||
sock = SCM_COERCE_OUTPORT (sock);
|
||
SCM_ASSERT (SCM_NIMP (sock) && SCM_OPFPORTP (sock), sock, SCM_ARG1, s_bind);
|
||
SCM_ASSERT (SCM_INUMP (fam), fam, SCM_ARG2, s_bind);
|
||
soka = scm_fill_sockaddr (SCM_INUM (fam), address, &args, 3, s_bind, &size);
|
||
fd = SCM_FPORT_FDES (sock);
|
||
rv = bind (fd, soka, size);
|
||
if (rv == -1)
|
||
scm_syserror (s_bind);
|
||
scm_must_free ((char *) soka);
|
||
return SCM_UNSPECIFIED;
|
||
}
|
||
|
||
SCM_PROC (s_listen, "listen", 2, 0, 0, scm_listen);
|
||
|
||
SCM
|
||
scm_listen (sock, backlog)
|
||
SCM sock;
|
||
SCM backlog;
|
||
{
|
||
int fd;
|
||
sock = SCM_COERCE_OUTPORT (sock);
|
||
SCM_ASSERT (SCM_NIMP (sock) && SCM_OPFPORTP (sock), sock, SCM_ARG1, s_listen);
|
||
SCM_ASSERT (SCM_INUMP (backlog), backlog, SCM_ARG2, s_listen);
|
||
fd = SCM_FPORT_FDES (sock);
|
||
if (listen (fd, SCM_INUM (backlog)) == -1)
|
||
scm_syserror (s_listen);
|
||
return SCM_UNSPECIFIED;
|
||
}
|
||
|
||
/* Put the components of a sockaddr into a new SCM vector. */
|
||
|
||
static SCM scm_addr_vector SCM_P ((struct sockaddr *address, const char *proc));
|
||
|
||
static SCM
|
||
scm_addr_vector (address, proc)
|
||
struct sockaddr *address;
|
||
const char *proc;
|
||
{
|
||
short int fam = address->sa_family;
|
||
SCM result;
|
||
SCM *ve;
|
||
#ifdef HAVE_UNIX_DOMAIN_SOCKETS
|
||
if (fam == AF_UNIX)
|
||
{
|
||
struct sockaddr_un *nad = (struct sockaddr_un *) address;
|
||
result = scm_make_vector (SCM_MAKINUM (2), SCM_UNSPECIFIED);
|
||
ve = SCM_VELTS (result);
|
||
ve[0] = scm_ulong2num ((unsigned long) fam);
|
||
ve[1] = scm_makfromstr (nad->sun_path,
|
||
(scm_sizet) strlen (nad->sun_path), 0);
|
||
}
|
||
else
|
||
#endif
|
||
if (fam == AF_INET)
|
||
{
|
||
struct sockaddr_in *nad = (struct sockaddr_in *) address;
|
||
result = scm_make_vector (SCM_MAKINUM (3), SCM_UNSPECIFIED);
|
||
ve = SCM_VELTS (result);
|
||
ve[0] = scm_ulong2num ((unsigned long) fam);
|
||
ve[1] = scm_ulong2num (ntohl (nad->sin_addr.s_addr));
|
||
ve[2] = scm_ulong2num ((unsigned long) ntohs (nad->sin_port));
|
||
}
|
||
else
|
||
scm_misc_error (proc, "Unrecognised address family: %s",
|
||
scm_listify (SCM_MAKINUM (fam), SCM_UNDEFINED));
|
||
|
||
return result;
|
||
}
|
||
|
||
/* Allocate a buffer large enough to hold any sockaddr type. */
|
||
static char *scm_addr_buffer;
|
||
static int scm_addr_buffer_size;
|
||
|
||
static void scm_init_addr_buffer SCM_P ((void));
|
||
|
||
static void
|
||
scm_init_addr_buffer ()
|
||
{
|
||
scm_addr_buffer_size =
|
||
#ifdef HAVE_UNIX_DOMAIN_SOCKETS
|
||
(int) sizeof (struct sockaddr_un)
|
||
#else
|
||
0
|
||
#endif
|
||
;
|
||
if (sizeof (struct sockaddr_in) > scm_addr_buffer_size)
|
||
scm_addr_buffer_size = (int) sizeof (struct sockaddr_in);
|
||
scm_addr_buffer = scm_must_malloc (scm_addr_buffer_size, "address buffer");
|
||
}
|
||
|
||
SCM_PROC (s_accept, "accept", 1, 0, 0, scm_accept);
|
||
|
||
SCM
|
||
scm_accept (sock)
|
||
SCM sock;
|
||
{
|
||
int fd;
|
||
int newfd;
|
||
SCM address;
|
||
SCM newsock;
|
||
|
||
int tmp_size;
|
||
sock = SCM_COERCE_OUTPORT (sock);
|
||
SCM_ASSERT (SCM_NIMP (sock) && SCM_OPFPORTP (sock), sock, SCM_ARG1, s_accept);
|
||
fd = SCM_FPORT_FDES (sock);
|
||
tmp_size = scm_addr_buffer_size;
|
||
newfd = accept (fd, (struct sockaddr *) scm_addr_buffer, &tmp_size);
|
||
newsock = scm_sock_fd_to_port (newfd, s_accept);
|
||
if (tmp_size > 0)
|
||
address = scm_addr_vector ((struct sockaddr *) scm_addr_buffer, s_accept);
|
||
else
|
||
address = SCM_BOOL_F;
|
||
|
||
return scm_cons (newsock, address);
|
||
}
|
||
|
||
SCM_PROC (s_getsockname, "getsockname", 1, 0, 0, scm_getsockname);
|
||
|
||
SCM
|
||
scm_getsockname (sock)
|
||
SCM sock;
|
||
{
|
||
int tmp_size;
|
||
int fd;
|
||
SCM result;
|
||
sock = SCM_COERCE_OUTPORT (sock);
|
||
SCM_ASSERT (SCM_NIMP (sock) && SCM_OPFPORTP (sock), sock, SCM_ARG1, s_getsockname);
|
||
fd = SCM_FPORT_FDES (sock);
|
||
tmp_size = scm_addr_buffer_size;
|
||
if (getsockname (fd, (struct sockaddr *) scm_addr_buffer, &tmp_size) == -1)
|
||
scm_syserror (s_getsockname);
|
||
if (tmp_size > 0)
|
||
result = scm_addr_vector ((struct sockaddr *) scm_addr_buffer, s_getsockname);
|
||
else
|
||
result = SCM_BOOL_F;
|
||
return result;
|
||
}
|
||
|
||
SCM_PROC (s_getpeername, "getpeername", 1, 0, 0, scm_getpeername);
|
||
|
||
SCM
|
||
scm_getpeername (sock)
|
||
SCM sock;
|
||
{
|
||
int tmp_size;
|
||
int fd;
|
||
SCM result;
|
||
sock = SCM_COERCE_OUTPORT (sock);
|
||
SCM_ASSERT (SCM_NIMP (sock) && SCM_FPORTP (sock), sock, SCM_ARG1, s_getpeername);
|
||
fd = SCM_FPORT_FDES (sock);
|
||
tmp_size = scm_addr_buffer_size;
|
||
if (getpeername (fd, (struct sockaddr *) scm_addr_buffer, &tmp_size) == -1)
|
||
scm_syserror (s_getpeername);
|
||
if (tmp_size > 0)
|
||
result = scm_addr_vector ((struct sockaddr *) scm_addr_buffer, s_getpeername);
|
||
else
|
||
result = SCM_BOOL_F;
|
||
return result;
|
||
}
|
||
|
||
SCM_PROC (s_recv, "recv!", 2, 1, 0, scm_recv);
|
||
|
||
SCM
|
||
scm_recv (sock, buf, flags)
|
||
SCM sock;
|
||
SCM buf;
|
||
SCM flags;
|
||
{
|
||
int rv;
|
||
int fd;
|
||
int flg;
|
||
|
||
SCM_ASSERT (SCM_NIMP (sock) && SCM_OPFPORTP (sock), sock, SCM_ARG1, s_recv);
|
||
SCM_ASSERT (SCM_NIMP (buf) && SCM_STRINGP (buf), buf, SCM_ARG2, s_recv);
|
||
|
||
fd = SCM_FPORT_FDES (sock);
|
||
if (SCM_UNBNDP (flags))
|
||
flg = 0;
|
||
else
|
||
flg = scm_num2ulong (flags, (char *) SCM_ARG3, s_recv);
|
||
|
||
SCM_SYSCALL (rv = recv (fd, SCM_CHARS (buf), SCM_LENGTH (buf), flg));
|
||
if (rv == -1)
|
||
scm_syserror (s_recv);
|
||
|
||
return SCM_MAKINUM (rv);
|
||
}
|
||
|
||
SCM_PROC (s_send, "send", 2, 1, 0, scm_send);
|
||
|
||
SCM
|
||
scm_send (sock, message, flags)
|
||
SCM sock;
|
||
SCM message;
|
||
SCM flags;
|
||
{
|
||
int rv;
|
||
int fd;
|
||
int flg;
|
||
|
||
sock = SCM_COERCE_OUTPORT (sock);
|
||
SCM_ASSERT (SCM_NIMP (sock) && SCM_OPFPORTP (sock), sock, SCM_ARG1, s_send);
|
||
SCM_ASSERT (SCM_NIMP (message) && SCM_ROSTRINGP (message), message, SCM_ARG2, s_send);
|
||
|
||
fd = SCM_FPORT_FDES (sock);
|
||
if (SCM_UNBNDP (flags))
|
||
flg = 0;
|
||
else
|
||
flg = scm_num2ulong (flags, (char *) SCM_ARG3, s_send);
|
||
|
||
SCM_SYSCALL (rv = send (fd, SCM_ROCHARS (message), SCM_ROLENGTH (message), flg));
|
||
if (rv == -1)
|
||
scm_syserror (s_send);
|
||
return SCM_MAKINUM (rv);
|
||
}
|
||
|
||
SCM_PROC (s_recvfrom, "recvfrom!", 2, 3, 0, scm_recvfrom);
|
||
|
||
SCM
|
||
scm_recvfrom (sock, buf, flags, start, end)
|
||
SCM sock;
|
||
SCM buf;
|
||
SCM flags;
|
||
SCM start;
|
||
SCM end;
|
||
{
|
||
int rv;
|
||
int fd;
|
||
int flg;
|
||
int offset = 0;
|
||
int cend;
|
||
int tmp_size;
|
||
SCM address;
|
||
|
||
SCM_ASSERT (SCM_NIMP (sock) && SCM_OPFPORTP (sock), sock, SCM_ARG1,
|
||
s_recvfrom);
|
||
SCM_ASSERT (SCM_NIMP (buf) && SCM_STRINGP (buf), buf, SCM_ARG2, s_recvfrom);
|
||
cend = SCM_LENGTH (buf);
|
||
|
||
if (SCM_UNBNDP (flags))
|
||
flg = 0;
|
||
else
|
||
{
|
||
flg = scm_num2ulong (flags, (char *) SCM_ARG3, s_recvfrom);
|
||
|
||
if (!SCM_UNBNDP (start))
|
||
{
|
||
offset = (int) scm_num2long (start,
|
||
(char *) SCM_ARG4, s_recvfrom);
|
||
|
||
if (offset < 0 || offset >= cend)
|
||
scm_out_of_range (s_recvfrom, start);
|
||
|
||
if (!SCM_UNBNDP (end))
|
||
{
|
||
int tend = (int) scm_num2long (end,
|
||
(char *) SCM_ARG5, s_recvfrom);
|
||
|
||
if (tend <= offset || tend > cend)
|
||
scm_out_of_range (s_recvfrom, end);
|
||
|
||
cend = tend;
|
||
}
|
||
}
|
||
}
|
||
|
||
fd = SCM_FPORT_FDES (sock);
|
||
|
||
tmp_size = scm_addr_buffer_size;
|
||
SCM_SYSCALL (rv = recvfrom (fd, SCM_CHARS (buf) + offset,
|
||
cend - offset, flg,
|
||
(struct sockaddr *) scm_addr_buffer,
|
||
&tmp_size));
|
||
if (rv == -1)
|
||
scm_syserror (s_recvfrom);
|
||
if (tmp_size > 0)
|
||
address = scm_addr_vector ((struct sockaddr *) scm_addr_buffer, s_recvfrom);
|
||
else
|
||
address = SCM_BOOL_F;
|
||
|
||
return scm_cons (SCM_MAKINUM (rv), address);
|
||
}
|
||
|
||
SCM_PROC (s_sendto, "sendto", 4, 0, 1, scm_sendto);
|
||
|
||
SCM
|
||
scm_sendto (sock, message, fam, address, args_and_flags)
|
||
SCM sock;
|
||
SCM message;
|
||
SCM fam;
|
||
SCM address;
|
||
SCM args_and_flags;
|
||
{
|
||
int rv;
|
||
int fd;
|
||
int flg;
|
||
struct sockaddr *soka;
|
||
scm_sizet size;
|
||
int save_err;
|
||
|
||
sock = SCM_COERCE_OUTPORT (sock);
|
||
SCM_ASSERT (SCM_NIMP (sock) && SCM_FPORTP (sock), sock, SCM_ARG1, s_sendto);
|
||
SCM_ASSERT (SCM_NIMP (message) && SCM_ROSTRINGP (message), message,
|
||
SCM_ARG2, s_sendto);
|
||
SCM_ASSERT (SCM_INUMP (fam), fam, SCM_ARG3, s_sendto);
|
||
fd = SCM_FPORT_FDES (sock);
|
||
soka = scm_fill_sockaddr (SCM_INUM (fam), address, &args_and_flags, 4,
|
||
s_sendto, &size);
|
||
if (SCM_NULLP (args_and_flags))
|
||
flg = 0;
|
||
else
|
||
{
|
||
SCM_ASSERT (SCM_NIMP (args_and_flags) && SCM_CONSP (args_and_flags),
|
||
args_and_flags, SCM_ARG5, s_sendto);
|
||
flg = scm_num2ulong (SCM_CAR (args_and_flags), (char *) SCM_ARG5, s_sendto);
|
||
}
|
||
SCM_SYSCALL (rv = sendto (fd, SCM_ROCHARS (message), SCM_ROLENGTH (message),
|
||
flg, soka, size));
|
||
save_err = errno;
|
||
scm_must_free ((char *) soka);
|
||
errno = save_err;
|
||
if (rv == -1)
|
||
scm_syserror (s_sendto);
|
||
return SCM_MAKINUM (rv);
|
||
}
|
||
|
||
|
||
|
||
void
|
||
scm_init_socket ()
|
||
{
|
||
/* protocol families. */
|
||
#ifdef AF_UNSPEC
|
||
scm_sysintern ("AF_UNSPEC", SCM_MAKINUM (AF_UNSPEC));
|
||
#endif
|
||
#ifdef AF_UNIX
|
||
scm_sysintern ("AF_UNIX", SCM_MAKINUM (AF_UNIX));
|
||
#endif
|
||
#ifdef AF_INET
|
||
scm_sysintern ("AF_INET", SCM_MAKINUM (AF_INET));
|
||
#endif
|
||
|
||
#ifdef PF_UNSPEC
|
||
scm_sysintern ("PF_UNSPEC", SCM_MAKINUM (PF_UNSPEC));
|
||
#endif
|
||
#ifdef PF_UNIX
|
||
scm_sysintern ("PF_UNIX", SCM_MAKINUM (PF_UNIX));
|
||
#endif
|
||
#ifdef PF_INET
|
||
scm_sysintern ("PF_INET", SCM_MAKINUM (PF_INET));
|
||
#endif
|
||
|
||
/* socket types. */
|
||
#ifdef SOCK_STREAM
|
||
scm_sysintern ("SOCK_STREAM", SCM_MAKINUM (SOCK_STREAM));
|
||
#endif
|
||
#ifdef SOCK_DGRAM
|
||
scm_sysintern ("SOCK_DGRAM", SCM_MAKINUM (SOCK_DGRAM));
|
||
#endif
|
||
#ifdef SOCK_RAW
|
||
scm_sysintern ("SOCK_RAW", SCM_MAKINUM (SOCK_RAW));
|
||
#endif
|
||
|
||
/* setsockopt level. */
|
||
#ifdef SOL_SOCKET
|
||
scm_sysintern ("SOL_SOCKET", SCM_MAKINUM (SOL_SOCKET));
|
||
#endif
|
||
#ifdef SOL_IP
|
||
scm_sysintern ("SOL_IP", SCM_MAKINUM (SOL_IP));
|
||
#endif
|
||
#ifdef SOL_TCP
|
||
scm_sysintern ("SOL_TCP", SCM_MAKINUM (SOL_TCP));
|
||
#endif
|
||
#ifdef SOL_UDP
|
||
scm_sysintern ("SOL_UDP", SCM_MAKINUM (SOL_UDP));
|
||
#endif
|
||
|
||
/* setsockopt names. */
|
||
#ifdef SO_DEBUG
|
||
scm_sysintern ("SO_DEBUG", SCM_MAKINUM (SO_DEBUG));
|
||
#endif
|
||
#ifdef SO_REUSEADDR
|
||
scm_sysintern ("SO_REUSEADDR", SCM_MAKINUM (SO_REUSEADDR));
|
||
#endif
|
||
#ifdef SO_STYLE
|
||
scm_sysintern ("SO_STYLE", SCM_MAKINUM (SO_STYLE));
|
||
#endif
|
||
#ifdef SO_TYPE
|
||
scm_sysintern ("SO_TYPE", SCM_MAKINUM (SO_TYPE));
|
||
#endif
|
||
#ifdef SO_ERROR
|
||
scm_sysintern ("SO_ERROR", SCM_MAKINUM (SO_ERROR));
|
||
#endif
|
||
#ifdef SO_DONTROUTE
|
||
scm_sysintern ("SO_DONTROUTE", SCM_MAKINUM (SO_DONTROUTE));
|
||
#endif
|
||
#ifdef SO_BROADCAST
|
||
scm_sysintern ("SO_BROADCAST", SCM_MAKINUM (SO_BROADCAST));
|
||
#endif
|
||
#ifdef SO_SNDBUF
|
||
scm_sysintern ("SO_SNDBUF", SCM_MAKINUM (SO_SNDBUF));
|
||
#endif
|
||
#ifdef SO_RCVBUF
|
||
scm_sysintern ("SO_RCVBUF", SCM_MAKINUM (SO_RCVBUF));
|
||
#endif
|
||
#ifdef SO_KEEPALIVE
|
||
scm_sysintern ("SO_KEEPALIVE", SCM_MAKINUM (SO_KEEPALIVE));
|
||
#endif
|
||
#ifdef SO_OOBINLINE
|
||
scm_sysintern ("SO_OOBINLINE", SCM_MAKINUM (SO_OOBINLINE));
|
||
#endif
|
||
#ifdef SO_NO_CHECK
|
||
scm_sysintern ("SO_NO_CHECK", SCM_MAKINUM (SO_NO_CHECK));
|
||
#endif
|
||
#ifdef SO_PRIORITY
|
||
scm_sysintern ("SO_PRIORITY", SCM_MAKINUM (SO_PRIORITY));
|
||
#endif
|
||
#ifdef SO_LINGER
|
||
scm_sysintern ("SO_LINGER", SCM_MAKINUM (SO_LINGER));
|
||
#endif
|
||
|
||
/* recv/send options. */
|
||
#ifdef MSG_OOB
|
||
scm_sysintern ("MSG_OOB", SCM_MAKINUM (MSG_OOB));
|
||
#endif
|
||
#ifdef MSG_PEEK
|
||
scm_sysintern ("MSG_PEEK", SCM_MAKINUM (MSG_PEEK));
|
||
#endif
|
||
#ifdef MSG_DONTROUTE
|
||
scm_sysintern ("MSG_DONTROUTE", SCM_MAKINUM (MSG_DONTROUTE));
|
||
#endif
|
||
|
||
scm_add_feature ("socket");
|
||
scm_init_addr_buffer ();
|
||
|
||
#include "socket.x"
|
||
}
|
||
|