home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / test / pdp11 / krt80s.mac next >
Text File  |  1996-10-17  |  28KB  |  983 lines

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