From:	CSBVAX::MRGATE!info-vax-RELAY@KL.SRI.COM@SMTP 18-JUL-1988 23:30
To:	ARISIA::EVERHART
Subj:	Unix termcap to VMS termtable converter 1/3


Received: from Csa4.LBL.Gov by KL.SRI.COM with TCP; Wed, 13 Jul 88 12:17:31 PDT
Date:    Wed, 13 Jul 88 12:15:23 PDT
From:     forrest@Csa4.LBL.Gov
Message-Id: <880713121523.280025a9@Csa4.LBL.Gov>
Subject: Unix termcap to VMS termtable converter 1/3
To:       info-vax@kl.sri.com
X-ST-Vmsmail-To: ST%"info-vax@kl.sri.com"

........................ Cut between dotted lines and save ......................
$!..............................................................................
$! VAX/VMS archive file created by VMS_SHAR V-4.03 05-Aug-1987
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by FORREST
$!      on Wednesday 13-JUL-1988 12:08:34.91
$!
$! ATTENTION: To keep each article below 15872 bytes, this program
$!            has been transmitted in 2 parts.
$! You should concatenate ALL parts to ONE file and execute (@) that file.
$!
$! It contains the following 3 files:
$! README.TC2TT TC2TT.C TABLE.H
$!==============================================================================
$ Set Symbol/Scope=(NoLocal,NoGlobal)
$ Version=F$GetSYI("VERSION") ! See what VMS version we have here:
$ If Version.ges."V4.4" then goto Version_OK
$ Write SYS$Output "Sorry, you are running VMS ",Version, -
                ", but this procedure requires V4.4 or higher."
$ Exit 44
$Version_OK: CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1: Define/User_Mode SYS$Output NL:
$ Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
        VMS_SHAR_DUMMY.DUMMY
f:=Get_Info(Command_Line,"File_Name");b:=Create_Buffer("",f);
o:=Get_Info(Command_Line,"Output_File");Set (Output_File,b,o);
Position (Beginning_of(b));Loop x:=Erase_Character(1); Loop ExitIf x<>"V";
Move_Vertical(1);x:=Erase_Character(1);Append_Line;Move_Horizontal
(-Current_Offset);EndLoop;Move_Vertical(1);ExitIf Mark(None)=End_of(b)
EndLoop;Exit;
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2: Return
$Start:
$ File_is="README.TC2TT"
$ Check_Sum_is=1633702059
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
XThis is the beta test version of a program that attempts to convert a
XUnix "termcap" file into a VMS TERMTABLE.TXT file. Two output files
Xare produced, a file called TERMTABLE.TXT containing SMG equivalents
Xof what was found in termcap, and a file called ERRLOG. containing
Xinformation about things TC2TT wasn't able to do. It is important
Xthat ERRLOG. be examined after running TC2TT to see what happened.
XDEC recommends, and I concur, that only terminals actually in use
Xat a site be kept in TERMTABLE.TXT. This requires that someone
Xedit TERMTABLE.TXT before the SMGBLDTRM program is run.
X
XThe task of converting termcap into TERMTABLE.TXT is made difficult by
Xseveral factors.
X
X1) There is no real standard for termcap files. In the process
Xof writing this program I have found termcap entries that don't
Xfollow the TERMCAP(5) manual page. My guess is that such entries
Xare fixed when the terminal with the errant entry
Xappears at the site. This program makes an attempt to diagnose
Xabnormal entries but no claim is made that this effort will
Xalways succeed.
X
X2) Although the VMS documentation does a reasonable job at explaining
Xthe contents of a TERMTABLE.TXT file, several key areas are ignored.
XFor example, DEC doesn't allow '-' or '+' characters in terminal names
Xalthough I couldn't find any specific mention of this restriction.
XSince these characters are used in many places in termcap something
Xhad to be done. My choice was to convert the '-' to '_' and to
Xconvert '+' into the string 'plus'. I hope this is the right thing
Xto do.
X
X3) More serious is the fact that strings in TERMTABLE.TXT can't be
Xlonger than 128 characters isn't documentated. This is a problem
Xbecause also not documented is the fact that if a string capability
Xappears more than once in a terminal description, the second string
Xdefinition is appended to the first definition. In the termcap file
XI used to test TC2TT there are several termcap entries that result
Xin more than one INIT_STRING capability, with a total length of over
X128 characters. Such problems show up as a "expression too complex"
Xerror message from SMGBLDTRM. This problem could be solved by keeping
Xtrack of whether a capability has already been used and, if so, ignoring
Xany subsequent usage.
X
X4) Termcap and curses assume a top left origin of (0,0) whereas
XSMG uses (1,1). Given that DEC VTxxx family terminals also use
Xa (1,1) origin this isn't too surprising. Termcap handles this
Xproblem by using the "%i" construct, which adds 1 to both the line
Xand column values being sent to the terminal. In order to work with
Xterminals with (0,0) origins, SMG entries must subtract 1 from the 
Xline and column values sent to terminals. This is why some entries
Xin the TERMTABLE.TXT file produced by TC2TT have SET_CURSOR_ABS
Xstrings containing expressions with -1.
X
X5) In many cases DEC ignores capabilities that are expressed in termcap.
XIn these cases TC2TT outputs a message into the errorlog file.
XOne good example is the "%2d" type of construct in termcap.
XThis is used, for example, when an integer is being sent to a terminal.
XApparently, some terminal only want to receive 2 digits, and
Xno more. Although the SYS$FAO system service allows constructs
Xsuch as !2UL, the SMGBLDTRM program generates a XXX error message.
X
X6) One very annoying problem is that SMGBLDTRM tries to parse strings
Xin all string capabilities. This sometimes causes a problem with
XINIT_STRING capabilities containing any of the arithmetic expression
Xcharacters. The end result of this is that any such string 
Xis seen as an overly complex expression by SMGBLDTRM.
XTo avoid this I insert the escape character '_' in front
Xof any such characters.
X
XTC2TT doesn't handle single termcap capabilities that extend over lines
Xyet. The best example of this is the entry for tvi950-style terminals.
XThis will be fixed in the next release. For the time being, edit
Xyour termcap file to keep all multi-line capabilities on one line.
X
XAnother problem is that I have done very little to verify that
Xthe output of TC2TT is correct. Most terminals at my disposal
Xare some variant of ANSI-compatible. I don't have access to any of the
Xolder, more bizarre terminals so I have no idea if TC2TT-generated
Xdefinition really work. Please keep me informed about this.
X
XRestrictions:
X
XTC2TT doesn't support the %n, %D, %>, and %B cursor addressing modes.
XWarning are written to errlog. if these are used. If these modes
Xare actually needed I'll consider adding them.
X
XNo check is made to insure that strings are no longer than 256
Xcharacters, which is the maximum allowed by the 'ex/vi' editor.
XThe requirements of this editor govern the sizes of termcap.
X
XOnly one level of indirection is supported for the "tc" capability.
X
XGiven all these conditions, I recommend that you use this first
Xversion of TC2TT as an imperfect tool. You may find problems.
XIf you find that SMGBLDTRM doesn't accept a line generated
Xby TC2TT, look at the termcap file you used for input. In my experience
X99% of such problems are caused by errors in the termcap file. If
Xthis is the case, edit your TERMTABLE.TXT file to remove all entries that
Xaren't acceptable to SMGBLDTRM. If you believe you've found a bug
Xplease send me both the entry from the termcap file that caused
Xthe error and the output generated by SMGBLDTRM. (Please don't send me
Xthe whole termcap file).
X
XI would like to know about any problems you find. It is my goal
Xto improve TC2TT to the point where it handles all but the most
Xobstinate termcap entries. The next version will incorporate any
Xbug fixes resulting from this beta release as well as a true
Xman page.
X
XJon Forrest
XFORREST@LBL.GOV
Xucbvax!lbl-csam!ux1!forrest
X415-486-4991
$ GoSub Convert_File
$ Goto Part2
