Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portability improvements, cleanup, and bug fixes #36

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
*~
*.o
*.ln
compile_commands.json
/supdup
/supdupd
2 changes: 1 addition & 1 deletion INFO
Original file line number Diff line number Diff line change
Expand Up @@ -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.
91 changes: 76 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
96 changes: 95 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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/)
8 changes: 5 additions & 3 deletions chaos.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#include <unistd.h>
#include <string.h>
#include <sys/un.h>
#include <sys/errno.h>
#include <errno.h>
#include <sys/socket.h>

// Where are the chaos sockets? Cf. https://github.com/bictorv/chaosnet-bridge
#ifndef CHAOS_SOCKET_DIRECTORY
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion supdup-login.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading