Tuesday, April 14, 2015

vtprint - blast from the past

I recently decided to have a look back at some old stuff I wrote.  Blast from the past stuff.  One of the things I decided to look at was the very first open source program I wrote -- something called vtprint.

vtprint is a tool that borrowed ideas stolen from the pine mail program.  This comes from the days of serial dialups, and legacy (Kermit or ProComm for those who remember such things) serial connectivity over 14.4K modems.  Printing a file on a remote server was hard back then; you could transfer the file using xmodem using rx(1), or its "newer" variants, rb(1) or rz(1), but this was awkward.  It turns out that most physical terminals had support for an escape sequence that would start hardcopy to a locally attached printer, and another that would stop it.  And indeed, many terminal emulators have the same support.  (I added support for this myself to the rxvt(1) terminal emulator back in the mid 90's, so any emulators derived from rxvt inherit this support as well.)

So vtprint, which in retrospect could have been written in a few lines of shell code, is a C program.  It supports configuration via a custom file called "vtprintcap", that can provide information about different $TERM values and the escape sequences they use.  So for example, TVI925 terminals use a different escape sequence than VT100 or VT220 terminals.

The first version of it, 1.0, is lost in time, and was written back in 1991 or 1992 while I was working as a "Computer Consultant" (fancy name for BOFH, though I also did a lot of programming for the school's Windows 3.1 network and Novell NetWare 3.12 server) at the Haas School of Business at UC Berkeley.  (I was a Chemical Engineering student there, and I flunked out in thermodynamics -- I still blame Gibbs Free Energy ΔG as a concept I never truly could get my mind around.  It took a couple of years before I finally gave up fighting "hard engineering" and accepted my true calling as a software engineer.)

Anyway, I transferred to SDSU into the Computer Science department.  While there, back in 1993, I updated vtprint significantly, and that is the release that lives on at SourceForge.

Today I imported that project to github.  (And let me tell you, it took some hoops to do this.  Apparently all the old CVS projects that were going to have converted to CVS are supposed to already have done so, because at this point even the conversion tools are mostly crufty and broken.  Maybe I'll post what I did there.)  Most of the files indicate an age of 11 years ago.  That's because 11 years ago I imported the source into CVS for the benefit of SourceForge.  The actual files date back to 1994, and you can even see my old email address -- which hasn't worked for a couple of decades, in the files.

So, I gave vtprint a whirl today for the first time in years:

garrett@hipster{4}> ./vtprint README
*** vtprint (v2.0.2) ***
Copyright 1993-1994, Garrett D'AmoreLast revised October 25, 1994.
NO WARRANTY!  Use "vtprint -w" for info.Freely redistributable.  Use "vtprint -l" for info.
vtprint: Can't open /usr/local/lib/vtprint/vtprintcap, using builtin codes.vtprint: Using <stdout> for output.vtprint: Output flags: formfeedvtprint: Printed README.vtprint: Successfully printed 1 file (1 specified).

Sadly, MacOS X Terminal.app does not appear to emulate the escape sequences properly.  But iTerm2 does so very nicely.  It even generates a nice print preview using the standard MacOS X print dialog.  Sadly, it does not pass through PostScript unmolested, but for printing ASCII files it works beautifully.

I think that I'm going to start using vtprint again, when I need to print a file located on a virtual machine, or over a connection that only offers SSH (such as a secured access machine).  With firewalled networks, I suspect that this program has new usefulness.  I'm also switching from Terminal.app (as many people have suggested) to iTerm2.

No comments: