$! ------------------ CUT HERE ----------------------- $ v='f$verify(f$trnlnm("SHARE_VERIFY"))' $! $! This archive created by VMS_SHARE Version 7.1-004 3-AUG-1989 $! On 30-NOV-1989 08:30:56.31 By user FORREST $! $! This VMS_SHARE Written by: $! Andy Harper, Kings College London UK $! $! Acknowledgements to: $! James Gray - Original VMS_SHARE $! Michael Bednarek - Original Concept and implementation $! $!+ THIS PACKAGE DISTRIBUTED IN 3 PARTS, TO KEEP EACH PART $! BELOW 30 BLOCKS $! $! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER $! AND EXECUTE AS A COMMAND PROCEDURE ( @name ) $! $! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING: $! 1. README.TC2TT;3 $! 2. TABLE.H;8 $! 3. TC2TT.C;3 $! $set="set" $set symbol/scope=(nolocal,noglobal) $f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID")) $e="write sys$error ""%UNPACK"", " $w="write sys$output ""%UNPACK"", " $ if f$trnlnm("SHARE_LOG") then $ w = "!" $ if f$getsyi("version") .ges. "V4.4" then $ goto START $ e "-E-OLDVER, Must run at least VMS 4.4" $ v=f$verify(v) $ exit 44 $UNPACK: SUBROUTINE ! P1=filename, P2=checksum $ if f$search(P1) .eqs. "" then $ goto file_absent $ e "-W-EXISTS, File ''P1' exists. Skipped." $ delete/nolog 'f'* $ exit $file_absent: $ if f$parse(P1) .nes. "" then $ goto dirok $ dn=f$parse(P1,,,"DIRECTORY") $ w "-I-CREDIR, Creating directory ''dn'." $ create/dir 'dn' $ if $status then $ goto dirok $ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped." $ delete/nolog 'f'* $ exit $dirok: $ w "-I-PROCESS, Processing file ''P1'." $ define/user sys$output nl: $ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1' PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET( SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name"); buff:=CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(buff)) ;LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION( BEGINNING_OF(buff));g:=0;LOOP EXITIF MARK(NONE)=END_OF(buff);x:= ERASE_CHARACTER(1);IF g = 0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x= "V" THEN APPEND_LINE;MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF; IF x="+" THEN g:=1;ERASE_LINE;ENDIF;ELSE IF x="-" THEN g:=0;ENDIF;ERASE_LINE; ENDIF;ENDLOOP;p:="`";POSITION(BEGINNING_OF(buff));LOOP r:=SEARCH(p,FORWARD); EXITIF r=0;POSITION(r);ERASE(r);COPY_TEXT(ASCII(INT(ERASE_CHARACTER(3)))); ENDLOOP;o:=GET_INFO(COMMAND_LINE,"output_file");WRITE_FILE(buff,o); ENDPROCEDURE;Unpacker;EXIT; $ delete/nolog 'f'* $ CHECKSUM 'P1' $ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT $ e "-E-CHKSMFAIL, Checksum of ''P1' failed." $ ENDSUBROUTINE $START: $ create/nolog 'f' 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`032 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 terminals 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`032 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@SYBASE.COM X`123pacbell,pyramid,sun,`123uunet,ucbvax`125!mtxinu`125!sybase!forrest X415-596-3422 $ CALL UNPACK README.TC2TT;3 55353196 $ create/nolog 'f' X#define STR`0090 X#define BOOL`0091 X#define NUM`0092 X Xstruct table_item X`123 X`009int type; X`009char *unix_name; X`009char *vms_name; X`125 table`091`093 = X`123 XSTR,`009"CC",`009"", XSTR,`009"ae",`009"END_ALTERNATE_CHAR", XSTR,`009"al",`009"", XBOOL,`009"am",`009"AUTO_MARGIN", XSTR,`009"as",`009"BEGIN_ALTERNATE_CHAR", XSTR,`009"bc",`009"", XSTR,`009"bl",`009"", XBOOL,`009"bs",`009"", XSTR,`009"bt",`009"", XBOOL,`009"bw",`009"", XSTR,`009"cd",`009"ERASE_TO_END_DISPLAY", XSTR,`009"ce",`009"ERASE_TO_END_LINE", XSTR,`009"ch",`009"CURSOR_RIGHT", XSTR,`009"cl",`009"ERASE_WHOLE_DISPLAY", XSTR,`009"cm",`009"SET_CURSOR_ABS", XNUM,`009"co",`009"COLUMNS", XSTR,`009"cr",`009"", XSTR,`009"cs",`009"SET_SCROLL_REGION", XSTR,`009"ct",`009"", XSTR,`009"cv",`009"", XNUM,`009"dB",`009"", XNUM,`009"dC",`009"CR_FILL", XNUM,`009"dF",`009"LF_FILL", XNUM,`009"dN",`009"", XNUM,`009"dT",`009"", XBOOL,`009"da",`009"", XBOOL,`009"db",`009"", XSTR,`009"dc",`009"DELETE_CHAR", XSTR,`009"dl",`009"DELETE_LINE", XSTR,`009"dm",`009"BEGIN_DELETE_MODE", XSTR,`009"do",`009"CURSOR_DOWN", XSTR,`009"ed",`009"END_DELETE_MODE", XSTR,`009"ei",`009"END_INSERT_MODE", XSTR,`009"eo",`009"", XSTR,`009"ff",`009"", XBOOL,`009"hc",`009"", XSTR,`009"hd",`009"", XSTR,`009"ho",`009"HOME", XSTR,`009"hu",`009"", XSTR,`009"hz",`009"", XSTR,`009"ic",`009"INSERT_CHAR", XSTR,`009"if",`009"", XSTR,`009"im",`009"BEGIN_INSERT_MODE", XBOOL,`009"in",`009"INSERT_MODE_NULLS", XSTR,`009"ip",`009"INSERT_PAD", XSTR,`009"is",`009"INIT_STRING", XSTR,`009"k0",`009"", XSTR,`009"k1",`009"", XSTR,`009"k2",`009"", XSTR,`009"k3",`009"", XSTR,`009"k4",`009"", XSTR,`009"k5",`009"", XSTR,`009"k6",`009"", XSTR,`009"k7",`009"", XSTR,`009"k8",`009"", XSTR,`009"k9",`009"", XSTR,`009"kb",`009"KEY_BACKSPACE", XSTR,`009"kd",`009"", XSTR,`009"ke",`009"SET_NUMERIC_KEYPAD", XSTR,`009"kh",`009"", XSTR,`009"kl",`009"KEY_LEFT_ARROW", XNUM,`009"kn",`009"", XSTR,`009"ko",`009"", XSTR,`009"kr",`009"KEY_RIGHT_ARROW", XSTR,`009"ks",`009"SET_APPLICATION_KEYPAD", XSTR,`009"ku",`009"KEY_UP_ARROW", XSTR,`009"l0",`009"", XSTR,`009"l1",`009"", XSTR,`009"l2",`009"", XSTR,`009"l3",`009"", XSTR,`009"l4",`009"", XSTR,`009"l5",`009"", XSTR,`009"l6",`009"", XSTR,`009"l7",`009"", XSTR,`009"l8",`009"", XSTR,`009"l9",`009"", XSTR,`009"le",`009"", XNUM,`009"li",`009"ROWS", XSTR,`009"ll",`009"", XSTR,`009"ma",`009"", XSTR,`009"mb",`009"", XSTR,`009"md",`009"", XSTR,`009"me",`009"", XSTR,`009"mh",`009"", XBOOL,`009"mi",`009"", XSTR,`009"ml",`009"", XSTR,`009"mr",`009"", XBOOL,`009"ms",`009"", XSTR,`009"mu",`009"", XBOOL,`009"nc",`009"", XSTR,`009"nd",`009"", XSTR,`009"nl",`009"NEWLINE_CHAR", XBOOL,`009"ns",`009"NO_SCROLL", XBOOL,`009"os",`009"OVERSTRIKE", XSTR,`009"pc",`009"PAD_CHAR", XBOOL,`009"pt",`009"PHYSICAL_TABS", XSTR,`009"rf",`009"", XSTR,`009"rs",`009"", XSTR,`009"se",`009"END_BOLD", XSTR,`009"sf",`009"SCROLL_FORWARD", XNUM,`009"sg",`009"", XSTR,`009"so",`009"BEGIN_BOLD", XSTR,`009"sr",`009"SCROLL_REVERSE", XSTR,`009"st",`009"", XSTR,`009"ta",`009"TAB_CHAR", XSTR,`009"tc",`009"", XSTR,`009"te",`009"RESTORE_CURSOR", XSTR,`009"ti",`009"SAVE_CURSOR", XSTR,`009"uc",`009"UNDERLINE_CHAR", XSTR,`009"ue",`009"END_UNDERSCORE", XNUM,`009"ug",`009"", XBOOL,`009"ul",`009"UNDERLINE", XSTR,`009"up",`009"CURSOR_UP", XSTR,`009"us",`009"BEGIN_UNDERSCORE", XSTR,`009"vb",`009"", XSTR,`009"ve",`009"", XSTR,`009"vs",`009"", XNUM,`009"vt",`009"", XBOOL,`009"xb",`009"", XBOOL,`009"xn",`009"IGNORE_NEWLINE", XBOOL,`009"xr",`009"", XBOOL,`009"xs",`009"NO_ERASE", XBOOL,`009"xt",`009"" X`125; $ CALL UNPACK TABLE.H;8 442098433 $ create/nolog 'f' X/* X X`009TC2TT Version 0.1 - Converts Unix (*tm) termcap files into VMS (*tm) X`009TERMTABLE.TXT files. See accompanying README.TC2TT for more X`009information. X X`009This program may not be sold. Otherwise it is in the public X`009domain. X X`009Compile and link this program like any other Vax C program. X`009It requires no special linking parameters. X X`009Jon Forrest X`009Sybase, Inc. X`009forrest@sybase.com X`009415-596-3422 X X*/ X X#include X#include X#include X#include "table.h" X X#ifdef VMS X#define TERMCAP`009`009"termcap." X#define ERRLOG`009`009"errlog." X#else X#define TERMCAP`009`009"termcap" X#define ERRLOG`009`009"errlog" X#endif X X#define LINE_LEN`009256 X#define TERMNAME_LEN`00964`009`009/* max len of terminal name */ X#define`009LONGNAME`0092`009`009/* long terminal name */ X#define EOL`009`009((char *)1) X#define NO_TC`009`0090 X#define`009TC`009`0091 X#define`009FOUND`009`0091 X X/* X** The following two lines are global only because of a bug in the X** VMS Debugger in VMS 4.7 which doesn't allow local character arrays to be X** examined. X*/ X Xchar input_line1`091LINE_LEN`093; Xchar input_line2`091LINE_LEN`093; Xchar term_name`091TERMNAME_LEN`093;`009`009/* official name of current termi Vnal */ XFILE *ifp, *ofp, *efp; XFILE *tcfp = NULL; Xint do_end = 0;`009`009`009`009/* don't output END 1st time */ X Xmain() X`123 X X`009if ((ifp = fopen(TERMCAP,"r")) == NULL) X`009`123 X`009`009perror(TERMCAP); X`009`009exit(1); X`009`125 X`009if ((ofp = fopen("termtable.txt","w")) == NULL) X`009`123 X`009`009perror("termtable.txt"); X`009`009exit(1); X`009`125 X`009if ((efp = fopen(ERRLOG,"w")) == NULL) X`009`123 X`009`009perror(ERRLOG); X`009`009exit(1); X`009`125 X X`009while (do_entry(ifp, input_line1, NO_TC) != EOF); X`009if (do_end) X`009`009fprintf(ofp,"END\n"); X`009fclose(ifp); X`009fclose(ofp); X`009fclose(efp); X`009if (tcfp != NULL) X`009`009fclose(tcfp); X`125 X X/* X** Process an entry for a terminal in termcap. This might be because X** we're processing a new entry or because we're looking for a terminal X** specified in a tc capability. The actual purpose is shown in the X** third argument. X*/ X Xdo_entry(ifp, input_line, purpose) +-+-+-+-+-+-+-+- END OF PART 1 +-+-+-+-+-+-+-+-