home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / old / misc / pdp10 / k10mit.mac < prev    next >
Text File  |  2020-01-01  |  177KB  |  5,593 lines

  1.     TITLE    KERMIT-10
  2.  
  3. ; Universals
  4.  
  5.     SEARCH    GLXMAC            ; Galaxy definitions
  6.     SEARCH    ORNMAC            ; Parser interface definitions
  7.     SEARCH    KERUNV            ; Kermit definitions
  8.  
  9. ; Directives
  10.  
  11.     PROLOG    (KERMIT)
  12.     .DIREC    FLBLST            ; List file line of binary only
  13.     PARSET                ; Define entries into the parser
  14.  
  15.   ; Version number
  16.  
  17.     MITVER==3            ; Major version number
  18.     MITMIN==0            ; Minor version number
  19.     MITEDT==134            ; Edit level
  20.     MITWHO==0            ; Customer edit
  21.  
  22.     TWOSEG    400K            ; Make this a two segment program
  23.     RELOC    0            ; Low segment
  24.     RELOC                ; Back to the high segment
  25.  
  26. TOPS10<
  27.     SEARCH    SCNMAC            ; WILD interface definitions
  28.     LOC    <.JBVER==:137>        ; Version number location
  29.     VRSN.(KER)            ; Store version number
  30.     RELOC                ; Back to the high segment
  31. >; End of TOPS10 condition
  32.     SUBTTL    Table of Contents
  33.  
  34. ;+
  35. ;.pag.lit
  36. ;                          Table of Contents of KERMIT
  37. ;
  38. ;
  39. ;                                    Section                             Page
  40. ;   1.   Revision History . . . . . . . . . . . . . . . . . . . . . . . .   3
  41. ;   2.   Command tables
  42. ;      2.1.   Prompt strings. . . . . . . . . . . . . . . . . . . . . . .   4
  43. ;      2.2.   Initial state . . . . . . . . . . . . . . . . . . . . . . .   5
  44. ;      2.3.   Final state . . . . . . . . . . . . . . . . . . . . . . . .   5
  45. ;      2.4.   BYE command . . . . . . . . . . . . . . . . . . . . . . . .   5
  46. ;      2.5.   CONNECT command . . . . . . . . . . . . . . . . . . . . . .   6
  47. ;      2.6.   DEFINE command. . . . . . . . . . . . . . . . . . . . . . .   7
  48. ;      2.7.   EXIT command. . . . . . . . . . . . . . . . . . . . . . . .   8
  49. ;      2.8.   FINISH command. . . . . . . . . . . . . . . . . . . . . . .   9
  50. ;      2.9.   GET command . . . . . . . . . . . . . . . . . . . . . . . .   9
  51. ;      2.10.  HELP command. . . . . . . . . . . . . . . . . . . . . . . .   9
  52. ;      2.11.  LOGOUT command. . . . . . . . . . . . . . . . . . . . . . .  10
  53. ;      2.12.  RECEIVE command . . . . . . . . . . . . . . . . . . . . . .  10
  54. ;      2.13.  SEND command. . . . . . . . . . . . . . . . . . . . . . . .  10
  55. ;      2.14.  SERVER command. . . . . . . . . . . . . . . . . . . . . . .  11
  56. ;      2.15.  SET command
  57. ;         2.15.1.   Dispatch table. . . . . . . . . . . . . . . . . . . .  12
  58. ;         2.15.2.   ON/OFF table. . . . . . . . . . . . . . . . . . . . .  13
  59. ;         2.15.3.   incomplete-file . . . . . . . . . . . . . . . . . . .  14
  60. ;         2.15.4.   Block-check-type. . . . . . . . . . . . . . . . . . .  14
  61. ;         2.15.5.   DEBUGGING . . . . . . . . . . . . . . . . . . . . . .  14
  62. ;         2.15.6.   DELAY . . . . . . . . . . . . . . . . . . . . . . . .  14
  63. ;         2.15.7.   ESCAPE. . . . . . . . . . . . . . . . . . . . . . . .  14
  64. ;         2.15.8.   FILE-BYTE-SIZE. . . . . . . . . . . . . . . . . . . .  15
  65. ;         2.15.9.   Line. . . . . . . . . . . . . . . . . . . . . . . . .  16
  66. ;         2.15.10.  Message . . . . . . . . . . . . . . . . . . . . . . .  17
  67. ;         2.15.11.  Parity. . . . . . . . . . . . . . . . . . . . . . . .  18
  68. ;         2.15.12.  Receive . . . . . . . . . . . . . . . . . . . . . . .  19
  69. ;         2.15.13.  Repeat-quote. . . . . . . . . . . . . . . . . . . . .  20
  70. ;         2.15.14.  Retry . . . . . . . . . . . . . . . . . . . . . . . .  21
  71. ;         2.15.15.  Send. . . . . . . . . . . . . . . . . . . . . . . . .  22
  72. ;      2.16.  STATUS command. . . . . . . . . . . . . . . . . . . . . . .  23
  73. ;      2.17.  SHOW command. . . . . . . . . . . . . . . . . . . . . . . .  24
  74. ;   3.   Entry vector and initialization. . . . . . . . . . . . . . . . .  25
  75. ;   4.   Kermit initialization. . . . . . . . . . . . . . . . . . . . . .  29
  76. ;   5.   KERMIT.INI processing. . . . . . . . . . . . . . . . . . . . . .  30
  77. ;   6.   CCL entry processing
  78. ;      6.1.   SETTMP. . . . . . . . . . . . . . . . . . . . . . . . . . .  31
  79. ;      6.2.   ADVTMP. . . . . . . . . . . . . . . . . . . . . . . . . . .  32
  80. ;      6.3.   ABRTAK. . . . . . . . . . . . . . . . . . . . . . . . . . .  33
  81. ;   7.   Command parsing utility routines
  82. ;      7.1.   CHKCTL. . . . . . . . . . . . . . . . . . . . . . . . . . .  34
  83. ;   8.   Command execution
  84. ;      8.1.   CONNECT command . . . . . . . . . . . . . . . . . . . . . .  35
  85. ;      8.2.   DEFINE command. . . . . . . . . . . . . . . . . . . . . . .  36
  86. ;      8.3.   EXIT command. . . . . . . . . . . . . . . . . . . . . . . .  37
  87. ;      8.4.   BYE command . . . . . . . . . . . . . . . . . . . . . . . .  38
  88. ;      8.5.   FINISH command. . . . . . . . . . . . . . . . . . . . . . .  39
  89. ;      8.6.   LOGOUT command. . . . . . . . . . . . . . . . . . . . . . .  40
  90. ;      8.7.   HELP command. . . . . . . . . . . . . . . . . . . . . . . .  41
  91. ;      8.8.   PROMPT command. . . . . . . . . . . . . . . . . . . . . . .  42
  92. ;      8.9.   SEND command. . . . . . . . . . . . . . . . . . . . . . . .  43
  93. ;      8.10.  GET command . . . . . . . . . . . . . . . . . . . . . . . .  44
  94. ;      8.11.  RECEIVE command . . . . . . . . . . . . . . . . . . . . . .  45
  95. ;      8.12.  SERVER command. . . . . . . . . . . . . . . . . . . . . . .  46
  96. ;      8.13.  SET command
  97. ;         8.13.1.   Top level . . . . . . . . . . . . . . . . . . . . . .  47
  98. ;         8.13.2.   SETKYW - Parse a keyword and store the value. . . . .  47
  99. ;         8.13.3.   DEBUGGING parameter . . . . . . . . . . . . . . . . .  48
  100. ;         8.13.4.   Initial DELAY . . . . . . . . . . . . . . . . . . . .  49
  101. ;         8.13.5.   LINE to use . . . . . . . . . . . . . . . . . . . . .  50
  102. ;         8.13.6.   MESSAGE parameters. . . . . . . . . . . . . . . . . .  51
  103. ;         8.13.7.   RECEIVE parameters. . . . . . . . . . . . . . . . . .  52
  104. ;      8.14.  SHOW command. . . . . . . . . . . . . . . . . . . . . . . .  55
  105. ;         8.14.1.   SHOW MACROS . . . . . . . . . . . . . . . . . . . . .  56
  106. ;         8.14.2.   SHOW VERSION. . . . . . . . . . . . . . . . . . . . .  57
  107. ;         8.14.3.   SHOW DAYTIME. . . . . . . . . . . . . . . . . . . . .  57
  108. ;         8.14.4.   SHOW DEBUGGING. . . . . . . . . . . . . . . . . . . .  58
  109. ;         8.14.5.   SHOW FILE-INFORMATION . . . . . . . . . . . . . . . .  59
  110. ;         8.14.6.   SHOW LINE-INFORMATION . . . . . . . . . . . . . . . .  60
  111. ;         8.14.7.   SHOW PACKET-INFORMATION . . . . . . . . . . . . . . .  61
  112. ;         8.14.8.   SHOW TIMING-INFORMATION . . . . . . . . . . . . . . .  62
  113. ;         8.14.9.   Support routines
  114. ;            8.14.9.1.   TONOFF . . . . . . . . . . . . . . . . . . . . .  63
  115. ;            8.14.9.2.   CHITXT . . . . . . . . . . . . . . . . . . . . .  64
  116. ;      8.15.  STATUS command. . . . . . . . . . . . . . . . . . . . . . .  65
  117. ;   9.   File processing
  118. ;      9.1.   INIFILE - Initialization. . . . . . . . . . . . . . . . . .  66
  119. ;      9.2.   FILE%OPEN . . . . . . . . . . . . . . . . . . . . . . . . .  67
  120. ;      9.3.   Routine to type the file specification. . . . . . . . . . .  69
  121. ;   10.  Routine to setup FILOP/ELB/PATH blocks . . . . . . . . . . . . .  70
  122. ;   11.  File processing
  123. ;      11.1.   Routine to convert FX blocks . . . . . . . . . . . . . . .  71
  124. ;      11.2.   FILE%CLOSE . . . . . . . . . . . . . . . . . . . . . . . .  72
  125. ;      11.3.   NEXT%FILE. . . . . . . . . . . . . . . . . . . . . . . . .  73
  126. ;      11.4.   GET%FILE - Get a byte. . . . . . . . . . . . . . . . . . .  74
  127. ;      11.5.   PUT%FILE - Store a byte. . . . . . . . . . . . . . . . . .  75
  128. ;      11.6.   FILE%DUMP - Not needed . . . . . . . . . . . . . . . . . .  76
  129. ;   12.  Support routines
  130. ;      12.1.   PRSFIL - Parse a file specification. . . . . . . . . . . .  77
  131. ;      12.2.   PRSSX$ - Parse a sixbit field. . . . . . . . . . . . . . .  78
  132. ;      12.3.   PRSWS$ - Parse a wild sixbit field . . . . . . . . . . . .  79
  133. ;      12.4.   CHKAL$ - Check for alphanumeric. . . . . . . . . . . . . .  80
  134. ;      12.5.   PRSOC$ - Parse a wild octal number . . . . . . . . . . . .  81
  135. ;      12.6.   INPCH$ - Input a character . . . . . . . . . . . . . . . .  82
  136. ;   13.  Packet count processing
  137. ;      13.1.   XFR%STATUS . . . . . . . . . . . . . . . . . . . . . . . .  83
  138. ;   14.  Terminal processing
  139. ;      14.1.   Message routines
  140. ;         14.1.1.   Initialization. . . . . . . . . . . . . . . . . . . .  84
  141. ;         14.1.2.   Open the terminal . . . . . . . . . . . . . . . . . .  85
  142. ;         14.1.3.   Close the terminal. . . . . . . . . . . . . . . . . .  86
  143. ;         14.1.4.   Send a message. . . . . . . . . . . . . . . . . . . .  87
  144. ;         14.1.5.   Wait for turnaround . . . . . . . . . . . . . . . . .  88
  145. ;         14.1.6.   Receive a message . . . . . . . . . . . . . . . . . .  89
  146. ;         14.1.7.   Check for keyboard input. . . . . . . . . . . . . . .  90
  147. ;         14.1.8.   Set time out timer. . . . . . . . . . . . . . . . . .  91
  148. ;      14.2.   General
  149. ;         14.2.1.   Determine using local line. . . . . . . . . . . . . .  92
  150. ;         14.2.2.   Open a terminal . . . . . . . . . . . . . . . . . . .  93
  151. ;         14.2.3.   T$CLOS - Close the terminal channel . . . . . . . . .  94
  152. ;         14.2.4.   Input a character . . . . . . . . . . . . . . . . . .  95
  153. ;         14.2.5.   Output a character. . . . . . . . . . . . . . . . . .  96
  154. ;         14.2.6.   Output a character for CONNECT. . . . . . . . . . . .  97
  155. ;         14.2.7.   Connect a terminal line . . . . . . . . . . . . . . .  98
  156. ;         14.2.8.   Set PIM break set . . . . . . . . . . . . . . . . . .  99
  157. ;      14.3.   Text output
  158. ;         14.3.1.   TERM%DUMP & DBG%DUMP. . . . . . . . . . . . . . . . . 100
  159. ;   15.  Error processing
  160. ;      15.1.   .KERERR - Handle KERMIT-10 errors. . . . . . . . . . . . . 101
  161. ;      15.2.   KRM%ERROR - Handle the KERMSG errors . . . . . . . . . . . 102
  162. ;   16.  CRC calculation routine. . . . . . . . . . . . . . . . . . . . . 104
  163. ;   17.  Data area. . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
  164. ;   18.  End of Kermit. . . . . . . . . . . . . . . . . . . . . . . . . . 107
  165. ;
  166. ;.end lit.pag
  167. ;-
  168.     SUBTTL    Revision History
  169.  
  170. COMMENT    |
  171. 100    By: Robert C. McQueen        On: Yes.
  172.     Lots of rewritting and other things.
  173.  
  174. 101    By: Nick Bush            On: 22-August-1983
  175.     Fix setting up of seven or eight bit byte pointers for file
  176.     I/O.  Do this once when the file is opened, not each time
  177.     a buffer is read.  TOPS-10 is quite happy to use whatever
  178.     byte size is stored in the buffer header byte pointer, and will
  179.     use that size to determine the byte count.
  180.  
  181. 102    By: Robert C. McQueen        On: 29-August-1983
  182.     Remove the TT% routines and use the common TT_ routines in the
  183.     Bliss module KERTT.
  184.  
  185. 103    By: Robert C. McQueen        On: 16-September-1983
  186.     Add XFR%STATUS and baud rate stats.
  187.  
  188. 104    By: Robert C. McQueen & Nick Bush    On: Many days
  189.     - Add CRC support
  190.     - Redo the SHOW command processing
  191.     - Fix random bugs.
  192.  
  193. 105    By: Robert C. McQueen & Nick Bush    On: Many days
  194.     - Implement IBM mode
  195.     - Implement file disposition
  196.     - Make CCL entry work
  197.  
  198. 106    By: Nick Bush        On: 3-November-1983
  199.     Fix terminal handling for non-network systems.  Also make sure
  200.     the terminal will be available when we try to use it by grabing
  201.     it when we set the line.
  202.     Modules: KERMIT
  203.  
  204. 107    By: Nick Bush        On: 12-November-1983
  205.     Add macro definition capability for SET options.
  206.     Modules: KERMIT
  207.  
  208. 111    By: Nick Bush        On: 16-November-1983
  209.     Add TAKE command.
  210.     Modules: KERMIT
  211.  
  212. 112    By: Nick Bush        On: 17-November-1983
  213.     Clear the input buffer before we send a message.  This ignores any garbage
  214.     which came in on the line since the last message we received.
  215.     Modules: KERMIT
  216.  
  217. 113    By: Nick Bush        On: 14-December-1983
  218.     Add some more single character commands for use during transfers.
  219.     Control-A will type a status line, control-D will toggle debugging, and
  220.     carriage return will force a timeout (therefore either a NAK or
  221.  retransmission).
  222.     Modules: KERMIT
  223.  
  224. 114    By: Nick Bush        On: 19-December-1983
  225.     Default the transfer terminal to KERMIT: if the logical name exists and
  226.     is a terminal.
  227.  
  228.     Remove FILE%DUMP, since KERMSG no longer references it.
  229.     Modules: KERMIT
  230.  
  231. 115    By: Nick Bush        On: 5-January-1983
  232.     Add support for different types of file names.  This changes the
  233.     SET FILE-xxx commands to be SET FILE xxx and adds a SET FILE NAMING
  234.     command.
  235.     Modules: KERMIT
  236.  
  237. 116    By: Nick Bush        On: 14-March-1984
  238.     Add parsing for all REMOTE commands.
  239.     Add support for some generic and local commands.
  240.     Fix wild card processing to handle pathological names correctly.
  241.     Modules: KERMIT,KERSYS,KERWLD
  242.  
  243. 120    By: Robert C. McQueen        On: 28-March-1984
  244.     Add bug fixes from WMU.  Many thanks to the people out in Kalamazoo.
  245.     Modules: KERMIT,KERWLD
  246.  
  247. 121    By: Robert C. McQueen        On: 28-March-1984
  248.     Add SET PROMPT command.  Start adding support for generic COPY and
  249.     RENAME commands.
  250.     Modules: KERUNV,KERMIT,KERWLD
  251.  
  252. 122    By: Robert C. McQueen        On: 29-March-1984
  253.     Remove ADJBP instructions and add the five instructions that adjust byte
  254.     pointers for the KI10s that use Kermit.'
  255.     Modules: KERMIT
  256.  
  257. 123    By: Nick Bush        On: 2-April-1984
  258.     Change SPACE generic command to use PPN of default path instead of users
  259.     PPN if no argument is supplied.
  260.     Make DIRECTORY and DELETE generic commands print out a header at the
  261.     top of the list, and print file size in both words and allocated blocks.
  262.     Add SPACE as synonym for DISK-USAGE command and ERASE as synonym for
  263.     DELETE.
  264.  
  265.     Modules: KERMIT,KERSYS
  266.  
  267. Start of Version 3(124)
  268.  
  269. 125    By: Nick Bush        On: 26-June-1984
  270.     Add patches from CSM:
  271.  
  272.     - Wrong AC when setting PIM break set.
  273.     - Checks for not-logged-in Kermits
  274.     - Parity for CONNECT (implemented differently)
  275.  
  276.     Modules: KERMIT,KERSYS
  277.  
  278. 126    By: Nick Bush        On: 11-July-1984
  279.     RECEIVE FOO.BAR would not work correctly.  It thought the extension was
  280.     wild-carded.
  281.  
  282.     Modules: KERMIT
  283.  
  284. 127    By: David Stevens    On: 9-July-1985
  285.     Add patches from PIMA:
  286.  
  287.     - Fix IFN stopcode if syntax error in KERMIT.INI.
  288.     - Add help text for connect mode escape commands
  289.         Q (quit) and R (resume) logging
  290.     - Add SET XON-XOFF-PROCESSING to determine how XON/XOF
  291.         should be handled during CONNECT.
  292.     - Add a new file byte-size 36-bit for 10 to 10/20 transfers.
  293.  
  294.     Modules: KERMIT, KERUNV
  295.  
  296. 130    By: David Stevens    On: 15-July-1985
  297.  
  298.     Fix multiple file sending problem.
  299.     - note this resulted in a patch to all kermits using KERMSG
  300.  
  301.     Modules: KERMIT, KERMSG
  302.  
  303. 131    By: David Stevens        On: 25-July-1985
  304.     Add SET HANSHAKE to set up an IBM hanshaking character
  305.  
  306.     Modules: KERMIT
  307.  
  308. 132    By David Stevens        On: 29-July-1985
  309.     Fix DFNMAC - IBM to set the handshake character instead of the
  310.     IBM-MODE
  311.  
  312.     Modules: KERMIT
  313.  
  314. 133    By David Stevens        On: 30-July-1985
  315.     Eliminate SET IBM-MODE.
  316.  
  317.     Modules: KERMIT
  318.  
  319. 134    By Dan Norstedt            On: 17-June-1989
  320.     Incorperated VMS enhancements, added Extended Length packets
  321.  
  322.     Modules: KERMIT, KERMSG (VMS version + updates), KERGLB
  323. |
  324.     SUBTTL    Command tables -- Initial state
  325.  
  326. ; The following is the initial state for the command tables.  These
  327. ; point to all of the other tables.
  328.  
  329. MON000:    $INIT    (MON010)
  330.  
  331. MON010:    $KEYDSP    (MON020,$ALTERNATE(KER010))
  332.  
  333. MON020:    $STAB
  334.      DSPTAB    (MON030,IGNORE,<CONTINUE>)    ; CONTINUE command
  335.      DSPTAB    (MON040,KERCMD,<KERMIT>)    ; KERMIT command
  336.      DSPTAB    (MON030,SHOVER,<RUN>)        ; RUN command
  337.      DSPTAB    (MON030,IGNORE,<START>)        ; START command
  338.     $ETAB
  339.  
  340. MON030:    $UQSTR    (CONFRM,IGNBRK)
  341.  
  342.  
  343. MON040:    $CRLF    ($ALTERNATE(KER010))
  344.  
  345. IGNORE:    $RETT
  346.  
  347.     BRINI$(IGN)            ; Mask for ignoring monitor commands
  348.     BRKCH$(IGN,.CHLFD,.CHFFD)    ; Only break on command terminators
  349.  
  350. IGNBRK:    BRGEN$(IGN)            ; Generate the mask
  351.  
  352. KER000:    $INIT    (KER010)
  353.  
  354. KER010:    $KEYDSP    (KER020)        ; Dispatch table
  355.  
  356. KER020:    $STAB
  357.      DSPTAB    (,C$EXI0,\"<.CHCNZ>,CM%INV)    ; Control-Z is same as EXIT
  358.      DSPTAB    (BYE000,C$BYE,<Bye>)        ; Bye command
  359.      DSPTAB    (CON000,C$CONNECT,<Connect>)    ; CONNECT to terminal line
  360.      DSPTAB    (DFN000,C$DEFINE,<Define>)    ;[107] Define set of parameters
  361.      DSPTAB    (EXI000,C$EXIT,<Exit>)        ; EXIT to monitor level
  362.      DSPTAB    (FIN000,C$FINISH,<Finish>)    ; Finish command
  363.      DSPTAB    (GET000,C$GET,<Get>)        ; GET command
  364.      DSPTAB    (HLP000,C$HELP,<Help>)        ; HELP command
  365.      DSPTAB    (LCL000,C$LOCAL,<Local>)    ; LOCAL command
  366.      DSPTAB    (LOG000,C$LOG,<Log>)        ; LOG command
  367.      DSPTAB    (LGO000,C$LOGOUT,<Logout>)    ; LOGOUT remote kermit
  368.      DSPTAB    (CONFRM,C$PROMPT,<PROMPT>,CM%INV) ; PROMPT command
  369.      DSPTAB    (EXI000,C$EXIT,<Quit>)        ; QUIT command
  370.      DSPTAB    (RCV000,C$RECEIVE,<R>,CM%INV!CM%ABR) ; Receive command
  371.      DSPTAB    (RCV000,C$RECEIVE,<Receive>)    ; RECEIVE command
  372.      DSPTAB    (REM000,C$REMOTE,<Remote>)    ;[116] Remote xxx command
  373.      DSPTAB    (SND000,C$SEND,<S>,CM%INV!CM%ABR) ; SEND command
  374.      DSPTAB    (SND000,C$SEND,<Send>)        ; SEND command
  375.      DSPTAB    (SRV000,C$SERVER,<Server>)    ; SERVER command
  376.      DSPTAB    (SET000,C$SET,<Set>)        ; SET command
  377.      DSPTAB    (SHO000,C$SHOW,<Show>)        ; Show information
  378.      DSPTAB    (STA000,C$STATUS,<Status>)    ; STATUS command
  379.      DSPTAB    (TAKFDB##,.KYTAK,<Take>)    ;[111] Take command
  380.     $ETAB
  381.  
  382. KER100:    $INIT    (KER110)
  383.  
  384. KER110:    $KEYDSP    (KER120)        ; Dispatch table
  385.  
  386. KER120:    $STAB
  387.      DSPTAB    (,C$EXI0,\"<.CHCNZ>,CM%INV)    ; Control-Z is same as EXIT
  388.      DSPTAB    (CON100,C$CONNECT,<Connect>)    ; CONNECT to terminal line
  389.      DSPTAB    (DFN000,C$DEFINE,<Define>)    ;[107] Define set of parameters
  390.      DSPTAB    (EXI000,C$EXIT,<Exit>)        ; EXIT to monitor level
  391.      DSPTAB    (HLP000,C$HELP,<Help>)        ; HELP command
  392.      DSPTAB    (LCL000,C$LOCAL,<Local>)    ; LOCAL command
  393.      DSPTAB    (LOG000,C$LOG,<Log>)        ; LOG command
  394.      DSPTAB    (CONFRM,C$PROMPT,<PROMPT>,CM%INV) ; PROMPT command
  395.      DSPTAB    (EXI000,C$EXIT,<Quit>)        ; QUIT command
  396.      DSPTAB    (RCV000,C$RECEIVE,<Receive>)    ; RECEIVE command
  397.      DSPTAB    (SND000,C$SEND,<S>,CM%INV!CM%ABR) ; SEND command
  398.      DSPTAB    (SND000,C$SEND,<Send>)        ; SEND command
  399.      DSPTAB    (SRV000,C$SERVER,<Server>)    ; SERVER command
  400.      DSPTAB    (SET000,C$SET,<Set>)        ; SET command
  401.      DSPTAB    (SHO000,C$SHOW,<Show>)        ; Show information
  402.      DSPTAB    (STA000,C$STATUS,<Status>)    ; STATUS command
  403.      DSPTAB    (TAKFDB##,.KYTAK,<Take>)    ;[111] Take command
  404.     $ETAB
  405.  
  406.  
  407.     SUBTTL    Command tables -- Final state
  408.  
  409. CONFRM:    $CRLF
  410.  
  411.  
  412.  
  413.  
  414.     SUBTTL    Command tables -- BYE command
  415.  
  416. BYE000:    $NOISE    (CONFRM,<to remote server>)
  417.     SUBTTL    Command tables -- CONNECT command
  418.  
  419. CON000:    $NOISE    (CON010,<to line>)
  420.  
  421. TOPS20<
  422. CON010:    $NUMBER    (CONFRM,^D8,<line number to use for virtual terminal>,$ALTERNATE(CONFRM))
  423. >; End of TOPS20 conditional
  424.  
  425. TOPS10<
  426. CON010:    $DEV    (CONFRM,<$HELP(Name of terminal to use),$ALTERNATE(CON020),$ERRPDB(CON020)>)
  427.  
  428. CON020:    $NODNM    (CON030,<Node name terminal line is connected to>,<$ALTERNATE(CON050),$ERRPDB(CON050)>)
  429.  
  430. CON030:    $NOISE    (CON040,<Line number>)
  431.  
  432. CON040:    $NUMBER    (CONFRM,^D8,<Line number on specified node>)
  433.  
  434. CON050:    $NUMBER    (CONFRM,^D8,<line number to use for virtual terminal>,$ALTERNATE(CONFRM))
  435. >; End of TOPS10 conditional
  436.  
  437. CON100:    $NOISE    (CON110,<to line>)
  438.  
  439. TOPS20<
  440. CON110:    $NUMBER    (CONFRM,^D8,<line number to use for virtual terminal>)
  441. >; End of TOPS20 conditional
  442.  
  443. TOPS10<
  444. CON110:    $DEV    (CONFRM,<$HELP(Name of terminal to use),$ALTERNATE(CON120),$ERRPDB(CON120)>)
  445.  
  446. CON120:    $NODNM    (CON130,<Node name terminal line is connected to>,<$ALTERNATE(CON150),$ERRPDB(CON150)>)
  447.  
  448. CON130:    $NOISE    (CON140,<Line number>)
  449.  
  450. CON140:    $NUMBER    (CONFRM,^D8,<Line number on specified node>)
  451.  
  452. CON150:    $NUMBER    (CONFRM,^D8,<line number to use for virtual terminal>)
  453. >; End of TOPS10 conditional
  454.     SUBTTL    Command tables -- DEFINE command
  455.  
  456. ;[107] Format:
  457. ;[107]    DEFINE macro-name {List of set options}
  458. ;[107]    DEFINE macro-name <CRLF> ! to delete macro definition
  459.  
  460. DFN000:    $NOISE    (DFN010,<macro name>)
  461.  
  462. DFN010:    $KEY    (DFN020,DFNTAB,<$ALTERNATE(DFN030)>)
  463.  
  464. DFN020:    $CRLF    (<$HELP(Confirm to delete macro)>)
  465.  
  466. DFN030:    $FIELD    (SET001,<macro name to define>)
  467.  
  468. ;[107] Tables used during macro expansion
  469.  
  470. SMC000:    $KEY    (SMC010,KER020)        ;[107] Allow any command (can only be define anyway)
  471.  
  472. SMC010:    $NOISE    (SMC020,<macro name>)
  473.  
  474. SMC020:    $KEY    (SET001,DFNTAB)        ;[107] Allow any macro name then set options
  475.     SUBTTL    Command tables -- EXIT command
  476.  
  477. EXI000:    $NOISE    (CONFRM,<to the monitor>)
  478.     SUBTTL    Command tables -- FINISH command
  479.  
  480. FIN000:    $NOISE    (CONFRM,<remote server operation>)
  481.  
  482.  
  483.  
  484.     SUBTTL    Command tables -- GET command
  485.  
  486. GET000:    $NOISE    (GET010,<remote files>)
  487.  
  488. GET010:    $FIELD    (CONFRM,<File specification>,<$BREAK(FILBRK)>)
  489.  
  490.  
  491.  
  492.     SUBTTL    Command tables -- HELP command
  493.  
  494. HLP000:    $NOISE    (HLP010,<with>)
  495.  
  496. HLP010:    $CTEXT    (CONFRM,<Topic for which help is wanted>,$ALTERNATE(CONFRM))
  497.     SUBTTL    Command tables -- LOGOUT command
  498.  
  499. LGO000:    $NOISE    (CONFRM,<remote server>)
  500.  
  501.  
  502.     SUBTTL    Command tables -- LOG command
  503.  
  504. LOG000:    $KEY    (LOG010,LOG001)
  505.  
  506. LOG001:    $STAB
  507.      KEYTAB    (DBGLOG,<Debugging-output>)
  508.      KEYTAB    (SESLOG,<Session>)
  509.      KEYTAB    (TRNLOG,<Transactions>)
  510.     $ETAB
  511.  
  512. LOG010:    $NOISE    (LOG020,<to file>)
  513.  
  514. LOG020:    $OFILE    (LOG030,<Log file name>,$ALTERNATE(CONFRM))
  515.  
  516. LOG030:    $SWITCH    (CONFRM,LOG031,$ALTERNATE(CONFRM))
  517.  
  518. LOG031:    $STAB
  519.      KEYTAB    (0,<Append>)
  520.     $ETAB
  521.  
  522.  
  523.     SUBTTL    Command tables -- RECEIVE command
  524.  
  525. RCV000:    $NOISE    (RCV010,<into files>)
  526.  
  527. RCV010:    $OFILE    (CONFRM,<File name to receive information into>,$ALTERNATIVE(CONFRM))
  528.     SUBTTL    Command tables -- REMOTE command
  529.  
  530. REM000:    $KEYDSP    (REM010)
  531.  
  532. REM010:    $STAB
  533.      DSPTAB    (REM080,<[XWD GETNFL,GC%COPY##]>,<Copy>)    ; Copy file
  534.      DSPTAB    (REM070,<[XWD GETPSW,GC%CONNECT##]>,<CWD>) ; Change working directory
  535.      DSPTAB    (REM020,<[XWD 0,GC%DELETE##]>,<Delete>)    ; Delete file
  536.      DSPTAB    (REM030,<[XWD 0,GC%DIRECTORY##]>,<Directory>) ; Directory command
  537.      DSPTAB    (REM040,<[XWD 0,GC%DISK%USAGE##]>,<Disk-usage>) ; Disk-usage report
  538.      DSPTAB    (REM020,<[XWD 0,GC%DELETE##]>,<Erase>)    ; Delete file
  539.      DSPTAB    (CONFRM,<[XWD 0,GC%EXIT##]>,<Exit>)    ; Exit
  540.      DSPTAB    (REM050,<[XWD 0,GC%HELP##]>,<Help>)    ; Help command
  541.      DSPTAB    (REM060,<[XWD 0,GC%COMMAND##]>,<Host-command>) ; Host command
  542.      DSPTAB    (REM100,<[XWD GETLGN,GC%LGN##]>,<Login>) ; Login
  543.      DSPTAB    (CONFRM,<[XWD 0,GC%LOGOUT##]>,<Logout>)    ; Logout command
  544.      DSPTAB    (REM090,<[XWD GETNFL,GC%RENAME##]>,<Rename>) ; Rename file
  545.      DSPTAB    (REM120,<[XWD GETMSG,GC%SEND%MSG##]>,<Send-message>) ; Send message command
  546.      DSPTAB    (REM040,<[XWD 0,GC%DISK%USAGE##]>,<Space>) ; Disk-usage report
  547.      DSPTAB    (CONFRM,<[XWD 0,GC%STATUS##]>,<Status>)    ; Status command
  548.      DSPTAB    (REM020,<[XWD 0,GC%TYPE##]>,<Type>)    ; Type file command
  549.      DSPTAB    (REM110,<[XWD GETOPT,GC%WHO##]>,<Who>)    ; Who is logged in
  550.     $ETAB
  551.  
  552. ; LOCAL commands.  Basically the same as the remote commands, the
  553. ;results are just typed locally instead of being transmitted.
  554.  
  555. LCL000:    $KEYDSP    (LCL010)
  556.  
  557. LCL010:    $STAB
  558.      DSPTAB    (REM070,<[XWD 0,GC%CONNECT##]>,<CWD>)    ; Change path
  559.      DSPTAB    (REM020,<[XWD 0,GC%DELETE##]>,<Delete>)    ; Delete file
  560.      DSPTAB    (REM030,<[XWD 0,GC%DIRECTORY##]>,<Directory>) ; Directory command
  561.      DSPTAB    (REM040,<[XWD 0,GC%DISK%USAGE##]>,<Disk-usage>) ; Disk-usage report
  562.      DSPTAB    (REM020,<[XWD 0,GC%DELETE##]>,<Erase>)    ; Delete file
  563.      DSPTAB    (REM050,<[XWD 0,GC%HELP##]>,<Help>)    ; Help command
  564.      DSPTAB    (REM070,<[XWD 0,GC%CONNECT##]>,<Set-path>) ; Set default path
  565.      DSPTAB    (REM040,<[XWD 0,GC%DISK%USAGE##]>,<Space>) ; Disk-usage report
  566.      DSPTAB    (CONFRM,<[XWD 0,GC%STATUS##]>,<Status>)    ; Status command
  567.      DSPTAB    (REM020,<[XWD 0,GC%TYPE##]>,<Type>)    ; Type file command
  568.     $ETAB
  569.  
  570. ; Here for items which take a required file spec (Type and Delete)
  571.  
  572. REM020:    $NOISE    (REM021,<file>)
  573.  
  574. REM021:    $CTEXT    (CONFRM,<file specification>)
  575.  
  576. ; Here for a directory command.  Accept an optional file spec.
  577.  
  578. REM030:    $NOISE    (REM031,<of files>)
  579.  
  580. REM031:    $CTEXT    (CONFRM,<file specification>,$ALTERNATE(CONFRM))
  581.  
  582. ; Here for a disk-usage and CWD commands
  583.  
  584. REM040:    $NOISE    (REM041,<of directory>)
  585. REM070:    $NOISE    (REM041,<to directory>)
  586.  
  587. REM041:    $CTEXT    (REM042,<directory specification>,$ALTERNATE(REM042))
  588.  
  589. REM042:    $CRLF    (<$HELP(<Confirm for default directory>)>)
  590.  
  591. ; Here for a help command
  592.  
  593. REM050:    $NOISE    (REM051,<with Kermit server>)
  594.  
  595. REM051:    $CTEXT    (CONFRM,<Topic for which help is wanted>,$ALTERNATE(CONFRM))
  596.  
  597. ; Here for a remote HOST command
  598.  
  599. REM060:    $CTEXT    (CONFRM,<Command to be executed by the remote host>)
  600.  
  601. ; Here for copy and rename commands
  602.  
  603. REM080:    $NOISE    (REM081,<from file>)
  604. REM090:    $NOISE    (REM081,<old file>)
  605.  
  606. REM081:    $CTEXT    (CONFRM,<old file name>)
  607.  
  608. ; Here for login command
  609.  
  610. REM100:    $NOISE    (REM101,<as user>)
  611.  
  612. REM101:    $CTEXT    (CONFRM,<User identification>)
  613.  
  614. ; Here for WHO command
  615.  
  616. REM110:    $NOISE    (REM111,<is using system>)
  617.  
  618. REM111:    $CTEXT    (CONFRM,<user identification or network host>,<$ALTERNATE(CONFRM)>)
  619.  
  620. ; Here for send message
  621.  
  622. REM120:    $NOISE    (REM121,<to>)
  623.  
  624. REM121:    $CTEXT    (CONFRM,<destination identification>)
  625.     SUBTTL    Command tables -- SEND command
  626.  
  627. SND000:    $NOISE    (SND010,<from files>)
  628.  
  629. SND010:    $FIELD    (CONFRM,<File specification>,<$BREAK(FILBRK)>)
  630.  
  631.     BRINI$(FIL,ALL)            ; Initialize the mask
  632.     UNBRK$(FIL,"A","Z")        ; Allow alphabetics
  633.     UNBRK$(FIL,"a","z")        ; And lower case
  634.     UNBRK$(FIL,"0","9")        ; And numbers
  635.     UNBRK$(FIL,"*")            ; Full wild card
  636.     UNBRK$(FIL,"%")            ; Single character wild-card
  637.     UNBRK$(FIL,"[")            ; Start of PPN or UIC
  638.     UNBRK$(FIL,"]")            ; End of PPN or UIC
  639.     .CHCMA==","            ; Value of a comma
  640.     UNBRK$(FIL,.CHCMA)        ; Separator in PPN's and UIC's
  641.     UNBRK$(FIL,".")            ; Between file name and extension (and generation)
  642.     UNBRK$(FIL,":")            ; After device names
  643.     UNBRK$(FIL,"$")            ; Part of VMS device names
  644.     UNBRK$(FIL,";")            ; Before generation or attributes
  645.     UNBRK$(FIL,"-")            ; For TOPS-20 file names
  646.     UNBRK$(FIL,.CHLAB)        ; Left angle bracket for TOPS-20 directories
  647.     UNBRK$(FIL,.CHRAB)        ; Right angle bracket for TOPS-20
  648.  
  649. FILBRK:    BRGEN$(FIL)            ; Generate the mask
  650.     SUBTTL    Command tables -- SERVER command
  651.  
  652. SRV000:    $NOISE    (CONFRM,<mode>)
  653.     SUBTTL    Command tables -- SET command -- Dispatch table
  654. ;[107]
  655. ;[107] Can be either a macro name or list of keyword/value pairs
  656. ;[107]
  657.  
  658. SET000:    $KEY    (CONFRM,DFNTAB,<$ALTERNATE(SET001)>)
  659.  
  660. SET001:    $KEYDSP    (SET010)        ;[107] Return here after comma
  661.  
  662. SET005:    $COMMA    (SET001,<$ALTERNATE(CONFRM)>)
  663.  
  664. SET010:    $STAB
  665.      DSPTAB    (BLK000,<[XWD CHKTYPE##,SETKYW]>,<block-check-type>)
  666.      DSPTAB    (DBG000,<[EXP SETDBG]>,<debugging>)
  667.      DSPTAB    (DEL000,<[XWD DELAY##,SETNUM]>,<delay>)
  668.      DSPTAB    (ESC000,<[EXP SETESC]>,<escape>)
  669.      DSPTAB    (FIL000,<[EXP SETFIL]>,<file>)
  670. ;[115];     DSPTAB    (FBS000,<[XWD FILTYP,SETKYW]>,<file-byte-size>)
  671. ;[115];TOPS10<     DSPTAB    (ONOFF,<[XWD WARN%FLAG##,SETKYW]>,<file-warning>)>; End of TOPS10
  672.      DSPTAB    (HSK000,<[EXP SETHSK]>,<handshake>);    [131]
  673. ;[133]     DSPTAB    (ONOFF,<[XWD IBM%FLAG##,SETKYW]>,<IBM-mode>)
  674.      DSPTAB    (ABT000,<[XWD ABT%FLAG##,SETKYW]>,<incomplete-file>)
  675.      DSPTAB    (LIN000,<[EXP SETLIN]>,<line>)
  676.      DSPTAB    (ONOFF,<[XWD LCLECH,SETKYW]>,<local-echo>)
  677.      DSPTAB    (MSG000,<[EXP SETMSG]>,<message>)
  678.      DSPTAB    (PAR000,<[XWD PARITY%TYPE##,SETKYW]>,<parity>)
  679.      DSPTAB    (PRM000,<[EXP SETPRM]>,<prompt>)
  680.      DSPTAB    (SRC000,<[EXP SETRCV]>,<receive>)
  681.      DSPTAB (RPT000,<[EXP SETRPT]>,<repeat>)
  682.      DSPTAB    (RTY000,<[EXP SETRTY]>,<retry>)
  683.      DSPTAB    (SSN000,<[EXP SETSND]>,<send>)
  684.      DSPTAB    (SSR000,<[XWD SRV%TIMEOUT##,SETNUM]>,<server-timer>)
  685.      DSPTAB    (XXP000,<[XWD XXPMOD,SETKYW]>,<XON-XOFF-processing>)    ;[127]
  686.     $ETAB
  687.     SUBTTL    Command tables -- SET command -- ON/OFF table
  688.  
  689. ONOFF:    $KEYDSP    (ONOFFT)
  690.  
  691. ONOFFT:    $STAB
  692.      DSPTAB    (SET005,BLSFAL,<off>)
  693.      DSPTAB    (SET005,BLSTRU,<on>)
  694.     $ETAB
  695.     SUBTTL    Command tables -- SET command -- incomplete-file
  696.  
  697. ABT000:    $NOISE    (ABT010,<disposition>)
  698.  
  699. ABT010:    $KEY    (SET005,ABT01T)
  700.  
  701. ABT01T:    $STAB
  702.      KEYTAB    (BLSTRU,<discard>)
  703.      KEYTAB    (BLSFAL,<keep>)
  704.     $ETAB
  705.  
  706.  
  707.     SUBTTL    Command tables -- SET command -- Block-check-type
  708.  
  709. BLK000:    $KEY    (SET005,BLK01T)
  710.  
  711. BLK01T:    $STAB
  712.      KEYTAB    (CHK%1C##,<1-character-checksum>)
  713.      KEYTAB    (CHK%2C##,<2-character-checksum>)
  714.      KEYTAB    (CHK%CR##,<3-character-CRC-CCITT>)
  715.      KEYTAB    (CHK%1C##,<one-character-checksum>)
  716.      KEYTAB    (CHK%CR##,<three-character-CRC-CCITT>)
  717.      KEYTAB    (CHK%2C##,<two-character-checksum>)
  718.     $ETAB
  719.  
  720.  
  721.     SUBTTL    Command tables -- SET command -- DEBUGGING
  722.  
  723. DBG000:    $KEYDSP(DBG00T)
  724.  
  725. DBG00T:    $STAB
  726.      DSPTAB    (DBG010,<[XWD SETODF,0]>,<log-file>)
  727.      DSPTAB    (SET005,<[XWD SETCDF,0]>,<no-log-file>)
  728.      DSPTAB    (SET005,<[XWD SETDBF,BLSFAL]>,<off>)
  729.      DSPTAB    (SET005,<[XWD SETDBF,BLSTRU]>,<on>)
  730.     $ETAB
  731.  
  732. DBG010:    $NOISE    (DBG011,<to>)
  733.  
  734. DBG011:    $OFILE    (SET005,<File name for debugging log>)
  735.  
  736.  
  737.     SUBTTL    Command tables -- SET command -- DELAY
  738.  
  739. DEL000:    $NOISE    (DEL010,<to>)
  740.  
  741. DEL010:    $NUMBER    (SET005,^D10,<decimal number of seconds>,<$ACTION(CHKPOS)>)
  742.  
  743.  
  744.  
  745.     SUBTTL    Command tables -- SET command -- ESCAPE
  746.  
  747. ESC000:    $NOISE    (ESC010,<character for connect to>)
  748.  
  749. ESC010:    $NUMBER    (SET005,^D8,<Octal value of ASCII control character>,<$DEFAULT(31)>)
  750.     SUBTTL    Command tables -- SET command -- FILE
  751.  
  752. FIL000:    $NOISE    (FIL010,<parameter>)
  753.  
  754. FIL010:    $KEYDSP    (FIL020)
  755.  
  756. FIL020:    $STAB
  757.      DSPTAB    (FBS000,<[XWD FILTYP,SETKYW]>,<byte-size>)
  758.      DSPTAB    (FNM000,<[XWD FIL%NORMAL%FORM##,SETKYW]>,<naming>)
  759. TOPS10<     DSPTAB    (ONOFF,<[XWD WARN%FLAG##,SETKYW]>,<warning>)>; End of TOPS10
  760.     $ETAB
  761.  
  762.  
  763.     SUBTTL    Command tables -- SET command -- FILE -- BYTE-SIZE
  764.  
  765. FBS000:    $NOISE    (FBS010,<to>)
  766.  
  767. FBS010:    $KEYDSP    (FBS020)
  768.  
  769. FBS020:    $STAB
  770.      DSPTAB (SET005,$FBS36,<36-bit>)        ;[127]
  771.      DSPTAB    (SET005,$FBS7,<7-bit>)
  772.      DSPTAB    (SET005,$FBS8,<8-bit>)
  773.      DSPTAB    (SET005,$FBAUT,<auto-byte>)
  774.      DSPTAB    (SET005,$FBS8,<eight-bit>)
  775.      DSPTAB    (SET005,$FBS7,<seven-bit>)
  776.      DSPTAB    (SET005,$FBS36,<thirty-six-bit>)    ;[127]
  777.     $ETAB
  778.  
  779.  
  780.     SUBTTL    Command tables -- SET command -- FILE -- BYTE-SIZE
  781.  
  782. FNM000:    $NOISE    (FNM010,<to>)
  783.  
  784. FNM010:    $KEYDSP    (FNM020)
  785.  
  786. FNM020:    $STAB
  787.      DSPTAB    (SET005,FNM%FULL##,<full-file-specification>)
  788.      DSPTAB    (SET005,FNM%NORMAL##,<normal-form>)
  789.      DSPTAB    (SET005,FNM%UNTRAN##,<untranslated>)
  790.     $ETAB
  791.     SUBTTL    Command tables -- SET command -- HANDSHAKE
  792.  
  793.  
  794. HSK000:    $NOISE    (HSK010,<character for IBM handshake>)        ;[131]
  795.  
  796. HSK010:    $NUMBER    (SET005,^D8,<Octal value of ASCII character>,<$DEFAULT(-1)>)    ;[131]
  797.  
  798.  
  799.  
  800.  
  801.     SUBTTL    Command tables -- SET command -- Line
  802.  
  803. LIN000:    $NOISE    (LIN010,<to>)
  804.  
  805. TOPS20<
  806. LIN010:    $NUMBER    (SET005,^D8,<line number to use for virtual terminal>)
  807. >; End of TOPS20 conditional
  808.  
  809. TOPS10<
  810. LIN010:    $DEV    (SET005,<$HELP(Name of terminal to use),$ALTERNATE(LIN020),$ERRPDB(LIN020)>)
  811.  
  812. LIN020:    $NODNM    (LIN030,<Node name terminal line is connected to>,<$ALTERNATE(LIN050),$ERRPDB(LIN050)>)
  813.  
  814. LIN030:    $NOISE    (LIN040,<Line number>)
  815.  
  816. LIN040:    $NUMBER    (SET005,^D8,<Line number on specified node>)
  817.  
  818. LIN050:    $NUMBER    (SET005,^D8,<line number to use for virtual terminal>,$ALTERNATE(SET005))
  819. >; End of TOPS10 conditional
  820.     SUBTTL    Command tables -- SET command -- Message
  821.  
  822. MSG000:    $NOISE    (MSG010,<type out to be>)
  823.  
  824. MSG010:    $KEY    (MSG020,MSG030,<$ALTERNATE(MSG020)>)
  825.  
  826. MSG020:    $KEY    (SET005,MSG040)
  827.  
  828. MSG030:    $STAB
  829.      KEYTAB    (BLSFAL,<no>)
  830.     $ETAB
  831.  
  832. MSG040:    $STAB
  833.      KEYTAB    (TY%FIL##,<file-specifications>)
  834.      KEYTAB    (TY%PKT##,<packet-numbers>)
  835.     $ETAB
  836.     SUBTTL    Command tables -- SET command -- Parity
  837.  
  838. PAR000:    $NOISE    (PAR010,<to>)
  839.  
  840. PAR010:    $KEYDSP    (PAR020)
  841.  
  842. PAR020:    $STAB
  843.      DSPTAB    (SET005,PR%EVEN##,<even>)
  844.      DSPTAB    (SET005,PR%MARK##,<mark>)
  845.      DSPTAB    (SET005,PR%NONE##,<none>)
  846.      DSPTAB    (SET005,PR%ODD##,<odd>)
  847.      DSPTAB    (SET005,PR%SPAC##,<space>)
  848.     $ETAB
  849.     SUBTTL    Command tables -- SET command -- Prompt
  850.  
  851. PRM000:    $FIELD    (SET005,<KERMIT prompt>,<$ALTERNATE(SET005),$BREAK(FILBRK)>)
  852.  
  853.     SUBTTL    Command tables -- SET command -- Receive
  854.  
  855. SRC000:    $KEYDSP    (SRC010)
  856.  
  857. SRC010:    $STAB
  858.      DSPTAB    (R8Q000,SETR8Q,<8th-bit-quote>)
  859.      DSPTAB    (R8Q000,SETR8Q,<eighth-bit-quote>)
  860.      DSPTAB    (REO000,SETREL,<end-of-line>)
  861.      DSPTAB    (RPL000,SETRPL,<packet-length>)
  862.      DSPTAB    (RPC000,SETRPC,<padchar>)
  863.      DSPTAB    (RPD000,SETRPD,<padding>)
  864.      DSPTAB    (RQU000,SETRQU,<quote>)
  865.      DSPTAB    (RSH000,SETRSH,<start-of-packet>)
  866.      DSPTAB    (RTI000,SETRTI,<timeout>)
  867.     $ETAB
  868.  
  869. R8Q000:    $NOISE    (R8Q010,<to>)
  870. R8Q010:    $NUMBER    (SET005,^D8,<Octal number between 41 and 76 or 140 and 176>,<$ACTION(CHK8QU)>)
  871.  
  872. REO000:    $NOISE    (REO010,<to>)
  873. REO010:    $NUMBER    (SET005,^D8,<Octal number of character between 0 and 37>,<$ACTION(CHKCTL)>)
  874.  
  875. RPL000:    $NOISE    (RPL010,<to>)
  876. RPL010:    $NUMBER    (SET005,^D10,<decimal number between 10 and 1000>,<$ACTION(CHKPKT)>) ; [134]
  877.  
  878. RPC000:    $NOISE    (RPC010,<to>)
  879. RPC010:    $NUMBER    (SET005,^D8,<Octal number of character between 0 and 37 or 177>,<$ACTION(CHKPDC)>)
  880.  
  881. RPD000:    $NOISE    (RPD010,<to>)
  882. RPD010:    $NUMBER    (SET005,^D10,<positive decimal number of padding characters>,<$ACTION(CHKPOS)>)
  883.  
  884. RQU000:    $NOISE    (RQU010,<to>)
  885. RQU010:    $NUMBER    (SET005,^D8,<Octal number between 41 and 76 or 140 and 176>,<$ACTION(CHK8QU)>)
  886.  
  887. RSH000:    $NOISE    (RSH010,<to>)
  888. RSH010:    $NUMBER    (SET005,^D8,<Octal number of character between 0 and 37>,<$ACTION(CHKSHC)>)
  889.  
  890. RTI000:    $NOISE    (RTI010,<to>)
  891. RTI010:    $NUMBER    (SET005,^D10,<Number of seconds before timing out, between 1 and 94>,<$ACTION(CHKTIM)>)
  892.     SUBTTL    Command tables -- SET command -- Repeat-quote
  893.  
  894. RPT000:    $NOISE    (RPT010,<to>)
  895.  
  896. RPT010:    $KEY    (SET005,RPT011,<$ALTERNATE(RPT020)>)
  897.  
  898. RPT011:    $STAB
  899.      KEYTAB    (<" ">,<none>)
  900.     $ETAB
  901.  
  902. RPT020:    $NUMBER    (SET005,^D8,<Octal number between 41 and 76 or 140 and 176>,<$ACTION(CHK8QU)>)
  903.  
  904.     SUBTTL    Command tables -- SET command -- Retry
  905.  
  906. RTY000:    $NOISE    (RTY010,<maximum for>)
  907.  
  908. RTY010:    $KEY    (RTY030,RTY020)
  909.  
  910. RTY020:    $STAB
  911.      KEYTAB    (SI%RETRIES##,<initial-connection>)
  912.      KEYTAB    (PKT%RETRIES##,<packets>)
  913.     $ETAB
  914.  
  915. RTY030:    $NUMBER    (SET005,^D10,<Number of retries>,<$ACTION(CHKPOS)>)
  916.     SUBTTL    Command tables -- SET command -- Send
  917.  
  918.  
  919. SSN000:    $KEYDSP    (SSN010)
  920.  
  921. SSN010:    $STAB
  922.      DSPTAB    (SEO000,SETSEL,<end-of-line>)
  923.      DSPTAB    (SPL000,SETSPL,<packet-length>)
  924.      DSPTAB    (SPC000,SETSPC,<padchar>)
  925.      DSPTAB    (SPD000,SETSPD,<padding>)
  926.      DSPTAB    (SQU000,SETSQU,<quote>)
  927.      DSPTAB    (SSH000,SETSSH,<start-of-packet>)
  928.      DSPTAB    (STI000,SETSTI,<timeout>)
  929.     $ETAB
  930.  
  931. SEO000:    $NOISE    (SEO010,<to>)
  932. SEO010:    $NUMBER    (SET005,^D8,<Octal number of character between 0 and 37>,<$ACTION(CHKCTL)>)
  933.  
  934. SPL000:    $NOISE    (SPL010,<to>)
  935. SPL010:    $NUMBER    (SET005,^D10,<decimal number between 10 and 1000>,<$ACTION(CHKPKT)>) ; [134]
  936.  
  937. SPC000:    $NOISE    (SPC010,<to>)
  938. SPC010:    $NUMBER    (SET005,^D8,<Octal number of character between 0 and 37 or 177>,<$ACTION(CHKPDC)>)
  939.  
  940. SPD000:    $NOISE    (SPD000,<to>)
  941. SPD010:    $NUMBER    (SET005,^D10,<positive decimal number of padding characters>,<$ACTION(CHKPOS)>)
  942.  
  943. SQU000:    $NOISE    (SQU010,<to>)
  944. SQU010:    $NUMBER    (SET005,^D8,<Octal number between 41 and 76 or 140 and 176>,<$ACTION(CHK8QU)>)
  945.  
  946. SSH000:    $NOISE    (SSH010,<to>)
  947. SSH010:    $NUMBER    (SET005,^D8,<Octal number of character between 0 and 37>,<$ACTION(CHKSHC)>)
  948.  
  949. STI000:    $NOISE    (RTI010,<to>)
  950. STI010:    $NUMBER    (SET005,^D10,<Number of seconds before timing out, between 1 and 94>,<$ACTION(CHKTIM)>)
  951.     SUBTTL    Command tables -- SET SERVER-TIMER
  952.  
  953. SSR000:    $NOISE    (SSR001,<to>)
  954.  
  955. SSR001:    $NUMBER    (SET005,^D10,<Number of seconds between idle server NAK's>)
  956.     SUBTTL    Command tables --SET command -- XON-XOFF-processing
  957.  
  958. XXP000:    $NOISE    (XXP010,<during connect to>)    ;[127]
  959. XXP010:    $KEYDSP    (XXP020)            ;[127]
  960. XXP020:    $STAB                    ;[127]
  961.      DSPTAB    (SET005,$XXDEF,<default>)    ;[127]
  962.      DSPTAB    (SET005,$XXLCL,<local>)        ;[127]
  963.      DSPTAB    (SET005,$XXREM,<remote>)    ;[127]
  964.     $ETAB
  965.     SUBTTL    Command tables -- STATUS command
  966.  
  967. STA000:    $NOISE    (CONFRM,<of Kermit>)
  968.     SUBTTL    Command tables -- SHOW command
  969.  
  970. SHO000:    $KEYDSP    (SHO010,<$DEFAULT(all)>)
  971.  
  972. SHO010:    $STAB
  973.      DSPTAB    (CONFRM,SHOALL,<all>)
  974.      DSPTAB    (CONFRM,SHODAY,<daytime>)
  975.      DSPTAB    (CONFRM,SHODEB,<debugging>)
  976.      DSPTAB    (CONFRM,SHOFIL,<file-information>)
  977.      DSPTAB    (CONFRM,SHOLIN,<line-information>)
  978.      DSPTAB    (CONFRM,SHOMAC,<macros>)
  979.      DSPTAB    (CONFRM,SHOPKT,<packet-information>)
  980.      DSPTAB    (CONFRM,SHOTIM,<timing-information>)
  981.      DSPTAB    (CONFRM,SHOVER,<version>)
  982.     $ETAB
  983.     SUBTTL    Entry vector and initialization
  984.  
  985. TOPS20<
  986. KERMIT:    JRST    START            ; Start program entry
  987.     JRST    START            ; Reenter address
  988.     BYTE    (3)KERWHO(9)KERVER(6)KERMIN(18)KEREDT
  989. >; End of TOPS20 entry vector
  990.  
  991.  
  992. TOPS10<
  993. KERMIT:    PORTAL    .+2            ; Allow EXO entry
  994.     PORTAL    .+2            ; Allow EXO entry
  995.     TDZA    S1,S1            ; Determine if CCL entry or not
  996.      SETO    S1,            ; Flag CCL entry
  997.     MOVEM    S1,CCLOFS        ; Store the CCL offset
  998. >; End of TOPS10 conditional
  999.  
  1000. START:    RESET                ; Reset everthing
  1001.     MOVE    P,[IOWD PDLLEN,PDL]    ; Set up the stack
  1002.     MOVE    S1,[XWD PHABEG,LOWPHA]    ; Set up to move the phased code
  1003.     BLT    S1,PHAEND        ; All of it
  1004.     MOVEI    S1,IB.SZ        ; Get the initialization block size
  1005.     XMOVEI    S2,IB            ; And the address
  1006.     $CALL    I%INIT            ; Initialize GLXLIB
  1007.     $CALL    MSG%INIT##        ; Initialize the message processing
  1008.     $CALL    TT%INIT##        ; Initialize the type out routines
  1009.  
  1010.     MOVEI    S1,LOWSIZ        ; Get the size of the low seg
  1011.     XMOVEI    S2,LOWBEG        ; And the start address
  1012.     $CALL    .ZCHNK            ; Clear the low segment out
  1013.     $CALL    SY%INIT##        ; Initialize KERSYS
  1014.     $CALL    LOKINI##        ; Initialize KERWLD data
  1015.  
  1016.     $CALL    INIKER            ; Initialize Kermit processing
  1017.     $CALL    INITRM            ; Initialize the terminal processing
  1018.     $CALL    INIFIL            ; Initialize the file processing
  1019.  
  1020. ; Determine node number of central site
  1021.  
  1022. TOPS10<
  1023.     MOVX    S1,<SIXBIT |CTY|>    ; Get console's name
  1024.     WHERE    S1,            ; Determine location
  1025.      SETZ    S1,            ; Assume no network support
  1026.     HRRZM    S1,HSTNOD        ; Save host node number
  1027.     TXNE    S1,RHMASK        ; Network support on?
  1028.      SKIPA    S1,[EXP [ITEXT(<^N/HSTNOD/::>)]] ; Yes, use node name
  1029.       MOVEI    S1,[ITEXT(<>)]        ; No, don't print node names
  1030.     MOVEM    S1,HSTITX        ; Save host name ITEXT address
  1031.  
  1032. ; Determine if we are logged in.
  1033.  
  1034.     PJOB    S1,            ;[125] Get our job number
  1035.     MOVNS    S1            ;[125] Set up for JOBSTS
  1036.     JOBSTS    S1,            ;[125] Get status for us
  1037.      MOVX    S1,JB.ULI        ;[125] If it doesn't work, this must be ancient
  1038.     TXNN    S1,JB.ULI        ;[125] Logged in?
  1039.      SETZ    S1,            ;[125] No, remember that
  1040.     MOVEM    S1,LOGDIN        ;[125] Save flag for file creation time
  1041. > ; End of TOPS10
  1042.  
  1043. ; Initialize the parser interface blocks
  1044.  
  1045.     XMOVEI    S1,KER000        ; Start of the tables
  1046.     MOVEM    S1,PRBLK+PAR.TB        ; Store it
  1047.     XMOVEI    S1,PROMPT        ; Address of the prompt string
  1048.     MOVEM    S1,PRBLK+PAR.PM        ; Store it
  1049.  
  1050. TOPS10<
  1051.     XMOVEI    S1,MON000        ; Monitor command block
  1052.     MOVEM    S1,MONBLK+PAR.TB    ; Store it
  1053.     XMOVEI    S1,[EXP 0]        ; No prompt string
  1054.     MOVEM    S1,MONBLK+PAR.PM    ; Store it
  1055.     SETOM    MONBLK+PAR.SR        ; Rescan the monitor command
  1056. >; End of TOPS10 conditional
  1057.  
  1058.     SETZB    S1,S2            ; No arguments
  1059.     $CALL    P$INIT            ; Initialize the parser
  1060.  
  1061.     $CALL    REDINI            ; Read the KERMIT.INI file
  1062.  
  1063. TOPS10<
  1064.     SKIPE    CCLOFS            ; CCL Entry ?
  1065.     $CALL    SETTMP            ; Yes, set up CCL file
  1066.     MOVEI    S2,MONBLK        ; Get the monitor Kermit paring
  1067.     SKIPN    CCLOFS            ; CCL Entry ?
  1068.      JRST    PARL.0            ; Monitor entry, use rescan block
  1069. >; End of TOPS10 conditional
  1070.     JRST    PARL.1            ; Enter the parsing loop
  1071.  
  1072. ; Here to set up to call the parser again
  1073.  
  1074. PARLOP:
  1075. TOPS10<
  1076.     SKIPN    TMPADR            ; Have a TMPCOR file?
  1077.      SKIPE    CCLIFN            ; Of a take file?
  1078.       JRST    PARL.8            ; Yes, don't exit yet
  1079. >; End of TOPS10 conditional
  1080.  
  1081.     SKIPE    INIIFN            ; Processing a KERMIT.INI?
  1082.      JRST    PARL.8            ; Yes, can not exit yet
  1083.  
  1084.     SKIPE    XITFLG            ; No, want out?
  1085.      $CALL    C$EXI0            ;[125] And exit
  1086.  
  1087. TOPS10<
  1088. PARL.8:    SKIPE    TMPADR            ; Have TMPCOR data?
  1089.      $CALL    ADVTMP            ; Yes, advance it
  1090. >; End of TOPS10 conditional
  1091.     SKIPN    S1,PAR.CM+PRBLK        ; Have some parsed data around?
  1092.      JRST    PARL.1            ; No, skip this
  1093.     MOVX    S2,COM.SZ-1        ; Get the size
  1094.     STORE    S2,.MSTYP(S1),MS.CNT    ; Store it
  1095.     SETZM    COM.CM(S1)        ; And clear text pointer
  1096.  
  1097. PARL.1:    $CALL    T$LOCAL            ; Determine if we are a local or remote
  1098.     MOVEI    S1,KER000        ; Assume remote
  1099.     SKIPF                ; Are we?
  1100.      MOVEI    S1,KER100        ; No, use local table
  1101.     MOVEM    S1,PRBLK+PAR.TB        ; Store it
  1102.     MOVEI    S2,PRBLK        ; Get the address of the arguments
  1103. PARL.0:    MOVX    S1,PAR.SZ        ; And the size
  1104.     $CALL    PARSER##        ; Parse a command
  1105.     DMOVEM    S1,PRTARG        ; Save the argument pointers
  1106.     LOAD    T1,PRT.CM(S2)        ; Get the address of the parsed data
  1107.     STORE    T1,PAR.CM+PRBLK        ; Save for next try
  1108.     LOAD    T2,PRT.FL(S2)        ; Get the flags
  1109.     TXC    T2,P.CTAK!P.ERRO    ; Error?
  1110.     TXCN    T2,P.CTAK!P.ERRO    ; from a TAKE file?
  1111.      JRST    PARL.D            ; Yes, display the line also
  1112.     TXNE    T2,P.DSPT        ; Need to display this?
  1113. PARL.D:     $TEXT    (,<^T/PROMPT/^T/@PRT.MS(S2)/^A>) ; Yes, do it
  1114.  
  1115.     JUMPF    PARL.E            ; Get an error on the command?
  1116.  
  1117.     MOVEI    S1,COM.SZ(T1)        ; No, get the address
  1118.     $CALL    P$SETU            ; Set up to parse the command
  1119.  
  1120.     $CALL    P$KEYW            ; Get the first keyword
  1121.     CAIN    S1,.KYTAK        ;[111] Take command is special
  1122.      JRST    PARLOP            ;[111] It gets handled before the return
  1123.     $CALL    (S1)            ; And call the processor for it
  1124.     JUMPT    PARLOP            ; If no error, keep going
  1125.  
  1126.     $CALL    ABRTAK            ; Abort any TAKE processing
  1127.     JRST    PARLOP            ; And try again
  1128. ; Here if the command parsing got and error.  Check for running out of data
  1129. ;on TMPCOR processing or rescan processing.  If we have run out of TMPCOR
  1130. ;If we have run out of data on a rescan, we will just prompt.
  1131.  
  1132. PARL.E:    TXNE    T2,P.CEOF!P.ENDT    ; Run out of data?
  1133.      JRST    PARL.F            ; Yes, go check what we should do
  1134.     $TEXT(,<? ^T/@PRT.EM(S2)/>)    ; Give the error
  1135.  
  1136. PARL.F:    TXNN    T2,P.ENDT        ; End of TAKE file?
  1137.      JRST    PARL.G            ; No, punt the take file if any
  1138.  
  1139.     SKIPE    INIIFN            ; Doing KERMIT.INI?
  1140.      $RETT                ; Yes, pop up a level
  1141.     $CALL    ABRT.0            ; No, end of normal TAKE file or CCL entry
  1142.     SKIPA                ; And continue on
  1143. PARL.G:     $CALL    ABRTAK            ; Abort what TAKE processing we can
  1144.     SKIPE    INIIFN            ; .INI file?
  1145.      $RETT                ; Yes, all done with it
  1146.     SKIPE    CCLOFS            ; CCL entry?
  1147.      $HALT                ; Yes, exit, but let him continue
  1148.     JRST    PARLOP            ; Go for next command
  1149. ; Here to handle the monitor command dispatch. We just see if we have
  1150. ; a CRLF or an item to dispatch on.  If we have a CRLF just return, else
  1151. ; we dispatch
  1152.  
  1153. KERCMD:    SETOM    XITFLG            ; Flag we must exit
  1154.     $CALL    P$CFM            ; Is this a confirm?
  1155.     JUMPF    KERCM0            ; If this is not a confirm, jump
  1156.     $CALL    SHOVER            ; Show the version
  1157.     SETZM    XITFLG            ; Clear the exit flag
  1158.     $RETT                ; Give a good return to the caller
  1159.  
  1160. ; Here if we got a command that we are to process
  1161.  
  1162. KERCM0:    $CALL    P$KEYW            ; Must have a keyword
  1163.     $RETIF                ; Return if something else
  1164.     $CALL    (S1)            ; Call the routine
  1165.     $RET                ; Pass back failures
  1166.  
  1167.     SUBTTL    Kermit initialization
  1168.  
  1169. ;+
  1170. ;.hl1 INIKER
  1171. ;This routine will initialize the Kermit processing.  It will get whatever
  1172. ;general information is required for Kermit.
  1173. ;.literal
  1174. ;
  1175. ; Usage:
  1176. ;    $CALL    INIKER
  1177. ;    (Return)
  1178. ;
  1179. ;.end literal
  1180. ;-
  1181.  
  1182. INIKER:    $CALL    DEFPRM            ; Default the prompt
  1183.     MOVX    S2,JI.USR        ; Get the user directory number
  1184.     SETO    S1,            ;  for this job
  1185.     $CALL    I%JINF            ; Get it
  1186.     MOVEM    S2,.MYPPN        ; Store for later
  1187.     MOVX    S1,D$ESCAPE        ; Get the default escape character
  1188.     MOVEM    S1,ESCAPE        ; Store it
  1189.     ADDI    S1,"A"-.CHCNA        ; Convert to printing character
  1190.     $TEXT    (<-1,,ESCTXT>,<^^^7/S1/^0>) ; Store the text
  1191.  
  1192. ;[107] Now define any default macros.  We will use a macro to do this.
  1193. ;[107]Arguments to the macro are:
  1194. ;[107]DFNMAC(macro.name,<Macro expansion>)
  1195. ;[107]
  1196. ;[107] Macro expansion must be a completely valid set of SET keywords/values
  1197. ;[107]
  1198. DEFINE DFNMAC(MNAME,MTEXT)<
  1199.     ...MNL==<...MTL==0>        ;;[107] Clear length counters
  1200.     .XCREF    ...MNL,...MTL        ;;[107] No need to CREF these
  1201.     IRPC <MNAME>,<...MNL==...MNL+1>    ;;[107] Count characters in the name
  1202.     IRPC <MTEXT>,<...MTL==...MTL+1>    ;;[107] And in the expansion text
  1203.     ...MTL==<6+1+...MNL+1+...MTL+2+5>/5 ;;[107] Length of full expansion in words
  1204.     ...MNL==<...MNL+5>/5        ;;[107] Get length of name in words (with null)
  1205. ;;[107] Now generate the code to insert the items into the table
  1206.  
  1207.     MOVEI    S1,$MBNAM+...MNL+...MTL    ;;[107] Get the length of the block
  1208.     $CALL    M%GMEM            ;;[107] Get the memory we need
  1209.     STORE    S1,$MBLEN(S2),MB$LEN    ;;[107] Store the length of the block
  1210.     MOVEI    S1,SETMAC        ;;[107] Store the routine
  1211.     HRLI    S1,(S2)            ;;[107] And block address
  1212.     MOVEM    S1,$MBRTN(S2)        ;;[107]  .  .  .
  1213.     MOVEI    S1,...MNL+$MBNAM    ;;[107] Store offset to expansion
  1214.     STORE    S1,$MBOFS(S2),MB$OFS    ;;[107]  .  .  .
  1215.     MOVEI    S1,$MBNAM(S2)        ;;[107] Point at name storage
  1216.     HRLI    S1,[ASCIZ |'MNAME'|]    ;;[107] And at name text
  1217.     BLT    S1,$MBNAM+...MNL-1(S2)    ;;[107] Copy the name
  1218.     MOVEI    S1,$MBNAM+...MNL(S2)    ;;[107] Point at expansion storage
  1219.     HRLI    S1,[ASCIZ |DEFINE MNAME MTEXT
  1220. |] ;;[107] And at the text
  1221.     BLT    S1,$MBNAM+...MNL+...MTL-1(S2) ;;[107] Copy it
  1222.     HRLI    S2,$MBNAM(S2)        ;;[107] Point at the name
  1223.     MOVEI    S1,DFNTAB        ;;[107] And at the table header
  1224.     $CALL    S%TBAD            ;;[107] Put the macro in the table
  1225.     JUMPF    [$STOP(BMD,<Bad macro definition>)]
  1226. > ;[107] End of DFNMAC
  1227. ;[107]
  1228. ;[107] Now actually define our default macro(s)
  1229. ;[107]
  1230.  
  1231. ;[133]    DFNMAC(IBM,<Handshake 21, IBM-mode on, Parity mark, Local-echo on>)
  1232.     DFNMAC(IBM,<Handshake 21, Parity mark, Local-echo on>)
  1233.     $RETT                ; Return to the caller
  1234.     SUBTTL    KERMIT.INI processing
  1235.  
  1236. ; This routine will set up for processing KERMIT.INI
  1237.  
  1238. REDINI:    SETZM    INIIFN            ; Assume no .INI file
  1239.     MOVX    S1,<<SIXBIT |INI|>>    ;[125] Try INI:KERMIT.INI first
  1240.     MOVEM    S1,INIFD+.FDSTR        ;[125] for global defs
  1241.     MOVEI    S1,INIFD        ;[125] Get the FD address
  1242.     SETZ    S2,            ;[125] No log file FD
  1243.     $CALL    P$TAKE            ;[125] Set up the take
  1244.     JUMPF    REDIN0            ;[125] If not there, don't worry about it
  1245.     MOVEM    S1,INIIFN        ;[125] Found the file, save the IFN
  1246.     $CALL    PARL.1            ;[125] Parse the file
  1247.     SETZM    INIIFN        ;[MF] Again assume no .INI file
  1248. REDIN0:    MOVX    S1,<<SIXBIT |DSK|>>    ;[125] Now we will use
  1249.     MOVEM    S1,INIFD+.FDSTR        ;[125] DSK:KERMIT.INI[,]
  1250.     GETPPN    S1,            ; Get our logged in PPN
  1251.      JFCL                ; Silly return
  1252.     STORE    S1,INIFD+.FDPPN        ; Store for where to find the KERMIT.INI
  1253.     MOVEI    S1,INIFD        ; Get the FD address
  1254.     SETZ    S2,            ; And clear the LOG file FD
  1255.     $CALL    P$TAKE            ; Set it up
  1256.     $RETIF                ; Just punt if none
  1257.     MOVEM    S1,INIIFN        ; Save the IFN
  1258.     $CALL    PARL.1            ; Parse the file
  1259.     SETZM    INIIFN            ; Clear the IFN
  1260.     $RETT                ; And return
  1261.     SUBTTL    CCL entry processing -- SETTMP
  1262.  
  1263. ; This routine will set up to read from either TMPCOR or a .TMP file on
  1264. ;disk.  This is used when we have been started at CCL entry.
  1265.  
  1266. TOPS10<
  1267.  
  1268. SETTMP:    SETZM    CCLIFN            ; Clear the IFN for disk file
  1269.     MOVX    S1,<XWD .TCRRF,T1>    ; Get the arg pointer
  1270.     MOVX    T1,<SIXBIT |KER|>    ; And the file name
  1271.     SETZ    T2,            ; No buffer
  1272.     TMPCOR    S1,            ; See if the file exists
  1273.      JRST    SETT.D            ; No, try on DSK:
  1274.     AOJ    S1,            ; Yes, bump the size
  1275.     MOVEM    S1,TMPSIZ        ; And remember it
  1276.     $CALL    M%GMEM            ; Get the memory
  1277.     MOVEM    S2,TMPADR        ; Save the address
  1278.     MOVN    T2,TMPSIZ        ; Get the buffer size
  1279.     MOVSI    T2,(T2)            ; In the left half
  1280.     HRRI    T2,-1(S2)        ; And make the IOWD
  1281.     MOVX    T1,<SIXBIT |KER|>    ; Get the name
  1282.     MOVX    S1,<XWD .TCRDF,T1>    ; Get the pointer
  1283.     TMPCOR    S1,            ; And read the file
  1284.      $STOP    TFD,<Temp file disappeared> ; Where did it go?
  1285.     MOVE    S1,TMPADR        ; Get the address
  1286.     HRLI    S1,(POINT 7,)        ; And make it a byte pointer
  1287.     STORE    S1,PRBLK+PAR.SR        ; Save the source
  1288.     ADD    S1,TMPSIZ        ; Point to last word+2
  1289.     HRLI    S1,(POINT 7,,34)    ; Point at last character
  1290.     SUBI    S1,2            ;  .  .  .
  1291.     MOVE    T1,TMPSIZ        ; Get the size
  1292.     SOJ    T1,            ; Minus one word
  1293.     IMULI    T1,5            ; Make it the max number of characters
  1294.  
  1295. SETT.0:    LDB    S2,S1            ; Get the character
  1296.     CAIN    S2,.CHLFD        ; End of command?
  1297.      $RETT                ; Yes, no problem
  1298.     JUMPN    S2,SETT.1        ; Some non-null character?
  1299.     ADDX    S1,<INSVL.(7,BP.POS)>    ; Back up the position
  1300.     JUMPG    S1,.+2            ; Go over a word boundary?
  1301.      SUBX    S1,<INSVL.(^D35,BP.POS)+1> ; Back to previous word
  1302.     SOJG    T1,SETT.0        ; Try again if anything left
  1303.     PJRST    ABRTAK            ; Nothing really there, all done
  1304.  
  1305. SETT.1:    MOVX    S2,.CHLFD        ; Doesn't end with a LF, get one
  1306.     IDPB    S2,S1            ; And store it
  1307.     $RETT                ; And return
  1308.  
  1309. ; Here to attempt to read the file from disk
  1310.  
  1311. SETT.D:    SETZM    TMPADR            ; Flag nothing in core
  1312.     MOVE    S1,[POINT 6,CCLFD+.FDNAM] ; Get the byte pointer to the name field
  1313.     MOVEM    S1,TMPBP        ; Save it
  1314.     PJOB    S1,            ; Get out job number
  1315.     $TEXT    (TMPDBP,<^D3R0/S1/KER^A>) ; Store the name
  1316.     MOVEI    S1,CCLFD        ; Get the FD for the file
  1317.     SETZ    S2,            ; Want no log file
  1318.     $CALL    P$TAKE            ; Set up the file
  1319.      $RETIF                ; If not found, just return
  1320.     MOVEM    S1,CCLIFN        ; Save the IFN so we can abort any TAKE file
  1321.  
  1322. ; Now cheat and delete the file on another channel
  1323.  
  1324.     MOVEI    S1,FOB.MZ        ; Get the size
  1325.     MOVEI    S2,CCLFOB        ; And the address
  1326.     $CALL    F%DEL            ; And delete it (other channel has open copy)
  1327.     $RETT                ; And return
  1328.  
  1329. ; Routine to store sixbit characters
  1330.  
  1331. TMPDBP:    CAIL    S1,"`"            ; Lower case?
  1332.      SUBI    S1,"a"-"A"        ; Yes, make upper
  1333.     SUBI    S1,"A"-'A'        ; Convert to SIXBIT
  1334.     JUMPL    S1,.RETT        ; Ignore control characters
  1335.     IDPB    S1,TMPBP        ; Store the character
  1336.     $RETT                ; And return
  1337. >; End of TOPS10 conditional
  1338.     SUBTTL    CCL entry processing -- ADVTMP
  1339.  
  1340. ; This routine is used to advance the byte pointer for the TMPCOR data.
  1341. ;It will step through the parsed data returned from PARSER while advancing
  1342. ;our own byte pointer to the TMPCOR data.
  1343.  
  1344. TOPS10<
  1345.  
  1346. ADVTMP:    MOVE    S1,PRTARG+1        ; Get the address of the arg block
  1347.     MOVE    S1,PRT.MS(S1)        ; Get the address of OPRPAR's buffer
  1348.     HRLI    S1,(POINT 7,)        ; Make it a byte pointer
  1349.  
  1350. ADVT.1:    ILDB    S2,S1            ; Get a character
  1351.     JUMPE    S2,ADVT.2        ; Done?
  1352.     IBP    PRBLK+PAR.SR        ; No, advance the pointer
  1353.     JRST    ADVT.1            ; And try again
  1354.  
  1355. ADVT.2:    MOVE    S1,PRBLK+PAR.SR        ; Get the current pointer
  1356.     ILDB    S2,S1            ; And peek at the next character
  1357.     JUMPN    S2,.RETT        ; If something left, try again
  1358.     $CALL    ABRTAK            ; All done, clear the take file
  1359.     SKIPE    CCLOFS            ; CCL entry?
  1360.      $HALT                ; Yes, then exit
  1361.     $RETT                ; Otherwise, try again
  1362. >; End of TOPS10 conditional
  1363.     SUBTTL    CCL entry processing -- ABRTAK
  1364.  
  1365. ; This routine will abort the current take file.
  1366.  
  1367. TOPS10<
  1368.  
  1369. ABRTAK:    SKIPN    S2,TMPADR        ; Have an incore file?
  1370.      JRST    ABRT.1            ; No, check for disk .TMP or TAKE file
  1371.     MOVE    S1,TMPSIZ        ; Yes, get the size
  1372.     $CALL    M%RMEM            ; Return the memory
  1373.     SETZM    TMPADR            ; Clear the address
  1374.     SETZM    PRBLK+PAR.SR        ; Clear the source pointer
  1375.     $RETT                ; And return
  1376.  
  1377. ABRT.1:    SKIPN    S1,INIIFN        ;[127] Have a KERMI.INI file?
  1378.     MOVE    S1,CCLIFN        ;[127] or anything else
  1379.      JUMPE    S1,.RETT        ;[127] All done if not
  1380.     SETO    S2,            ; Yes, position it to EOF
  1381.     $CALL    F%POS            ;  .  .  .
  1382. ABRT.0:    SKIPN    INIIFN            ;[127] Unless doing KERMIT.INI
  1383.     SETZM    CCLIFN            ; Remember we have done this
  1384.     $RETT                ; And return
  1385.  
  1386. >; End of TOPS10 conditional
  1387.     SUBTTL    Command parsing utility routines -- GETANS - Get an answer
  1388.  
  1389. ; This routine will prompt the user and get his string answer.
  1390. ;
  1391. ; Usage:
  1392. ;    S1/ Echo flag,,address of prompt(as ITEXT)
  1393. ;    S2/ Length in chars,,address for answer
  1394. ;    $CALL    GETANS
  1395. ;     (return true always, S1= Length of response in characters)
  1396. ;
  1397.     ND    ANSLEN,    ^D40        ; Allow lots of room for answers
  1398.  
  1399. GETANS:    DMOVE    T1,S1            ; Get the args
  1400.     MOVEI    S1,.RDRTY+1        ; Get the length
  1401.     MOVEI    S2,TXIBLK        ; Get the address of the block
  1402.     $CALL    .ZCHNK            ; Clear it out
  1403.     MOVEI    S1,ANSLEN        ; Get the buffer length
  1404.     MOVEI    S2,ANSBUF        ; And the address
  1405.     $CALL    .ZCHNK            ; Clear it out
  1406.  
  1407.     MOVX    S1,.RDRTY        ; Get the last word we have
  1408.     MOVEM    S1,TXIBLK+.RDCWB    ; Save it
  1409.     MOVX    S1,RD%TOP!RD%CRF!RD%JFN    ; Get the flags
  1410.     TXNE    T1,LHMASK        ; Want no echo?
  1411.      TXO    S1,RD%NEC        ; Yes, flag that also
  1412.     MOVEM    S1,TXIBLK+.RDFLG    ; Store the flags
  1413.     MOVX    S1,<XWD .PRIIN,.PRIOU>    ; Get the JFN's for the terminal
  1414.     MOVEM    S1,TXIBLK+.RDIOJ    ; Save them
  1415.  
  1416.     MOVE    S1,[POINT 7,ANSBUF]    ; Get the buffer pointer
  1417.     MOVEM    S1,TXIBLK+.RDDBP    ; Save it for storing the prompt
  1418.     MOVX    S1,<ANSLEN*5>-1        ; Get the length of the buffer
  1419.     MOVEM    S1,TXIBLK+.RDDBC    ; Save as initial count
  1420.  
  1421.     $TEXT(ANSDBP,<^I/(T1)/^A>)    ; Get the prompt into the buffer
  1422.     MOVE    S1,TXIBLK+.RDDBP    ; Get the updated byte pointer
  1423.     MOVEM    S1,TXIBLK+.RDBFP    ; Save as start of destination buffer also
  1424.     $TEXT(<-1,,PRMPTB>,<^I/(T1)/^A^0>) ; Store in prompt buffer
  1425.     HRROI    S1,PRMPTB        ; Get the address of the buffer
  1426.     MOVEM    S1,TXIBLK+.RDRTY    ; Save it for ^R
  1427.     $CALL    K%SOUT            ; Output the string also
  1428.  
  1429.     MOVEI    S1,TXIBLK        ; Get the block address
  1430.     $CALL    K%TXTI            ; And do the TEXTI simulation
  1431.     TXNE    T1,LHMASK        ; No-echo flag?
  1432.      $TEXT    (,<>)            ; Yes, force a CRLF
  1433.     MOVE    T1,TXIBLK+.RDBFP    ; Get the pointer to the text we got
  1434.     HRLI    T2,(POINT 7,)        ; Get the destination byte pointer
  1435.     SETO    S1,            ; Clear the character counter
  1436.  
  1437. GETA.L:    ILDB    S2,T1            ; Get a character
  1438.     CAXN    S2,.CHLFD        ; Line break?
  1439.      SETZ    S2,            ; Yes, change to a null
  1440.     IDPB    S2,T2            ; Store the character
  1441.     AOJ    S1,            ; Count the character
  1442.     JUMPN    S2,GETA.L        ; And loop for more unless done
  1443.     $RETT                ; And return
  1444.  
  1445. ANSDBP:    SOSLE    TXIBLK+.RDDBC        ; Count the character
  1446.      IDPB    S1,TXIBLK+.RDDBP    ; Store the character
  1447.     $RETT                ; And return
  1448.     SUBTTL    Command parsing utility routines -- CHKCTL
  1449.  
  1450. ;+
  1451. ;.HL1 Command parsing utility routines
  1452. ; These routines are called as $ACTION routines during parsing to
  1453. ;check if the values typed for a field are reasonable.  If the
  1454. ;value is not, an error is returned.
  1455. ;
  1456. ;.HL2 CHKCTL
  1457. ; This routine will check that the value typed represents a valid ASCII
  1458. ;control character.
  1459. ;octal.
  1460. ;-
  1461.  
  1462. CHKCTL:    SKIPL    T1,CR.RES(S2)        ; Get the result value
  1463.      CAIL    T1," "            ; Legal character?
  1464.       TRNA                ; Failed, skip
  1465.     $RETT                ; Everything is OK
  1466.     $CALL    FIXIT            ; Back up the pointer
  1467.     MOVEI    S2,[ASCIZ |Value must be between 0 and 37 octal|]
  1468.     $RETF                ; Pass back the error
  1469.  
  1470. ;+
  1471. ;.HL2 CHK8QU
  1472. ; This routine will check that the value typed is a valid 8-bit quoting
  1473. ;character.
  1474. ;-
  1475.  
  1476. CHK8QU:    MOVE    T1,CR.RES(S2)        ; Get the result value
  1477.     CAIL    T1,41            ; Less than 41?
  1478.      CAILE    T1,76            ; And less than 76  (range of 41 to 76)
  1479.       TRNA                ; No, continue checks
  1480.     $RETT                ; Yes, give a good return
  1481.     CAIL    T1,140            ; Within the range of 140 to
  1482.      CAILE    T1,176            ;  176
  1483.       TRNA                ; No, give an error return
  1484.     $RETT                ; Yes, give an ok return
  1485.     $CALL    FIXIT            ; Fix up the pointers
  1486.     MOVEI    S2,[ASCIZ |Value must be within the ranges of 41 to 76 or 140 to 176|]
  1487.     $RETF                ; Give a failure return
  1488.  
  1489. ;+
  1490. ;.HL2 CHKTIM
  1491. ;This routine will check to see if the time out time is valid.  Valid time out
  1492. ;times are within the range of 1 to 94.
  1493. ;-
  1494.  
  1495. CHKTIM:    SKIPL    T1,CR.RES(S2)        ; Get the result value
  1496.      CAILE    T1,^D94            ; Within range?
  1497.       TRNA                ; No, give the error return
  1498.       $RETT                ; Valid, return now
  1499.     $CALL    FIXIT            ; Fix up the command block
  1500.     MOVEI    S2,[ASCIZ |Time out must be between 0 and 94|]
  1501.     $RETF                ; Give a failure return
  1502.  
  1503. ;+
  1504. ;.HL2 CHKPOS
  1505. ;This routine will check to see if the number is positive.  If it is not then
  1506. ;an error will be issued.
  1507. ;-
  1508.  
  1509. CHKPOS:    SKIPL    CR.RES(S2)        ; Valid number?
  1510.      $RETT                ; Yes, just return
  1511.     $CALL    FIXIT            ; No, error out
  1512.     MOVEI    S2,[ASCIZ |Must be a positive number|]
  1513.     $RETF                ; Give a failure return
  1514.  
  1515. ;+
  1516. ;.HL2 CHKPKT
  1517. ;This routine will check to see if the packet length if valid.
  1518. ;-
  1519.  
  1520. CHKPKT:    MOVE    T1,CR.RES(S2)        ; Get the value given
  1521.     CAIL    T1,^D10            ; Is this within range?
  1522.      CAILE    T1,^D1000 ; [134] 94    ; . . .
  1523.       TRNA                ; No, issue an error
  1524.     $RETT                ; it is ok, just return
  1525.     $CALL    FIXIT            ; Fix up pointers
  1526.     MOVEI    S2,[ASCIZ |Packet length must be between 10 and 1000|] ; [134]
  1527.     $RETF                ; Give a failure return
  1528.  
  1529. ;+
  1530. ;.HL2 CHKPDC
  1531. ;This routine will check to see if the padding character is valid.  It will
  1532. ;make sure that it is either 177 or in the range of 0 to 37.
  1533. ;-
  1534.  
  1535. CHKPDC:    MOVE    T1,CR.RES(S2)        ; Get the value
  1536.     CAIN    T1,.CHDEL        ; Delete?
  1537.       $RETT                ; Yes, just return
  1538.     CAIL    T1,.CHNUL        ; At least a null
  1539.      CAILE    T1," "-1        ; And less than a space?
  1540.       TRNA                ; No, illegal value
  1541.     $RETT                ; Yes, give a good return
  1542.     $CALL    FIXIT            ; Fix up the pointers
  1543.     MOVEI    S2,[ASCIZ |Illegal padding character|]
  1544.     $RETF                ; Give a failure return
  1545.  
  1546. ;+
  1547. ;.HL2 CHKSHC
  1548. ;This routine will check to see if the start of header character is valid.
  1549. ;It will make sure that it is either 177 or in the range of 0 to 37.
  1550. ;-
  1551.  
  1552. CHKSHC:    MOVE    T1,CR.RES(S2)        ; Get the value
  1553.     CAIL    T1,.CHNUL        ; At least a null
  1554.      CAILE    T1," "-1        ; And less than a space?
  1555.       TRNA                ; No, illegal value
  1556.     $RETT                ; Yes, give a good return
  1557.     $CALL    FIXIT            ; Fix up the pointers
  1558.     MOVEI    S2,[ASCIZ |Illegal start of packet character|]
  1559.     $RETF                ; Give a failure return
  1560.  
  1561. ;+
  1562. ;.HL2 FIXIT
  1563. ;This routine will adjust the pointers back so that the command
  1564. ;can be Ctl-H'd.
  1565. ;-
  1566.  
  1567. FIXIT:    HRRZ    T4,CR.FLG(S2)        ; Get the address of the command block
  1568.     MOVE    T1,.CMPTR(T4)        ; Get the command pointer
  1569.     MOVE    T2,.CMABP(T4)        ; Get the byte pointer to the atom buffer
  1570. FIXI.1:    ADDX    T1,<INSVL.(7,BP.POS)>    ;; Back up the position
  1571.     JUMPG    T1,.+2            ;; Go over a word boundary?
  1572.      SUBX    T1,<INSVL.(^D35,BP.POS)+1> ; Back to previous word
  1573.     AOS    .CMCNT(T4)        ; Increment the count
  1574.     ILDB    T3,T2            ; Get a character
  1575.     JUMPN    T3,FIXI.1        ; If zero then finished
  1576.     MOVEM    T1,.CMPTR(T4)        ; Store the adjusted byte pointer
  1577.     POPJ    P,0
  1578.     SUBTTL    Command execution -- CONNECT command
  1579.  
  1580. ;+
  1581. ;.hl1 C$CONNECT
  1582. ;This routine will parse and process the CONNECT command.  This routine
  1583. ;will check to determine that the line that is being set is not the same as
  1584. ;a line that is currently being used.
  1585. ;-
  1586.  
  1587. C$CONNECT:
  1588.     $CALL    P$CFM            ; User type a CONNECT <CRLF>?
  1589.     JUMPT    CNCT.1            ; Yes, skip the setting of this
  1590.     $CALL    LINSBR            ; Parse the line information
  1591.     $RETIF                ; Just return if that failed
  1592.  
  1593. CNCT.1:    MOVE    S1,XFRTRM+$TTNOD    ; Get the transfer line node number
  1594.     MOVE    S2,XFRTRM+$TTLIN    ; Get the transfer line number
  1595.     CAMN    S1,MYTERM+$TTNOD    ; Different from this?
  1596.      CAME    S2,MYTERM+$TTLIN    ; Same node and line number?
  1597.       JRST    CNCT.0            ; No, different, so open the terminals
  1598.     $KERR    (<Can not connect to your terminal line>)
  1599.     $RETF                ; Return a failure
  1600.  
  1601. ; Here if we can open the terminal lines.
  1602.  
  1603. CNCT.0:    RELEAS    TTY,            ; Close this terminal channel
  1604.     XMOVEI    S1,XFRTRM        ; Point to the remote terminal
  1605.     $CALL    T$OPEN            ; Open the terminal
  1606.     $RETIF                ; Return if that fails
  1607.     SETZ    S1,            ; Break on all characters
  1608.     XMOVEI    S2,XFRTRM        ; Point to the block
  1609.     $CALL    T$SBRK            ; Set the break information
  1610.  
  1611.     XMOVEI    S1,MYTERM        ; Now open my terminal
  1612.     $CALL    T$OPEN            ; Open it
  1613.     JUMPF    [XMOVEI    S1,XFRTRM        ; Close the other terminal
  1614.         $CALL    T$CLOS            ; . . .
  1615.         $RETF]                ; And return
  1616.  
  1617.     SETZ    S1,            ; Break on all characters
  1618.     XMOVEI    S2,MYTERM        ;[125] Point to the block
  1619.     $CALL    T$SBRK            ; Set the PIM mode break set
  1620.  
  1621.     MOVE    S1,XXPMOD        ;[127] Get XON-XOFF-processing
  1622.     CAIN    S1,$XXDEF        ;[127] Should we set it?
  1623.      JRST    CNCT.2            ;[127] No, skip this
  1624.     MOVX    T1,.TOPAG+.TOSET    ;[127] want to set it
  1625.     MOVE    T2,MYTERM+$TTUDX    ;[127] and UDX
  1626.     CAIN    S1,$XXLCL        ;[127] Local mode?
  1627.      MOVEI    T3,1            ;[127] Yes, turn page on
  1628.     CAIN    S1,$XXREM        ;[127] Remote mode?
  1629.      MOVEI    T3,0            ;[127] Yes, turn page off
  1630.     MOVE    S1,[XWD 3,T1]        ;[127]
  1631.     TRMOP.    S1,            ;[127] do it
  1632.       JFCL                ;[127] oh well
  1633.     MOVE    T2,XFRTRM+$TTUDX    ;[127] Also do Xfr line
  1634.     MOVE    S1,[XWD 3,T1]        ;[127]
  1635.     TRMOP.    S1,            ;[127] do it
  1636.       JFCL                ;[127] oh well
  1637. CNCT.2:                    ;[127]
  1638.  
  1639.     MOVE    S1,$TTUDX+XFRTRM    ; Get the UDX we are using
  1640.     DEVNAM    S1,            ; Convert to real name
  1641.      SETZ    S1,            ; No device?
  1642.     $TEXT(CN.TYP,<[Connecting to remote host via line ^W/S1/:^A>)
  1643.     SKIPE    XFRTRM+$TTNOD        ; If no network, don't confuse him
  1644.      $TEXT(CN.TYP,< (^N/XFRTRM+$TTNOD/:: line # ^O/XFRTRM+$TTLIN/)^A>)
  1645.     $TEXT(CN.TYP,<]>)
  1646.  
  1647.  
  1648.     $TEXT(CN.TYP,<Type ^T/ESCTXT/C to return to local KERMIT, ^T/ESCTXT/? for help>)    ;
  1649.     MOVEI    P1,"S"            ; Send chrs state
  1650.  
  1651. ; Set up session log if desired
  1652.  
  1653.     SETZ    P2,            ; Assume no log file
  1654.     MOVE    T1,SESLOG+$LGFLG    ; Get flags
  1655.     TXNN    T1,LG$SET        ; Have one?
  1656.      JRST    CN.LP            ; No, just enter loop
  1657.     MOVX    S1,FOB.MZ        ; Yes, get size of FOB
  1658.     MOVEI    S2,SESLOG+$LGFOB    ; Point at FOB
  1659.     TXNE    T1,LG$APP        ; Want to append?
  1660.      $CALL    F%AOPN            ; Yes, do it
  1661.     TXON    T1,LG$APP        ; No, we will next time
  1662.      $CALL    F%OOPN            ; Create new file this time
  1663.     MOVEM    S1,SESLOG+$LGIFN    ; Save possible IFN
  1664.     TXO    T1,LG$OPN        ; Assume file opened OK
  1665.     MOVEM    T1,SESLOG+$LGFLG    ; Save new flags
  1666.     MOVE    P2,S1            ; Get IFN in convenient place
  1667.     JUMPT    CN.LP            ; And go enter loop
  1668.     $KERR    (<Cannot open session log file ^F/SESLOG+$LGFD/ - ^E/S1/>)
  1669.     SETZB    P2,SESLOG+$LGFLG    ; Give up on session log
  1670.  
  1671. ; This the main CONNECT loop. Get chrs from terminal and
  1672. ; send them down the data line and vice versa.
  1673. ; Within this loop, P1 contains the state, P2 the IFN of the session log
  1674. ;file (if any).
  1675.  
  1676. CN.LP:    XMOVEI    S2,MYTERM        ; Get the address of my terminal block
  1677.     $CALL    T$CIN            ; Input a character if possible
  1678.     JUMPF    CN.LP1            ; Failed, try to output
  1679.     MOVE    S2,S1            ;[125] Get a copy of the character
  1680.     ANDI    S2,177            ;[125] Keep only 7 bits
  1681.     CAIN    P1,"E"            ; In escape sequence?
  1682.      JRST    CN.ESC            ; Yes
  1683.     CAIN    P1,"C"            ; control chr mode?
  1684.      JRST    CN.CTL            ; yes
  1685.     CAME    S2,ESCAPE        ; Is this escape?
  1686.      JRST    CN.SND            ; no, just send it
  1687.     MOVEI    P1,"E"            ; Yes, set escape mode
  1688.     JRST    CN.LP            ; and loop
  1689.  
  1690. ; Previous chr was an escape chr, check for special commands
  1691. CN.ESC:    CAIE    S2,"C"            ; Is is C
  1692.      CAIN    S2,"c"            ; or lower case c?
  1693.       JRST    CN.END            ; Yes done
  1694.     MOVEI    P1,"S"            ; Assume not send control chr
  1695.     CAMN    S2,ESCAPE        ; Another escape?
  1696.      JRST    CN.SND            ; Yes, send a real one
  1697.     CAIN    S2,"?"            ; want help?
  1698.      JRST    CN.HLP            ; Yes, do it
  1699.     CAIE    S2,"S"            ; Want status?
  1700.      CAIN    S2,"s"            ; or lower case "s"
  1701.       JRST    CN.STS            ; Yes
  1702.     CAIE    S2,"O"            ; Clear buffers?
  1703.      CAIN    S2,"o"            ;  .  .  .
  1704.        JRST    CN.CLR            ; Yes, go clear terminal buffers
  1705.     CAIE    S2,"Q"            ; Quit logging?
  1706.      CAIN    S2,"q"            ;  .  .  .
  1707.       JRST    CN.QUT        ; Quit logging
  1708.     CAIE    S2,"R"            ; Resume logging
  1709.      CAIN    S2,"r"            ;  .  .  .
  1710.       JRST    CN.RSM            ; Yes, do it
  1711.     CAIE    S2,"^"            ; Want control chr?
  1712.       JRST    CN.ESE            ; No, bad
  1713.     MOVEI    P1,"C"            ; Yes, set state
  1714.     JRST    CN.LP            ; and loop
  1715.  
  1716. ; Here to ding the user because he typed a bad command
  1717.  
  1718. CN.ESE:    MOVX    S1,.CHBEL        ; Control-G
  1719.     $CALL    CN.TYP            ; DING
  1720.     JRST    CN.LP            ; And loop
  1721.  
  1722. ; Quit logging
  1723.  
  1724. CN.QUT:    JUMPN    P2,CN.QU1        ; Are we logging now?
  1725.     $TEXT    (CN.TYP,<[^I/@HSTITX/Logging already disabled]>)
  1726.     JRST    CN.LP            ; Try again
  1727.  
  1728. CN.QU1:    $TEXT    (CN.TYP,<[^I/@HSTITX/Logging disabled]>)
  1729.     SETZ    P2,            ; Flag no log
  1730.     JRST    CN.LP            ; And back to top of loop
  1731.  
  1732. ; Resume logging to session log
  1733.  
  1734. CN.RSM:    MOVX    S2,LG$OPN        ; File open?
  1735.     TDNE    S2,SESLOG+$LGFLG    ; Is it?
  1736.      JRST    CN.RS1            ; Yes, go get IFN
  1737.     $TEXT    (CN.TYP,<[^I/@HSTITX/No log file open]>)
  1738.     JRST    CN.LP            ; No, back to top of loop
  1739.  
  1740. CN.RS1:    $TEXT    (CN.TYP,<[^I/@HSTITX/Logging to file ^F/SESLOG+$LGFD/ resumed]>)
  1741.     MOVE    P2,SESLOG+$LGIFN    ; Yes, get the IFN
  1742.     JRST    CN.LP            ; Try next character
  1743.  
  1744. ; Control chr mode - change next chr to control chr
  1745. CN.CTL:    MOVEI    P1,"S"            ; Next state
  1746.     CAIL    S1,"@"            ; See if reasonable
  1747.      CAILE    S1,"~"            ; also allow lower case
  1748.       JRST    CN.ESE            ; No, ignore it
  1749.     CAIL    S1,"`"            ;[125] Lower case range?
  1750.      XORI    S1,240            ;[125] Yes, toggle parity bit and convert to upper
  1751.     XORI    S1,300            ;[125] Convert to control character
  1752.  
  1753.     JRST    CN.SND            ; and send it
  1754.  
  1755. ; Process <escape chr>? - give them some hints
  1756. CN.HLP:    $TEXT(CN.TYP,<^M^J^I/@HSTITX/CONNECT escape commands:>)    ;
  1757.     $TEXT(CN.TYP,<  ^T/ESCTXT/C - Close connect and return to local KERMIT>)    ;
  1758.     $TEXT(CN.TYP,<  ^T/ESCTXT/O - Clear terminal input and output buffer>)
  1759.     $TEXT(CN.TYP,<    ^T/ESCTXT/Q - Turn off session logging (if enabled)>)    ;[127]
  1760.     $TEXT(CN.TYP,<    ^T/ESCTXT/R - Resume session logging after ^T/ESCTXT/Q>)    ;[127]
  1761.     $TEXT(CN.TYP,<  ^T/ESCTXT/S - Type status>)    ;
  1762.     $TEXT(CN.TYP,<  ^T/ESCTXT/? - Help (this message)>)    ;
  1763.     $TEXT(CN.TYP,<  ^T/ESCTXT/^T/ESCTXT/ - Send actual ^T/ESCTXT/>)    ;
  1764.     MOVEI    S1,[ASCIZ |^x (where x is A-Z,[,\,],^,_) - Send CONTROL-x.  Only|]    ;
  1765.     $TEXT(CN.TYP,<  ^T/ESCTXT/^Q/S1/>)    ; Avoid confusing $TEXT
  1766.     $TEXT(CN.TYP,<                 needed to send CONTROL-S and CONTROL-Q, since other>)    ;
  1767.     $TEXT(CN.TYP,<                 control characters can be typed directly.>)    ;
  1768.     JRST    CN.LP            ; and loop
  1769.  
  1770. ; Process <escape chr>S - give status
  1771. CN.STS:    MOVE    S1,$TTUDX+XFRTRM    ; Get the UDX we are using
  1772.     DEVNAM    S1,            ; Convert to real name
  1773.      SETZ    S1,            ; No device?
  1774.     $TEXT(CN.TYP,<^M^J[^I/@HSTITX/Connecting to remote host via line ^W/S1/:^A>)
  1775.     SKIPE    XFRTRM+$TTNOD        ; If no network, don't confuse him
  1776.      $TEXT(CN.TYP,< (^N/XFRTRM+$TTNOD/:: line # ^O/XFRTRM+$TTLIN/)^A>)
  1777.     $TEXT(CN.TYP,<]>)
  1778.     JUMPE    P2,CN.LP        ; Session log open?
  1779.     $TEXT    (CN.TYP,<[^I/@HSTITX/Logging session to ^F/SESLOG+$LGFD/]>)
  1780.     JRST    CN.LP            ; and loop
  1781.  
  1782. ; Clear terminal buffers
  1783.  
  1784. CN.CLR:    MOVX    T1,.TOCIB        ; Clear input buffer
  1785.     MOVE    T2,XFRTRM+$TTUDX    ; Get UDX
  1786.     MOVE    S1,[XWD 2,T1]        ; Arg pointer
  1787.     TRMOP.    S1,            ; Clear input
  1788.      MOVE    S1,[XWD 2,T1]        ; Reload pointer
  1789.     MOVX    T1,.TOCOB        ; Clear output buffer also
  1790.     TRMOP.    S1,            ; Clear it
  1791.      JFCL                ; Ignore error
  1792.     JRST    CN.LP            ; And loop back
  1793.  
  1794. ; Send the chr in S1 down the data line
  1795. CN.SND:    BLSCAL    GEN%PARITY##,<S1>    ; Generate correct parity for other terminal
  1796.     XMOVEI    S2,XFRTRM        ; Get the terminal control block
  1797.     $CALL    T$CCOT            ; Send chr down line
  1798.     SKIPN    LCLECH            ; Check if local echo
  1799.      JRST    CN.LP            ; No, just get another character
  1800.     $CALL    CN.PAR            ; Tack on even parity bit unless PR%NONE
  1801.     XMOVEI    S2,MYTERM        ; Yes, output to our terminal also
  1802.     $CALL    T$CCOT            ;  .  .  .
  1803. CN.LOG:    JUMPE    P2,CN.LP        ; If we echo it, log it also
  1804.     MOVE    S2,S1            ; Get the character
  1805.     MOVE    S1,P2            ; And the IFN
  1806.     $CALL    F%OBYT            ; Write the character
  1807.     JUMPT    CN.LP            ; Return to loop
  1808.     $TEXT    (CN.TYP,<% Output error for log file - ^E/S1/, logging disabled>)
  1809.     SETZ    P2,            ; Disable the logging
  1810.     JRST    CN.LP            ; and loop
  1811.  
  1812. ; No more Terminal input just now, see if we did any at all
  1813. CN.LP1:    XMOVEI    S2,XFRTRM        ; Point to the remote terminal line
  1814.     $CALL    T$CIN            ; Get a chr from line
  1815.     JUMPF    CN.HIB            ; None
  1816.     $CALL    CN.TYP            ; Type it on TTY
  1817.     JRST    CN.LOG            ; Go log the character (maybe) and try again
  1818.  
  1819. ; No output either, take a break
  1820.  
  1821. CN.HIB:    MOVE    S1,[HB.RIO+HB.RTC+HB.RWJ+^D1000]    ;
  1822.     HIBER    S1,            ; Wait a bit
  1823.       JFCL                ; ignore error
  1824.     JRST    CN.LP            ; and again
  1825.  
  1826. ; Here when done to close line and reset TTY status
  1827.  
  1828. CN.END:    MOVX    S2,LG$OPN        ; Log file open?
  1829.     TDNN    S2,SESLOG+$LGFLG    ; Is it?
  1830.      JRST    CN.EN1            ; No, continue
  1831.     ANDCAM    S2,SESLOG+$LGFLG    ; Clear open flag
  1832.     MOVE    S1,SESLOG+$LGIFN    ; Get the IFN
  1833.     $CALL    F%REL            ; Close it
  1834. CN.EN1:    XMOVEI    S1,XFRTRM        ; Close all the channels
  1835.     $CALL    T$CLOS            ; Close this off
  1836.     XMOVEI    S1,MYTERM        ; Point to my terminal block
  1837.     $CALL    T$CLOS            ; Close that one too
  1838.     $CALL    OCTERM            ; Kludge the terminal back
  1839.     $TEXT(,<^M^J[Connection closed. Returning to local KERMIT]>)    ;
  1840.     $RETT                ;
  1841.  
  1842. CN.TYP:    $CALL    CN.PAR            ;[125] Tack on even parity bit if needed
  1843.     XMOVEI    S2,MYTERM        ; Point to the terminal block
  1844.     $CALL    T$CCOT            ; Output the character
  1845.     $RETT                ; and return
  1846.  
  1847. ;[125] Here to put even parity on a character.
  1848.  
  1849. CN.PAR:    MOVE    S2,PARITY%TYPE##    ;[125] Get the parity type
  1850.     CAIN    S2,PR%NONE##        ;[125] No parity?
  1851.      $RET                ;[125] Yes, leave it alone
  1852.     ANDI    S1,177            ;[125] Keep only 7 bits
  1853.     MOVEI    S2,(S1)            ;[125] Get a copy
  1854.     LSH    S2,-4            ;[125] Shift back 4 bits
  1855.     XORI    S2,(S1)            ;[125] Combine halves
  1856.     TRCE    S2,14            ;[125] Left bits both 0
  1857.      TRNN    S2,14            ;[125] Or both 1?
  1858.       XORI    S1,200            ;[125] Yes, change high bit
  1859.     TRCE    S2,3            ;[125] Right bits both zero
  1860.      TRNN    S2,3            ;[125] Or both one?
  1861.       XORI    S1,200            ;[125] Yes, change high bit
  1862.     $RET                ;[125] All done
  1863.     SUBTTL    Command execution -- DEFINE command
  1864.  
  1865. ;[107]
  1866. ;[107] This command allows definition (and deletion) of macros which
  1867. ;[107]consist of options setable by the SET command.
  1868. ;[107]
  1869. ;[107] The table is a standard TBLUK table.  The value stored in the
  1870. ;[107]right halfword will be the address of the macro block.  Each macro block
  1871. ;[107]has the following format:
  1872. ;[107]
  1873. ;[107]    XWD    block address,SETMAC    ;[111] So SET dispatch works
  1874. ;[107]    XWD    offset to macro text,length of block in words
  1875. ;[107]    ASCIZ    /macro name/
  1876. ;[107]    ASCIZ    /macro text/
  1877. ;[107]
  1878. ;[107] These blocks are allocated using M%GMEM.
  1879.  
  1880. C$DEFINE:
  1881.     $CALL    P$KEYW            ;[107] Get a keyword
  1882.     JUMPF    DEFI.1            ;[107] If not a keyword, go get new definition
  1883.  
  1884. ;[107] Here if we got a macro to delete.  We must remove the keyword from
  1885. ;[107]the table and delete the text storage.  The storage is the keyword
  1886. ;[107]value. First we must find the correct entry in the table.
  1887.  
  1888.     MOVE    P1,S1            ;[107] Copy macro block address
  1889.     HRROI    S2,$MBNAM(P1)        ;[107] Point at macro name
  1890.     MOVEI    S1,DFNTAB        ;[107] And point to table
  1891.     $CALL    S%TBLK            ;[107] Lookup in table
  1892.     TXNN    S2,TL%EXM        ;[107] Must be exact match (we put it there)
  1893.      JRST    [$KERR    (<Macro table inconsistent>)    ;[107] Give up
  1894.         $RETF]            ;[107] Since table is screwed up
  1895.     MOVE    S2,S1            ;[107] Get address of entry
  1896.     MOVEI    S1,DFNTAB        ;[107] Point at table
  1897.     $CALL    S%TBDL            ;[107] Delete the entry
  1898.      JUMPF    [$KERR    (<Macro table inconsistent>)    ;[107] Couldn't?
  1899.         $RETF]            ;[107] Then punt
  1900.     MOVE    S2,P1            ;[107] Get the macro block address
  1901.     LOAD    S1,$MBLEN(S2),MB$LEN    ;[107] Get the length
  1902.     $CALL    M%RMEM            ;[107] Return the block
  1903.     $RETT                ;[107] And return
  1904.  
  1905. ;[107] Here to define a new macro
  1906.  
  1907. DEFI.1:    $CALL    P$FLD            ;[107] Must be a field here if not keyword
  1908.     $RETIF                ;[107] Give up if not (should really be here)
  1909.     MOVE    T2,S2            ;[107] Save the length (+1)
  1910.     MOVEI    T1,PFD.D1(S1)        ;[107] Point at the data
  1911.     MOVE    S1,PRTARG+1        ;[107] Get the address of returned arguments
  1912.     MOVE    S1,PRT.CM(S1)        ;[107] Get the address of the command message
  1913.     ADD    S1,COM.CM(S1)        ;[107] And get offset to command string
  1914.     MOVEI    T3,PFD.D1(S1)        ;[107] Save the pointer
  1915.     LOAD    S1,PFD.HD(S2),PF.LEN    ;[107] Get the length of the text (+1)
  1916.     ADDI    S1,$MBNAM-2(T1)        ;[107] Get the length of the block we need
  1917.     $CALL    M%GMEM            ;[107] Get a block
  1918.     STORE    S1,$MBLEN(S2),MB$LEN    ;[107] Store the block length
  1919.     MOVEI    S1,SETMAC        ;[107] Get the address of the action routine
  1920.     HRLI    S1,(S2)            ;[107] Also save pointer to the block
  1921.     MOVEM    S1,$MBRTN(S2)        ;[107] Store it
  1922.     ADDI    T2,$MBNAM-1        ;[107] Get offset to text
  1923.     STORE    T2,$MBOFS(S2),MB$OFS    ;[107] Store the offset
  1924.     $TEXT    (<-1,,$MBNAM(S2)>,<^T/(T1)/^0^A>) ;[107] Move the name text
  1925.     ADDI    T2,(S2)            ;[107] Point at macro expansion storage
  1926.     $TEXT    (<-1,,(T2)>,<^T/(T3)/^0>) ;[107] Store the string
  1927.  
  1928. ;[107] Now insert the table entry
  1929.  
  1930.     MOVEI    S1,DFNTAB        ;[107] Point at the table header
  1931.     HRLI    S2,$MBNAM(S2)        ;[107] Get the entry value
  1932.     MOVE    T1,S2            ;[107] Save copy just in case
  1933.     $CALL    S%TBAD            ;[107] Put it in
  1934.     $RETIT                ;[107] If it went in ok, all done
  1935.     $KERR    (<Cannot define macro ^T/$MBNAM(T1)/>) ;[107] Couldn't do it?
  1936.     HRRZ    S2,T1            ;[107] Point at macro block
  1937.     LOAD    S1,$MBLEN(T1),MB$LEN    ;[107] Get the length
  1938.     $CALL    M%RMEM            ;[107] Return it
  1939.     $RETF                ;[107] And return
  1940.  
  1941.  
  1942. ;[107] Macro expansion routine
  1943. ;[107]This routine is called from the SET command processor when it is
  1944. ;[107]given a macro name.  We must now parse the text of the macro
  1945. ;[107]expansion.
  1946. ;[107] We enter with the macro block address in P1
  1947.  
  1948. SETMAC:    STKVAR    <<MPRDAT,PAR.SZ>>    ;[107] Allocate the space for the args to parser
  1949.     MOVEI    S1,SMC000        ;[107] Get address of initial macro expansion PDB
  1950.     MOVEM    S1,PAR.TB+MPRDAT    ;[107] Store it
  1951.     MOVEI    S1,[ASCIZ ||]        ;[107] No prompt
  1952.     MOVEM    S1,PAR.PM+MPRDAT    ;[107]  .  .  .
  1953.     SETZM    PAR.CM+MPRDAT        ;[107] Let OPRPAR get a page
  1954.     LOAD    S1,$MBOFS(P1),MB$OFS    ;[107] Get offset to expansion of macro
  1955.     ADDI    S1,(P1)            ;[107] Point at the text
  1956.     MOVEM    S1,PAR.SR+MPRDAT    ;[107] Store the pointer
  1957.     MOVEI    S1,PAR.SZ        ;[107] Get the size of the block
  1958.     MOVEI    S2,MPRDAT        ;[107] And the address
  1959.     $CALL    PARSER            ;[107] And parse the expansion
  1960.     JUMPF    [$KERR    (<Error parsing macro expansion - Internal table conflict>)
  1961.         $RETF]            ;[107] Should never get an error, we did this once
  1962.     MOVE    S1,PRT.CM(S2)        ;[107] Get address of data
  1963.     MOVEM    S1,PAR.CM+MPRDAT    ;[107] Save the page so we know what to return
  1964.     ADDI    S1,COM.SZ        ;[107] Point at first word
  1965.     $CALL    P$SETU            ;[107] Set up for P$xxx routines
  1966.  
  1967.     $CALL    P$KEYW            ;[107] First field is a keyword
  1968.     $CALL    P$KEYW            ;[107] And another
  1969.     $CALL    C$SET            ;[107] Can now process set options
  1970.     MOVE    S1,PAR.CM+MPRDAT    ;[107] Get the address of the data page back
  1971.     $CALL    M%RPAG            ;[107] Return it
  1972.     $RETT                ;[107] And return
  1973.     SUBTTL    Command execution -- EXIT command
  1974.  
  1975. C$EXIT:    $CALL    P$CFM            ; Make sure we have a confirm
  1976.     $RETIF                ; Return if we don't
  1977.  
  1978. ; Here on a control-Z
  1979.  
  1980. C$EXI0:    SKIPN    LOGDIN            ;[125] Are we logged in?
  1981.      JRST    [$TEXT    (,<.KJOB^M^J.^A>)    ;[125] No, make a nice message
  1982.         LOGOUT    1,            ;[125] And quit
  1983.         JRST    .+1]            ;[125] Shouldn't really get here, but...
  1984.     $HALT                ; Exit to the monitor
  1985.     $RETT                ; Allow continues
  1986.     SUBTTL    Command execution -- BYE command
  1987.  
  1988. ;+
  1989. ;.hl1 C$BYE
  1990. ;This routine will process the BYE command.  It will cause the remote
  1991. ;server to exit and then will cause the local Kermit to exit.
  1992. ;.literal
  1993. ;
  1994. ; Usage:
  1995. ;    $CALL    C$BYE
  1996. ;    (Return)
  1997. ;
  1998. ;.end literal
  1999. ;-
  2000.  
  2001. C$BYE:    $CALL    C$LOGOUT        ; Cause the remote to go away
  2002.     $RETIF                ; Return if that failed
  2003.     SETOM    XITFLG            ; Flag we must exit
  2004.     $RETT                ; Give a good return
  2005.     SUBTTL    Command execution -- FINISH command
  2006.  
  2007. ;+
  2008. ;.hl1 C$FINISH
  2009. ;This routine will cause the remote server to exit to its operating system.
  2010. ;.literal
  2011. ;
  2012. ; Usage:
  2013. ;    $CALL    C$FINISH
  2014. ;    (Return)
  2015. ;
  2016. ;.end literal
  2017. ;-
  2018.  
  2019. C$FINISH:
  2020.     $CALL    T$LOCAL            ; Is this my terminal?
  2021.     JUMPT    [$KERR(<Must use SET LINE first>)
  2022.         $RETF]            ; And return
  2023.     $CALL    OPNTRM            ; Open the terminal
  2024.     $RETIF                ; Just return if this fails
  2025.     $CALL    CLRGEN            ; Clear generic arguments
  2026.     BLSCAL    (DO%GENERIC##,<[EXP GC%EXIT##]>)
  2027.     $CALL    CLSTRM            ; Close the terminal
  2028.     $RETT                ; Give a good return
  2029.  
  2030. ; Subroutine to clear generic arguments
  2031.  
  2032. CLRGEN:    SETZM    GEN%1SIZE##        ; No first argument
  2033.     SETZM    GEN%2SIZE##        ; Nor second
  2034.     SETZM    GEN%3SIZE##        ; Or third
  2035.     MOVEI    S1,<MAX%MSG##+4>/5    ; Get length of arguments
  2036.     MOVEI    S2,GEN%1DATA##        ; First buffer address
  2037.     $CALL    .ZCHNK            ; Clear it
  2038.     MOVEI    S1,<MAX%MSG##+4>/5    ; Get length of arguments
  2039.     MOVEI    S2,GEN%2DATA##        ; First buffer address
  2040.     $CALL    .ZCHNK            ; Clear it
  2041.     MOVEI    S1,<MAX%MSG##+4>/5    ; Get length of arguments
  2042.     MOVEI    S2,GEN%3DATA##        ; First buffer address
  2043.     $CALL    .ZCHNK            ; Clear it
  2044.     $RETT                ; Return
  2045.     SUBTTL    Command execution -- LOG command
  2046.  
  2047. ;+
  2048. ;.hl1 C$LOG
  2049. ; This routine will store the file specification for various log files.
  2050. ;-
  2051.  
  2052. C$LOG:    $CALL    P$KEYW            ; Next item should be a keyword
  2053.     MOVE    P1,S1            ; Save the address of the storage
  2054.     $CALL    P$OFIL            ; Now we want an output file spec
  2055.     JUMPT    LOG.1            ; If we got one, go store it
  2056.  
  2057. ; Here for LOG keyword <CRLF>.  This means we no longer want the
  2058. ;specified log file.
  2059.  
  2060.     SETZM    $LGFLG(P1)        ; Clear flags to indicate no file
  2061.     $RETT                ; And return
  2062.  
  2063. ; Here with S1 pointing at FD returned from P$OFIL.  Copy the FD to
  2064. ;the correct storage.
  2065.  
  2066. LOG.1:    ADDI    S2,$LGFD(P1)        ; Point at end of FD
  2067.     HRLI    S1,(S1)            ; Set up pointer to move FD
  2068.     HRRI    S1,$LGFD(P1)        ;  .  .  .
  2069.     BLT    S1,-1(S2)        ; Copy it
  2070.  
  2071.     $CALL    P$SWITCH        ; Get a switch
  2072.     SKIPT                ; Get something?
  2073.      SETZ    S1,            ; No, get a zero
  2074.     TXO    S1,LG$SET        ; Flag we have the file spec
  2075.     MOVEM    S1,$LGFLG(P1)        ; Store the flags
  2076.     $RETT                ; And return
  2077.  
  2078.     SUBTTL    Command execution -- LOGOUT command
  2079.  
  2080. ;+
  2081. ;.hl1 C$LOGOUT
  2082. ;This routine will cause the remote server to LOGOUT of the remote system.
  2083. ;.literal
  2084. ;
  2085. ; Usage:
  2086. ;    $CALL    C$LOGOUT
  2087. ;    (RETURN)
  2088. ;
  2089. ;.END LITERAL
  2090. ;-
  2091.  
  2092. C$LOGOUT:
  2093.     $CALL    T$LOCAL            ; Is this my terminal?
  2094.     JUMPT    [$KERR(<Must use SET LINE first>)
  2095.         $RETF]
  2096.     $CALL    OPNTRM            ; Open the terminal
  2097.     $RETIF                ; Just return if this fails
  2098.     $CALL    CLRGEN            ; Clear the generic args
  2099.     BLSCAL    (DO%GENERIC##,<[EXP GC%LOGOUT##]>)
  2100.     $CALL    CLSTRM            ; Close the terminal
  2101.     $RETT                ; Give a good return
  2102.     SUBTTL    Command execution -- HELP command
  2103.  
  2104. ;+
  2105. ;.hl1 C$HELP
  2106. ;This routine will process the HELP command.  It will call the OPRPAR routine
  2107. ;to do the actual processing of the HELP command.
  2108. ;.literal
  2109. ;
  2110. ; Usage:
  2111. ;    $CALL    C$HELP
  2112. ;    (Return)
  2113. ;
  2114. ;.end literal
  2115. ;-
  2116.  
  2117. C$HELP:    $CALL    P$CFM            ; Confirm?
  2118.     JUMPT    HELP.0            ; Yes, Skip this then
  2119.     $CALL    P$TEXT            ; Parse the text
  2120.     ADD    S1,[POINT 7,PFD.D1]    ; Point to the data
  2121.     JRST    HELP.1            ; Continue on
  2122.  
  2123. HELP.0:    MOVE    S1,[POINT 7,[BYTE (7).CHNUL,.CHNUL]] ; Null string
  2124.  
  2125. HELP.1:    MOVEI    S2,HLPFD        ; Point to the FD to use
  2126.     EXCH    S1,S2            ; Put into the right registers
  2127.     $CALL    P$HELP##        ; Call the help processor
  2128.     $RETT                ; Give a good return
  2129.     SUBTTL    Command execution -- PROMPT command
  2130.  
  2131. ;+
  2132. ;.HL1 PROMPT
  2133. ;This routine will just cause KERMIT-10 to prompt the user again.
  2134. ;It is used when the user needs to get to the KERMIT-10> prompt when
  2135. ;KERMIT is run from the monitor KERMIT command.
  2136. ;.LITERAL
  2137. ;
  2138. ; Usage:
  2139. ;    $CALL    C$PROMPT
  2140. ;    (Return)
  2141. ;
  2142. ;.end literal
  2143. ;-
  2144.  
  2145. C$PROMPT:
  2146.     $CALL    P$CFM            ; See if there is a confirm
  2147.     $RETIF                ; Just return if false
  2148.     SETZM    CCLOFS            ; Clear the CCL offset
  2149.     SETZM    XITFLG            ; Don't exit now
  2150.     $CALL    SHOVER            ; Show the version (ala KERMIT-20)
  2151.     $RETT                ; Give a good return
  2152.     SUBTTL    Command execution -- REMOTE command
  2153.  
  2154. ;+
  2155. ;.HL1 C$REMOTE
  2156. ;This routine will parse the REMOTE command.  It will set up the
  2157. ;correct arguments and call KERMSG to handle the generic command.
  2158. ;-
  2159.  
  2160. C$REMOTE:
  2161.     $CALL    T$LOCAL            ; Is this my terminal?
  2162.     JUMPT    [$KERR(<Must use SET LINE first>)
  2163.         $RETF]            ; And return
  2164.     $CALL    CLRGEN            ; Clear the generic args
  2165.     $CALL    P$KEYW            ; Get a keyword
  2166.     $RETIF                ; Should really be there
  2167.     MOVE    P1,(S1)            ; Get the command type (arg for DO_GENERIC)
  2168.     $CALL    P$TEXT            ; Get some text
  2169.     JUMPF    REMO.2            ; If none, go do the command
  2170.  
  2171.     ADD    S1,[POINT 7,PFD.D1]    ; Point at the data
  2172.     MOVE    S2,[POINT 7,GEN%1DATA##] ; Point at where to store it
  2173.  
  2174. REMO.1:    ILDB    T1,S1            ; Get a character
  2175.     IDPB    T1,S2            ; Store it
  2176.     AOS    GEN%1SIZE##        ; Count it
  2177.     JUMPN    T1,REMO.1        ; And copy all the characters
  2178.     SOS    GEN%1SIZE##        ; Don't count the null
  2179.  
  2180. ; If more arguments are needed, get them
  2181.  
  2182.     HLRZ    S1,P1            ; Get routine address
  2183.     JUMPE    S1,REMO.2        ; Any routine to call?
  2184.     SKIPE    GEN%1SIZE        ; If no first arg, don't need rest
  2185.      $CALL    (S1)            ; Yes, do it
  2186.  
  2187. ; Here to request KERMSG to perform the command.
  2188.  
  2189. REMO.2:    $CALL    OPNTRM            ; Open the terminal
  2190.     $RETIF                ; Just return if this fails
  2191.     TXZ    P1,LHMASK        ; Clear any left half data
  2192.     BLSCAL    (DO%GENERIC##,<P1>)
  2193.     $CALL    CLSTRM            ; Close the terminal
  2194.     $RETT                ; Give a good return
  2195.  
  2196. ; Subroutines to get arguments.
  2197. ; Get login information
  2198.  
  2199. GETLGN:    MOVEI    S1,[ITEXT(<Account: >)] ; Get the prompt, echo input
  2200.     MOVE    S2,[XWD MAX%MSG##,GEN%3DATA##] ; Point at storage
  2201.     $CALL    GETANS            ; Get the result
  2202.     MOVEM    S1,GEN%3SIZE##        ; Store size
  2203. ;    PJRST    GETPSW            ; And get password
  2204.  
  2205. ; Get a password.  This is done with no echo.  The password is put in
  2206. ; GEN%2DATA.
  2207. ; Get message for short send
  2208.  
  2209. GETPSW:    SKIPA    S1,[XWD -1,[ITEXT(<Password: >)]] ; Point at the prompt, no echo
  2210. GETMSG:     MOVEI    S1,[ITEXT(<Message: >)]    ; Get the prompt
  2211. GET2GN:    MOVE    S2,[XWD MAX%MSG##,GEN%2DATA##] ; Point at buffer
  2212.     $CALL    GETANS            ; Get the result
  2213.     MOVEM    S1,GEN%2SIZE##        ; Store size we got
  2214.     $RETT                ; And return
  2215.  
  2216. ; Get a new file specification
  2217. ; Get options for "finger"
  2218.  
  2219. GETNFL:    SKIPA    S1,[XWD 0,[ITEXT(<New file name: >)]] ; Get the prompt
  2220. GETOPT:     MOVEI    S1,[ITEXT(<Options: >)]    ; Get the prompt for options
  2221.     JRST    GET2GN            ; Go get the second argument
  2222.     SUBTTL    Command execution -- LOCAL command
  2223.  
  2224. ;+
  2225. ;.HL1 C$LOCAL
  2226. ;This routine will parse the LOCAL command.  It will set up the
  2227. ;correct arguments and call SY%GENERIC to generate the text.
  2228. ;The resulting text will then be typed on the terminal.
  2229. ;-
  2230.  
  2231. C$LOCAL:
  2232.     $CALL    CLRGEN            ; Clear the generic args
  2233.     $CALL    P$KEYW            ; Get a keyword
  2234.     $RETIF                ; Should really be there
  2235.     MOVE    P1,(S1)            ; Get the command type (arg for DO_GENERIC)
  2236.     $CALL    P$TEXT            ; Get some text
  2237.     JUMPF    LOCA.2            ; If none, go do the command
  2238.  
  2239.     ADD    S1,[POINT 7,PFD.D1]    ; Point at the data
  2240.     MOVE    S2,[POINT 7,GEN%1DATA##] ; Point at where to store it
  2241.  
  2242. LOCA.1:    ILDB    T1,S1            ; Get a character
  2243.     IDPB    T1,S2            ; Store it
  2244.     AOS    GEN%1SIZE##        ; Count it
  2245.     JUMPN    T1,LOCA.1        ; And copy all the characters
  2246.     SOS    GEN%1SIZE##        ; Don't count the null
  2247.  
  2248. LOCA.2:    SETZM    LCLSIZ            ; Make sure these are clear now
  2249.     SETZM    LCLRTN            ;  .  .  .
  2250.  
  2251.     BLSCAL    SY%GENERIC##,<P1,[EXP LCLSTR],[EXP LCLSIZ],[EXP LCLRTN]> ; Generate result
  2252.     CAXN    S1,RMS32        ; File processing error?
  2253.      $RETF                ; Yes, just give up, error already typed
  2254.     TXNN    S1,BLSTRU        ; Good result?
  2255.      JRST    [$KERR(Unimplemented local command)
  2256.         $RETF]            ; Punt
  2257.     SKIPN    LCLSIZ            ; Have a string result?
  2258.      JRST    LOCA.3            ; No, check for routine
  2259.     $TEXT    (,<^T/@LCLSTR/>)    ; Yes, type it
  2260.     $RETT                ; And return
  2261.  
  2262. ; Here if we did not get a string result.  Check if we have a routine
  2263. ;to call for each character.
  2264.  
  2265. LOCA.3:    SKIPE    LCLRTN            ; Have one?
  2266.      JRST    LOCA.4            ; Yes, go handle it
  2267.  
  2268. ; Here if we have a file to type.  The file spec is in FILE%NAME, all
  2269. ;set up for FILE%OPEN to open it up.  Just open it and then type
  2270. ;the file.
  2271.  
  2272.     $SAVE    <TY%FIL##>        ; Save type files flag
  2273.     SETZB    S1,TY%FIL##        ; Want to read the file
  2274.     BLSCAL    FILE%OPEN,<S1>
  2275.     TXNN    S1,BLSTRU        ; Error?
  2276.      $RETF                ; Yes, should have been typed already
  2277.  
  2278.     MOVEI    S1,GET%FILE        ; Now use get file to fetch chars
  2279.     TXO    S1,1B0            ; Remember file is open
  2280.     MOVEM    S1,LCLRTN        ; Save the address
  2281.  
  2282. ; Here to fetch characters and type them
  2283.  
  2284. LOCA.4:    BLSCAL    @LCLRTN,<[EXP LCLCHR]>    ; Get a character
  2285.     TXNE    S1,BLSTRU        ; Error?
  2286.      CAIN    S1,EOF            ; End of file?
  2287.       JRST    LOCA.5            ; Yes, assume EOF
  2288.     OUTCHR    LCLCHR            ; Type it
  2289.     JRST    LOCA.4            ; Keep looping until eof
  2290.  
  2291. ; Here when all has been typed, close file (if necessary), and return
  2292.  
  2293. LOCA.5:    SKIPL    LCLRTN            ; Need to close a file?
  2294.      $RETT                ; No, all done
  2295.     BLSCAL    FILE%CLOSE,<[EXP 0]>    ; Close the file
  2296.     $RETT                ; And return
  2297.     SUBTTL    Command execution -- SEND command
  2298.  
  2299. ;+
  2300. ;.HL1 C$SEND
  2301. ;This routine will parse the SEND command for KERMIT-10.  It will call
  2302. ;the lower level routines with the ASCIZ of the file specification.
  2303. ;-
  2304.  
  2305. C$SEND:
  2306.     $CALL    P$QSTR            ; Parse the argument
  2307.      SKIPT                ; Ok?
  2308.       $CALL    P$FLD            ; Parse a field
  2309.     $RETIF                ; Return if that failed
  2310.  
  2311.     ADD    S1,[POINT 7,PFD.D1]    ; Point to the data
  2312.     MOVE    T1,[POINT 7,FILE%NAME##] ; Point to the information
  2313.     IMULX    S2,5            ; Determine the number of characters
  2314.     SUBX    S2,PFD.D1*5        ; Remove the size of the header
  2315.     SETZM    FILE%SIZE##        ; Clear the character count
  2316.  
  2317. SEND.0:    SOJL    S2,SEND.1        ; Finished?
  2318.     ILDB    T2,S1            ; Get a byte
  2319.     IDPB    T2,T1            ; Store it
  2320.     JUMPE    T2,SEND.2        ; Null byte finally
  2321.     AOS    FILE%SIZE##        ; Increment the count of the characters
  2322.     JRST    SEND.0            ; Loop for all characters
  2323.  
  2324. SEND.1:    SETZ    T2,            ; Clear this
  2325.     IDPB    T2,T1            ; End of file specification
  2326.  
  2327. ; Now that the file specification is copied to the KERMSG area we can now
  2328. ; attempt to transfer the file
  2329.  
  2330. SEND.2:    $CALL    OPNTRM            ; Open the terminal
  2331.     $RETIF                ; Return if that failed
  2332.  
  2333.     $CALL    SEND%SWITCH##        ; Send the file specification
  2334.  
  2335.     $CALL    CLSTRM            ; Close the terminal
  2336.     $RETT                ; Return to the caller
  2337.     SUBTTL    Command execution -- GET command
  2338.  
  2339. ;+
  2340. ;.hl1 C$GET
  2341. ;this routine will get a file(s) from the remote Kermit.  It will
  2342. ;use the RECEIVE routine for most of the work.
  2343. ;.literal
  2344. ;
  2345. ; Usage:
  2346. ;    $CALL    C$GET
  2347. ;    (Return)
  2348. ;
  2349. ;.end literal
  2350. ;-
  2351.  
  2352. C$GET:
  2353.     SETZM    USRFIL            ; No user supplied name
  2354.     $CALL    T$LOCAL            ; Is this my terminal?
  2355.     JUMPT    [$KERR(<Must use SET LINE first>)
  2356.         $RETF]
  2357.     $CALL    P$QSTR            ; Parse the argument
  2358.      SKIPT                ; Ok?
  2359.       $CALL    P$FLD            ; Parse a field
  2360.     $RETIF                ; Return if that failed
  2361.  
  2362.     ADD    S1,[POINT 7,PFD.D1]    ; Point to the data
  2363.     MOVE    T1,[POINT 7,FILE%NAME##] ; Point to the information
  2364.     IMULX    S2,5            ; Determine the number of characters
  2365.     SUBX    S2,PFD.D1*5        ; Remove the size of the header
  2366.     SETZM    FILE%SIZE##        ; Clear the character count
  2367.  
  2368. GET.0:    SOJL    S2,GET.1        ; Finished?
  2369.     ILDB    T2,S1            ; Get a byte
  2370.     IDPB    T2,T1            ; Store it
  2371.     JUMPE    T2,GET.2        ; Null byte finally
  2372.     AOS    FILE%SIZE##        ; Increment the count of the characters
  2373.     JRST    GET.0            ; Loop for all characters
  2374.  
  2375. GET.1:    SETZ    T2,            ; Clear this
  2376.     IDPB    T2,T1            ; End of file specification
  2377.  
  2378. GET.2:    JRST    RECE.1            ; Get the files
  2379.     SUBTTL    Command execution -- RECEIVE command
  2380.  
  2381. ;+
  2382. ;.HL1 C$RECEIVE
  2383. ;This routine will copy the unquoted string that is the file specification
  2384. ;to the FILE%NAME data area in KERMSG and the length of the string into
  2385. ;FILE%SIZE.
  2386. ; After that is done the terminal will be opened and the SEND%SWITCH
  2387. ;BLISS routine called.
  2388. ;-
  2389.  
  2390. C$RECEIVE:
  2391.     SETZM    FILE%SIZE##        ; Flag we will accept whatever we get
  2392.     SETZM    USRFIL            ; Flag user didn't supply specification
  2393.     $CALL    P$OFIL            ; Have an output file specification?
  2394.     JUMPF    RECE.0            ; No, skip this
  2395.     SETOM    USRFIL            ; User supplied output specification
  2396.     HRL    S1,S1            ; Get set to move it
  2397.     HRRI    S1,USRFX        ; Point to the user block
  2398.     ADDI    S2,USRFX        ; Point to the end
  2399.     BLT    S1,-1(S2)        ; Move all of the file specification
  2400.     SETOM    USRFX+.FDNMM        ; Flag not wild
  2401. ;[126];@C$RECEIVE + 9
  2402.     HRROS    USRFX+.FDEXM        ;[126] . . .
  2403.     SETOM    USRFX+.FDDIM        ; . . .
  2404.     MOVE    S1,[XWD USRFX+.FDDIM,USRFX+.FDSFM] ; Fill all of the path
  2405.     BLT    S1,USRFX+.FDSFM+4    ; All SFDs
  2406.     $CALL    P$CFM            ; Parse the confirm
  2407.     $RETIF                ; Return if that fails
  2408.     JRST    RECE.1            ; Continue processing
  2409.  
  2410. RECE.0:    $CALL    P$CFM            ; Parse the confirm
  2411.     $RETIF                ; Return if that fails
  2412.     SETZM    FILE%SIZE##        ; No file specification
  2413.  
  2414. RECE.1:    $CALL    OPNTRM            ; Open the terminal
  2415.     $RETIF                ; Return if that fails
  2416.     $CALL    REC%SWITCH##        ; Call the BLISS routine
  2417.     $CALL    CLSTRM            ; Close the terminal
  2418.     $RETT                ; Return to the caller
  2419.  
  2420. FILSTO:    IDPB    S1,FILPTR        ; Store the byte
  2421.     AOS    FILE%SIZE##        ; Increment the number of characters
  2422.     $RETT                ; Return to the caller
  2423.     SUBTTL    Command execution -- SERVER command
  2424.  
  2425. ;+
  2426. ;.hl1 SERVER
  2427. ;This command will cause KERMIT to go into SERVER mode as desribed in
  2428. ;the protocol manual version 2 or later.
  2429. ;-
  2430.  
  2431. SRVTXT:    ASCIZ    |
  2432. [Kermit Server running  on  the  DEC  Host.   Please  type  your  escape
  2433. sequence   to  return  to  your  local  machine.  Shut down the server by
  2434. typing the Kermit BYE command on your local machine.]
  2435. |                    ;[127]
  2436.  
  2437. C$SERVER:
  2438.     $CALL    P$CFM            ; Have a confirm?
  2439.     $RETIF                ; Just return if not
  2440.     $TEXT    (,<^T/SRVTXT/>)        ; Output the text
  2441.  
  2442.     $CALL    OPNTRM            ; Open the user terminal
  2443.     $RETIF                ; Return if it failed
  2444.  
  2445.     $CALL    SERVER##        ; Call the server processor
  2446.     MOVE    P1,S1            ; Copy the value returned
  2447.     $CALL    CLSTRM            ; Close the terminal
  2448.  
  2449.     CAXE    P1,ABORTED        ; Was the transfer aborted (Ctl-C)?
  2450.      SETOM    XITFLG            ; No, flag we must exit
  2451.     $RETT                ; Give a good return
  2452.     SUBTTL    Command execution -- SET command -- Top level
  2453.  
  2454. ;+
  2455. ;.hl1 C$SET
  2456. ;This routine will handle the SET command.  It will determine which of
  2457. ;the keywords was typed and then dispatch to the correct routine to process
  2458. ;the command.
  2459. ;-
  2460.  
  2461. C$SET:    $CALL    P$KEYW            ; Parse a keyword
  2462.     $RETIF                ; Return if that fails
  2463.     MOVE    S1,(S1)            ; Get the information supplied
  2464.     HLRZ    P1,S1            ; Get the extra data
  2465.     CAIN    S1,SETMAC        ;[107] Macro setting is special
  2466.      PJRST    (S1)            ;[107] We just go there
  2467.     $CALL    (S1)            ; Call the correct routine
  2468.     $CALL    P$COMMA            ;[107] Check for a comma
  2469.     JUMPT    C$SET            ;[107] If we get one, we have another keyword
  2470.     $RETT                ;[107] Return to the top level
  2471.  
  2472.  
  2473.     SUBTTL    Command execution -- SET command -- SETKYW - Parse a keyword and store the value
  2474.  
  2475. ;+
  2476. ;.HL2 SETKYW
  2477. ;This routine is used for the various SET commands that take only a keyword.
  2478. ;It will then store the information into the address pointed to by P1.
  2479. ;-
  2480.  
  2481. SETKYW:    $CALL    P$KEYW            ; Get the keyword supplied
  2482.     $RETIF                ; Return if there is no keyword
  2483.     MOVEM    S1,(P1)            ; Store the information
  2484.     $RETT                ; Give a good return
  2485.  
  2486.  
  2487.     SUBTTL    Command execution -- SET command -- SETNUM - Parse a number
  2488.  
  2489. ;+
  2490. ;.HL2 SETNUM
  2491. ;This routine is used for the various SET commands that take only a
  2492. ;numeric value.
  2493. ;It will then store the information into the address pointed to by P1.
  2494. ;-
  2495.  
  2496. SETNUM:    $CALL    P$NUM            ; Get the number supplied
  2497.     $RETIF                ; Return if there is no number
  2498.     MOVEM    S1,(P1)            ; Store the information
  2499.     $RETT                ; Give a good return
  2500.     SUBTTL    Command execution -- SET command -- DEBUGGING parameter
  2501.  
  2502. ;+
  2503. ;.HL2 SETDBG
  2504. ; This routine will handle the SET DEBUG command.  This command allows
  2505. ;debugging typeout to be turned on or off, and also allows a log file
  2506. ;of debugging info to be created.
  2507. ; It will determine which format of the command was given, and either
  2508. ;store the ON/OFF value or open/close the log file.
  2509. ;-
  2510.  
  2511. SETDBG:    $CALL    P$KEYW            ; Get the keyword
  2512.     HLRZ    S2,(S1)            ; Get the routine to call
  2513.     HRRZ    S1,(S1)            ; And a possible value
  2514.     JRST    (S2)            ; Go handle type of keyword
  2515.  
  2516. ; Here for SET DEBUGGING ON/OFF
  2517.  
  2518. SETDBF:    MOVEM    S1,DEBUG%FLAG##        ; Store the flag value
  2519.     $RETT                ; And return
  2520.  
  2521. ; Here for SET DEBUGGING LOG-FILE filename
  2522.  
  2523. SETODF:    $CALL    P$OFIL            ; Get an output file FD
  2524.     HRLI    S1,(S1)            ; Set up pointer to copy file
  2525.     HRRI    S1,DBGLOG+$LGFD        ; Point at destination
  2526.     ADDI    S2,DBGLOG+$LGFD        ; And final word
  2527.     BLT    S1,-1(S2)        ; Copy block
  2528.     MOVX    S1,LG$SET!LG$APP    ; Get the flags
  2529.     MOVEM    S1,DBGLOG+$LGFLG    ; Save them
  2530.     MOVX    S1,BLSTRU        ; Get a true
  2531.     MOVEM    S1,DEBUG%FLAG##        ; Save it so debugging runs
  2532.     $RETT                ; And return
  2533.  
  2534. ; Here for SET DEBUGGING NO-LOG-FILE.
  2535.  
  2536. SETCDF:    MOVX    S1,BLSFAL        ; Flag it as false
  2537.     MOVEM    S1,DEBUG%FLAG##        ; Store it
  2538.     SETZM    DBGLOG+$LGFLG        ; No log file anymore
  2539.     $RETT                ; And return
  2540. ;+
  2541. ;.HL2 SETESC
  2542. ;This routine will set the escape character.  It will check to determine if the
  2543. ;escape character is valid.
  2544. ;-
  2545.  
  2546. SETESC:    $CALL    P$NUM            ; get the number
  2547.     JUMPF    SETES0            ; Failed, issue an error
  2548.     JUMPLE    S1,SETES0        ; Issue an error
  2549.     CAIL    S1," "            ; Must be a control character
  2550.      JRST    SETES0            ; Failed
  2551.     MOVEM    S1,ESCAPE        ; Store the character
  2552.     ADDI    S1,"A"-.CHCNA        ; Convert to printing equivalent
  2553.     $TEXT    (<-1,,ESCTXT>,<^^^7/S1/^0>) ; Store the text
  2554.     $RETT
  2555.  
  2556. SETES0:    $KERR    (Illegal escape character ^O/S1/)
  2557.     $RETF                ; Failure return
  2558.  
  2559.  
  2560.     SUBTTL    Command execution -- SET command -- FILE parameters
  2561.  
  2562. ;+
  2563. ; This will handle the dispatch of the SET FILE command.
  2564. ;-
  2565.  
  2566. SETFIL:    $CALL    P$KEYW            ; Parse a keyword
  2567.     $RETIF                ; Return if that fails
  2568.     MOVE    S1,(S1)            ; Get the information supplied
  2569.     HLRZ    P1,S1            ; Get the extra data
  2570.     $CALL    (S1)            ; Call the correct routine
  2571.     $RET                ; And return
  2572.  
  2573.  
  2574.     SUBTTL    Command execution -- SET command -- HANDSHAKE
  2575.  
  2576. ;+
  2577. ;[131] This routine will set up the IBM handshaking character
  2578. ;-
  2579.  
  2580. SETHSK:    $CALL    P$NUM            ;[131] Get the number
  2581.     CAIN    S1,""            ;[131] Is it a NULL
  2582.      JRST    SETHS0            ;[131] Yes, set default value
  2583.     CAIG    S1,""            ;[131] Is it a negative number
  2584.      JRST    SETHS1            ;[131] Yes, give error
  2585.     MOVEM    S1,IBM%CHAR##        ;[131] Move in Handshake character
  2586.     $RETT                ;[131] True return
  2587.  
  2588. SETHS0:    SETOM    IBM%CHAR##        ;[131] Move in default character
  2589.     $RETT                ;[131] True return
  2590.  
  2591. SETHS1:    $KERR    (Illegal handshake character ^O/S1/)    ;[131]
  2592.     $RETF                ;[131] Failure return
  2593.     SUBTTL    Command execution -- SET command -- LINE to use
  2594.  
  2595.  
  2596. ;+
  2597. ;.HL2 SETLIN
  2598. ;This routine will store the line number to use to talk to the remote
  2599. ;Kermit.
  2600. ;-
  2601.  
  2602. SETLIN:    $CALL    P$CFM            ; Do we have a confirm?
  2603.     JUMPF    LINSBR            ; No, do the set stuff
  2604.  
  2605.     MOVE    S1,$TTNOD+MYTERM    ; Use my terminal
  2606.     MOVEM    S1,$TTNOD+XFRTRM    ; Store it
  2607.     MOVE    S1,$TTLIN+MYTERM    ; . . .
  2608.     MOVEM    S1,$TTLIN+XFRTRM    ; Store it
  2609.     RELEAS    TTYHLD,            ; Give up on terminal we grabbed
  2610.     $RETT                ; Return to the caller
  2611.  
  2612.  
  2613. ; Here to set the line to use for transfering information
  2614.  
  2615. LINSBR:    $CALL    P$NUM            ; Get the line number
  2616.     JUMPF    SETLI0            ; Failed, see if other type
  2617.     $TEXT    (<-1,,.TEMP>,<TTY^O/S1/^0>) ; Build the device name
  2618.     HRROI    S1,.TEMP        ; Point to the text
  2619.     JRST    SETLI2            ; Convert to node and line number
  2620.  
  2621. SETLI0:    $CALL    P$NODE            ; Parse a node name/number
  2622.     JUMPF    SETLI1            ; Failed, try for device
  2623.     TLNN    S1,-1            ; Is this a name?
  2624.       JRST    SETLI4            ; No, store the number
  2625.  
  2626.     MOVE    S2,S1            ; Move the information
  2627.     MOVEI    S1,2            ; Get the length of this
  2628.     MOVX    T1,<XWD .NDRNN,S1>    ; Point to the arguments
  2629.     NODE.    T1,            ; Do it
  2630.      JRST    [$KERR    (<Illegal node name>)
  2631.         $RETF]
  2632.     MOVE    S1,T1            ; Get the number now
  2633. SETLI4:    MOVEM    S1,XFRTRM+$TTNOD    ; Store the node information
  2634.     $CALL    P$NUM            ; Parse the line number
  2635.     MOVEM    S1,XFRTRM+$TTLIN    ; Store as the line number
  2636.  
  2637. ; Now make sure we can get the terminal
  2638.  
  2639. SETLI6:    MOVEI    S1,XFRTRM        ; Get the terminal descriptor address
  2640.     $CALL    T$CONN            ; Make sure the terminal is
  2641.     MOVE    T2,S1            ; Get the name
  2642.     IONDX.    S1,            ; Available
  2643.      JRST    [$KERR    (<Terminal not available>)
  2644.         $RETF]            ; Punt
  2645.     MOVEM    S1,XFRTRM+$TTUDX    ; Store the UDX
  2646.     MOVE    S1,T2            ; Reget device name
  2647.     DEVTYP    S1,            ; Get the device type bits
  2648.      JRST    [$KERR    (<Illegal terminal name>)
  2649.         $RETF]            ; Give up
  2650.     TXNN    S1,TY.AVL        ; Device available?
  2651.      JRST    [$KERR    (<Terminal in use by job ^D/S1,TY.JOB/>)
  2652.         $RETF]            ; We can't get the terminal
  2653.     $CALL    T$LOCAL            ; Check if using own terminal
  2654.     JUMPT    [RELEAS    TTYHLD,        ; Yes, let go of other terminal
  2655.         $RETT]            ; And return
  2656.     MOVX    T1,.IOASC        ; Get the mode
  2657.     SETZ    T3,            ; No buffers
  2658.     OPEN    TTYHLD,T1        ; Get the terminal so no one steals it
  2659.      JRST    [$KERR    (<Cannot open terminal>)
  2660.         $RETF]            ; Give up
  2661.     $RETT                ; And return to the caller
  2662.  
  2663. SETLI1:    $CALL    P$DEV            ; Parse the terminal name
  2664.     $RETIF                ; Return if that failed
  2665.     ADD    S1,[POINT 7,PFD.D1]    ; Point to the data area
  2666. SETLI2:    $CALL    S%SIXB            ; Convert to a device name
  2667.     $RETIF                ; Return if this fails
  2668.     MOVE    S1,S2            ; Save a copy
  2669.     GTNTN.    S2,            ; Convert to node and line number
  2670.      JRST    SETLI3            ; Failed, issue error message
  2671.     HLRZM    S2,XFRTRM+$TTNOD    ; Store the node number
  2672.     HRRZM    S2,XFRTRM+$TTLIN    ; And the line number
  2673.     JRST    SETLI6            ; Go grab the terminal
  2674.  
  2675. SETLI3:    CAMN    S2,S1            ; Non-network system?
  2676.      JRST    SETLI5            ; Yes, go store correct things
  2677.     $KERR    (<^T/@GTNERR(S2)/>)    ; Issue the error
  2678.     $RETF                ; Return to the caller
  2679.  
  2680. ; Here if system does not have network support
  2681.  
  2682. SETLI5:    SETZM    XFRTRM+$TTNOD        ; No node
  2683.     IONDX.    S2,            ; Convert to UDX (for line number)
  2684.      JRST    [$KERR    (<Nonexistent device>)    ; Must not be valid
  2685.         $RETF]            ; Can't set the line here
  2686.     CAXL    S2,.UXTRM        ; Check if valid terminal
  2687.      CAXLE    S2,.UXTRM+^O777        ;  .  .  .
  2688.       JRST    [$KERR    (<Device is not a terminal>) ; Nope, give up
  2689.         $RETF]            ; Give up
  2690.     MOVEM    S2,XFRTRM+$TTUDX    ; Store UDX
  2691.     SUBX    S2,.UXTRM        ; Convert to line number
  2692.     MOVEM    S2,XFRTRM+$TTLIN    ; And line number
  2693.     JRST    SETLI6            ; Go grab the terminal
  2694.  
  2695. ; Error text
  2696.  
  2697. GTNERR:    [ASCIZ    /Nonexistent device/]
  2698.     [ASCIZ    /Device is not a terminal/]
  2699.     [ASCIZ    /Terminal is not connected/]
  2700.     SUBTTL    Command execution -- SET command -- MESSAGE parameters
  2701.  
  2702. ;+
  2703. ;.hl2 SETMSG
  2704. ;This routine will set the level of message type out the user wishes to see.
  2705. ;This current parameters include the typing of file specifications on
  2706. ;receive or send and the packet numbers.
  2707. ;-
  2708.  
  2709. SETMSG:    $CALL    P$KEYW            ; Parse a keyword
  2710.     $RETIF                ; Return if that failed
  2711.  
  2712.     MOVE    P1,S1            ; Get the information parsed
  2713.     $CALL    P$KEYW            ; Get the next keyword (could have
  2714.                     ;  gotten NO as the first)
  2715.     JUMPF    [MOVX    S1,TRUE        ; If no second keyword, get a true
  2716.         MOVEM    S1,(P1)        ; And set the argument
  2717.         $RETT]            ; All done
  2718.     MOVEM    P1,(S1)            ; Otherwise, store the false
  2719.     $RETT                ; Return to the caller
  2720.     SUBTTL    Command execution -- SET command -- PROMPT
  2721.  
  2722. ;+
  2723. ;.HL2 SETPRM
  2724. ;This routine will set the user prompt.  This is used to allow the user
  2725. ;to set how he/she wants Kermit to prompt for commands.  This allows you
  2726. ;to be connected through various Kermits and always keep which wants input
  2727. ;straight.
  2728. ;-
  2729.  
  2730. SETPRM:    $CALL    P$FLD            ; Parse an unquoted string
  2731.     JUMPF    DEFPRM            ; Failed, so reset the prompt
  2732. ;
  2733. ; Here to copy the new prompt to the low segment
  2734. ;
  2735.     CAXLE    S2,D$PSIZ        ; Smaller than max?
  2736.      $RETF                ; Don't set it if it is
  2737.     ADD    S1,[POINT 7,PFD.D1]    ; Point to the data
  2738.  
  2739. SPRM.0:    MOVE    T1,[POINT 7,PROMPT]    ; Point to the prompt area
  2740. SPRM.1:    ILDB    S2,S1            ; Get a character
  2741.     IDPB    S2,T1            ; Store it
  2742.     JUMPN    S2,SPRM.1        ; Loop for all characters
  2743.     $RET                ; Return to the caller
  2744.  
  2745. DEFPRM:    MOVE    S1,[POINT 7,[ASCIZ /Kermit-10>/]] ; Get the prompt
  2746.     JRST    SPRM.0            ; Join common code
  2747.     SUBTTL    Command execution -- SET command -- RECEIVE parameters
  2748.  
  2749.  
  2750. ;+
  2751. ;.hl2 SETRCV
  2752. ;This routine is used to set the various RECEIVE parameters.  It will
  2753. ;dispatch to lower level routines to do the real work.
  2754. ;-
  2755.  
  2756. SETRCV:    $CALL    P$KEYW            ; Get the keywd the user supplied
  2757.     $RETIF                ; Return if false
  2758.     $CALL    (S1)            ; Call the user routine
  2759.     $RET                ; Return to the user
  2760.  
  2761. ;+
  2762. ;.HL2 SETR8Q
  2763. ;This routine will set the 8bit quoting character.
  2764. ;-
  2765.  
  2766. SETR8Q:    $CALL    P$NUM            ; Get the number
  2767.     MOVEM    S1,RCV%8QUOTE%CHAR##    ; Store the value
  2768.     $RETT                ; Give a good return
  2769.  
  2770. ;+
  2771. ;.hl2 SETREL
  2772. ;Routine to set the end of line character for the receiver side.
  2773. ;-
  2774.  
  2775. SETREL:    $CALL    P$NUM            ; Get the number
  2776.     $RETIF                ; Return
  2777.     MOVEM    S1,RCV%EOL##        ; Store the parameter
  2778.     $RETT                ; Give a good return
  2779. ;+
  2780. ;.HL2 SETRPC
  2781. ;This routine will set the padding character for the receive side.
  2782. ;-
  2783.  
  2784. SETRPC:    $CALL    P$NUM            ; Parse a number
  2785.     $RETIF                ; Return if false
  2786.     CAIN    S1,.CHDEL        ; Is this a delete?
  2787.       JRST    STRPC0            ; Yes, ok
  2788.     SKIPL    S1            ; Less than zero?
  2789.      CAILE    S1,^O37            ; Or greater than 37?
  2790.       JRST    STRPC1            ; Yes, illegal
  2791. STRPC0:    MOVEM    S1,RCV%PADCHAR##    ; Store the padding character
  2792.     $RETT                ; Give a good return
  2793.  
  2794. STRPC1:    $KERR    (Illegal padding cahracter)
  2795.     $RETF                ; Give a failure return
  2796.  
  2797. ;+
  2798. ;.HL2 SETRPD
  2799. ;This routine will store the number of padding characters that should be
  2800. ;sent to the remote Kermit.
  2801. ;-
  2802.  
  2803. SETRPD:    $CALL    P$NUM            ; Get the number we parsed
  2804.     $RETIF                ; Return if that failed
  2805.     JUMPL    S1,[$KERR(Must be a postive number)
  2806.         $RETF    ]        ; Issue the error and return
  2807.     MOVEM    S1,RCV%NPAD##        ; Store the number of characters
  2808.     $RETT                ; Give a good return
  2809.  
  2810. ;+
  2811. ;.hl2 SETRPL
  2812. ;This routine will set the length of the packets to receive.
  2813. ;-
  2814.  
  2815. SETRPL:    $CALL    P$NUM            ; Get the number parsed
  2816.     $RETIF                ; Return if that failed
  2817.     CAIL    S1,^D10            ; Min length
  2818.      CAILE    S1,^D1000 ; [134] 94    ; Max length
  2819.       JRST    [$KERR(Illegal packet size)
  2820.         $RETF]            ; Issue error and return
  2821.     MOVEM    S1,RCV%PKT%SIZE##    ; Store the packet length
  2822.     $RETT                ; Return to the caller
  2823.  
  2824. ;+
  2825. ;.hl2 SETRQU
  2826. ;This routine will set the receive quoting character.
  2827. ;-
  2828.  
  2829. SETRQU:    $CALL    P$NUM            ; Get the value
  2830.     MOVEM    S1,RCV%QUOTE##        ; Store the quote character
  2831.     $RETT
  2832.  
  2833. ;+
  2834. ;.HL2 SETRSH
  2835. ; This routine will store the parsed start of header character.
  2836. ;-
  2837.  
  2838. SETRSH:    $CALL    P$NUM            ; Get a number
  2839.     $RETIF                ; Punt if we can't
  2840.     MOVEM    S1,RCV%SOH##        ; Store it
  2841.     $RETT                ; And give a good return
  2842.  
  2843. ;+
  2844. ;.HL2 SETRTI
  2845. ;This routine will store the parsed time out time.
  2846. ;-
  2847.  
  2848. SETRTI:    $CALL    P$NUM            ; Get the number
  2849.     $RETIF                ; Return if that fails
  2850.     MOVEM    S1,RCV%TIMEOUT##    ; Store it
  2851.     $RETT                ; Give a good return
  2852. ;+
  2853. ;.HL2 SETRTY
  2854. ;This routine will set the retry count for either the initial connection or
  2855. ;the number of packets.
  2856. ;-
  2857.  
  2858. SETRTY:    $CALL    P$KEYW            ; Parse a keyword
  2859.     $RETIF                ; Return if that fails
  2860.     MOVE    P1,S1            ; Copy the store address
  2861.     $CALL    P$NUM        ; Get the number of retries allowed
  2862.     $RETIF                ; Return if that fails
  2863.     MOVEM    S1,(P1)            ; Store the number of retries
  2864.     $RETT                ; Give a good return to the caller
  2865. ;+
  2866. ;.HL2 SETSND
  2867. ;This routine will set the various SEND parameters.  It will dispatch
  2868. ;to lower level routines to do the real work.
  2869. ;-
  2870.  
  2871. SETSND:    $CALL    P$KEYW            ; Parse a keyword
  2872.     $RETIF                ; Return if it isn't
  2873.     $CALL    (S1)            ; Call the routine
  2874.     $RET                ; Return to the caller
  2875. ;+
  2876. ;.HL2 SETSEL
  2877. ;This routine will set the send side end of line character.
  2878. ;-
  2879.  
  2880. SETSEL:    $CALL    P$NUM            ; Get the number
  2881.     $RETIF                ; Return
  2882.     MOVEM    S1,SND%EOL##        ; Store the parameter
  2883.     $RETT                ; Give a good return
  2884.  
  2885. ;+
  2886. ;.HL2 SETSPC
  2887. ;This routine will store the send padding character.
  2888. ;-
  2889.  
  2890. SETSPC:    $CALL    P$NUM            ; Parse a number
  2891.     $RETIF                ; Return if false
  2892.     CAIN    S1,.CHDEL        ; Is this a delete?
  2893.       JRST    STSPC0            ; Yes, ok
  2894.     SKIPL    S1            ; Less than zero?
  2895.      CAILE    S1,^O37            ; Or greater than 37?
  2896.       JRST    STRPC1            ; Yes, illegal
  2897. STSPC0:    MOVEM    S1,SND%PADCHAR##    ; Store the padding character
  2898.     $RETT                ; Give a good return
  2899.  
  2900. ;+
  2901. ;.hl2 SETSPD
  2902. ;This routine will store the number of send padding characters to expect.
  2903. ;-
  2904.  
  2905. SETSPD:    $CALL    P$NUM            ; Get the number we parsed
  2906.     $RETIF                ; Return if that failed
  2907.     JUMPL    S1,[$KERR(Must be a postive number)
  2908.         $RETF    ]        ; Issue the error and return
  2909.     MOVEM    S1,SND%NPAD##        ; Store the number of characters
  2910.     $RETT                ; Give a good return
  2911.  
  2912. ;+
  2913. ;.HL2 SETSPL
  2914. ;This routine will set the send packet length.
  2915. ;-
  2916.  
  2917. SETSPL:    $CALL    P$NUM            ; Get the number parsed
  2918.     $RETIF                ; Return if that failed
  2919.     CAIL    S1,^D10            ; Min length
  2920.      CAILE    S1,^D1000 ; [134] 94    ; Max length
  2921.       JRST    [$KERR(Illegal packet size)
  2922.         $RETF]            ; Issue error and return
  2923.     MOVEM    S1,SND%PKT%SIZE##    ; Store the packet length
  2924.     $RETT                ; Return to the caller
  2925.  
  2926. ;+
  2927. ;.HL2 SETSQU
  2928. ;This routine will set the sending quoting character
  2929. ;-
  2930.  
  2931. SETSQU:    $CALL    P$NUM        ; Gett he value
  2932.     MOVEM    S1,SND%QUOTE##        ; Store the quote character
  2933.     $RETT
  2934.  
  2935. ;+
  2936. ;.HL2 SETSSH
  2937. ; This routine will store the parsed start of header character.
  2938. ;-
  2939.  
  2940. SETSSH:    $CALL    P$NUM            ; Get a number
  2941.     $RETIF                ; Punt if we can't
  2942.     MOVEM    S1,SND%SOH##        ; Store it
  2943.     $RETT                ; And give a good return
  2944.  
  2945. ;+
  2946. ;.hl2 SETSTI
  2947. ;This routine will set the sending time out time.
  2948. ;-
  2949.  
  2950. SETSTI:    $CALL    P$NUM            ; Get the number
  2951.     $RETIF                ; Return if that fails
  2952.     MOVEM    S1,SND%TIMEOUT##    ; Store it
  2953.     $RETT                ; Give a good return
  2954.  
  2955.  
  2956. ;+
  2957. ;.HL2 SETRPT
  2958. ;This routine will set the repeat quoting character
  2959. ;-
  2960.  
  2961. SETRPT:    $CALL    P$NUM            ; Get the number
  2962.     JUMPT    SETRP0            ; If we got it, store it
  2963.     $CALL    P$KEYW            ; Otherwise, get a keyword
  2964.     $RETIF                ; If not, give up
  2965. SETRP0:    MOVEM    S1,SET%REPT%CHR##    ; Store the repeat character
  2966.     $RETT
  2967.  
  2968.     SUBTTL    Command execution -- SHOW command
  2969.  
  2970. ;+
  2971. ;.HL1 C$SHOW
  2972. ;This command will show the current values of the parameters that can be
  2973. ;set with the SET command.  This routine is called after the SHOW command
  2974. ;has been parsed.
  2975. ;-
  2976.  
  2977. C$SHOW:
  2978.     $CALL    P$KEYW            ; Get the keyword parsed
  2979.     $RETIF                ; Return if not a keyword
  2980.     $CALL    (S1)            ; Call the correct routine
  2981.     $RET                ; Return to the caller
  2982.  
  2983. ;+
  2984. ;.HL2 SHOALL
  2985. ;This routine will show all of the various parameters.  This routine
  2986. ;is called from the SHOW command dispatch routine.
  2987. ;.literal
  2988. ;
  2989. ; Usage:
  2990. ;    $CALL    SHOALL
  2991. ;    (Return)
  2992. ;
  2993. ;.end literal
  2994. ;-
  2995.  
  2996. SHOALL:    $CALL    SHOVER            ; Show the version first
  2997.     $CALL    SHODAY            ; Show the date/time
  2998.     $TEXT    (,<>)            ; Issue a blank line
  2999.     $CALL    SHOLIN            ; Output the line information
  3000.     $TEXT    (,<>)            ; Issue a blank line.
  3001.     $CALL    SHOFIL            ; Show the file information
  3002.     $TEXT    (,<>)            ; Issue a blank line.
  3003.     $CALL    SHODEB            ; Show debugging flag
  3004.     $TEXT    (,<>)            ; Issue a blank line.
  3005.     $CALL    SHOPKT            ; Show the packet information
  3006.     $TEXT    (,<>)            ; Issue a blank line.
  3007.     $CALL    SHOTIM            ; Show the timing information
  3008.     $TEXT    (,<>)            ; Issue a blank line
  3009.     $CALL    SHOMAC            ; Show the defined macros
  3010.     $TEXT    (,<>)            ; And a CRLF
  3011.     $RETT                ; Give a good return
  3012.     SUBTTL    Command execution -- SHOW command -- SHOW MACROS
  3013.  
  3014. ;+
  3015. ;.hl2 SHOMAC
  3016. ; This routine will list all defined macros.
  3017. ;See definition of macro blocks in header of routine C$DEFINE
  3018. ;-
  3019.  
  3020. SHOMAC:    HLRZ    P1,DFNTAB        ; Get the count of defined macros
  3021.     JUMPE    P1,[$TEXT    (,< No defined macros>)    ; If nothing, say so
  3022.         $RETT]            ; And return
  3023.     MOVN    P1,P1            ; Negate the count
  3024.     HRLI    P1,DFNTAB+1        ; Build the pointer
  3025.     MOVS    P1,P1            ;  .  .  .
  3026.     $TEXT    (,< Macros:>)        ; Say what we are typing
  3027.  
  3028. SHOM.1:    HRRZ    S1,(P1)            ; Get the macro block address
  3029.     LOAD    S2,$MBOFS(S1),MB$OFS    ; Get offset to string
  3030.     ADD    S1,S2            ; Point at it
  3031.     $TEXT    (,<  ^T/(S1)/^A>)    ; Type the definition (includes name and CRLF)
  3032.     AOBJN    P1,SHOM.1        ; Loop for all macros
  3033.     $RETT                ; And return
  3034.     SUBTTL    Command execution -- SHOW command -- SHOW VERSION
  3035.  
  3036. ;+
  3037. ;.HL2 SHOVER
  3038. ;This routine will display the version of KERMIT-10.  This is compatible with
  3039. ;KERMIT-20.
  3040. ;.literal
  3041. ;
  3042. ; Usage:
  3043. ;    $CALL    SHOVER
  3044. ;    (Return)
  3045. ;
  3046. ;.end literal
  3047. ;-
  3048.  
  3049. SHOVER:    $TEXT    (,<TOPS-10 KERMIT version ^V/.JBVER/>)
  3050.     $RETT                ; Give a good return
  3051.  
  3052.  
  3053.  
  3054.  
  3055.     SUBTTL    Command execution -- SHOW command -- SHOW DAYTIME
  3056.  
  3057. ;+
  3058. ;.HL2 SHODAY
  3059. ;This routine will display the current date/time.  This is compatible with
  3060. ;KERMIT-20.
  3061. ;.literal
  3062. ;
  3063. ; Usage:
  3064. ;    $CALL    SHODAY
  3065. ;    (Return)
  3066. ;
  3067. ;.end literal
  3068. ;-
  3069.  
  3070. SHODAY:    $TEXT    (,<^H/[EXP -1]/>)    ; Output the date/time
  3071.     $RETT                ; Give a good return
  3072.     SUBTTL    Command execution -- SHOW command -- SHOW DEBUGGING
  3073.  
  3074. ;+
  3075. ;.HL2 SHODEB
  3076. ;This rotine will display the state of the debugging parameters.  This
  3077. ;routine is called by the SHOW command dispatcher and SHOW ALL command.
  3078. ;.literal
  3079. ;
  3080. ; Usage:
  3081. ;    $CALL    SHODEB
  3082. ;    (Return)
  3083. ;
  3084. ;.end literal
  3085. ;-
  3086.  
  3087. SHODEB:    MOVE    S1,TY%FIL##        ; Get the file specification type out
  3088.     $CALL    TONOFF            ; Get the text associated with it
  3089.     $TEXT    (,<File specification type out is ^T/(S1)/>)
  3090.     MOVE    S1,TY%PKT##        ; Get the packet number type out flag
  3091.     $CALL    TONOFF            ; Get the text associated with it
  3092.     $TEXT    (,<Packet number type out is ^T/(S1)/>)
  3093.     MOVE    S1,DEBUG%FLAG##        ; Get the flag value
  3094.     $CALL    TONOFF            ; Get the text
  3095.     $TEXT    (,<Debugging is ^T/(S1)/>)
  3096.     MOVEI    S1,DBGLOG        ; Point at debugging log info
  3097.     MOVEI    S2,[ASCIZ |Debugging|] ; And the text
  3098.     $CALL    SDEB.1            ; Type out if necessary
  3099.     MOVEI    S1,SESLOG        ; Point at session info
  3100.     MOVEI    S2,[ASCIZ |Session|]    ; And text
  3101.     $CALL    SDEB.1            ; Type it
  3102.     MOVEI    S1,TRNLOG        ; And transaction log
  3103.     MOVEI    S2,[ASCIZ |Transaction|] ; And its text
  3104. ;    PJRST    SDEB.1            ; Type it out
  3105.  
  3106. SDEB.1:    MOVE    TF,S2            ; Copy text to type
  3107.     MOVE    S2,$LGFLG(S1)        ; Get log file flags
  3108.     TXNN    S2,LG$SET        ; File set?
  3109.      $RETT                ; No, just return
  3110.     TXNE    S2,LG$APP        ; Want to append to it?
  3111.      SKIPA    S2,[[ASCIZ |/Append|]]    ; Yes, get the switch
  3112.       MOVEI    S2,[ASCIZ ||]        ; No, no switch
  3113.     $TEXT    (,<^T/@TF/ log file is ^F/$LGFD(S1)/^T/(S2)/>) ; Say what it is
  3114.     $RETT                ; Give a good return
  3115.     SUBTTL    Command execution -- SHOW command -- SHOW FILE-INFORMATION
  3116.  
  3117. ;+
  3118. ;.HL2 SHOFIL
  3119. ;This routine will display the various file information parameters that
  3120. ;are possible to set.
  3121. ;-
  3122.  
  3123. SHOFIL:    MOVE    S1,FILTYP        ; Get the file type being used
  3124.     $TEXT    (,<File type is ^T/@FBSTBL(S1)/>)
  3125.  
  3126.     MOVEI    S1,[ASCIZ |Unknown|]    ; Unkown file naming
  3127.     MOVE    S2,FIL%NORMAL%FORM##    ; Get the file name type
  3128.     CAIN    S2,FNM%NORMAL##        ; Normalized file names?
  3129.      MOVEI    S1,[ASCIZ |Normal form|] ; Yes, use that
  3130.     CAIN    S2,FNM%FULL##        ; Full file specs?
  3131.      MOVEI    S1,[ASCIZ |Full|]    ; Yes, say so
  3132.     CAIN    S2,FNM%UNTRAN##        ; Untranslated?
  3133.      MOVEI    S1,[ASCIZ |Untranslated|] ; Yes, get the text
  3134.     $TEXT    (,<File naming: ^T/(S1)/ file specifications>)
  3135.  
  3136. TOPS10<
  3137.     MOVE    S1,WARN%FLAG##        ; Get the flag value
  3138.     $CALL    TONOFF            ; Get the value
  3139.     $TEXT    (,<File warning is ^T/(S1)/>)
  3140. >; End of TOPS10 conditional
  3141.  
  3142.     MOVE    S1,ABT%FLAG##        ; Get aborted file flag
  3143.     TXNE    S1,BLSTRU        ; True?
  3144.      SKIPA    S1,[[ASCIZ |Discard|]]    ; Yes, discard
  3145.       MOVEI    S1,[ASCIZ |Keep (whatever portion was received)|] ; No, Keep
  3146.     $TEXT    (,<Disposition for incomplete received files: ^T/(S1)/>)
  3147.     $RETT                ; Return to the caller
  3148.  
  3149. DEFINE FT(NUM,TEXT)<[ASCIZ |TEXT|]>
  3150. FBSTBL:    $FLTYP
  3151.     SUBTTL    Command execution -- SHOW command -- SHOW LINE-INFORMATION
  3152.  
  3153. ;+
  3154. ;.hl2 SHOLIN
  3155. ;This routine will display the line that is being used for the transfer of
  3156. ;information to the remote Kermit.
  3157. ;-
  3158.  
  3159. SHOLIN:    MOVEI    S1,XFRTRM        ; Point to the information
  3160.     $CALL    T$CONN            ; Connect the terminal to the system
  3161.     $TEXT    (,<Line being used is ^W/S1/: ^A>)
  3162.     SKIPE    XFRTRM+$TTNOD        ; Non-network?
  3163.      $TEXT    (,<(^N/XFRTRM+$TTNOD/:: line # ^O/XFRTRM+$TTLIN/)^A>)
  3164.     $TEXT    (,<>)            ; And a CRLF
  3165.  
  3166. ;[133]    MOVE    S1,IBM%FLAG##        ; Get the flag
  3167. ;[133]    $CALL    TONOFF            ; Get the value
  3168. ;[133]    $TEXT    (,<  IBM-mode:    ^T/(S1)/^A>)
  3169.     MOVE    S1,IBM%CHAR##        ; Get the IBM hand shake character
  3170.     $CALL    CHITXT            ; Get the text for it
  3171. ;[133]    $TEXT    (,<, Handshake: ^T/.TEMP/>)
  3172.     $TEXT    (,<  Handshake: ^T/.TEMP/>)
  3173.  
  3174.     MOVE    S1,PARITY%TYPE##    ; Get the parity type
  3175. ;[133]    MOVE    S2,IBM%FLAG##        ; Get the IBM flag
  3176. ;[133]    TXNN    S2,BLSTRU        ; Is it on?
  3177.      CAIN    S1,PR%MARK        ; Mark?
  3178.       MOVEI    S2,[ASCIZ |mark|]    ; Yes, either mark set or IBM mode
  3179.     CAIN    S1,PR%NONE        ; None?
  3180.      MOVEI    S2,[ASCIZ |none|]    ; Yes
  3181.     CAIN    S1,PR%SPACE        ; Space?
  3182.      MOVEI    S2,[ASCIZ |space|]    ; Yes
  3183.     CAIN    S1,PR%ODD        ; Odd?
  3184.      MOVEI    S2,[ASCIZ |odd|]    ; Yes
  3185.     CAIN    S1,PR%EVEN        ; Even parity?
  3186.      MOVEI    S2,[ASCIZ |even|]    ; Yes
  3187.     $TEXT    (,<  Parity:      ^T/(S2)/>)
  3188.  
  3189. ;    MOVE    S1,DUPLEX##        ; Get the duplex variable
  3190. ;    MOVEI    S2,[ASCIZ /Half/]    ; Default text
  3191. ;    CAIN    S1,DP%FULL##        ; Is this full duplex?
  3192. ;     MOVEI    S2,[ASCIZ /Full/]    ; Yes, use this text instead
  3193. ;    $TEXT    (,<  Duplex:    ^T/(S2)/>)
  3194.  
  3195.     MOVE    S1,LCLECH        ; Get the flag
  3196.     $CALL    TONOFF            ; Get the value
  3197.     $TEXT    (,<  Local echo:  ^T/(S1)/^A>)
  3198.  
  3199.     MOVE    S1,ESCAPE        ; Get the escape character
  3200.     $CALL    CHITXT            ; Get the correct way to type it
  3201.     $TEXT    (,<  Escape:      ^T/.TEMP/>)
  3202.     MOVE    S1,XXPMOD        ;[127] get XON-XOFF-processing
  3203.     CAIN    S1,$XXDEF        ;[127] Default?
  3204.      MOVEI    S2,[ASCIZ /default/]    ;[127]
  3205.     CAIN    S1,$XXLCL        ;[127] Local?
  3206.      MOVEI    S2,[ASCIZ /local/]    ;[127]
  3207.     CAIN    S1,$XXREM        ;[127] Remote?
  3208.      MOVEI    S2,[ASCIZ /remote/]    ;[127]
  3209.     $TEXT    (,<  XON-XOFF-processing:  ^T/(S2)/>)    ;[127]
  3210.     $RETT                ; Give a good return
  3211.     SUBTTL    Command execution -- SHOW command -- SHOW PACKET-INFORMATION
  3212.  
  3213. ;+
  3214. ;.hl2 SHOPKT
  3215. ;This routine will show the packet information.
  3216. ;-
  3217.  
  3218. SHOPKT:    $TEXT    (,<Packet parameters:^M^J                    Receive        Send>)
  3219.     MOVM    S1,SND%PKT%LENGTH##    ; Get the length
  3220.     $TEXT    (,<  Size:             ^D7 /RCV%PKT%LENGTH##/       ^D5 /S1/ chars>)
  3221.     MOVM    S1,SND%NPAD##        ; Get the padding value
  3222.     $TEXT    (,<  Padding:          ^D7 /RCV%NPAD##/       ^D5 /S1/>)
  3223.     MOVE    S1,RCV%PAD##        ; Get the padding character
  3224.     $CALL    CHITXT            ; Convert it to text
  3225.     $TEXT    (,<  Pad Character:    ^T7R /.TEMP/       ^A>)
  3226.     MOVM    S1,SND%PAD        ; Get the send pad character
  3227.     $CALL    CHITXT            ; Get the text
  3228.     $TEXT    (,<^T5R /.TEMP/>)
  3229.     MOVE    S1,RCV%EOL##        ; Get the receive EOL character
  3230.     $CALL    CHITXT            ; Convert it
  3231.     $TEXT    (,<  End-Of-Line:      ^T7R /.TEMP/       ^A>)
  3232.     MOVM    S1,SND%EOL##        ; Get the end of line character
  3233.     $CALL    CHITXT            ; Get the text
  3234.     $TEXT    (,<^T5R /.TEMP/>)
  3235.     MOVE    S1,RCV%QUOTE##        ; Get the receive quoting character
  3236.     $CALL    CHITXT            ; Convert it to text
  3237.     $TEXT    (,<  Control Quote:    ^T7R /.TEMP/       ^A>)
  3238.     MOVM    S1,SND%QUOTE##        ; Get the send quoting character
  3239.     $CALL    CHITXT            ; Convert it to text
  3240.     $TEXT    (,<^T5R /.TEMP/>)
  3241.     MOVE    S1,RCV%SOH##        ; Get the start of header character
  3242.     $CALL    CHITXT            ; Make it text
  3243.     $TEXT    (,<  Start-of-Packet:  ^T7R /.TEMP/       ^A>)
  3244.     MOVM    S1,SND%SOH##        ; Get the send start of header
  3245.     $CALL    CHITXT            ; Make it text
  3246.     $TEXT    (,<^T5R /.TEMP/>)    ; Output it
  3247.     MOVE    S1,RCV%8QUOTE##        ; Get the quoting character
  3248.     $CALL    CHITXT            ; Convert to text
  3249.     $TEXT    (,<^M^J 8th-bit Quote character ^T/.TEMP/>)
  3250.     MOVE    S1,SET%REPT%CHR##    ; Get the repeat character
  3251.     $CALL    CHITXT            ; Make it printable
  3252.     MOVE    S1,SET%REPT%CHR##    ; Get the charcter back
  3253.     CAIN    S1," "            ; Is it a space?
  3254.      JRST    [MOVE    S1,[ASCII |None|] ; Yes, that really means no repeats
  3255.         MOVEM    S1,.TEMP    ; So say that
  3256.         JRST    .+1]        ; Continue
  3257.     $TEXT    (,< Repeat Quote character  ^T/.TEMP/>)
  3258.     MOVE    S1,CHKTYPE##        ; Get the block check type
  3259.     MOVE    S1,SHOBLT-CHK%1C##(S1)    ; Get the text to type
  3260.     $TEXT    (,< Block check type is ^T/(S1)/>) ; Type it
  3261.     $RETT                ; And return
  3262.  
  3263. SHOBLT:    EXP    [ASCIZ |1 character checksum|]
  3264.     EXP    [ASCIZ |2 character checksum|]
  3265.     EXP    [ASCIZ |3 character CRC-CCITT|]
  3266.     SUBTTL    Command execution -- SHOW command -- SHOW TIMING-INFORMATION
  3267.  
  3268. ;+
  3269. ;.hl2 SHOTIM
  3270. ;This routine will show the timing parameters.
  3271. ;-
  3272.  
  3273. SHOTIM:    $TEXT    (,<Timing parameters:^M^J                    Receive        Send>)
  3274.     MOVM    S1,SND%TIMEOUT##        ; Get the time out
  3275.     $TEXT    (,<  Time out:         ^D7 /RCV%TIMEOUT##/       ^D5 /S1/ secs>)
  3276.     $TEXT    (,<^M^J  Delay before sending first packet: ^D/DELAY##/ secs>)
  3277.     $TEXT    (,<  Packet retries before timeout: ^D/PKT%RETRIES##/>)
  3278.     $TEXT    (,<  Number of retries for initial packet: ^D/SI%RETRIES##/>)
  3279.     $TEXT    (,<  Server NAKs every ^D/SRV%TIMEOUT##/ seconds while waiting for commands>)
  3280.     $RETT                ; Give a good return
  3281.     SUBTTL    Command execution -- SHOW command -- Support routines -- TONOFF
  3282.  
  3283. ;+
  3284. ;.hl3 TONOFF
  3285. ;This routine is a utility routine that will return the address of the
  3286. ;string "on" or "off" or "unknown" depending on if the value passed to
  3287. ;it is either the BLISS value for TRUE or FALSE or neither.
  3288. ;.literal
  3289. ;
  3290. ; Usage:
  3291. ;    MOVE    S1,Value
  3292. ;    $CALL    TONOFF
  3293. ;    (Return)
  3294. ;
  3295. ; On return:
  3296. ;    S1/ Address of the text
  3297. ;
  3298. ;.end literal
  3299. ;-
  3300.  
  3301. TONOFF:    MOVE    S2,S1            ; Copy this
  3302.     MOVEI    S1,[ASCIZ |unknown|]    ; Start with unknown
  3303.     CAIN    S2,BLSTRU        ; On?
  3304.      MOVEI    S1,[ASCIZ |on|]        ; Yes, use this
  3305.     CAIN    S2,BLSFAL        ; Off?
  3306.      MOVEI    S1,[ASCIZ |off|]    ; Yes, use this instead
  3307.     $RET                ; Return to the caller
  3308.     SUBTTL    Command execution -- SHOW command -- Support routines -- CHITXT
  3309.  
  3310. ;+
  3311. ;.hl3 CHITXT
  3312. ;This routine will store the text associated with the character that is
  3313. ;passed to it.  The text will be stored in .TEMP in the low segment.
  3314. ;.literal
  3315. ;
  3316. ; Usage:
  3317. ;    MOVE    S1,Character value
  3318. ;    $CALL    CHITXT
  3319. ;    (Return)
  3320. ;
  3321. ; On return:
  3322. ;    .TEMP/ Contains the ASCIZ text of the character
  3323. ;
  3324. ;.end ltieral
  3325. ;-
  3326.  
  3327. CHITXT:    CAIE    S1,.CHDEL        ; Delete?
  3328.       JRST    CHITX0            ; No, skip this
  3329.     $TEXT    (<-1,,.TEMP>,<^7/[EXP .CHLAB]/del^7/[EXP .CHRAB]/^0>) ; Yes, get the text
  3330.     $RET                ; Return to the caller
  3331.  
  3332. CHITX0:    CAIGE    S1," "            ; Greater than a space?
  3333.       JRST    CHITX1            ; No, control characer
  3334.     $TEXT    (<-1,,.TEMP>,<^7/S1/^0>) ; Yes, normal character
  3335.     $RET                ; Return to the caller
  3336.  
  3337. CHITX1:    MOVEI    S2,"A"-1(S1)        ; Make it a printing character
  3338.     $TEXT    (<-1,,.TEMP>,<^^^7/S2/^0>) ; Get the text
  3339.     $RET                ; Return to the caller
  3340.     SUBTTL    Command execution -- STATUS command
  3341.  
  3342. ;+
  3343. ;.HL1 C$STATUS
  3344. ;This routine will give some information about the last transfer and
  3345. ;all transfers that we have done.
  3346. ;-
  3347.  
  3348. C$STATUS:
  3349.     MOVEI    S1,T%TTY        ; Output to terminal
  3350.     $CALL    WRTSTS            ; Do totals
  3351.     $TEXT    (,<^M^JTotals for the last transfer>)
  3352.     MOVE    T1,XFR%TIME##        ; Get the total time spent
  3353.     IDIVX    T1,^D<60*60*1000>    ; Get hours
  3354.     IDIVX    T2,^D<60*1000>        ; Minutes
  3355.     IDIVX    T3,^D1000        ; Seconds and milliseconds
  3356.     MOVE    S1,XFR%TIME##        ; Also get
  3357.     IDIVI    S1,^D1000        ; As seconds and milliseconds
  3358.     $TEXT    (,< Last transfer time ^D/T1/:^D2R0/T2/:^D2R0/T3/.^D3R0/T4/(^D/S1/.^D3R0/S2/ seconds)>)
  3359.     $TEXT    (,< Characters sent ^D/SMSG%TOTAL%CHARS##/>)
  3360.     $TEXT    (,< Characters received ^D/RMSG%TOTAL%CHARS##/>)
  3361.     $TEXT    (,< Data characters sent ^D/SMSG%DATA%CHARS##/>)
  3362.     $TEXT    (,< Data characters received ^D/RMSG%DATA%CHARS##/>)
  3363.     $TEXT    (,< NAKs sent ^D/SMSG%NAKS##/>)
  3364.     $TEXT    (,< NAKs received ^D/RMSG%NAKS##/>)
  3365.     SKIPN    T2,XFR%TIME##        ; Get the time of the last transfer
  3366.       JRST    STAT.1            ; Skip it, hasn't happened
  3367.     MOVE    T1,RMSG%DATA%CHARS##    ; Get the number of data characters
  3368.                     ;  received
  3369.     CAMGE    T1,SMSG%DATA%CHARS##    ; Should we use the other?
  3370.      MOVE    T1,SMSG%DATA%CHARS##    ; Yes, get it
  3371.     IMULI    T1,^D10            ; Make this 10 times for baud rate
  3372.     ADDI    T2,^D500        ; Round up
  3373.     IDIVI    T2,^D1000        ; Milliseconds to seconds
  3374.     IDIV    T1,T2            ; Compute the baud rate
  3375.     $TEXT    (,< Effective data rate: ^D/T1/ baud>)
  3376. STAT.1:    $TEXT    (,<>)
  3377.     $RETT                ; All done
  3378.  
  3379. ; Here to write total values.  This is also used for generic status command.
  3380.  
  3381. WRTSTS::$SAVE    <P1>            ; Save P1
  3382.     MOVE    P1,S1            ; Get the output routine
  3383.     $TEXT    (@P1,<^M^JTotals since Kermit was started>)
  3384.     MOVE    T1,TOTAL%TIME##        ; Get the total time spent
  3385.     IDIVX    T1,^D<60*60*1000>    ; Get hours
  3386.     IDIVX    T2,^D<60*1000>        ; Minutes
  3387.     IDIVX    T3,^D1000        ; Seconds and milliseconds
  3388.     MOVE    S1,TOTAL%TIME##        ; Also get
  3389.     IDIVI    S1,^D1000        ; As seconds and milliseconds
  3390.     $TEXT    (@P1,< Total transfer time ^D/T1/:^D2R0/T2/:^D2R0/T3/.^D3R0/T4/(^D/S1/.^D3R0/S2/ seconds)>)
  3391.     $TEXT    (@P1,< Characters sent ^D/SND%TOTAL%CHARS##/>)
  3392.     $TEXT    (@P1,< Characters received ^D/RCV%TOTAL%CHARS##/>)
  3393.     $TEXT    (@P1,< Data characters sent ^D/SND%DATA%CHARS##/>)
  3394.     $TEXT    (@P1,< Data characters received ^D/RCV%DATA%CHARS##/>)
  3395.     $TEXT    (@P1,< NAKs sent ^D/SND%NAKS##/>)
  3396.     $TEXT    (@P1,< NAKs received ^D/RCV%NAKS##/>)
  3397.     $TEXT    (@P1,< Total packets sent ^D/SND%COUNT/>)
  3398.     $TEXT    (@P1,< Total packets received ^D/RCV%COUNT/>)
  3399.     SKIPN    T2,TOTAL%TIME##        ; Get the amount of time
  3400.       JRST    WRTS.0            ; None, so skip this
  3401.     MOVE    T1,RCV%DATA%CHARS##    ; Get the number of data characters
  3402.                     ;  received
  3403.     ADD    T1,SND%DATA%CHARS##    ; Add in to get total data characters
  3404.                     ;  transfered
  3405.     IMULI    T1,^D10            ; Make this 10 times for baud rate
  3406.     ADDI    T2,^D500        ; Round up
  3407.     IDIVI    T2,^D1000        ; Milliseconds to seconds
  3408.     IDIV    T1,T2            ; Compute the baud rate
  3409.     $TEXT    (@P1,< Effective data rate: ^D/T1/ baud>)
  3410. WRTS.0:    LDB    S1,[POINT 7,LAST%ERROR##] ; Check if any error text
  3411.     JUMPE    S1,WRTS.1        ; If none, don't type line
  3412.     $TEXT    (,<^M^JLast error: ^T/LAST%ERROR/>)
  3413. WRTS.1:    $RETT
  3414.     SUBTTL    File processing -- INIFILE - Initialization
  3415.  
  3416. ;+
  3417. ;.hl1 INIFIL
  3418. ;This routine will initialize the file processing for KERMIT.
  3419. ;.LITERAL
  3420. ;
  3421. ; Usage:
  3422. ;    $CALL    INIFIL
  3423. ;    (Return)
  3424. ;
  3425. ;
  3426. ;.end literal
  3427. ;-
  3428.  
  3429. INIFIL:    MOVX    S1,D$FTP        ; Get the default file type
  3430.     MOVEM    S1,FILTYP        ; Store it
  3431.     $RETT                ; Return to the caller
  3432.     SUBTTL    File processing -- FILE%OPEN
  3433.  
  3434. ;+
  3435. ;.HL1 FILE%OPEN (Function)
  3436. ; This routine will open the file for reading or writing.
  3437. ;-
  3438.  
  3439. BLSRTN(FILE%OPEN,<FUNCTION>)
  3440. TOPS10<
  3441.     $SAVE    <T1,T2,T3,T4>        ; Save a few registers
  3442.     $SAVE    <TF,S2>            ; Save this too
  3443.     $SAVE    <P1>            ; Save as a flag
  3444.     MOVEI    S1,.FDSIZ        ; Get the size of the FX block
  3445.     MOVEI    S2,FX            ; And the address
  3446.     $CALL    .ZCHNK            ; Clear out the block
  3447.     SETZ    P1,            ; Flag from FILE%OPEN
  3448.     MOVE    S1,[POINT 7,FILE%N##]    ; Point to the file name
  3449.     MOVEI    S2,FX            ; Point to the FX block
  3450.     $CALL    PRSFIL            ; Parse the file spec
  3451.     MOVE    S1,FUNCTION        ; Get the function
  3452.     JUMPE    S1,OPNREA        ; Open for reading?
  3453.  
  3454. ; Here if we are opening the file for writing.  We just make sure that we are
  3455. ; not overwriting any files if WARN%FLAG is true.
  3456.  
  3457.     SKIPN    LOGDIN            ; Are we logged in?
  3458.      JRST    [KERERR    (<Cannot write files without LOGIN first>) ;[125] No, don't write files now
  3459.         BLSRET    RMS32]        ;[125] So we don't compromise security
  3460.     SETO    S1,            ; Flag for output
  3461.     $CALL    SETFLP            ; Set up FILOP block
  3462.     MOVEI    T1,FX            ; Point to the scanner block
  3463.     SKIPE    USRFIL            ; User supply a file specification?
  3464.      MOVEI    T1,USRFX        ; Yes, point to that block instead
  3465.     MOVEI    T2,FLP+.FOIOS        ; Point to the open block
  3466.     MOVEI    T3,ELB            ; Point to the LOOKUP/ENTER block
  3467.     MOVEI    T4,PTH            ; Point to the path block
  3468.     $CALL    .STOPB            ; Convert to FILOP block
  3469.       JRST    [KERERR (<Wild file specifications illegal on RECEIVE>)
  3470.         BLSRET    RMS32]
  3471.     MOVE    S1,FILTYP        ; Get the file type we are using
  3472.     CAXE    S1,$FBS8        ; 8-bit file?
  3473. IFE .IOASC,<TDZA S1,S1>            ; No, Use ASCII mode
  3474. IFN .IOASC,<SKIPA S1,[EXP .IOASC]>    ; No, Use ASCII mode
  3475.      MOVX    S1,.IOBIN        ; Yes, use binary mode
  3476.     MOVEM    S1,FLP+.FOIOS        ; Store the mode
  3477.     MOVX    S1,FO.PRV        ; Use priv's if we have any
  3478.     MOVEM    S1,FLP+.FOFNC        ; Store it
  3479.     MOVX    S1,FIL            ; Get the channel
  3480.     STORE    S1,FLP+.FOFNC,FO.CHN    ; Store the channel
  3481.     MOVX    S1,.FOCRE        ; Create a new file
  3482.     MOVX    S2,BLSTRU        ; File warning on or off?
  3483.     CAME    S2,WARN%FLAG##        ; On?
  3484.       MOVX    S1,.FOWRT        ; No, just write this file
  3485.     STORE    S1,FLP+.FOFNC,FO.FNC    ; Store the function
  3486.  
  3487.     MOVEI    S1,FLP+.FOIOS        ; Point to the argument block
  3488.     DEVSIZ    S1,            ; Get the buffer size
  3489.      JRST    [KERERR(<DEVSIZ UUO failure (^D/S1/)>)
  3490.         BLSRET    RMS32]        ; Claim RMS error
  3491.     HLRZ    S2,S1            ; Get the number of buffers
  3492.     MOVEI    S1,(S1)            ; Get the size
  3493.     IMULI    S1,(S2)            ; Compute the total size
  3494.     MOVEM    S1,FBFSIZ        ; Store the number of words
  3495.     $CALL    M%GMEM            ; Allocate the memory
  3496.     JUMPF    [KERERR(<^E/S1/>)
  3497.         BLSRET    RMS32]
  3498.     MOVEM    S2,FBFADR        ; Store the buffer address
  3499.     EXCH    S2,.JBFF        ; Exchange with .JBFF
  3500.  
  3501.     MOVE    T4,ELB+.RBPPN        ;[125] Remember path or PPN in case of failure
  3502.     MOVE    S1,[XWD .FOMAX-1,FLP]    ; Point to the argument block
  3503.     FILOP.    S1,            ; Do the FILOP.
  3504.       JRST    OPNWR0            ; Failed, see why
  3505.  
  3506. OPNWR3:    MOVEM    S2,.JBFF        ; Restore .JBFF
  3507.  
  3508. ; Set up byte pointer in buffer header.  The monitor will correctly calculate
  3509. ;the byte count if we do so.
  3510.  
  3511.     MOVX    S1,<POINT 7,,34>    ; Assume ASCII files
  3512.     MOVX    S2,$FBS8        ; Is it really 8-bit?
  3513.     CAMN    S2,FILTYP        ; . . .
  3514.      MOVX    S1,<POINT 8,,31>    ; Yes, use 8 bit
  3515.     HLLM    S1,BH+.BFPTR        ; Store in the pointer
  3516.     MOVE    S1,TY%FIL##        ; Get the type file flag
  3517.     TXNN    S1,BLSTRU        ; Want type out?
  3518.      BLSRET    NORMAL            ; Give a good return
  3519.     MOVEI    S1,[ASCIZ | as |]    ; Get the text to type
  3520.     $CALL    TYPFIL            ; Type the file specification
  3521.     BLSRET    NORMAL            ; Give a good return
  3522.  
  3523. ; Here if we have gotten an error.  Restore .JBFF and then see if the error
  3524. ; is allowed (WARN%FLAG and superceeding error)
  3525.  
  3526. OPNWR0:    MOVE    T1,S1            ; Copy the error code
  3527.     MOVEM    S2,.JBFF        ; Store .JBFF back
  3528.     MOVX    S2,BLSFAL        ; Get the false value
  3529.     CAME    S2,WARN%FLAG##        ; Can we change the name (to protect the inocent?)
  3530.       JRST    OPNWR1            ; Yes, change the name
  3531. OPNWR2:    MOVE    S1,FBFSIZ        ; Get the size of the buffers
  3532.     MOVE    S2,FBFADR        ; Get the address
  3533.     $CALL    M%RMEM            ; Return the memory
  3534.     KERERR    (<^T/FILERR##(T1)/>)
  3535.     BLSRET    RMS32            ; Failure return
  3536.  
  3537. ; Here to change the extension of the file to something different.
  3538.  
  3539. OPNWR1:    CAIE    T1,ERAEF%        ; Already exist error?
  3540.       JRST    OPNWR2            ; No, just return the buffers and exit
  3541.     MOVSI    S1,(<SIXBIT |000|>)    ; Get the initial extension
  3542.     MOVEM    S1,ELB+.RBEXT        ; Store it
  3543.     MOVE    S2,FBFADR        ; Get the buffer's address again
  3544.     EXCH    S2,.JBFF        ; Exchange this
  3545. OPNWR4:    MOVEM    T4,ELB+.RBPPN        ;[125] Reset path or PPN so file goes correct place
  3546.     MOVE    S1,[XWD .FOMAX-1,FLP]    ; Point to the argument block
  3547.     FILOP.    S1,            ; Do it
  3548.       SKIPA                ; Failed
  3549.     JRST    OPNWR3            ; Worked this time, just exit now
  3550.     CAIE    T1,ERAEF%        ; Same problem still?
  3551.       JRST    OPNWR0            ; No, something else this time
  3552.     HLRZ    S1,ELB+.RBEXT        ; Get the extension
  3553.     TXZ    S1,<'000'>        ; Turn this off
  3554.     TXO    S1,707070        ; Turn this on
  3555.     AOJ    S1,            ; Increment this
  3556.     TXZ    S1,707070        ; Reverse it
  3557.     TXO    S1,<'000'>        ; Make it sixbit again
  3558.     HRLZM    S1,ELB+.RBEXT        ; Store this back
  3559.     JRST    OPNWR4            ; Try again
  3560. >; End of TOPS10 conditional
  3561. ; Here if we are reading a stream of files.  Call .LKWLD if we are under
  3562. ; TOPS-10, else TOPS-20 will do the right thing.
  3563.  
  3564. TOPS10<
  3565. OPNREA:    SETZ    S1,            ; Clear this
  3566.     $CALL    SETFLP            ; Set up the FILOP. block
  3567.     MOVEI    S1,FX            ; Point to the argument block
  3568.     MOVEM    S1,WLD+$LKFDB        ; Store it
  3569.     MOVX    S1,.FOMAX        ; Get the length
  3570.     STORE    S1,WLD+$LKFLP,LK$FLN    ; Store the length
  3571.     MOVEI    S1,FLP            ; Point to the argument block
  3572.     STORE    S1,WLD+$LKFLP,LK$FLP    ; Store the address
  3573.     MOVX    S1,LK$FRS        ; Flag this is the first time
  3574.     SKIPGE    P1            ; First time?
  3575.      SETZ    S1,            ; No, not the first time
  3576.     MOVEM    S1,WLD+$LKFLG        ; Store in the flag word
  3577.     MOVEI    S1,$LKLEN        ; Get the length
  3578.     MOVEI    S2,WLD            ; And the argument block
  3579.     $CALL    LOKWLD##        ; Look for the file.
  3580.     JUMPF    OPNRE0            ; Failed, process error
  3581.  
  3582. ; Here if we have the a file from the remote
  3583.  
  3584.     MOVEI    S1,FIL            ; Get the channel number
  3585.     STORE    S1,FLP+.FOFNC,FO.CHN    ; Store it
  3586.     MOVEI    S1,.FORED        ; Get the function
  3587.     STORE    S1,FLP+.FOFNC,FO.FNC    ; Store the function
  3588.     MOVX    S1,FO.PRV        ; Use privs
  3589.     IORM    S1,FLP+.FOFNC        ; Light the bit
  3590.  
  3591.     MOVEI    S1,FLP+.FOIOS        ; Point to the open block
  3592.     DEVSIZ    S1,            ; Attempt to determine the size
  3593.       JRST    [KERERR(<DEVSIZ UUO failure (^D/S1/)>)
  3594.         BLSRET    RMS32]            ; Error return
  3595.     HLRZ    S2,S1            ; Get the number of buffers
  3596.     MOVEI    S1,(S1)            ; Get the buffer size
  3597.     IMULI    S1,(S2)            ; Compute the total size
  3598.     MOVEM    S1,FBFSIZ        ; Store it
  3599.     $CALL    M%GMEM            ; Allocate the memory
  3600.      JUMPF    [KERERR(<^E/S1/>)    ; Output the error
  3601.         BLSRET    RMS32]        ; Return the failure
  3602.     MOVEM    S2,FBFADR        ; Store the address
  3603.     EXCH    S2,.JBFF        ; Exchange with the first free
  3604.     MOVX    S1,<XWD .FOMAX,FLP>    ; Point to the argument block
  3605.     FILOP.    S1,            ; Attempt to read the file
  3606.       JRST    OPNRE1            ; Failed, try again
  3607.  
  3608.     SKIPGE    P1            ;[130] Skip if first pass
  3609.     $TEXT    (,<Sending: ^A>)    ;[130] Give prompt
  3610.     MOVEM    S2,.JBFF        ; Store .JBFF back
  3611.     MOVE    S1,[POINT 7,FILE%NAME##] ; Point to the file name
  3612.     MOVEM    S1,FILPTR        ; Store the byte pointer
  3613.     SETOM    FILE%SIZE##        ; Clear the count
  3614.     MOVE    S2,FIL%NORMAL%FORM##    ; Get name type
  3615.     CAIE    S2,FNM%FULL##        ; Full file specs?
  3616.      JRST    OPNRE8            ; No, use short name
  3617.     $TEXT    (FILSTO,<^W/FLP+.FODEV/:^W/ELB+.RBNAM/.^W/ELB+.RBEXT,LHMASK/^A>)
  3618.     SKIPN    FPTH+.PTPPN        ; Is there a PPN?
  3619.       JRST    OPNRE5            ; No, finish up and return
  3620.     $TEXT    (FILSTO,<[^O/FPTH+.PTPPN,LHMASK/,^O/FPTH+.PTPPN,RHMASK/^A>)
  3621.     MOVSI    S1,-5            ; Get the number of SFDs possible
  3622. OPNRE6:    SKIPN    FPTH+.PTSFD(S1)        ; Finished?
  3623.      JRST    OPNRE7            ; Yes, close off
  3624.     $TEXT    (FILSTO,<,^W/FPTH+.PTSFD(S1)/^A>) ; Type the SFD
  3625.     AOBJN    S1,OPNRE6        ; Loop for all SFDs
  3626. OPNRE7:    $TEXT    (FILSTO,<]^A>)        ; Type the closing bracket
  3627. OPNRE5:    $TEXT    (FILSTO,<^0>)        ; Store final null
  3628.     JRST    OPNRE9            ; And go set up pointers
  3629.  
  3630. OPNRE8:    $TEXT    (FILSTO,<^W/ELB+.RBNAM/.^W/ELB+.RBEXT,LHMASK/^0>)
  3631.  
  3632. ; Now set up the correct size byte pointers.
  3633.  
  3634. OPNRE9:    MOVE    S2,FILTYP        ; Get the file type
  3635.     CAXE    S2,$FBAUT        ; Automatic?
  3636.      JRST    OPNRE2            ; No, use what was set
  3637.     LOAD    S1,ELB+.RBPRV,RB.MOD    ; Get the mode the file was written in
  3638.     CAXE    S1,.IOIMG        ; Image?
  3639.      CAXN    S1,.IOIBN        ; Or image binary?
  3640.       MOVX    S2,$FBS8        ; Yes, 8-bit
  3641.     CAXE    S1,.IOBIN        ; Binary?
  3642.      CAXN    S1,.IODPR        ; Or dump record?
  3643.       MOVX    S2,$FBS8        ; Yes, 8-bit
  3644. OPNRE2:    MOVEM    S2,CURFTP        ; Save the file type for this file
  3645.     MOVX    S1,<POINT 7,,34>    ; Assume ASCII files
  3646.     CAXN    S2,$FBS8        ; Is it ASCII?
  3647.      MOVX    S1,<POINT 8,,31>    ; No, use 8 bit
  3648.     HLLM    S1,BH+.BFPTR        ; Store in the pointer
  3649.  
  3650.     $CALL    T$LOCAL            ; Check if local
  3651.      JUMPT    [BLSRET    NORMAL]        ; If no terminal, just return
  3652.     MOVE    S1,TY%FIL##        ; Get the type file flag
  3653.     TXNN    S1,BLSTRU        ; Want type out?
  3654.      BLSRET    NORMAL            ; Give a good return
  3655.     MOVEI    S1,[ASCIZ ||]        ; Get the text
  3656.     $CALL    TYPFIL            ; Type the file specification
  3657.     $TEXT    (,< as ^A>)        ; Say what we send it out as
  3658.     BLSRET    NORMAL            ; Give a good return
  3659.  
  3660. ; Here if there were no files
  3661.  
  3662. OPNRE0:    JUMPN    P1,[BLSRET NOMORFILES]    ; Flag no more and return
  3663.     KERERR    (<No such files as ^F/FX/>)
  3664.     BLSRET    RMS32            ; Give a failure
  3665.  
  3666. ; Here if the FILOP. failed.
  3667.  
  3668. OPNRE1:    PUSH    P,S1            ; Save the error code
  3669.     MOVE    S1,FBFSIZ        ; Get the size of the buffers
  3670.     MOVE    S2,FBFADR        ; Get the address of them
  3671.     $CALL    M%RMEM            ; Return the memory
  3672.     POP    P,S1            ; Restore S1
  3673.     KERERR    (<^T/FILERR##(S1)/ - ^F/FX/>)
  3674.     BLSRET    RMS32            ; Give the failure return
  3675. >; End of TOPS10 conditional
  3676.     SUBTTL    File processing -- Routine to type the file specification
  3677.  
  3678. ;+
  3679. ;.hl1 TYPFIL
  3680. ;This routine will type the file specification that we are processing
  3681. ;on the user's terminal.  It will output the text passed to this routine
  3682. ;first.  Type out will only happen if we are using a different terminal
  3683. ;line other than the controlling terminal.
  3684. ;.literal
  3685. ;
  3686. ; Usage:
  3687. ;    MOVEI    S1,[ASCIZ |Text|]
  3688. ;    $CALL    TYPFIL
  3689. ;    (Return)
  3690. ;
  3691. ;.end literal
  3692. ;-
  3693.  
  3694. TYPFIL:    $SAVE    <P1>            ; Save a registers
  3695.     MOVE    P1,S1            ; Copy the text
  3696.     $CALL    T$LOCAL            ; Are we connected to a different line?
  3697.      $RETIT                ; If nowhere to type, just return
  3698.     $TEXT    (,<^T/(P1)/^W/FLP+.FODEV/:^W/ELB+.RBNAM/.^W/ELB+.RBEXT,LHMASK/^A>)
  3699.     SKIPN    FPTH+.PTPPN        ; Is there a PPN?
  3700.       JRST    TYPF.0            ; No, finish up and return
  3701.     $TEXT    (,<[^O/FPTH+.PTPPN,LHMASK/,^O/FPTH+.PTPPN,RHMASK/^A>)
  3702.     MOVSI    S1,-5            ; Get the number of SFDs possible
  3703. TYPF.2:    SKIPN    FPTH+.PTSFD(S1)        ; Finished?
  3704.      JRST    TYPF.1            ; Yes, close off
  3705.     $TEXT    (,<,^W/FPTH+.PTSFD(S1)/^A>) ; Type the SFD
  3706.     AOBJN    S1,TYPF.2        ; Loop for all SFDs
  3707. TYPF.1:    $TEXT    (,<]^A>)        ; Type the closing bracket
  3708.  
  3709. TYPF.0:    $RETT                ; Return to the caller
  3710.     SUBTTL    Routine to setup FILOP/ELB/PATH blocks
  3711.  
  3712. ;+
  3713. ;.HL1 SETFLP
  3714. ;This routine will clear and initialize the FILOP. block.
  3715. ;.literal
  3716. ;
  3717. ; Usage:
  3718. ;    S1/ -1 for output, 0 for input
  3719. ;    $CALL    SETFLP
  3720. ;    (Return)
  3721. ;
  3722. ;.end literal
  3723. ;-
  3724.  
  3725. TOPS10<
  3726. SETFLP:    $SAVE    <P1>            ; Save the flag
  3727.     MOVE    P1,S1            ; Copy the flag
  3728.     MOVEI    S1,.FOMAX        ; Get the length
  3729.     MOVEI    S2,FLP            ; Get the address
  3730.     $CALL    .ZCHNK            ; Clear the block
  3731.     MOVEI    S1,.PTMAX        ; Get the length
  3732.     MOVEI    S2,PTH            ; Get the address
  3733.     $CALL    .ZCHNK            ; Clear the block
  3734.     MOVEI    S1,.RBMAX        ; Get the length
  3735.     MOVEI    S2,ELB            ; Get the address
  3736.     $CALL    .ZCHNK            ; Clear the block
  3737.  
  3738.     MOVX    S1,.RBMAX        ; Get the length
  3739.     MOVEM    S1,ELB+.RBCNT        ; Store it
  3740.     MOVEI    S1,PTH            ; Get the PATH block address
  3741.     MOVEM    S1,ELB+.RBPPN        ; Store it
  3742.     MOVEI    S1,ELB            ; Point to the LOOKUP/ENTER block
  3743.     MOVEM    S1,FLP+.FOLEB        ; Store it
  3744.     MOVE    S1,[XWD .PTMAX,FPTH]    ; Get the file found in path block
  3745.     MOVEM    S1,FLP+.FOPAT        ; Store it for later
  3746.     MOVEI    S1,BH            ; Get the buffer header address
  3747.     SKIPGE    P1            ; Output?
  3748.      MOVSS    S1            ; Yes, move to the other half
  3749.     MOVEM    S1,FLP+.FOBRH        ; Store the buffer header
  3750.     SKIPL    P1            ; Input?
  3751.      HLLOS    FLP+.FONBF        ; Yes, set default number of buffers
  3752.     SKIPGE    P1            ; Output?
  3753.      HRROS    FLP+.FONBF        ; Yes, set the other way
  3754.     MOVE    S1,FILTYP        ; Get the file type
  3755.     CAXE    S1,$FBS8        ; 8-bit?
  3756. IFE .IOASC,<TDZA S1,S1>            ; No, use ascii
  3757. IFN .IOASC,<SKIPA S1,[EXP .IOASC]>    ; No, use ascii
  3758.      MOVX    S1,.IOBIN        ; Get the mode
  3759.     MOVEM    S1,FLP+.FOIOS        ; Store the status
  3760.     $RET                ; Return to the caller
  3761. >; End of TOPS10 conditional
  3762.     SUBTTL    File processing -- Routine to convert FX blocks
  3763.  
  3764. ;.STOPB -- ROUTINE TO TURN SCAN BLOCK INTO OPEN/LOOKUP BLOCKS
  3765. ;  WILD-CARDS ARE ILLEGAL
  3766. ;CALL:    MOVEI    T1,SCAN BLOCK
  3767. ;        LH(T1)=LENGTH IF .GT. 24
  3768. ;    MOVEI    T2,OPEN BLOCK (3 WORDS)
  3769. ;    MOVEI    T3,LOOKUP BLOCK (6 WORDS OR MORE)
  3770. ;        LH(T3)=LENGTH IF .GT. 6
  3771. ;    MOVEI    T4,PATH BLOCK (9 WORDS)
  3772. ;    PUSHJ    P,.STOPB
  3773. ;ERROR RETURN IF WILD-CARDS
  3774. ;SKIP RETURN IF SETUP OK
  3775. ;USES T1-4
  3776.  
  3777. TOPS10<
  3778. .STOPB:    $SAVE    <P1,P2,P3>        ; Save a few registers
  3779.     SKIPN    P3,.FDSTR(T1)        ;GET DEVICE
  3780.       MOVSI    P3,'DSK'        ;DEFAULT IF BLANK
  3781.     MOVEM    P3,1(T2)        ;STORE IN OPEN BLOCK
  3782.     MOVE    P1,.FDMOD(T1)        ;GET SWITCHES
  3783.     HRRZS    (T2)            ; Clear left half of first word
  3784.     SKIPE    P3,.FDNAM(T1)        ;IF NAME NOT BLANK,
  3785.     SETCM    P3,.FDNMM(T1)        ;GET NAME MASK
  3786.     JUMPN    P3,.POPJ##        ;ERROR IF WILD
  3787.     MOVE    P3,.FDNAM(T1)        ;GET NAME
  3788.     MOVEM    P3,.RBNAM(T3)        ;STORE IN LOOKUP BLOCK
  3789.     SKIPN    P3,.FXEXT(T1)        ;GET EXTENSION
  3790.       JRST    STOP.0            ; Ok, skip this
  3791.     AND    P3,.FDEXM(T1)        ; AND with the mask
  3792.     CAME    P3,.FDEXT(T1)        ; Still the same
  3793.       POPJ    P,            ; No, fail
  3794. STOP.0:    MOVEM    P3,.RBEXT(T3)        ;STORE IN LOOKUP BLOCK
  3795.     MOVEI    P3,0            ;CLEAR DIRECTORY
  3796.     MOVX    P1,FD.DIR        ;GET DIRECTORY BIT
  3797.     TDNN    P1,.FDMOD(T1)        ;SEE IF SET
  3798.     JRST    STOPND            ;NO--USE [-]
  3799.     SETCM    P3,.FDDIM(T1)        ;GET UFD MASK
  3800.     JUMPN    P3,.POPJ##        ;ERROR IF WILD
  3801.     MOVE    P3,.FDPPN(T1)        ;GET UFD
  3802.     TLNN    P3,-1            ;SEE IF PROJECT
  3803.     HLL    P3,.MYPPN        ;NO--USE LOGGED IN NUMBER
  3804.     TRNN    P3,-1            ;SEE IF PROGRAMMER
  3805.     HRR    P3,.MYPPN        ;NO--USE LOGGED IN NUMBER
  3806.     MOVEM    P3,.FDPPN(T1)        ;STORE FOR ERROR MESSAGES
  3807.     SKIPN    .FDPAT(T1)        ;SEE IF SFDS
  3808.     JRST    STOPND            ;NO--GO STORE AND RETURN
  3809.     SETZM    (T4)            ;CLEAR PATH
  3810.     HRLZI    P1,(T4)            ; ..
  3811.     HRRI    P1,1(T4)        ; ..
  3812.     BLT    P1,.PTMAX-1(T4)        ; ..
  3813.     MOVEM    P3,.PTPPN(T4)        ;STORE UFD
  3814.     MOVEI    P1,.FDPAT(T1)        ;POINT TO ARGUMENT SFD
  3815.     MOVSI    P2,-D$MSFD+1        ;COUNT SFDS
  3816.     HRRI    P2,(T4)            ;INDICATE START OF SFD BLOCK
  3817. STOPNS:    SKIPN    P3,(P1)            ;SEE IF DONE
  3818.     JRST    STOPNT            ;YES--FINISH UP
  3819.     MOVEM    P3,.PTPPN+1(P2)     ;NO--STORE IN PATH
  3820.     SETCM    P3,.FDD2M(P1)        ;GET MASK
  3821.     JUMPN    P3,.POPJ##        ;ERROR IF WILD
  3822.     AOJ    P1,            ; Advane to the next
  3823.     AOBJN    P2,STOPNS        ;LOOP UNTIL DONE
  3824. STOPNT:    MOVEI    P3,(T4)            ;INDICATE SFD
  3825. STOPND:    MOVEM    P3,.RBPPN(T3)        ;SET INTO LOOKUP
  3826.     JRST    .POPJ1##        ;SKIP RETURN
  3827. >; End of TOPS10 conditional
  3828.     SUBTTL    File processing -- FILE%CLOSE
  3829.  
  3830. ;+
  3831. ;.hl1 FILE%CLOSE
  3832. ;This routine will close the file that is currently open.
  3833. ;-
  3834.  
  3835. BLSRTN(FILE%CLOSE,<ABTFLG>)
  3836.     $SAVE    <TF,S2>            ; Save a few registers
  3837.     MOVE    S2,ABTFLG        ; Get the abort flag
  3838.     MOVEI    S1,FIL            ; Get the channel
  3839.     TXNN    S2,BLSTRU        ; Want to punt file?
  3840.      JRST    FILCL2            ; No, go close it
  3841.     RESDV.    S1,            ; Kill the channel
  3842.      JFCL                ; Ignore error
  3843.     JRST    FILCL3            ; Go return buffer space
  3844.  
  3845. ; Here if we want to close the file normally
  3846.  
  3847. FILCL2:    RELEASE    FIL,            ; Release the file channel (OK if already RESDV.'ed)
  3848.  
  3849. FILCL3:    MOVE    S1,FBFSIZ        ; Get the size of the buffers
  3850.     MOVE    S2,FBFADR        ; Get the address of them
  3851.     $CALL    M%RMEM            ; Return the memory to the OTS
  3852.     BLSRET    NORMAL            ; Give a good return
  3853.     SUBTTL    File processing -- NEXT%FILE
  3854.  
  3855. ;+
  3856. ;.hl1 NEXT%FILE
  3857. ;This routine will advance to the wild card file.
  3858. ;-
  3859.  
  3860. BLSRTN(NEXT%FILE)
  3861.     $SAVE    <S2,TF>            ; Save some registers
  3862.     $SAVE    <T1,T2,T3,T4>        ; That will be used
  3863.     $SAVE    <P1>            ; Save the flag
  3864.     SETO    P1,            ; Flag from here
  3865.     PJRST    OPNREA            ; Open attempting to read the next file
  3866.     SUBTTL    File processing -- GET%FILE - Get a byte
  3867.  
  3868. ;+
  3869. ;.hl1 GET%FILE(Character)
  3870. ;This routine will input a character from the file.  It will then store
  3871. ;the character in the address that is passed to it.
  3872. ;.literal
  3873. ;
  3874. ; Usage:
  3875. ;    GET%FILE (Character);
  3876. ;
  3877. ;.end literal
  3878. ;-
  3879.  
  3880. BLSRTN(GET%FILE,<CHARACTER>)
  3881. TOPS10<
  3882.  
  3883. GETFI2:    SOSGE    BH+.BFCNT        ; Decrement the count
  3884.       JRST    GETFI0            ; Need a new buffer
  3885.     ILDB    S1,BH+.BFPTR        ; Get a character
  3886.     MOVEM    S1,@CHARACTER        ; Store the character
  3887.     MOVE    S1,CURFTP        ; Get the file type
  3888.     CAXE    S1,$FBS36        ;[127][MF] Is this 36 bit?
  3889.      BLSRET    NORMAL            ; Give a good return
  3890.     MOVE    S1,BH+.BFPTR        ; Get the buffer pointer
  3891.     TXNE    S1,<FLD(76,BP.POS)>    ; Is this the end?
  3892.      BLSRET    NORMAL            ; No, just return
  3893.     MOVE    S1,@BH+.BFPTR        ; Get the full work
  3894.     TRNN    S1,1            ; LSA bit on?
  3895.      BLSRET    NORMAL            ; No, just return
  3896.     MOVX    S1,200            ; Turn on the high order bit
  3897.     IORM    S1,@CHARACTER        ; . . .
  3898.     BLSRET    NORMAL            ; And return to the caller
  3899.  
  3900. ; Here to get a new buffer
  3901.  
  3902. GETFI0:    IN    FIL,            ; Get the next buffer
  3903.       JRST    GETFI2            ; Loop
  3904.     GETSTS    FIL,S1            ; Get the status
  3905.     TXNN    S1,IO.EOF        ; End of file?
  3906.       JRST    GETFI1            ; No, an error
  3907.     BLSRET    EOF            ; Yes, return end of file
  3908.  
  3909. GETFI1:    KERERR    (<Input error, status = ^O60/S1/>)
  3910.     BLSRET    RMS32            ; Close enough
  3911.  
  3912. >; End of TOPS10 conditional
  3913.     SUBTTL    File processing -- PUT%FILE - Store a byte
  3914.  
  3915. ;+
  3916. ;.hl1 PUT%FILE(Character)
  3917. ;This routine will store a character into the file.  It will then
  3918. ;return to the caller.
  3919. ;.literal
  3920. ;
  3921. ; Usage:
  3922. ;    PUT%FILE(Character);
  3923. ;
  3924. ;.end literal
  3925. ;-
  3926.  
  3927. BLSRTN(PUT%FILE,<CHARACTER>)
  3928.     $SAVE    <S2>            ; Save a register
  3929. TOPS10<
  3930. PUTFI1:    SOSGE    BH+.BFCNT        ; Decrement the count
  3931.       JRST    PUTFI0            ; Need to dump the buffer
  3932.     MOVE    S1,CHARACTER        ; Get the character
  3933.     IDPB    S1,BH+.BFPTR        ; Store the character
  3934.     MOVE    S2,FILTYP        ; Get the file type
  3935.     CAXN    S2,$FBS36        ;[127][MF] 36 bit?
  3936.      TRNN    S1,200            ;[MF] Yes, is the high order bit on?
  3937.       BLSRET NORMAL            ; No, Give a good return
  3938.     MOVX    S2,<FLD(76,BP.POS)>    ; Is this word aligned?
  3939.     TDNE    S2,BH+.BFPTR        ; . . .
  3940.      BLSRET    NORMAL            ; No, just return
  3941.     MOVEI    S1,1            ; Yes, light the LSA bit
  3942.     IORM    S1,@BH+.BFPTR        ; in the output
  3943.     BLSRET    NORMAL            ; Just return
  3944.  
  3945. ; Here to dump the buffer into the file.
  3946.  
  3947. PUTFI0:    OUT    FIL,            ; Dump the buffer
  3948.       JRST    PUTFI1            ; Adjust the buffer header
  3949.     GETSTS    FIL,S1            ; Get the status, it failed
  3950.     KERERR    (<Output error, status = ^O60/S1/>)
  3951.     BLSRET    RMS32            ; Close enough
  3952.     SUBTTL    Support routines -- PRSFIL - Parse a file specification
  3953.  
  3954. ;+
  3955. ;.hl1 PRSFIL
  3956. ;This routine will parse a file specification.  Is assumes that the file
  3957. ;specification is in the following format:
  3958. ;.literal
  3959. ;
  3960. ;    Device:File.Extension[Path]
  3961. ;
  3962. ;.en literal
  3963. ;This routine will accept wild cards in the file names, extensions and the
  3964. ;path specification.
  3965. ;.literal
  3966. ;
  3967. ; Usage:
  3968. ;    S1/ Byte pointer to the string
  3969. ;    S2/ Address to store the information in
  3970. ;    $CALL    PRSFIL
  3971. ;    (Return)
  3972. ;
  3973. ; On a true return:
  3974. ;    - The file specification parsed correctly
  3975. ;
  3976. ; On a false return:
  3977. ;    - Invalid file specification
  3978. ;
  3979. ;.end literal
  3980. ;-
  3981.  
  3982. TOPS10<
  3983. PRSFIL::$SAVE    <P1,P2>            ; Save two registers
  3984.     DMOVE    P1,S1            ; Copy the arguments
  3985.  
  3986.     MOVX    T1,.FDNAT        ; Get the type
  3987.     STORE    T1,.FDLEN(P2),FD.TYP    ; Store this
  3988.     MOVX    T1,.FDSIZ        ; Get the size
  3989.     STORE    T1,.FDLEN(P2),FD.LEN    ; Store this too
  3990.  
  3991.     $CALL    PRSWS$            ; Parse a sixbit item (with wilds)
  3992.     CAIE    S1,":"            ; Device delimiter?
  3993.       JRST    [MOVX    T3,<SIXBIT /DSK/>    ; Use disk
  3994.         MOVEM    T3,.FDSTR(P2)        ; Store it
  3995.         JRST    PRSF.5]            ; Continue processing
  3996.     MOVEM    T1,.FDSTR(P2)        ; Store the device name
  3997. PRSF.1:    $CALL    PRSWS$            ; Input the file name
  3998. PRSF.5:    CAIE    S1,.CHLAB        ; Start of directory?
  3999.      CAIN    S1,"["            ; Normal start of directory?
  4000.       JUMPE    T1,PRSF.4        ; Yes, go handle it if nothing before it
  4001.     MOVEM    T1,.FDNAM(P2)        ; Store the name
  4002.     MOVEM    T2,.FDNMM(P2)        ; And the mask
  4003.     JUMPE    S1,.RETT        ; End of the spec?
  4004.     CAIN    S1,"["            ; Is this a path?
  4005.       JRST    PRSF.4            ; Yes, go get it
  4006.     CAIE    S1,"."            ; Correct delimiter?
  4007.      JRST    PRSF.6            ; No, check for semi-colon (Files-11)
  4008.     $CALL    PRSWS$            ; No, get the extension
  4009.     ANDX    T1,LHMASK        ; Keep only three characters
  4010.     MOVEM    T1,.FDEXT(P2)        ; Store the extension
  4011.     MOVEM    T2,.FDEXM(P2)        ; Store the mask also
  4012.     JUMPE    S1,.RETT        ; End of the spec?
  4013.     CAIE    S1,.CHLAB        ; Also allow angle brackets (in case of dumb terminal)
  4014.      CAIN    S1,"["            ; Start of the path?
  4015.       JRST    PRSD.0            ; Yes, go handle it
  4016.  
  4017.     CAIE    S1,"."            ; Have another dot (TOPS-20)
  4018. PRSF.6:     CAIN    S1,";"            ; Or semi-colon (Files-11)?
  4019.       $RETT                ; Yes, return
  4020.     $RETF                ; No, bad file spec
  4021.  
  4022. ; Here if we have a directory before the file name
  4023.  
  4024. PRSF.4:    PUSHJ    P,PRSD.0        ; Get the directory
  4025.      $RETIF                ; If bad, just give up now
  4026.     JUMPE    S1,.RETT        ; If all done, just return
  4027.     JRST    PRSF.1            ; Otherwise, try again for file name
  4028.  
  4029. ; Here to parse the path specification.
  4030. ; The open bracket has already been read
  4031. ;
  4032. ; Usage:
  4033. ;    S1/ Byte pointer to text
  4034. ;    S2/ Address of FD
  4035. ;    $CALL    PRSDIR
  4036. ;
  4037. ; or
  4038. ;
  4039. ;    P1/ byte pointer to text
  4040. ;    P2/ Address of FD
  4041. ;    $CALL    PRSD.0
  4042. ;
  4043.  
  4044. PRSDIR::$SAVE    <P1,P2>            ; Save two registers
  4045.     DMOVE    P1,S1            ; Copy the arguments
  4046.     $CALL    INPCH$            ; Get a character
  4047.     CAIE    S1,"["            ; Open bracket?
  4048.      CAIN    S1,.CHLAB        ;  Other type?
  4049.       JRST    PRSD.0            ; Good bracket
  4050.        $RETF            ; Error return
  4051. PRSD.0:    MOVX    S2,FD.DIR        ; Get the directory specified bit
  4052.     TDNE    S2,.FDMOM(P2)        ; Directory given yet?
  4053.      TDNN    S2,.FDMOD(P2)        ;  .  .  .
  4054.       JRST    .+2            ; No, all is fine
  4055.        $RETF            ; Yes, punt
  4056.     IORM    S2,.FDMOD(P2)        ; Flag it
  4057.     IORM    S2,.FDMOM(P2)        ; . . .
  4058.     $CALL    PRSOC$            ; Input the programmer number
  4059.     TXNE    T1,LHMASK        ; Anything in the left half?
  4060.      JRST    PRSD.1            ; See if "[-]"
  4061.     HRLM    T1,.FDPPN(P2)        ; Store the directory
  4062.     HRLM    T2,.FDDIM(P2)        ; Store the mask too
  4063.     CAIE    S1,","            ; Good delimiter?
  4064.      $RETF                ; No, bad file spec
  4065.     $CALL    PRSOC$            ; Get the programmer number
  4066.     TXNE    T1,LHMASK        ; Is it valid?
  4067.      $RETF                ; No, very bad
  4068.     HRRM    T1,.FDPPN(P2)        ; Store the programmer number
  4069.     HRRM    T2,.FDDIM(P2)        ; And the mask
  4070.     JUMPE    S1,.RETT        ; If nothing else, just return
  4071.     CAIE    S1,.CHRAB        ; Allow angle bracket end
  4072.      CAIN    S1,"]"            ; Valid end?
  4073.       $RETT                ; Yes, all done with directory
  4074.     CAIE    S1,","            ; SFDs coming?
  4075.      $RETF                ; No, Give a failure return
  4076.  
  4077. ; Here to loop for all the Sub file directories
  4078.  
  4079.     $SAVE    <P2>            ; Save the pointer here
  4080.     HRLI    P2,-5            ; Make the AOBJN pointer
  4081.     ADDI    P2,.FDPAT        ; Point to the first SFD
  4082.  
  4083. PRSD.2:    $CALL    PRSWS$            ; Parse the SFD name
  4084.     MOVEM    T1,(P2)            ; Store the SFD name
  4085.     MOVEM    T2,.FDD2M(P2)        ; Store the mask also
  4086.     CAIE    S1,","            ; Delimited by a comma?
  4087.       JRST    PRSD.3            ; No, Try for other items
  4088.     AOBJN    P2,PRSD.2        ; Loop for all items
  4089.     $RETF                ; Too many SFDs
  4090.  
  4091. ; Here to check for default directory given by the user.
  4092.  
  4093. PRSD.1:    CAIE    S1,"-"            ; Use default?
  4094.       $RETF                ; No, error
  4095.     MOVX    S2,FD.DFX        ; Use default
  4096.     IORM    S2,.FDMOD(P2)        ; Light it
  4097.     IORM    S2,.FDMOD(P2)        ; . . .
  4098.     $CALL    INPCH$            ; Get the next character
  4099.  
  4100. PRSD.3:    JUMPE    S1,.RETT        ; If finished, just return
  4101.     CAIE    S1,"]"            ; Valid end?
  4102.      CAIN    S1,.CHRAB        ; . . .
  4103.       $RETT                ; Give a good return
  4104.     $RETF                ; No, Give a failure return
  4105. >; End of TOPS10 conditional
  4106.     SUBTTL    Support routines -- PRSSX$ - Parse a sixbit field
  4107.  
  4108. ;+
  4109. ;.hl1 PRSSX$
  4110. ;This routine will arse a non:wild sixbit field.  It will return the value
  4111. ;in T1.
  4112. ;.literal
  4113. ;
  4114. ; Usage:
  4115. ;    P1/ Byte pointer
  4116. ;    $CALL    PRSSX$
  4117. ;    (Return)
  4118. ;
  4119. ; On return:
  4120. ;    S1/ Delimiter character
  4121. ;    T1/ Sixbit token
  4122. ;
  4123. ;.end literal
  4124. ;-
  4125.  
  4126. TOPS10<
  4127. PRSSX$:    SETZ    T1,            ; Clear the destination
  4128.     MOVE    S2,[POINT 6,T1]        ; Gget the byte pointer
  4129.  
  4130. PRSS.0:    $CALL    INPCH$            ; Input a character
  4131.     $CALL    CHKAL$            ; Check to see if alphanumeric
  4132.     $RETIF                ; Return if it is not
  4133.     SUBI    S1,"A"-'A'        ; Convert to sixbit
  4134.     TRNN    T1,77            ; Finished?
  4135.      IDPB    S1,S2            ; No, Store the character
  4136.     JRST    PRSS.0            ; Loop for more
  4137. >; End of TOPS10 conditional
  4138.     SUBTTL    Support routines -- PRSWS$ - Parse a wild sixbit field
  4139.  
  4140. ;+
  4141. ;.hl1 PRSWS$
  4142. ;This routine will parse a wild sixbit field.  It will only accept
  4143. ;the following types of wild cards:
  4144. ;.literal
  4145. ;    *    - All wild
  4146. ;    xxx*    - Remainder of the field wild
  4147. ;    XXX???    - Same as above
  4148. ;    XXX%%%    - Same as above
  4149. ;    XXX%XX    - Single wild character
  4150. ;    XXX?XX    - Same as above
  4151. ;
  4152. ; Usage:
  4153. ;    P1/ Byte pointer to the string to parse
  4154. ;    $CALL    PRSWS$
  4155. ;    (Return)
  4156. ;
  4157. ; On return:
  4158. ;    S1/ Delimiter character
  4159. ;    T1/ Sixbit token
  4160. ;    T2/ Mask for the item
  4161. ;
  4162. ;.end literal
  4163. ;-
  4164.  
  4165. TOPS10<
  4166. PRSWS$:    SETZ    T1,            ; Clear where we are storing them
  4167.     SETO    T2,            ; Assume not wild
  4168.     MOVE    T3,[POINT 6,T1]        ; Byte pointer to the name
  4169.     MOVE    T4,[POINT 6,T2]        ; And to the mask
  4170.  
  4171. PRSW.0:    $CALL    INPCH$            ; Input the first character
  4172.     $CALL    CHKAL$            ; Check to see if alphanumeric
  4173.      JUMPF    PRSW.1            ; See if a wild card
  4174.     MOVX    S2,-1            ; Get the mask to store
  4175. PRSW.3:    SUBI    S1,"A"-'A'        ; Convert to sixbit
  4176.     TRNE    T1,77            ; Finished?
  4177.       JRST    PRSW.0            ; Yes, loop eating characters
  4178.     IDPB    S1,T3            ; Store the character
  4179.     IDPB    S2,T4            ; Store the mask
  4180.     JRST    PRSW.0            ; Loop back for more characters
  4181.  
  4182. ; Here if the character is not an alphanumeric.  Check for single character
  4183. ; wild cards and the remainder of the word wildcards
  4184.  
  4185.  
  4186. PRSW.1:    CAIE    S1,"?"            ; Is it valid single character
  4187.      CAIN    S1,"%"            ;  wild card?
  4188.       SKIPA                ; Yes, Keep going
  4189.     JRST    PRSW.2            ; No, Try for full word
  4190.     SETZ    S2,            ; Clear the mask
  4191.     JRST    PRSW.3            ; Store the byte
  4192.  
  4193. ; Here if we are to check to see if the remainder of thw word is to be wild
  4194.  
  4195. PRSW.2:    CAIE    S1,"*"            ; Remainder wild?
  4196.      JRST    PRSW.5            ; Go skip bad characters
  4197.     MOVEI    S1,'*'            ; Make it a sixbit *
  4198.     TXNE    T3,BP.POS        ; Filled?
  4199.      IDPB    S1,T3            ; No, Store the wild character
  4200.     SETZ    S1,            ; Clear the character
  4201.     TXNE    T4,BP.POS        ; Done?
  4202. PRSW.4:     IDPB    S1,T4            ; No, clear the mask character
  4203.     TXNE    T4,BP.POS        ; Done yet?
  4204.      JRST    PRSW.4            ; No, keep clearing things
  4205.     $CALL    INPCH$            ; Get the next character
  4206.                     ; And eat any extra characters
  4207.  
  4208. ; Here for a character which is not a valid part of a sixbit thing.
  4209. ;We will skip any characters which are not break characters for some field
  4210. ;of the filename.
  4211.  
  4212. PRSW.5:    JUMPE    S1,.RETT        ; If null, all done
  4213.     CAIE    S1,"["            ; Open bracket?
  4214.      CAIN    S1,"]"            ; Or close?
  4215.       $RETT                ; Yes, just return
  4216.     CAIE    S1,"."            ; Start of extension?
  4217.      CAIN    S1,","            ; Or directory element delimeter?
  4218.       $RETT                ; Yes, good break character
  4219.     CAIN    S1,":"            ; End of device name?
  4220.      $RETT                ; Yes, return now
  4221.     JRST    PRSW.0            ; And try again
  4222. >; End of TOPS10 conditional
  4223.     SUBTTL    Support routines -- CHKAL$ - Check for alphanumeric
  4224.  
  4225. ;+
  4226. ;.hl1 CHKAL$
  4227. ;This routine will check to see if the character specified is an alphanumeric
  4228. ;character.
  4229. ;.literal
  4230. ;
  4231. ; Usage:
  4232. ;    S1/ Character to check
  4233. ;    $CALL    CHKAL$
  4234. ;    (Return)
  4235. ;
  4236. ; On a true return:
  4237. ;    S1/ Upper case A to Z or 0 to 9.
  4238. ;
  4239. ; On a false return:
  4240. ;    S1/ Non-alphanumeric character
  4241. ;
  4242. ;.end literal
  4243. ;-
  4244.  
  4245. TOPS10<
  4246. CHKAL$:    CAIL    S1,"0"            ; Numeric?
  4247.      CAILE    S1,"9"            ; . . .
  4248.       SKIPA                ; No, Continue
  4249.     $RETT                ; Yes, Give a true return
  4250.  
  4251.     CAIL    S1,"A"            ; Upper case?
  4252.      CAILE    S1,"Z"            ; . . .
  4253.       SKIPA                ; No, Continue
  4254.     $RETT                ; Yes, Give a good return
  4255.  
  4256.     CAIL    S1,"a"            ; Lower case?
  4257.      CAILE    S1,"z"            ; . . .
  4258.       $RETF                ; No, Give a failure return
  4259.     MOVEI    S1,"A"-"a"(S1)        ; Convert to upper case
  4260.     $RETT                ; Give a good return
  4261. >; End of TOPS10 conditional
  4262.     SUBTTL    Support routines -- PRSOC$ - Parse a wild octal number
  4263.  
  4264. ;+
  4265. ;.hl1 PRSOC$
  4266. ;This routine will parse a wild octal number.  It will accept either
  4267. ;question mark (?) or percent sign (%) as the single wild card characters.
  4268. ;.literal
  4269. ;
  4270. ; Usage:
  4271. ;    P1/ Byte pointer
  4272. ;    $CALL    PRSOC$
  4273. ;    (Return)
  4274. ;
  4275. ; On return:
  4276. ;    T1/ Number (Right half only)
  4277. ;    T2/ Mask
  4278. ;
  4279. ;.end literal
  4280. ;-
  4281.  
  4282. TOPS10<
  4283. PRSOC$:    SETZB    T1,T2            ; Clear the number and the mask
  4284.     $CALL    INPCH$            ; Get the first character
  4285.     CAIN    S1,"*"            ; Full wild-card?
  4286.      $RETT                ; Yes, all done
  4287.     SOJA    T2,PRSO.3        ; No, go check other possibilities
  4288.  
  4289. PRSO.0:    $CALL    INPCH$            ; Get a character
  4290. PRSO.3:    CAIL    S1,"0"            ; Within range?
  4291.      CAILE    S1,"7"            ; . . .
  4292.       JRST    PRSO.1            ; No, check for wilds
  4293.     MOVX    S2,7            ; Flag not wild
  4294.  
  4295. PRSO.2:    LSH    T1,3            ; Move this over a digit
  4296.     LSH    T2,3            ; And the mask
  4297.     ADDI    T1,-"0"(S1)        ; Fill in this character
  4298.     TDO    T2,S2            ; Get the mask item
  4299.     JRST    PRSO.0            ; Loop for all the digits
  4300.  
  4301. PRSO.1:    CAIE    S1,"?"            ; Question mark?
  4302.      CAIN    S1,"%"            ; Or a percent?
  4303.       SKIPA                ; Yes, Continue
  4304.     $RETT                ; No, Return to the user
  4305.  
  4306.     SETZ    S2,            ; Clear the mask item
  4307.     MOVEI    S1,"0"            ; Use a zero
  4308.     JRST    PRSO.2            ; Loop all digits
  4309. >; End of TOPS10 conditional
  4310.     SUBTTL    Support routines -- INPCH$ - Input a character
  4311.  
  4312. ;+
  4313. ;.hl1 INPCH$
  4314. ;This routine will input a single character.  It will cause any extranous
  4315. ;bits to be remoted.  It will return the character in S1.
  4316. ;.literal
  4317. ;
  4318. ; Usage:
  4319. ;    P1/ Byte pointer
  4320. ;    $CALL    INPCH$
  4321. ;    (Return)
  4322. ;
  4323. ; On a true return:
  4324. ;    S1/ Character input
  4325. ;
  4326. ; On a false return:
  4327. ;    S1/ Null
  4328. ;
  4329. ;.end literal
  4330. ;-
  4331.  
  4332. TOPS10<
  4333. INPCH$:    ILDB    S1,P1            ; Get a character
  4334.     ANDX    S1,177            ; Clear the junk
  4335.     JUMPE    S1,.RETF        ; Return if this is zero
  4336.     $RETT                ; Give a good return
  4337. >; End of TOPS10 conditional
  4338.     SUBTTL    Packet count processing -- XFR%STATUS
  4339.  
  4340. ;+
  4341. ;.hl1 XFR%STATUS
  4342. ;This routine will handle the status that must be displayed on the user
  4343. ;terminal for the udpated counts of the packets and NAKs.
  4344. ;.LITERAL
  4345. ;
  4346. ; Usage:
  4347. ;    XFR_STATUS (Type, Sub-type);
  4348. ;
  4349. ;.end literal
  4350. ;.ls
  4351. ;.LE;Type - "S" or "R" for either Send or Receive.
  4352. ;.LE;Sub-type - "P" or "N" for either packet or NAK.
  4353. ;.els
  4354. ;-
  4355.  
  4356. BLSRTN(XFR%STATUS,<SUBTYPE,TYPE>)
  4357.     $SAVE    <TF,S1,S2>        ; Save a few registers
  4358.     $SAVE    <T1,T2,T3,T4>        ; . . .
  4359.     $CALL    T$LOCAL            ; Is this a local terminal?
  4360.       $RETIT            ; No, just skip this
  4361.  
  4362.     MOVE    TF,TY%PKT##        ; Want to type the packet information?
  4363.     TXNN    TF,BLSTRU        ; Want type out?
  4364.      $RETT                ; No, all done
  4365.  
  4366.     MOVE    T1,SUBTYPE        ; Get the sub type
  4367.     MOVEI    S1,0            ; Assume send packet
  4368.     CAIN    T1,"N"            ; Is this a NAK?
  4369.      MOVEI    S1,1            ; Yes, use NAK offset
  4370.     MOVE    T1,TYPE            ; Get the type now
  4371.     CAIN    T1,"R"            ; Is this receive
  4372.       MOVEI    S1,2(S1)        ; Yes, add in the other offset
  4373.     $TEXT    (,< ^T/PKTTXT(S1)/^D/@PKTCNT(S1)/^A>)
  4374.     $RET                ; Just return to the caller
  4375.  
  4376. DEFINE    PKTITM,<
  4377. PKT    S,SND%COUNT##
  4378. PKT    SN,SMSG%NAK##
  4379. PKT    R,RCV%COUNT##
  4380. PKT    RN,RMSG%NAK##
  4381. >; End of PKTITM
  4382.  
  4383. DEFINE    PKT(A,B)<ASCII /A/>
  4384. PKTTXT:    PKTITM
  4385. DEFINE    PKT(A,B)<EXP    B>
  4386. PKTCNT:    PKTITM
  4387.     SUBTTL    Terminal processing -- Message routines -- Initialization
  4388.  
  4389. ;+
  4390. ;.hl1 INITRM
  4391. ;This routine will initialize the terminal processing.  It will get the
  4392. ;line number for the command terminal.
  4393. ;.literal
  4394. ;
  4395. ; Usage:
  4396. ;    $CALL    INITRM
  4397. ;    (Return)
  4398. ;
  4399. ;
  4400. ; On a true return:
  4401. ;    - Terminal line number set up
  4402. ;
  4403. ;.end literal
  4404. ;-
  4405.  
  4406. INITRM:    MOVX    S2,JI.TNO        ; Get terminal number
  4407.     SETO    S1,            ;  for this job
  4408.     $CALL    I%JINF            ; Get it
  4409. TOPS20<
  4410.     MOVEM    S2,XFRTRM+$TTLIN    ; Store the line to use
  4411.     MOVEM    S2,MYTERM+$TTLIN    ; Store here also
  4412. >; End of TOPS20 conditional
  4413. TOPS10<
  4414.     PUSH    P,S2            ; Save this
  4415.     $TEXT    (<-1,,.TEMP>,<TTY^O/S2/^0>) ; Get the text
  4416.     HRROI    S1,.TEMP        ; Point to the location
  4417.     $CALL    S%SIXB            ; Convert to sixbit
  4418.     MOVEM    S2,MYTERM+$TTDEV    ; Store here
  4419.     MOVEM    S2,XFRTRM+$TTDEV    ; And also here
  4420.     POP    P,S2            ; Restore S2
  4421.     ADDI    S2,.UXTRM        ; Convert to a UDX
  4422.     GTNTN.    S2,            ; Get the node and line number
  4423.      SUBI    S2,.UXTRM        ; Can only fail because no network support
  4424.     HRRZM    S2,XFRTRM+$TTLIN    ; Store the line number
  4425.     HLRZM    S2,XFRTRM+$TTNOD    ; Store the node number
  4426.     HRRZM    S2,MYTERM+$TTLIN    ; Store the line number
  4427.     HLRZM    S2,MYTERM+$TTNOD    ; Store the node number
  4428.  
  4429.     MOVX    S1,%CNTIC        ; Get the number of jiffies per second
  4430.     GETTAB    S1,            ; From the monitor
  4431.       MOVX    S1,^D60            ; Assume 60
  4432.     MOVEM    S1,JIFSEC        ; Store for later use
  4433.  
  4434. ; Now check if we have a logical device KERMIT:.  If we do, that is our default
  4435. ;transfer device.
  4436.  
  4437.     MOVX    S1,<SIXBIT |KERMIT|>    ; Get the name
  4438.     DEVNAM    S1,            ; Check if it exists
  4439.      JRST    INIT.1            ; No, leave things as they are
  4440.     MOVE    S2,S1            ; Get a copy
  4441.     DEVCHR    S2,            ; Make sure it is a terminal
  4442.     TXNN    S2,DV.TTY        ; Is it?
  4443.      JRST    [$KERR (Device KERMIT: is not a terminal, using TTY: instead)
  4444.         JRST    INIT.1]        ; Just continue using console
  4445.     MOVEM    S1,XFRTRM+$TTDEV    ; And also here
  4446.     IONDX.    S1,            ; Get the UDX for the terminal
  4447.      JRST    INIT.1            ; Should never fail, since DEVCHR worked
  4448.     GTNTN.    S1,            ; Get the node and line number
  4449.      SUBI    S1,.UXTRM        ; Can only fail because no network support
  4450.     HRRZM    S1,XFRTRM+$TTLIN    ; Store the line number
  4451.     HLRZM    S1,XFRTRM+$TTNOD    ; Store the node number
  4452. INIT.1:
  4453. >; End of TOPS10 conditional
  4454.  
  4455.     SETZM    LCLECH            ; Default is no local echo
  4456.     MOVX    S1,$XXDEF        ;[127] Get default for XON-XOFF
  4457.     MOVEM    S1,XXPMOD        ;[127] and store it
  4458.     $RETT                ; Return to the caller
  4459.     SUBTTL    Terminal processing -- Message routines -- Open the terminal
  4460.  
  4461. ;+
  4462. ;.hl1 OPNTRM
  4463. ;This routine will open the terminal that has been sepecified or the
  4464. ;the command terminal if none has been specified.
  4465. ;.literal
  4466. ;
  4467. ; Usage:
  4468. ;    $CALL    OPNTRM
  4469. ;    (Return)
  4470. ;
  4471. ; On a true return:
  4472. ;    - Terminal open
  4473. ;
  4474. ; On a false return:
  4475. ;    - Terminal not open, error message issued.
  4476. ;
  4477. ;.end literal
  4478. ;-
  4479.  
  4480. OPNTRM:
  4481. TOPS10<
  4482.     $SAVE    <P1>            ; Save P1
  4483.     MOVEI    P1,XFRTRM        ; Point to the transfer terminal info
  4484.     CLOSE    TTY,            ; Just close incase it was open
  4485.                     ; (KLUDGE, since we can not get the
  4486.                     ;  terminal number GLXLIB is using
  4487.                     ;  and we should process commands after
  4488.                     ;  a send/receive)
  4489.     MOVE    S1,P1            ; Get the address
  4490.     $CALL    T$OPEN            ; Open the terminal
  4491.     $RETIF                ; Return if that failed
  4492.  
  4493.     MOVE    S1,RCV%EOL##        ; Get the end of line character
  4494.     MOVE    S2,S1            ; Get a copy
  4495.     LSH    S2,^D9            ; Up nine bits
  4496.     TRO    S1,^O200(S2)        ; Break even if parity on
  4497.     MOVE    S2,P1            ; Get the address of the control block
  4498.     $CALL    T$SBRK            ; Set the break set
  4499.  
  4500.     MOVX    T1,BLSTRU        ; Assume it is
  4501.     MOVE    S1,$TTLIN(P1)        ; Get this terminal line number
  4502.     MOVE    S2,$TTNOD(P1)        ; Get the node number
  4503.     CAMN    S1,MYTERM+$TTLIN    ; Is this the same?
  4504.      CAME    S2,MYTERM+$TTNOD    ; . . .
  4505.       MOVX    T1,BLSFAL        ; No, false
  4506.     MOVEM    T1,CONNECT%FLAG##    ; Store the flag
  4507.  
  4508. ; Now clear the terminal input buffer.  This will allow us to dump any NAKs
  4509. ; that were sent by the remote server into the bit bucket and not confuse
  4510. ; the protocol.
  4511.  
  4512.     MOVX    T1,.TOCIB        ; Clear the input buffer
  4513.     MOVE    T2,$TTUDX(P1)        ; Get the UDX
  4514.     MOVX    S1,[XWD 2,T1]        ; Point to the argument
  4515.     TRMOP.    S1,            ; Clear the input buffer
  4516.       JFCL                ; Don't care
  4517.  
  4518. ; Now open any debugging log file
  4519.  
  4520.     MOVE    T1,DBGLOG+$LGFLG    ; Get flags for debug file
  4521.     TXNN    T1,LG$SET        ; Check if file is set
  4522.      $RETT                ; No, nothing to open
  4523.     MOVX    S1,FOB.MZ        ; Get length of FOB
  4524.     MOVEI    S2,DBGLOG+$LGFOB    ; Point at FOB
  4525.     TXNE    T1,LG$APP        ; Want to append to file?
  4526.      $CALL    F%AOPN            ; Yes, do it
  4527.     TXON    T1,LG$APP        ; Next time we will want to append
  4528.      $CALL    F%OOPN            ; Even if we created file this time
  4529.     MOVEM    S1,DBGLOG+$LGIFN    ; Save the IFN
  4530.     TXO    T1,LG$OPN        ; Flag file is open
  4531.     MOVEM    T1,DBGLOG+$LGFLG    ; Save new flags
  4532.     $RETIT                ; If we got the file open, continue
  4533.     $KERR    (<Cannot open debugging log file ^F/DBGLOG+$LGFD/ - ^E/S1/>)
  4534.     SETZM    DBGLOG+$LGFLG        ; Ignore log file from now on
  4535.     $RETT                ; Give a good return
  4536.  
  4537. ; Here to reset the terminal for commands (KLUDGE for GLXLIB)
  4538.  
  4539. OCTERM:    MOVX    T1,IO.SYN!.IOASC!IO.SUP    ; Get the mode
  4540.     MOVE    T2,$TTDEV+MYTERM    ; Get my terminal name
  4541.     SETZ    T3,            ; Clear this
  4542.     OPEN    TTY,T1            ; Open the terminal
  4543.       JFCL                ; Don't care
  4544.     $RETT                ; Give a good return
  4545. >; End of TOPS10 conditional
  4546.     SUBTTL    Terminal processing -- Message routines -- Close the terminal
  4547.  
  4548. ;+
  4549. ;.hl1 CLSTRM
  4550. ;This routine will close the terminal that has been opened by OPNTRM.
  4551. ;.literal
  4552. ;
  4553. ; Usage:
  4554. ;    $CALL    CLSTRM
  4555. ;    (Return)
  4556. ;
  4557. ;.end literal
  4558. ;-
  4559.  
  4560. CLSTRM:    MOVEI    S1,XFRTRM        ; Point to the transfer terminal info
  4561.     $CALL    T$CLOS            ; Close the terminal
  4562.     MOVX    S1,BLSFAL        ; Get the false value
  4563.     EXCH    S1,CONNECT%FLAG##    ; Store it
  4564.  
  4565. TOPS10<
  4566.     CAIN    S1,BLSTRU        ; Was it true?
  4567.      $CALL    OCTERM            ; Open the command terminal again
  4568. >; End of TOPS10 conditional
  4569. ;
  4570. ; Close the debugging log (if any)
  4571.  
  4572.     MOVE    T1,DBGLOG+$LGFLG    ; Get the flags
  4573.     TXZN    T1,LG$OPN        ; File open?
  4574.      $RETT                ; No, just return
  4575.     MOVEM    T1,DBGLOG+$LGFLG    ; Save new flags
  4576.     MOVE    S1,DBGLOG+$LGIFN    ; Yes, get the IFN
  4577.     $CALL    F%REL            ; Close the file
  4578.     $RETT                ; And return
  4579.     SUBTTL    Terminal processing -- Message routines -- Send a message
  4580.  
  4581. ;+
  4582. ;.hl1 SEND
  4583. ;This routine will send a message to the remote Kermit.  It is called with
  4584. ;the address of the message and the length of it.
  4585. ;.literal
  4586. ;
  4587. ; Usage:
  4588. ;    SEND(Address, Length);
  4589. ;
  4590. ;.end literal
  4591. ;-
  4592.  
  4593. BLSRTN(SEND,<MSGLEN,MSGADR>)
  4594.     $SAVE    <TF,S2,T1,T2>        ; Save some registers
  4595.  
  4596. ;[112] First clear the input buffer to dump any junk which showed up since
  4597. ;[112] we last received a message.
  4598.  
  4599.     MOVX    T1,.TOCIB        ;[112] Clear input buffer function
  4600.     MOVE    T2,XFRTRM+$TTUDX    ;[112] Get the UDX for the transfer terminal
  4601.     MOVE    S1,[XWD 2,T1]        ;[112] Point at arguments
  4602.     TRMOP.    S1,            ;[112] Clear the buffer
  4603.      CLRBFI                ;[112] Assume using console terminal
  4604.     MOVE    T1,MSGADR        ; Get the address of the message
  4605.     HRLI    T1,(POINT 8)        ; Point to it
  4606.     MOVE    T2,MSGLEN        ; Get a copy of the message length
  4607.  
  4608. SEND0:    SOJL    T2,SEND1        ; Finished?
  4609.     ILDB    S1,T1            ; No, get a character
  4610.     XMOVEI    S2,XFRTRM        ; Point to the information block
  4611.     $CALL    T$COUT            ; Output the character
  4612.     JUMPT    SEND0            ; True return, try for the next character
  4613.  
  4614. SEND2:    MOVE    S2,$TTIOS+XFRTRM    ; Get the status
  4615.     TXNE    S2,IO.ERR        ; Any errors?
  4616.       JRST    SEND4            ; Yes, handle it
  4617.     SETZ    S2,            ; Clear this
  4618.     HIBER    S2,            ; Wait until done
  4619.       JFCL                ; Don't care
  4620.     JRST    SEND2            ; Try again
  4621.  
  4622. SEND1:    XMOVEI    S2,XFRTRM        ; Point to the block
  4623.     $CALL    T$DMPO            ; Dump the character output buffer
  4624.     JUMPT    [BLSRET NORMAL]        ; Give a good return
  4625.  
  4626.     MOVE    S2,$TTIOS+XFRTRM    ; Get the IO status
  4627.     TXNN    S2,IO.ERR        ; Any errors?
  4628.       JRST    [SETZ    S2,            ; No, just sleep a little
  4629.         HIBER    S2,            ; . . .
  4630.           JFCL                ; Don't care about errors
  4631.         JRST    SEND1]            ; Try again
  4632.  
  4633. ; Here if there was an error
  4634.  
  4635. SEND4:    KERERR    (<Output error, status ^O60/S2/>)
  4636.     BLSRET    SNDERR            ; Return the error
  4637.     SUBTTL    Terminal processing -- Message routines -- Wait for turnaround
  4638.  
  4639. ;+
  4640. ;.hl1 IBM%WAIT
  4641. ; This routine will wait for the turnaround character from the line.
  4642. ;.literal
  4643. ;
  4644. ; Usage:
  4645. ;    STATUS = IBM_WAIT();
  4646. ;
  4647. ;.end literal
  4648. ;-
  4649.  
  4650.     BLSRTN(IBM%WAIT)
  4651.     $SAVE    <TF,S2>            ; Save the temps
  4652. IBMW.0:    XMOVEI    S2,XFRTRM        ; Point to the argument block
  4653.     $CALL    T$CIN            ; Attempt to read a character
  4654.     JUMPT    IBMW.1            ; If we got a character, check it out
  4655.     $CALL    RECEIE            ; Check out possible error
  4656.     TXNN    S1,BLSTRU        ; Still ok?
  4657.      JRST    [CAXN    S1,TIMEOUT    ; No, time out?
  4658.           MOVX    S1,NORMAL    ; Yes, pretend all ok
  4659.         $RET]            ; And return
  4660. IBMW.1:    ANDX    S1,177            ; Strip parity bit
  4661.     CAME    S1,IBM%CHAR##        ; This the turnaround character?
  4662.      JRST    IBMW.0            ; No, try again
  4663.  
  4664.     BLSRET    NORMAL            ; Give good return
  4665.     SUBTTL    Terminal processing -- Message routines -- Receive a message
  4666.  
  4667. ;+
  4668. ;.hl1 RECEIVE
  4669. ;This routine will receive a message from the remote Kermit.  This routine
  4670. ;will time out if the message is not received in the correct number of
  4671. ;seconds.
  4672. ;.literal
  4673. ;
  4674. ; Usage:
  4675. ;    RECEIVE(Address, Length);
  4676. ;
  4677. ;.end literal
  4678. ;-
  4679.  
  4680. BLSRTN(RECEIVE,<MSGLEN,MSGADR>)
  4681.     $SAVE    <TF,S2>
  4682.     $SAVE    <T1,T2,T3,T4>        ; Save a few registers
  4683. TOPS10<
  4684.     $CALL    SETTMR            ; Set the timer
  4685.  
  4686. RECEI0:    SETZM    @MSGLEN            ; Clear the count of characters
  4687.     MOVE    T1,MSGADR        ; Get the address to store into
  4688.     HRLI    T1,(POINT 8)        ; Build a byte pointer to it
  4689.     $CALL    RECSUB            ; Get a character
  4690.      $RETIF                ; Give up if failed
  4691.     ANDI    S1,^O177        ; Strip parity bit (if still there)
  4692.     MOVE    S2,S1            ; Get a copy of the character
  4693.     CAMN    S2,RCV%SOH##        ; Start of header character?
  4694.      JRST    RECEI1            ; Yes, go store it
  4695.     CAIE    S2,.CHCNC        ; Control-C?
  4696.      JRST    RECEI0            ; Not a character we are interested in,
  4697.  
  4698. RECEIC:    $CALL    RECSUB            ; Get a character
  4699.      $RETIF                ; Give up on failure
  4700.     ANDI    S1,^O177        ; Strip the parity bit
  4701.     MOVE    S2,S1            ; Get a copy
  4702.     CAMN    S2,RCV%SOH##        ; Start of packet?
  4703.      JRST    RECEI1            ; Yes, go read the packet
  4704.     CAIE    S2,.CHCNC        ; Control-C?
  4705.      JRST    RECEI0            ; No, just eat it
  4706.     BLSRET    ABORTED            ; Yes, give up
  4707.  
  4708.  
  4709. RECEI1:    IDPB    S1,T1            ; Store the character
  4710.     AOS    S1,@MSGLEN        ; Increment the count
  4711.     CAIL    S1,MAX%MSG##        ; Fill entire buffer?
  4712.      JRST    RECEIN            ; Yes, give good return
  4713.     CAIN    S2,.CHCNC        ; Control-C?
  4714.      JRST    RECEIC            ; Yes, go see if we get a second
  4715.     CAME    S2,RCV%EOL        ; End of line character?
  4716.      JRST    RECEI2            ; No, get another character
  4717.  
  4718. ; Here to give "normal" return
  4719.  
  4720. RECEIN:    $CALL    CHKKBD            ; Check for keyboard input first
  4721.     BLSRET    NORMAL            ; Then return normal
  4722.  
  4723. RECEI2:    $CALL    RECSUB            ; Get a character
  4724.     $RETIF                ; Just pass back errors
  4725.  
  4726.     MOVE    S2,S1            ; Get copy of character
  4727.     ANDI    S2,^O177        ; Strip parity bit
  4728.     CAME    S2,RCV%SOH##        ; Start of header again?
  4729.      JRST    RECEI1            ; No, go store character
  4730.  
  4731. ; Here if we got a second start of header.  Restart the message
  4732.  
  4733. RECEI3:    SETZM    @MSGLEN            ; Clear the length
  4734.     MOVE    T1,MSGADR        ; Get the address to store into
  4735.     HRLI    T1,(POINT 8)        ; Build a byte pointer to it
  4736.     JRST    RECEI1            ; Go store the SOH
  4737.  
  4738. ; Here if there are not more characters in the input buffer
  4739.  
  4740. RECEIE:    MOVE    S1,XFRTRM+$TTIOS    ; Get the IO status
  4741.     TXNN    S1,IO.ERR        ; Any errors?
  4742.       JRST    RECEIT            ; No, ASYNC blocking
  4743.     KERERR    (<Receive error, status ^O60/S1/>)
  4744.     BLSRET    RECERR            ; Return the value
  4745.  
  4746. ; Here if we are waiting for the input.  TOPS-10 timer processing
  4747.  
  4748. RECEIT:    $CALL    CHKKBD            ; Check for keyboard input
  4749.     SKIPN    SEND%TIMEOUT##        ; Any timeout?
  4750.      JUMPT    [BLSRET TIMEOUT]    ; No, pretend we just timed out
  4751.     MOVX    T3,%CNSUP        ; Get the system uptime
  4752.     GETTAB    T3,            ; . . . .
  4753.       JFCL                ; Failed?
  4754.     CAML    T3,TIMLIM        ; Output of time?
  4755.      BLSRET    TIMEOUT            ; Yes, time out
  4756.     SUB    T3,TIMLIM        ; Get the amount to hibernate
  4757.     IMULX    T3,-^D1000        ; Convert to milliseconds
  4758.     IDIV    T3,JIFSEC        ; . . .
  4759.     CAXLE    T3,^D1000        ; Never wait more than a second
  4760.       MOVX    T3,^D1000        ; (in case monitor screws up)
  4761.     TXO    T3,HB.RIO!HB.RTC!HB.RWJ    ; Wake when I/O done
  4762.     HIBER    T3,            ; Go away
  4763.       JFCL                ; Don't care
  4764.     BLSRET    NORMAL            ; Return OK
  4765.  
  4766.  
  4767. ; Subroutine to get a character and handle timing
  4768.  
  4769. RECSUB:    XMOVEI    S2,XFRTRM        ; Point to the argument block
  4770.     $CALL    T$CIN            ; Attempt to read a character
  4771.     JUMPF    RECS.1            ; If error, go check it out
  4772.     MOVE    S2,PARITY%TYPE##    ; Get the type
  4773.     CAIE    S2,PR%NONE##        ; No parity?
  4774.      ANDI    S1,^O177        ; No, strip parity bit
  4775.     $RET                ; Pass back true return
  4776.  
  4777. RECS.1:    $CALL    RECEIE            ; Check out error
  4778.     TXNN    S1,BLSTRU        ; Some type of error?
  4779.      $RET                ; Yes, give up (passing back failure)
  4780.     JRST    RECSUB            ; Try again
  4781.     SUBTTL    Terminal processing -- Message routines -- Check for keyboard input
  4782.  
  4783. ;+
  4784. ;.HL1 CHKKBD
  4785. ; This routine will check to see if the user has typed an interesting character
  4786. ;on the keyboard (assuming we still have one).
  4787. ; This allows for aborting the current file or an entire stream.
  4788. ;.literal
  4789. ;
  4790. ; Usage:
  4791. ;    $CALL    CHKKBD
  4792. ;
  4793. ; On true return:
  4794. ;    Some interesting character seen.
  4795. ;
  4796. ; On a false return:
  4797. ;    Nothing of interest seen.
  4798. ;
  4799. ;.end literal
  4800. ;-
  4801.  
  4802. CHKKBD:    MOVX    S2,BLSTRU        ; Get the flag value
  4803.     TDNE    S2,CONNECT%FLAG##    ; Check if connected
  4804.      $RETF                ; Yes, no keyboard to poll
  4805. CHKKB1:    INCHRS    S1            ; No, get a character from the keyboard
  4806.      $RETF                ; Nothing there
  4807.     CAXE    S1,.CHCRT        ; Carriage return?
  4808.      CAXN    S1,.CHCNA        ; Control-A?
  4809.       JRST    CHKKB2            ; Yes, go set flag and give correct return
  4810.     CAXN    S1,.CHCND        ; Control-D?
  4811.      XORM    S2,DEBUG%FLAG##        ; Yes, toggle debugging
  4812.     CAXE    S1,.CHCNX        ; Control-X?
  4813.      CAXN    S1,.CHCNZ        ; or control-Z?
  4814.       JRST    .+2            ; Yes, set correct flag
  4815.        JRST    CHKKB1            ; No, check if more there
  4816. CHKKB2:    CAXN    S1,.CHCNX        ; Control-X?
  4817.      MOVEM    S2,ABT%CUR%FILE##    ; Yes, abort current file
  4818.     CAXN    S1,.CHCNZ        ; No, control-Z?
  4819.      MOVEM    S2,ABT%ALL%FILE##    ; Yes, abort entire stream
  4820.     CAXN    S1,.CHCNA        ; Control-A?
  4821.      MOVEM    S2,TYP%STS%FLAG##    ; Flag that user wants some info
  4822.     CAXN    S1,.CHCND        ; Control-D?
  4823.      XORM    S2,DEBUG%FLAG##        ; Yes, toggle debugging
  4824.     CAXN    S1,.CHCRT        ; Carriage return?
  4825.      SETOM    TIMLIM            ; Yes, force immediate timeout
  4826.     INCHRS    S1            ; Any more characters?
  4827.      $RETT                ; No, return but remember we had something
  4828.     JRST    CHKKB2            ; Yes, go check if interesting
  4829.  
  4830.     SUBTTL    Terminal processing -- Message routines -- Set time out timer
  4831.  
  4832. ;+
  4833. ;.hl1 SETTMR
  4834. ;This routine will set the time out timer for inputting and outputting a
  4835. ;message.  It will be called by the RECEIVE and SEND routines.
  4836. ;.literal
  4837. ;
  4838. ; Usage:
  4839. ;    $CALL    SETTMR
  4840. ;    (Return)
  4841. ;
  4842. ; On return:
  4843. ;    TIMLIM set up
  4844. ;
  4845. ;.end literal
  4846. ;-
  4847.  
  4848. TOPS10<
  4849. SETTMR:    SKIPN    SEND%TIMEOUT##        ; Have a value?
  4850.       JRST    [MOVX    S1,.INFIN        ; No, use infinity
  4851.         MOVEM    S1,TIMLIM        ; Store the time limit
  4852.         $RET]                ; Return to the caller
  4853.     MOVX    S1,%CNSUP        ; Get the current uptime
  4854.     GETTAB    S1,            ; From the system
  4855.       JFCL                ; Don't care
  4856.     MOVEM    S1,TIMLIM        ; Store this
  4857.     MOVE    S1,SEND%TIMEOUT##    ; Get the time out again
  4858.     IMUL    S1,JIFSEC        ; Mul by jiffies per second
  4859.     ADDM    S1,TIMLIM        ; Update for the delta
  4860.     $RET                ; Return to the caller
  4861. >; End of TOPS10 conditional
  4862.     SUBTTL    Terminal processing -- General -- Determine using local line
  4863.  
  4864. ;+
  4865. ;.hl1 T$LOCAL
  4866. ;This routine will determine if we are using a local line or not.  It
  4867. ;will return TRUE if the line in XFRTRM is the same as MYTERM.
  4868. ;.literal
  4869. ;
  4870. ; Usage:
  4871. ;    $CALL    T$LOCAL
  4872. ;    (Return)
  4873. ;
  4874. ; Return true:
  4875. ;    MYTERM == XFRTRM
  4876. ;
  4877. ; Return false:
  4878. ;    MYTERM <> XFRTRM
  4879. ;
  4880. ;.end literal
  4881. ;-
  4882.  
  4883. T$LOCAL:
  4884.     MOVE    S1,$TTLIN+XFRTRM    ; Get this terminal line number
  4885.     MOVE    S2,$TTNOD+XFRTRM    ; Get the node number
  4886.     CAMN    S1,MYTERM+$TTLIN    ; Is this the same?
  4887.      CAME    S2,MYTERM+$TTNOD    ; . . .
  4888.       $RETF                ; Not the same
  4889.     $RETT                ; Same
  4890.     SUBTTL    Terminal processing -- General -- Open a terminal
  4891.  
  4892. ;+
  4893. ;.hl1 T$OPEN
  4894. ;This routine will open a terminal for input and output.  It is called with
  4895. ;the address of the terminal information block.  It will store the address
  4896. ;and size of the buffers, the channel number and device name into the
  4897. ;information block.
  4898. ;.literal
  4899. ;
  4900. ; Usage:
  4901. ;    XMOVEI    S1,Terminal information block
  4902. ;    $CALL    T$OPEN
  4903. ;    (Return)
  4904. ;
  4905. ; On a true return:
  4906. ;    - Terminal is open
  4907. ;
  4908. ; On a false return:
  4909. ;    - Terminal failed to open
  4910. ;
  4911. ;.end literal
  4912. ;-
  4913.  
  4914. TOPS10<
  4915. T$OPEN:    $SAVE    <P1,P2,P3,P4>        ; Save a registers
  4916.     MOVE    P1,S1            ; Copy the argument
  4917.     $CALL    T$CONN            ; Connect the terminal
  4918.     MOVEM    S1,$TTDEV(P1)        ; Store the device name
  4919.     MOVEM    S1,FLP+.FODEV        ; Store the name
  4920.     IONDX.    S1,            ; Get the UDX also
  4921.      SETO    S1,            ; Pretend it is us
  4922.     MOVEM    S1,$TTUDX(P1)        ; Remember the UDX
  4923.     MOVX    S1,.IOPIM!IO.SUP!UU.AIO    ; Get the mode and other information
  4924.     MOVEM    S1,FLP+.FOIOS        ; Store the status information
  4925.     HRLI    S1,$TTOBH(P1)        ; Get the output buffer header
  4926.     HRRI    S1,$TTIBH(P1)        ; Get the input buffer header
  4927.     MOVEM    S1,FLP+.FOBRH        ; Store them
  4928. ;[134]    MOVX    S1,-1            ; Assume defaults
  4929. ;[134]    MOVEM    S1,FLP+.FONBF        ; Store the number of buffers
  4930.     SETZM    FLP+.FOFNC        ; Clear this
  4931.     MOVX    S1,.FORED        ; Claim reading
  4932.     STORE    S1,FLP+.FOFNC,FO.FNC    ; Store the function
  4933.     MOVX    S1,FO.ASC        ; Assign a channel
  4934.     IORM    S1,FLP+.FOFNC        ; Turn this on
  4935.     MOVEI    S1,FLP+.FOIOS        ; Point to the block
  4936.     DEVSIZ    S1,            ; Get the size of the buffers
  4937.      JRST    [$KERR(<DEVSIZ UUO failure (^D/S1/)>)
  4938.         $RETF]            ; Return to the caller
  4939.     MOVEI    S2,MAX%MSG##/4+1 ;[134]    ; Get maximum message size
  4940.     PUSH    P,S2+1        ; [134]
  4941.     IDIVI    S2,-3(S1)    ; [134]    ; Compute no of buffers (3 word header)
  4942.     POP    P,S2+1        ; [134]
  4943.     ADDI    S2,1        ; [134]    ; Result was truncated, add a buffer
  4944.     HRL    S2,S2        ; [134]    ; Set up for both input and output
  4945.     MOVEM    S2,FLP+.FONBF    ; [134]    ; Store the number of buffers
  4946.     MOVEI    S1,(S1)            ; Get the size
  4947.     IMULI    S1,(S2)            ; Compute the total size
  4948.     LSH    S1,1            ; Double it (input and output)
  4949.     MOVEM    S1,$TTBSZ(P1)        ; Store the number of words
  4950.     $CALL    M%GMEM            ; Allocate the memory
  4951.     $RETIF                ; Failed?
  4952.     MOVEM    S2,$TTBAD(P1)        ; Store the buffer address
  4953.     EXCH    S2,.JBFF        ; Exchange with .JBFF
  4954.     MOVX    S1,<XWD .FONBF+1,FLP>    ; Point to the argument block
  4955.     FILOP.    S1,            ; Open terminal, allocate buffers
  4956.       JRST    OPEN.0            ; Failed, restore and get out
  4957.     MOVEM    S2,.JBFF        ; Store .JBFF back
  4958.     LOAD    S1,FLP+.FOFNC,FO.CHN    ; Get the channel assigned
  4959.     MOVEM    S1,$TTCHN(P1)        ; Store it
  4960.  
  4961. ; Remember any parameters we need to change, then change them
  4962.  
  4963.     MOVX    P2,.TOPAG        ; Get the TT PAGE (on/off) setting
  4964.     MOVE    P3,$TTUDX(P1)        ; Get the UDX
  4965.     MOVX    S1,<XWD 2,P2>        ; Point at the block
  4966.     TRMOP.    S1,            ; And get the bit
  4967.      SETZ    S1,            ; Must not know about it
  4968.     MOVEM    S1,$TTPAG(P1)        ; Save the bit setting
  4969.     SETOM    TRMOPN            ; Transfer terminal is now open
  4970. ;[133]    MOVE    S1,IBM%FLAG##        ; IBM mode?
  4971. ;[133]    TXNN    S1,BLSTRU        ;  .  .  .
  4972. ;[133]     $RETT                ; No, all done
  4973.     MOVE    S1,IBM%CHAR##        ; Yes, get the character
  4974.     CAXL    S1,.CHNUL        ;[133] Is it a character?
  4975.      JRST    .+2            ; Yes, need to clear TTY PAGE
  4976.       $RETT                ; No, leave things alone
  4977.     MOVX    S1,<XWD 3,P2>        ; Get the pointer
  4978.     ADDX    P2,.TOSET        ; Change to set function
  4979.     MOVEI    P4,1B35            ; Turn page on
  4980.     TRMOP.    S1,            ; Do it
  4981.      JFCL                ; Ignore error
  4982.     $RETT                ; Give a good return
  4983.  
  4984.  
  4985. ; Here if the FILOP. failed to open the terminal.
  4986.  
  4987. OPEN.0:    MOVEM    S2,.JBFF        ; Store .JBFF back
  4988.     $KERR    (<Terminal open failure ^T/FILERR##(S1)/>)
  4989.     SETZB    S1,S2            ; Clear these
  4990.     EXCH    S1,$TTBSZ(P1)        ; Get the size and clear entry
  4991.     EXCH    S2,$TTBAD(P1)        ; Get the address and clear it
  4992.     $CALL    M%RMEM            ; Return the memory
  4993.     $RETF                ; Return to the caller
  4994. >; End of TOPS10 conditional
  4995. SUBTTL    Terminal processing -- General -- T$CLOS - Close the terminal channel
  4996.  
  4997. ;+
  4998. ;.hl1 T$CLOS
  4999. ;This routine will close the terminal channel and return the buffers
  5000. ;associated with the terminal.
  5001. ;.literal
  5002. ;
  5003. ; Usage:
  5004. ;    XMOVEI    S1,Terminal information block
  5005. ;    $CALL    T$CLOSE
  5006. ;    (Return)
  5007. ;
  5008. ; On return:
  5009. ;    Terminal channel closed and the buffers returned.
  5010. ;
  5011. ;.end literal
  5012. ;-
  5013.  
  5014. T$CLOS:    $SAVE    <P1,P2,P3,P4>        ; Save P1
  5015.     SETZM    TRMOPN            ; Transfer terminal now closed
  5016.     MOVE    P1,S1            ; Copy the argument into here
  5017.  
  5018. ; First reset the parameters correctly
  5019.  
  5020.     MOVX    P2,.TOSET+.TOPAG    ; Reset TTY PAGE correctly
  5021.     MOVE    P3,$TTUDX(P1)        ;  .  .  .
  5022.     MOVE    P4,$TTPAG(P1)        ;  .  .  .
  5023.     MOVX    S1,<XWD 3,P2>        ; Point at block
  5024.     TRMOP.    S1,            ; And set bit back the way we found it
  5025.      JFCL                ; We tried
  5026.     SETZ    S2,            ; Clear this word
  5027.     MOVE    S1,$TTCHN(P1)        ; Get the channel number
  5028.     STORE    S1,S2,FO.CHN        ; Store the channel number
  5029.     MOVX    S1,.FOREL        ; Get the function
  5030.     STORE    S1,S2,FO.FNC        ; Store the function
  5031.     MOVX    S1,<XWD 1,S2>        ; Point to the argument block
  5032.     FILOP.    S1,            ; Release the channel
  5033.       JFCL                ; Don't care
  5034.     MOVE    S1,$TTBSZ(P1)        ; Get the number of words
  5035.     MOVE    S2,$TTBAD(P1)        ; Get the address
  5036.     $CALL    M%RMEM            ; Return the memory
  5037.     $RETF                ; Return if that fails
  5038.     $RETT                ; Give a good return
  5039.     SUBTTL    Terminal processing -- General -- Input a character
  5040.  
  5041. ;+
  5042. ;.hl1 T$CIN
  5043. ;This routine will input a character given the terminal information
  5044. ;block address.  This routine assumes that the terminal has been opened.
  5045. ;.literal
  5046. ;
  5047. ; Usage:
  5048. ;    XMOVEI    S2,Terminal info block
  5049. ;    $CALL    T$CIN
  5050. ;    (Return)
  5051. ;
  5052. ; On a true return:
  5053. ;    S1/ Character
  5054. ;
  5055. ; On a false return:
  5056. ;    $TTIOS word of terminal block contains the status
  5057. ;
  5058. ;.end literal
  5059. ;-
  5060.  
  5061. T$CIN:    SOSGE    $TTIBH+.BFCNT(S2)        ; Decrement the character count
  5062.       JRST    CIN.0            ; Get a buffer
  5063.     ILDB    S1,$TTIBH+.BFPTR(S2)    ; Read one character
  5064.     $RETT                ; And return it
  5065.  
  5066. ; Here to get the next buffer from the terminal
  5067.  
  5068. CIN.0:    SETZ    TF,            ; Clear a registers
  5069.     MOVX    S1,.FOINP        ; Get the FILOP. function
  5070.     STORE    S1,TF,FO.FNC        ; Store the function
  5071.     MOVE    S1,$TTCHN(S2)        ; Get the channel
  5072.     STORE    S1,TF,FO.CHN        ; Store the channel
  5073.     MOVX    S1,<XWD 1,TF>        ; Get the argument pointer
  5074.     FILOP.    S1,            ; Attempt to read characters
  5075.       TRNA                ; Failed, store status
  5076.     JRST    T$CIN            ; Loop to get the characters
  5077.  
  5078. ; Here if the FILOP. failed, store the status and give a fail return
  5079.  
  5080.     MOVEM    S1,$TTIOS(S2)        ; Store the status
  5081.     $RETF                ; And fail
  5082.     SUBTTL    Terminal processing -- General -- Output a character
  5083.  
  5084. ;+
  5085. ;.hl1 T$COUT
  5086. ;This routine will output a character given the character and the terminal
  5087. ;information block.
  5088. ;.literal
  5089. ;
  5090. ; Usage:
  5091. ;    MOVEI    S1,Character
  5092. ;    XMOVEI    S2,Terminal information block
  5093. ;    $CALL    T$COUT
  5094. ;    (Return)
  5095. ;
  5096. ; On a true return:
  5097. ;    - Character stuffed in the buffer
  5098. ;
  5099. ; On a false return:
  5100. ;    - Problems outputting the character.
  5101. ;
  5102. ;.end literal
  5103. ;-
  5104.  
  5105. T$COUT:    SOSGE    $TTOBH+.BFCNT(S2)    ; Decrement the count
  5106.       JRST    COUT.0            ; Output the buffer
  5107.     IDPB    S1,$TTOBH+.BFPTR(S2)    ; Store the character
  5108.     $RETT                ; Give a good return
  5109.  
  5110. COUT.0:    $CALL    T$DMPO            ; Output the buffer
  5111.     JUMPT    T$COUT            ; Try again
  5112.     $RET                ; Pass back the error
  5113.  
  5114. T$DMPO:    $SAVE    <S1,S2>            ; Save two registers
  5115.     SETZ    S1,            ; Clear this
  5116.     MOVE    TF,$TTCHN(S2)        ; Get the channel
  5117.     STORE    TF,S1,FO.CHN        ; Store it
  5118.     MOVX    TF,.FOOUT        ; Get the function
  5119.     STORE    TF,S1,FO.FNC        ; Store it
  5120.     MOVX    TF,<XWD 1,S1>        ; Point to the argument block
  5121.     FILOP.    TF,            ; Output the information
  5122.       SKIPA                ; Failed, store the status and return
  5123.     $RETT                ; Give a good return
  5124.     MOVEM    TF,$TTIOS(S2)        ; Store the status
  5125.     $RETF                ; Give a failure return
  5126.     SUBTTL    Terminal processing -- General -- Output a character for CONNECT
  5127.  
  5128. ;+
  5129. ;.hl1 T$CCOT
  5130. ;This routine will output a character given the character and the terminal
  5131. ;information block. It will send only the single character using
  5132. ;a TRMOP.
  5133. ;.literal
  5134. ;
  5135. ; Usage:
  5136. ;    MOVEI    S1,Character
  5137. ;    XMOVEI    S2,Terminal information block
  5138. ;    $CALL    T$CCOT
  5139. ;    (Return)
  5140. ;
  5141. ; On a true return:
  5142. ;    - Character stuffed in the buffer
  5143. ;
  5144. ; On a false return:
  5145. ;    - Problems outputting the character.
  5146. ;
  5147. ;.end literal
  5148. ;-
  5149.  
  5150. T$CCOT:    $SAVE    <P1,P2,P3>        ; Save some registers
  5151.     MOVE    P2,$TTUDX(S2)        ; Get the terminal UDX
  5152.     MOVX    P1,.TOOIC        ; Output an image character
  5153.     MOVE    P3,S1            ; And the character
  5154.     MOVE    S1,[XWD 3,P1]        ; Get the argument pointer
  5155.     TRMOP.    S1,            ; Send the character
  5156.      JRST    [MOVE    S1,P3        ; Couldn't, get the character back
  5157.         PJRST    T$COUT]        ; And try the other way
  5158.     MOVE    S1,P3            ; Get the character back
  5159.     $RETT                ; And return
  5160.     SUBTTL    Terminal processing -- General -- Connect a terminal line
  5161.  
  5162. ;+
  5163. ;.hl1 T$CONN
  5164. ;This routine will connect a terminal to the system.  This is a TOPS-10
  5165. ;only routine
  5166. ;.literal
  5167. ;
  5168. ; Usage:
  5169. ;    MOVEI    S1,Terminal information block
  5170. ;    $CALL    T$CONN
  5171. ;    (Return)
  5172. ;
  5173. ; On return:
  5174. ;    S1/ Terminal name in sixbit
  5175. ;
  5176. ;.end literal
  5177. ;-
  5178.  
  5179. TOPS10<
  5180. T$CONN:    $SAVE    <P1>            ; Save this registers
  5181.     MOVE    P1,S1            ; Copy the address
  5182.     MOVX    S1,<<XWD .NDTCN,T1>>    ;[MF] Point to the argument block
  5183.     MOVX    T1,2            ; Number of words
  5184.     MOVE    T2,$TTLIN(P1)        ; Get the line number
  5185.     HRL    T2,$TTNOD(P1)        ; Get the node number
  5186.     NODE.    S1,            ; Connect the terminal
  5187.      JRST    .+2            ; Not a network system
  5188.     $RET                ; Return to the caller
  5189.     CAXE    S1,<XWD .NDTCN,T1>    ; Non-network system?
  5190.      JRST    TCON.E            ; No, some other error
  5191.     MOVE    S1,$TTLIN(P1)        ; Get the line number
  5192.     ADDX    S1,.UXTRM        ; Convert to UDX
  5193.     DEVNAM    S1,            ; Convert to terminal name
  5194.      SETO    S1,            ; Not a device?
  5195. TCON.E:    $RET                ; Return
  5196. >; End of TOPS10 conditional
  5197.     SUBTTL    Terminal processing -- General -- Set PIM break set
  5198.  
  5199. ;+
  5200. ;.hl1 T$SBRK
  5201. ;This routine will set the PIM mode break set.  It will be called with
  5202. ;the character to use and the address of the terminal control block.
  5203. ;.literal
  5204. ;
  5205. ; Usage:
  5206. ;    MOVEI    S1,<BYTE(9)0,0,Character,second character>
  5207. ;    XMOVE    S2,Terminal control block
  5208. ;    $CALL    T$SBRK
  5209. ;    (Return)
  5210. ;
  5211. ; On a true return;
  5212. ;    - Mask set
  5213. ;
  5214. ; On a false return:
  5215. ;    - It failed.
  5216. ;
  5217. ;.end literal
  5218. ;-
  5219.  
  5220. TOPS10<
  5221. T$SBRK:    $SAVE    <P1,P2,P3>        ; Save a few registers
  5222.     MOVE    P2,$TTUDX(S2)        ; Get the terminal UDX
  5223.     HRLZ    P3,S1            ; Copy the character
  5224.     JUMPE    P3,.+2            ; If no desired break char, break on all
  5225.      TXO    P3,<BYTE (9)0,0,.CHCNC,.CHCNC!^O200> ; Otherwise, also break on Ctl-C
  5226. ;[133]    MOVE    S1,IBM%FLAG##        ; Check if we are talking to IBM
  5227.     MOVE    S1,IBM%CHAR##        ;[133] See if we are talkng to IBM
  5228.     CAXGE    S1,.CHNUL        ;[133] Are we?
  5229.      TDZA    S1,S1            ; No, no additional break char
  5230.     LSH    S1,^D9            ; Position to correct place
  5231.     JUMPE    P3,.+2            ; If already breaking on all, stay that way
  5232.      TRO    P3,(S1)            ; Turn it on
  5233.     MOVX    P1,.TOSET+.TOPBS    ; Get the function
  5234.     MOVX    S1,<XWD 3,P1>        ; Point to the argument block
  5235.     TRMOP.    S1,            ; Do the function
  5236.       $RETF                ; Pass back the error
  5237.     $RETT                ; Give a good return
  5238. >; End of TOPS10 conditional
  5239.     SUBTTL    Terminal processing -- Text output -- TERM%DUMP & DBG%DUMP
  5240.  
  5241. ;+
  5242. ;.HL1 TERM%DUMP
  5243. ;This routine will dump the terminal buffer that the BLISS routines have been
  5244. ;keepng on the user's terminal.
  5245. ;.hl1 DBG%DUMP
  5246. ; This routine will dump the buffer onto either the terminal or into
  5247. ;the debugging file.
  5248. ;-
  5249.  
  5250. BLSRTN(TERM%DUMP,<COUNT,BUFFER>)
  5251.     $SAVE    <TF,S1>            ; Save TF and S1
  5252.     MOVX    S1,BLSTRU        ; Determine if connected
  5253.     TDNN    S1,CONNECT%FLAG##    ; Are we?
  5254.      $TEXT    (,<^T/@BUFFER/^A>)    ; No, type it
  5255.     $RET                ; And return
  5256.  
  5257.  
  5258. BLSRTN(DBG%DUMP,<COUNT,BUFFER>)
  5259.     $SAVE    <TF,S1,S2>        ; Save a few registers
  5260.     MOVX    S2,LG$OPN        ; Is the debugging log open?
  5261.     TDNE    S2,DBGLOG+$LGFLG    ;  .  .  .
  5262.      JRST    TRMD.1            ; Yes, just dump the buffer
  5263.     MOVE    S2,CONNECT%FLAG##    ; Get the flag
  5264.     TXNN    S2,BLSTRU        ; Communicating on controlling term?
  5265.      $TEXT    (,<^T/@BUFFER/^A>)    ; No, we can type on it
  5266.     $RET                ; And return
  5267.  
  5268. ; Here to output the text to the debugging file
  5269.  
  5270. TRMD.1:    MOVE    S1,DBGLOG+$LGIFN    ; Get the IFN
  5271.     MOVE    S2,BUFFER        ; Get the address of the buffer
  5272.     HRL    S2,COUNT        ; And the count
  5273.     $CALL    F%OBUF            ; Output the buffer
  5274.     $RETIT                ; If no error, return
  5275.  
  5276.     MOVE    S1,DBGLOG+$LGIFN    ; Get the IFN back
  5277.     MOVX    S2,LG$OPN        ; Get the open flag
  5278.     ANDCAM    S2,DBGLOG+$LGFLG    ; Flag file not open anymore
  5279.     PJRST    F%REL            ; Try to keep what we wrote already
  5280.     SUBTTL    Error processing -- .KERERR - Handle KERMIT-10 errors
  5281.  
  5282. ;+
  5283. ;.hl1 _.KERERR
  5284. ;This routine is called by the KERERR macro.  It is used to pass error
  5285. ;text to the remote KERMIT.
  5286. ;-
  5287.  
  5288. .KERERR::
  5289.     HRRZ    TF,@(P)            ; Get the address of the text
  5290.     MOVEM    TF,.TEMP        ; Save it here
  5291.     $SAVE    <TF,S1,S2>        ; Save a few registers
  5292.     $SAVE    <T1,T2,T3,T4>        ; And a few more
  5293.     $TEXT    (<-1,,MSGTXT>,<?Kermit-10 ^I/@.TEMP/^0>) ; Type the text
  5294.     JRST    KRERR            ; Join the common code
  5295.     SUBTTL    Error processing -- KRM%ERROR - Handle the KERMSG errors
  5296.  
  5297. ;+
  5298. ;.hl1 KRM%ERROR
  5299. ;This routine will handle the errors that KERMSG will generate.
  5300. ;-
  5301.  
  5302. BLSRTN(KRM%ERROR,<ERRTYP>)
  5303.     $SAVE    <TF,S2>            ; Save a few registers
  5304.     $SAVE    <T1,T2,T3,T4>        ; And a few more
  5305.     MOVE    S1,ERRTYP        ; Get the error type
  5306.     MOVSI    S2,-ERRLEN        ; Get the size of the table
  5307.  
  5308. KRMER0:    CAME    S1,ERRTBL(S2)        ; Is this the error?
  5309.     AOBJN    S2,.-1            ; Look until we find it
  5310.     $TEXT    (<-1,,MSGTXT>,<?Kermit-10 ^T/@ERRTXT(S2)/^0>) ; Write the text
  5311.  
  5312. ; Here to count the characters and call the BLISS routine to write the
  5313. ; error packet to the remote
  5314.  
  5315. KRERR:    SKIPN    TRMOPN            ; Transfer terminal open?
  5316.      JRST    [$TEXT    (,<^T/MSGTXT/>)    ; No, just type the error message
  5317.         BLSRET    ABORTED]    ; And punt
  5318.     MOVE    S1,[POINT 7,MSGTXT]    ; Point to the text
  5319.     SETZ    S2,            ; Clear the counter
  5320.  
  5321. KRERR0:    ILDB    T1,S1            ; Get a character
  5322.     JUMPE    T1,KRERR1        ; Finished?
  5323.     AOJA    S2,KRERR0        ; No, count it up and loop
  5324.  
  5325. KRERR1:    PUSH    P,S2            ; Push this on the stack
  5326.     XMOVEI    S1,MSGTXT        ; Point to the text
  5327.     PUSH    P,S1            ; Save this on the stack too
  5328.     PUSHJ    P,SND%ERROR##        ; Send the error message
  5329.     ADJSP    P,-2            ; Remove the information
  5330.     BLSRET    NORMAL            ; Give a normal return for now
  5331.  
  5332. ; BLISS error text
  5333.  
  5334. DEFINE    KER(TYPE,VALUE,TEXT)<EXP VALUE>
  5335.  
  5336. ERRTBL:    KERRORS
  5337.  ERRLEN==.-ERRTBL
  5338.  
  5339. DEFINE    KER(TYPE,VALUE,TEXT)<EXP [ASCIZ |Text|]>
  5340.  
  5341. ERRTXT:    KERRORS
  5342.     EXP    [ASCIZ |Unknown error code|]
  5343.     SUBTTL    CRC calculation routine
  5344.  
  5345. ;+
  5346. ;.hl1 CRC calculation
  5347. ; This routine will calculate the CRC for a string.  It will use
  5348. ;the CRC-CCITT polynomial.
  5349. ;.lit
  5350. ;
  5351. ; Usage:
  5352. ;    CRC = CRCCLC(.Address, .Length)
  5353. ;
  5354. ;.end lit
  5355. ;-
  5356.  
  5357. BLSRTN(CRCCLC,<LEN,BYTEPTR>)        ; Define the routine
  5358.     $SAVE    <T1,T2,T3,T4>        ; Save T1-T4
  5359.  
  5360. ; AC usage:
  5361. ;    S1/ Accumulated CRC
  5362. ;    T4/ Remaining length
  5363. ;    T3/ Byte pointer to string
  5364. ;    T2/ temp
  5365. ;    T1/ temp
  5366.  
  5367.     SETZ    S1,            ; Initial CRC is 0
  5368.     MOVE    T4,LEN            ; Get the length
  5369.     MOVE    T3,BYTEPTR        ; And the address
  5370.  
  5371. CRCC.1:    ILDB    T1,T3            ; Get a character
  5372.     XORI    T1,(S1)            ; Add in with current CRC
  5373.     LDB    T2,[POINT 4,T1,31]    ; Get high 4 bits
  5374.     ANDI    T1,^O17            ; And low 4 bits
  5375.     MOVE    T1,CRCTB2(T1)        ; Get low portion of CRC factor
  5376.     XOR    T1,CRCTAB(T2)        ; Plus high portion
  5377.     LSH    S1,-^D8            ; Shift off a byte from previous CRC
  5378.     XOR    S1,T1            ; Add in new value
  5379.     SOJG    T4,CRCC.1        ; Loop for all characters
  5380.  
  5381.     $RET                ; Return (value already in S1)
  5382.  
  5383.  
  5384. ; Data tables for CRC-CCITT generation
  5385.  
  5386. CRCTAB:    OCT    0
  5387.     OCT    10201
  5388.     OCT    20402
  5389.     OCT    30603
  5390.     OCT    41004
  5391.     OCT    51205
  5392.     OCT    61406
  5393.     OCT    71607
  5394.     OCT    102010
  5395.     OCT    112211
  5396.     OCT    122412
  5397.     OCT    132613
  5398.     OCT    143014
  5399.     OCT    153215
  5400.     OCT    163416
  5401.     OCT    173617
  5402.  
  5403. CRCTB2:    OCT    0
  5404.     OCT    10611
  5405.     OCT    21422
  5406.     OCT    31233
  5407.     OCT    43044
  5408.     OCT    53655
  5409.     OCT    62466
  5410.     OCT    72277
  5411.     OCT    106110
  5412.     OCT    116701
  5413.     OCT    127532
  5414.     OCT    137323
  5415.     OCT    145154
  5416.     OCT    155745
  5417.     OCT    164576
  5418.     OCT    174367
  5419.     SUBTTL    Data area
  5420.  
  5421.     RELOC                ; To the low segment
  5422.  
  5423. PDL:    BLOCK    PDLLEN            ; Stack
  5424. TOPS10<
  5425. CCLOFS:    BLOCK    1            ; CCL offset
  5426. >; End of TOPS10 conditional
  5427.  
  5428. LOWBEG:!
  5429. HSTNOD::BLOCK    1            ; Host node number
  5430. HSTITX::BLOCK    1            ; Host node ITEXT string
  5431. XITFLG:    BLOCK    1            ; Exit flag
  5432. PRTARG:    BLOCK    2            ; Saved parser information
  5433. PRBLK:    BLOCK    PAR.SZ            ; Parser interface block
  5434. PROMPT:    BLOCK    D$PSIZ            ; User prompt
  5435. TXIBLK:    BLOCK    .RDRTY+1        ; TEXTI block
  5436. ANSBUF:    BLOCK    ANSLEN            ; Answer buffer
  5437. PRMPTB:    BLOCK    ANSLEN            ; Prompt buffer
  5438. TOPS10<
  5439. LOGDIN::BLOCK    1            ;[125] Flag if we are logged in
  5440. MONBLK:    BLOCK    PAR.SZ            ; Monitor command block
  5441. TMPBP:    BLOCK    1            ; Byte pointer for building .TMP file name
  5442. TMPSIZ:    BLOCK    1            ; TMP file size
  5443. TMPADR:    BLOCK    1            ; Address of TMP pointer
  5444. CCLIFN:    BLOCK    1            ; CCL file IFN
  5445. .MYPPN:    BLOCK    1            ; My ppn
  5446. >; End of TOPS10 conditional
  5447.  
  5448. INIIFN:    BLOCK    1            ; KERMIT.INI IFN
  5449.  
  5450. ; LOCAL command processing storage
  5451.  
  5452. LCLSTR:    BLOCK    1            ; Address of string to type
  5453. LCLSIZ:    BLOCK    1            ; Size of string
  5454. LCLRTN:    BLOCK    1            ; Address of get a char routine
  5455. LCLCHR:    BLOCK    1            ; Location to fetch character into
  5456.  
  5457. ; Terminal I/O information
  5458.  
  5459. TOPS10<
  5460. TIMLIM:    BLOCK    1            ; Time out time
  5461. JIFSEC::BLOCK    1            ; Number of jiffies per second
  5462. >; End of TOPS10 conditional
  5463. TRMOPN:    BLOCK    1            ; Transfer terminal open
  5464.  
  5465. ESCAPE:    BLOCK    1            ; CONNECT escape character
  5466. ESCTXT:    BLOCK    1            ; Escape character in ASCII
  5467.  
  5468. LCLECH:    BLOCK    1            ; Local echo flag
  5469.  
  5470. XXPMOD:    BLOCK    1            ;[127] XON-XOFF-processing
  5471. XFRTRM:    BLOCK    $TTSIZ            ; Transfer terminal information
  5472. MYTERM:    BLOCK    $TTSIZ            ; My terminal information
  5473.  
  5474. ; File I/O information
  5475.  
  5476. FILTYP:    BLOCK    1            ; Type of file being read/written
  5477. CURFTP:    BLOCK    1            ; File byte size for currently read file
  5478. FILPTR:    BLOCK    1            ; Location containing a byte pointer to store FILE%NAME
  5479. TOPS10<
  5480. USRFIL:    BLOCK    1            ; Non-zero if user supply spec
  5481. USRFX:    BLOCK    .FDSIZ            ; Length of the file spec area
  5482. FX:    BLOCK    .FDSIZ            ; File specification length
  5483. BH:    BLOCK    3            ; Buffer header
  5484. FBFADR:    BLOCK    1            ; Address of the file buffers
  5485. FBFSIZ:    BLOCK    1            ; Size of the file buffers
  5486. WLDPTR:    BLOCK    1            ; Pointer used by .LKWLD
  5487. FLP::    BLOCK    .FOMAX            ; FILOP. block
  5488. ELB::    BLOCK    .RBMAX            ; Enter/Lookup block
  5489. PTH::    BLOCK    .PTMAX            ; Path block
  5490. FPTH::    BLOCK    .PTMAX            ; File found in path
  5491.  
  5492. ; LOKWLD interface
  5493.  
  5494. WLD:    BLOCK    $LKLEN            ; Length of block
  5495. >; End of TOPS10 conditional
  5496.  
  5497. ; Random information and storage
  5498.  
  5499. .TEMP:    BLOCK    10            ; Temp storage for strings
  5500.  
  5501. MSGTXT:    BLOCK    50            ; Area for 250 character of message
  5502. LOWEND:!
  5503.  
  5504. LOWSIZ==.-LOWBEG
  5505.  
  5506.     RELOC                ; Back to the high segment
  5507. PHABEG:    PHASE    LOWEND
  5508.  
  5509. LOWPHA:!
  5510.  
  5511. IB:    $BUILD    IB.SZ
  5512.      $SET    IB.FLG,,IT.OCT!IB.NPF
  5513.      $SET    IB.PRG,,%%.MOD
  5514.     $EOB
  5515.  
  5516. HLPFD:    $BUILD    FDMSIZ
  5517.      $SET    .FDLEN,FD.LEN,FDMSIZ    ; Size of the block
  5518.      $SET    .FDLEN,FD.TYP,.FDNAT    ; Native file specification
  5519.      $SET    .FDSTR,,<SIXBIT /HLP/>    ; HLP:
  5520.      $SET    .FDNAM,,%%.MOD        ; KERMIT
  5521.      $SET    .FDEXT,,<SIXBIT /HLP/>    ; .HLP
  5522.     $EOB
  5523.  
  5524. CCLFD:    $BUILD    FDMSIZ            ; Minimum size FD
  5525.      $SET    .FDLEN,FD.LEN,FDMSIZ    ; Size of the FDB
  5526.      $SET    .FDLEN,FD.TYP,.FDNAT    ; Native spec
  5527.      $SET    .FDSTR,,<SIXBIT |DSK|>    ; Device is DSK
  5528.      $SET    .FDEXT,,<SIXBIT |TMP|>    ; Extension
  5529.     $EOB                ; End of block
  5530.  
  5531. CCLFOB:    $BUILD    FOB.MZ            ; Build an FOB
  5532.      $SET    FOB.FD,,CCLFD        ; Address of FD
  5533.      $SET    FOB.CW,FB.BSZ,7        ; Byte size
  5534.     $EOB                ; End of block
  5535.  
  5536. ; FD for KERMIT.INI
  5537.  
  5538. INIFD:    $BUILD    FDMSIZ            ; Minimum size FD
  5539.      $SET    .FDLEN,FD.LEN,FDMSIZ    ; Size
  5540.      $SET    .FDLEN,FD.TYP,.FDNAT    ; Native FD
  5541. TOPS10<
  5542.      $SET    .FDSTR,,<SIXBIT |DSK|>    ; Device is DSK
  5543.      $SET    .FDNAM,,<SIXBIT |KERMIT|>    ; Name is KERMIT
  5544.      $SET    .FDEXT,,<SIXBIT |INI|>    ; .INI
  5545. >; End of TOPS10 conditional
  5546. TOPS20<
  5547.      $SET    .FDSTG,,<ASCIZ |DSK:KERMIT.INI|>
  5548. >; End of TOPS20 conditional
  5549.     $EOB                ; End of block
  5550.  
  5551.  
  5552. ; Blocks for log files
  5553.  
  5554.     DEFINE LGBLK(NAM)<
  5555. NAM'LOG:
  5556.     $BUILD    $LGSIZ            ; Build an LG block
  5557.      $SET    $LGFLG,,0        ; No flags (file no set)
  5558.      $SET    $LGFOB+FOB.CW,FB.BSZ,7    ; Byte size
  5559.      $SET    $LGFOB+FOB.FD,,NAM'LOG+$LGFD ; Address of FD
  5560.     $EOB                ; End of block
  5561. > ; End of LGBLK macro definition
  5562.  
  5563. ; Now expand the macro for each type of log file
  5564.  
  5565.     LGBLK(DBG)            ; Debugging log file
  5566.     LGBLK(SES)            ; Session log file
  5567.     LGBLK(TRN)            ; Transaction log file
  5568.  
  5569.  
  5570. ; FOB for debugging file
  5571.  
  5572. DBFFOB:    $BUILD    FOB.MZ            ; Build an FOB
  5573.      $SET    FOB.CW,FB.BSZ,7        ; Byte size
  5574.     $EOB                ; End of block
  5575.  
  5576.  
  5577. ;[107] Macro name table for DEFINE/SET
  5578.  
  5579. DFNTAB:    XWD    0,D$MAXD        ;[107] Current number, maximum
  5580.     BLOCK    D$MAXD            ;[107] Leave the space
  5581.  
  5582. PHALEN==.-LOWEND
  5583.  
  5584. PHAEND:    DEPHASE
  5585.  
  5586.     RELOC                ; Back to the low segment
  5587.     BLOCK    PHALEN            ; Allocate the phased space
  5588.     RELOC                ; Back to the high segment
  5589.     SUBTTL    End of Kermit
  5590.  
  5591. TOPS20<    END    <3,,KERMIT>>
  5592. TOPS10<    END    KERMIT>
  5593.