summaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c64
1 files changed, 33 insertions, 31 deletions
diff --git a/socket.c b/socket.c
index 5c0aa7b..290de2f 100644
--- a/socket.c
+++ b/socket.c
@@ -48,8 +48,8 @@
#include "scm.h"
#ifdef macintosh
-#define SOCKETDEFS
-#include "macsocket.h"
+# define SOCKETDEFS
+# include "macsocket.h"
#endif
#include <sys/types.h>
@@ -72,6 +72,9 @@
# ifdef __OpenBSD__
# include <unistd.h>
# endif
+# ifdef __NetBSD__
+# include <unistd.h>
+# endif
#endif /* STDC_HEADERS */
static char s_inetaddr[] = "inet:string->address";
@@ -79,7 +82,7 @@ SCM l_inetaddr (host)
SCM host;
{
struct in_addr soka;
- ASSERT(NIMP(host) && STRINGP(host), host, ARG1, s_inetaddr);
+ ASRTER(NIMP(host) && STRINGP(host), host, ARG1, s_inetaddr);
soka.s_addr = inet_addr(CHARS(host));
if (-1==soka.s_addr) {
struct hostent *entry;
@@ -247,15 +250,15 @@ SCM l_servinfo(args)
}
name = CAR(args);
proto = CDR(args);
- ASSERT(NIMP(proto) && CONSP(proto), args, WNA, s_servinfo);
+ ASRTER(NIMP(proto) && CONSP(proto), args, WNA, s_servinfo);
proto = CAR(proto);
- ASSERT(NIMP(proto) && STRINGP(proto), args, ARG2, s_servinfo);
+ ASRTER(NIMP(proto) && STRINGP(proto), args, ARG2, s_servinfo);
DEFER_INTS;
if (NIMP(name) && STRINGP(name)) {
SYSCALL(entry = getservbyname(CHARS(name), CHARS(proto)););
}
else {
- ASSERT(INUMP(proto), proto, ARG1, s_servinfo);
+ ASRTER(INUMP(proto), proto, ARG1, s_servinfo);
SYSCALL(entry = getservbyport(INUM(proto), CHARS(proto)););
}
comlab: ALLOW_INTS;
@@ -303,9 +306,9 @@ SCM l_socket(fam, proto)
int sd, j, tp = INUM(fam);
FILE* f;
SCM port;
- ASSERT(INUMP(fam), fam, ARG1, s_socket);
+ ASRTER(INUMP(fam), fam, ARG1, s_socket);
if UNBNDP(proto) proto = INUM0;
- else ASSERT(INUMP(proto), proto, ARG2, s_socket);
+ else ASRTER(INUMP(proto), proto, ARG2, s_socket);
NEWCELL(port);
DEFER_INTS;
SYSCALL(sd = socket(tp, SOCK_STREAM, INUM(proto)););
@@ -326,7 +329,7 @@ SCM l_socket(fam, proto)
#else
sd = setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &j, sizeof(j));
#endif
- ASSERT(!sd, port, "could not set socket option", s_socket);
+ ASRTER(!sd, port, "could not set socket option", s_socket);
}
return port;
}
@@ -338,9 +341,9 @@ SCM l_socketpair(fam, proto)
int sv[2];
FILE* f[2];
SCM port[2];
- ASSERT(INUMP(fam), fam, ARG1, s_socketpair);
+ ASRTER(INUMP(fam), fam, ARG1, s_socketpair);
if UNBNDP(proto) proto = INUM0;
- else ASSERT(INUMP(proto), proto, ARG2, s_socketpair);
+ else ASRTER(INUMP(proto), proto, ARG2, s_socketpair);
NEWCELL(port[0]); NEWCELL(port[1]);
DEFER_INTS;
SYSCALL(sts = socketpair(tp, SOCK_STREAM, INUM(proto), sv););
@@ -368,8 +371,8 @@ SCM l_shutdown(port, how)
SCM port, how;
{
int sts;
- ASSERT(NIMP(port) && OPFPORTP(port), port, ARG1, s_shutdown);
- ASSERT(INUMP(how) && 0 <= INUM(how) && 2 >= INUM(how),
+ ASRTER(NIMP(port) && OPFPORTP(port), port, ARG1, s_shutdown);
+ ASRTER(INUMP(how) && 0 <= INUM(how) && 2 >= INUM(how),
how, ARG2, s_shutdown);
SYSCALL(sts = shutdown(fileno(STREAM(port)), INUM(how)););
if (sts) return BOOL_F;
@@ -390,14 +393,14 @@ SCM l_connect (sockpt, address, arg)
{
long flags;
int sts;
- ASSERT(NIMP(sockpt) && SOCKP(sockpt), sockpt, ARG1, s_connect);
+ ASRTER(NIMP(sockpt) && SOCKP(sockpt), sockpt, ARG1, s_connect);
switch SOCKTYP(sockpt) {
default:
- ASSERT(0, sockpt, s_unkfam, s_connect);
+ ASRTER(0, sockpt, s_unkfam, s_connect);
case AF_INET:
- ASSERT(NIMP(arg) && CONSP(arg) && NULLP(CDR(arg)), arg, WNA, s_connect);
+ ASRTER(NIMP(arg) && CONSP(arg) && NULLP(CDR(arg)), arg, WNA, s_connect);
arg = CAR(arg);
- ASSERT(INUMP(arg), arg, ARG3, s_connect);
+ ASRTER(INUMP(arg), arg, ARG3, s_connect);
{
struct sockaddr_in soka;
soka.sin_addr.s_addr =
@@ -409,8 +412,8 @@ SCM l_connect (sockpt, address, arg)
}
break;
case AF_UNIX:
- ASSERT(NULLP(arg), arg, WNA, s_connect);
- ASSERT(NIMP(address) && STRINGP(address), address, ARG2, s_connect);
+ ASRTER(NULLP(arg), arg, WNA, s_connect);
+ ASRTER(NIMP(address) && STRINGP(address), address, ARG2, s_connect);
{
struct sockaddr_un soka;
soka.sun_family = AF_UNIX;
@@ -433,12 +436,12 @@ SCM l_bind(sockpt, address)
SCM sockpt, address;
{
int sts;
- ASSERT(NIMP(sockpt) && SOCKP(sockpt), sockpt, ARG1, s_bind);
+ ASRTER(NIMP(sockpt) && SOCKP(sockpt), sockpt, ARG1, s_bind);
switch SOCKTYP(sockpt) {
default:
- ASSERT(0, sockpt, s_unkfam, s_bind);
+ ASRTER(0, sockpt, s_unkfam, s_bind);
case AF_UNIX:
- ASSERT(NIMP(address) && STRINGP(address), address, ARG2, s_bind);
+ ASRTER(NIMP(address) && STRINGP(address), address, ARG2, s_bind);
{
struct sockaddr_un sa_server;
bzero((char *) &sa_server, sizeof(sa_server));
@@ -449,7 +452,7 @@ SCM l_bind(sockpt, address)
}
break;
case AF_INET:
- ASSERT(INUMP(address), address, ARG2, s_bind);
+ ASRTER(INUMP(address), address, ARG2, s_bind);
{
struct sockaddr_in sa_server;
bzero((char *) &sa_server, sizeof(sa_server));
@@ -470,8 +473,8 @@ SCM l_listen(port, backlog)
{
long flags;
int sts;
- ASSERT(NIMP(port) && SOCKP(port), port, ARG1, s_listen);
- ASSERT(INUMP(backlog), backlog, ARG2, s_listen);
+ ASRTER(NIMP(port) && SOCKP(port), port, ARG1, s_listen);
+ ASRTER(INUMP(backlog), backlog, ARG2, s_listen);
SYSCALL(sts = listen(fileno(STREAM(port)), INUM(backlog)););
if (sts) return BOOL_F;
DEFER_INTS;
@@ -491,7 +494,7 @@ SCM l_accept(sockpt)
FILE *newfd;
SCM newpt;
NEWCELL(newpt);
- ASSERT(NIMP(sockpt) && OPINPORTP(sockpt), sockpt, ARG1, s_accept);
+ ASRTER(NIMP(sockpt) && OPINPORTP(sockpt), sockpt, ARG1, s_accept);
sadlen=sizeof(sad);
SYSCALL(newsd = accept(fileno(STREAM(sockpt)), &sad, &sadlen););
if (-1==newsd) {
@@ -548,7 +551,7 @@ char s_sknm_family[] = "socket-name:family";
SCM l_sknm_family(snm)
SCM snm;
{
- ASSERT(NIMP(snm) && TYP16(snm)==tc16_sknm, snm, ARG1, s_sknm_family);
+ ASRTER(NIMP(snm) && TYP16(snm)==tc16_sknm, snm, ARG1, s_sknm_family);
return MAKINUM(((struct sockaddr *)CDR(snm))->sa_family + 0L);
}
char s_sknm_port_num[] = "socket-name:port-number";
@@ -600,11 +603,11 @@ SCM l_getpeername(sockpt)
struct sockaddr_in sad;
int sts, sadlen = sizeof(sad);
bzero((char *) &sad, sizeof(sad));
- ASSERT(NIMP(sockpt) && OPFPORTP(sockpt), sockpt, ARG1, s_getpeername);
+ ASRTER(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;
-/* ASSERT(sad.sin_family==AF_INET, sockpt, "non-internet", s_getpeername); */
+/* ASRTER(sad.sin_family==AF_INET, sockpt, "non-internet", s_getpeername); */
return maksknm(&sad);
}
static char s_getsockname[] = "getsockname";
@@ -614,7 +617,7 @@ SCM l_getsockname(sockpt)
struct sockaddr_in sad;
int sts, sadlen = sizeof(sad);
bzero((char *) &sad, sizeof(sad));
- ASSERT(NIMP(sockpt) && OPFPORTP(sockpt), sockpt, ARG1, s_getsockname);
+ ASRTER(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;
@@ -625,7 +628,6 @@ static iproc subr1s[] = {
{s_inetstr, l_inetstr},
{s_network, l_network},
{s_lna, l_lna},
- {s_makaddr, l_makaddr},
{s_accept, l_accept},
{s_sknm_family, l_sknm_family},