home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / pdp11 / k11ini.mac < prev    next >
Text File  |  2020-01-01  |  24KB  |  847 lines

  1.     .title    k11ini    initialization and rarely used routines
  2.     .ident    /3.42/
  3.  
  4.  
  5. ;    03-Jul-84  09:34:32  Brian Nelson
  6. ;
  7. ;    Copyright (C) 1984 Change Software, Inc.
  8. ;
  9. ;
  10. ;    Remove Kermit init code and routines like SPAR and RPAR that
  11. ;    are only called once per file transfer. Placed into  overlay
  12. ;    with K11ATR.  This was  done to reduce the  task size a bit.
  13. ;    Really, the only system the size is a problem is on RT11.
  14.  
  15.  
  16.  
  17.  
  18.  
  19.     .if ndf, K11INC
  20.     .ift
  21.     .include    /IN:K11MAC.MAC/
  22.     .endc
  23.  
  24.     .iif ndf, k11inc, .error    ; missing .INCLUDE for K11MAC.MAC
  25.     .enabl    gbl
  26.     .psect    $code
  27.  
  28.     .macro    $chkb    val    ,reg    ,?a
  29.     tstb    @reg
  30.     bne    a
  31.     movb    val    ,@reg
  32. a:    inc    reg
  33.     .endm    $chkb
  34.  
  35.  
  36.  
  37.  
  38.  
  39.     .sbttl    initialize ourselves
  40.  
  41.     .iif ndf, SOH, SOH = 1
  42.  
  43. kerini::call    init0
  44.     call    init1
  45.     return
  46.  
  47.  
  48. init0:    mov    #rwdata    ,r0        ; first of all, clear all read/write
  49.     mov    #rwsize/2,r1        ; data out please
  50. 10$:    clr    (r0)+            ; for i := 1 to rwdata_size
  51.     sob    r1    ,10$        ;  do data[i] := 0 ;
  52.     mov    sp    ,remote        ; /42/ (Moved) assume remote
  53.     mov    #1    ,blip        ; assume logging all packets to tty
  54.     clrb    defdir            ; /51/ Moved it
  55.     call    xinit            ; /42/ Moved call forward
  56.     mov    #15    ,recdlm        ; /56/ Assume CR
  57.     mov    #-1    ,setrpt        ; assume we will do repeat counts
  58.     mov    sp    ,doattr        ; default to sending attr packets
  59.     mov    do$lng    ,dolong        ; /42/ We want long packets if doable
  60.     mov    sp    ,doauto        ; default to cecking file attributes
  61.     mov    do$exi    ,exieof        ; /45/ Exit on end of mcr command line
  62.     call    rparini            ; default remotes sinit parameters
  63.     call    sparini            ; initialize my sinit parameters
  64.     mov    #60.    ,serwait    ; /41/ Support SET SERVER [NO]WAIT
  65.     mov    argbuf    ,argpnt        ;
  66.     mov    #SOH    ,recsop        ; assume control A please
  67.     mov    #SOH    ,sensop        ; assume control A please
  68.     mov    #mx$try    ,maxtry        ; initialize retry limit
  69.     mov    #defchk    ,chktyp        ; set the default checksum type
  70.     movb    #defchk    ,setsen+p.chkt    ; here also please
  71.     movb    #defchk    ,setrec+p.chkt    ; here also please
  72.     mov    #defdly    ,sendly        ; init the delay for send command
  73.     mov    #1    ,chksiz        ; and the default checksum size
  74.     mov    #par$no    ,parity        ; default the parity type please
  75.     copyz    #defprm    ,#prompt    ; set the prompt up
  76.     mov    sp    ,con8bit    ; assume 8 bits are ok for console
  77.     tst    vttype            ; did xinit set this up?
  78.     bne    20$            ; yes
  79.     mov    #tty    ,vttype        ; default to hardcopy console
  80. 20$:    tst    proflg            ; if pro/350 then vt100
  81.     beq    30$            ; not
  82.     mov    #vt100    ,vttype        ; yes
  83.     clr    con8bit            ; also say we want 7 bit data at connect
  84. 30$:    return                ; end
  85.  
  86.     .enabl    lc
  87.     .save
  88.     .psect    $PDATA    ,D
  89. defprm:    .asciz    /Kermit-11>/
  90.     .even
  91.     .restore
  92.  
  93.  
  94.     .enabl    lsb
  95.  
  96. init1::    nop                ; can always patch this with a 207
  97.     mov    #200$    ,r3        ; try to open an INIT file somewhere
  98. 10$:    tst    @r3            ; any more to open up ?
  99.     beq    100$            ; no
  100.     calls    open    ,<(r3)+,#lun.ta,#text>
  101.     tst    r0            ; did the open work ?
  102.     bne    10$            ; no, just ignore it
  103. 20$:    mov    #lun.ta    ,cmdlun        ; yes, setup for reading from INIT
  104.     mov    sp    ,sy.ini        ; a flag to use later
  105. 100$:    return
  106.  
  107.     .save
  108.     .psect    $pdata
  109.     .even
  110. 200$:    .word    210$,220$,230$,240$,0
  111. 210$:    .asciz    /SY:KERMIT.INI/
  112. 220$:    .asciz    /LB:[1,2]KERMIT.INI/
  113. 230$:    .asciz    /SY:[1,2]KERMIT.INI/
  114. 240$:    .asciz    /KERMIT:KERMIT.INI/
  115.     .even
  116.     .restore
  117.     .dsabl    lsb
  118.  
  119.     global    <xinit    ,cmdlun    ,lun.ta    ,defchk    ,defdly    ,chktyp    ,sendly>
  120.     global    <chksiz    ,sy.ini    ,parity    ,setrec    ,setsen    ,sendat    ,vttype>
  121.     global    <setrpt    ,con8bit,proflg    ,blip    ,sensop    ,recsop>
  122.     global    <argbuf,argpnt>
  123.  
  124.  
  125.     .sbttl    spar    fill will my send-init parameters
  126.  
  127.  
  128. ;    S P A R
  129. ;
  130. ;    spar( %loc data )
  131. ;
  132. ;    input:    @r5    address of array [0..9] of char
  133.  
  134. spar::    save    <r0,r1,r2>        ; save registers we may use
  135.     mov    #.sparsz,sparsz        ; copy the send init packet size
  136.     tst    doattr            ; attribute support disabled today?
  137.     bne    10$            ; no
  138.     tst    dolong            ; /42/ What about long packets
  139.     bne    10$            ; /42/ Yep
  140.     mov    #11    ,sparsz        ; No, shorten the packet up
  141. 10$:    mov    @r5    ,r2        ; point to the destiniation
  142.     mov    #senpar    ,r1        ; and our local parameters
  143.     clr    snd8bit            ; assume we don't need 8bit prefixing
  144.     movb    #'Y&137    ,p.qbin(r1)    ; assume 'if we must do it, ok' for 8bit
  145.     movb    conpar+p.qbin,r0    ; get senders 8bit quote character
  146.     cmpb    r0    ,#'N&137    ; can the other kermit ever do 8bit ?
  147.     bne    15$            ; no, don't bother setting the mode
  148.     clr    do8bit            ; don't ever try to do it
  149.     br    30$            ;
  150. 15$:    cmpb    r0    ,#'Y&137    ; has the other one required this mode?
  151.     bne    20$            ; yes, set the mode up then
  152.     cmpb    parity    ,#par$no    ; no, but do we need to do it?
  153.     beq    30$            ; no, don't waste the overhead
  154.     movb    #myqbin    ,r0        ; yes, force this to the other side
  155.     movb    r0    ,p.qbin(r1)    ; tell the other kermit we HAVE to do it
  156. 20$:    mov    sp    ,snd8bit    ; flag we need it for sending a file
  157.     mov    sp    ,do8bit        ; force 8bit prefixing then
  158.     movb    r0    ,ebquot        ; and set ours to the same please
  159.     movb    r0    ,p.qbin(r1)    ; /29/ fix this please
  160. 30$:    tochar    (r1)+    ,(r2)+        ; senpar.spsiz
  161.     tochar    (r1)+    ,(r2)+        ; senpar.time
  162.     tochar    (r1)+    ,(r2)+        ; senpar.npad
  163.     ctl    (r1)+    ,(r2)+        ; senpar.padc
  164.     tochar    (r1)+    ,(r2)+        ; senpar.eol
  165.     movb    (r1)+    ,(r2)+        ; senpar.qctl
  166.     movb    (r1)+    ,(r2)+        ; senpar.qbin
  167.     movb    (r1)+    ,(r2)+        ; senpar.chkt
  168.     movb    (r1)+    ,(r2)+        ; senpar.rept
  169.     bicb    #CAPA.L    ,@r1        ; /42/ Assume NO long packet support
  170.     tst    dolong            ; /42/ Do long packet crap?
  171.     beq    35$            ; /42/ No
  172.     bisb    #CAPA.L    ,@r1        ; /42/ Yes, insert it NOW
  173. 35$:    bisb    #CAPA.A    ,@r1        ; /42/ Assume attribute support
  174.     tst    doattr            ; /42/ Really do it ?
  175.     bne    40$            ; /42/ Yes
  176.     bicb    #CAPA.A    ,@r1        ; /42/ No, disable it now
  177. 40$:    tochar    (r1)+    ,(r2)+        ; senpar.capas
  178.     tochar    (r1)+    ,(r2)+        ; /42/ senpar.capas+1 (window size)
  179.     tochar    (r1)+    ,(r2)+        ; /42/ senpar.capas+2 (maxlen2)
  180.     tochar    (r1)+    ,(r2)+        ; /42/ senpar.capas+3 (maxlen1)    
  181.     clrb    (r2)+            ; end
  182.     unsave    <r2,r1,r0>
  183.     return
  184.  
  185.  
  186. fixchk::tstb    setsen+p.chkt        ; did the user ever set block-check?
  187.     beq    100$            ; no
  188.     cmpb    setsen+p.chkt,#'1    ; insure that it's legit
  189.     blo    100$
  190.     cmpb    setsen+p.chkt,#'3    ; insure that it's legit
  191.     bhi    100$
  192.     movb    setsen+p.chkt,senpar+p.chkt
  193. 100$:    return
  194.  
  195.     .sparsz    ==    15        ; /42/ 13 parameters to send over
  196.  
  197. sparin::save    <r1,r2,r3>        ; save registers we may use
  198.     mov    #.sparsz,sparsz        ; copy the send init packet size
  199.     tst    doattr            ; attribute support disabled today?
  200.     bne    10$            ; no
  201.     tst    dolong            ; /42/ Doing long packets ?
  202.     bne    10$            ; /42/ Yes
  203.     mov    #11    ,sparsz        ; No, shorten the packet up
  204. 10$:    mov    #senpar    ,r1        ; where to put them
  205.     movb    #maxpak    ,(r1)+        ; maximum packet size
  206.     movb    #mytime    ,(r1)+        ; my desired timeout
  207.     movb    #mypad    ,(r1)+        ; how much padding
  208.     movb    #mypchar,(r1)+        ; whatever i use for padding
  209.     movb    #myeol    ,(r1)+        ; line terminators (don't need it)
  210.     movb    #myquote,(r1)+        ; quoting ?
  211.     movb    #'Y&137    ,(r1)+        ; do quoting ?
  212.     movb    #mychkt    ,@r1        ; /42/ checksum type
  213. ;-    tst    dolong            ; /42/ Want to do long packet?
  214. 15$:    inc    r1
  215.     movb    #40    ,@r1        ; assume no repeat processing
  216.     tst    setrpt            ; really say we do repeat crap?
  217.     beq    20$            ; no
  218.     movb    #myrept    ,@r1        ; default on the rest of it
  219. 20$:    inc    r1            ; fix the pointer please
  220.     movb    #mycapa    ,@r1        ; we can read attributes
  221.     tst    doattr            ; /42/ No attrs but do long packets?
  222.     bne    30$            ; /42/ Leave attribute support in
  223.     bicb    #CAPA.A    ,@r1        ; /42/ Remove attribute support
  224. 30$:    tst    dolong            ; /42/ Long packet support desired?
  225.     bne    40$            ; /42/ Yes, leave the bit alone
  226.     bicb    #CAPA.L    ,@r1        ; /42/ No, remove support bit
  227. 40$:    bicb    #1    ,@r1        ; /42/ Insure no more capas bytes
  228.     inc    r1            ; /42/ Next please
  229.     clrb    (r1)+            ; /42/ No window size to send over
  230.     mov    #maxpak    ,r3        ; /42/ Setup to break the size into
  231.     clr    r2            ; /42/ two bytes
  232.     div    #95.    ,r2        ; /42/ Done
  233.     movb    r2    ,(r1)+        ; /42/ maxl1 = buffersize / 95
  234.     movb    r3    ,(r1)+        ; /42/ maxl2 = buffersize mod 95
  235.     clrb    (r1)+            ; default on the rest of it
  236.     clrb    (r1)+            ; default on the rest of it
  237.     movb    #'&    ,ebquot
  238.     unsave    <r3,r2,r1>
  239.     return
  240.  
  241.     global    <setrec    ,senpar    ,setsen    ,sparsz>
  242.     global    <reclng    ,senlng    ,dolong    ,doattr    ,doslid> ; /42/
  243.     global    <senwin    ,recwin    ,inqbuf>             ; /42/
  244.  
  245.  
  246.  
  247.     .sbttl    rpar    read senders initialization parameters
  248.  
  249. ;    R P A R
  250. ;
  251. ;    rpar( %loc msgpacket, %val size )
  252. ;
  253. ;    input:    @r5    message packet to get data from
  254. ;        2(r5)    packet length
  255. ;    output:    REMPAR[0..20] of parameters
  256.  
  257. rpar::    save    <r0,r1,r2,r3,r4>    ; save registers we may use
  258.     clr    r3            ; /42/ Sending long packet buffersize
  259.     mov    @r5    ,r1        ; incoming packet address
  260.     mov    2(r5)    ,r0        ; size
  261.     mov    #conpar    ,r2        ; address of remotes parameters
  262.     movb    #'N    ,p.qbin(r2)    ; /58/ Worst case on 8bit quoting
  263.     unchar    (r1)+    ,(r2)+        ; conpar.spsiz
  264.     dec    r0            ; exit if no more data
  265.     beq    4$            ; all done
  266.     unchar    (r1)+    ,(r2)+        ; conpar.time
  267.     dec    r0            ; exit if no more data
  268.     beq    4$            ; all done
  269.     unchar    (r1)+    ,(r2)+        ; conpar.npad
  270.     dec    r0            ; exit if no more data
  271.     beq    4$            ; all done
  272.     ctl    (r1)+    ,(r2)+        ; conpar.padc
  273.     dec    r0            ; exit if no more data
  274.     beq    4$            ; all done
  275.     unchar    (r1)+    ,(r2)+        ; conpar.eol
  276.     dec    r0            ; exit if no more data
  277.     beq    4$            ; all done
  278.     movb    (r1)+    ,(r2)+        ; conpar.qctl
  279.     dec    r0            ; exit if no more data
  280.     beq    4$            ; all done
  281.     movb    (r1)+    ,(r2)+        ; conpar.qbin
  282.     dec    r0            ; exit if no more data
  283.     beq    4$            ; all done
  284.     movb    (r1)+    ,(r2)+        ; conpar.chkt
  285.     dec    r0            ; exit if no more data
  286.     beq    4$            ; all done
  287.     movb    (r1)+    ,(r2)+        ; conpar.rept
  288. 1$:    dec    r0            ; exit if no more data
  289.     beq    4$            ; all done
  290.     unchar    (r1)+    ,@r2        ; conpar.capas
  291.     bitb    #1    ,(r2)+        ; /42/ More CAPAS to go ?
  292.     bne    1$            ; /42/ Yes, keep getting them
  293.     dec    r0            ; /42/ Look for the Window size
  294.     beq    4$            ; /42/ Not present
  295.     unchar    (r1)+    ,senwin        ; /42/ Present, save it away please
  296.     dec    r0            ; /42/ Look for long packet size
  297.     beq    4$            ; /42/ Anything ?
  298.     unchar    (r1)+    ,r3        ; /42/ Yes, get it please
  299.     bicb    #200    ,r3        ; /42/ Insure high bit off
  300.     mul    #95.    ,r3        ; /42/ and save it
  301.     dec    r0            ; /42/ Get the next part please
  302.     beq    4$            ; /42/ Nothing is left
  303.     unchar    (r1)+    ,r4        ; /42/ Last entry, low order of size
  304.     bicb    #200    ,r4        ; /42/ Insure high bit off
  305.     add    r4    ,r3        ; /42/ Add into senders buffersize
  306.  
  307. 4$:    clrb    (r2)+
  308.     mov    #conpar    ,r2        ; now clear parity off please in
  309.     mov    #15    ,r0        ; case an IBM system set it.
  310. 5$:    bicb    #200    ,(r2)+        ; simple
  311.     sob    r0    ,5$        ; next please
  312.     call    rparck            ; /37/ insure parameters are OK
  313.     mov    #setsen    ,r0        ; /43/ check to see if we need to
  314.     mov    #conpar    ,r1        ; override any of the sinit stuff
  315.     movb    p.padc(r0),r2        ; /57/ Check for SET SEND PADC
  316.     beq    6$            ; /57/ Never set
  317.     movb    r2    ,p.padc(r1)    ; /57/ Set, use it
  318. 6$:    movb    p.npad(r0),r2        ; /57/ Check for SET SEND PADC
  319.     beq    7$            ; /57/ Never set
  320.     movb    r2    ,p.npad(r1)    ; /57/ Set, use it
  321. 7$:    movb    p.spsiz(r0),r2        ; if user set packetsize
  322.     beq    10$            ;  then
  323.     movb    r2    ,p.spsiz(r1)    ;   conpar.size := setrec.size
  324. 10$:    movb    p.eol(r0),r2        ; if user set endofline
  325.     beq    20$            ;  then
  326.     movb    r2    ,p.eol(r1)    ;   conpar.eol := setrec.eol
  327. 20$:    movb    p.time(r0),r2        ; if user set timeout
  328.     beq    30$            ;  then
  329.     movb    r2    ,p.time(r1)    ;   conpar.time := setrec.time
  330. 30$:    tstb    p.chkt(r1)        ; if checksum_type = null
  331.     bne    40$            ;  then
  332.     movb    #defchk    ,p.chkt(r1)    ;   checksum_type := default
  333. 40$:    movb    p.chkt(r1),senpar+p.chkt; setup for type of checksum used
  334.  
  335.     mov    snd8bit    ,do8bit        ; in case SPAR decided WE need 8bit
  336.     clr    snd8bit            ; prefixing to send a file over.
  337.     cmpb    p.qbin(r1),#'Y&137    ; was this a simple 'YES' ?
  338.     bne    50$            ; no
  339.     movb    #myqbin    ,ebquot        ; yes, change it to the default '&'
  340.     br    70$            ; and exit
  341. 50$:    cmpb    p.qbin(r1),#'N&137    ; eight bit quoting support present
  342.     bne    60$            ; yes
  343.     clr    do8bit            ; no
  344.     br    70$
  345. 60$:    mov    sp    ,do8bit        ; flag for doing 8 bit prefixing then
  346.     movb    p.qbin(r1),ebquot    ; and set the quote character please
  347. 70$:    clr    senlng            ; /42/ Clear the write long buffer size
  348.     tst    dolong            ; /42/ Really want long packets today?
  349.     bne    75$            ; /42/ Yes
  350.     bicb    #CAPA.L    ,p.capas(r1)    ; /42/ No, so turn it off please
  351. 75$:    bitb    #CAPA.L    ,p.capas(r1)    ; /42/ Can the sender do long packets?
  352.     beq    90$            ; /42/ No
  353.     mov    r3    ,senlng        ; /42/ Yes, stuff the max buffersize
  354.     bne    80$            ; /42/ Something is there
  355. ..DEFL    ==    . + 2            ; /52/ Default
  356.     mov    #90.    ,senlng        ; /42/ Nothing, assume 90 (10) chars
  357. 80$:    cmp    senlng    ,#MAXLNG    ; /42/ Is this size bigger than buffer?
  358.     ble    100$            ; /42/ No
  359.     mov    #MAXLNG    ,senlng        ; /42/ Yes, please fix it then
  360.     br    100$            ; /43/ And exit
  361. 90$:    tst    reclng            ; /43/ Ever do a SET REC PAC > 94 ?
  362.     beq    100$            ; /43/ No
  363.     tst    infomsg            ; /43/ Really dump this message?
  364.     beq    100$            ; /43/ No
  365.     tst    msgtim            ; /43/ Please, NOT for EVERY file
  366.     bne    100$            ; /43/ Not again
  367.     mov    sp    ,msgtim        ; /43/ Flag we printed a warning
  368.     calls    printm    ,<#1,#lmsg>    ; /43/ Yes, print a warning message
  369. 100$:    unsave    <r4,r3,r2,r1,r0>
  370.     return
  371.  
  372.  
  373.     .save
  374.     .psect    $PDATA    ,D
  375. lmsg:    .ascii    /%Warning - You have requested LONG packet support/<CR><LF>
  376.     .asciz    /but the other Kermit does not support this feature./<CR><LF>
  377.     .even
  378.     .restore
  379.  
  380.  
  381.  
  382.     .sbttl    setup defaults for senders parameters and also check them
  383.  
  384. rparin::save    <r1,r2>            ; save registers we may use
  385.     mov    #conpar    ,r1        ; where to put them
  386.     movb    #maxpak    ,(r1)+        ; maximum packet size
  387.     movb    #mytime    ,(r1)+        ; my desired timeout
  388.     movb    #mypad    ,(r1)+        ; how much padding
  389.     movb    #mypchar,(r1)+        ; whatever i use for padding
  390.     movb    #myeol    ,(r1)+        ; line terminators (don't need it)
  391.     movb    #myquote,(r1)+        ; quoting ?
  392.     movb    #'Y&137    ,(r1)+        ; do quoting ?
  393.     movb    #mychkt    ,(r1)+        ; checksum type
  394.     movb    #40    ,(r1)+        ; assume no repeat count processing
  395.     clrb    (r1)+            ; default on the rest of it
  396.     clrb    (r1)+            ; default on the rest of it
  397.     clrb    (r1)+            ; default on the rest of it
  398.     clrb    (r1)+            ; default on the rest of it
  399.     clrb    (r1)+            ; default on the rest of it
  400.     mov    #setsen    ,r0        ; /57/ check to see if we need to
  401.     mov    #conpar    ,r1        ; /57/ override any of the sinit stuff
  402.     movb    p.padc(r0),r2        ; /57/ Check for SET SEND PADC
  403.     beq    10$            ; /57/ Never set
  404.     movb    r2    ,p.padc(r1)    ; /57/ Set, use it
  405. 10$:    movb    p.npad(r0),r2        ; /57/ Check for SET SEND PADC
  406.     beq    20$            ; /57/ Never set
  407.     movb    r2    ,p.npad(r1)    ; /57/ Set, use it
  408. 20$:    movb    p.eol(r0),r2        ; /57/ if user set endofline
  409.     beq    30$            ; /57/  then
  410.     movb    r2    ,p.eol(r1)    ; /57/   conpar.eol := setrec.eol
  411. 30$:    unsave    <r2,r1>
  412.     return
  413.  
  414. rparck:    mov    #conpar    ,r0        ; /37/ address of senders parameters
  415.     $chkb    #maxpak    ,r0        ; /37/ Be defensive about the senders
  416.     $chkb    #mytime    ,r0        ; /37/ parameters please
  417.     $chkb    #mypad    ,r0
  418.     $chkb    #mypchar,r0
  419.     $chkb    #myeol    ,r0
  420.     $chkb    #myquote,r0
  421.     $chkb    #'Y    ,r0
  422.     $chkb    #mychkt    ,r0
  423.     $chkb    #40    ,r0
  424.     return                ; /37/ exit to RPAR
  425.  
  426.  
  427.     global    <conpar    ,do8bit    ,setrec    ,ebquot>
  428.  
  429.  
  430.  
  431.  
  432.     .sbttl    fillog    log file opens/close to disk
  433.  
  434. ;    F I L L O G
  435. ;
  436. ;    input:    @r5    0    for open for read
  437. ;            1    for open for write
  438. ;        2(r5)    filename
  439.  
  440.     .enabl    lsb
  441.  
  442. fillog::save    <r0,r1>
  443.     bit    #log$fi    ,trace        ; logging file activity to disk ?
  444.     beq    100$            ; no
  445.     calls    putc    ,<#cr,#lun.lo>    ; insure buffers are flushed
  446.     mov    #200$    ,r1        ; assume a header of 'writing'
  447.     tst    @r5            ; perhaps writing ?
  448.     beq    10$            ; no
  449.     mov    #210$    ,r1        ; yes
  450. 10$:    movb    (r1)+    ,r0        ; copy the byte over
  451.     beq    20$            ; all done
  452.     calls    putc    ,<r0,#lun.lo>    ; next byte pleae
  453.     br    10$            ; next
  454. 20$:    mov    2(r5)    ,r1        ; now for the filename
  455. 30$:    movb    (r1)+    ,r0        ; copy the byte over
  456.     beq    40$            ; all done
  457.     calls    putc    ,<r0,#lun.lo>    ; next byte pleae
  458.     br    30$            ; next
  459. 40$:    calls    putc    ,<#cr,#lun.lo>    ; dump the record
  460. 100$:    unsave    <r1,r0>            ; and exit
  461.     return
  462.  
  463.  
  464.     .save
  465.     .psect    $PDATA    ,D
  466. 200$:    .asciz    /Receiving file /
  467. 210$:    .asciz    /Sending   file /
  468.     .even
  469.     .restore
  470.     .dsabl    lsb
  471.  
  472.  
  473.  
  474.  
  475.     .sbttl    debug dump to disk
  476.  
  477. ;    D S K D M P
  478. ;
  479. ;    input:    @r5    name ('rpack' or 'spack')
  480. ;        2(r5)    packet length
  481. ;        4(r5)    packet type
  482. ;        6(r5)    packet number
  483. ;        10(r5)    packet address
  484.  
  485.     .enabl    lsb
  486.  
  487. dskdmp::save                ; /42/ Save R0-R5
  488.     sub    #120    ,sp        ; allocate a formatting buffer
  489.     mov    sp    ,r1        ; point to it
  490.     mov    #120    ,r0        ; and clear it out
  491. 10$:    movb    #40    ,(r1)+        ; simple
  492.     sob    r0    ,10$
  493.     mov    sp    ,r1        ; point back to the buffer
  494.     mov    (r5)+    ,r0        ; point to the routine name
  495.     call    200$            ; and copy it
  496.     mov    #110$    ,r0        ; and a label ('LEN')
  497.     call    200$            ; copy it
  498.     mov    (r5)+    ,r2        ; get the length saved
  499.     deccvt    r2,r1,#3        ; convert the length to decimal
  500.     add    #6    ,r1        ; and skip over it
  501.     mov    #120$    ,r0        ; another label ('TYP')
  502.     call    200$            ; simple
  503.     movb    (r5)+    ,(r1)+        ; get the packet type
  504.     movb    #40    ,(r1)+        ; and some spaces
  505.     cmpb    @r1    ,#badchk    ; checksum error ?
  506.     bne    20$            ; no
  507.     movb    #'*    ,-1(r1)        ; yes, flag it please
  508. 20$:    inc    r5            ; point to the next arguement
  509.     movb    #40    ,(r1)+        ; and some spaces
  510.     movb    #40    ,(r1)+        ; and some spaces
  511.     movb    #40    ,(r1)+        ; and some spaces
  512.     mov    #130$    ,r0        ; and a label ('PAK')
  513.     call    200$            ; copy it
  514.     mov    (r5)+    ,r0
  515.     deccvt    r0,r1,#3        ; and convert to decimal
  516.     add    #4    ,r1        ; now point to the end
  517.     clrb    @r1            ; make it .asciz
  518.     mov    sp    ,r1        ; point back to the start
  519.     calls    putrec    ,<r1,#70.,#lun.lo> ; and put out to disk now
  520.     mov    @r5    ,r3        ; /42/ May have very large packets
  521.     mov    r2    ,r4        ; /42/ Save the length please
  522. 30$:    mov    r4    ,r0        ; /42/ Assume a reasonable size
  523.     bmi    50$            ; /42/ Anything left over to do?
  524.     cmp    r0    ,#72.        ; /42/ Will the leftovers fit?
  525.     ble    40$            ; /42/ Yes
  526.     mov    #72.    ,r0        ; /42/ No
  527. 40$:    calls    putrec    ,<r3,r0,#LUN.LO>; /42/ Dump a (partial) bufferfull
  528.     add    #72.    ,r3        ; /42/ Move up to next partial
  529.     sub    #72.    ,r4        ; /42/ And try again
  530.     br    30$            ; /42/ Next please
  531. 50$:    tst    debug            ; should we also dump to ti:?
  532.     beq    100$            ; no
  533.     .print    r1            ; yes, dump the length and type
  534.     .newli                ; and a carrriage return
  535.     tst    r2            ; anything in the packet?
  536.     beq    100$            ; no
  537.     .print    @r5    ,r2        ; yes, dump it
  538.     .newlin                ; and do a <cr><lf>
  539. 100$:    add    #120    ,sp        ; pop the local buffer and exit
  540.     unsave                ; /42/ Unsave R5-R0
  541.     return                ; bye
  542.  
  543.  
  544.     .save
  545.     .psect    $PDATA    ,D
  546. 110$:    .asciz    /Length/
  547. 120$:    .asciz    /Type/
  548. 130$:    .asciz    /Paknum/
  549.     .even
  550.     .restore
  551.  
  552.  
  553. 200$:    movb    (r0)+    ,(r1)+        ; copy .asciz string to buffer
  554.     bne    200$            ; done yet ?
  555.     dec    r1            ; yes, back up and overwrite the
  556.     movb    #40    ,(r1)+        ; null with a space
  557.     movb    #40    ,(r1)+        ; one more space for formatting
  558.     return                ; bye
  559.  
  560.     .dsabl    lsb
  561.  
  562.  
  563.     .sbttl    do some logging to TI: ?
  564.  
  565.  
  566. senhdr::save    <r1>            ; /43/
  567.     mov    #-1    ,pcnt.n+2
  568.     clr    pcnt.n+0        ; /43/ Clear high order bits
  569.     mov    #-1    ,pcnt.t+2    ; /44/ Clear timeout stuff
  570.     clr    pcnt.t+0        ; /44/ Clear timeout stuff
  571.     call    dovt
  572.     bcs    100$
  573.     print    #$sendh
  574.     mov    sp    ,logini
  575. 100$:    unsave    <r1>            ; /43/
  576.     return
  577.  
  578. rechdr::save    <r1>            ; /43/
  579.     mov    #-1    ,pcnt.n+2
  580.     clr    pcnt.n+0        ; /43/ Clear high order bits
  581.     mov    #-1    ,pcnt.t+2    ; /44/ Clear timeout stuff
  582.     clr    pcnt.t+0        ; /44/ Clear timeout stuff
  583.     call    dovt            ; vt100 vttype type?
  584.     bcs    100$            ; no, forget it
  585.     print    #$rech            ; initial header please
  586.     mov    sp    ,logini        ; save we did it already
  587. 100$:    unsave    <r1>            ; /43/
  588.     return                ; bye
  589.  
  590.  
  591. reclog::save    <r1>
  592.     call    dolog
  593.     bcs    100$
  594.     mov    pcnt.r+2,r1        ; check for modulo on screen updates
  595.     clr    r0            ; setup for the divide
  596.     div    blip    ,r0        ; do it
  597.     tst    r1            ; any remainder left over
  598.     bne    100$            ; yes, simply exit
  599.     mov    vttype    ,r0        ; no, dispatch to the correct routine
  600.     asl    r0
  601.     jsr    pc    ,@recdsp(r0)
  602. 100$:    unsave    <r1>
  603.     return
  604.  
  605.  
  606. rectty:    mov    #pcnt.r    ,r1        ; /43/ Pass address in r1
  607.     call    numout
  608.     print    #$delim
  609.     mov    #pcnt.s+<4*<<'N&137>-100>>,r1 ; /43/ 32 bits this time
  610.     cmp    2(r1)    ,pcnt.n+2    ; /43/ unlikely that the nak
  611.     beq    100$            ; /43/ count would ever be > 32767
  612.     mov    2(r1)    ,pcnt.n+2    ; /43/ Use low order 16 bites
  613.     call    numout
  614. 100$:    print    #$leftm
  615.     return
  616.  
  617. recvt1:    call    dovt            ; vt100 type?
  618.     bcs    100$            ; no
  619.     tst    logini            ; need the header?
  620.     bne    10$            ; no
  621.     call    rechdr            ; yes
  622. 10$:    print    #$pos1            ; position the cursor    
  623.     mov    #pcnt.r    ,r1        ; received packet count /43/
  624.     call    numout            ; dump it
  625.     mov    #pcnt.s+<4*<<'N&137>-100>>,r1 ; get the sent NAK count /43/
  626.     cmp    2(r1)    ,pcnt.n+2    ; /43/ Really need to update naks?
  627.     beq    90$            ; no
  628.     mov    2(r1)    ,pcnt.n+2    ; /43/ Stuff low order 16 bits
  629.     call    nakpos
  630.     call    numout            ; print the NAK count
  631. 90$:    call    dotmo            ; /44/ DO timeouts
  632.     print    #$leftm
  633. 100$:    return
  634.     
  635.  
  636.  
  637.  
  638. ;    for sending files, log transactions here
  639.  
  640. senlog::save    <r1>
  641.     call    dolog
  642.     bcs    100$
  643.     mov    pcnt.s+2,r1        ; check for modulo on screen updates
  644.     clr    r0            ; setup for the divide
  645.     div    blip    ,r0        ; do it
  646.     tst    r1            ; any remainder left over
  647.     bne    100$            ; yes, simply exit
  648.     mov    vttype    ,r0
  649.     asl    r0
  650.     jsr    pc    ,@sendsp(r0)
  651. 100$:    unsave    <r1>
  652.     return
  653.  
  654.  
  655. sentty:    mov    #pcnt.s    ,r1        ; /43/ 32 bits now
  656.     call    numout
  657.     print    #$delim
  658.     mov    #pcnt.r+<4*<<'N&137>-100>>,r1 ; get the sent NAK count
  659.     cmp    2(r1)    ,pcnt.n+2
  660.     beq    100$
  661.     mov    2(r1)    ,pcnt.n+2
  662.     call    numout
  663. 100$:    print    #$leftm
  664.     return
  665.  
  666. senvt1:    tst    logini            ; need the header?
  667.     bne    10$            ; no
  668.     call    senhdr            ; yes
  669. 10$:    print    #$pos1            ; position the cursor
  670.     mov    #pcnt.s    ,r1        ; /43/ 32 bits now
  671.     call    numout
  672.     mov    #pcnt.r+<4*<<'N&137>-100>>,r1 ; get the sent NAK count
  673.     cmp    2(r1)    ,pcnt.n+2
  674.     beq    90$
  675.     mov    2(r1)    ,pcnt.n+2
  676.     call    nakpos
  677.     call    numout
  678. 90$:    call    dotmo            ; /44/ Timeouts
  679.     print    #$leftm
  680. 100$:    return
  681.  
  682.  
  683.     .sbttl    data for packet transfer logging
  684.  
  685.  
  686.     .save
  687.     .psect    $vtdat    ,ro,d,lcl,rel,con
  688. $sendh:    .byte    33,'<
  689.     .ascii    <cr><33>/[2KPackets sent     :            Naks: /
  690.     .asciz    /            Timeouts: /
  691. $rech:    .byte    33,'<
  692.     .ascii    <cr><33>/[2KPackets received :            Naks: /
  693.     .asciz    /            Timeouts: /
  694. $pos1:    .asciz    <cr><33>/[20C/        ; goto column 20
  695. $pos2:    .asciz    <33>/[14C/        ; move over 14 please
  696. $leftm:    .byte    cr,0            ; goto left margin please
  697. $delim:    .asciz    #/#
  698.     .even
  699.  
  700. sendsp:    .word    sentty    ,senvt1    ,senvt1    ,senvt1    ,senvt1    ,senvt1    ,senvt1
  701. recdsp:    .word    rectty    ,recvt1    ,senvt1    ,senvt1    ,senvt1    ,senvt1    ,senvt1
  702.     .assume    tty    eq    0
  703.     .assume    vt100    eq    1
  704.     .restore
  705.     
  706. numout:    save    <r0,r1,r2>        ; /43/ Use $CDDMG from SYSLIB
  707.     sub    #20    ,sp        ; /43/ Allocate a buffer please
  708.     mov    sp    ,r0        ; /43/ Point to buffer for $CDDMG
  709.     clr    r2            ; /43/ We want leading zero and spaces
  710.     call    $cddmg            ; /43/ out please
  711.     clrb    @r0            ; /43/ Make into .asciz
  712.     mov    sp    ,r0        ; /43/ Reset pointer
  713.     print    r0            ; /43/ Dump the string and exit
  714.     add    #20    ,sp        ; /43/ Pop buffer
  715.     unsave    <r2,r1,r0>        ; /43/ Pop registers and exit
  716.     return                ; /43/ Exit
  717.  
  718.     global    <$cddmg>        ; /43/ From syslib.olb
  719.  
  720.  
  721.  
  722.     .sbttl    decide what to do about logging
  723.     .enabl    lsb
  724.  
  725.  
  726. dovt:    cmpb    vttype,#vt100        ; a vt100 today?
  727.     blo    90$            ; /39/ no, but allow vt220 type
  728. dolog:    tst    blip            ;
  729.     beq    90$            ; do not do this at all
  730.     tst    infomsg            ; /51/ Don't do if SET QUIET
  731.     beq    90$            ; /51/ 
  732.     tst    remote            ; a server?
  733.     bne    90$            ; could be
  734.     tst    xmode            ; text reply?
  735.     bne    90$            ; yes
  736.     br    100$            ; debug is ok then
  737. 90$:    sec
  738.     return
  739. 100$:    clc
  740.     return
  741.  
  742.     global    <blip>
  743.  
  744.     .dsabl    lsb
  745.  
  746.  
  747. nakpos:    print    #npos
  748.     return
  749.  
  750.     .save
  751.     .psect    $PDATA    ,D
  752. npos:    .asciz    <cr><33>/[38C/        ; goto column 38
  753. dpos:    .asciz    <cr><33>/[59C/        ; /44/ For timeout count
  754.     .even
  755.     .restore
  756.  
  757.  
  758. dotmo:    mov    #pcnt.r+<4*<<'T&137>-100>>,r1 ; /44/ Get timeout count
  759.     cmp    2(r1)    ,pcnt.t+2    ; /44/ Timeout count has changed?
  760.     beq    100$            ; /44/ No, just exit
  761.     mov    2(r1)    ,pcnt.t+2    ; /44/ Yes, update counter
  762.     print    #dpos            ; /44/ Position cursor
  763.     call    numout            ; /44/ Dump please
  764. 100$:    return
  765.  
  766.  
  767.  
  768.     global    <pcnt.n    ,pcnt.r    ,pcnt.s    ,remote    ,xmode    ,vttype>
  769.     global    <pcnt.t>
  770.  
  771.  
  772.  
  773.     .sbttl    Control A packet stats 09-Dec-86  07:46:02
  774.     .enabl    lsb
  775.  
  776.  
  777. ;     This is simliar to the vms kermit's Control A status  line,
  778. ;    which  is  just like that used in FTP. The useful way to use
  779. ;    this is to, in the KERMIT.INI file, add  a  line  to  modify
  780. ;    the  packet  count  interval:  to turn it off, SET UPDATE 0,
  781. ;    otherwise its MOD value. Typing control  A  will  print  the
  782. ;    char count stat. 
  783.  
  784. cs$in::    mov    #210$    ,r0        ; /56/ Save please
  785.     mov    #filein    ,r1        ; /56/ Address of data to print
  786.     br    10$            ; /56/ Common code now
  787.                     ; /56/
  788. cs$out::mov    #200$    ,r0        ; /56/ Save please
  789.     mov    #fileout,r1        ; /56/ Address of data to print
  790. 10$:    Message    <[>            ; /56/ Header for line
  791.     call    numout            ; /56/ Dump the character count
  792.     Print    r0            ; /56/ Formatting
  793.     Print    #filnam            ; /56/ The name of the file
  794.     Message    <]>,CR            ; /56/ All done
  795.     clr    logini            ; /56/ Needed if packet counting
  796.     return                ; /56/ Exit
  797.  
  798.     .Save                ; /56/ Save current Psect
  799.     .Psect    $Pdata    ,d        ; /56/ Switch to data psect
  800. 200$:    .asciz    <33>/[K Characters sent for /    
  801. 210$:    .asciz    <33>/[K Characters received for /
  802.     .even                ; /56/ Insure word alignment
  803.     .Restore            ; /56/ Pop old psect
  804.     .Dsabl    lsb            ; /56/ All done
  805.  
  806.     Global    <filein,fileout,filnam>    ; /56/
  807.  
  808.  
  809.  
  810.     .sbttl    32 bit conversion from rsx syslib
  811.  
  812.  
  813.     .GLOBL    $CBTA        ;Global reference
  814.     .GLOBL    $SAVRG        ;Global reference
  815.     .GLOBL    $CDDMG
  816. $CDDMG:    JSR    R5,$SAVRG
  817.     MOV    R0,R3
  818.     MOV    #23420,R4
  819.     MOV    #12,R5
  820.     TST    R2
  821.     BEQ    C00024
  822. C00022:    BIS    #1000,R5
  823. C00024=    C00022+2
  824.     CMP    (R1),R4
  825.     BCC    C00104
  826.     MOV    (R1)+,R0
  827.     MOV    (R1),R1
  828.     DIV    R4,R0
  829.     MOV    R1,-(SP)
  830.     MOV    R0,R1
  831.     BEQ    C00064
  832.     MOV    #24000,R2
  833.     CALL    C00072
  834.     BIS    #1000,R5
  835.     MOV    R0,R3
  836. C00064:    MOV    (SP)+,R1
  837.     MOV    #20000,R2
  838. C00072:    MOV    R3,R0
  839.     BIS    R5,R2
  840.     CALL    $CBTA
  841.     BR    C00116
  842. C00104:    MOV    #5,R2
  843. C00110:    MOVB    #52,(R0)+
  844.     SOB    R2,C00110
  845. C00116:    RETURN
  846.     .end
  847.