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

  1.     .title    K1180S    Server things unique to the exec we are using
  2.     .ident    /2.0.06/
  3.     .include    /SY:[1,2]COMMON.MAC/
  4.  
  5.  
  6.     .if ndf, K11INC
  7.     .ift
  8.     .include    /IN:K11MAC.MAC/
  9.     .endc
  10.  
  11.     .iif ndf, xrb    , .error ; INCULDE for [1,2]COMMON.MAC failed
  12.     .iif ndf, k11inc, .error ; INCLUDE for IN:K11MAC.MAC failed
  13.     .title    K1180S
  14.  
  15.     .psect    $code
  16.     .enabl    lc
  17.     .enabl    gbl
  18.  
  19.     .macro    clrfqb
  20.     call    $clrfq
  21.     .endm    clrfqb
  22.  
  23.     .macro    clrxrb
  24.     call    $clrxr
  25.     .endm    clrxrb
  26.  
  27.  
  28.  
  29. ;    do a SYSTAT (also host commands)
  30. ;
  31. ;    01-Feb-84  11:11:34  Brian Nelson
  32. ;
  33. ;    We have several options for doing the remote WHO command.
  34. ;    First of all, we could spawn a job on a PK (or VT for M+)
  35. ;    and get  the output sent to a disk file and then send the
  36. ;    disk file over to the  reqesting Kermit.  This would have
  37. ;    the  advantage of keeping the command consistant with the
  38. ;    system managers desires.
  39. ;    The other option,  of course, is to do it ourself via the
  40. ;    appropiate  monitor directives  to get  that information.
  41. ;    That  option is really  only available for RSTS since RSX
  42. ;    does not have the directives needed to get that info from
  43. ;    the exec.  For now, I will  use the second option.  To be
  44. ;    used,  Kermit must run with  temporary privileges (RSTS).
  45. ;    To  patch out,  add (at task build time) the following to
  46. ;    the tkb command file.
  47. ;
  48. ;    GBLPAT=K11WHO:SYSTAT+0:240
  49. ;
  50. ;    It would, of course, be fairly straight forward to do the
  51. ;    SYSTAT  on a PK as I already  have the code to log output
  52. ;    to disk.
  53. ;
  54. ;
  55. ;    input:    @r5    value of channel to do i/o on, zero --> terminal
  56. ;    output:    r0    rsts error code if any.
  57. ;
  58. ;
  59. ;    12-Sep-86  10:31:20  BDN    Convert to I/D space
  60.  
  61.     .macro    dosys    jobnum    ,type
  62.     mov    type    ,-(sp)
  63.     mov    jobnum    ,-(sp)
  64.     call    .dosys
  65.     cmp    (sp)+    ,(sp)+
  66.     .endm    dosys
  67.  
  68.  
  69.  
  70.  
  71.     .sbttl    the real work of systat
  72.  
  73. systat::br    5$            ; skip the error exit
  74.     mov    #10.    ,r0        ; return protection violation
  75.     return                ; bye
  76.  
  77. 5$:    save    <r1,r2,r3,r4,r5>    ; save all registers please
  78.     sub    #120    ,sp        ; allocate a text buffer
  79.     call    getprv            ; we need temp privs
  80.     mov    #512.    ,xrb+0        ; try a peek to see if we have
  81.     .peek                ; priv's to run with
  82.     movb    firqb    ,r0        ; well ?
  83.     bne    100$            ; none, so exit please
  84.  
  85.     clr    r4            ; index # of job to do
  86.  
  87.  
  88. 10$:    mov    sp    ,r3        ; point to our local buffer now
  89.     inc    r4            ; jobnumber := jobnumber+1
  90.     dosys    r4    ,#0        ; do the uu.sys part 0 please
  91.     tstb    r0            ; did it work ?
  92.     beq    20$            ; yes
  93.     cmpb    r0    ,#10.        ; no job of such number present?
  94.     beq    80$            ; yes, just do the next job then
  95.     br    100$            ; no, exit then as we are all done
  96. 20$:    tstb    firqb+5            ; is the job we found attached ?
  97.     bmi    80$            ; yes, skip it then
  98.     deccvt    r4,r3,#3        ; convert job number to ascii
  99.     add    #3    ,r3        ; and point to end of the string
  100.     movb    #40    ,(r3)+        ; stuff a space in
  101.     movb    #40    ,(r3)+        ; stuff a space in
  102.     call    cvtppn            ; convert the ppn next
  103.     movb    #40    ,(r3)+        ; again a space please
  104.     call    cvtkb            ; get the kb number next
  105.     mov    #firqb+22,r1        ; get the program name next
  106.     call    rad            ; convert to ascii and fix pointer
  107.     dosys    r4    ,#1        ; get the current size now
  108.     movb    firqb+16,r0        ; where it returned the size
  109.     deccvt    r0,r3,#5        ; convert with at least 3 spaces
  110.     add    #5    ,r3        ; move the pointer right along
  111.     movb    #'K    ,(r3)+        ; the size please
  112.     movb    #40    ,(r3)+        ; spaces again
  113.     movb    #40    ,(r3)+        ; spaces again
  114.     movb    #40    ,(r3)+        ; spaces again
  115.     dosys    r4    ,#0        ; get the info part zero back
  116.     mov    #firqb+34,r1        ; and the current RTS name now
  117.     call    rad            ; convert to ascii and fix pointer
  118.     clrb    @r3            ; all done at last
  119.     mov    sp    ,r3        ; point back to the buffer
  120.     call    doio            ; do the i/o at last
  121. 80$:    br    10$            ; next please
  122.  
  123.  
  124. 100$:    cmpb    r0    ,#18.        ; end of the table ?
  125.     bne    110$            ; no
  126.     clr    r0            ; yes
  127. 110$:    add    #120    ,sp        ; pop the local buffer
  128.     unsave    <r5,r4,r3,r2,r1>    ; pop temps and exit
  129.     call    drpprv            ; please do this
  130.     return
  131.  
  132.  
  133.  
  134.  
  135.  
  136.     .sbttl    utilities and the actual i/o
  137.     .enabl    lsb
  138.  
  139. doio:    tst    @r5            ; channel zero today ?
  140.     bne    10$            ; no, assume disk then
  141.     print    r3
  142.     print    #200$
  143.     br    100$
  144. 10$:    strlen    r3            ; try to a disk file now
  145.     calls    putrec    ,<r3,r0,@r5>    ; write to the passed LUN
  146. 100$:    return
  147.  
  148.     .save
  149.     .psect    $pdata    ,d
  150. 200$:    .byte    cr,lf,0
  151.     .even
  152.     .restore
  153.     .dsabl    lsb
  154.  
  155.  
  156. rad:    calls    rdtoa    ,<r3,(r1)+>    ; common code to to rad50 cvt
  157.     add    #3    ,r3        ; pointer := pointer + 3
  158.     calls    rdtoa    ,<r3,(r1)+>    ; common code to to rad50 cvt
  159.     add    #3    ,r3        ; pointer := pointer + 3
  160.     return
  161.  
  162.  
  163.  
  164.  
  165.     .sbttl    misc utilities
  166.     .enabl    lsb
  167.  
  168. cvtppn:    save    <r0,r1>            ; save temps please
  169.     sub    #20    ,sp        ; convert ppn to ascii next
  170.     mov    sp    ,r0        ; a pointer to the ppn
  171.     clr    r1            ; get the project number now
  172.     bisb    firqb+27,r1        ; ok
  173.     bne    10$            ; if <> 0 then a real account
  174.     mov    #200$    ,r1        ; if eq 0 then not logged it yet
  175.     br    20$            ; copy over *,*
  176. 10$:    deccvt    r1,r0,#3        ; convert it to decimal
  177.     add    #3    ,r0
  178.     movb    #',    ,(r0)+        ; stuff a comma in please
  179.     clr    r1            ; get the programmer number now
  180.     bisb    firqb+26,r1        ; ok
  181.     deccvt    r1,r0,#3        ; convert it to decimal
  182.     mov    sp    ,r1        ; point to the buffer now
  183. 20$:    movb    #40    ,(r3)+        ; stuff a space into our result
  184.     mov    #7    ,r0        ; seven characters to copy
  185. 30$:    movb    (r1)+    ,(r3)+        ; and copy the rest of it
  186.     sob    r0    ,30$        ; simple
  187.     movb    #40    ,(r3)+        ; stuff a space into our result
  188.     movb    #40    ,(r3)+        ; stuff a space into our result
  189.     movb    #40    ,(r3)+        ; stuff a space into our result
  190.     add    #20    ,sp        ; pop the local buffer
  191.     unsave    <r1,r0>
  192.     return
  193.     
  194.     .save
  195.     .psect    $pdata    ,d
  196. 200$:    .asciz    /  *,  */
  197.     .even
  198.     .restore
  199.     .dsabl    lsb
  200.  
  201. cvtkb:    save    <r0,r1>            ; convert kb number to ascii
  202.     sub    #10    ,sp        ; allocate a local buffer
  203.     mov    sp    ,r1        ; point to it
  204.     movb    firqb+5    ,r0        ; KB number to convert
  205.     movb    #'K    ,(r3)+        ; insert a header
  206.     movb    #'B    ,(r3)+        ; simple
  207.     deccvt    r0,r1,#3        ; can't ever be more than 127
  208.     mov    r3    ,-(sp)        ; saev the output pointer now
  209.     mov    #3    ,r0        ; three at most to copy over
  210. 10$:    cmpb    @r1    ,#40        ; a space present ?
  211.     beq    20$            ; yes, please ignore it
  212.     movb    @r1    ,(r3)+        ; copy it over at last
  213. 20$:    inc    r1            ; next ch please
  214.     sob    r0    ,10$        ; simple
  215.     movb    #40    ,(r3)+        ; insert some spaces now
  216.     movb    #40    ,(r3)+        ; insert some spaces now
  217.     movb    #40    ,(r3)+        ; insert some spaces now
  218.     movb    #40    ,(r3)+        ; insert some spaces now
  219.     mov    (sp)+    ,r3        ; restore the old pointer
  220.     add    #5    ,r3        ; say we copied 5+2 characters over
  221.     add    #10    ,sp        ; pop the local buffer and exit
  222.     unsave    <r1,r0>            ; pop registers
  223.     return
  224.     
  225.  
  226.  
  227. $clrxr:    save    <r0>
  228.     mov    #xrb    ,r0
  229. 10$:    clr    (r0)+
  230.     cmp    r0    ,#xrb+14
  231.     blos    10$
  232.     unsave    <r0>
  233.     return
  234.  
  235.  
  236.  
  237. $clrfq:    save    <r0>
  238.     mov    #firqb    ,r0
  239. 10$:    clr    (r0)+
  240.     cmp    r0    ,#firqb+36
  241.     blos    10$
  242.     unsave    <r0>
  243.     return
  244.  
  245.  
  246.  
  247.  
  248. .dosys:    clrfqb                ; clear the firqb out first
  249.     movb    #uu.sys    ,firqb+fqfun    ; do a systat call to RSTS
  250.     movb    2(sp)    ,firqb+4    ; job number to do it for
  251.     movb    4(sp)    ,firqb+5    ; which type (0 or 1)
  252.     .uuo                ; simple
  253.     movb    firqb    ,r0        ; return with error code in r0
  254.     return                ; bye
  255.  
  256.     .sbttl    do the server C command for RSTS/E version 8
  257.  
  258. ;    13-Apr-84  13:15:50  Brian Nelson
  259. ;
  260. ;    input:    @r5    address of command string
  261. ;        2(r5)    LUN to send the output to, zero implies TT:
  262. ;    output:    r0    error code (rms or RSTS/E)
  263. ;
  264. ;    Note:    This is a very SIMPLE version of the code I wrote
  265. ;        several years ago to do complete PK handling.  In
  266. ;        this version, we NEVER try to read anything  from
  267. ;        the users keyboard, nor do we EVER write anything
  268. ;        to it  since it is assumed that we are supporting
  269. ;        the server host command packet stuff. Any attempt
  270. ;        by the invoked CCL/DCL command to read input will
  271. ;        cause the program (and job) to be aborted.
  272.  
  273.  
  274.     .iif ndf, corcom, corcom = 460
  275.  
  276.     .psect    pkbuff    ,rw,lcl,rel,con,d
  277.  
  278. pkbuff:    .blkb    200
  279. pkbufp:    .word    0
  280. pkbufs:    .word    0
  281. jobnum:    .word    0
  282.     .even
  283. pkbsiz    =    200
  284.  
  285.  
  286.     .sbttl    the real work of sercmd
  287.     .psect    $code
  288.  
  289. sercmd::clr    pkbufs            ; insure no data is left in buffer
  290.     mov    #jfsys    ,xrb+0        ; get temp privs back
  291.     .set                ; simple to do
  292.     call    openpk            ; find an available PK
  293.     tst    r0            ; perhaps we could not get one
  294.     bne    100$            ; r0 will have RSTS/E error code
  295.     call    logv8            ; get logged in on the PK
  296.     tst    r0            ; if it fails, it's the error code
  297.     bne    100$            ; oops
  298.     mov    r1    ,jobnum        ; save the jobnumber please
  299.     movb    #'c&37    ,-(sp)        ; no, force a control C
  300.     call    putpk            ; simple
  301.     mov    #2    ,xrb+0        ; wait a moment
  302.     .sleep                ; simple. any i/o will wake us up
  303. 5$:    call    getpk            ; eat the result of the control C
  304.     tst    r0            ; loop until eofeof error (11)
  305.     beq    5$            ; go back for more
  306.     mov    #10    ,r1        ; wait for kmon
  307. 10$:    mov    jobnum    ,-(sp)        ; simple
  308.     call    jobsts            ; waiting for KB input now ?
  309.     tst    r0            ; well?
  310.     bmi    15$            ; ok
  311.     mov    #1    ,xrb+0        ; wait a moment
  312.     .sleep                ; simple. any i/o will wake us up
  313.     sob    r1    ,10$        ;
  314.  
  315. 15$:    mov    @r5    ,-(sp)        ; do it
  316.     call    sendcmd            ; ok
  317.     mov    #10    ,xrb+0        ; wait a little while before checking
  318.     .sleep                ; job status. any i/o will reset this
  319.  
  320.  
  321. 20$:    call    getpk            ; now get the result of the command
  322.     tst    r0            ; did it work ?
  323.     bne    30$            ; no, find out why then
  324.     call    output            ; dump the ch read to somewhere
  325.     br    40$
  326. 30$:    mov    jobnum    ,-(sp)        ; the job number
  327.     call    jobsts            ; find out what's happening here
  328.     tst    r0            ; if ge, then it's just running
  329.     bmi    90$            ; it's waiting for input or all done
  330.     mov    #1    ,xrb+0        ; if ok, take a one second nap
  331.     .sleep                ; simple
  332. 40$:    br    20$            ; try to get some more data now
  333.  
  334. 90$:    mov    #377    ,r0        ; a fake error to return
  335.  
  336. 100$:    mov    #jfsys    ,xrb+0
  337.     .clear
  338.     call    killpk
  339.     return
  340.  
  341.  
  342.  
  343.     .sbttl    where to put the output
  344.  
  345. output:    tst    2(r5)            ; the LUN to use
  346.     bne    10$            ; a disk
  347.     movb    r1    ,-(sp)        ; the terminal
  348.     mov    sp    ,r1        ; a pointer
  349.     print    r1    ,#1        ; dump it
  350.     tst    (sp)+            ; pop the buffer and exit
  351.     br    100$            ; bye
  352. 10$:    movb    r1    ,r0        ; rms output today
  353.     mov    2(r5)    ,r1        ; the channel
  354.     call    putcr0            ; simple to do
  355. 100$:    return                ; bye
  356.  
  357.  
  358.  
  359.     pk.lun    =    12.
  360.  
  361.  
  362. openpk:    mov    r1    ,-(sp)        ; save this one today
  363.     clr    r1            ; start at PK0:
  364. 10$:    clrfqb                ; insure no defaults
  365.     movb    #opnfq    ,firqb+fqfun    ; open the thing up now
  366.     movb    #pk.lun*2,firqb+fqfil    ; channel number times 2
  367.     movb    r1    ,firqb+fqdevn    ; device unit number please
  368.     movb    #377    ,firqb+fqdevn+1    ; unit is for real here
  369.     mov    #"PK    ,firqb+fqdev    ; device name also
  370.     calfip                ; try to open it up
  371.     movb    firqb    ,r0        ; get the rsts error code if any
  372.     beq    100$            ; all is well
  373.     cmpb    r0    ,#6        ; invalid device ?
  374.     beq    100$            ; yes exit with this error
  375.     inc    r1            ; else try again
  376.     br    10$            ; next please
  377. 100$:    mov    (sp)+    ,r1        ; pop r1 and exit
  378.     return
  379.  
  380.  
  381.     .sbttl    create a logged in job for the PK (version 8 only)
  382.  
  383. ;    Creates a job under the current account for the PK that's
  384. ;    open on PK.LUN.
  385. ;
  386. ;    returns: r0    rsts error code
  387. ;         r1    created job number
  388.  
  389.  
  390. logv8:    movb    #uu.sys    ,firqb+fqfun    ; get the user's default RTS please
  391.     clr    firqb+4            ; current job, systat part 0
  392.     .uuo                ; simple, can't fail either
  393.     mov    firqb+26,-(sp)        ; save the user's account number
  394.     mov    firqb+32,-(sp)        ; save the user's defkbm
  395.     mov    firqb+30,-(sp)        ; save the user's defkbm
  396.     clrfqb                ; now get the kb number for the PK
  397.     movb    #uu.fcb    ,firqb+fqfun    ; get the DDB returned for it
  398.     movb    #pk.lun    ,firqb+fqfun+1    ; channel number that we want
  399.     .uuo                ; default to GET DDB info
  400.     movb    firqb+14,-(sp)        ; save it
  401.     asrb    (sp)            ; not times two please
  402.  
  403.     clrfqb                ; version 8, enter a run time system
  404.     mov    #firqb+fqfun,r0        ; at the p.new entry point
  405.     movb    #uu.job    ,(r0)+        ; create a job function for fip
  406.     movb    #20!100!200,(r0)+    ; create logged in @ defkbm always
  407.     movb    (sp)+    ,(r0)+        ; kb number to attach to job
  408.     clr    (r0)+            ; unused field
  409.     mov    (sp)+    ,(r0)+        ; user's default run time system
  410.     mov    (sp)+    ,(r0)+        ; both rad50 words please
  411.     clr    (r0)+            ; unused field
  412.     mov    (sp)+    ,@r0        ; account number also
  413.     bisb    #40    ,firqb+4    ; set flag for account to login to
  414.     movb    corcom    ,-(sp)        ; save this please
  415.     clrb    corcom            ; core common is also passed
  416.     .uuo                ; try to create the job now
  417.     movb    (sp)+    ,corcom        ; restore first byte of core common
  418.     movb    firqb+4    ,r1        ; created job number please
  419.     asr    r1            ; but not times two
  420.     movb    firqb    ,r0        ; did it work?
  421.     bne    110$            ; no
  422.     tstb    firqb            ; huh
  423.     clc                ; yes, flag success and exit
  424.     return                ; bye
  425.  
  426. 110$:    sec                ; job creation failed, exit
  427.     return                ; set a flag and return
  428.  
  429.  
  430.     
  431.  
  432.     .sbttl    pkread/write    i/o for the pk
  433.  
  434.  
  435. getpk:    clrxrb                ; clear xrb
  436.     tst    pkbufs            ; any buffered data left to get?
  437.     bne    10$            ; no
  438.     call    200$            ; reload the buffer please
  439.     tst    r0            ; get anything ?
  440.     bne    100$            ; no, exit
  441. 10$:    mov    pkbufp    ,r0        ; yes, get a pointer to the buffer
  442.     clr    r1            ; avoid sign extension
  443.     bisb    pkbuff(r0),r1        ; get the ch now
  444.     inc    pkbufp            ; advance the pointer for next time
  445.     dec    pkbufs            ; one less character left to get
  446.     clr    r0            ; say it worked
  447. 100$:    return                ; bye
  448.  
  449. 200$:    clr    pkbufp            ; no data, clear buffer pointer
  450.     clrxrb                ; no defaults
  451.     mov    #pkbsiz    ,xrb+xrlen    ; as many as we can grab
  452.     mov    #pkbuff    ,xrb+xrloc    ; buffer location
  453.     movb    #pk.lun*2,xrb+xrci    ; channel #
  454.     inc    xrb+xrtime        ; wait at most one second
  455.     .read                ; read from pk
  456.     movb    firqb    ,r0        ; get any error codes
  457.     bne    210$            ; no
  458.     mov    xrb+xrbc,pkbufs        ; it worked, init the bytes left
  459. 210$:    return                ; back to work...
  460.  
  461.  
  462. putpk:    clrxrb                ; no odd things please
  463.     inc    xrb+xrlen        ; one ch to do
  464.     mov    sp    ,xrb+xrloc    ; buffer location
  465.     add    #2    ,xrb+xrloc    ; off by one
  466.     mov    #1    ,xrb+xrbc    ; byte count
  467.     movb    #pk.lun*2,xrb+xrci    ; channel #
  468.     mov    #9.    ,xrb+xrmod    ; record 9%
  469.     .write                ; write to pk
  470.     movb    firqb    ,r0        ; result
  471.     mov    (sp)+    ,(sp)        ; pop ch that we wrote
  472.     return                ; back to work...
  473.  
  474.  
  475.  
  476.     .sbttl    pk utilities
  477.  
  478.  
  479. sendcmd:mov    r1    ,-(sp)
  480.     mov    4(sp)    ,r1        ; command address to send to PK
  481. 10$:    tstb    @r1            ; done yet ?
  482.     beq    100$            ; yes, exit
  483.     movb    (r1)+    ,-(sp)        ; loop until a null is found
  484.     call    putpk            ; simple
  485.     br    10$            ; next please
  486. 100$:    mov    (sp)+    ,r1        ; pop register we used
  487.     mov    (sp)+    ,(sp)        ; pop address of string and exit
  488.     mov    #cr    ,-(sp)        ; finish with a carriage return
  489.     call    putpk            ; simple
  490.     return
  491.     
  492.  
  493. waitpk:    clrxrb                ; no odd things please
  494.     mov    sp    ,xrb+xrloc    ; buffer location
  495.     movb    #pk.lun*2,xrb+xrci    ; channel #
  496.     mov    #6.    ,xrb+xrmod    ; record 2+4
  497.     .write                ; write to pk
  498.     tstb    firqb            ; result
  499.     beq    100$            ; it's ready for a command
  500.     cmpb    firqb    ,#28.        ; need a control C?
  501.     beq    100$
  502.     sec                ; it's not ready    
  503.     return
  504. 100$:    clc
  505.     return                ; back to work...
  506.  
  507.  
  508. killpk:    clrxrb                ; no odd things please
  509.     mov    sp    ,xrb+xrloc    ; buffer location
  510.     movb    #pk.lun*2,xrb+xrci    ; channel #
  511.     mov    #20    ,xrb+xrmod    ; record 2+4
  512.     .write                ; write to pk
  513.     clrfqb                ; now close it up
  514.     movb    #clsfq    ,firqb+fqfun    ; simple
  515.     movb    #pk.lun*2,firqb+fqfil    ; channel to do
  516.     calfip                ; do it
  517.     return                ; back to work...
  518.  
  519.     
  520.  
  521.     .sbttl    jobsts    return status of the controlled job
  522.  
  523.  
  524. ;    input:    2(sp)    job number 
  525. ;    output:    r0    < 0 then kb stall, 0 waiting for tt output, > 0 running
  526. ;
  527. ;    This will be called to determine when the spawned job should
  528. ;    be aborted.
  529. ;
  530. ;    r0    = -2    the job is logged out, waiting for input or
  531. ;            in a kmon wait
  532. ;    r0    = -1    timeout
  533. ;    r0    = 0    job is waiting for output to the PK
  534. ;    r0    > 0    job is in a run state
  535.  
  536.     .jbstat    =    12
  537.     .jbwait    =    14
  538.     .iif ndf, j2con    ,j2con    =    4
  539.     .iif ndf, j2nopr,j2nopr    =    10000
  540.     .iif ndf, js.kb    ,js.kb    =    2
  541.     .iif ndf, js.tel,js.tel    =    4000
  542.  
  543.  
  544. jobsts:    mov    r1    ,-(sp)        ; we may access these here
  545.     mov    r2    ,-(sp)        ; save these also
  546.     movb    #uu.sys    ,firqb+fqfun    ; for looking up a job
  547.     movb    6(sp)    ,firqb+fqfun+1    ; job number to do
  548.     movb    #1    ,firqb+fqfun+2    ; part two to do please
  549.     .uuo                ; do it
  550.     tstb    firqb            ; did it work ?
  551.     bne    90$            ; no, return abort please
  552.     bit    #jfnopr    ,firqb+6    ; logged in ?
  553.     bne    90$            ; no, return abort then
  554.     mov    firqb+.jbstat,r1    ; get the current jbstat word
  555.     mov    firqb+.jbwait,r2    ; get the current jbwait word
  556.     com    r1            ; and get the and of the two
  557.     bic    r1    ,r2        ; if result <> 0 then job is
  558.     bne    10$            ; running ok
  559.     bit    #js.kb    ,firqb+.jbwait    ; not running, stalled for kb input?
  560.     bne    90$            ; yes, abort the job then
  561.     bit    #js.tel    ,firqb+.jbwait    ; waiting for tt output
  562.     bne    80$            ; yes
  563.  
  564. 10$:    mov    firqb+34,xrb+0        ; no, check the elapsed time please
  565.     add    #j2con    ,xrb+0        ; simple
  566.     .peek                ; do it
  567.     tstb    firqb            ; did that work ?
  568.     bne    90$            ; no, die
  569.     cmp    xrb+0    ,#300        ; allow three minutes at most
  570.     bhis    95$            ; no, die
  571.     mov    #1    ,r0        ; all is well, exit
  572.     br    100$
  573.  
  574. 80$:    clr    r0            ; job is waiting on tt output
  575.     br    100$            ; bye
  576.  
  577. 90$:    mov    #-2    ,r0        ; waiting on KB or logged out
  578.     br    100$            ; bye
  579.  
  580. 95$:    mov    #-1    ,r0        ; timeout
  581.     br    100$            ; exit
  582.  
  583. 100$:    mov    (sp)+    ,r2        ; exit
  584.     mov    (sp)+    ,r1
  585.     mov    (sp)+    ,(sp)        ; pop parameter and exit
  586.     return
  587.  
  588.     .iif ndf , UU.CHK,    UU.CHK = 40
  589.     .iif ndf , UU.PRV,    UU.PRV = 34
  590.     .iif ndf , NOSUCH,    NOSUCH = 5
  591.     .iif ndf , NOTAVL,    NOTAVL = 10
  592.     .iif ndf , PRVIOL,    PRVIOL = 12
  593.     .iif ndf , QUOTA ,    QUOTA  = 105
  594.  
  595.  
  596.  
  597.     .sbttl    LOGIN    Login from a remote server command
  598.  
  599.  
  600. ;    LOGIN    24-Sep-85  10:01:33  Brian Nelson (V9.x and later only)
  601. ;        Added on Edit 2.36
  602. ;
  603. ;
  604. ;    Passed:    0(r5)    Address (asciz) of PPN to log into
  605. ;        2(r5)    Address (asciz) of password
  606. ;        4(r5)    Address of where to return informative messages
  607. ;    Return:    R0    Zero for success, else the error code.
  608.  
  609.     .enabl    lsb
  610.  
  611. login::    save    <r1,r2>            ; save work regs
  612.     call    dolin            ; try to switch
  613.     tst    r0            ; successful ?
  614.     beq    100$            ; yes
  615.     clr    r1            ; no, Reply with a reasonable error
  616. 10$:    tstb    200$(r1)        ; end of the list
  617.     beq    20$            ; yes, use a catchall error
  618.     cmpb    200$(r1),r0        ; find the error yet ?
  619.     beq    20$            ; yes
  620.     inc    r1            ; no
  621.     br    10$            ; next please
  622. 20$:    asl    r1            ; times two for word addressing
  623.     mov    r0    ,-(sp)        ; save the error code
  624.     strcpy    4(r5),210$(r1)        ; simple
  625.     mov    (sp)+    ,r0        ; restore the error code
  626. 100$:    unsave    <r2,r1>            ; exit
  627.     return                ; and exit
  628.  
  629.  
  630.     .save
  631.     .psect    $PDATA    ,D
  632.  
  633. 200$:    .byte    NOSUCH,NOTAVL,PRVIOL,QUOTA,0
  634.     .even
  635. 210$:    .word    220$  ,230$  ,240$  ,250$ ,220$
  636. 220$:    .asciz    /Invalid password or account, or system password needed/
  637. 230$:    .asciz    /Expired, non-interactive or non-dialup account/
  638. 240$:    .asciz    /WACNT privilege needed for REMOTE LOGIN/
  639. 250$:    .asciz    /Some quota is exceeded/
  640.     .even
  641.     .restore
  642.     .dsabl    lsb
  643.  
  644.  
  645.     .sbttl    really do the login now
  646.  
  647.  
  648. ;    DOLIN:
  649. ;
  650. ;    Passed:    0(r5)    Address of the PPN (.asciz) to log into
  651. ;        2(r5)    Address of the password (.asciz) to log into
  652. ;
  653. ;    Return:    r0    =  0 for success
  654. ;        r0    <> 0 with RSTS/E error code
  655.  
  656.  
  657. dolin:    sub    #10    ,sp        ; allocate a buffer for use here
  658.     mov    #WACNT    ,-(sp)        ; check to see if we have WACNT priv
  659.     call    chkprv            ; do it
  660.     tst    r0            ; do we have WACNT privilege ?
  661.     beq    90$            ; no
  662.     clrxrb                ; yes, continue on by clearing the
  663.     clrfqb                ; XRB and FIRQB
  664.     movb    #UU.SWP    ,FIRQB+FQFUN    ; To find out the physical name of
  665.     movb    #2    ,FIRQB+FQFIL    ; the system disk we will call the
  666.     movb    #377    ,FIRQB+5    ; exec to find out the name of swap
  667.     .UUO                ; file 2, which is always on _SY0:
  668.     mov    FIRQB+FQDEV,(sp)    ; Also, no privilege is needed.
  669.     mov    FIRQB+FQDEVN,2(sp)    ; copy the device name and unit flags
  670.     clrfqb                ; clear things out again to do a .FSS
  671.     mov    @r5    ,r0        ; on the passed PPN to convert it to
  672. 10$:    tstb    (r0)+            ; the proper format.
  673.     bne    10$            ; Find the length of the string
  674.     sub    @r5    ,r0        ; end of it, subtract starting address
  675.     dec    r0            ; and correct for autoincrement
  676.     mov    r0    ,XRB+0        ; stuff the string length
  677.     mov    r0    ,XRB+2        ; again
  678.     mov    @r5    ,XRB+4        ; and the buffer address
  679.     .FSS                ; call the exec
  680.     movb    FIRQB    ,r0        ; Did this work
  681.     bne    100$            ; If not, must be a invalid PPN format
  682.     mov    FIRQB+FQPPN,4(sp)    ; Save the parsed PPN please
  683.     movb    #UU.LIN    ,FIRQB+3    ; Finally, do a password check on the
  684.     movb    #1+<2*1>,FIRQB+5    ; desired account to log into.
  685.     mov    #FIRQB+FQNAM1,r1    ; This presumes version 9.x, using
  686.     mov    2(r5)    ,r0        ; ascii passwords.
  687. 20$:    movb    (r0)+    ,(r1)+        ; copy the password over to the FIRQB
  688.     bne    20$            ; not yet done
  689.     mov    (sp)    ,FIRQB+FQDEV    ; Lastly, restore the system disk name
  690.     mov    2(sp)    ,FIRQB+FQDEVN    ; unit number and units flags.
  691.     .UUO                ; Finally call the exec to check it.
  692.     movb    FIRQB    ,r0        ; But did the passwords match ?
  693.     bne    100$            ; No, exit on error then
  694.     clrfqb                ; Next, we must log out to be able to
  695.     incb    FIRQB+4            ; Must NOT close i/o channels up.
  696.     movb    #UU.BYE    ,FIRQB+FQFUN    ; log back in again (Remember, we need
  697.     .UUO                ; WACNT to avoid self kill by the exec)
  698.     movb    FIRQB    ,r0        ; Did this work ?
  699.     bne    100$            ; no, exit please
  700.     cmp    FIRQB+4    ,#-1        ; Did the logout succeed ?
  701.     beq    80$            ; no (quota exceeded)
  702.     clrfqb                ; Clear the FIRQB one last time
  703.     movb    #UU.LIN    ,FIRQB+FQFUN    ; Login function for .UUO
  704.     movb    #10*1    ,FIRQB+5    ; We can skip the password check as we
  705.     mov    4(sp)    ,FIRQB+FQPPN    ; already checked and we needed WACNT
  706.     .UUO                ; at LAST .....
  707.     movb    FIRQB    ,r0        ; save and exit
  708.     bne    100$            ; ....
  709.     call    setprv            ; set authorized privileges up
  710.     clr    r0            ; it's ok
  711.     br    100$            ; exit
  712.  
  713. 80$:    mov    #QUOTA    ,r0        ; UU.BYE failed due to a quota
  714.     br    100$
  715. 90$:    mov    #PRVIOL    ,r0        ; No WACNT--> protection violation
  716. 100$:    add    #10    ,sp        ; pop buffer and exit
  717.     return
  718.  
  719.     .save
  720.     .psect    $PDATA    ,D
  721. wacnt:    .asciz    /WACNT/
  722. exqta:    .asciz    /EXQTA/    
  723.     .even
  724.     .restore
  725.  
  726.  
  727.  
  728.     .sbttl    detach the server
  729.  
  730.  
  731. detach::clrfqb                ; insure no defaults
  732.     movb    #UU.SYS    ,FIRQB+FQFUN    ; do a systat and get the kb number
  733.     .UUO                ; simple to do
  734.     movb    FIRQB+5    ,r1        ; save the kb number
  735.     clrfqb                ; insure no defaults
  736.     movb    #clsfq    ,FIRQB+FQFUN    ; insure KB: is detached
  737.     movb    #5*2    ,FIRQB+FQFUN+1    ; the lun for it
  738.     CALFIP                ; do it, skip any error codes
  739.     clrfqb
  740.     movb    #UU.DET    ,FIRQB+FQFUN    ; the uuo detach code
  741.     movb    #200    ,FIRQB+FQFUN+1    ; close all luns for KB:
  742.     .UUO                ; simple to do
  743.     movb    FIRQB    ,r0        ; return any errors
  744.     bne    100$            ; yep
  745.     mov    #1    ,xrb+0
  746.     .sleep
  747.     clrfqb                ; now spawn a job attached
  748.     mov    #FIRQB+FQFUN,r0        ; to our old kb
  749.     movb    #UU.JOB    ,(r0)+        ; create a job exec call
  750.     movb    #20!100!200,(r0)+    ; into def kbm, no logins is ok
  751.     movb    r1    ,@r0        ; the kb number to attach to
  752.     bne    10$            ; not KB0:
  753.     movb    #200    ,@r0        ; KB0:, must set flag for it
  754. 10$:    .UUO                ; simple to do, ignore errors
  755.     clr    r0            ; return success
  756. 100$:    return
  757.  
  758.  
  759.  
  760.     .sbttl    check for AUTHOURIZED priv
  761.  
  762. ;    This  is  again  different  from  CHKPRV,  which  checks for
  763. ;    CURRENT priv, and JOBPRV, which checks for JOB  priv  as  in
  764. ;    SET  JOB/[NO]PRIV.  This  one  goes out to disk and gets the
  765. ;    AUTHORIZED priv mask and checks for the passed priv. 
  766. ;
  767. ;    Passed:    2(sp)    Name of priv to check, upper case please
  768. ;    Return:    R0    1 for success or pre 9.x, zero for no priv
  769. ;
  770. ;    Example:
  771. ;
  772. ;    mov    #HWCFG    ,-(sp)
  773. ;    call    JOBPRV
  774. ;    tst    r0
  775. ;    beq    error
  776. ;
  777. ;
  778. ; hwcfg:.asciz    /HWCFG/
  779. ;    .even
  780.  
  781.  
  782. authpr::mov    r1    ,-(sp)        ; /41/ Save a register
  783.     mov    r2    ,-(sp)        ; /41/ ... save another one
  784.     sub    #10    ,sp        ; /41/ temp save area
  785.     mov    #1    ,r2        ; /41/ Assume success
  786.     tst    ver9.x            ; /41/ version nine or later?
  787.     beq    100$            ; /41/ no, return( success )
  788.     clrfqb                ; /41/ Clear firqb out
  789.     mov    #FIRQB+FQFUN,r1        ; /41/ Read authorized priv mask
  790.     movb    #UU.ATR    ,(r1)+        ; /41/ Function to perform
  791.     movb    #377    ,(r1)+        ; /41/ Read function
  792.     movb    #2    ,(r1)+        ; /41/ Read AUTHORIZED priv mask
  793.     .UUO                ; /41/ Go to it
  794.     mov    #FIRQB+12,r0        ; /41/ Where the priv mask is
  795.     mov    sp    ,r1        ; /41/ Where to save it
  796.     mov    (r0)+    ,(r1)+        ; /41/ Save it please
  797.     mov    (r0)+    ,(r1)+        ; /41/ .Save it please
  798.     mov    (r0)+    ,(r1)+        ; /41/ ..Save it please
  799.     mov    (r0)+    ,(r1)+        ; /41/ ...Save it please
  800.     clrfqb                ; /41/ clear firqb out
  801.     mov    #FIRQB+FQFUN,r0        ; /41
  802.     movb    #UU.CHK    ,(r0)+        ; /41/ Convert priv name to bitmask
  803.     inc    (r0)+            ; /41/ Subfunbction code = 1
  804.     tst    (r0)+            ; /41/ skip this field
  805.     mov    2+14(sp),r1        ; /41/ copy the priv over
  806. 10$:    movb    (r1)+    ,(r0)+        ; /41/ copy the asciz name over
  807.     bne    10$            ; /41/ simple
  808.     .UUO                ; /41/ convert NAME to MASK
  809.     mov    sp    ,r1        ; /41/ point back to save area
  810.     mov    #FIRQB+FQNAM1,r0    ; /41/ Where the bit pattern is
  811.     mov    #4    ,r2        ; /41/ Four words to check
  812. 20$:    bit    (r0)+    ,(r1)+        ; /41/ Any bit(s) set here ?
  813.     bne    30$            ; /41/ Yes, we have it
  814.     sob    r2    ,20$        ; /41/ No, keep looking
  815.     br    90$            ; /41/ Failure
  816. 30$:    mov    #1    ,r2        ; /41/ Flag we have it
  817.     br    100$            ; /41/ exit
  818.  
  819. 90$:    clr    r2            ; /41/ failure
  820. 100$:    mov    r2    ,r0        ; /41/ Return the status now
  821.     add    #10    ,sp        ; /41/ Pop buffer
  822.     mov    (sp)+    ,r2        ; /41/ ...Pop a register
  823.     mov    (sp)+    ,r1        ; /41/ Pop a register
  824.     mov    (sp)+    ,(sp)        ; /41/ Pop over the parameter
  825.     return                ; /41/ At last
  826.  
  827.  
  828.  
  829.  
  830.     .sbttl    Logout
  831.  
  832. ;    LOGOUT
  833. ;
  834. ;    Logout from the RSTS/E host from the server
  835. ;
  836. ;    Rewritten 3.45 11-Feb-86  15:25:17  BDN for version 9.x
  837. ;
  838. ;    Check quotas, if ok, drop the line and logout
  839.  
  840.  
  841. logout::save    <r0,r1,r2>        ; /45/ Save registers
  842.     clr    r2            ; /45/ Preset EXQTA priv flag
  843.     tst    ver9.x            ; /45/ Version nine or later
  844.     beq    50$            ; /45/ No, skip the quota check
  845.     mov    #exqta    ,-(sp)        ; /45/ V9, see if we have EXQTA
  846.     call    chkprv            ; /45/ ...
  847.     mov    r0    ,r2        ; /45/ Save the flag
  848.     bne    10$            ; /45/ EXQTA, skip quota checks
  849.                     ;
  850.     clrfqb                ; /45/ Ensure FIRQB is cleared out
  851.     movb    #UU.ATR    ,FIRQB+FQFUN    ; /45/ Do some quota checks
  852.     decb    FIRQB+4            ; /45/ Read account attributes
  853.     incb    FIRQB+5            ; /45/ We want quota data
  854.     .UUO                ; /45/ Get the data
  855.     tstb    FIRQB            ; /45/ Did this work ?
  856.     bne    50$            ; /45/ No, just log out then
  857.     cmpb    FIRQB+21,FIRQB+17    ; /45/ Is MSB of quota OK ?
  858.     bhi    100$            ; /45/ No, exit
  859.     cmp    FIRQB+24,FIRQB+12    ; /45/ Is current usage < outquota?
  860.     bhi    100$            ; /45/ No
  861.                     ;
  862. 10$:    clrfqb                ; /45/ Yes, get keyboard number
  863.     movb    #UU.SYS    ,FIRQB+FQFUN    ; /45/ UU.SYS part 0
  864.     .UUO                ; /45/ We have it now
  865.     movb    FIRQB+5    ,r1        ; /45/ Save it
  866.     bitb    #200    ,r1        ; /45/ Detached?
  867.     bne    50$            ; /45/ Yes, skip hangup
  868.     clrfqb                ; /45/ Get set to disconnect line
  869.     movb    #UU.HNG    ,FIRQB+FQFUN    ; /45/ At last....
  870.     movb    r1    ,FIRQB+4    ; /45/ Line to do it to
  871.     incb    FIRQB+5            ; /45/ Do it quickly (1 second)
  872.     .UUO                ; /45/ Drop the line, now log out
  873.                     ;
  874. 50$:    clrfqb                ; /45/ Clear FIRQB out
  875.     movb    #UU.BYE    ,FIRQB+FQFUN    ; /45/ Log out now
  876.     tst    r2            ; /45/ Version 9 and EXQTA ?
  877.     beq    60$            ; /45/ No
  878.     movb    #2    ,FIRQB+4    ; /45/ Yes, bypass quota checks
  879. 60$:    .UUO                ; /45/ Call the EXEC
  880.     cmp    FIRQB+4    ,#-1        ; /45/ Are we logged out ?
  881.     beq    100$            ; /45/ No
  882.     call    exit            ; /45/ Yes, exit please (never happen)
  883. 100$:    unsave    <r2,r1,r0>        ; /45/ Pop registers
  884.     return                ; /45/ Quota must be exceeded
  885.  
  886.  
  887.  
  888.  
  889.     .sbttl    Check current quotas to see if UU.BYE will succeed
  890.  
  891.  
  892. quochk::tst    ver9.x            ; /45/ Version nine or later
  893.     beq    30$            ; /45/ No, skip the quota check
  894.     mov    #exqta    ,-(sp)        ; /45/ V9, see if we have EXQTA
  895.     call    chkprv            ; /45/ ...
  896.     tst    r0            ; /45/ Save the flag
  897.     beq    10$            ; /45/ No EXQTA, do quota checks
  898.     clr    r0            ; /45/ EXQTA, return(success)
  899.     br    100$            ; /45/ Exit
  900.                     ;
  901. 10$:    clr    r0            ; /45/ Assume SUCCESS
  902.     clrfqb                ; /45/ Ensure FIRQB is cleared out
  903.     movb    #UU.ATR    ,FIRQB+FQFUN    ; /45/ Do some quota checks
  904.     decb    FIRQB+4            ; /45/ Read account attributes
  905.     incb    FIRQB+5            ; /45/ We want quota data
  906.     .UUO                ; /45/ Get the data
  907.     tstb    FIRQB            ; /45/ Did this work ?
  908.     bne    100$            ; /45/ No, just return(success)
  909.     cmpb    FIRQB+21,FIRQB+17    ; /45/ Is MSB of quota OK ?
  910.     bhi    20$            ; /45/ No, exit
  911.     cmp    FIRQB+24,FIRQB+12    ; /45/ Is current usage < outquota?
  912.     blos    100$            ; /45/ Yes
  913. 20$:    mov    sp    ,r0        ; /45/ No, return(nonzero)
  914.     br    100$            ; /45/ Exit
  915.  
  916. 30$:    clrfqb                ; /45/ Pre version 9 code
  917.     movb    #UU.RAD    ,FIRQB+FQFUN    ; /45/ rad accounting data please
  918.     .UUO                ; /45/ simple
  919.     clr    r0            ; /45/ assume success
  920.     tstb    FIRQB            ; /45/ did it work ?
  921.     bne    100$            ; /45/ no
  922.     tst    FIRQB+34        ; /45/ unlimited quota here ?
  923.     beq    100$            ; /45/ yes
  924.     cmp    FIRQB+6,FIRQB+34    ; /45/ is used > allowed ?
  925.     blos    100$            ; /45/ quota is ok
  926.     mov    sp    ,r0        ; /45/ quota is not ok, flag it
  927.  
  928. 100$:    return                ; /45/ Return to caller
  929.  
  930.  
  931.  
  932.  
  933.     .sbttl    Return disk space usage
  934.  
  935. ;    D S K U S E
  936. ;
  937. ;    input:    @r5    address of string to return the usage
  938.  
  939.     .enabl    lsb
  940.  
  941. dskuse::save    <r0,r1>
  942.     clrfqb                ; clear FIRQB out
  943.     movb    #UU.RAD    ,FIRQB+FQFUN    ; uuo function, read accounting data
  944.     .UUO                ; do it
  945.     mov    @r5    ,r1        ; point to the output string
  946.     copyz    #120$    ,r1        ; copy a header over please
  947.     strlen    r1            ; get the current length
  948.     add    r0    ,r1        ; point to the end of the string
  949.     deccvt    <FIRQB+6>,r1,#6        ; and convert used to string
  950.     add    #6    ,r1        ; point to the end again
  951.     copyz    #130$    ,r1        ; copy some more stuff
  952.     strlen    r1            ; get the count of chars we copied
  953.     add    r0    ,r1        ; point to the end of the string
  954.     mov    FIRQB+34,r0        ; get the quota
  955.     bne    10$            ; not unlimited
  956.     copyz    #140$    ,r1        ; unlimited, say so
  957.     br    20$
  958. 10$:    sub    FIRQB+6    ,r0        ; and get the free space
  959.     deccvt    r0    ,r1        ; copy the free space over now
  960.     clrb    6(r1)            ; make the string .asciz
  961. 20$:    unsave    <r1,r0>
  962.     return                ; bye
  963.  
  964.  
  965.     .save
  966.     .psect    $PDATA    ,D
  967. 120$:    .asciz    /SY: Space used /
  968. 130$:    .asciz    /    Space free /
  969. 140$:    .asciz    /    Unlimited/
  970.     .even
  971.     .restore
  972.     .dsabl    lsb
  973.  
  974.     .end
  975.