From 2020c0cb428eaa9f7a48f48cee9eec03324e9ee6 Mon Sep 17 00:00:00 2001 From: "Jeffrey H. Johnson" Date: Sun, 27 Oct 2024 05:02:46 -0400 Subject: [PATCH] Portability improvements, cleanup, and bug fixes * Add or fix support for building on Solaris, illumos, Linux/musl, NetBSD, OpenBSD, IBM AIX, IBM OS/400 (PASE), Cygwin, and Haiku, which weren't previously cleanly building. * Use `pkg-config` when available to determine CFLAGS and libraries. * Initialize some variables in `supdupd`. * Fix off-by-one error in `supdup`. * Suppress spurious error when Chaosnet bridge socket is missing. * Create `README.md`. * Cleanup Makefile. * Properly detect bad ports (negative or >65535). * Fix non-ANSI function declarations. * Add `*.ln` (*Lint*) files, `supdupd`, and `compile_commands.json` to `.gitignore`. * Create `.gitattributes`. * Ensure file handle is valid (non-negative) before closing. * Correct various spelling errors. * Tested build under Oracle Solaris, OpenIndiana illumos, Linux/musl, Linux/glibc, IBM AIX, IBM OS/400 (PASE), Haiku, FreeBSD, OpenBSD, NetBSD, DragonFly BSD, Cygwin, and Apple macOS. * Compilation tested and working with PCC, GCC, Clang, Xcode, IBM XL C, IBM Open XL C, Oracle Studio C, NVIDIA HPC SDK C, Portland Group C, and DMD ImportC. * Passes Cppcheck and Clang Analyzer. * Closes: #25, #35, #38 Signed-off-by: Jeffrey H. Johnson --- .gitignore | 3 ++ INFO | 2 +- Makefile | 91 +++++++++++++++++++++++++++++++++++++++-------- README.md | 96 +++++++++++++++++++++++++++++++++++++++++++++++++- chaos.c | 8 +++-- supdup-login.c | 2 +- supdup.c | 62 +++++++++++++++++++++----------- supdup.h | 2 +- supdupd.c | 35 ++++++++++++------ tcp.c | 17 +++++++-- 10 files changed, 262 insertions(+), 56 deletions(-) diff --git a/.gitignore b/.gitignore index 770c0cf..1ddbfcf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ *~ *.o +*.ln +compile_commands.json /supdup +/supdupd diff --git a/INFO b/INFO index f9a3706..106651f 100644 --- a/INFO +++ b/INFO @@ -26,7 +26,7 @@ reappears. They also have a bug that if you type a meta character the character that gets sent is shifted and if you type meta shift character it sends a lowercase character. There is nothing I can do about this. -For some reason talk, amoung a few other things, core dumps when +For some reason talk, among a few other things, core dumps when supduping in from a lisp machine (either a 3600 or a cadr). I've seen the same bug a BBN bitgraph. It seems to be a bug with programs which use curses and is evoked by large screen sizes. diff --git a/Makefile b/Makefile index a2941f5..09010cf 100644 --- a/Makefile +++ b/Makefile @@ -1,36 +1,97 @@ # Makefile for the supdup server and client. -PREFIX ?= /usr/local +SHELL=/bin/sh +PREFIX?=/usr/local -OS_NAME = $(shell uname) -ifeq ($(OS_NAME), Darwin) -OS = OSX +OS_NAME?=$(shell uname 2> /dev/null) +CFLAGS+=$(shell pkg-config --cflags ncurses 2> /dev/null) +NCURSES_LIBS?=$(shell pkg-config --libs ncurses 2> /dev/null || printf '%s' "-lncurses") + +# AIX (requires linking libcurses *after* libncurses!) +ifeq ($(OS_NAME),AIX) + EXTRA_LDFLAGS=-lcurses +endif + +# Mac OS X +ifeq ($(OS_NAME),Darwin) + ifneq (,$(wildcard /opt/local/include)) + CFLAGS+=-I/opt/local/include + else + ifneq (,$(wildcard /usr/local/include)) + CFLAGS+=-I/usr/local/include + endif + endif + ifneq (,$(wildcard /opt/local/lib)) + LDFLAGS+=-L/opt/local/lib + else + ifneq (,$(wildcard /usr/local/lib)) + LDFLAGS+=-L/usr/local/lib + endif + endif +endif + +# Solaris and illumos +ifeq ($(OS_NAME),SunOS) + CFLAGS+=-I/usr/include/ncurses + EXTRA_LDFLAGS=-lnsl -lsocket endif -CC = cc -CFLAGS = -g -Wall -LDFLAGS = -g +# Haiku +ifeq ($(OS_NAME),Haiku) + EXTRA_LDFLAGS=-lnetwork +endif -# Mac OSX -ifeq ($(OS), OSX) -LDFLAGS = -L/opt/local/lib +# NetBSD +ifeq ($(OS_NAME),NetBSD) + CFLAGS+=-I/usr/pkg/include -I/usr/pkg/include/ncurses + LDFLAGS+=-L/usr/pkg/lib endif -# The server isn't ready for prime time. -all: supdup +# The server (supdupd) and supdup-login aren't ready for prime time. +.PHONY: all +all: supdup SUPDUP_OBJS = supdup.o charmap.o tcp.o chaos.o supdup: $(SUPDUP_OBJS) - $(CC) $(LDFLAGS) -o $@ $(SUPDUP_OBJS) -lncurses + $(CC) $(LDFLAGS) -o $@ $(SUPDUP_OBJS) $(NCURSES_LIBS) $(EXTRA_LDFLAGS) SUPDUPD_OBJS = supdupd.o supdupd: $(SUPDUPD_OBJS) $(CC) $(LDFLAGS) -o $@ $(SUPDUPD_OBJS) +.PHONY: install install: supdup install -m 0755 supdup $(PREFIX)/bin test -x supdupd && install -m 0755 supdupd $(PREFIX)/bin +.PHONY: clean clean: - rm -f *.o - rm -f supdup supdupd + $(RM) *.o + $(RM) supdup supdupd + +.PHONY: distclean +distclean: clean + $(RM) *~ *.bak core *.core + +.PHONY: printvars printenv +printvars printenv: + -@printf '%s: ' "FEATURES" 2> /dev/null + -@printf '%s ' "$(.FEATURES)" 2> /dev/null + -@printf '%s\n' "" 2> /dev/null + -@$(foreach V,$(sort $(.VARIABLES)), \ + $(if $(filter-out environment% default automatic,$(origin $V)), \ + $(if $(strip $($V)),$(info $V: [$($V)]),))) + -@true > /dev/null 2>&1 + +.PHONY: print-% +print-%: + -@$(info $*: [$($*)] ($(flavor $*). set by $(origin $*)))@true + -@true > /dev/null 2>&1 + +# Dependencies +chaos.o: chaos.c supdup.h +charmap.o: charmap.c charmap.h +supdup.o: supdup.c supdup.h charmap.h +supdupd.o: supdupd.c supdup.h +supdup-login.o: supdup-login.c +tcp.o: tcp.c supdup.h diff --git a/README.md b/README.md index 92fcddb..e1c88bf 100644 --- a/README.md +++ b/README.md @@ -1 +1,95 @@ -![](https://travis-ci.org/larsbrinkhoff/lbForth.svg?branch=master) +# `supdup` + +## Overview + +* `supdup` is a client (and `supdupd` is a server) implementing the SUPDUP (*Sup*er *Dup*er TELNET) protocol, a highly efficient [TELNET](https://www.rfc-editor.org/rfc/rfc854.txt)-style remote display protocol, on UNIX-like systems. + +* It originated as a private protocol between the [Chaosnet](https://chaosnet.net/)-connected ITS systems at MIT to allow a user at any one of these systems to use one of the others as a display; later implementations were developed for [various platforms](https://gunkies.org/wiki/Chaosnet#Protocol_implementations). + +* The software creates connections over TCP/IP and Chaosnet (optionally using the [cbridge](https://github.com/bictorv/chaosnet-bridge) software). + +## Tested platforms + +* Tested operating systems: Oracle Solaris, OpenIndiana illumos, Linux/musl, Linux/glibc, IBM AIX, IBM OS/400 (PASE), Haiku, FreeBSD, OpenBSD, NetBSD, DragonFly BSD, Cygwin, and Apple macOS. + +## Tested compilers + +* Tested compilers: PCC, GCC, Clang, Xcode, IBM XL C, IBM Open XL C, Oracle Studio C, NVIDIA HPC SDK C, Portland Group C, and DMD ImportC. + +## Building the `supdup` client + +### Generic UNIX + +* Building on generic UNIX-like systems (**Linux**, **\*BSD**, **macOS**, **Haiku**, etc.): + * Install prerequisite packages: + * Required: `make` (GNU), `ncurses` (libraries and headers), + * Recommended: `pkg-config` + * Build: `gmake` (or sometimes just `make`) +[]() + +[]() +* The usual environment variables (*e.g.* `CC`, `CFLAGS`, `LDFLAGS`, etc.) are respected, for example: + * `env CC="gcc" CFLAGS="-Wall" LDFLAGS="-L/usr/local" gmake` + +### IBM AIX + +* Building on IBM AIX 7: + * Install prerequisite packages: + * `dnf install make ncurses-devel pkg-config` + * Build with IBM XL C V16: + * `env CC="xlc" CFLAGS="-q64" LDFLAGS="-q64" gmake` + * Build with IBM Open XL C V17: + * `env CC="ibm-clang" CFLAGS="-m64" LDFLAGS="-m64" gmake` + * Build with GNU GCC: + * `env CC="gcc" CFLAGS="-maix64" LDFLAGS="-maix64 -Wl,-b64" gmake` + * Build with Clang: + * `env CC="clang" CFLAGS="-m64" LDFLAGS="-m64" gmake` + +### IBM i (OS/400) + +* Building on PASE for IBM i (OS/400): + * Install prerequisite packages: + * `yum install gcc10 make-gnu ncurses-devel pkg-config` + * Build with GNU GCC: + * `env CC="gcc-10" CFLAGS="-maix64" LDFLAGS="-maix64 -Wl,-b64" gmake` + +### DMD ImportC + +* Building with DMD ImportC: + * `dmd -betterC -c -of=supdup.o chaos.c charmap.c supdup.c tcp.c $(pkg-config --cflags-only-I ncurses)` + * `cc -o supdup supdup.o $(pkg-config --libs ncurses)` + +## Building the `supdup` server + +* An *experimental* server, `supdupd`, is included. +* The server component is *antiquated*, *incomplete*, and *will not* build on all platforms. +[]() + +[]() +* To build the server on generic UNIX-like systems: + * Install prerequisite packages: `make` (GNU) + * Build: `gmake` (or sometimes just `make`) + +## Bug Reporting + +* To report a problem with `supdup`, use GitHub Issues: + * https://github.com/PDP-10/supdup/issues/new/choose + +## External links + +### SUPDUP + +* [RFC 734: SUPDUP Protocol](https://www.rfc-editor.org/rfc/rfc734.txt) +* [RFC 736: TELNET SUPDUP Option](https://www.rfc-editor.org/rfc/rfc736.txt) +* [RFC 746: The SUPDUP Graphics Extension](https://www.rfc-editor.org/rfc/rfc746.txt) +* [RFC 747: Recent Extensions to the SUPDUP Protocol](https://www.rfc-editor.org/rfc/rfc747.txt) +* [RFC 749: TELNET SUPDUP-OUTPUT Option](https://www.rfc-editor.org/rfc/rfc749.txt) +* [AI Memo 643: A Local Front End for Remote Editing](http://www.bitsavers.org/pdf/mit/ai/aim/AIM-643.pdf) +* [AI Memo 644: The SUPDUP Protocol](http://www.bitsavers.org/pdf/mit/ai/aim/AIM-644.pdf) +* [PuTTY: SUPDUP Backend](https://git.tartarus.org/?p=simon/putty.git;a=blob;f=otherbackends/supdup.c;h=6f574c9fb9c34b1307b67326038aa713c2b1d07a;hb=HEAD) + +### Chaosnet + +* [AI Memo 628: Chaosnet](http://bitsavers.org/pdf/mit/ai/AIM-628_chaosnet.pdf) +* [Chaosnet Bridge](https://github.com/bictorv/chaosnet-bridge) +* [Chaosnet Wiki](https://chaosnet.net/) diff --git a/chaos.c b/chaos.c index 37609dd..d2c3b89 100644 --- a/chaos.c +++ b/chaos.c @@ -9,7 +9,8 @@ #include #include #include -#include +#include +#include // Where are the chaos sockets? Cf. https://github.com/bictorv/chaosnet-bridge #ifndef CHAOS_SOCKET_DIRECTORY @@ -41,7 +42,7 @@ connect_to_named_socket(int socktype, char *path) slen = strlen(server.sun_path)+ 1 + sizeof(server.sun_family); if (connect(sock, (struct sockaddr *)&server, slen) < 0) { - if (errno != ECONNREFUSED) + if (errno != ENOENT) // Fail silently if Chaosnet bridge is not there perror("connect(server)"); return -1; @@ -114,7 +115,8 @@ chaos_connect(const char *hostname, const char *contact) if (contact == NULL) contact = "SUPDUP"; if (connection(fd, hostname, contact) < 0) { - close(fd); + if (fd >= 0) + close(fd); return -1; } return fd; diff --git a/supdup-login.c b/supdup-login.c index 9d29988..1f4f476 100644 --- a/supdup-login.c +++ b/supdup-login.c @@ -658,7 +658,7 @@ doremoteterm(term, tp) tp->sg_flags = ECHO|CRMOD|ANYP|XTABS; } -#ifdef 0 +#if 0 /* Use syslog instead */ logerr(fmt, a1, a2, a3) char *fmt, *a1, *a2, *a3; diff --git a/supdup.c b/supdup.c index 1b2d79f..e9ae0ac 100644 --- a/supdup.c +++ b/supdup.c @@ -31,12 +31,13 @@ */ #ifndef USE_TERMIOS -#define USE_TERMIOS 1 /* e.g. Linux */ +#define USE_TERMIOS 1 /* e.g. Linux, SysV */ #endif #ifndef USE_BSD_SELECT -#define USE_BSD_SELECT 0 /* not e.g. Linux */ +#define USE_BSD_SELECT 0 /* e.g. not Linux, SysV */ #endif +#include #include #include @@ -50,11 +51,16 @@ #include #include -#include +#include #include #include #include +#ifdef __sun +#include +#include +#endif + #include "supdup.h" #include "charmap.h" @@ -153,9 +159,13 @@ int currcol, currline; /* Current cursor position */ void sup_term(void); void supdup (char *loc); void intr(int), deadpeer(int); -char *key_name(int); +char *local_key_name(int); struct cmd *getcmd(void); +#ifdef __HAIKU__ +#define speed_t unsigned int +#endif + #if !USE_TERMIOS struct tchars otc; struct ltchars oltc; @@ -178,7 +188,7 @@ int putch (int c) } -void put_newline () +void put_newline (void) { if (newline) tputs (newline, 1, putch); @@ -428,7 +438,7 @@ main (int argc, char **argv) connected = 1; printf ("Connected to %s.\n", hostname); - printf ("Escape character is \"%s\".", key_name (escape_char)); + printf ("Escape character is \"%s\".", local_key_name (escape_char)); fflush (stdout); mode (1); if (clr_eos) @@ -628,8 +638,16 @@ mode (int f) sb.sg_erase = sb.sg_kill = -1; tc = ¬c; ltc = &noltc; +#else +#ifdef __sun + ntio.c_iflag &= ~(IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); + ntio.c_oflag &= ~OPOST; + ntio.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); + ntio.c_cflag &= ~(CSIZE|PARENB); + ntio.c_cflag |= CS8; #else cfmakeraw(&ntio); +#endif #endif onoff = 1; break; @@ -959,7 +977,7 @@ command (unsigned char chr) { clear_bottom_line (); printf ("?Invalid SUPDUP command \"%s\"", - key_name (chr)); + local_key_name (chr)); ttyoflush (); return; } @@ -989,7 +1007,7 @@ status (void) printf(" (Console location: \"%s\")", myloc); ttyoflush (); put_newline (); - printf ("Escape character is \"%s\".", key_name (escape_char)); + printf ("Escape character is \"%s\".", local_key_name (escape_char)); ttyoflush (); /* eat space, or unread others */ { @@ -1030,7 +1048,7 @@ suspend (void) tcsetattr(0, TCSANOW, &otio); #endif (void) mode (save); - *netfrontp++ = ITP_ESCAPE; /* Tell other end that it sould refresh */ + *netfrontp++ = ITP_ESCAPE; /* Tell other end that it should refresh */ *netfrontp++ = ITP_PIATY; /* the screen */ restore (); } @@ -1058,18 +1076,18 @@ help (void) ttyoflush (); printf ("Type \"%s\" followed by the command character. Commands are:", - key_name (escape_char)); + local_key_name (escape_char)); ttyoflush (); put_newline (); printf (" %-8s%s", - key_name (escape_char), + local_key_name (escape_char), "sends escape character through"); ttyoflush (); for (c = cmdtab; c->name; c++) { put_newline (); printf (" %-8s%s", - key_name (c->name), + local_key_name (c->name), c->help); } ttyoflush (); @@ -1115,7 +1133,7 @@ setloc(void) else fprintf(stdout,"Set console location: "); ttyoflush(); - for (i = 0; i < sizeof(loc); i++) { + for (i = 0; i < sizeof(loc)-1; i++) { c = read_char(); if (c == Ctl ('g')) { /* abort */ restore (); @@ -1557,12 +1575,12 @@ netflush (int dont_die) } -char key_name_buffer[20]; +char local_key_name_buffer[20]; char * -key_name (int c) +local_key_name (int c) { - char *p = key_name_buffer; + char *p = local_key_name_buffer; if (c >= 0200) { *p++ = 'M'; @@ -1620,17 +1638,19 @@ key_name (int c) else *p++ = c; *p++ = 0; - return (key_name_buffer); + return (local_key_name_buffer); } void deadpeer(int sig) { + (void)sig; mode (0); longjmp (peerdied, -1); } void intr (int sig) { + (void)sig; mode (0); exit (1); } @@ -1653,7 +1673,7 @@ setescape (void) ttyoflush (); escape_char = read_char (); clear_bottom_line (); - printf ("Escape character is \"%s\".", key_name (escape_char)); + printf ("Escape character is \"%s\".", local_key_name (escape_char)); ttyoflush (); } @@ -1662,7 +1682,7 @@ setoptions (void) { showoptions = !showoptions; clear_bottom_line (); - printf ("%s show option processing.", showoptions ? "Will" : "Wont"); + printf ("%s show option processing.", showoptions ? "Will" : "Won't"); ttyoflush (); } #endif /* 0 */ @@ -1674,7 +1694,7 @@ setcrmod (void) { crmod = !crmod; clear_bottom_line (); - printf ("%s map carriage return on output.", crmod ? "Will" : "Wont"); + printf ("%s map carriage return on output.", crmod ? "Will" : "Won't"); ttyoflush (); } #endif /* 0 */ @@ -1685,7 +1705,7 @@ setdebug (void) { debug = !debug; clear_bottom_line (); - printf ("%s turn on socket level debugging.", debug ? "Will" : "Wont"); + printf ("%s turn on socket level debugging.", debug ? "Will" : "Won't"); if (debug && net > 0 && setsockopt (net, SOL_SOCKET, SO_DEBUG, 0, 0) < 0) perror ("setsockopt (SO_DEBUG)"); ttyoflush (); diff --git a/supdup.h b/supdup.h index 76c9e01..446bf7d 100644 --- a/supdup.h +++ b/supdup.h @@ -42,7 +42,7 @@ #define ITP_MTA 00400 /* META key depressed */ #define ITP_TOP 04000 /* TOP key depressed */ #define CTL_PREFIX 0237 /* c-m-_ is control prefix */ -#define ITP_CHAR(char1,char2) (((char1 & 037) << 7) + char2) +#define ITP_CHAR(char1,char2) ((((char1) & 037) << 7) + (char2)) #define ITP_ESCAPE 034 /* ITS ITP codes follow */ #define ITP_CURSORPOS 020 /* user sends vpos/hpos */ diff --git a/supdupd.c b/supdupd.c index e22f51a..21ee8c7 100644 --- a/supdupd.c +++ b/supdupd.c @@ -25,8 +25,18 @@ /* #define TERMINFO 1 */ /* Define if want terminfo support. */ /* there should be a TERMCAP too */ -#define _XOPEN_SOURCE 500 /* for unlockpt and ptsname */ +#ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE +#endif + +#ifndef _XOPEN_SOURCE +#define _XOPEN_SOURCE 500 /* for unlockpt and ptsname */ +#endif +#if _XOPEN_SOURCE < 500 +#undef _XOPEN_SOURCE +#define _XOPEN_SOURCE 500 +#endif + #include #include @@ -172,7 +182,7 @@ void echo_char (unsigned char c) #ifdef DAEMON int main (int argc, char *argv[]) { - int s, pid, options; + int s, pid, options = 0; struct servent *sp; #ifdef DEBUG @@ -232,7 +242,7 @@ int main (int argc, char *argv[]) perror ("telnetd: setsockopt (SO_DEBUG)"); if (setsockopt (s, SOL_SOCKET, SO_KEEPALIVE, 0, 0) < 0) perror ("supdupd: setsockopt (SO_KEEPALIVE)"); - while (bind (s, (caddr_t) &sin, sizeof (sin)) < 0) + while (bind (s, (void *) &sin, sizeof (sin)) < 0) { perror ("supdupd: bind"); sleep (5); @@ -244,7 +254,7 @@ int main (int argc, char *argv[]) struct sockaddr_in from; int s2, fromlen = sizeof (from); - s2 = accept (s, (caddr_t)&from, &fromlen); + s2 = accept (s, (void *)&from, &fromlen); if (s2 < 0) { if (errno == EINTR) @@ -270,6 +280,7 @@ int main (int argc, char *argv[]) { struct sockaddr_in from; socklen_t fromlen = sizeof(from); + (void)argc; #ifdef DEBUG open_debug_output (); @@ -425,7 +436,11 @@ void fatalperror (int f, char *msg, int errn) fatalmsg (f, buf); } -static void sig_handler_cleanup(int sig) { cleanup(); } +static void sig_handler_cleanup(int sig) +{ + (void)sig; + cleanup(); +} /* * Main loop. Select from pty and network, and @@ -871,21 +886,21 @@ void do_crlf (void) /* base state */ #define RS_DATA 0 -/* recieved ITP_ESCAPE (034) Waiting for `m' */ +/* received ITP_ESCAPE (034) Waiting for `m' */ #define RS_ITP_ESCAPE 1 /* received ITP_ESCAPE, `m'>#o100 Waiting for `n'. Char will be (+ (* (- `m' #o100) #o200) `n') */ #define RS_BUCKY 2 -/* Recived ITP_ESCAPE, ITP_FLOW_CONTROL_INCREASE +/* Received ITP_ESCAPE, ITP_FLOW_CONTROL_INCREASE Ignore next char, since un*x can't hack real, winning, flow control */ #define RS_FLOW_CONTROL_INCREASE 3 -/* Recived ITP_ESCAPE, ITP_CURSORPOS +/* Received ITP_ESCAPE, ITP_CURSORPOS Waiting for `row' */ #define RS_CURSORPOS_1 4 -/* Recived ITP_ESCAPE, ITP_CURSORPOS, `row' +/* Received ITP_ESCAPE, ITP_CURSORPOS, `row' Waiting for `column' */ #define RS_CURSORPOS_2 5 @@ -1247,7 +1262,7 @@ void sup_options (int net) { char temp[6]; int count; - int tcmxh, tcmxv; + int tcmxh = 0, tcmxv = 0; read (net, temp, 6); /* Read count */ count = -((-1 << 6) | temp[2]); diff --git a/tcp.c b/tcp.c index 3a7ce97..869477f 100644 --- a/tcp.c +++ b/tcp.c @@ -1,14 +1,21 @@ /* TCP specific code, pulled out from supdup.c. */ #include +#include #include #include #include #include +#include #include #include #include "supdup.h" +#if defined(_AIX) || defined(__sun) +#undef bcopy +#define bcopy(__src, __dst, __len) memcpy(__dst, __src, __len) +#endif + #define STANDARD_PORT 95 /*Per gospel from St. Postel.*/ static int @@ -21,8 +28,12 @@ get_port(struct sockaddr_in *tsin, const char *port) else tsin->sin_port = sp->s_port; } else { + if ((atoi (port) < 0) || (atoi (port) > 65535)) { + fprintf(stderr,"%s: bad port number.\n", port); + return -1; + } tsin->sin_port = atoi (port); - if (tsin->sin_port <= 0) { + if (tsin->sin_port == 0) { fprintf(stderr,"%s: bad port number.\n", port); return -1; } @@ -40,9 +51,9 @@ get_host (struct sockaddr_in *tsin, const char *name) { tsin->sin_family = host->h_addrtype; #ifdef notdef - bcopy (host->h_addr_list[0], (caddr_t) &tsin->sin_addr, host->h_length); + bcopy (host->h_addr_list[0], (void *) &tsin->sin_addr, host->h_length); #else - bcopy (host->h_addr, (caddr_t) &tsin->sin_addr, host->h_length); + bcopy (host->h_addr, (void *) &tsin->sin_addr, host->h_length); #endif /* h_addr */ return 0; }