summaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/socket.c b/socket.c
index 6296b38..68e0195 100644
--- a/socket.c
+++ b/socket.c
@@ -1,18 +1,18 @@
/* Copyright (C) 1994, 1995 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, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111, USA.
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
@@ -36,7 +36,7 @@
*
* 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.
+ * If you do not wish that, delete this exception notice.
*/
/* "socket.c" internet stream socket support for client/server in SCM
@@ -308,11 +308,13 @@ SCM l_socket(fam, proto)
SYSCALL(sd = socket(tp, SOCK_STREAM, INUM(proto)););
if (-1==sd) wta(UNDEFINED, (char *)NALLOC, s_socket);
SYSCALL(f = fdopen(sd, "r+"););
+ /* SCM_OPENCALL(f = fdopen(sd, "r+")); */
if (!f) {
close(sd);
wta(MAKINUM(sd), (char *)NALLOC, s_port_type);
}
- CAR(port) = tc_socket | (tp<<24) | BUF0;
+ CAR(port) = scm_port_entry(tc_socket, BUF0);
+ SCM_PORTDATA(port) = fam;
SETSTREAM(port, f);
i_setbuf0(port);
ALLOW_INTS;
@@ -341,18 +343,19 @@ SCM l_socketpair(fam, proto)
DEFER_INTS;
SYSCALL(sts = socketpair(tp, SOCK_STREAM, INUM(proto), sv););
if (-1==sts) wta(UNDEFINED, (char *)NALLOC, s_socketpair);
- SYSCALL(f[0] = fdopen(sv[0], "r+"););
+ SCM_OPENCALL(f[0] = fdopen(sv[0], "r+"));
if (!f[0]) {
close(sv[0]);
wta(MAKINUM(sv[0]), (char *)NALLOC, s_port_type);
}
- SYSCALL(f[1] = fdopen(sv[1], "r+"););
+ SCM_OPENCALL(f[1] = fdopen(sv[1], "r+"));
if (!f[1]) {
fclose(f[0]);
close(sv[1]);
wta(MAKINUM(sv[1]), (char *)NALLOC, s_port_type);
}
- CAR(port[0]) = CAR(port[1]) = tc16_fport | mode_bits("r+0");
+ CAR(port[0]) = scm_port_entry(tc16_fport, mode_bits("r+0", (char *)0));
+ CAR(port[1]) = scm_port_entry(tc16_fport, mode_bits("r+0", (char *)0));
SETSTREAM(port[0], f[0]); SETSTREAM(port[1], f[1]);
i_setbuf0(port[0]); i_setbuf0(port[1]);
ALLOW_INTS;
@@ -364,7 +367,7 @@ SCM l_shutdown(port, how)
SCM port, how;
{
int sts;
- ASSERT(NIMP(port) && OPPORTP(port), port, ARG1, s_shutdown);
+ ASSERT(NIMP(port) && OPFPORTP(port), port, ARG1, s_shutdown);
ASSERT(INUMP(how) && 0 <= INUM(how) && 2 >= INUM(how),
how, ARG2, s_shutdown);
SYSCALL(sts = shutdown(fileno(STREAM(port)), INUM(how)););
@@ -416,7 +419,8 @@ SCM l_connect (sockpt, address, arg)
break;
}
if (sts) return BOOL_F;
- CAR(sockpt) = tc16_fport | mode_bits("r+0");
+ CAR(sockpt) = scm_port_entry(tc16_fport, mode_bits("r+0", (char *)0));
+ SCM_PORTDATA(sockpt) = cons(address, arg);
return sockpt;
}
@@ -465,7 +469,9 @@ SCM l_listen(port, backlog)
ASSERT(INUMP(backlog), backlog, ARG2, s_listen);
SYSCALL(sts = listen(fileno(STREAM(port)), INUM(backlog)););
if (sts) return BOOL_F;
- CAR(port) = tc16_fport | mode_bits("r0");
+ DEFER_INTS;
+ CAR(port) = scm_port_entry(tc16_fport, mode_bits("r0", (char *)0));
+ ALLOW_INTS;
return port;
}
@@ -489,12 +495,12 @@ SCM l_accept(sockpt)
wta(sockpt, "couldn't", s_accept);
}
DEFER_INTS;
- SYSCALL(newfd = fdopen(newsd, "r+"););
+ SCM_OPENCALL(newfd = fdopen(newsd, "r+"));
if (!newfd) {
close(newsd);
wta(MAKINUM(newsd), (char *)NALLOC, s_port_type);
}
- CAR(newpt) = tc16_fport | mode_bits("r+0");
+ CAR(newpt) = scm_port_entry(tc16_fport, mode_bits("r+0", (char *)0));
SETSTREAM(newpt, newfd);
i_setbuf0(newpt);
ALLOW_INTS;
@@ -527,7 +533,7 @@ sizet sknm_free(p)
CELLPTR p;
{
must_free(CHARS((SCM)p), sizeof(struct sockaddr));
- return sizeof(struct sockaddr);
+ return 0;
}
long tc16_sknm;
static smobfuns sknm_smob = {mark0, sknm_free, sknm_print, 0};
@@ -574,10 +580,9 @@ SCM maksknm(sad)
SCM sknm;
struct sockaddr *msknm;
DEFER_INTS;
- sknm = must_malloc_cell(0L+sizeof(struct sockaddr), "sknm");
+ sknm = must_malloc_cell(0L+sizeof(struct sockaddr), (SCM)tc16_sknm, "sknm");
msknm = (struct sockaddr *)CDR(sknm);
*msknm = *sad;
- CAR(sknm) = tc16_sknm;
ALLOW_INTS;
return sknm;
}
@@ -589,7 +594,7 @@ SCM l_getpeername(sockpt)
struct sockaddr_in sad;
int sts, sadlen = sizeof(sad);
bzero((char *) &sad, sizeof(sad));
- ASSERT(NIMP(sockpt) && OPPORTP(sockpt), sockpt, ARG1, s_getpeername);
+ ASSERT(NIMP(sockpt) && OPFPORTP(sockpt), sockpt, ARG1, s_getpeername);
SYSCALL(sts = getpeername(fileno(STREAM(sockpt)),
(struct sockaddr*)&sad, &sadlen););
if (sts || sizeof(sad) != sadlen) return BOOL_F;
@@ -603,7 +608,7 @@ SCM l_getsockname(sockpt)
struct sockaddr_in sad;
int sts, sadlen = sizeof(sad);
bzero((char *) &sad, sizeof(sad));
- ASSERT(NIMP(sockpt) && OPPORTP(sockpt), sockpt, ARG1, s_getsockname);
+ ASSERT(NIMP(sockpt) && OPFPORTP(sockpt), sockpt, ARG1, s_getsockname);
SYSCALL(sts = getsockname(fileno(STREAM(sockpt)),
(struct sockaddr*)&sad, &sadlen););
if (sts || sizeof(sad) != sadlen) return BOOL_F;