home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / test / pdp11 / krttra.mac < prev    next >
Text File  |  1996-10-17  |  7KB  |  240 lines

  1.     .title    KRTTRA    ASCII transfer to remote
  2.     .ident    "V04.64"
  3.  
  4. ; /E64/    05-May-96  John Santos
  5. ;
  6. ;    Conditionalize for RSTS/E
  7. ;    Restore RSTS-specific version of c$tran
  8.  
  9. ; /63/    24-Dec-94  Billy Youdelman
  10.  
  11. ; /62/    27-Jul-93  Billy Youdelman  V03.62
  12. ;
  13. ;    now called direct instead of through KRTCM1
  14.  
  15. ; /BBS/     1-Dec-91  Billy Youdelman  V03.61
  16. ;
  17. ;    after each byte sent the response from the receiver is echo'd
  18. ;    this makes it handy for reading text files into a called system's
  19. ;    message editor, etc..  speed is locked at 1 byte/tick, which is
  20. ;    600 baud in 60Hz land
  21. ;
  22. ;    added code at EOF so last char(s) echo'd by remote are displayed
  23. ;    modified action on EOF to reconnect, also suppress CONNECTs sign-on
  24. ;    message for a cleaner return
  25.  
  26. ;    07-Mar-84  11:42:22   Brian Nelson
  27. ;
  28. ;    Copyright 1984 Change Software, Inc.
  29.  
  30.  
  31.     .include "IN:KRTMAC.MAC"
  32.     .iif ndf  KRTINC  .error    <; .include for IN:KRTMAC.MAC failed>
  33.  
  34. .if df    RT11                ; /E64/
  35.     .mcall    .TTYOUT    ,.TWAIT
  36. .endc    ;RT11                ; /E64/
  37.  
  38.  
  39.     .psect    $pdata
  40. .if df    RT11                ; /E64/
  41. fifteen:.word    0 ,15            ; wait fifteen ticks after EOF
  42. short:    .word    0 ,1            ; wait up to 1 tick for remote to echo
  43. twarea:    .word    0 ,0            ; .twait work area
  44. .endc    ;RT11                ; /E64/
  45.  
  46. .if df    RSTS                ; /E64/
  47. isecho:    .word    0
  48. .endc    ;RSTS                ; /E64/
  49.  
  50.     .psect    $code
  51. .if df    RT11                ; /E64/
  52.     .sbttl    TRANSMIT        ; /BBS/ heavily hacked..
  53.  
  54. ;    input:    argbuf    = name of file to send
  55. ;    output:       r0    = if <>, error code
  56.  
  57. c$tran::tst    remote            ; /62/ disallow to TT
  58.     beq    10$            ; prevents typing TSX lead-in!
  59.     direrr    #er$pls            ; please SET LINE first
  60.     return
  61.  
  62. 10$:    clr    r2            ; input_open := false
  63.     clr    r3            ; terminal_set := false
  64.     upcase    argbuf            ; /62/ upper case all args
  65.     calls    fparse    ,<argbuf,#srcnam> ; /62/ parse the file name please
  66.     tst    r0            ; did the $parse work ok?
  67.     bne    50$            ; no
  68.     calls    iswild    ,<#srcnam>    ; check for wildcarded file spec
  69.     tst    r0            ; is it?
  70.     bne    50$            ; ya..
  71.  
  72.     call    opentt            ; open the link
  73.     tst    r0            ; did it work?
  74.     bne    50$            ; no
  75.     mov    sp    ,r3        ; ya, flag link is init'd..
  76.     calls    open    ,<#srcnam,#lun.in,#text> ; open the input file
  77.     tst    r0            ; did it work?
  78.     bne    50$            ; no
  79.     mov    sp    ,r2        ; ya, flag the file is open
  80.  
  81. 20$:    tst    cccnt            ; ^C typed?
  82.     bne    60$            ; ya, exit
  83.     calls    getc    ,<#lun.in>    ; no, get the next char in the file
  84.     tst    r0            ; did that work?
  85.     bne    50$            ; no
  86.     cmpb    r1    ,#lf        ; a line feed we don't need?
  87.     beq    20$            ; ya, skip it
  88.     mov    r1    ,-(sp)        ; one word buffer
  89.     mov    sp    ,r1        ; point to it please
  90.     calls    binwri    ,<r1,#1>    ; simple to put a single char
  91.     tst    (sp)+            ; pop the tiny buffer now
  92.     .twait    #twarea    ,#short        ; wait one tick
  93. 30$:    calls    xbinrea    ,<#-1>        ; now try for the echo please
  94.     tst    r0            ; get anything back?
  95.     bne    20$            ; no, continue sending
  96.     tst    tsxsav            ; running under TSX?
  97.     beq    40$            ; no
  98.     cmpb    r1    ,m.tsxr        ; /62/ ya, don't type
  99.     beq    30$            ; the lead-in char
  100. 40$:    mov    r1    ,r0        ; pass char to .ttyout
  101.     .ttyout                ; dump it to the terminal
  102.     br    30$            ; and see if another can be had
  103.  
  104. 50$:    mov    r0    ,r4        ; save a copy of the error
  105.     cmp    r0    ,#er$eof    ; end of file?
  106.     beq    60$            ; yes, that's ok
  107.     direrr    r0            ; no, print the error out and exit
  108. 60$:    tst    r2            ; input file still open?
  109.     beq    100$            ; no
  110.     .twait    #twarea    ,#fifteen    ; after EOF, wait 15. ticks
  111. 70$:    calls    xbinrea    ,<#-1>        ; now clean up echo at end
  112.     tst    r0            ; get anything back this time?
  113.     bne    90$            ; no, all done
  114.     tst    tsxsav            ; running under TSX?
  115.     beq    80$            ; no
  116.     cmpb    r1    ,m.tsxr        ; /62/ ya, don't type
  117.     beq    70$            ; the lead-in char
  118. 80$:    mov    r1    ,r0        ; pass char to .ttyout
  119.     .ttyout                ; dump it to the terminal
  120.     br    70$            ; see if another can be had
  121.  
  122. 90$:    calls    close    ,<#lun.in>    ; close the input file
  123. 100$:    cmp    r4    ,#er$eof    ; end of file today?
  124.     beq    130$            ; ya, reconnect with link open
  125.     tst    r3            ; should we put the terminal back?
  126.     beq    110$            ; no
  127.     call    clostt            ; close the link device
  128. 110$:    tst    r2            ; ever get file open?
  129.     beq    120$            ; no, so skip the newline
  130.     .newline            ; for prompt
  131. 120$:    clr    r0            ; /62/ error already handled..
  132.     return
  133.  
  134. 130$:    mov    #bell    ,r0        ; load a beep
  135.     .ttyout                ; ring the bell when done
  136.     mov    sp    ,conmsg        ; suppress CONNECT sign-on msg
  137.     jmp    c$conn            ; and connect automatically..
  138.  
  139. .endc    ;RT11                ; /E64/
  140.  
  141. .if df    RSTS                ; /E64/
  142.     .sbttl    TRANSMIT        ; /E64/ heavily hacked..
  143.  
  144. ;    Transfer  a  file  without  the  blessing  of  any
  145. ;    protocal to another system. What this  amounts  to
  146. ;    is  to  send  a  single  character from a file and
  147. ;    then wait for it's echo to show up.  Timeout  will
  148. ;    be  10  seconds.  It  is  presumed  the  the other
  149. ;    system is running some sort of  program  like  PIP
  150. ;    to  get  the  data. Line feeds will never be sent,
  151. ;    thus this  is  only  good  for  text  files.  This
  152. ;    option  will  hopefully  be  of some assistance in
  153. ;    getting initial bootstraps onto other systems.
  154. ;
  155. ;    Usage:
  156. ;
  157. ;    Use the  SET LINE, SET SPEED  and CONNECT commands
  158. ;    to  initiate the  receiving  program on  the other
  159. ;    system. Then 'escape' back to Kermit-11 and simply
  160. ;    type TRA filename.type.
  161. ;
  162. ;
  163. ;    T R A N S F (%loc filename )
  164. ;
  165. ;    Input:    @r5    addess of the .asciz filename to send
  166. ;    Output:    r0    any system or RMS11 error codes
  167.  
  168.     .sbttl    the real (and simple) work of transfer
  169.  
  170. ;    A simple brute force transfer of a file.
  171.  
  172.  
  173. c$tran::clr    r2            ; input_open := false
  174.     clr    r3            ; terminal_set := false
  175.     mov    #3    ,isecho        ; /47/ Countdown on read timeouts
  176.     tst    remote            ; if remote
  177.     beq    10$            ;  then ttname := ourname
  178.     calls    gttnam    ,<#ttname>    ; get the terminal name here
  179. 10$:    calls    ttyini    ,<#ter$xo>
  180.     tst    r0
  181.     bne    20$
  182.     calls    ttysav    ,<#ttname>    ; save terminal settings
  183.     calls    ttyset    ,<#ttname>    ; set some things now
  184.     tst    r0            ; terminal setup work out ?
  185.     bne    20$            ; no
  186.     mov    sp    ,r3        ; yes
  187.  
  188. 20$:    calls    open    ,<@r5,#lun.in,#text>
  189.     tst    r0            ; did the open work today?
  190.     bne    90$            ; no
  191.     mov    sp    ,r2        ; flag that the file is open
  192.     mov    #200    ,r4        ; start of things
  193.  
  194.  
  195. 30$:    tst    cccnt            ; /47/ Control C today?
  196.     bne    90$            ; /47/ Yes, exit please
  197.     calls    getc    ,<#lun.in>    ; get the next ch in the file
  198.     tst    r0            ; did that work ?
  199.     bne    90$            ; no
  200.     dec    r4            ; time for the remote to dump a block?
  201.     bne    40$            ; no
  202.     calls    suspend    ,<#1,#0>    ; yes, sleep for 1 second
  203.     call    cantyp            ; /47/ Dump pending typeahead
  204.     mov    #200    ,r4        ; and re-init the count
  205. 40$:    cmpb    r1    ,#lf        ; a line feed we don't need ?
  206.     bne    50$            ; no
  207.     calls    suspend    ,<#0,#6>    ; wait 1/10 sec please
  208.     calls    xbinrea    ,<#-1>        ; eat perhaps a line feed (no wait)
  209.     br    60$
  210. 50$:    mov    r1    ,-(sp)        ; yes, now send it to the other
  211.     mov    sp    ,r1        ; point to it please
  212.     calls    binwri    ,<r1,#1>    ; simple to put a single char.
  213.     tst    (sp)+            ; pop the tiny buffer now please.
  214.     tst    r0            ; did that work out ?
  215.     bne    90$            ; no
  216.     calls    xbinrea    ,<#2>        ; /47/ yes, try for the echo please
  217.     tst    r0            ; /47/ did we ever get anything back?
  218.     beq    55$            ; /47/ Yes, keep going
  219.     dec    isecho            ; /47/ Shoud we give up looking for
  220.     bne    60$            ; /47/ data being echoed?
  221. 55$:    mov    #3    ,isecho        ; /47/ Start the counter for echoing
  222. 60$:    br    30$            ; next please
  223.  
  224.  
  225. 90$:    cmp    r0    ,#ER$EOF    ; RMS end of file today ?
  226.     beq    100$            ; yes, that ok
  227.     direrr    r0            ; no, print the error out and exit
  228. 100$:    tst    r2            ; input file still open ?
  229.     beq    110$            ; no
  230.     calls    close    ,<#lun.in>
  231. 110$:    tst    r3            ; should we put the terminal back ?
  232.     beq    120$            ; no
  233.     calls    ttyfin
  234.     calls    ttyrst            ; yes
  235. 120$:    return
  236.  
  237. .endc    ;RSTS                ; /E64/
  238.  
  239.     .end
  240.