From ae2b295c7deaf2d7c18ad1ed9b6050970e56bae7 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 20 Feb 2017 00:05:31 -0800 Subject: Import Upstream version 5e2 --- socket.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'socket.c') diff --git a/socket.c b/socket.c index 290de2f..c2d1394 100644 --- a/socket.c +++ b/socket.c @@ -115,6 +115,7 @@ SCM l_network (host) return ulong2num(0L+inet_netof(addr)); } +#ifndef __CYGWIN__ static char s_lna[] = "inet:local-network-address"; SCM l_lna (host) SCM host; @@ -123,6 +124,7 @@ SCM l_lna (host) addr.s_addr = htonl(num2ulong(host, (char *)ARG1, s_lna)); return ulong2num(0L+inet_lnaof(addr)); } +#endif static char s_makaddr[] = "inet:make-address"; SCM l_makaddr (net, lna) @@ -135,6 +137,7 @@ SCM l_makaddr (net, lna) return ulong2num(ntohl(addr.s_addr)); } +#ifndef __CYGWIN__ static char s_hostinfo[] = "gethost"; SCM l_hostinfo(name) SCM name; @@ -144,15 +147,15 @@ SCM l_hostinfo(name) SCM lst = EOL; struct hostent *entry; struct in_addr inad; - char **argv; + const char **argv; int i = 0; -#ifndef linux - if UNBNDP(name) { +# ifndef linux + if (UNBNDP(name)) { DEFER_INTS; SYSCALL(entry = gethostent();); } else -#endif +# endif if (NIMP(name) && STRINGP(name)) { DEFER_INTS; SYSCALL(entry = gethostbyname(CHARS(name));); @@ -185,7 +188,7 @@ SCM l_netinfo(name) SCM ans = make_vector(MAKINUM(4), UNSPECIFIED); SCM *ve = VELTS(ans); struct netent *entry; - if UNBNDP(name) { + if (UNBNDP(name)) { DEFER_INTS; SYSCALL(entry = getnetent();); } @@ -207,6 +210,7 @@ SCM l_netinfo(name) ve[ 3] = ulong2num(entry->n_net + 0L); return ans; } +#endif static char s_protoinfo[] = "getproto"; SCM l_protoinfo(name) SCM name; @@ -214,7 +218,7 @@ SCM l_protoinfo(name) SCM ans = make_vector(MAKINUM(3), UNSPECIFIED); SCM *ve = VELTS(ans); struct protoent *entry; - if UNBNDP(name) { + if (UNBNDP(name)) { DEFER_INTS; SYSCALL(entry = getprotoent();); } @@ -243,7 +247,7 @@ SCM l_servinfo(args) SCM *ve = VELTS(ans); SCM name, proto; struct servent *entry; - if NULLP(args) { + if (NULLP(args)) { DEFER_INTS; SYSCALL(entry = getservent();); goto comlab; @@ -273,28 +277,30 @@ SCM l_servinfo(args) SCM l_sethost(arg) SCM arg; { - if UNBNDP(arg) endhostent(); + if (UNBNDP(arg)) endhostent(); else sethostent(NFALSEP(arg)); return UNSPECIFIED; } +#ifndef __CYGWIN__ SCM l_setnet(arg) SCM arg; { - if UNBNDP(arg) endnetent(); + if (UNBNDP(arg)) endnetent(); else setnetent(NFALSEP(arg)); return UNSPECIFIED; } +#endif SCM l_setproto(arg) SCM arg; { - if UNBNDP(arg) endprotoent(); + if (UNBNDP(arg)) endprotoent(); else setprotoent(NFALSEP(arg)); return UNSPECIFIED; } SCM l_setserv(arg) SCM arg; { - if UNBNDP(arg) endservent(); + if (UNBNDP(arg)) endservent(); else setservent(NFALSEP(arg)); return UNSPECIFIED; } @@ -307,7 +313,7 @@ SCM l_socket(fam, proto) FILE* f; SCM port; ASRTER(INUMP(fam), fam, ARG1, s_socket); - if UNBNDP(proto) proto = INUM0; + if (UNBNDP(proto)) proto = INUM0; else ASRTER(INUMP(proto), proto, ARG2, s_socket); NEWCELL(port); DEFER_INTS; @@ -342,7 +348,7 @@ SCM l_socketpair(fam, proto) FILE* f[2]; SCM port[2]; ASRTER(INUMP(fam), fam, ARG1, s_socketpair); - if UNBNDP(proto) proto = INUM0; + if (UNBNDP(proto)) proto = INUM0; else ASRTER(INUMP(proto), proto, ARG2, s_socketpair); NEWCELL(port[0]); NEWCELL(port[1]); DEFER_INTS; @@ -383,7 +389,7 @@ SCM l_shutdown(port, how) break; case 2: CAR(port) &= ~(RDNG | WRTNG); } - if SOCKP(port) close_port(port); /* can't read or write */ + if (SOCKP(port)) close_port(port); /* can't read or write */ return port; } static char s_unkfam[] = "unknown-family"; @@ -627,8 +633,9 @@ static iproc subr1s[] = { {s_inetaddr, l_inetaddr}, {s_inetstr, l_inetstr}, {s_network, l_network}, +#ifndef __CYGWIN__ {s_lna, l_lna}, - +#endif {s_accept, l_accept}, {s_sknm_family, l_sknm_family}, {s_sknm_port_num, l_sknm_port_num}, @@ -638,11 +645,13 @@ static iproc subr1s[] = { {0, 0}}; static iproc subr1os[] = { + {s_protoinfo, l_protoinfo}, +#ifndef __CYGWIN__ {s_hostinfo, l_hostinfo}, {s_netinfo, l_netinfo}, - {s_protoinfo, l_protoinfo}, - {"sethostent", l_sethost}, {"setnetent", l_setnet}, +#endif + {"sethostent", l_sethost}, {"setprotoent", l_setproto}, {"setservent", l_setserv}, {0, 0}}; -- cgit v1.2.3