EX-1.1 January 30, 1977 There is a binary for ex1.1 in this directory (a.out) which can be "installed" if you have a full load of user core and an 11/45 or 11/70. If you have an 11/34 or 11/40 with 64K bytes of user space, you can "mv a.outNOID a.out" and then "install". If you prefer an ex without open and visual modes (for whatever reason) choose between "a.outNOVISUAL" and "a.outNOVISNOID". If you have a Berkeley type system (with full word significant user id's) then you should use the "patchd" program in this directory on the binaries you wish to use. This is just a db "!" patch, but db doesn't work on separate i/d programs. Thus a typical installation, using just "a.out", on a standard UNIX system would be: sh install or to install the smallest ex here on an 11/34 or 11/40 mv a.outNOVISNOID a.out sh install This process will give you a basic editor (without any of its data bases) which you can try. Other files (other than /usr/bin/ex and /usr/bin/edit): The editor keeps its error messages in a file. This file is "/usr/lib/ex1.1strings", and must be present or all errors will be diagnosed as "ERROR". The data base for the editor "help" command lives in "/usr/lib/how_ex" (a directory)... the files in how_ex go there. The programs "expreserve" and "exrecover" (from ../exrecover) should be setuserid root and go in /usr/lib. There should be a directory /usr/preserve owned by root, mode 755 for use by these programs. If you clean out /tmp in /etc/rc there should be a line /usr/lib/expreserve -a before you do this. This editor needs a number of hooks into the rest of the system to get information about teletype types. The changes needed in the system at large to support this are described in the file SETUP. The editor uses the data base "/etc/ttycap" to discern capabilities of terminals, mapping a two character code it gleaned from the "htmp" data base (described below) to the characteristics of that terminal. You can add new terminals to /etc/ttycap quite easily... look at ../s6/ttycap.5. Adding a cursor addressible terminal requires an editor recompilation if you want to use the cursor addressing. Only a straightforward change to ex_ca.c is necessary. There is a system data base "/etc/ttytype" which maps terminals to 2 character type codes... see ../s6/ttytype.5. Look at ../etc/ttytype for a sample of this data base... you should change this file to correspond to your system. You can add new types as necessary to "/etc/ttycap" in this process or simply leave some terminals "unknown" for now. The editor uses a data base "/etc/htmp" to determine a user's home directory and his terminal type. This is necessary for terminal types to handle dial-ups and for home directories to allow them to be changed and to avoid password file searches on systems with large password files. The best way to implement the maintenance of "/etc/htmp" is to have the "login" program maintain it. There is a set of routines in ../s7 (libX.a) which make this trivial. The "htmp" routines can be used to access htmp, the "typeof" routines to extract types from /etc/ttytype. If you don't have "login" do this, you will have to do it by hand every time you login, or the editor may have the wrong terminal type and will not be able to find your start_up file. A login and an su program changed to handle the maintenance of "htmp" are given in ../s1. If you need to recompile: This directory contains all of the source for "ex" version 1.1. To recompile the editor you will need a version 7 C compiler as well as the following non-standard programs: mkstr create string message file lnall link a number of files to a directory in one blow mvall move all of a number of files rmtree remove a hierarchical subtree cxref a shell script giving a list of routine defn points All of these programs are on this tape (except the C compiler) and of the others, only mkstr is truly essential. (Recompilation should not be necessary unless you wish to change the editor or have a Version 7 UNIX system.) System dependencies: The only major problems here are the format of "/etc/utmp", the form of teletype names, and the meaning of user/group id's. Several of the programs in ../s6, notably "ttytype" and "sethome", assume that "utmp" is accessed as a array indexed by the letter of the terminal in use, treated as a number. Other systems have slots arranged '0', '1', ... '9', 'A', ... . If you have the latter format you'll have to change these programs. If you treat a user/id as being significant in all 16 bits returned from "getuid()" in determining if two people are the same person (i.e. if you have "newgrp") then should use the program "patchd" to change the initial value of "mask" to be 0177777, i.e.: patchd _mask 177777 a.out This is trivial, but essential. Note that you must also change the source for the ttytype and sethome programs to not mask off these bits and recompile (or use patchd) Finally the editor (and all other programs here) assume ttynames of the form "/dev/ttyx" with x a single letter. If you are having system related problems or have questions please feel free to give me a call. Other, less serious, dependencies are: 1. This editor assumes that you have a restricted, 512 byte argument list. If your system gives larger lists that is no problem, but the "next" command will allow at most 512 character lists on subsequent matchings. 2. The major and minor device numbers of /dev/null and /dev/tty are used and are given in ex_io.h. Also the system error codes are mapped from magic numbers to names here. If your system has additional codes these numbers will have to be extended and new cases will have to be added to the switch on page 6 of ex_io.c. 3. To add a cursor addressible terminal in this version, you must recompile. A simple change is required to the routines in "ex_ca.c", with a return code of 1 being supplied for the new known type, and a string doing the addressing being returned from cgoto. This information should be put in /etc/ttycap, but I haven't seen enough terminals to know a good encoding. 4. This version of the editor needs a printf which prints through putchar. Such a printf exists in printf.s in this directory. 5. The read routine rop in exr.c knows about special binary files. Thus if you have any more binary files with different magic numbers it makes sense to add them here so the editor will give better diagnostics. I would like to hear of other dependencies/problems you encounter. Scripts: The following scripts are in this directory of general interest makeex make a new binary and string file comp recompile and load one or more files install put new ex in /usr/bin... you may want to change the path names The shell used for these scripts is in the directory ../ashell, with documentation in ../s6/sh.6. If you comment out the "set" commands or make a dummy set command which does nothing then any other shell should do fine. Note also that the scripts making ex use a "version" shell script which uses ex. If you have no ex, the script will fail in a safe way. In order for the option setting for "edit" to work either the second or third character of its name must be a 'd'. Thus "edit" and "nedit" are fine. This is naive, but easy to change... look at the first few lines of ex.c. To complete the installation of ex you must also install exrecover and expreserve see the directory ../exrecover. I would appreciate hearing of any problems you have with the editor or of any improvements you make. One thing which would be nice to have is the ability to drive terminals with more intelligent operations such as add or delete a line on the screen or insert characters pushing them to the right. I havent done this because we have only 2 such terminals both of which are hard-wired at 9600 baud (and private terminals). The changes needed to do this are almost all localized in the routine "ex_vadjust.c". Bill Joy CS Division Department of EE and CS UC Berkeley Berkeley, California 94704 (415) 524-4510 [HOME] (415) 642-4948 [SCHOOL] October 12, 1977 The editor uses the following data bases: /etc/ttytype gives teletype types of hardwire ports /etc/ttycap gives capabilities of teletypes /etc/htmp gives home directories and teletype types The implications of the absence of these are as follows: /etc/ttycap Editor will think all terminals are model 33 teletypes, essentially, as they will be "unknown." You'll have no way of specifying the capabilities of your terminal. /etc/ttytype You will have to tell the editor the type of the terminal you are on every time you log in, unless you trust that the way the last user of your port set your terminal type is correct. /etc/htmp Editor start-up files cannot work; you won't be able to specify your terminal type once per login... you have to do it each time you enter the editor. These data bases are maintained and used in the following ways: HTMP data base: The file /etc/htmp contains a structure described by htmp (V). It contains, for each user, his "home" directory, normally the login directory, his user-id, and the type of terminal he is on. The home directory is here because on large systems searching the password file is unreasonably slow. Its presence in this data base also allows it to be changed. The tty type information is necessary here because users who dial in on a dialup port need to be able to specify it. TTYTYPE data base: The file /etc/ttytype is organized similarly to /etc/ttys and maps tty names to 2 character codes. This data base is used both by the editor and by the program "tset", and can be used by other programs. TTYCAP data base: The file /etc/ttycap allows programs to map a terminal's type code to its characteristics. This allows addition of new terminals to the system without changing any existing programs - only the data base needs to be updated. (Note that currently cursor addressing information is not recorded here requiring changes to the editor to add new such terminals.) The following utility programs are included with the editor: SETHOME Set the home directory entry in /etc/htmp. TTYTYPE Set the teletype type entry in /etc/htmp. The following changes to support the editor are suggested: LOGIN So that naive users may login on dial up ports and have their home directory and terminal-type set to reasonable values at initialization without any action on their part, the program login should be changed to write the initial entry in /etc/htmp. The work involved is in getting the terminal type from the file /etc/ttytype and writing it into /etc/htmp. The overhead should be negligible, especially since the operations of reading /etc/passwd and looking for mail in /usr/mail are typically much more expensive. This change is simple to make, just calling some of the routines in the supplied library htmp (V) .. SU So that the home directory will be correct after a su command, the command should be changed to save and restore this entry in /etc/htmp before and after the su. This is similar to the saving and restoring of the utmp user byte entry to allow who to print out the name of the person one is su'd to. (This latter change has been made at Berkeley.) For more information on formats and programs see the following documents Section V: htmp, ttycap, ttytype Section VI: sethome, ttytype Section VII: htmp, typeof, ttycap Bill Joy CS Division Department of EE and CS UC Berkeley Berkeley, California 94704 (415) 524-4510 [home] (415) 642-4948 [school] November 9, 1977 KNOWN SYSTEM DEPENDENCIES / MAGIC NAMES IN EX-1.1 Globally: 1. Needs a printf which prints through putchar. 2. Wants the data bases described in SETUP. 3. Needs a large amount of core; separate i/d preferred. 4. Needs a version 7 C compiler. 5. Assumes (in the library routines and the way it deals with ttyn e.g. for the visualmessage option) that teletype names are single characters, and that /etc/utmp is indexed by this character. (More on this below.) --------------------------------------------- In the HEADERS: ex.h Defines ECHO and RAW for stty. Defines TTYNAM which is initialized in ex_tty.c and there assumes that single char teletype names are used. Note that ex does not catch the TERMINATE signal of version 7 UNIX... it should be defined here. ex_glob.h The definitions here limit the argument list size possible with the next command. This does not limit the size of entry argument list however... if invoked with a longer list that is ok (although it has never been tested of course!) ex_io.h The basic stat buffer structure is assumed here. Also the error codes for errno from system error returns on i/o are defined here... if you have more error codes you should add them... ex does not use "perror" because this way puts the messages in the string message file saving space. ex_vis.h The definitions of TUBELINES, TUBECOLS, and TUBESIZE here limit the kinds of terminals on which open and visual are possible. The areas are allocated, with fixed size, on the stack at entry to the routines in exo.c and exv.c. Variable sized screens would be possible if you added an assembly language intermediary here, or you can make these numbers larger, at the expense of allocating these larger buffers on terminals with small screens. --- CODE files: ex.c /erpath =+ 9/ Assumes that the error path contains a prefix like "/usr/lib" so that adding 9 bytes will give the last portion of the error file name for testing "a.out". /== 'd'/ Here derive the properties of "edit". /signal/ New caught signals should be added here, notably the signal TERMINATE for a version 7 system. ex_ca.c To add a cursor addressible terminal you must add it to the routine canCA and change cgoto to return a string. All terminals which are to be added must have their properties recorded in /etc/ttycap. ex_glob.c This glob routine supports constructs in all portions of path names, e.g. "/*/bill/a.out"; it also interprets trailing slashes as forcing a directory match - eg "*/" matches all subdirectory names. This corresponds to the glob which is glob2.c in ../s6 and also the glob built into ../ashell. ex_tty.c This routine assumes the version 6 structure of teletype names in its handling of TTYNAM. This can be easily changed by forming the value of TTYNAM in a slightly different way. ex_io.c The routine ioerror embodies the strings from "perror" which are related to input/output. These should be added to or changed as appropriate to your system. Perror is not used because it is desired to have the error messages in the string message file (this saves ~~ 200 bytes per editor user in the swap image.) ex_put.c Note the routine "setcol" which fixes UNIX's notion of the tab column position after a cursor addressing sequence on an ADM-3A. This is hard, in general. If you wish to perform a similar fix for your terminals this is the place to do it. ex_recover.c The routines here assume that you have installed the exrecover and expreserve routines from ../exrecover, and that when the system crashes you run expreserve in /etc/rc to save the stuff from /tmp so that people can continue where they left off. If this is not true, no harm is done... as long as you don't ever crash! ex_set.c Note that the default directory and shell are initialized here. ex_tty.c Here the capabilities of the terminal which interest us are extracted. These are used by the print routines in ex_put.c, and more exten- sively by the visual and open mode routines. Currently, we are running visual on ADM-3A's (its native terminal) and also on HP2645's. For the latter, the editor makes use only of the clear to end-of-line operation. I have not put in the use of the add and delete line operations (although they are read here into AL and DL). If you have a number of intelligent terminals you may wish to try to add the intelligent terminal driving to visual... it is not hard. I have not done it since we have only 2 HP2645's and both are at 9600 baud where it matters little if it knows about the intelligence. The routines most likely to be changed in such an addition are all in the file ex_vadjust.c... they are mentioned below. ex_unix.c It is here assumed that the shell understands the option "-c", and also the option "-i" to give a login type shell. Both of the shells from Berkeley, and also the Version 7 shell from Bell have this property. Note also that substituted file names are given high-order bits set so that glob will not be a nuisance... it is better of course not to edit files with funny names. ex_vadjust.c This is where the work is required to add the AL (add line) and DL (delete line) capabilities of the terminal to open and visual. Likely candidates for change are the routines "vopen", "vsync", and "vredraw"... with these capabilities you may well want to always use "vredraw"... "vsync" is the routine which leaves the dirty "@" lines on the screen. If you do any work here I would like to hear of it as I am not planning to do this but would like to have working code for it. ex_vcurs.c Note that the routine "vputchar" assumes that you can simply overwrite and have no trouble (that overstrking an "a" with a "b" works leaving a "b"). If you have terminals where this is not true (i.e. that have OS) you can send a blank to clear the position first... rumor has it that there are some ITT beasts of this flavor (at UCLA?). exr.c Sensibility detection by decoding the flags bit of a stat buffer an by looking at the magic numbers of PLAIN files should be changed to reflect the kinds of stuff you have in your file system. exw.c Note the explicit checks for /dev/tty and /dev/null by major and minor device number here. -------------------------------------------------- I would be glad to learn of any other problems you have or changes you make to ex. I will be glad to answer questions by mail or phone, and would be glad to know of any fixes and changes. Bill Joy CS Division Department of EE and CS UC Berkeley Berkeley, California 94704 (415) 524-4510 [home] (415) 642-4948 [school]