$verno==^d3 ; Major version number. $mnver==^d3 ; Minor version number. $edno==^d96 ; Edit number. $who==^d0 ; Who edited, 0=Columbia. ; ;PS:KERMIT.MAC.442, 20-Dec-83 19:47:03, Frank ;[96] Add SEND (AS) remote-filespec when sending a single file. ; Don't display escape character in SHOW LINE unless local. ;PS:KERMIT.MAC.437, 15-Dec-83 19:20:10, Frank ;[95] Remove SET EIGHTH-BIT-PREFIX command always request it if parity is ; being used. Minor cleanups of help & program text. Change version number ; typeout to agree with the way the Exec now does it: major.minor(edit)-who. ; Get rid of old GTCHR and PTCHR routines. Also SET IBM routines. ;PS:KERMIT.MAC.431, 14-Dec-83 18:21:44, Frank ;[94] Don't allow user to type RECEIVE or SERVER commands when local. ;PS:KERMIT.MAC.428, 14-Dec-83 15:18:03, Frank ;[93] Minor corrections in ENCODE for off-by-1 errors doing repeat counts. ;PS:KERMIT.MAC.420, 14-Dec-83 12:39:32, Frank ;[92] Add repeat count processing to SPAR, RPAR, SINIT, RINIT. ; (It was already in the i/o routines, but never used.) ;PS:KERMIT.MAC.419, 13-Dec-83 18:25:55, Frank ;[91] Add routine TTXON, call it whenever there's a timeout. ; This should unstick the two sides in case of an XOFF deadlock. ;PS:KERMIT.MAC.415, 12-Dec-83 13:04:35, Frank ;[90] Make 8th-bit prefixing work with PDP-10 36-bit binary files. ;PS:KERMIT.MAC.405, 9-Dec-83 15:15:39, Frank ;[89] Polish up previous edit. Turn on prefixing if using parity. ;PS:KERMIT.MAC.400, 8-Dec-83 16:40:28, Frank ;[88] Turn on 8th-bit prefixing in RPAR & SPAR, add SET & SHOW stuff for it. ;****************** Version 3C ********************** ;PS:KERMIT.MAC.394, 2-Dec-83 14:50:55, Frank ;[87] Fix bugs in [85]; make sure line does not change after halt/cont. ;PS:KERMIT.MAC.382, 1-Dec-83 14:15:24, Frank ;[86] Don't send 4 extra characters if file is ITS binary. ;PS:KERMIT.MAC.381, 1-Dec-83 13:58:23, Frank ;[85] Make rescan work even if no KERMIT.INI file. ; Make sure line is set up correctly after exit and continue. ;PS:KERMIT.MAC.379, 25-Nov-83 17:13:16, Frank ;[84] Add SET option to convert file names to "normal form". ; SET FILE-BYTE-SIZE changed to SET FILE BYTESIZE to allow other file ; options, like this new one (SET FILE NAMING). ; Still allow "SET FILE 8", etc, for compatibility with the old way. ;PS:KERMIT.MAC.361, 25-Nov-83 11:34:54, Frank ;[83] Return properly from SHOW ALL command. ; Allow init file to be taken even when there is a command line argument. ; Init file is always taken before looking at any other commands. ;PS:KERMIT.MAC.355, 11-Nov-83 19:14:43, Frank ;[82] Clear/refuse links, system messages during file transfer. ; Also, make sure we print the contents of any incoming error packet if ; in local mode. Also, don't echo back DEFINEs any more. ;PS:KERMIT.MAC.354, 9-Nov-83 18:35:53, Frank ;[81] More miscellaneous fixes: ; . Since CCOFF is called whenever RESLIN is called, have RESLIN call CCOFF. ; . Don't turn ^C trap off between transactions if running in server mode. ; . Fix broken autobyte code (skipn/skipe, sigh...) ; . Fix broken "bit35" code in PUTCH for SOS & PDP-10 binary files. ; . Remove debugging output for DEFINE & SET macro stuff. ;PS:KERMIT.MAC.338, 8-Nov-83 11:39:11, Frank ;[80] Fix miscellaneous bugs: ; . Communication line JFNs improperly juggled in $SETLN. ; . Control-C trap was leaving an extra entry on the stack. ; . Turn off Control-C trap after ^C out of send, receive, or server mode. ; . Close file we're sending if other side sends an error packet. ; . Time transfer started not always properly initialized. ; . Remove garbage at end of set-macro body string. ; . Clean up code at $SEND and $RECV for server entry. ;PS:KERMIT.MAC.331, 28-Oct-83 20:35:46, Frank ;[79] Do an implicit TAKE of KERMIT.INI upon initial startup. ;PS:KERMIT.MAC.309, 28-Oct-83 15:29:45, Frank ;[78] Add TAKE command to allow (nested) command files. ;PS:KERMIT.MAC.288, 27-Oct-83 18:55:44, Frank ;[77] Add DEFINE command for SET macros. Remove hardwired SET IBM. ;PS:KERMIT.MAC.268, 26-Oct-83 14:15:23, Frank ;[76] Add SET HANDSHAKE. ;PS:KERMIT.MAC.251, 12-Oct-83 10:51:56, Frank ;[75] Add ITS binary format file handling, as specified in KRFC #3. ;PS:KERMIT.MAC.243, 10-Oct-83 13:33:53, Frank ;[74] Fix bug that truncated JSYS error messages in error packet text. ;PS:KERMIT.MAC.241, 10-Oct-83 13:07:33, Frank ;[73] Make sure old JFN's on assigned TTYs are released properly. ;PS:KERMIT.MAC.240, 10-Oct-83 11:44:47, Frank ;[72] Fix bug that made any file sent after a null file also null. ; Fix bug in which last send from server sets byte size for next receive. ;PS:KERMIT.MAC.237, 7-Oct-83 16:47:24, Frank ;[71] Fix SHOW DEBUG not to foul up if log JFN is .PRIOU. ;PS:KERMIT.MAC.230, 7-Oct-83 14:02:35, Frank ;[70] Catch illegal memory references when mapping in a nonexistent page. ; If i/o error sending a file, don't "abort", tell other side to discard. ; This allows wildcard sends to proceed after a memory access error. ; Also, allow ^C's to interrupt a nonworking FINISH or BYE command gracefully. ;PS:KERMIT.MAC.224, 6-Oct-83 18:56:09, Frank ;[69] Fix bug that prevented interrupts from working after EXIT & continue. ;PS:KERMIT.MAC.219, 6-Oct-83 15:13:33, Frank ;[68] Separate local and remote mode top-level command tables. ; Make remote commands invisible in local mode & vice versa. ; Move command keyword tables to where they are used. ;PS:KERMIT.MAC.212, 6-Oct-83 10:18:30, Frank ;[67] Remove REMOTE & LOCAL commands for now -- these will be added later. ; Update help text to reflect changes since last release, mainly ^A,^X,^Z. ; Rename SET ABORTED-FILE to SET INCOMPLETE to avoid emotionally toned word. ; Rename SET IBM-FLAG to SET IBM (flags are for programmers). ; Break up help text for SET command. ; Move help text for each command to same area as command itself. ;PS:KERMIT.MAC.202, 4-Oct-83 19:16:37, Frank ;[66] Same deal as [63], but for file output routines. ; Old PTCHR replaced by PUTBUF, DECODE, and PUTCH. ; Also, include Nick Bush's CRC routine, but don't use it yet. ;PS:KERMIT.MAC.199, 30-Sep-83 19:48:52, Frank ;[65] Clean up SEND command parsing, don't parse for initial filespec if no ; wildcards given. ;PS:KERMIT.MAC.196, 29-Sep-83 19:13:45, Frank ;[64] Debug the previous edit for basic service. ;PS:KERMIT.MAC.184, 28-Sep-83 18:53:21, Frank ;[63] Rewrite file input routines to separate i/o from packet formation. ; New routines are GETBUF to fill a packet buffer, ; GETCH to get an input character, ; ENCODE to process the character, performing control quoting, prefix quoting, ; and, if selected, 8th-bit quoting and repeat count processing. ; GTCHR is still present, but not used at all. ;PS:KERMIT.MAC.169, 19-Sep-83 17:56:27, Frank ;[62] Add ^X and ^Z to interrupt receiving a file or a batch, respectively. ; Required insertion of data ("D") in ACK for data packet. ;PS:KERMIT.MAC.163, 16-Sep-83 19:19:13, Frank ;[61] Put brief status report on ^A, like NFT has. ;PS:KERMIT.MAC.156, 16-Sep-83 15:45:56, Frank ;[60] Add return code to SPACK to distinguish different kinds of failures. ;PS:KERMIT.MAC.151, 15-Sep-83 19:32:57, Frank ;[59] Add ^X and ^Z to interrupt sending a file or a batch, respectively. ; Required addition of data ("X" or "Z") to Z packet. ;PS:KERMIT.MAC.146, 15-Sep-83 16:18:26, Frank ;[58] Add sending of "I" packets before server commands. ;PS:KERMIT.MAC.137, 8-Sep-83 20:20:28, Frank ;[57] Add debugging log capability to server commands as well as file xfer. ;PS:KERMIT.MAC.130, 8-Sep-83 18:55:05, Frank ;[56] Begin adding new server commands. First, add LOCAL and REMOTE ; top level commands, with operands like DELETE, TYPE, DISK, etc. ; Implement DISK first, that's the easiest test of sending back info in ; the data field of an ACK. Also, catch a couple places where the nonskip ; return from SPACK was not being accounted for (oops!). ;**************** Version 3B ******************************* ;PS:KERMIT.MAC.126, 8-Sep-83 15:14:37, Frank ;[55] Add CFIBFs in BYE and FINISH; all commands to servers should do this. ;PS:KERMIT.MAC.123, 8-Sep-83 14:02:38, Frank ;[54] Report number of NAKs and timeouts in STATISTICS command. ;PS:KERMIT.MAC.7, 2-Sep-83 17:56:19, Frank ;[53] When receiving a file, NAK a trashed packet immediately, don't just wait ; for it to come again and only NAK after timeout. This should result in a ; major speed improvement over noisy lines. The book has always said to do it ; this way. Fix is in RINIT, RFILE, RDATA. Other KERMITs may need this too. ;PS:KERMIT.MAC.4, 2-Sep-83 16:43:22, Frank ;[52] Combine some common code in the send routines, and improve comments. ;PS:20KERMIT.MAC.40, 25-Aug-83 15:28:36, Frank ;[51] Fix packet number compares for mod 64 in SFILE, SDATA, SEOF, SEOT. ; This eliminates "aborting" whenever a retransmission of packet 0 occurs. ; ;(Old Edit History moved to end of file, after END statement) ; THINGS TO DO... ; ; * When local and receiving a file, if ^Z has no effect, send an error packet ; to shut down the transaction. ; ; * Add option for a transaction file showing all files sent or received, ; disposition (kept, discarded, etc), or reason why file couldn't be sent. ; This is important for long, unattended batch transfers. ; ; * In "autobyte" mode, try to do incoming files right. Detect whether b8 ; is populated, either in first packet before writing it out (what is the ; probability that this will work most of the time?) or in any packet, in ; which case we have to redo the entire file so far, which might take so ; long that the other side could time us out... On second though, this is ; REALLY hard -- how can we tell the difference between 8-bit binary files ; and 36-bit binary files (like PDP-10 .EXE files, SOS line numbered files)? ; ; * What if another process in this job has a ^A interrupt enabled? This would ; prevent any KERMIT packet from arriving. Can I find out about it? I can ; always do an STIW for the whole job, but then can I restore things later? ; ; * 2-character checksum option: parse, put it in the packet routines, add to ; SHOW command, etc. Ditto for 3-character CRC (code is in, not yet used). ; ; * Add new server functions: delete, disk usage query, etc, and user commands ; to invoke them. Short response to any server command can be sent back in ; the ACK to the request if it will fit, otherwise it must be sent like a ; file (with "X" packet replacing the "F" packet). ; ; * Add host commands. Fork an Exec, pass commands to it in rescan, somehow ; pipe the Exec's typeout back, packetized. Too bad TOPS-20 isn't UNIX... ; ; * Add some support for file attribute packets. ; ; * Add code to negotiate binary mode with ARPAnet TAC, as in MODEM7.MAC? ; ; * Integrate %JSERR etc with the debugging log mechanism? ; ; * Terminal interrupts to switch debugging modes during a transfer? ; Ditto for block check type? ; ; * In local mode, let user type CR, like in micro KERMITs, to wake things up. ; ; * Try this (make sure it doesn't break the other KERMITs) -- When receiving ; a file, put the name I open the file under in the data field of the ACK to ; the File Header. When receiving File Headers in local mode, print the ; contents of the data field instead of doing a JFNS if the data field is not ; empty. If this works OK, then try it out in some other KERMITs that ; actually have to change the file name to avoid conflicts. ; ; * PUSH command. ; ; * Think a little more carefully about the load-dependent timeouts. If the ; timeout interval is set very long, maybe upon timing out we should check to ; see if a packet has partially arrived before NAKing it... Also, we should ; do some experimentation to adjust the timeout function & its parameters ; optimally -- right now, they're just rough stabs based on guesses. Also ; take class scheduling into account when getting load average. ; ; * Separate out the routines according to ISO levels. In particular, make the ; transport-level routines available to any other application (like mail, ; e.g. SMTP) that may want to use them. ; ; * For various reasons, it might be nice to allow KERMIT-20 to send its ; packets to a file, without another KERMIT to talk to. This will translate ; a file into all printable characters (with data compaction, etc) suitable ; for transmission over an RJE link or other picky communication media. ; ; * Parse single characters in nicer ways, like CONTROL X, or "^X", as well ; as octal numbers (in all the SET commands). Title Kermit -- That's Celtic for "free". ; Needs only standard DEC-distributed external files MONSYM, MACSYM, CMD. search monsym,macsym,cmd .require sys:macrel,sys:cmd ; Originally written by Bill Catchings, Columbia University, April 1981. ; ; This program is the DEC-20 implementation of a file transfer protocol for ; use over serial asynchronous communication lines. See the KERMIT user and ; protocol manuals for the specifications. ; ; Version 1, 1981-82: Basic service (Bill) ; ; Version 2, Feb 83: Basic server service (Bill) ; ; Version 3, Mar 83: Talk to server (Frank da Cruz) ; ; Version 3B, Oct 83: I packets, ^X,^Z interrupts, TAKE, DEFINE, etc (Frank) subttl Help Text. ;[18] Lengthy help messages added in edit [18]. ; This text provides an overall summary. More detailed help text for each ; command is with the command itself. ; hkermi: asciz | KERMIT is a file transfer protocol for use over an asynchronous serial telecommunication line. Files are broken up into "packets" with checksums and other control information to promote error-free and complete transmission. KERMIT-20 is the KERMIT implementation for the DECSYSTEM-20. KERMIT-20 can be run "locally" with a remote Kermit on the other end of an assigned TTY line (e.g. over an autodialer connection), or "remotely" from another computer (e.g. a microcomputer). You can run Kermit interactively by typing repeated commands in response to its "Kermit-20>" prompt, or you can invoke it from the TOPS-20 Exec with a single command line argument (e.g. "kermit receive"), or you can run it as a remote server. KERMIT-20 command summary -- optional parts are in [brackets]: * For exchanging files: SEND file(s) [(INITIAL) file] RECEIVE [file] GET remote-file(s) * For acting as local Kermit: SET: LINE, PARITY, DUPLEX, HANDSHAKE, ESCAPE CONNECT [line] * For acting as a server: SERVER * For talking to a server: BYE, FINISH, GET remote-file(s), SEND file(s) * For running interactively: PROMPT * Setting nonstandard transmission and file parameters: SET: DEBUG, DELAY, FILE, INCOMPLETE, PARITY, RETRY SET SEND (or RECEIVE): END-OF-LINE, START-OF-PACKET, PACKET-LENGTH, PAUSE, TIMEOUT, PADDING DEFINE a macro for a combination of SET commands. * For interrupting transmission: Control-X (^X), ^Z * Getting information: HELP [topic], STATISTICS, SHOW, ^A * Executing command files: TAKE * Leaving the program: EXIT, QUIT, BYE If you have a file called KERMIT.INI in your login directory, KERMIT-20 will execute an implicit TAKE command on it upon initial startup. KERMIT.INI may contain any KERMIT-20 commands; but DEFINE or SET commands make the most sense. For further information, type "help" for any of the above, e.g. "help set", or see the "Kermit Users Guide" and the "Kermit Protocol Manual" for complete details. | subttl Definitions pdlsiz==^d100 ; Stack size. takel==^d20 ;[78] TAKE command JFN stack size. f=0 ; AC defs: flag AC (not used), t4=+1>+1>+1 ; temporary AC's, q4=+1>+1>+1 ; and preserved AC's. state=q4+1 ; State of the automaton. rchr=state+1 ; Total data chars received. schr=rchr+1 ; Total data chars sent. debug=schr+1 ;[22] Debugging (0=none, 1=states, 2=verbose) mappag==200 ; Single page window for mapping files. SOH==^o001 ; Start of header char. XON==^o021 ; Control-Q. maxpkt=="~"-" "+2 ; Maximum size of a packet. dmxtry==5 ; Default number of retries on a packet. dimxtr==20 ; Default number of retries send initiate. drpsiz==^d80 ; Default receive packet size. dspsiz==^d80 ; Default send packet size. spmin==^d10 ;[47] Minimum size packet we want to send. spmax==^d94 ;[47] Maximum ... dstim==^d10 ; Default send time out interval. drtim==^d8 ; Default receive time out interval. dsrvtm==^d30 ;[20] Def timout when awaiting server commands. drpaus==0.0 ;[35] Default pause before ACKing packets. dspaus==0.0 ;[36] Default pause before sending packets. dspad==^o000 ; Default send padding char. drpad==^o000 ; Default receive padding char. dspadn==^d0 ; Default number of send padding chars. drpadn==^d0 ; Default number of receive padding chars. dseol==.chcrt ; Default send EOL char. dreol==.chcrt ; Default receive EOL char. dsquot=="#" ; Default control prefix for sending. drquot=="#" ; Default control prefix for receiving. dqbin==^o46 ; Default 8th-bit prefix = "&". drept=="~" ; Default repeat count prefix. ddelay==^d5 ; Default delay before the first packet, secs. dxfull==0 ;[18] Full duplex. dxhalf==1 ;[18] Half duplex. ;*** These three settings are for Columbia's IBM mainframes. Change them to ;*** suit your own, if its settings are different. ;(Note -- This has been made obsolete by SET macro facility) ;ibmhsh==XON ;[76] Handshake for IBM host. ;ibmdpx==dxhalf ;[18] Duplex for IBM host. ;ibmpar==mark ; Parity for IBM host. ;*** defpar==none ; Default parity. defits==-1 ;[75] Handle ITS binary files by default. maxtim=^d94 ;[2] Maximum timeout interval to set, secs. minlod=4.0 ;[2] Minimum ldav to consider for timeout. maxlod=50.0 ;[2] Maximum ldav to consider for timeout. blip=^d5 ;[4] Every this many packets, print a blip. diasw==0 ; Default is diagnostics off. mnblen==^d200 ;[77] Macro name buffer length (words). mtblen==^d1000 ;[77] Macro text buffer length (words). macmax==^d100 ;[77] Maximum number of macros. subttl Macros ; ERMSG -- Type error message on local terminal, and save a pointer to the ; error string, that can be used when querying most recent error. define ermsg (msg) < call [ tmsg < > hrroi t1, [asciz/?Kermit: 'msg/] movem t1, errptr ;; Save pointer to error mess for stats. PSOUT% tmsg < > ret ] >;ermsg ; KERMSG -- Like ERMSG, but also send the message to the other KERMIT in ; an error packet, which causes the current transmission to "abort". define kermsg (msg) < $count=0 irpc msg, <$count=$count+1> call [ movei t1, "E" ;; Send an error packet to the other side. move t2, pktnum ;; Packet number. movei t3, $count+^d13 ;; The count. move t4, [point 7, [asciz/?Kermit-20: 'msg/]] ;; The msg. movem t4, errptr ;; Save pointer to error msg for status. call spack ;; Send the error packet. nop tmsg < ?Kermit: 'msg > ret ] > ; Error handling macros, cont'd ; %JSERR -- Invoked by ERJMP after a JSYS call. Prints the given message, ; if any, then the JSYS error message, and then jumps to the address given ; or else halts (continuably) if no jump address given. define %jserr (msg, label) < ;; Use this immediately following a JSYS. erjmp [ tmsg < ?Kermit: 'msg> ;; Type given msg with our prefix, ifnb ,< call jserr0> ;; if given, put JSYS error after dash, ifb ,< call jsmsg0> ;; else right after "?Kermit: " ifb