Interpinkie, a Finger client in Interlisp

I wrote Interpinkie, a basic Finger client in Interlisp that runs on the Medley environment. This is the main window of the program:

Main window of the Interpinkie Interlisp Finger client.

It was a fun challenge considering I couldn't use Medley's TCP/IP stack.

I always wanted to do some network programming with Medley. But the bitrot of its TCP/IP stack left it in a non working state since before the Medley Interlisp project, and the revival effort hasn't got around to the stack yet. The XNS stack still mostly works with the Dodo Services XNS implementation. But, as far as I know, XNS provides LAN services and I'm not sure whether or how it allows access to the outside Internet.

So I cheated and reached for Medley's escape hatch.

As part of the Medley modernization effort, the UNIXUTILS library module provides the ShellCommand function to run a Unix program on the host operating system and send the output to a stream. Since I can run arbitrary Unix commands from Medley, it's trivial to build a client that talks the Finger protocol via Netcat.

For example, to run the Finger query amoroso@happynetbox.com I can just execute this from the Linux shell:

$ echo "amoroso" | nc -C -w 3 happynetbox.com finger

where -C sends \r\n as line-ending, -w 3 sets a timeout of 3 seconds, and finger is the Finger port number as per /etc/services.

All Interpinkie does is to build and feed a query to ShellCommand, pipe the output through tr to remove extra \rs, and redirect the output to a suitable destination.

The Interlisp function QUERY.FINGER.SERVER wraps this functionality. By default the output goes to the primary output (Interlisp jargon for stdout), or optionally to a separate window with menu options for running another Finger query or quitting the program.

Interpinkie builds upon user interface techniques I used in previous projects such as attaching a menu to a TEdit window.

TEdit, the WYSIWYG the rich text editor of Medley, can be driven by other programs that send output to the editor buffer. This is handy as the programs get an automatically repainted scrollable window for free from TEdit. In addition, Interpinkie attaches a command menu to the TEdit window and uses TEdit's prompt window (Interlisp jargon for an edit field and status area) to request input and display errors.

Unlike my previous Interlisp projects, however, Interpinkie doesn't call the TEdit API to insert text in the buffer. Instead, the program redirects the ShellCommand output to the Lisp stream associated with the TEdit window, causing the text to appear in the buffer.

By default ordinary Lisp printing functions such as PRIN1 and PRINT send the output to the REPL or optionally to another Lisp I/O stream. Along with these output destinations, some Interlisp components and programs like TEdit have an associated stream. So it's easy to send output to TEdit by just printing to the stream returned by (TEXTSTREAM Window), where Window is a TEdit window, or redirecting to that stream the output of printing functions like PRIN1. In other words, ordinary stream I/O is the API.

Since ShellCommand accepts a stream as an optional argument, QUERY.FINGER.SERVER passes TEdit's stream to ShellCommand thus causing the output to go to the editor buffer. The benefit is Interpinkie uses the same QUERY.FINGER.SERVER function to output to both the primary output and a TEdit window.

If the destination is a window Interpinkie does some additional processing before and after sending the output. For example, before doing output the program updates the window title to reflect the Finger query, and sets the TEdit buffer to read-only once the output finishes.

These days there are not many Finger servers and I was lucky to stumble upon happynetbox.com. It is managed by Happy Net Box, a nice public Finger server anyone can sign up to for for free and publish a status file. Happy Nex Box was essential for developing and testing Interpinkie, as well as fun — and addictive — as you can see by running the query random@happynetbox.com to look up a random user.

#Interpinkie #Interlisp #Lisp

Discuss... Email | Reply @amoroso@fosstodon.org