home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / d / cvker.src < prev    next >
Text File  |  2020-01-01  |  96KB  |  3,269 lines

  1. <<< KERMIT.BUFEMP >>>
  2. ; 18 jly 85 esj converted
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;; BUFEMP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4.       E'F A:S(NWLS)
  5.       E'O BUFEMP.(BUFFER,LEN)
  6.  
  7. ;     write out the content of the buffer out to the receiving disk file
  8. ;     BUFFER is an integer array which holds the data
  9. ;     LEN tells how many bytes are there in this buffer array
  10. ;
  11. ; NOTE -- the following /INCLUDES refer to files that are included below
  12. ; without the "BYU.PROG." prefix.  There are many /INCLUDES for these files,
  13. ; so watch out!
  14.  
  15. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  16. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  17.  
  18.       I'R BUFFER(132),LEN,CH,I,T
  19.  
  20. #     E'E HEXDMPP.(0,LEN,0,BUFFER)
  21.  
  22.       I=0                           ;start with the very first charact
  23.       W'E (I.L.LEN)                 ;put LEN characters into disk file
  24.          T=BUFFER(I)                ;get the next character from buffe
  25.          W'R (T.EQ.MYQUOTE)         ;is this my quote character
  26.             I=I+1                   ;increment the counter
  27.             T=BUFFER(I)             ;get next character from buffer
  28.             W'R (T.NE.MYQUOTE), T=CTL.(T)  ;is this quote character the
  29.                                     ;actual QUOTE character
  30.          E'L
  31.          W'R (T.NE.LF), E'E DPUTCH.(T,FD) ;filter out LF
  32.          I=I+1
  33.       E'W
  34.       F'N
  35.       E'N
  36. <<< KERMIT.BUFILL >>>
  37. ; 23 jly esj on cr, add lf
  38. ; 18 jly 85 esj converted
  39. ;;;;;;;;;;;;;;       BUFILL            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  40.       E'F A:S(NWLS)
  41.       E'O BUFILL.(BUFFER)
  42.  
  43. ;     fill up the buffer with character byte from the sending disk file
  44. ;     BUFFER is used to stored the data from the sending disk file
  45.  
  46. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  47. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  48.  
  49.       I'R I,BUFFER(132)
  50.  
  51.       I=0
  52.  
  53.       R'T
  54.          E'E DGETCH.(T,FD)                 ;keep reading byte from the d
  55.          W'R T .E. -1 , B'K                ;file until we reach an EOF,o
  56.                                            ;we have enough byte to fill
  57.                                            ;buffer, return from within t
  58.                                            ;directly
  59.          W'R ((T.LT.BLANK).OR.(T.EQ.DEL).OR.(T.EQ.QUOTE))
  60.              W'R (T.EQ.CR)               ;it is the line delimiter of
  61.                 BUFFER(I)=QUOTE            ;this system, insert the CR
  62.                 I=I+1                      ;before the LF
  63.                 BUFFER(I)=CTL.(CR)
  64.                 I=I+1
  65.                 T = LF                    ; and put lf in buffer
  66.              E'L
  67.              BUFFER(I)=QUOTE               ;we got a character that
  68.              I=I+1                         ;quoting
  69.              W'R (T.NE.QUOTE),T=CTL.(T)
  70.          E'L
  71.          BUFFER(I)=T
  72.          I=I+1
  73.          W'R (I.GT.(SPSIZ-8))      ;read up to spsiz-8 byte from disk
  74.             LCLSTATE=I               ;I byte was read
  75.             F'N LCLSTATE
  76.          E'L
  77.       F'R
  78.  
  79.       W'R (I.EQ.0)
  80.         LCLSTATE=EOF                   ;zero byte was read
  81.         F'N LCLSTATE
  82.       O'E
  83.         LCLSTATE=I                    ;partial EOF was detected
  84.         F'N LCLSTATE
  85.       E'L
  86.       F'N LCLSTATE
  87.       E'N
  88. <<< KERMIT.CHTOIN >>>
  89. ; 18 jly 85 esj converted
  90. ;;;;;;;;;;;;         CHTOIN             ;;;;;;;;;;;;;;;;;;;;;;;;;;;;C
  91.       E'F A:S(NWLS)
  92.       E'O CHTOIN.(CSTRING,ISTRING,ILENGTH)
  93.  
  94. ;     converts a character string into an integer array, using only the
  95. ;     the last 7 bits, also added an extra EOS into the end of the
  96. ;     integer array string
  97.  
  98. ;     CSTRING is the character string
  99. ;     ISTRING is the integer array which will hold the new string
  100. ;     ILENGTH tell how long the character string is
  101.  
  102. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  103.  
  104.       I'R ISTRING(1),ILENGTH
  105.  
  106.       I = 0
  107.       W'E I.L. ILENGTH
  108.          ISTRING(I) = LDBYTT.(CSTRING, I) .LAND. '7F'
  109.          I = I + 1
  110.       E'W
  111.  
  112.       ISTRING(I) = EOS
  113.       F'N
  114.       E'N
  115. <<< KERMIT.CTL >>>
  116. ; 18 jly 85 esj converted
  117. ;;;    CTL    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  118.       E'F A:S(NWLS)
  119.       E'O CTL.(T)
  120.  
  121. ;     toggle the control bit of a character so that
  122. ;     CNTR-A becomes A and vice versa
  123.  
  124.       I'R T
  125.  
  126.       F'N (T .EOR. 64)  ;do a exclusive OR on the control bit which is
  127.                       ;the seventh th bit
  128.       E'N
  129. <<< KERMIT.CTOI >>>
  130. ; 18 jly 85 esj converted
  131. ;;;       CTOI          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  132.       E'F A:S(NWLS)
  133.       E'O CTOI.(IN, I)
  134.       I'R IN(1)
  135.       I'R I, S
  136. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  137. LBL0 W'R (.NOT.(IN(I) .EQ. 32 .OR. IN(I) .EQ. 9)), T'O LBL1
  138.       I = I + 1
  139.       T'O LBL0
  140. LBL1 C'E
  141.       W'R (.NOT.(IN(I) .EQ. 45 .OR. IN(I) .EQ. 43)), T'O LBL2
  142.       S = IN(I)
  143.       I = I + 1
  144.       T'O LBL3
  145. LBL2 C'E
  146.       S = 0
  147. LBL3 C'E
  148.       LCLCTOI = 0
  149. LBL4 W'R (.NOT.(IN(I) .NE. 10002)), T'O LBL6
  150.       W'R (.NOT.(IN(I) .LT. 48 .OR. IN(I) .GT. 57)), T'O LBL7
  151.       T'O LBL6
  152. LBL7 C'E
  153.       LCLCTOI = 10 * LCLCTOI + IN(I) - 48
  154. LBL5 I = I + 1
  155.       T'O LBL4
  156. LBL6 C'E
  157.       W'R (.NOT.(S .EQ. 45)), T'O LBL9
  158.       LCLCTOI = -LCLCTOI
  159. LBL9 C'E
  160.       F'N LCLCTOI
  161.       E'N
  162. <<< KERMIT.DODOT >>>
  163. ;  6 aug 85 esj created
  164. ;--------------------------< dodot >------------------------------------
  165.    E'F
  166.    E'O DODOT.
  167. ;-----------------------------------------------------------------------
  168. ; purpose
  169. ; to print dots and to add a cr/lf after 79 char if in local mode
  170. ;
  171. ; input
  172. ;  none
  173. ;
  174. ; output
  175. ;  none
  176. ;
  177. ; insert files
  178. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  179. ;
  180. ; local static storage
  181. ;  none
  182. ;
  183. ; global
  184.    G'L DODOTCT    ; count the number of dots sent
  185.    G'L HOSTON     ; see kercom
  186. ;
  187. ;----------------------< start of code >--------------------------------
  188.  
  189.    W'R (HOSTON.EQ.NO)                 ;if we are running in local
  190.       E'E TYPOUT.(1,$..$)
  191.       DODOTCT = DODOTCT + 1
  192.       W'R DODOTCT .E. 78
  193.          DODOTCT = 0
  194.          E'E TYPE.(0,0)
  195.       E'L
  196.    E'L
  197.    F'N
  198.    E'N
  199. <<< KERMIT.IBMGETLN >>>
  200. ;;;;;;;;;;;;;;;;            IBMGETLN           ;;;;;;;;;;;;;;;;;;;;;;;;
  201.       E'F A:S(NWLS)
  202.       E'O IBMGETLN.(BUFFER,CH)
  203.  
  204. ;     read a packet with a SOH in it and wait for the prompt
  205. ;     before returning it
  206.  
  207. ;     BUFFER is an integer array that will hold the incoming packet
  208. ;     CH tells this routine which channel to read the packet from
  209.  
  210. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  211. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  212.  
  213.       I'R BUFFER(132),CH,STATUS,GASOH,COUNT,T,IBYTE
  214.       I'R X
  215.  
  216.       STATUS=YES
  217.       GASOH=NO                          ;we have not gotten a packet yet
  218.       COUNT=1
  219.       W'E (STATUS.EQ.YES)
  220.           W'E (GASOH.EQ.NO)          ;keep reading one byte at a tim
  221.             IBYTE=0                     ;the I/O port until you see the
  222.             X=TGETCH.(IBYTE,CH)          ;character , EOF is not expected
  223.             W'R (IBYTE.EQ.SOH)
  224.                GASOH=YES                ;I got the SOH
  225.                BUFFER(COUNT)=IBYTE      ;store the SOH into buffer
  226.                COUNT=COUNT+1            ;increment the buffer pointer
  227.             E'L
  228.           E'W
  229.           IBYTE=0
  230.           X=TGETCH.(IBYTE,CH)            ;read a byte from the I/O port
  231.           W'R (IBYTE.EQ.PROMPT)       ; we got the prompt
  232.              STATUS=NO
  233.           O'E
  234.               BUFFER(COUNT)=IBYTE       ;it is not a prompt, but another
  235.               COUNT=COUNT+1             ;data of the incoming packet
  236.           E'L                         ;store it and increment pointer
  237.       E'W
  238.       BUFFER(COUNT)=EOS                 ;add an EOS into end of buffer
  239.       LCLSTATE=OK
  240.       F'N LCLSTATE
  241.       E'N
  242. <<< KERMIT.INSTALL >>>
  243. *
  244. * THIS FILE WILL COMPILE AND LOAD CODE NEEDED FOR CV-KERMIT.
  245. *
  246. *-------------------------------------------------------------------------
  247. COMPILE BYU.PROG.KERMIT.BUFEMP
  248. COMPILE BYU.PROG.KERMIT.BUFILL
  249. COMPILE BYU.PROG.KERMIT.CHTOIN
  250. COMPILE BYU.PROG.KERMIT.CTL
  251. COMPILE BYU.PROG.KERMIT.CTOI
  252. COMPILE BYU.PROG.KERMIT.DODOT
  253. COMPILE BYU.PROG.KERMIT.IBMGETLN
  254. COMPILE BYU.PROG.KERMIT.KGETLIN
  255. COMPILE BYU.PROG.KERMIT.KMAIN
  256. COMPILE BYU.PROG.KERMIT.NEXTFILE
  257. COMPILE BYU.PROG.KERMIT.PACK
  258. COMPILE BYU.PROG.KERMIT.PARSER
  259. COMPILE BYU.PROG.KERMIT.PUTLIN
  260. COMPILE BYU.PROG.KERMIT.RDATA
  261. COMPILE BYU.PROG.KERMIT.RECSW
  262. COMPILE BYU.PROG.KERMIT.RFILE
  263. COMPILE BYU.PROG.KERMIT.RINIT
  264. COMPILE BYU.PROG.KERMIT.RPACK
  265. COMPILE BYU.PROG.KERMIT.RPAR
  266. COMPILE BYU.PROG.KERMIT.SBREAK
  267. COMPILE BYU.PROG.KERMIT.SCONNECT
  268. COMPILE BYU.PROG.KERMIT.SCOPY
  269. COMPILE BYU.PROG.KERMIT.SDATA
  270. COMPILE BYU.PROG.KERMIT.SENDSW
  271. COMPILE BYU.PROG.KERMIT.SEOF
  272. COMPILE BYU.PROG.KERMIT.SETCOOK
  273. COMPILE BYU.PROG.KERMIT.SETPORT
  274. COMPILE BYU.PROG.KERMIT.SETRAW
  275. COMPILE BYU.PROG.KERMIT.SFILE
  276. COMPILE BYU.PROG.KERMIT.SHELP
  277. COMPILE BYU.PROG.KERMIT.SINIT
  278. COMPILE BYU.PROG.KERMIT.SPACK
  279. COMPILE BYU.PROG.KERMIT.SPAR
  280. COMPILE BYU.PROG.KERMIT.SQUIT
  281. COMPILE BYU.PROG.KERMIT.SRECEIVE
  282. COMPILE BYU.PROG.KERMIT.SSEND
  283. COMPILE BYU.PROG.KERMIT.SSET
  284. COMPILE BYU.PROG.KERMIT.SSTATUS
  285. COMPILE BYU.PROG.KERMIT.TEXT-FILE-IO
  286. COMPILE BYU.PROG.KERMIT.TGETCH
  287. COMPILE BYU.PROG.KERMIT.TOCHAR
  288. COMPILE BYU.PROG.KERMIT.TPUTCH
  289. COMPILE BYU.PROG.KERMIT.UN&PACK
  290. COMPILE BYU.PROG.KERMIT.UNCHAR
  291. COMPILE BYU.PROG.KERMIT.XDELAY
  292. *
  293. *
  294. *
  295. SYSLOAD BYU.PROG.KERMIT.MAKE
  296. GENCOMIX
  297.  
  298. COPYTEXT BYU.PROG.KERMIT.SYSNEWS SYSNEWS.COMMAND.KERMIT//REPLACE=NEWER
  299. <<< KERMIT.KGETLIN >>>
  300. ; 16 jly 85 esj converted
  301. ;;;;;;;;;;;;;;;;;;              KGETLIN             ;;;;;;;;;;;;;;;;;;;;
  302.       E'F A:S(NWLS)
  303.       E'O KGETLIN.(BUFFER,UNIT)
  304.  
  305. ;     read a packet with a SOH in it and DON'T wait for the prompt
  306. ;     before returning it
  307.  
  308. ;     BUFFER is an integer array that will hold the incoming packet
  309. ;     UNIT tells this routine which device to read the packet from
  310.  
  311. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  312. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  313.  
  314.       I'R BUFFER(*),STATUS,GASOH,COUNT,IBYTE
  315.       I'R X,LCLSTATE
  316.  
  317. ;      E'E TYPEHEX.(.ADDR.BUFFER)
  318.       STATUS=YES
  319.       GASOH=NO                          ;we have not gotten a packet yet
  320.       COUNT=0
  321.       W'E (STATUS.EQ.YES)
  322.           IBYTE=0
  323.           X=TGETCH.(IBYTE,UNIT)            ;read a byte from the I/O port
  324.           W'R (IBYTE.EQ.MYEOL .AND. GASOH .E. YES) ;we got the required MYEOL
  325.              STATUS=NO
  326.           O'R (IBYTE .E. SOH)
  327.              BUFFER(0)=IBYTE        ;store the SOH into buffer
  328.              COUNT = 1              ; rest buffer pointer to first soh
  329.              GASOH = YES
  330.           O'R (GASOH .E. YES)       ; get char into buffer iff gasoh=yes
  331.               BUFFER(COUNT)=IBYTE       ;it is not MYEOL, but another
  332.               COUNT=COUNT+1             ;data of the incoming packet
  333.           E'L                         ;store it and increment pointer
  334.       E'W
  335.       BUFFER(COUNT)=EOS                 ;add an EOS into end of buffer
  336.       LCLSTATE=OK
  337. ;      E'E TYPOUT.(2,$KL$)
  338. ;      E'E TYPEHEX.(COUNT)
  339.  ;     E'E TYPEHEX.(.ADDR.(BUFFER(COUNT)))
  340.   ;    E'E STACKDMP.
  341.       F'N LCLSTATE
  342.       E'N
  343. <<< KERMIT.KMAIN >>>
  344. ; 15-AUG-85 MVI: CHANGED NO IOFLAG VALUE FROM 0 TO -1.
  345. ;  7 aug 85 dg/esj added no wait io support
  346. ; 17 jly 85 esj converted
  347. ;;;;;;;;;;;;;;    KMAIN       ;;;;;;;;;;;;;;;;;;;;;;;
  348. ;
  349.       E'F A:S(NWLS)
  350.       E'O KMAIN.
  351.  
  352. ;     CGOS-KERMIT MAIN PROGRAM
  353.  
  354. ;     CGOS KERMIT was converted from hp1000 kermit
  355. ;     guilty parties:   esj, lec, pcc
  356. ;     cohort in crime:  mvi
  357.  
  358. ;     HP1000 KERMIT was implemented by John Lee of RCA Laboratories
  359. ;     6/29/84
  360.  
  361. ;     Permission is granted to any individual or instution to copy
  362. ;     or use this program, except for explicitly commerical purpose.
  363.  
  364.  
  365. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  366. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  367.  
  368.  
  369.       G'L VENQACK,VXONXOFF
  370.       G'L VERNUM
  371.  
  372.  
  373. *     FORMATS TRANSFORMED TO V:S
  374.       V'S F99   =  $ CGOS KERMIT Version!$
  375.       V'S F100  =  $ Remote Host KERMIT mode now in effect!$
  376.  
  377.       DELAY = 15           ; 15 SECONDS
  378.       EOL = 13             ; CR
  379.       ESCHAR = 29          ; CNTR-]
  380.       HOSTON = YES         ; we are running in Remote Host mode
  381.       IBMON = NO
  382.  
  383. ;     set up no wait io for terminal io
  384.       LOCALDEV = $SD$      ; default comdev
  385.       LOCALDEV(1) = -1     ; no io flag yet
  386.       RMTDEV   = $SD$      ; default kermit device name since we wake up in
  387.       RMTDEV(1)   = -1     ; no io flag yet
  388.       MAXTRY = 5           ; remote mode
  389.       MYEOL = 13
  390.       MYPAD = 0
  391.       MYPCHAR = 0
  392.       MYQUOTE = 35
  393.       PAD = 0
  394.       PADCHAR = 0
  395.       PAKSIZ = 80
  396.       PROMPT = 17           ;DC1, IBM MODE ONLY
  397.       QUOTE = 35
  398.       SOH = 1
  399.       STATE = BIGC
  400.       SPARITY = NO
  401.       SBAUD = NO
  402.       SPORT = YES
  403.       VXONXOFF = 1     ;set XON/XOFF enabled
  404.       VENQACK = 0      ;set ENQ/ACK disabled
  405. ;
  406.  
  407.  
  408. ;     determine whether we are running in Remote or Local KERMIT mode
  409.       HOSTON  =  YES             ;remote kermit in effect
  410.       E:E TYPMSG.(F99)
  411.       E:E TYPEMSG.(VERNUM)
  412.       E:E TYPEMSG.(F100)
  413.  
  414.       E'E PARSER.
  415.       F'N
  416.       E'N
  417. <<< KERMIT.MAKE >>>
  418. * 16 sep 86 cdo; copied to the byu catalog
  419. * 12 sep 85 esj  changed loadsym to janmake.symfile.universe
  420. * 26 aug 85 esj  added loadlib.kermit and globals dodotct and lclchq
  421. *  6 aug 85 esj  birthday
  422. *---------------------< cvcommand.make.command.kermit >---------------------
  423. *
  424. *
  425. *
  426. *load symbol files & insert equate files
  427. *---------------------------------------
  428. loadsym janmake.symfile.universe
  429. *
  430. *
  431. *
  432. *define object code block
  433. *------------------------
  434. equ &blksiz 3000
  435. equ &blktop &command+&blksiz
  436. *
  437. *
  438. *
  439. *define common area (globals) block
  440. *----------------------------------
  441. equ &gvsiz 2000
  442. equ &gvtop &blktop+&gvsiz
  443. *
  444. *
  445. *
  446. *define misc: sort buffers or temp buffer.......
  447. *-----------------------------------------------
  448. equ   &remspac     &cortop - &gvtop - 100
  449. if &remspac  > 1000
  450.       equ &arraysz 1000
  451. else
  452.       equ &arraysz &remspac
  453. endc
  454. *
  455. *
  456. *
  457. *define start : code is loaded from
  458. *----------------------------------
  459. cororg &command
  460. *
  461. *
  462. *
  463. block &gvtop,&cortop  ;(misc area)
  464. *---------------------------------
  465. *
  466. *
  467. *
  468. block &blktop,&gvtop ;(common area)
  469. *----------------------------------
  470. print " loading globals "
  471.  
  472. global fd(100), ifd(100), ifdflg(1)
  473. global delay(1), eol(1), eschar(1), filname(85), hoston(1)
  474. global ibmon(1), maxtry(1), myeol(1)
  475. global mypad(1), mypchar(1), myquote(1), n(1), numtry(1)
  476. global oldtry(1), packet(85), pad(1), padchar(1), paksiz(1)
  477. global parity(1), prompt(1), quote(1), recpkt(85)
  478. global rmtdev(2), localdev(2)
  479. global rmttty(85), rpsiz(1), sbaud(1), size(1)
  480. global soh(1), sparity(1), speed(1), sport(1), spsiz(1), state(1)
  481. global venqack(1), vxonxoff(1)
  482. global xnew(1), xcount(1), xeof(1)
  483. global tpname(84), timeout(2), dodotct(1), lclchq(1001)
  484. *
  485. block &command,&blktop ;(object code block)
  486. *------------------------------------------
  487.  
  488. print " loading code "
  489. *
  490. calltv kmain
  491. *
  492. * MUST BE INCLUDED WITH EVERY SUBMISSION!
  493. insert byu.prog.kermit.version-log
  494. *
  495. *load subroutines
  496. *-----------------------------------------
  497. load byu.prog.kermit/kmain, bufemp, bufill, chtoin, ctl, ctoi
  498. load byu.prog.kermit/ibmgetln, kgetlin
  499. load byu.prog.kermit/pack, parser, putlin, rdata
  500. load byu.prog.kermit/recsw, rfile, rinit
  501. load byu.prog.kermit/rpack, rpar, sbreak
  502. load byu.prog.kermit/scopy, sdata, sendsw, seof
  503. load byu.prog.kermit/setcook, setport, setraw
  504. load byu.prog.kermit/sinit, spack, spar
  505. load byu.prog.kermit/squit, sreceive, nextfile
  506. load byu.prog.kermit/text-file-io, tgetch, tochar, tputch, un&pack
  507. load byu.prog.kermit/unchar, sfile, shelp, dodot
  508. load byu.prog.kermit/sconnect, ssend, sset, sstatus, xdelay
  509.  
  510. *load all undefined referenced subroutines
  511. *-----------------------------------------
  512.  
  513. print " loading loadlibs "
  514.  
  515. lib byu.prog.kermit.loadlib.kermit
  516. lib loadlib.oslib
  517. *
  518. *
  519. *
  520. *define: referencing command name or dloc
  521. *----------------------------------------
  522. if debug = -1
  523.    filename kermee
  524. else
  525.    filename =cvscommand.kermit
  526. endc
  527. cwrite &blksiz,&command,&cortop
  528. <<< KERMIT.NEXTFILE >>>
  529. ;  7 aug 85 esj created
  530. ;--------------------------< nextfile >---------------------------------
  531.    E'F
  532.    E'O NEXTFILE.( FILEDESC, FNAME)
  533. ;-----------------------------------------------------------------------
  534. ; purpose
  535. ;  to get the next file name from the file specified in fd
  536. ;
  537. ; input
  538.    I'R FILEDESC(*)   ; descriptor of the file containing names
  539. ;
  540. ; output
  541.    I'R FNAME(*)      ; cgos format filename. fname will = 0 when there
  542.                      ; are no more files to be opened
  543. ;
  544. ; insert files
  545. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  546. ;
  547. ; local static storage
  548.    I'R CHAR
  549. ;
  550. ; global
  551. ;  none
  552. ;
  553. ;----------------------< start of code >--------------------------------
  554.    FNAME(0) = 0
  555.    R'T
  556.       E'E DGETCH.(CHAR, FILEDESC)
  557.       W'R CHAR .E. '0D' .OR. CHAR .E. -1
  558.          E'E PACKLINE.($! $, FNAME)
  559.          B'K
  560.       E'L
  561.       E'E PACKLINE.(CHAR,FNAME)
  562.    F'R
  563.  
  564. #  E'E TYPE.(0,0)
  565. #  E'E HEXDMP.(FNAME, FNAME+FNAME+1, FNAME, FNAME)
  566.  
  567.    W'R CHAR .E. -1
  568.       E'E CLOSTEXT.(FILEDESC)
  569.       FNAME = 0
  570.    E'L
  571.  
  572.    F'N  GOOD
  573.    E'N
  574. <<< KERMIT.PACK >>>
  575. ; 18 jly 85 esj converted
  576. ;;;;;;;;;;;; PACK           ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  577.    E'F A:S(NWLS)
  578.    E'O PACK.(XFROM,XTO)
  579.  
  580. ;     pack the integer array of XFROM into the array of XTO
  581.  
  582. ; input
  583.    I'R XFROM(*)   ; string in kermit format
  584.  
  585. ; output
  586.    I'R XTO        ; array XTO is a cv format string array
  587.  
  588.  
  589. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  590.  
  591.    I = 0
  592.    XTO = 0
  593.  
  594.    W'E XFROM(I) .NE. EOS
  595.       E'E PACKLINE.(XFROM(I), XTO)
  596.       I = I + 1
  597.    E'W
  598.    F'N
  599.    E'N
  600. <<< KERMIT.PARSER >>>
  601. ; 16 aug 85 esj remove server commands that were added as aliases
  602. ; 12 aug 85 esj add extra aliases
  603. ;  6 aug 85 esj set dot count to 0 on every command
  604. ; 26 jly 85 esj detach kermit port on quit.
  605. * 15-Jul-85 lec; TPL conversion.
  606. ;--------------------------------------< parser >---------------------------
  607.       E:F
  608.       E'O PARSER.
  609. ;----------------------------------------------------------------------------
  610. ;
  611. ; Purpose
  612. ;  the main parser at the command level of kermit
  613.  
  614. ; Input
  615. ;  none
  616.  
  617. ; Output
  618. ;  none
  619.  
  620. ; Inserts
  621. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  622.  
  623. ; Globals
  624.    G'L HOSTON
  625.    G'L DODOTCT
  626.  
  627. ; Locals
  628.    I'R BLIN(132)
  629.    I'R STATUS
  630.    I:R OPTION(4)
  631.  
  632. ; Method
  633. ;  initialize keyword character string
  634.  
  635. ;  convert character string to integer array with an EOS at end
  636. ;  of the integer array
  637.  
  638. ;  do forever
  639.  
  640. ;---------------------------< start of code >-------------------------------
  641.  
  642.       STATUS=YES
  643.  
  644.       W'E (STATUS.EQ.YES)
  645. ;        set dot count to 0
  646.          DODOTCT = 0
  647.  
  648.          W'R HOSTON .E. YES
  649. ;           when running local kermit, put prompt in caps
  650.             E'E TYPOUT.(9, $KERMIT-CV$)
  651.          O'E
  652. ;           when running remote kermit, put prompt in lowercase
  653.             E'E TYPOUT.(9, $kermit-cv$)
  654.          E'L
  655.          W:R NEWCMD.($> $,1,0) .G. 0
  656.             E:E IDENT.(OPTION)
  657.  
  658.             ;it is the keyword CONNECT
  659.             W'R COMPNAM.(OPTION,$CONNECT $) .E. 0 .OR.
  660. 1               COMPNAM.(OPTION,$CON     $) .E. 0 .OR.
  661. 1               COMPNAM.(OPTION,$C       $) .E. 0
  662.                E'E SCONNECT.
  663.  
  664.             ;it is the keyword QUIT or EXIT
  665.             O'R COMPNAM.(OPTION,$QUIT    $) .E. 0 .OR.
  666. 1               COMPNAM.(OPTION,$EXIT    $) .E. 0 .OR.
  667. 1               COMPNAM.(OPTION,$Q       $) .E. 0 .OR.
  668. 1               COMPNAM.(OPTION,$E       $) .E. 0
  669.                E'E DETACH.($KM$)
  670.                E:E TYPEMSG.($Leaving KERMIT now...!$)
  671.                STATUS = $NO$
  672.  
  673.             ;it is the keyword HELP
  674.             O'R COMPNAM.(OPTION,$HELP    $) .E. 0
  675.                E'E SHELP.
  676.  
  677.             ;it is the keyword RECEIVE
  678.             O'R COMPNAM.(OPTION,$RECEIVE $) .E. 0 .OR.
  679. 1               COMPNAM.(OPTION,$REC     $) .E. 0 .OR.
  680. 1               COMPNAM.(OPTION,$R       $) .E. 0
  681.                E'E SRECEIVE.
  682.  
  683.             ;it is the keyword SET
  684.             O'R COMPNAM.(OPTION,$SET     $) .E. 0
  685.                E'E SSET.(BLIN)
  686.  
  687.             ;it is the keyword SEND
  688.             O'R COMPNAM.(OPTION,$SEND    $) .E. 0
  689.                E'E SSEND.
  690.  
  691.             ;it is the keyword STATUS
  692.             O'R COMPNAM.(OPTION,$STATUS  $) .E. 0
  693.                E'E SSTATUS.
  694.  
  695.             O'E
  696.                E:E TYPEMSG.($Unrecognized command  type "HELP"!$)
  697.             E'L
  698.          E:L
  699.       E'W
  700.  
  701.       F'N
  702.       E:N
  703. <<< KERMIT.PUTLIN >>>
  704. ; 07 AUG 85 DG IOFLAG IS PART OF UNIT
  705. ;              ADDED NO WAIT I/O SUPPORT
  706. ; 18 jly 85 esj
  707. ;-------------------------------< putlin >-------------------------------
  708.    E'F A:S(NWLS)
  709.    E'O PUTLIN.(ALIN,UNIT)
  710. ;------------------------------------------------------------------------
  711. ;     output a line ot the specific channel
  712.  
  713. ; input
  714.    I'R ALIN       ; line in kermit format to be output
  715.    I'R UNIT(1)    ; UNIT(0) unit we want to send I/O to
  716.                   ; UNIT(1) I/O flag for the unit
  717.  
  718. ; output
  719. ;  none
  720.  
  721. ; local storage
  722.    I'R ARGLIST(3)
  723.    I'R LINE(80)               ; temp line storage
  724.  
  725. ; insert files
  726. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  727.  
  728.  
  729. ;------------------------< start of executable code >-----------------------
  730.  
  731.    LINE(0) = 0
  732.    E'E PACK.(ALIN, LINE)
  733.  
  734.    ARGLIST(0) = 0
  735.    ARGLIST(1) = LINE(0)
  736.    ARGLIST(2) = 0
  737.  
  738.    W'R UNIT(1) .NE. 0
  739. ;     non zero means not first time through for this unit
  740.  
  741.       W:R TESTIO.(UNIT(1)).E.0     ;I/O IN PROGRESS FROM LAST REQUEST
  742.          E:E WAITIO.(UNIT(1))      ;WAIT FOR I/O TO FINISH
  743.       E:L
  744.    E'L
  745.  
  746.    UNIT(1) = CONTROL.( UNIT, ARGLIST, LINE(1), 0 )
  747.  
  748.    F'N
  749.    E'N
  750. <<< KERMIT.RDATA >>>
  751. ; 18 jly 85 esj converted
  752. ;;;;;;;;;;;;;           RDATA        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  753.       E'F A:S(NWLS)
  754.       E'O RDATA.(X)
  755.  
  756. ;     read a data packet from the other KERMIT
  757.  
  758. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  759. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  760.  
  761.       I'R NUM,LEN,STATUS,X,TNUM
  762.       I'R TV1,TV2,TV3,TV4
  763.  
  764.    W'R (NUMTRY.GT.MAXTRY)
  765.       LCLSTATE=BIGA                   ;exceeded maxtry , gives up
  766.       E'E CLOSTEXT.(FD)
  767.  
  768.    O'E
  769.       NUMTRY=NUMTRY+1             ;try it again
  770.       STATUS=RPACK.(LEN,NUM,PACKET)    ;read a packet
  771.  
  772.       E'E DODOT.                 ; tell all if ok to
  773.  
  774.       W'R (STATUS.EQ.BIGD)          ;we got the data packet
  775.          W'R (NUM.NE.N)
  776.             W'R (OLDTRY.GT.MAXTRY)
  777.                LCLSTATE=BIGA
  778.                E'E CLOSTEXT.(FD)
  779.             O'E
  780.                OLDTRY=OLDTRY+1
  781.                W'R (NUM.EQ.(N-1))
  782.                   E'E SPAR.(PACKET)      ;we got a duplicted packet
  783.                   TV1=BIGY               ;just ACK it
  784.                   TV2=6
  785.                   E'E SPACK.(TV1,NUM,TV2,PACKET)
  786.                   NUMTRY=0
  787.                   LCLSTATE=STATE
  788.                O'E
  789.                   LCLSTATE=BIGA
  790.                   E'E CLOSTEXT.(FD)
  791.                E'L
  792.             E'L
  793.  
  794.          O'E
  795.             E'E BUFEMP.(PACKET,LEN)     ;write the data packet just receive
  796.             TNUM=N                      ;into the receiving disk file
  797.             TV1=BIGY
  798.             TV2=TNUM
  799.             TV3=0
  800.             TV4=0
  801.             E'E SPACK.(TV1,TV2,TV3,TV4) ;ACK the just received packet
  802.             OLDTRY=NUMTRY
  803.             NUMTRY=0
  804.             N=(N+1) .MOD. 64
  805.             LCLSTATE=BIGD
  806.          E'L
  807.  
  808.       O'R (STATUS.EQ.BIGF)        ;the packet is the file header
  809.          W'R (OLDTRY.GT.MAXTRY)   ;we should have already gotten
  810.             LCLSTATE=BIGA              ;exceeded number of retry, give
  811.             E'E CLOSTEXT.(FD)
  812.  
  813.          O'E
  814.             OLDTRY=OLDTRY+1
  815.             W'R (NUM.EQ.(N-1))       ;we got duplicate file header p
  816.                TV1=BIGY
  817.                TV2=0
  818.                TV3=0
  819.                E'E SPACK.(TV1,NUM,TV2,TV3)  ;just ACK it
  820.                NUMTRY=0
  821.                LCLSTATE=STATE
  822.  
  823.             O'E
  824.                LCLSTATE=BIGA
  825.                E'E CLOSTEXT.(FD)
  826.  
  827.             E'L
  828.          E'L
  829.  
  830.       O'R (STATUS.EQ.BIGZ)             ;we got the EOF packet
  831.          W'R (NUM.NE.N)
  832.             LCLSTATE=BIGA
  833.             E'E CLOSTEXT.(FD)
  834.          O'E
  835.             TNUM=N
  836.             TV1=BIGY
  837.             TV2=0
  838.             TV3=0
  839.             E'E SPACK.(TV1,TNUM,TV2,TV3)  ;ACK it
  840.             E'E CLOSTEXT.(FD)             ;close the receiving disk fi
  841.             N = (N+1) .MOD. 64
  842.             LCLSTATE=BIGF                    ;change the state to look fo
  843.           E'L
  844.  
  845.       O'R (STATUS.EQ.BAD)
  846.               LCLSTATE=STATE                   ;there was an error in the
  847.               TNUM=N                        ;checksum
  848.               TV1=BIGN
  849.               TV2=0
  850.               TV3=0
  851.               E'E SPACK.(TV1,TNUM,TV2,TV3)  ;NAK it
  852.  
  853.       O'E
  854.           LCLSTATE=BIGA                     ;we got a unknown packet type
  855.           E'E CLOSTEXT.(FD)
  856.       E'L                              ;gives up
  857.    E'L
  858.    F'N LCLSTATE
  859.    E'N
  860. <<< KERMIT.RECSW >>>
  861. ; 17 jly 85 esj converted
  862. ;;;;;;;;;;;;;             RECSW            ;;;;;;;;;;;;;;;;;;;;;;;
  863.       E'F A:S(NWLS)
  864.       E'O RECSW.(X)
  865.  
  866. ;     receive a file or a group of file from the other KERMIT
  867.  
  868. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  869. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  870.  
  871.       G'L XNEW,XCOUNT
  872.       I'R X,STATUS
  873.       I'R TV1,TV2,TV3,TV4
  874.  
  875.       STATUS=YES
  876.       STATE=BIGR
  877.       XNEW=YES
  878.       XCOUNT=1
  879.       N=0
  880.       NUMTRY=0
  881.       W'E (STATUS.EQ.YES)
  882. #              E'E TYPOUT.(2,'A000'.LOR.STATE)
  883. #              E'E TYPEMSG.($ is current state!$)
  884.  
  885.                W'R (STATE.EQ.BIGD)                ;read a DATA packet
  886.                   STATE=RDATA.(X)
  887.  
  888.                O'R(STATE.EQ.BIGR)           ;read a SINIT packet
  889.                    STATE=RINIT.(X)
  890.  
  891.                O'R(STATE.EQ.BIGF)           ;read a file header
  892.                    STATE=RFILE.(X)
  893.  
  894.                O'R(STATE.EQ.BIGC)           ;file transfer compl
  895.                    LCLSTATE=YES
  896.                    F'N LCLSTATE
  897.  
  898.                O'R(STATE.EQ.BIGA)           ;we got an error
  899.                    LCLSTATE=NO
  900.                    TV1=BIGE
  901.                    TV2=N
  902.                    TV3=0
  903.                    TV4=0
  904.                    E'E SPACK.(TV1,TV2,TV3,TV4)  ;send an ERROR packe
  905.                    F'N LCLSTATE                       ;file channel
  906.                E'L
  907.       E'W
  908.       F'N LCLSTATE
  909.       E'N
  910. <<< KERMIT.RFILE >>>
  911. ; 17 jly 85 esj converted
  912. ;----------------------------------------< rfile >--------------------------
  913.       E'F A:S(NWLS)
  914.       E'O RFILE.(X)
  915. ;----------------------------------------------------------------------------
  916. ;
  917. ; Purpose
  918. ;  read a file header packet from the other KERMIT
  919.  
  920. ; Input
  921. ;  none
  922.  
  923. ; Output
  924. ;  none
  925.  
  926. ; Inserts
  927. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  928. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  929.  
  930. ; Globals
  931. ;  none
  932.  
  933. ; Locals
  934.    I'R NUM,LEN,STATUS,LCLSTATE,X,TNUM
  935.    I'R TV1,TV2,TV3,TV4,XWRITE
  936.  
  937. ;---------------------------< start of code >-------------------------------
  938.  
  939.       XWRITE=1
  940.       W'R (NUMTRY.GT.MAXTRY)
  941.          LCLSTATE=BIGA                          ;exceeded max. # of re-try
  942.          F'N LCLSTATE                              ;gives up
  943.       O'E
  944.           NUMTRY=NUMTRY+1
  945.       E'L
  946.       STATUS=RPACK.(LEN,NUM,PACKET)
  947.       W'R (STATUS.EQ.BIGS)                 ;we got a SINIT packet
  948.          W'R (OLDTRY.GT.MAXTRY)
  949.             LCLSTATE=BIGA                       ;re-try it again
  950.             F'N LCLSTATE
  951.          O'E
  952.              OLDTRY=OLDTRY+1
  953.          E'L
  954.  
  955.          W'R (NUM.EQ.(N-1))                ;we already got the SINIT
  956.             E'E SPAR.(PACKET)                ;packet, get my file-transf
  957.             TV1=BIGY                         ;requirement/parameters
  958.             TV2=6
  959.             E'E SPACK.(TV1,NUM,TV2,PACKET)   ;ACK it
  960.             NUMTRY=0
  961.             LCLSTATE=STATE
  962.             F'N LCLSTATE
  963.  
  964.          O'E
  965.              LCLSTATE=BIGA                      ;unexpected sequence #
  966.              F'N LCLSTATE                          ;gives up
  967.          E'L
  968.  
  969.       O'R (STATUS.EQ.BIGZ)            ;we got a EOF packet
  970.               W'R (OLDTRY.GT.MAXTRY)
  971.                  LCLSTATE=BIGA                  ;exceeded max # of re-try
  972.                  F'N LCLSTATE                      ;gives up
  973.  
  974.               O'E
  975.                   OLDTRY=OLDTRY+1            ;re-try one more time
  976.               E'L
  977.  
  978.               W'R (NUM.EQ.(N-1))
  979.                  TV1=BIGY                    ;we already got the EOF pac
  980.                  TV2=0
  981.                  TV3=0
  982.                  E'E SPACK.(TV1,NUM,TV2,TV3) ;just ACK it
  983.                  NUMTRY=0
  984.                  LCLSTATE=STATE
  985.                  F'N LCLSTATE
  986.  
  987.               O'E
  988.                   LCLSTATE=BIGA                 ;unexpected sequence #
  989.                   F'N LCLSTATE
  990.               E'L
  991.  
  992.       O'R (STATUS.EQ.BIGF)            ;we got the file header pac
  993.               W'R (NUM.NE.N)
  994.                  LCLSTATE=BIGA                  ;unexpected sequence #,give
  995.                  F'N LCLSTATE
  996.               E'L
  997.  
  998.               PACKET(LEN)=EOS              ;filename packet
  999.               W'R (HOSTON.EQ.NO)
  1000.                  E'E TYPE.(0,0)
  1001.                  E:E TYPMSG.($Receiving !$)
  1002.                  E'E PUTLIN.(PACKET,LOCALDEV) ;display the incoming file
  1003.                  E'E TYPE.(0,0)
  1004.               E'L
  1005.  
  1006.               ERR = OPENTEXT.(PACKET,$SU$, $KM$, FD) ;open that file for writing
  1007.               W'R (ERR.NE.0)
  1008.                  LCLSTATE=BIGA                  ;we got a ERR in opening th
  1009.                  F'N LCLSTATE
  1010.               E'L
  1011.  
  1012.               TNUM=N
  1013.               TV1=BIGY
  1014.               TV2=0
  1015.               TV3=0
  1016.               E'E SPACK.(TV1,TNUM,TV2,TV3)   ;ACK the file header packet
  1017.               OLDTRY=NUMTRY
  1018.               NUMTRY=0
  1019.               N=(N+1) .MOD. 64
  1020.               LCLSTATE=BIGD                    ;change state to look for DA
  1021.               F'N LCLSTATE                        ;packet
  1022.  
  1023.       O'R (STATUS.EQ.BIGB)           ;we got a BREAK transmission
  1024.               W'R (NUM.NE.N)
  1025.                  LCLSTATE=BIGA
  1026.                  F'N LCLSTATE
  1027.               E'L
  1028.  
  1029.               TNUM=N
  1030.               TV1=BIGY
  1031.               TV2=0
  1032.               TV3=0
  1033.               E'E SPACK.(TV1,TNUM,TV2,TV3) ;ACK the BREAK packet
  1034.               LCLSTATE=BIGC                   ;change state to complete sta
  1035.               F'N LCLSTATE
  1036.  
  1037.       O'R (STATUS.EQ.BAD)           ;we got an error on the check
  1038.               LCLSTATE=STATE
  1039.               TNUM=N
  1040.               TV1=BIGN
  1041.               TV2=0
  1042.               TV3=0
  1043.               E'E SPACK.(TV1,TNUM,TV2,TV3) ;NAK it
  1044.               F'N LCLSTATE
  1045.       O'E
  1046.           LCLSTATE=BIGA                       ;unexpected packet type, give
  1047.       E'L
  1048.       F'N LCLSTATE
  1049.       E'N
  1050. <<< KERMIT.RINIT >>>
  1051. ; 17 jly 85 esj converted
  1052. ;;;;;     RINIT     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1053.       E'F A:S(NWLS)
  1054.       E'O RINIT.(X)
  1055.  
  1056. ;     receive the initial packet from the remote KERIT
  1057.  
  1058. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  1059. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  1060.  
  1061.       I'R LEN,NUM,STATUS,LCLSTATE,X,TNUM
  1062.       I'R TV1,TV2,TV3
  1063.  
  1064.       W'R (NUMTRY.GT.MAXTRY)
  1065.          LCLSTATE=BIGA                           ;exceeded max. # of re-try
  1066.          F'N LCLSTATE                               ;gives up
  1067.       O'E
  1068.           NUMTRY=NUMTRY+1                     ;try-it again
  1069.       E'L
  1070.  
  1071.       E'E FILL.(40,0,PACKET)
  1072.  
  1073.       STATUS=RPACK.(LEN,NUM,PACKET)            ;read a packet
  1074.       W'R (STATUS.EQ.BIGS)                  ;we got a SINIT packet
  1075.          E'E RPAR.(PACKET)                    ;store other KERMIT's requ
  1076.          E'E SPAR.(PACKET)                    ;get our parameters/requir
  1077.          TNUM=N
  1078.          TV1=BIGY
  1079.          TV2=6
  1080.          E'E SPACK.(TV1,TNUM,TV2,PACKET)      ;send out requirement and
  1081.          OLDTRY=NUMTRY                        ;ACK it on one shot
  1082.          NUMTRY=0
  1083.          N=((N+1).MOD.64)
  1084.          LCLSTATE=BIGF                           ;change state to look for
  1085.          F'N LCLSTATE                               ;the file header packet
  1086.  
  1087.       O'R(STATUS.EQ.BAD)              ;we got a checksum error
  1088.            LCLSTATE=STATE
  1089.            TNUM=N
  1090.            TV1=BIGN
  1091.            TV2=0
  1092.            TV3=0
  1093.            E'E SPACK.(TV1,TNUM,TV2,TV3)       ;NAK it
  1094.            F'N LCLSTATE
  1095.  
  1096.       O'E
  1097.           LCLSTATE=BIGA                          ;we got an unexpected pack
  1098.       E'L                                   ;type, gives up
  1099.  
  1100.       F'N LCLSTATE
  1101.       E'N
  1102. <<< KERMIT.RPACK >>>
  1103. ; 16 jly 85 esj converted
  1104. ;;;;;;    RPACK     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1105.       E'F A:S(NWLS)
  1106.       E'O RPACK.(LEN,NUM,XDATA)
  1107.  
  1108. ;     read a packet from other KERMIT
  1109.  
  1110. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  1111. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  1112.  
  1113.       I'R LEN,NUM,UNIT
  1114.       I'R XDATA(1)
  1115.       I'R COUNT,STATUS,J,K,T
  1116.       I'R TV1,TV2,TV3, LCLSTATE
  1117.       I'R BUFFER(132),CHKSUM,XTYPE,GAPTRY,MGAPTRY
  1118.  
  1119.       G'L TIMEOUT(1)       ; temp for lblset call
  1120.  
  1121. ;------------------------------< debugging stubs >----------------------------
  1122.  
  1123. #   LEN = 0
  1124. #   NUM = N
  1125. #   XDATA = 0
  1126. #   E'E TGETCH.(XTYPE,$SD$)
  1127. #   E'E FILL.(132,0,XDATA)
  1128. #   F'N XTYPE
  1129.  
  1130. ;------------------------------< real code >----------------------------
  1131. ;     setup lblset for handling deadlock condition
  1132.       E'E LBLSET.(TIMEOUT, WAYOUT)
  1133.  
  1134.       UNIT=RMTDEV                           ;this is the input channel to
  1135.                                            ;a packet from
  1136.       GAPTRY=1
  1137.       MGAPTRY=2
  1138.       CHKSUM=0
  1139.  
  1140. ;     read me a packet that begins with a SOH and ends with MYEOL
  1141.  
  1142.       W'E (GAPTRY.LE.MGAPTRY)
  1143.          W'R (IBMON.EQ.YES)
  1144.             STATUS=IBMGETLN.(BUFFER,UNIT)    ;get a packet and waits for t
  1145.          O'E                              ;prompt
  1146.             STATUS=KGETLIN.(BUFFER,UNIT)       ;get a packet without waitin
  1147.          E'L                             ;for a prompt
  1148. ;        E'E HEXDMP.(0,45,0,BUFFER)
  1149.  
  1150.          COUNT=0
  1151.  
  1152. ;        skips all other characters until we see one with a SOH in it
  1153.  
  1154.          W'E ((BUFFER(COUNT).NE.SOH).AND.(BUFFER(COUNT).NE.EOS))
  1155.             COUNT=COUNT+1                  ;wait for a SOH or EOS
  1156.          E'W
  1157.          W'R (BUFFER(COUNT).EQ.SOH)      ;we got the SOH
  1158.  
  1159. ;           we got a line that begins with a SOH
  1160.  
  1161.             K=COUNT+1
  1162.             CHKSUM=BUFFER(K)
  1163.             LEN=UNCHAR.(BUFFER(K))-3        ;get the length of the packet
  1164.  
  1165.             K=K+1
  1166.             CHKSUM=CHKSUM+BUFFER(K)
  1167.             NUM=UNCHAR.(BUFFER(K))          ;get the sequence number of
  1168.                                            ;the frame packet
  1169.             K=K+1
  1170.             XTYPE=BUFFER(K)                ;get the data type
  1171.             CHKSUM=CHKSUM+BUFFER(K)
  1172.             K=K+1
  1173.  
  1174. ;           get the data
  1175.  
  1176. ;           ZERO OUT THE XDATA ARRAY
  1177. ;            E'E FILL.(132,0,XDATA)
  1178.  
  1179.             T'H L1 FOR J=0, 1, J .GE. LEN
  1180.                XDATA(J)=BUFFER(K)
  1181.                CHKSUM=CHKSUM+BUFFER(K)
  1182.                K=K+1
  1183. L1          C'E
  1184.             COUNT = J
  1185.  
  1186.             XDATA(COUNT+1)=EOS
  1187.             T=BUFFER(K)
  1188.  
  1189. ;           calculate the checksum of the incoming packet
  1190.  
  1191.             TV1=CHKSUM.LAND.192
  1192.             TV2=TV1/64
  1193.             TV3=CHKSUM+TV2
  1194.             CHKSUM=TV3.LAND.63
  1195.  
  1196. ;           does the checksum matches
  1197.  
  1198.             W'R (CHKSUM.NE.UNCHAR.(T))
  1199. #              E'E TYPEMSG.($ BAD CHECKSUM !$)
  1200.                LCLSTATE=BAD                   ;bad checksum
  1201.                F'N LCLSTATE
  1202.  
  1203.             O'E
  1204.                 LCLSTATE=XTYPE
  1205.                 F'N LCLSTATE
  1206.             E'L
  1207.          E'L
  1208.  
  1209. ;        we got the EOS, the packet has no SOH, read another one
  1210.  
  1211.          GAPTRY=GAPTRY+1
  1212.       E'W
  1213. #     E'E TYPEMSG.($ SOME OTHER BAD STATE !$)
  1214.       LCLSTATE=BAD
  1215.       F'N LCLSTATE
  1216.  
  1217. WAYOUT  F'N BAD     ; wayout of a deadlock situation
  1218.  
  1219.       E'N
  1220. <<< KERMIT.RPAR >>>
  1221. ;16 jly 85 esj converted
  1222. ;;;;;;;;;;;;;           RPAR          ;;;;;;;;;;;;;;;;;;;;;
  1223.       E'F A:S(NWLS)
  1224.       E'O RPAR.(XDATA)
  1225.  
  1226. ;     store the other KERMIT's file transfer requirement away
  1227.  
  1228. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  1229. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  1230.  
  1231.       I'R XDATA(*)
  1232.       I'R DMY(5)
  1233.  
  1234.       W'R (XDATA(0).EQ.0)               ;if the other KERMIT did not s
  1235.          SPSIZ=PAKSIZ                     ;any parameters, default them
  1236.                                           ;our setting; otherwise use wh
  1237.                                           ;the other KERMITs sends
  1238.       O'E
  1239.          DMY(0) = SPSIZ=UNCHAR.(XDATA(0))
  1240.       E'L
  1241.       W'R (XDATA(2).NE.0), DMY(1) = PAD=UNCHAR.(XDATA(2))
  1242.  
  1243.       W'R (XDATA(3).NE.0), DMY(2) = PADCHAR=CTL.(XDATA(3))
  1244.  
  1245.       W'R (XDATA(4).NE.0), DMY(3) = EOL=UNCHAR.(XDATA(4))
  1246.  
  1247.       W'R (XDATA(5).NE.0), DMY(4) = QUOTE=XDATA(5)
  1248.  
  1249. #     E'E HEXDMPP.(5,11,5,DMY)
  1250.       F'N
  1251.       E'N
  1252. <<< KERMIT.SBREAK >>>
  1253. ; 16 jly 85 esj converted
  1254. ;;;;;;;;;;;;;       SBREAK       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1255.       E'F A:S(NWLS)
  1256.       E'O SBREAK.(X)
  1257.  
  1258. ;     send the break packet to signify the end of transmissions
  1259.  
  1260. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  1261. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  1262.  
  1263.       I'R NUM,LEN,STATUS,X,TNUM
  1264.       I'R TV1,TV2,TV3
  1265.  
  1266.       W'R (NUMTRY.GT.MAXTRY)
  1267.          LCLSTATE=BIGA                             ;exceeded max. # of re-
  1268.          F'N LCLSTATE                                  ;gives up
  1269.       O'E
  1270.           NUMTRY=NUMTRY+1                        ;try it again
  1271.       E'L
  1272.  
  1273.       TNUM=N
  1274.       TV1=BIGB
  1275.       TV2=0
  1276.       TV3=0
  1277.       E'E SPACK.(TV1,TNUM,TV2,TV3)
  1278.       STATUS=RPACK.(LEN,NUM,RECPKT)
  1279.  
  1280.       W'R (STATUS.EQ.BIGN)                     ;we got a NAK packet
  1281.          W'R (N.NE.(NUM-1))
  1282.             LCLSTATE=STATE
  1283.             F'N LCLSTATE
  1284.           E'L
  1285.  
  1286.       O'R (STATUS.EQ.BIGY)                ;we got a ACK packet
  1287.               W'R (N.NE.NUM)
  1288.                  LCLSTATE=STATE                    ;but it is out of seque
  1289.                  F'N LCLSTATE
  1290.               E'L
  1291.               NUMTRY=0
  1292.               N=(N+1).MOD.64
  1293.               LCLSTATE=BIGC                        ;change state to comple
  1294.               F'N LCLSTATE                             ;status
  1295.  
  1296.       O'R (STATUS.EQ.BAD)
  1297.               LCLSTATE=STATE
  1298.               F'N LCLSTATE
  1299.  
  1300.       O'E
  1301.            LCLSTATE=BIGA                           ;receive unknown packet
  1302.       E'L                                      ;type or error packet
  1303.       F'N LCLSTATE
  1304.       E'N
  1305. <<< KERMIT.SCONNECT >>>
  1306. * 14 aug 85 esj attempt to use a queue structure to prevent dropping
  1307. *              characters in connect mode
  1308. * 18-jul-85 pcc; fix so it compiles
  1309. *
  1310. *************************************** CVCOMMAND.KERMIT.SCONNECT ******
  1311. *
  1312.       E:F A:S(NWLS)
  1313.       E:O SCONNECT.
  1314. *
  1315. ************************************************************************
  1316. *
  1317. *
  1318. *     Allows the local KERMIT to act as a dumb terminal connected to
  1319. *     another computer.
  1320. *
  1321. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  1322. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  1323. *
  1324.    EQU LCLQSIZ = 1000
  1325.    EQU RMTQSIZ = 10
  1326. *
  1327.    I'R TISUNIT
  1328.    I'R TISTYPE
  1329.    I'R COUNT
  1330.    I'R CHBUF
  1331.    I'R STATUS
  1332.    G'L LCLCHQ(LCLQSIZ)        ; char queues for local and remote devices
  1333.    I'R RMTCHQ(RMTQSIZ)
  1334.    I'R LCLQPTRI                ; index to next empty spot in queue
  1335.    I'R RMTQPTRI
  1336.    I'R LCLQPTRO                ; index to next char to be dumped in queue
  1337.    I'R RMTQPTRO
  1338.  
  1339.  
  1340. *Formats to V:S
  1341.    V:S F101 = $ To exit from CHAT mode; type control-!$
  1342. *
  1343. ******************* start of executable code ***************************
  1344. *
  1345.    STATUS=YES
  1346.  
  1347.    E:E TYPMSG.(F101)
  1348.    CHBUF = CTL.(ESCHAR)
  1349.    E'E TYPE.(1,CHBUF.LSH.8)
  1350.  
  1351.    E'E TRANSPAR.
  1352.  
  1353. ;  start up the queue structures
  1354.    LCLQPTRI = LCLQPTRO = 0
  1355.    RMTQPTRI = RMTQPTRO = 0
  1356.  
  1357. ;  start up the io flags
  1358.        LOCALDEV(1) = -1
  1359.        RMTDEV(1)   = -1
  1360.  
  1361. ;     r't
  1362. ;        w'r there is input
  1363. ;           input char
  1364. ;           did char come from localdev?
  1365. ;           yes --> is it the escape char?
  1366. ;                 yes --> punt to exit
  1367. ;                 no  --> send to rmtdev queue
  1368. ;           no  --> it came from the rmtdev
  1369. ;                   send it to the localdev queue
  1370. ;        e'l
  1371. ;        w'r lcldev is not busy and lcldev queue is not empty
  1372. ;           send char to lcldev
  1373. ;        e'l
  1374. ;        w'r rmtdev is not busy and rmtdev queue is not empty
  1375. ;           send char to rmtdev
  1376. ;        e'l
  1377. ;     f'r
  1378.  
  1379.    R'T
  1380.       W'E CHKINPUT.(TISUNIT,COUNT) .E. 0
  1381.          E'E INPUT.(TISUNIT, TISTYPE, COUNT, CHBUF)
  1382.  
  1383.          W'R TISUNIT .E. LOCALDEV
  1384.             W'R CHBUF .E. ESCHAR
  1385.                T'O DONE
  1386.             O'E
  1387. ;            E'E TPUTCH.(CHBUF, RMTDEV)
  1388. ;              put the char on the queue and ignore overflow condition for now
  1389.                RMTCHQ(RMTQPTRI) = CHBUF
  1390.                RMTQPTRI = (RMTQPTRI + 1) .MOD. RMTQSIZ
  1391. #              E'E HEXDMP.(1,11,1,RMTCHQ(RMTQPTRO))
  1392.  
  1393.             E'L
  1394.  
  1395.          O'E
  1396. ;         E'E TPUTCH.(CHBUF, LOCALDEV)
  1397. ;           put the char on the queue and ignore overflow condition for now
  1398.  
  1399.             LCLCHQ(LCLQPTRI) = CHBUF
  1400.             LCLQPTRI = (LCLQPTRI + 1) .MOD. LCLQSIZ
  1401. #           E'E HEXDMP.(0,10,0,LCLCHQ(LCLQPTRO))
  1402.          E'L
  1403.       E'W
  1404.  
  1405. ;     if the queue is not empty and there is no io in progress or
  1406. ;     this is the first time through the io loop, print a char
  1407.       W'R LCLQPTRI .NE. LCLQPTRO
  1408. #        E'E HEXDMP.(0,1,0,LOCALDEV)
  1409.          W'R LOCALDEV(1) .E. -1
  1410. ;           this is for the first time through
  1411.             E'E TPUTCH.(LCLCHQ(LCLQPTRO), LOCALDEV)
  1412.             LCLQPTRO = (LCLQPTRO + 1) .MOD. LCLQSIZ
  1413. #           E'E HEXDMP.(0,1,0,LOCALDEV)
  1414.  
  1415.          O'R TESTIO.(LOCALDEV(1)) .NE. 0
  1416. ;           this is for all of the other times through when io is done
  1417.             LOCALDEV(1) = -1 ; clear io flag
  1418.             E'E TPUTCH.(LCLCHQ(LCLQPTRO), LOCALDEV)
  1419.             LCLQPTRO = (LCLQPTRO + 1) .MOD. LCLQSIZ
  1420. #           E'E HEXDMP.(0,1,0,LOCALDEV)
  1421.          E'L
  1422.       E'L
  1423.  
  1424. ;     ditto
  1425.       W'R RMTQPTRI .NE. RMTQPTRO
  1426. #        E'E HEXDMP.(1,2,1,RMTDEV)
  1427.          W'R RMTDEV(1) .E. -1
  1428. ;           this is for the first time through
  1429.             E'E TPUTCH.(RMTCHQ(RMTQPTRO), RMTDEV)
  1430.             RMTQPTRO = (RMTQPTRO + 1) .MOD. RMTQSIZ
  1431. #           E'E HEXDMP.(1,2,1,RMTDEV)
  1432.  
  1433.          O'R TESTIO.(RMTDEV(1)) .NE. 0
  1434. ;           this is for all of the other times through when io is done
  1435.             RMTDEV(1) = -1 ; clear io flag
  1436.             E'E TPUTCH.(RMTCHQ(RMTQPTRO), RMTDEV)
  1437.             RMTQPTRO = (RMTQPTRO + 1) .MOD. RMTQSIZ
  1438. #           E'E HEXDMP.(1,2,1,RMTDEV)
  1439.          E'L
  1440.       E'L
  1441.  
  1442.    F'R
  1443.  
  1444. DONE   E'E OPAQUE.
  1445.        E'E TYPE.(0,0)
  1446.    F'N
  1447.    E'N
  1448. <<< KERMIT.SCOPY >>>
  1449. ; 16 jly 85 esj converted
  1450. ;;;;;;;;;;;;;;;;;;;;;      SCOPY          ;;;;;;;;;;;;;;;;;;;;
  1451.       E'F A:S(NWLS)
  1452.       E'O SCOPY.(XFROM,I,XTO,J)
  1453.  
  1454.       I'R XFROM(1),XTO(1),I,J,K1,K2
  1455.  
  1456. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  1457.  
  1458.       K2=J
  1459.       K1=I
  1460.  
  1461.       W'E (XFROM(K1).NE.EOS)
  1462.          XTO(K2)=XFROM(K1)
  1463.          K2=K2+1
  1464.          K1=K1+1
  1465.       E'W
  1466.  
  1467.       XTO(K2)=EOS
  1468.       F'N
  1469.       E'N
  1470. <<< KERMIT.SDATA >>>
  1471. ; 16 jly 85 esj converted
  1472. ;;;;;;;;;;;;;;;;;             SDATA          ;;;;;;;;;;;;;
  1473.       E'F A:S(NWLS)
  1474.       E'O SDATA.(X)
  1475.  
  1476. ;     sends a data packet to other KERMIT
  1477.  
  1478. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  1479. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  1480.  
  1481.       I'R X,NUM,LEN,STATUS,TNUM,TV1
  1482.       I'R RECKPT(100)      ; packet to get the ack back in
  1483.       I'R LCLSTATE         ; temp for returned state
  1484.  
  1485. #     E'E TYPMSG.($ IN SDATA !$)
  1486.  
  1487.       W'R (NUMTRY.GT.MAXTRY)
  1488.          LCLSTATE=BIGA
  1489.          E'E CLOSTEXT.(FD)
  1490.          T'O GETOUT
  1491.       O'E
  1492.           NUMTRY=NUMTRY+1
  1493.       E'L
  1494.  
  1495.       TNUM=N
  1496.       TV1=BIGD
  1497.  
  1498.       E'E SPACK.(TV1,TNUM,SIZE,PACKET)    ;send that data packet
  1499.  
  1500.       STATUS=RPACK.(LEN,NUM,RECPKT)       ;get the reply
  1501.  
  1502.       E'E DODOT.                          ; tell all if ok
  1503.  
  1504. #      E'E TYPOUT.(2,'A000'.LOR.STATUS)
  1505. #      E'E TYPEMSG.($  got dis status!$)
  1506.  
  1507. ;     the next statements is to make sure we are not one packet
  1508. ;     ahead of other KERMIT, it will happen if other KERMIT send a NAK
  1509. ;     (due to time-out detection feature) before we send the first
  1510. ;     SINIT packet
  1511.  
  1512.       W'R ((STATUS.EQ.BIGY).AND.(N.EQ.(NUM+1)))
  1513.           STATUS=RPACK.(LEN,NUM,RECKPT)
  1514.       E'L
  1515.  
  1516.       W'R (STATUS.EQ.BIGN)               ;we got a NAK
  1517.          W'R (N.NE.(NUM-1))
  1518.             LCLSTATE=STATE                    ;to the right sequence #, tyr
  1519.             T'O GETOUT
  1520.           E'L
  1521.  
  1522.       O'R(STATUS.EQ.BIGY)          ;we got a ACK
  1523.               W'R (N.NE.NUM)
  1524.                  LCLSTATE=STATE               ;but, it was for the last pac
  1525.                  T'O GETOUT
  1526.               E'L
  1527.  
  1528.               NUMTRY=0
  1529.               N=(N+1).MOD.64              ;increment frame sequence num
  1530.               SIZE=BUFILL.(PACKET)          ;fill up more data onto buffe
  1531.               W'R (SIZE.EQ.EOF)          ;we got EOF on the sending
  1532.                  LCLSTATE=BIGZ                ;disk file, change state so t
  1533.                  T'O GETOUT                    ;we can sent ane EOF packet
  1534.               E'L
  1535.  
  1536.               LCLSTATE=BIGD                   ;we send the DATA packet, sen
  1537.               T'O GETOUT
  1538.  
  1539.       O'R(STATUS.EQ.BAD)           ;we got a checksum error
  1540.               LCLSTATE=STATE                  ;try it again
  1541.               T'O GETOUT
  1542.  
  1543.       O'E
  1544.            LCLSTATE=BIGA                      ;we got unknown packet type o
  1545.            E'E CLOSTEXT.(FD)
  1546.            T'O GETOUT
  1547.  
  1548.       E'L                                ;an error type packet
  1549. GETOUT C'E
  1550. #      E'E TYPOUT.(2,'A000'.LOR. LCLSTATE)
  1551. #      E'E TYPEMSG.($ rdata exit state!$)
  1552.  
  1553.       F'N LCLSTATE
  1554.       E'N
  1555. <<< KERMIT.SENDSW >>>
  1556. ; 16 jly 5 esj converted
  1557. ;;;;;;;;;;;       SENDSW          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1558.       E'F A:S(NWLS)
  1559.       E'O SENDSW.(X)
  1560.  
  1561. ;     send this group of files
  1562.  
  1563. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  1564. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  1565.  
  1566.       G'L XNEW,XCOUNT,XEOF
  1567.  
  1568.       I'R SDATA,SFILE,SEOF,SINIT,SBREAK
  1569.       I'R TV1,TV2,TV3,TV4
  1570.  
  1571.       STATE=BIGS
  1572.       XNEW=YES
  1573.       XCOUNT=1
  1574.       XEOF=NO
  1575.       N=0
  1576.       NUMTRY=0
  1577.       STATUS=YES
  1578.  
  1579.       W'E (STATUS.EQ.YES)
  1580. #              E'E TYPOUT.(2,'A000'.LOR.STATE)
  1581. #              E'E TYPEMSG.($ is current state!$)
  1582.  
  1583.                W'R (STATE.EQ.BIGD)                 ;send a data packet
  1584.                   STATE=SDATA.(X)
  1585.  
  1586.                O'R (STATE.EQ.BIGF)            ;send a file header
  1587.                        STATE=SFILE.(X)
  1588.  
  1589.                O'R (STATE.EQ.BIGZ)            ;send a EOF header
  1590.                        STATE=SEOF.(X)
  1591.  
  1592.                O'R (STATE.EQ.BIGS)            ;send a SINIT packe
  1593.                        STATE=SINIT.(X)
  1594.  
  1595.                O'R (STATE.EQ.BIGB)            ;send a BREAK packe
  1596.                        STATE=SBREAK.(X)
  1597.  
  1598.                O'R (STATE.EQ.BIGC)
  1599.                        LCLSTAT=YES                    ;file transfer comp
  1600.                        B'K
  1601.  
  1602.                O'R (STATE.EQ.BIGA)            ;file transfer fail
  1603.                        LCLSTAT=NO
  1604.                        TV1=BIGE
  1605.                        TV2=N
  1606.                        TV3=0
  1607.                        TV4=0
  1608.                        E'E SPACK.(TV1,TV2,TV3,TV4)  ;send a ERROR packet
  1609.                        B'K
  1610.  
  1611.                 O'E
  1612.                      STATUS=NO
  1613.                      LCLSTAT=NO                      ;file transfer failu
  1614.                 E'L
  1615.       E'W
  1616.       F'N LCLSTAT
  1617.       E'N
  1618. <<< KERMIT.SEOF >>>
  1619. ;  6 aug 85 esj restored send @file support
  1620. ; 19 jly 85 esj removed send @file support
  1621. ; 16 jly 85 esj converted
  1622. ;;;;;;;;;;;;;;;        SEOF          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1623.       E'F A:S(NWLS)
  1624.       E'O SEOF.(X)
  1625.  
  1626. ;     send an EOF packet to the other KERMIT
  1627.  
  1628. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  1629. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  1630.  
  1631.       I'R NUM,LEN,STATUS,LCLSTATE,TNUM
  1632.       I'R TPNAME(132),AONE,BONE,TV1,TV2,TV3
  1633.       I'R XREAD
  1634.       G'L IFD(*),IFDFLG
  1635.  
  1636.       XREAD=0
  1637.  
  1638.       W'R (NUMTRY.GT.MAXTRY)
  1639.          LCLSTATE=BIGA        ;exceeded max. # of re-try, give up
  1640.          E'E CLOSTEXT.(FD)
  1641.  
  1642.       O'E
  1643.          NUMTRY=NUMTRY+1
  1644.          AONE=1
  1645.          BONE=1
  1646.          TNUM=N
  1647.          TV1=BIGZ
  1648.          TV2=0
  1649.          TV3=0
  1650.          E'E SPACK.(TV1,TNUM,TV2,TV3)       ;send an EOF packet to other KE
  1651.          STATUS=RPACK.(LEN,NUM,RECPKT)       ;what is its reply ??
  1652.  
  1653.          W'R (STATUS.EQ.BIGN)             ;we got an NAK
  1654.  
  1655.                LCLSTATE=STATE
  1656.                F'N LCLSTATE
  1657.  
  1658.          O'R (STATUS.EQ.BIGY)             ;we got a ACK
  1659.             W'R (N.NE.NUM)
  1660.                LCLSTATE=STATE             ;but it was for the last packet
  1661.  
  1662.             O'E
  1663.                N=(N+1).MOD.64
  1664.                NUMTRY=0
  1665.                E'E CLOSTEXT.(FD)          ;close the sending disk file ch
  1666.  
  1667. ;              are we sending multiple files?
  1668.                W'R IFDFLG .E. YES
  1669.                   R'T
  1670. ;                    yes, get the next file
  1671.                      E'E NEXTFILE.(IFD, TPNAME)
  1672.                      W'R TPNAME .E. 0
  1673. ;                       if at eof, close up shop
  1674.                         LCLSTATE = BIGB
  1675.                         B'K
  1676.  
  1677.                      O'E
  1678. ;                       go for next file
  1679.                         LCLSTATE = BIGF
  1680.                         STATUS = OPENTEXT.(TPNAME,$RD$, $CV$, FD)
  1681.  
  1682.                         W'R (STATUS.NE.0)  ;file exist ??
  1683. ;                          no, say so and try again
  1684.                            E'E TYPOUT.(TPNAME-1,TPNAME(1))
  1685.                            E:E TYPEMSG.($ <--- Source file does not exist!$)
  1686.                            E'E CLOSTEXT.(FD)
  1687.                            LCLSTATE = BIGB
  1688.  
  1689.                         O'E
  1690. ;                          yes, all ok, convert the filename to
  1691. ;                          kermit packet format, being careful to not
  1692. ;                          include the ! terminator
  1693.                            E'E CHTOIN.(TPNAME(1), FILNAME, TPNAME-1)
  1694.                            B'K
  1695.  
  1696.                         E'L
  1697.                      E'L
  1698.                   F'R
  1699.                O'E
  1700. ;                 no more files, close up shop
  1701.                   LCLSTATE = BIGB
  1702.  
  1703.                E'L
  1704.  
  1705.             E'L
  1706.  
  1707.          O'R (STATUS.EQ.BAD)              ;there was a checksum error
  1708.             LCLSTATE=STATE                ;try it again
  1709.  
  1710.          O'E
  1711.             LCLSTATE=BIGA                 ;we got an unexpected packet
  1712.             E'E CLOSTEXT.(FD)
  1713.                                           ;or error packet, abort
  1714.                                           ;transfer mode
  1715.          E'L
  1716.       E'L
  1717.       F'N LCLSTATE
  1718.       E'N
  1719. <<< KERMIT.SETCOOK >>>
  1720. ; 16 jly 85 esj converted
  1721. ;;;;;;;;;;;;;            SETCOOK         ;;;
  1722.       E'F
  1723.       E'O SETCOOK.(CH,FNAME)
  1724.  
  1725. ;     a noop for cgos.  maybe replace with a call to transpare/opaque
  1726.       F'N
  1727.       E'N
  1728. <<< KERMIT.SETPORT >>>
  1729. ; 16 jly 85 esj converted
  1730. ;;;;;;;;;;;;       SETPORT         ;;;;;;;;;;;;;;;;;;;;;;;
  1731.       E'F
  1732.       E'O SETPORT.(CH,FNAME)
  1733.  
  1734. ;     this routine would normally enable a user to select which
  1735. ;     port to used for remote file transfer, but it will not
  1736. ;     be implemented in the CGOS system.  This routine is a nop until it
  1737. ;     can be used for setting the proper port configuration such as
  1738. ;     baud rate, parity, xon/xoff,enq/ack, stop bits, bpc etc
  1739.  
  1740.       F'N
  1741.       E'N
  1742. <<< KERMIT.SETRAW >>>
  1743. ; 16 jly 85 esj converted
  1744. ;;;;;;;;        SETRAW           ;;;;;;;;;;;;;;;;;;;;;;;;;;
  1745.       E'F
  1746.       E'O SETRAW.(CH,FNAME)
  1747.  
  1748. ;     this is a noop for cgos.
  1749.  
  1750.  
  1751. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  1752.  
  1753.  
  1754.       F'N
  1755.       E'N
  1756. <<< KERMIT.SFILE >>>
  1757. ; 16 jly 85 esj converted
  1758. ;------------------------------------------< sfile >----------------------
  1759.       E'F A:S(NWLS)
  1760.       E'O SFILE.(X)
  1761. ;-------------------------------------------------------------------------
  1762. ;
  1763. ; Purpose
  1764. ;  send the filename to other KERMIT
  1765.  
  1766. ; Input
  1767. ;  none
  1768.  
  1769. ; Output
  1770. ;  none
  1771.  
  1772. ; Insert
  1773. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  1774. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  1775.  
  1776. ; Globals
  1777.    G'L XNEW,XCOUNT,XEOF,DODOTCT
  1778.  
  1779. ; Locals
  1780.    I'R NUM,LEN,X,TNUM,LCLSTATE,STATUS
  1781.    I'R TV1,ALIN(132),AONE,BONE
  1782.  
  1783. ;----------------------< start of code >----------------------------
  1784.  
  1785.       AONE=1
  1786.       BONE=1
  1787.       E'E SCOPY.(FILNAME,0,ALIN,0)
  1788.  
  1789.       W'R (HOSTON.EQ.NO)
  1790.          DODOTCT = 0
  1791.          E'E TYPE.(0,0)
  1792.          E'E TYPMSG.($Sending !$)          ;we are in local mode  dis
  1793.          E'E PUTLIN.(ALIN,LOCALDEV)         ;the filename being send
  1794.          E'E TYPE.(0,0)
  1795.       E'L
  1796.  
  1797.       W'R (NUMTRY.GT.MAXTRY)
  1798.          LCLSTATE=BIGA                           ;exceeded max. # of re-try
  1799.          F'N LCLSTATE                               ;gives up
  1800.       O'E
  1801.           NUMTRY=NUMTRY+1                     ;try it one more time
  1802.       E'L
  1803.  
  1804.       LEN=0
  1805.       W'E (FILNAME(LEN).NE.EOS)            ;determine the length of f
  1806.          LEN=LEN+1
  1807.       E'W
  1808.  
  1809.       TNUM=N
  1810.       TV1=BIGF
  1811.       E'E SPACK.(TV1,TNUM,LEN,FILNAME)         ;send filename to other KE
  1812.       STATUS=RPACK.(LEN,NUM,RECPKT)
  1813.  
  1814.       W'R (STATUS.EQ.BIGN)                  ;we got a NAK
  1815.          W'R (N.NE.(NUM-1))
  1816.             LCLSTATE=STATE
  1817.             F'N LCLSTATE
  1818.          E'L
  1819.  
  1820.       O'R (STATUS.EQ.BIGY)             ;we got a ACK
  1821.            W'R (N.NE.NUM)
  1822.               LCLSTATE=STATE
  1823.               F'N LCLSTATE
  1824.            E'L
  1825.            NUMTRY=0
  1826.            N=(N+1).MOD.64
  1827.            XNEW=YES
  1828.            XCOUNT=1
  1829.            XEOF=NO
  1830.            SIZE=BUFILL.(PACKET)               ;fill up a buffer full of b
  1831.            LCLSTATE=BIGD                        ;change state to sent data
  1832.            F'N LCLSTATE
  1833.  
  1834.       O'R (STATUS.EQ.BAD)             ;we got a checksum error
  1835.               LCLSTATE=STATE
  1836.               F'N LCLSTATE
  1837.       O'E
  1838.            LCLSTATE=BIGA                        ;we got an error or unexpec
  1839.            F'N LCLSTATE                            ;packet type
  1840.       E'L
  1841.       F'N LCLSTATE
  1842.       E'N
  1843. <<< KERMIT.SHELP >>>
  1844. ; 18 aug 85 esj replaced s.e.fm.error.uil with kerdef
  1845. ; 31 jly 85 esj created
  1846. ;---------------------------------------< shelp >---------------------------
  1847.    E'F A:S(NWLS)
  1848.    E'O SHELP.
  1849. ;---------------------------------------------------------------------------
  1850. ;
  1851. ;  Purpose
  1852. ;  Print out the help file for kermit.
  1853.  
  1854. ;  Input
  1855. ;  none
  1856.  
  1857. ;  Output
  1858. ;  none
  1859.  
  1860. ;  Globals
  1861. ;  none
  1862.  
  1863. ; Inserts
  1864. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  1865. /INCLUDE SYM.EQU.FM.OPEN
  1866. /INCLUDE SYM.EQU.FM.BASIC
  1867. /INCLUDE SYM.EQU.FM.READ
  1868.  
  1869. ;  Local static
  1870.    V'S HELPNAME = 31,$=SYSNEWS.CVCOMMAND.&BCD.KERMIT!$
  1871.  
  1872.    V'S TXTSPEC =  03,
  1873. 1                 %CATLOG,%%SEARCH,
  1874. 1                 %FORMAT , %%TEXT,
  1875. 1                 %RTNERR
  1876.  
  1877.    V'S RDSPC =    02,
  1878. 1                 %RTNERR,
  1879. 1                 %RETURN,1,
  1880. 1                       %%BYTCNT
  1881.  
  1882.  
  1883.    V'S CLOSPC =   1,
  1884. 1                 %RTNERR
  1885.  
  1886.  
  1887. ;  Local dynamic
  1888.    I'R CH               ; channel holder
  1889.    I'R LINE(100)        ; line buffer
  1890.    I'R OTSPC(9)         ;
  1891.    I'R STATUS(1)        ; FM error code
  1892.  
  1893.  
  1894. ;----------------------------------< start of code >------------------------
  1895.  
  1896. *  Set to no error
  1897.       STATUS = STATUS(1) = FM%NOERR
  1898.  
  1899.       ; call the fm and try to open the help file
  1900.       E'E F&OPEN.(%OREAD   ,
  1901. 1                 %IDFILNM ,
  1902. 1                 HELPNAME ,
  1903. 1                 TXTSPEC  ,
  1904. 1                 CH       ,
  1905. 1                 OTSPC    ,
  1906. 1                 STATUS   )
  1907.  
  1908. #     E'E HEXDMP.(1,1,1,STATUS)
  1909.  
  1910. ;     type out contents of file
  1911.       W'R STATUS .E. FM%NOERR
  1912. ;        if open status is ok, print till eof
  1913.          R'T
  1914.            E'E F&READ.(CH       ,
  1915. 1                       1        ,
  1916. 1                       LINE     ,
  1917. 1                       RDSPC    ,
  1918. 1                       OTSPC    ,
  1919. 1                       STATUS   )
  1920.  
  1921. #          E'E HEXDMP.(1,1,1,STATUS)
  1922.             W'R STATUS .NE. FM%NOERR, B'K
  1923.  
  1924.             E'E TYPE.(OTSPC(3),LINE)
  1925.          F'R
  1926.       E'L
  1927.  
  1928.       E'E F&CLOSE.(CH, CLOSPC, STATUS)
  1929.  
  1930.       F'N STATUS
  1931.       E'N
  1932. <<< KERMIT.SINIT >>>
  1933. ; 18 jly 85 esj removed send @filename support
  1934. ; 16 jly 85 esj converted
  1935. ;;;;;;;;;;;           SINIT          ;;;;;;;;;;;;;;;;;;;;;;;;;;
  1936.       E'F A:S(NWLS)
  1937.       E'O SINIT.(X)
  1938.  
  1939. ;     send an initial packet for the first connection
  1940. ;     state what my parameters are
  1941.  
  1942. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  1943. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  1944.  
  1945.       I'R NUM,LEN,STATUS,LCLSTATE,TNUM
  1946.       I'R AONE,BONE,TV1,TV2
  1947.  
  1948.  
  1949.       W'R (NUMTRY.GT.MAXTRY)
  1950.          LCLSTATE=BIGA        ;exceeded max # of re-try , give up
  1951.  
  1952.       O'E
  1953.          NUMTRY=NUMTRY+1     ;try it again
  1954.  
  1955.  
  1956.          AONE=1
  1957.          BONE=1
  1958.          E'E SPAR.(PACKET)                   ;get my requirement parameters
  1959. #        E'E HEXDMP.(1,11,1,PACKET)
  1960.          TNUM=N
  1961.          TV1=BIGS
  1962.          TV2=6
  1963.          E'E SPACK.(TV1,TNUM,TV2,PACKET)     ;send my parameters requiremen
  1964.          STATUS=RPACK.(LEN,NUM,RECPKT)        ;what was the reply ??
  1965.  
  1966. #        E'E TYPOUT.(2,'A000'.LOR.STATUS)
  1967. #        E'E TYPEMSG.($  got dis status!$)
  1968.  
  1969.          W'R (STATUS.EQ.BIGN)              ;NAK it
  1970.                LCLSTATE=STATE                   ;try it again
  1971.  
  1972.          O'R (STATUS.EQ.BIGY)         ;ACK it
  1973.             W'R (N.NE.NUM)            ;but it was for the previous p
  1974.                LCLSTATE=STATE              ;re-try it again
  1975.  
  1976.             O'E
  1977.                E'E RPAR.(RECPKT)           ;get the packet reqirement of
  1978.                                            ;other KERMIT if provided
  1979.                NUMTRY=0
  1980.                N=((N+1).MOD.64)
  1981.                LCLSTATE = BIGF
  1982.             E'L
  1983.  
  1984.          O'R (STATUS.EQ.BAD)   ;checksum error detected
  1985.             LCLSTATE=STATE          ;try it again
  1986.  
  1987.          O'E
  1988.             LCLSTATE=BIGA
  1989.  
  1990.          E'L
  1991.       E'L
  1992.  
  1993.       F'N LCLSTATE
  1994.       E'N
  1995. <<< KERMIT.SPACK >>>
  1996. ; 07 aug 85 dg call TPUTCH with rmtdev - nuke CH
  1997. ; 16 jly 85 esj converted
  1998. ;;;;;;;;;;;;      SPACK          ;;;;;;;;;;;;;;;;;;;;;;;
  1999.       E'F A:S(NWLS)
  2000.       E'O SPACK.(XTYPE,NUM,LEN,XDATA)
  2001.  
  2002. ;     send this packet to the remote KERMIT
  2003.  
  2004. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  2005. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  2006.  
  2007.       I'R XTYPE,XDATA(1),NUM,LEN
  2008.       I'R TV1,TV2,TV3
  2009.       I'R I,COUNT,CHKSUM,BUFFER(132)
  2010.  
  2011.  
  2012. ;------------------------------< real code >----------------------------
  2013.  
  2014.       I=0                              ;out on, start with the first byte
  2015.  
  2016.       W'E (I.LE.PAD)                   ;send out padchar if need
  2017.          E'E TPUTCH.(PADCHAR,RMTDEV)
  2018.          I=I+1
  2019.       E'W
  2020. ;                                     ;build up the packet
  2021.       COUNT=0
  2022.  
  2023.       BUFFER(COUNT)=SOH
  2024.       COUNT=COUNT+1
  2025.  
  2026.       CHKSUM=TOCHAR.(LEN+3)
  2027.       BUFFER(COUNT)=TOCHAR.(LEN+3)
  2028.       COUNT=COUNT+1
  2029.  
  2030.       CHKSUM=CHKSUM+TOCHAR.(NUM)
  2031.       BUFFER(COUNT)=TOCHAR.(NUM)
  2032.       COUNT=COUNT+1
  2033.  
  2034.       CHKSUM=CHKSUM+XTYPE
  2035.       BUFFER(COUNT)=XTYPE
  2036.       COUNT=COUNT+1
  2037.  
  2038.       T'H L1 FOR I=0, 1, I .GE. LEN    ;copy the content of packet informa
  2039.          BUFFER(COUNT)=XDATA(I)        ;calculate the checksum
  2040.          COUNT=COUNT+1
  2041.          CHKSUM=CHKSUM+XDATA(I)
  2042. L1    C:E
  2043.  
  2044.       TV1=CHKSUM.LAND.192
  2045.       TV2=TV1/64
  2046.       TV3=TV2+CHKSUM
  2047.       CHKSUM=TV3.LAND.63
  2048.  
  2049.       BUFFER(COUNT)=TOCHAR.(CHKSUM)
  2050.       COUNT=COUNT+1
  2051.  
  2052.       BUFFER(COUNT)=EOL
  2053.       BUFFER(COUNT+1)=EOS
  2054. *      E'E HEXDMPP.(1,COUNT+2,1,BUFFER)
  2055.  
  2056.       COUNT=0
  2057.  
  2058.       W'E (BUFFER(COUNT).NE.EOS)             ;send out the packet
  2059.          E'E TPUTCH.(BUFFER(COUNT),RMTDEV)
  2060.          COUNT=COUNT+1
  2061.       E'W
  2062.  
  2063.       F'N GOOD
  2064.  
  2065.       E'N
  2066. <<< KERMIT.SPAR >>>
  2067. ; 16 jly 85 esj converted
  2068. ;;;;;;;;;;;;;;;;;;;;          SPAR            ;;;;;;;;;;;;;;
  2069.       E'F A:S(NWLS)
  2070.       E'O SPAR.(XDATA)
  2071.  
  2072. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  2073. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  2074.       I'R XZERO
  2075.       I'R XDATA(5)
  2076.  
  2077.       XZERO=0
  2078.       XDATA(0)=TOCHAR.(PAKSIZ)
  2079.       XDATA(1)=TOCHAR.(XZERO)
  2080.       XDATA(2)=TOCHAR.(XZERO)
  2081.       XDATA(3)=CTL.(XZERO)
  2082.       XDATA(4)=TOCHAR.(MYEOL)
  2083.       XDATA(5)=MYQUOTE
  2084.  
  2085.       F'N
  2086.       E'N
  2087. <<< KERMIT.SQUIT >>>
  2088. ; 16 jly 85 esj converted
  2089. ;;;;;;;;;;;;;         SQUIT         ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2090.       E'F A:S(NWLS)
  2091.       E'O SQUIT.
  2092.  
  2093. ;     exit from the CVkermit program
  2094.  
  2095.       E'E NEXTCOMM.
  2096.       F'N
  2097.       E'N
  2098. <<< KERMIT.SRECEIVE >>>
  2099. ; 16 jly 84 esj; converted
  2100. ;-------------------------------------< sreceive >--------------------------
  2101.       E'F A:S(NWLS)
  2102.       E'O SRECEIVE.
  2103. ;----------------------------------------------------------------------------
  2104. ;
  2105. ; Purpose
  2106. ;  sets up TTY line before calling for RECSW routine
  2107.  
  2108. ; Input
  2109. ;  none
  2110.  
  2111. ; Output
  2112. ;  none
  2113.  
  2114. ; Inserts
  2115. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  2116. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  2117.  
  2118. ; Globals
  2119. ;  none
  2120.  
  2121. ; Locals
  2122.    I'R LOGTTY(132),STATUS,X,BELL
  2123.  
  2124. ;---------------------------< start of code >-------------------------------
  2125.  
  2126.       BELL=7
  2127.  
  2128.       W'R (HOSTON.EQ.YES)
  2129.          E'E SETRAW.(RMTDEV,LOGTTY)    ;put this TTY into RAW mode
  2130.  
  2131.          STATUS=RECSW.(X)
  2132.  
  2133.          E'E SETCOOK.(RMTDEV,LOGTTY)   ;put this TTY back into COOK mod
  2134.  
  2135.       O'E
  2136.           E'E SETRAW.(RMTDEV,RMTTTY)   ;put this TTY into RAW mode
  2137.  
  2138.           STATUS=RECSW.(X)
  2139.  
  2140.           E'E SETCOOK.(RMTDEV,RMTTTY)  ;put TTY back into COOK mode
  2141.  
  2142.           E'E TYPE.(0,0)
  2143.  
  2144.           W'R (STATUS.EQ.YES)
  2145.              E:E TYPEMSG.($File transfer COMPLETED!$)
  2146.           O'E
  2147.              E:E TYPEMSG.($File transfer FAILED!$)
  2148.           E'L
  2149.       E'L
  2150.       F'N
  2151.       E'N
  2152. <<< KERMIT.SSEND >>>
  2153. ;  6 aug 85 esj add support for @filename
  2154. ; 23 jly 85 esj fixing filename problems
  2155. * 19-Jul-85 LEC; tpl conversion, first pass
  2156. ;;;;;;       SSEND        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2157.       E:F A:S (NWLS,STKARG)
  2158.       E'O SSEND.
  2159.  
  2160. ;     setting up remote line and directory file before calling SENDSW
  2161.  
  2162. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  2163. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  2164.  
  2165.       G:L CHAR
  2166.       G:L TPNAME(*)
  2167.       G'L IFD(*)     ; file descriptor for file containing a list of
  2168.                      ; files to be sent
  2169.       G'L IFDFLG     ; yes = file names from ifd file/ no = only 1 file
  2170.       I'R STATUS
  2171.       I'R X,BELL
  2172.  
  2173.  
  2174.       BELL=7
  2175.  
  2176. ;     test for empty line
  2177.       E:E NXTCHAR.(1)
  2178.  
  2179.       W'R CHAR .E. 0
  2180.          E:E TYPEMSG.($Proper format is "SEND [@]FILENAME"!$)
  2181.          T'O BADOUT
  2182.       E'L
  2183.  
  2184. ;     restore the last char if not at eol
  2185.       E'E PREVCHAR.(1)
  2186.  
  2187.       W'R CHAR .E. $@$
  2188. ;        get the file name to send from our source file
  2189.          IFDFLG = YES
  2190.  
  2191. ;        trash the @ char before getting the filename
  2192.          E:E NXTCHAR.(1)
  2193.          E:E FMNAME.(TPNAME)
  2194.  
  2195.          STATUS = OPENTEXT.(TPNAME,$RD$, $CV$, IFD)
  2196.  
  2197.          W'R (STATUS.NE.0)                        ;file exist ??
  2198.             E'E TYPOUT.(TPNAME-1,TPNAME(1))
  2199.             E:E TYPEMSG.($ <--- Indirection source file does not exist!$)
  2200.             E'E CLOSTEXT.(IFD)
  2201.             T'O BADOUT
  2202.  
  2203.          O'E
  2204. ;           get the first file to read
  2205.             E'E NEXTFILE.(IFD, TPNAME)
  2206.             W'R TPNAME .E. 0, T'O BADOUT
  2207.          E'L
  2208.  
  2209.       O'E
  2210. ;        get the only file to read
  2211.          IFDFLG = NO
  2212.          E:E FMNAME.(TPNAME)
  2213.  
  2214.       E'L
  2215.  
  2216.       STATUS = OPENTEXT.(TPNAME,$RD$, $CV$, FD)
  2217.  
  2218.       W'R (STATUS.NE.0)                        ;file exist ??
  2219.          E'E TYPOUT.(TPNAME-1,TPNAME(1))
  2220.          E:E TYPEMSG.($ <--- Source file does not exist!$)
  2221.          E'E CLOSTEXT.(FD)
  2222.       O'E
  2223.  
  2224. ;        convert filename to kermit type string, being careful to not
  2225. ;        include the ! terminator
  2226.          E'E CHTOIN.(TPNAME(1), FILNAME, TPNAME-1)
  2227.  
  2228.          W'R (HOSTON.EQ.YES)        ;we are running in Host mode
  2229.  
  2230.             E'E TYPE.(0,0)
  2231.             E'E TYPMSG.($File OK, Waiting !$)
  2232.             E'E TYPEINT.(DELAY)
  2233.             E'E TYPEMSG.($ seconds!$)
  2234.             E'E XDELAY.(DELAY)
  2235.             STATUS=SENDSW.(X)       ;send the requested file
  2236.  
  2237.          O'E
  2238.  
  2239.              STATUS=SENDSW.(X)                          ;send the request fi
  2240.  
  2241.          E'L
  2242.  
  2243.          E'E TYPE.(0,0)
  2244.  
  2245.          W'R (STATUS.EQ.YES)
  2246.             E:E TYPEMSG.($file transfer COMPLETED!$)
  2247.          O'E
  2248.             E:E TYPEMSG.($file transfer FAILED!$)
  2249.          E'L
  2250.  
  2251.       E'L
  2252.  
  2253.       E'E CLOSTEXT.(FD)
  2254. BADOUT C'E
  2255.       F'N
  2256.       E'N
  2257. <<< KERMIT.SSET >>>
  2258. ; 16 jly 85 pcc allow the port attached by select line start with non-alpha
  2259. ;               characters.
  2260. ; 26 jly 85 esj attach to port on set line <XXXX> command
  2261. ; 24 jly 85 esj fix setup port selection
  2262. * 16-Jul-85 LEC; tpl conversion, parsing.
  2263. ;----------------------------------------< sset >----------------------------
  2264.       E:F
  2265.       E'O SSET.(X)
  2266. ;----------------------------------------------------------------------------
  2267. ;
  2268. ; Purpose
  2269. ;     parse and set various selectable parameters
  2270.  
  2271. ; Input
  2272. ;  none
  2273.  
  2274. ; Output
  2275. ;  none
  2276.  
  2277. ; Inserts
  2278. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  2279. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  2280.  
  2281. ; Globals
  2282.    G:L CHAR
  2283.  
  2284. ; Local storage
  2285.    I:R OPTION(4),KEYWORD(4),X
  2286.    I'R UNITNUM(1)
  2287.  
  2288. ;---------------------------< start of code >-------------------------------
  2289. ;     grab option to set
  2290.       E:E IDENT.(OPTION)
  2291.  
  2292.       W'R COMPNAM.(OPTION,$BAUD    $).E.0
  2293.          E:E TYPEMSG.($Baud rate setting not supported!$)
  2294.  
  2295.       O'R COMPNAM.(OPTION,$DELAY   $).E.0
  2296.          W'R (HOSTON.EQ.NO)
  2297.             E:E TYPEMSG.($Delay setting not valid in Local Host mode!$)
  2298.             F'N
  2299.          E'L
  2300.          E:E INT.(X)
  2301.          W'R (X.LT.0)
  2302.             E:E TYPEMSG.($Invalid delay setting!$)
  2303.             F'N
  2304.          O'R(X.GT.30)
  2305.             E:E TYPEMSG.($Delay setting too long!$)
  2306.             E:E TYPEMSG.($defaulted to 30 seconds!$)
  2307.             DELAY=30
  2308.             F'N
  2309.          O'E
  2310.             DELAY=X
  2311.             F'N
  2312.          E'L
  2313.       O'R COMPNAM.(OPTION,$PARITY  $).E.0
  2314.          E:E TYPEMSG.($Parity setting not supported.!$)
  2315.  
  2316.       O'R COMPNAM.(OPTION,$IBM     $).E.0              ;set IBM
  2317.          W'R (HOSTON.EQ.YES)
  2318.             E:E TYPEMSG.($SET IBM ON/OFF not supported in!$)
  2319.             E:E TYPEMSG.($Remote Host mode!$)
  2320.             F'N
  2321.          O:E
  2322.             E:E IDENT.(KEYWORD)
  2323.             W'R COMPNAM.(KEYWORD,$ON      $).E.0
  2324.                IBMON=YES                   ;set IBM flag ON
  2325.             O'R COMPNAM.(KEYWORD,$OFF     $).E.0
  2326.                IBMON=NO               ;set IBM flag OFF
  2327.             O'E
  2328.                E:E TYPEMSG.($Invalid SET IBM mode selected!$)
  2329.                F'N
  2330.             E'L
  2331.          E:L
  2332.       O'R COMPNAM.(OPTION,$ESCAPE  $).E.0              ;set escape
  2333.          W'R (HOSTON.EQ.YES)
  2334.             E:E TYPEMSG.($Escape setting not valid in!$)
  2335.             E:E TYPEMSG.($Remote Host mode!$)
  2336.             F'N
  2337.          O:E
  2338.             E:E INT.(X)
  2339.             W'R ((X.GT.0).AND.(X.LT.32))
  2340.                ESCHAR=X
  2341.             O'E
  2342.                E:E TYPEMSG.($Escape character must be between 0 & 32!$)
  2343.                F'N
  2344.             E'L
  2345.          E:L
  2346.       O'R COMPNAM.(OPTION,$LINE    $).E.0           ;set remote line
  2347.  
  2348.          W'R (SPORT.EQ.YES)          ;is set line supported ??
  2349.             I = 0
  2350. ;           fill keyword with blanks to set things up
  2351.             E:E FILLCHRT.(8,$ $,KEYWORD,0)
  2352.  
  2353. ;           grab next 8 char. can't use ident because any char is
  2354. ;           legal for a device name!
  2355.             W:E (CHAR.NE.0) .AND. (CHAR.NE.$ $) .AND. (I.L.8)
  2356.                E:E STCHRT.(CHAR,KEYWORD,I)
  2357.                E:E NXTCHAR.(0)
  2358.                I .INCR. 1
  2359.             E:W
  2360.  
  2361.             W:R CHAR .E. $ $, E:E NXTCHAR.(1)
  2362.             W:R COMPNAM.(KEYWORD,$COMDEV  $).E.0
  2363.                RMTDEV = $SD$
  2364.                HOSTON = YES
  2365.                E'E DETACH.($KM$)
  2366.             O:E
  2367. ;              connect to the port indicated by the word following LINE
  2368. #              E'E HEXDMP.(0,4,0,KEYWORD)
  2369.                E'E UNBYUNM.( UNITNUM(1), KEYWORD)
  2370.                W'R UNITNUM(1) .E. -1
  2371.                   E'E TYPOUT.(4,KEYWORD)
  2372.                   E'E TYPEMSG.($ does not exist.!$)
  2373.                O'E
  2374. ;                 if the port exists, attach to it.
  2375. #                 E'E HEXDMP.(0,4,0,KEYWORD)
  2376.                   UNITNUM = -1
  2377. #                 E'E HEXDMP.(1,2,1,UNITNUM)
  2378. ;                 detach from kermit device before attaching another
  2379.                   E'E DETACH.($KM$)
  2380.  
  2381. ;                 now attach to the device
  2382.                   W'R ATTACH.($KM$, UNITNUM) .E. 1
  2383.                      RMTDEV = $KM$
  2384.                      HOSTON = NO
  2385.                      E'E TYPOUT.(4,KEYWORD)
  2386.                      E'E TYPEMSG.($ is connected.!$)
  2387.                   O'E
  2388.                      E'E TYPOUT.(4,KEYWORD)
  2389.                      E'E TYPEMSG.($ is not available for connection.!$)
  2390. #                    E'E HEXDMP.(0,4,0,KEYWORD)
  2391.                   E'L
  2392.                E'L
  2393.             E:L
  2394.             F'N
  2395.          O'E
  2396.             E:E TYPEMSG.($SET remote line is not supported!$)
  2397.             F'N
  2398.          E'L
  2399.  
  2400.       O'R COMPNAM.(OPTION,$PROMPT  $).E.0
  2401.          W'R (HOSTON.EQ.YES)
  2402.             E:E TYPEMSG.($SET IBM PROMPT not valid!$)
  2403.             E:E TYPEMSG.($In Remote Host mode!$)
  2404.             F'N
  2405.          O:E
  2406.             E:E INT.(X)
  2407.             W'R ((X.EQ.EOL).OR.(X.EQ.SOH))
  2408.                E:E TYPEMSG.($Invalid;  in conflict with EOL or SOH!$)
  2409.                F'N
  2410.             O'E
  2411.                W'R ((X.GT.0).AND.(X.LT.32))
  2412.                   PROMPT=X
  2413.                E:L
  2414.             E'L
  2415.          E:L
  2416.       O'R COMPNAM.(OPTION,$PACKET  $).E.0
  2417.          E:E INT.(X)
  2418.          W'R ((X.GT.30).AND.(X.LT.95))
  2419.             PAKSIZ=X
  2420.             F'N
  2421.          O'E
  2422.             E:E TYPEMSG.($Invalid Packet size specifiecd!$)
  2423.             F'N
  2424.          E'L
  2425.       O'R COMPNAM.(OPTION,$SOH     $).E.0
  2426.          E:E INT.(X)
  2427.          W'R (HOSTON.EQ.YES)
  2428.             W'R (X.EQ.EOL)
  2429.                E:E TYPEMSG.($Invalid; in conflict with EOL!$)
  2430.                F'N
  2431.             O'E
  2432.                W'R ((X.GT.0).AND.(X.LT.32))
  2433.                   SOH=X
  2434.                   F'N
  2435.                O'E
  2436.                   E:E TYPEMSG.($Invalid; SOH must be between 0 & 32!$)
  2437.                   F'N
  2438.                E'L
  2439.             E'L
  2440.          O'E
  2441.             W'R ((X.EQ.EOL).OR.(X.EQ.PROMPT))
  2442.                E:E TYPEMSG.($Invalid; in conflict with EOL!$)
  2443.                E:E TYPEMSG.($or IBM prompt!$)
  2444.                F'N
  2445.             O'E
  2446.                W'R ((X.GT.0).AND.(X.LT.32))
  2447.                   SOH=X
  2448.                   F'N
  2449.                O'E
  2450.                   E:E TYPEMSG.($Invalid; SOH must be between!$)
  2451.                   E:E TYPEMSG.($0 & 32!$)
  2452.                   F'N
  2453.                E'L
  2454.             E'L
  2455.          E'L
  2456.       O'R COMPNAM.(OPTION,$QUOTE   $).E.0
  2457.          E:E INT.(X)
  2458.          W'R ((X.GT.32).AND.(X.LT.127))
  2459.             MYQUOTE=X
  2460.             F'N
  2461.          O'E
  2462.             E:E TYPEMSG.($QUOTE character must be between!$)
  2463.             E:E TYPEMSG.($32 & 127!$)
  2464.             F'N
  2465.          E'L
  2466.       O'E
  2467.          E:E TYPEMSG.($Invalid SET parameter(s) detected!$)
  2468.          F'N
  2469.       E'L
  2470.       F'N
  2471.       E:N
  2472. <<< KERMIT.SSTATUS >>>
  2473. ; 23 jly 85 esj added display of eol
  2474. ; 20 jly 85 lec converted
  2475. ;;;;;;;;;             SSTATUS           ;;;;;;;;;;;;;;;;;;;;;;;
  2476.       E:F A:S (NWLS)
  2477.       E'O SSTATUS.
  2478.  
  2479.  ;     output the status and values of variables
  2480.  
  2481. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  2482. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  2483.  
  2484.       I'R I
  2485.  
  2486.       W'R (HOSTON.EQ.YES)          ;we are running in remote host mode
  2487.          E:E TYPEMSG.($Remote Host KERMIT mode in effect!$)
  2488.          E:E TYPEINT.(DELAY)
  2489.          E:E TYPEMSG.($ = DELAY in seconds!$)
  2490.          E:E TYPEINT.(MYEOL)
  2491.          E:E TYPEMSG.($ = MYEOL!$)
  2492.          E:E TYPEINT.(EOL)
  2493.          E:E TYPEMSG.($ = EOL!$)
  2494.          E:E TYPEINT.(PAKSIZ)
  2495.          E:E TYPEMSG.($ = PAKSIZ!$)
  2496.          E:E TYPEINT.(MYQUOTE)
  2497.          E:E TYPEMSG.($ = MYQUOTE!$)
  2498.          E:E TYPEINT.(SOH)
  2499.          E:E TYPEMSG.($ = SOH!$)
  2500.          W'R (STATE.EQ.BIGC)
  2501.             E:E TYPEMSG.($File transfer state = C!$)
  2502.          O'E
  2503.              E:E TYPEMSG.($File transfer state = A!$)
  2504.          E'L
  2505.        O'E
  2506.            E:E TYPEINT.(MYEOL)
  2507.            E:E TYPEMSG.($ = MYEOL!$)
  2508.            E:E TYPEINT.(ESCHAR)
  2509.            E:E TYPEMSG.($ = ESCAPE Char!$)
  2510.            W'R (IBMON.EQ.YES)
  2511.               E:E TYPEMSG.($IBM flag = ON!$)
  2512.               E:E TYPEINT.(PROMPT)
  2513.               E:E TYPEMSG.($ = IBM PROMPT!$)
  2514.            O'E
  2515.               E:E TYPEMSG.($IBM flag = OFF!$)
  2516.            E'L
  2517.            E:E TYPEINT.(PAKSIZ)
  2518.            E:E TYPEMSG.($ = PACKET size!$)
  2519.  
  2520.            E:E TYPEINT.(MYQUOTE)
  2521.            E:E TYPEMSG.($ = MYQUOTE!$)
  2522.            E:E TYPEINT.(SOH)
  2523.            E:E TYPEMSG.($ = SOH!$)
  2524.            E:E TYPEMSG.($Remote TTY line used is ??!$)
  2525.            W'R (STATE.EQ.BIGC)
  2526.               E:E TYPEMSG.($File transfer state = C!$)
  2527.            O'E
  2528.               E:E TYPEMSG.($File transfer state = A!$)
  2529.            E'L
  2530.       E'L
  2531.       F'N
  2532.       E:N
  2533. <<< KERMIT.TEXT-FILE-IO >>>
  2534. ; 18 aug 85 esj replaces s.e.fm.error.uil with kerdef
  2535. * 18 jly 85 ESJ CREATED FOR kermit
  2536. *
  2537. *-----------------------------  text-file-io  -------------------------
  2538.    E:F A:S(NWLS , STKARG)
  2539. *-----------------------------------------------------------------------
  2540. *
  2541. * PURPOSE
  2542. *
  2543. * INPUT
  2544.    I'R FD(*)            ; file descriptor block
  2545. *
  2546. * OUTPUT
  2547. *)
  2548. *
  2549. * GLOBALS DEFINITIONS
  2550. *  none
  2551. *
  2552. * LOCAL DEFINITIONS
  2553.    I'R NEWNAME(42)      ; dest name field
  2554.    I'R PACKNAME(42)     ; temp for packed filename
  2555.    I'R OPENMODE         ; open mode temp
  2556.    I'R TEMPMODE         ; open mode temp
  2557.    I'R OTSPC(9)         ;
  2558.    I'R STATUS(1)        ; FM error code
  2559.    I'R WRSPEC(3)        ; inspecs field for write call
  2560.  
  2561.  
  2562. * SUBROUTINES CALLED
  2563. *
  2564. * INSERTS
  2565. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  2566. /INCLUDE SYM.EQU.FM.OPEN
  2567. /INCLUDE SYM.EQU.FM.BASIC
  2568. /INCLUDE SYM.EQU.FM.READ
  2569.  
  2570. *--- put equates for the FD block here till ready to move to sym file---
  2571.  
  2572.       EQU   FD&CHAN = 0          ; channel number of the file once it's
  2573.                                  ; open
  2574.  
  2575.       EQU   FD&MAX  = 1          ; maximum length of the text record which
  2576.                                  ; can be handled by this FD. It is also
  2577.                                  ; the size of the FD&TXTB field.
  2578.  
  2579.       EQU   FD&NDX  = 2          ; index for next char to be read from TXTB
  2580.  
  2581.       EQU   FD&MODE = 3          ; mode of how the file was opened
  2582.  
  2583.       EQU   FD&LNPOS= 4          ; number of current line being read. 0 based
  2584.  
  2585.       EQU   FD&TXTC = 5          ; text count. The length of the text record
  2586.                                  ; currently in this FD
  2587.  
  2588.       EQU   FD&TXTB = FD&TXTC+1  ; text buffer
  2589.  
  2590. *-----------------------------------------------------------------------
  2591. *
  2592. * STATIC DATA INITIALIZATION
  2593.       V'S TXTSPEC =  03,
  2594. 1                    %CATLOG,%%SEARCH,
  2595. 1                    %FORMAT , %%TEXT,
  2596. 1                    %RTNERR
  2597.  
  2598.       V'S BCDNAME = 4,$&BCD$
  2599. *
  2600. * RESTRICTIONS
  2601. *
  2602. * ERROR INDICATIONS
  2603. *
  2604. * METHOD
  2605. *
  2606. *
  2607. *---------------------------- START OF CODE ----------------------------
  2608. *  HOW TO USE
  2609. *     opentext is part of a simplified interface for manipulating
  2610. *     text files with the new file manager.  opentext is used to
  2611. *     open a text file for stream io.
  2612. *     opentext takes four arguments:
  2613. *     1) FD is a buffer that contains information about the file and
  2614. *        the record being manipulated.  the information in FD is to be
  2615. *        hidden from the user so that information can be added,deleted
  2616. *        or changed without the need to support existing structures.
  2617. *        The size of FD is defined by FD&SIZE. The buffer will need to
  2618. *        be created by an ALLOC call because the buffer is larger than a
  2619. *        local data section.
  2620. *     2) FILENAME is a string in kermit or cv format.  opentext will
  2621. *        make a copy of the file name and add an &bcd level to the name
  2622. *        and stick an ! on the end, if needed converting the file name
  2623. *        to a proper text file name.
  2624. *     3) TEXTMODE is a two character descripter for the open mode for
  2625. *        a text file.  The only modes supported are, RD for read,
  2626. *        MO for modify, and SU for supercede.
  2627. *
  2628. *     4) NAMETYPE defines the type of string in filename.  CV is a cv type
  2629. *        of string.  KM is a kermit type of string.
  2630. *
  2631.       E'O OPENTEXT.( FILENAME, TEXTMODE, NAMETYPE, FD)
  2632.  
  2633. #     E'E TYPE.(2,NAMETYPE)
  2634.       ; convert filename to &bcd type and put ! on end
  2635.       W'R NAMETYPE .E. $KM$
  2636. #        E'E HEXDMPP.(1,41,1,FILENAME)
  2637.          E'E PACK.(FILENAME, PACKNAME )
  2638. #        E'E HEXDMP.(2,42,2,PACKNAME)
  2639.          E'E FMEXPNM.(PACKNAME,BCDNAME,NEWNAME)
  2640.       O'E
  2641.          E'E FMEXPNM.(FILENAME,BCDNAME,NEWNAME)
  2642.       E'L
  2643.  
  2644.  
  2645.       W'R LDCHRT.(NEWNAME(1),NEWNAME-1) .NE. $!$
  2646.          E'E STCHRT.($!$,NEWNAME(1),NEWNAME)
  2647.          NEWNAME(0) = NEWNAME(0) + 1
  2648.       E'L
  2649.  
  2650. #     E'E TYPEMSG.($THIS SHOULD BE THE &BCD NAME!$)
  2651. #     E'E HEXDMP.(0,NEWNAME,0,NEWNAME)
  2652.  
  2653.       ; convert textmode to open file mode
  2654.       ; convert char string to cv char type and lower case
  2655.       TEMPMODE = TEXTMODE .LOR. 'A0A0'
  2656.  
  2657. #     E'E HEXDMP.(TEMPMODE,TEMPMODE,TEMPMODE,TEMPMODE)
  2658.       W'R TEMPMODE .E. $rd$
  2659.          ; read mode
  2660.          OPENMODE = %OREAD
  2661. *
  2662.       O'R TEMPMODE .E. $mo$
  2663.          ; modify mode
  2664.          OPENMODE = %OMODIFY
  2665. *
  2666.       O'R TEMPMODE .E. $su$
  2667.          ; supercede mode
  2668.          OPENMODE = %OSUPR
  2669.  
  2670.       O'E
  2671.          ; force openmode error
  2672.          OPENMODE = -1
  2673.  
  2674.       E'L
  2675. *
  2676. *  Set to no error
  2677.       STATUS = STATUS(1) = FM%NOERR
  2678.  
  2679.       ; call the fm and try to open
  2680.       E'E F&OPEN.(OPENMODE,
  2681. 1                 %IDFILNM,
  2682. 1                 NEWNAME ,
  2683. 1                 TXTSPEC ,
  2684. 1                 FD(FD&CHAN),
  2685. 1                 OTSPC   ,
  2686. 1                 STATUS  )
  2687.  
  2688. #     E'E HEXDMP.(1,1,1,STATUS)
  2689. *
  2690.       FD(FD&NDX)   = 0            ; make text buffer empty
  2691.       FD(FD&TXTC)  = 0
  2692.       FD(FD&MODE)  = OPENMODE     ; set up access protection
  2693.       FD(FD&LNPOS) = 0
  2694.  
  2695.       F:N STATUS
  2696.  
  2697.  
  2698. *------------  end of opentext  -------------------------------------
  2699. *------------  start of dgetch  --------------------------------------
  2700. *     dgetch is part of a simplified interface for Manipulating
  2701. *     text files with the new file manager.  dgetch is used to
  2702. *     read characters from a text file for stream io.
  2703. *     dgetch takes two arguments:
  2704. *     1) CHAR is a single char from the file described in FD.  The
  2705. *        character is in kermit format.  When end of file is reached,
  2706. *        CHAR will equal -1.  End of line is indicated by CR.
  2707. *     2) FD is a buffer that contains information about the file and
  2708. *        the record being manipulated.  the information in FD is to be
  2709. *        hidden from the user so that information can be added,deleted
  2710. *        or changed without the need to support existing structures.
  2711. *        The size of FD is defined by FD&SIZE. The buffer will need to
  2712. *        be created by an ALLOC call because the buffer is larger than a
  2713. *        local data section.
  2714. *
  2715.    V'S RDSPC = 02,
  2716. 1              %RTNERR,
  2717. 1              %RETURN,1,
  2718. 1                     %%BYTCNT
  2719.  
  2720.       E'O DGETCH.(CHAR, FD)
  2721.  
  2722.       STATUS = STATUS(1) = 0
  2723.  
  2724.       ;if char index = 0 read in line and stick cr at end
  2725.       W'R FD(FD&NDX) .E. 0
  2726.  
  2727.          E'E F&READ.(FD(FD&CHAN),
  2728. 1                    1           ,
  2729. 1                    FD(FD&TXTB) ,
  2730. 1                    RDSPC       ,
  2731. 1                    OTSPC       ,
  2732. 1                    STATUS      )
  2733.  
  2734.          W'R STATUS .GE. FM%NOERR
  2735.             FD(FD&TXTC) = OTSPC(3)
  2736.             E'E STBYTT.('8D', FD(FD&TXTB), FD(FD&TXTC))
  2737.             FD(FD&TXTC) = FD(FD&TXTC) + 1
  2738.          E'L
  2739.  
  2740.       E'L
  2741.  
  2742.       W'R STATUS .GE.FM%NOERR
  2743.          ; get a char from the input stream
  2744.          CHAR = LDBYTT.(FD(FD&TXTB), FD(FD&NDX)) .LAND. '7F'
  2745.  
  2746.          W'R CHAR .E. '000D'
  2747.             FD(FD&NDX) = 0
  2748.             FD(FD&LNPOS) = FD(FD&LNPOS) + 1
  2749.          O'E
  2750.             FD(FD&NDX) = FD(FD&NDX) + 1
  2751.          E'L
  2752.  
  2753.       O'R STATUS .E. UL%RDEOF
  2754.          ; if at eof set char = -1
  2755.          CHAR = -1
  2756.  
  2757.       E'L
  2758.  
  2759.       F'N STATUS
  2760.  
  2761. *-------------- end of dgetch  -----------------------------------------
  2762. *-------------- start of dputch  ---------------------------------------
  2763. *     dputch is part of a simplified interface for manipulating
  2764. *     text files with the new file manager.  dputch is used to
  2765. *     write a stream of characters to a text file.
  2766. *     dputch takes two arguments:
  2767. *     1) CHAR is a single char from the file described in FD.  The
  2768. *        character is in kermit format.  The end of line is indicated by
  2769. *        the symbol CR.
  2770. *     1) FD is a buffer that contains information about the file and
  2771. *        the record being manipulated.  the information in FD is to be
  2772. *        hidden from the user so that information can be added,deleted
  2773. *        or changed without the need to support existing structures.
  2774. *        The size of FD is defined by FD&SIZE. The buffer will need to
  2775. *        be created by an ALLOC call because the buffer is larger than a
  2776. *        local data section.
  2777.  
  2778.       E'O DPUTCH.(CHAR, FD)
  2779.  
  2780.       STATUS = 0
  2781. #     E'E HEXDMP.(0,0,0,CHAR)
  2782. #     E'E HEXDMP.(1,50,1,FD(FD&TXTC))
  2783.       W'R CHAR .NE. '000D'
  2784.          W'R CHAR .E. '000A' .AND. FD(FD&TXTC) .E. 0 , T:O EXITPCH
  2785.          FD(FD&NDX) = FD(FD&NDX) + 1
  2786.          W'R PACKLINE.((CHAR), FD(FD&TXTC)) .NE. -1, T:O EXITPCH
  2787.       E'L
  2788.       WRSPEC(0) = 2
  2789.       WRSPEC(1) = %RECLEN
  2790.       WRSPEC(2) = FD(FD&TXTC)
  2791.       WRSPEC(3) = %RTNERR
  2792.       E'E F&WRITE.(FD(FD&CHAN), 1, FD(FD&TXTB), WRSPEC, OTSPC, STATUS)
  2793.  
  2794.       FD(FD&TXTC)  = FD(FD&NDX) = 0
  2795.       FD(FD&LNPOS) = FD(FD&LNPOS) + 1
  2796.  
  2797. EXITPCH C'E
  2798.       F'N STATUS
  2799.  
  2800.  
  2801. *-------------- end of dputch  -----------------------------------------
  2802. *-------------- start of closstrm -------------------------------------
  2803. *     closstrm is part of a simplified interface for manipulating
  2804. *     text files with the new file manager.  closstrm is used to
  2805. *     close a text file used for stream io.
  2806. *     closstrm takes one argument:
  2807. *     1) FD is a buffer that contains information about the file and
  2808. *        the record being manipulated.  the information in FD is to be
  2809. *        hidden from the user so that information can be added,deleted
  2810. *        or changed without the need to support existing structures.
  2811. *        The size of FD is defined by FD&SIZE. The buffer will need to
  2812. *        be created by an ALLOC call because the buffer is larger than a
  2813. *        local data section.
  2814. *
  2815.       V'S CLOSPC = 1,
  2816. 1                  %RTNERR
  2817.  
  2818.       E'O CLOSTEXT.(FD)
  2819.  
  2820. #     E'E TYPEMSG.($ CLOSSTRM!$)
  2821. #     E'E HEXDMP.(0,0,0,FD(FD&TXTC))
  2822.       W'R FD(FD&TXTC) .NE. 0
  2823.          ;  the line buffer is not empty, so flush the line to disk
  2824.          E'E DPUTCH.('000D', FD)
  2825.       E'L
  2826.  
  2827.       E'E F&CLOSE.(FD(FD&CHAN),CLOSPC, STATUS)
  2828.  
  2829.       F'N STATUS
  2830.  
  2831. *-------------- end of clostext -------------------------------------
  2832. *
  2833.       E:N
  2834. <<< KERMIT.TGETCH >>>
  2835. ; 29 jly 85 esj added timeout support
  2836. ; 17 jly 85 esj converted
  2837. ;;;;;;;;;;;         TGETCH                 ;;;;;;;;;;;;
  2838.       E'F A:S(NWLS)
  2839.       E'O TGETCH.(XCHAR,UNIT)
  2840.  
  2841. ;  PURPOSE
  2842. ;     get a CHAR from the TTY without echoing it
  2843.  
  2844. ; INPUT
  2845. ;  none
  2846.  
  2847. ; OUTPUT
  2848.    I'R XCHAR   ; char output- char in lo byte
  2849.    I'R UNIT    ; unit we expect input from
  2850.  
  2851. ; LOCAL STORAGE
  2852.    I'R TYPE    ; type of input from tis
  2853.    I'R COUNT   ; count of char input from tis
  2854.    I'R CHBUF   ; buffer of char input from tis
  2855.    I'R TISUNIT ; unit the input came from
  2856.  
  2857. ; global
  2858.    G'L TIMEOUT(1)
  2859.    G'L LOCALDEV
  2860.    G'L HOSTON
  2861.  
  2862. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  2863.  
  2864. #  E'E TYPOUT.( 2,UNIT )
  2865. #  E'E TYPEMSG.($ <--- UNIT TO GET INPUT FROM!$ )
  2866.  
  2867.    R'T
  2868.  
  2869.       E'E INPUT.(TISUNIT, TYPE, COUNT, CHBUF)
  2870.  
  2871.       W'R HOSTON .E. NO .AND. TISUNIT .E. LOCALDEV
  2872. ;     we probably hung, so abort to rpack as a bad packet
  2873.          E'E LBLGO.(TIMEOUT)
  2874.       E'L
  2875.  
  2876.    U'L UNIT .E. TISUNIT
  2877.  
  2878. #  E'E TYPEHEX.(CHBUF)
  2879.  
  2880.    XCHAR = CHBUF .LAND. '7F'X
  2881.  
  2882.    F'N OK
  2883.    E'N
  2884. <<< KERMIT.TOCHAR >>>
  2885. ; 18 jly 85 esj converted
  2886. ;;;;;;;;;;;;          TOCHAR          ;;;;;;;;;;;;;;;;;;;;;;C
  2887.       E'F
  2888.       E'O TOCHAR.(CH)
  2889.  
  2890.  
  2891. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  2892.  
  2893.       F'N (CH+BLANK)
  2894.       E'N
  2895. <<< KERMIT.TPUTCH >>>
  2896. ; 15-AUG-85 MVI: CHANGED NO IOFLAG VALUE FROM 0 TO -1.
  2897. ; 07 AUG 85 DG IOFLAG IS PART OF UNIT
  2898. ; 06 AUG 85 DG ADDED NO WAIT I/O SUPPORT
  2899. ; 17 jly 85 esj converted
  2900. ;;;;;;;;;;;;;;          TPUTCH          ;;;;;;;;;;;;;;;;;;;;;;;;
  2901.       E'F A:S(NWLS)
  2902.       E'O TPUTCH.(XCHAR, UNIT)
  2903.  
  2904. ;  PURPOSE
  2905. ;     output a char to the TTY line
  2906.  
  2907. ; INPUT
  2908.    I'R XCHAR   ; char output- char in lo byte
  2909.    I'R UNIT(1) ; UNIT(0) unit we want to send char to
  2910.                ; UNIT(1) I/O flag for the unit
  2911.  
  2912. ; OUTPUT
  2913. ;  none
  2914.  
  2915.  
  2916. ; LOCAL STORAGE
  2917.    I'R ARGLIST(2)
  2918.    I'R CHAR          ; local char temp
  2919.  
  2920. ;------------------------< start of executable code >-----------------------
  2921.  
  2922. #   E'E TYPE.(2,UNIT)
  2923. #   E'E HEXDMP.(0,0,0,XCHAR)
  2924.  
  2925.    ARGLIST(0) = 0
  2926.    ARGLIST(1) = 1
  2927.    ARGLIST(2) = 0
  2928.  
  2929.    CHAR = XCHAR .LSH. 8
  2930.  
  2931.    W'R UNIT(1) .NE. -1
  2932. ;     -1 means first time through for this unit
  2933.  
  2934.      W:R TESTIO.(UNIT(1)).E.0     ;I/O IN PROGRESS FROM LAST REQUEST
  2935.         E:E WAITIO.(UNIT(1))      ;WAIT FOR I/O TO FINISH
  2936.      E:L
  2937.    E'L
  2938.  
  2939.    UNIT(1) = CONTROL.( UNIT, ARGLIST, CHAR, '0001')  ;NO WAIT I/O
  2940.  
  2941.    F'N
  2942.    E'N
  2943. <<< KERMIT.UN&PACK >>>
  2944. * 27-AUG-83 JDG
  2945. *
  2946. *-------------------------------------------  ???????.UN&PACK ----------
  2947.     E:F A:S(NWLS , STKARG)
  2948. *-----------------------------------------------------------------------
  2949. *
  2950. * PURPOSE
  2951. *
  2952. *     PACKLINE: ADD CHAR TO AN ARRAY
  2953. *     EMPTLINE: UNPACK A CHAR FROM ARRAY CHARACTER INTO CHAR
  2954. *
  2955. * INPUT
  2956. *
  2957. *     PACKLINE: CHAR:   ELEMENT TO ADD TO ARRAY
  2958. *               ARRAY:  ARRAY TO STUFF CHAR INTO
  2959. *     EMPTLINE: ARRAY:  ARRAY FROM WHICH TO DRAW CHAR
  2960. *
  2961. * OUTPUT
  2962. *
  2963. *     PACKLINE:    UPDATED ARRAY
  2964. *                  F:N TRUE ==> ARRAY FULL
  2965. *                  F:N FALSE==> ARRAY NOT FULL
  2966. *     EMPTLINE:    CHAR FROM ARRAY,UPDATED ARRAY
  2967. *                  F:N TRUE ==> ARRAY EMPTY
  2968. *                  F:N FALSE==> ARRAY NOT EMPTY
  2969. *
  2970. * LOCAL DEFINITIONS
  2971. *
  2972.       I:R CHAR          ; contains char to be put into array
  2973.                         ; char format can be the same as fig-forth
  2974.                         ; char is in lower byte of word  '00cc' where
  2975.                         ; cc is the hex code for a char
  2976.                         ; or the chat format can be that of cgos where
  2977.                         ; the char is in the high order byte and has
  2978.                         ; the '80' bit turned on
  2979.  
  2980.       D:N ARRAY(81)     ; array contains the string of packed chars
  2981.                         ; the format of array is :
  2982.                         ; |xxxx|cccc|cccc|cc??|
  2983.                         ; xxxx = count of char in string
  2984.                         ; cccc = two packed char in one word
  2985. *
  2986.       I:R TCHAR         ; temp version of char
  2987. *
  2988. * DATA STATEMENT
  2989. *
  2990.       V:S MAXNDX = '80'
  2991.       V:S TRUE = -1
  2992.       V:S FALSE = 0
  2993. *
  2994. ************************************************************************
  2995. *                START OF EXECUTABLE CODE
  2996. ************************************************************************
  2997. *
  2998.       E:O PACKLINE.(CHAR,ARRAY)
  2999. *
  3000.       W:R ARRAY(0).UGE.MAXNDX
  3001.          STAT = TRUE
  3002.       O:E
  3003.          W:R CHAR .L. 0
  3004.             TCHAR = CHAR .RSH. 8
  3005.          O:E
  3006.             TCHAR = CHAR .LAND. '7F' .LOR. '80' ; MAKE IT CGOS FORMAT
  3007.          E:L
  3008.          E'E STBYTT.(TCHAR, ARRAY(1), ARRAY(0))
  3009.          ARRAY(0) = ARRAY(0) + 1
  3010.          W:R ARRAY(0).UL.MAXNDX
  3011.              STAT = FALSE
  3012.          O:E
  3013.              STAT = TRUE
  3014.          E:L
  3015.       E:L
  3016. #  W:R ARRAY(0) .UGE. MAXNDX , E:E HEXDMP.(1,1,1,ARRAY(0))
  3017.          F:N STAT
  3018. *
  3019. ************************************************************************
  3020. *
  3021.       E:O EMPTLINE.(CHAR,ARRAY)
  3022. *
  3023.       W:R ARRAY(0).E.0, F'N TRUE       ; EMPTY ARRAY
  3024.       ARRAY(0) = ARRAY(0) - 1
  3025.       ; pull char out of array from front to back
  3026.       CHAR = LDBYTT.(ARRAY(1), MAXNDX - ARRAY(0))
  3027.       W:R ARRAY(0).NE.0
  3028.          STAT = FALSE
  3029.       O:E
  3030.          STAT = TRUE
  3031.       E:L
  3032.       F:N STAT
  3033. *
  3034.       E:N
  3035. <<< KERMIT.UNCHAR >>>
  3036. ; 18 jly 85 esj converted
  3037. ;;;;;;;         UNCHAR           ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3038.       E'F
  3039.       E'O UNCHAR.(CH)
  3040.  
  3041. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  3042.  
  3043.       F'N  (CH-BLANK)
  3044.  
  3045.       E'N
  3046. <<< KERMIT.VERSION-LOG >>>
  3047. * 26 aug 85 esj v1.21 made loadlib.kermit to remove the last of the cgos work
  3048. *               pack dependences. (i hope) also added debug flag
  3049. * 18 aug 85 esj v1.20 removed s.e.fm.error.uil references and made fewer
  3050. *               cgos workpack dependences.
  3051. * 16 aug 85 esj/pcc v1.19 removed server commands as aliases.
  3052. *               added formatting around sending messages.
  3053. *               added formatting around receiving messages.
  3054. *               allow device names selected by set line to
  3055. *               begin with non alfa characters.
  3056. * 15 aug 85 mvi/esj v1.18a sconnect and no wait io mods to prevent
  3057. *               sconnect keep from dropping characters
  3058. * 13 aug 85 esj v1.18 added aliases for: quit,receive,connect
  3059. *               made connect state the actual char to be typed for leaving
  3060. *               connect mode.
  3061. * 12 aug 85 esj v1.17 converted to cvcommand for submission to master pack
  3062. *  7 aug 85 esj v1.16 added send @filename, AND first public release
  3063. *  7 aug 85 dg/esj v1.15 add support for no wait io in tputch and putlin
  3064. *  6 aug 85 esj v1.14 fixed the printing of dots when a packet is received to
  3065. *               a routine of its own. Also made it add a crlf at 80 char limit
  3066. *               changed messages for sending and getting files.
  3067. *               added "waiting <n> seconds" to ssend when in remote mode.
  3068. *  6 aug 85 esj V1.13 created
  3069. *----------------------------< version-log >-----------------------------
  3070. *
  3071. * This file contains the version number for kermit.  This must be included with
  3072. * every submission.
  3073.  
  3074.    global vernum(5)
  3075.    set    vernum = " V1.21!"
  3076.  
  3077. * debug is a symbol to control conditional loading in the kermit make
  3078. * file.  if debug = 0 then debugging is off.  if debug = -1 the debugging is
  3079. * on
  3080.    equ debug = 0
  3081. <<< KERMIT.XDELAY >>>
  3082. ; 22 jly esj converted
  3083. ;;;;;;;;;;;;;;;;;;;          XDELAY          ;;;;;;;;;;;;;;;;;;;C
  3084.       E'F A:S(NWLS)
  3085.       E'O XDELAY.(X)
  3086.  
  3087. ;     delay the calling program for x seconds
  3088.  
  3089.  
  3090.    E'E HIBERN8.(100*X)
  3091.    F'N
  3092.    E'N
  3093. <<< KERMIT.SYM.EQU.KERCOM >>>
  3094. ; 22 jly 85 esj converted and eliminated uneeded globals
  3095. ;;;;;;;;;;;;;;  KERCOM         ;;;;;;;;;;;;;;;;;;;;;;;
  3096. ;     DEFINITION OF KEY GLOBAL VARIABLES FOLLOWS:
  3097.  
  3098. ;     DELAY        - # of seconds waited before sending out the first
  3099. ;                  - SINIT packet ( only in remote mode).
  3100. ;     EOL          - End of line delimiter required by other KERMITS.
  3101. ;     ESCHAR       - The character used to return back to command parser
  3102. ;                  - from 'CHAT' mode.
  3103. ;     FD           - The file descriptor of sending/receiving
  3104. ;                  - file
  3105. ;     FILNAME(*) - The integer array which holds  The currrent working
  3106. ;                  - filename
  3107. ;     HOSTON       - Identifies whether this KERMIT is running in local
  3108. ;                  - or remote mode.
  3109. ;     IBMON        - Identifies whether this KERMIT is talking to an
  3110. ;                  - IBM CMS system.
  3111. ;     MAXTRY       - Maximum number of re-try before giving up
  3112. ;     MYEOL        - The end of line delimiter selectable by users
  3113. ;     MYPAD        - The # of pad characters required by this KERMIT
  3114. ;     MYPCHAR      - The pad character required by this KERMIT
  3115. ;     MYQUOTE      - The quote  used for control s
  3116. ;                  - by this KERMIT slectable by user
  3117. ;     N            - The number of the current packet frame number
  3118. ;     NUMTRY       - The number of re-try attempt so far
  3119. ;     OLDTRY       - The number of re-try already attempted
  3120. ;     PACKET(*)  - An integer array to hold the content of a packet
  3121. ;     PAD          - The # of pad characters required by other KERMIT
  3122. ;     PADCHAR      - The pad character to used if required by other KERM
  3123. ;     PAKSIZ       - The maximum packet size selectable by users
  3124. ;     PROMPT       - The turnaround control character this KERMIT looks
  3125. ;                  - for in file transfer with IBM.
  3126. ;     QUOTE        - The quote character used for control character used
  3127. ;                  - by other KERMITS
  3128. ;     RECPKT(*)  - An integer array which holds the incoming packet
  3129. ;     RMTDEV(*)  - The remote (TTY) line KM will be the default name
  3130. ;                  - RMTDEV(1) = IOFLAG FOR THE UNIT
  3131. ;     LOCALDEV(*)- Local (tty) (login line) SD is the device name
  3132. ;                  - LOCALDEV(1) = IOFLAG FOR THE UNIT
  3133. ;     RMTTTY(*)  - An integer array which hold the un-login line
  3134. ;                  - for file-transfer.
  3135. ;     RPSIZ        - maximum size of packet to be receive
  3136. ;     SBAUD        - whether this system supports baud switching
  3137. ;     SIZE         - maximum size of data packet to be sent
  3138. ;     SOH          - The start of header used in sending packet; selecta
  3139. ;                  - by user
  3140. ;     SPARITY      - whether this system supports parity switching
  3141. ;     SPORT        - whether this system supports remote line switching
  3142. ;     SPSIZ        - Maximum size of packet to be used for sending
  3143. ;     STATE        - Current state of file transfer processs
  3144.  
  3145.  
  3146.       G'L   DELAY,EOL,ESCHAR,FD(*),FILNAME(*),HOSTON
  3147.       G'L   IBMON,MAXTRY
  3148.       G'L   MYEOL,MYPAD,MYPCHAR,MYQUOTE,N,NUMTRY,OLDTRY
  3149.       G'L   PACKET(*),PAD,PADCHAR,PAKSIZ,PROMPT
  3150.       G'L   QUOTE,RECPKT(*),RMTDEV(*),RMTTTY(*)
  3151.       G'L   RPSIZ,SBAUD,SIZE,SOH,SPARITY,SPORT,SPSIZ
  3152.       G'L   STATE
  3153.       G'L   LOCALDEV(*) ; replaced --> LOCALINFD
  3154.                         ; NOT USED --> LOCALOUTFD
  3155. <<< KERMIT.SYM.EQU.KERDEF >>>
  3156. ; 19 aug 85 esj added fm error constants as teq in case they really get
  3157. ;           included
  3158. ; 23 jly 85 esj oops, equs need hex constant, not decimal
  3159. ; 16 jly 85 esj renamed constants with excessive size.
  3160. ;;;;;;;;;;;;;;  KERDEF         ;;;;;;;;;;;;;;;;;;;;;;;
  3161. ;     DEFINES VARIOUS CONSTANTS FOR THE KERMIT-CGOS PROGRAM
  3162.    EQU   BACKSLSH    =    5C  ; replaced --> BACKSLASH = 92
  3163.    EQU   BACKSPCE    =     8  ; replaced --> BACKSPACE = 8
  3164.    EQU   GOOD        =     0
  3165.    EQU   BAD         =    8000
  3166.    EQU   BANG        =    21
  3167.    EQU   BAR         =    7C     ;
  3168.    EQU   ATSIGN      =    40
  3169.    EQU   BIGA        =    41
  3170.    EQU   BIGB        =    42
  3171.    EQU   BIGC        =    43
  3172.    EQU   BIGD        =    44
  3173.    EQU   BIGE        =    45
  3174.    EQU   BIGF        =    46
  3175.    EQU   BIGG        =    47
  3176.    EQU   BIGH        =    48
  3177.    EQU   BIGI        =    49
  3178.    EQU   BIGJ        =    4A
  3179.    EQU   BIGK        =    4B
  3180.    EQU   BIGL        =    4C
  3181.    EQU   BIGM        =    4D
  3182.    EQU   BIGN        =    4E
  3183.    EQU   BIGO        =    4F
  3184.    EQU   BIGP        =    50
  3185.    EQU   BIGQ        =    51
  3186.    EQU   BIGR        =    52
  3187.    EQU   BIGS        =    53
  3188.    EQU   BIGT        =    54
  3189.    EQU   BIGU        =    55
  3190.    EQU   BIGV        =    56
  3191.    EQU   BIGW        =    57
  3192.    EQU   BIGX        =    58
  3193.    EQU   BIGY        =    59
  3194.    EQU   BIGZ        =    5A
  3195.    EQU   BLANK       =    20
  3196.    EQU   CARET       =    5E
  3197.    EQU   COLON       =    3A
  3198.    EQU   COMMA       =    2C
  3199.    EQU   CR          =    0D
  3200.    EQU   DEL         =    7F
  3201.    EQU   DIG0        =    30
  3202.    EQU   DIG1        =    31
  3203.    EQU   DIG2        =    32
  3204.    EQU   DIG3        =    33
  3205.    EQU   DIG4        =    34
  3206.    EQU   DIG5        =    35
  3207.    EQU   DIG6        =    36
  3208.    EQU   DIG7        =    37
  3209.    EQU   DIG8        =    38
  3210.    EQU   DIG9        =    39
  3211.    EQU   DIGIT       =     2
  3212.    EQU   DOLLAR      =    24
  3213.    EQU   DQUOTE      =    22
  3214.    EQU   EOF         =  -1
  3215.    EQU   EOS         =  -8
  3216.    EQU   LETA        =    61
  3217.    EQU   LETB        =    62
  3218.    EQU   LETC        =    63
  3219.    EQU   LETD        =    64
  3220.    EQU   LETE        =    65
  3221.    EQU   LETF        =    66
  3222.    EQU   LETG        =    67
  3223.    EQU   LETH        =    68
  3224.    EQU   LETI        =    69
  3225.    EQU   LETJ        =    6A
  3226.    EQU   LETK        =    6B
  3227.    EQU   LETL        =    6C
  3228.    EQU   LETM        =    6D
  3229.    EQU   LETN        =    6E
  3230.    EQU   LETO        =    6F
  3231.    EQU   LETP        =    70
  3232.    EQU   LETQ        =    71
  3233.    EQU   LETR        =    72
  3234.    EQU   LETS        =    73
  3235.    EQU   LETT        =    74
  3236.    EQU   LETU        =    75
  3237.    EQU   LETV        =    76
  3238.    EQU   LETW        =    77
  3239.    EQU   LETX        =    78
  3240.    EQU   LETY        =    79
  3241.    EQU   LETZ        =    7A
  3242.    EQU   LF          =    0A
  3243.    EQU   NO          =     0
  3244.    EQU   OK          =    -2
  3245.    EQU   PERCENT     =    25
  3246.    EQU   PERIOD      =    2E
  3247.    EQU   PLUS        =    2B
  3248.    EQU   QMARK       =    3F
  3249.    EQU   SEMICOL     =    3B
  3250.    EQU   SHARP       =    23
  3251.    EQU   SLASH       =    2F
  3252.    EQU   SQUOTE      =    27
  3253.    EQU   STAR        =    2A
  3254.    EQU   STDOUT      =     1
  3255.    EQU   TAB         =     9
  3256.    EQU   TILDE       =    7E
  3257.    EQU   UNDRLINE    =    5F       ; replaced --> UNDERLINE  = 95
  3258.    EQU   YES         =     1
  3259.  
  3260. ;  FM ERROR CONSTANTS
  3261.  
  3262.    ASSM
  3263.  
  3264.    TEQ   FM%NOERR    = 0000   ; Everything is fine.
  3265.    TEQ   UL%RDEOF    = 0C5F9  ; Attempt to read record at
  3266.                               ; End Of File
  3267.  
  3268.    ENDA
  3269.