home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ccpm86 / cn8trm.a86 < prev    next >
Text File  |  2020-01-01  |  8KB  |  258 lines

  1. ; * * * * * * * * * * * * * * * version 2.7 * * * * * * * * * * * * * * * *
  2. ; [fdc]    Print message about how to get help during connect.
  3. ; [29e]    Move terminal session logging to terminal module.
  4. ; * * * * * * * * * * * * * * * version 2.6 * * * * * * * * * * * * * * * *
  5. ; [24b revisited]    Fix handling of double-escape character
  6. ;    RonB, 03/22/84
  7. ; [26]
  8. ;      Move TELNET stuff from KERMIT to a this module: KERTRM.
  9. ;    This is to modularize terminal emulation.
  10. ;
  11. ;      integrate keyboard check in-line.  This allows keyboard check
  12. ;    between port checks to work without blowing the stack.
  13. ;
  14. ;    to improve speed, let the port-to-screen routine loop for a certain
  15. ;    number of characters before checking the keyboard.  If we
  16. ;    check every time,  we lose a few characters at 9600 baud 
  17. ;    without flow control.
  18. ;
  19. ;    Mar-1984.    R. Garland - Columbia University.
  20. ;
  21. ; [24]
  22. ; (a)   Add terminal session logging (KERMIT,KERSYS,KERUTL)
  23. ; (b)   Allow escape character to local-echo (KERMIT)
  24. ;    RonB, 03/15/84
  25. ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  26.  
  27.     cseg    $        ;resume code segment
  28.  
  29. ; This is the CONNECT command.  It makes the local Kermit act as a terminal.
  30.  
  31. telnet:    mov    ah,cmcfm
  32.     call    comnd        ;Get a confirm.
  33.      jmp    r        ; Didn't get a confirm.
  34.     mov    dx, offset inms01 ;Confirmed, print informatory message.
  35.     call    tcrmsg
  36.     call    escprt
  37.     mov    dx, offset inms02
  38.     call    tmsg        ;[fdc] Say how to get help during connect.
  39.     call    escprt        ;[fdc]
  40.     mov    dx, offset inms25    ;[fdc]
  41.     call    tmsgcr        ;[fdc]
  42.     cmp    logflg, 0    ;Is logging specified?        ;[24a] begin
  43.     je    telnt1
  44.     call    logopn        ;If so, open the log file
  45.      jmp    logerr                        ;[24a] end
  46.  
  47. telnt1:            ;Check keyboard.
  48.     mov    teloop, cx    ;initialize loop counter
  49.     call    dbinst        ;Any chars out there?
  50.      jmp    telntx        ; If not, check serial port
  51.     call    dbin        ;Yes, then get the char.
  52.     cmp    al, escchr    ;Is it an escape char?
  53.     jz    intchr        ;If so go process it.
  54. telnty:    call    dopar        ;Set parity (if any).        ;[24b]
  55.     mov    dx, ax
  56.     call    prtout        ;Output the char to the port.
  57.     cmp    ecoflg, 0    ;Is the echo flag turned on?
  58.     jz    telnt2        ;no - go on
  59.     and     dl, 7FH        ;Turn off the parity bit.
  60.     call     dbout        ;Echo the character.
  61. telntx:    mov    cx, telnct    ;load count for telnt2 loop
  62. telnt2:            ;Check serial port.
  63.     mov    teloop, cx    ;save loop count
  64.     call    instat        ;Any characters available?
  65.      jmp    telnt1        ; No, check keyboard
  66.     call    inchr        ;Get the character.
  67.     and    al, 7FH        ;Strip off parity bit.
  68.     mov    dl, al        ;Get the character.
  69.     call    dbout        ;output to screen.
  70.     mov    cx, teloop    ;get loop counter
  71.     loop    telnt2        ;loop a bunch of characters before
  72.                 ;checking keyboard - for speed.
  73.     jmp    telnt1        ;go back and check keyboard.
  74.  
  75. intchr:    call    dbin        ;Get a char.
  76.     cmp    al, 0        ;Is the char a null?
  77.     jz    intchr        ;If so, go until we get a char.
  78.     mov    bl, al        ;Save the actual char.
  79.     and    al, 137O    ;Convert to upper case.
  80.             ;C = close
  81.     cmp    al, 'C'        ;Is it close?
  82.     jne    intch0
  83.     call    logcls        ;Close the log file        ;[24a]
  84.     mov    dx, offset inms03
  85.     call    tcmsgc        ;return to micro message
  86.     jmp    rskp        ;return from telnet
  87.             ;B = break
  88. intch0:    cmp    al,'B'        ;[19e] Is it "send break"?
  89.     jne    intch1        ;[19e] no.
  90.     call    prtbrk        ;[19e] send a break.
  91.     jmp    telnt2        ;[19e]
  92.             ;escape character
  93. intch1:    cmp    bl, escchr    ;Is it the escape char?
  94.     jne    intch2        ;If not, go send a beep to the user.
  95.     mov    al, bl        ;If so, uncapitalize it        ;[24b]
  96.     jmp    telnty        ;go on, we are done here.        ;[24b]
  97.             ;? = help
  98. intch2:    cmp    bl, '?'        ;Is it a cry for help?            ;[20c]
  99.     jne    intch3
  100.     mov    dx, offset inthlp    ;If so, display help message on screen
  101.     call    tcrmsg
  102.     call    escprt
  103.     mov    dx, offset inthl2
  104.     call    tmsg
  105.     call    escprt
  106.     mov    dx, offset inthl3
  107.     call    tmsgcr
  108.     jmp    intchr        ;Keep looking for escape character.    ;[20c]
  109.             ;L = toggle logging
  110. intch3:    cmp    al, 'L'        ;Is it the logging toggle?    ;[24a] begin
  111.     jne    intch4
  112.     cmp    logflg, 0    ;Is logging now off?
  113.     jne    intc32
  114. intc31:    mov    logflg, 0FFh    ;If so, set to 'on' value.
  115.     call    logopn        ;Open log file.
  116.         jmp    logerr
  117.     jmp    telnt2
  118. intc32:    mov    logflg, 0
  119.     call    logcls        ;Close the log file.
  120.     jmp    telnt2                        ;[24a] end
  121.             ;Q = quit logging            ;[29e] begin
  122. intch4:    cmp    al, 'Q'
  123.     jne    intch5
  124.     cmp    logflg, 0    ;If logging currently enabled,
  125.     jne    intc32        ;  go set flag to 'off'
  126.     jmp    telnt2
  127.             ;R = resume logging
  128. intch5:    cmp    al, 'R'
  129.     jne    intch6
  130.     cmp    logflg, 0    ;If logging currently disabled,
  131.     je    intc31        ;  go set flag to 'on'
  132.     jmp    telnt2                        ;[29e] end
  133.             ;error = beep!
  134. intch6:    mov    dl, bell    ;Otherwise send a beep.
  135.     call    dbout
  136.     jmp    telnt2
  137.  
  138. logerr:    mov    logflg, 0    ;Reset logging on file error    ;[24a] begin
  139.     call    logcls        ;Make sure log file is closed
  140.     mov    dx, offset erms22 ;Print an error message.
  141.     call    tcrmsg
  142.     mov    dx, offset lfcb
  143.     call    tfile
  144.     call    tcrlf
  145.     jmp    rskp        ;And keep doing whatever we were ;[24a] end
  146.  
  147. ; These are the file handling routines for terminal session logging.
  148. ; LOGOPN opens the logfile in lfcb.
  149.  
  150. logopn:    mov    byte ptr lfcb+12,0
  151.     mov    byte ptr lfcb+13,0
  152.     mov    byte ptr lfcb+14,0
  153.     mov    dx, offset lfcb
  154.     call    gtjfn        ;Is file already present?
  155.     cmp    al, 0FFh
  156.     jne    logo4        ;If so, go seek to its end & open it.
  157.     mov    bx, offset lfcb+1 ;Don't allow wild or blank name
  158.     cmp    byte ptr [bx], ' '
  159.     je    logo2
  160.     cmp    wldflg, 0
  161.     je    logo3
  162. logo2:    cld
  163.     push    ds
  164.     pop    es
  165.     mov    di, offset lfcb    ;Make it "KERMIT.LOG" instead
  166.     mov    si, offset lognam
  167.     mov    cx, 12
  168.     rep movsb
  169. logo3:    mov    dx, offset lfcb
  170.     call    create        ;Otherwise create the file.
  171.     mov    bx, offset lfcb
  172.     mov    byte ptr 32[bx], 0    ;Zero "CR" field
  173.     mov    bx, offset dma
  174.     cmp    al, 0FFh    ;If no more directory space
  175.     jne    logo9
  176.     ret            ;  then return an error
  177.  
  178. logo4:    cld
  179.     push    ds
  180.     pop    es
  181.     mov    di, offset lfcb+1 ;Get the unambiguous filename
  182.     mov    si, offset dma+1
  183.     mov    cl, 5
  184.     shl    al, cl
  185.     mov    ah, 0
  186.     add    si, ax
  187.     mov    cx, 11
  188.     rep movsb
  189.     mov    dx, offset lfcb
  190.     call    openf
  191.     mov    dx, offset lfcb    ;Get existing file size
  192.     call    sizef
  193.     mov    bx, offset lfcb
  194.     cmp    byte ptr 35[bx], 0
  195.     je    logo5        ;If file is too full
  196.     ret            ;  then return an error
  197. logo5:    cmp    word ptr 33[bx], 0    ;Is the file totally empty?
  198.     je    logo8        ;  if so, don't look for control-Z.
  199.     dec    word ptr 33[bx]    ;Point to last record in file
  200.     mov    dx, offset lfcb
  201.     call    rinr        ;Read random
  202.     mov    bx, offset dma-1 ;Look for the terminating control-Z.
  203.     mov    cx, 80h
  204. logo6:    inc    bx
  205.     cmp    byte ptr [bx], 'Z'-100O
  206.     je    logo9
  207.     loop    logo6
  208.     mov    dx, offset lfcb
  209.     call    soutr        ;If no control-Z, then start a new buffer
  210. logo8:    mov    bx, offset dma
  211. logo9:    mov    bufpnt, bx    ;Save current buffer location.
  212.     mov    logfil, 0FFh    ;Flag that file is open
  213.     mov    dx, offset infm11 ;And display status on the terminal
  214.     call    tmsg
  215.     mov    dx, offset lfcb    ;Including the file name
  216.     call    tfile
  217.     mov    dx, offset infm12
  218.     call    tmsgcr
  219.     jmp    rskp        ;Return success.
  220.  
  221. ; LOGCLS - closes the log file, but only if it was open
  222.  
  223. logcls:    cmp    logfil, 0    ;Is file open?
  224.     je    logc3        ;No, just return.
  225.     cmp    bufpnt, offset dma ;Do we have an empty buffer?
  226.     je    logc2
  227.     mov    bx, bufpnt    ;If not, fill remainder with control-Z's
  228.     mov    cx, offset DMA+80h
  229.     sub    cx, bx
  230.     mov    al, 'Z'-100O
  231. logc1:    mov    [bx], al
  232.     inc    bx
  233.     loop    logc1
  234.     mov    dx, offset lfcb    ;Write out last buffer
  235.     call    soutr
  236. logc2:    mov    dx, offset lfcb    ;Close the log file
  237.     call    closf
  238.     mov    dx, offset infm13 ;Tell user so.
  239.     call    tcmsgc
  240.     mov    logfil, 0    ;Show file closed.
  241. logc3:    ret                            ;[24a] end
  242.  
  243.  
  244.  
  245. ;    data specific to terminal emulation
  246.  
  247.     dseg    $
  248.  
  249. telnct    dw    10        ;count of characters to take from port
  250.                 ;for the screen before checking keyboard.
  251. teloop    dw    0        ;active loop counter
  252. logflg    db    deflog        ;Is logging enabled?        ;[24a] begin
  253. logfil    db    0        ;Is the log file open?
  254. lognam    db    0,'KERMIT  LOG'    ;Default log filename
  255. lfcb    db    0,'KERMIT  LOG'    ;Logging file control block
  256.     rb    24                        ;[24a] end
  257.  
  258.