From:	HENRY::IN%"RGERBER%nybvx1.bitnet%wiscvm.wisc.edu%sri-kl.ARPA%relay.cs.net@rca.com" 24-FEB-1987 13:51
To:	info-vax@sri-kl.arpa, warnock%clemson.csnet@csnet-relay.csnet
Subj:	Re: Recent reques on how to show operator terminals (bug fix)

        I have taken the routine that Todd Warnock posted earlier today and
fixed the problem with LAT terminals.  There seems to be a problem if the
terminal is not logged in or was enabled during a previous log in session.
I would appreciate any fixes to my modifications.  Also I made it so the
program will temporarily enable CMKRNL so it can run properly.
 
        Robert Gerber
        Comtex Systems
---------- CUT HERE -----------------------------------------------------------
        .title  show_operators  See what operators are enabled.
        .sbttl  documentation
;+++
;               This routine diplays the enabled operators.  Sorry that it's
;               not well documented or clean, it was a quick hack.  R. Wells
;
;      AUTHORS:
;
;               R. WELLS
;
;      CREATION DATE:   10-OCT-1985
;
;
;                      C H A N G E   L O G
;
;      Date     | Name  | Description
;---------------+-------+-----------------------------------------------------
;  10-OCT-1985  | WELLS | ORIGINAL RELEASE
;---------------+-------+-----------------------------------------------------
;  23-Feb-1987  | Gerber| Have the program enable CMKRNL temporarily so the
;               |       | number of funny results are reduced.
;               |       | Also get the UNIT number from the UCB instead of a
;               |       | local counter as units do not have to be contiguos!
;---------------+-------+-----------------------------------------------------
;
;      BUILD:
;               MACRO SHOWENABLED+SYS$LIBRARY:LIB/LIB
;               LINK  SHOWENABLED,SYS$SYSTEM:SYS.STB/SEL
;
;      INVOKE:
;               RUN SHOWENABLED
;
;---
        .sbttl data_declarations
 
        .psect  data, noexe
 
        $dcdef                  ; device class info
        $ucbdef                 ; unit control block info
        $ddbdef                 ; device data block info
        $prvdef                 ; define priv bits
        $devdef                 ; define device characteristic bits
 
priv_mask:
        .long   prv$m_cmkrnl    ;We need CMKRNL priv's to do this
        .long   0               ; No privs from the second longword are needed
 
bufsiz = 80
buffer: .blkw   bufsiz
bufdsc: .long   bufsiz                          ; fao output buffer
        .address buffer
 
faomsg1: .ascid /!%D Operator enabled on terminal !AC!ZW./
faomsg2: .ascid /!%D No operator terminals enabled./
 
maxops = 500                                    ; maximum number of ops
ttname: .blkl   maxops                          ; array of saved names
ttunit: .blkb   maxops                          ; array of saved units
ttcnt:  .long   0
 
;++
;
;
;--
 
        .sbttl  executable
        .psect code, exe,nowrt
 
        .entry main,^m<>
 
        $setprv_s #1,priv_mask  ; We want to enable (for duration of process)
                                ;the priv's specified by the mask (CMKRNL)
        cmpl    R0,#SS$_Normal  ;Did we do ok?
        beql    priv_ok         ; Yes, continue
        movl    #SS$_NOPRIV,r0  ; No, Indicate so
        ret                     ; and return to VMS
 
priv_ok:
        $cmkrnl_s routin=kernal1
 
        movl    ttcnt,r5
        tstl    r5
        beql    no_operators
 
        moval   ttname,r3
        moval   ttunit,r2
 
write:  $fao_s  outbuf=bufdsc, ctrstr=faomsg1,-
                p1=#0, p2=R3, p3=(R2)
 
        pushal  bufdsc
        calls   #1,g^lib$put_output
 
        addl    #2,r2
        addl    #4,r3
 
        sobgtr  r5,write
 
        $exit_s r0
 
no_operators:
        $fao_s  outbuf=bufdsc, ctrstr=faomsg2,-
                p1=#0
        pushal  bufdsc
        calls   #1,g^lib$put_output
 
        $exit_s r0
;
;
;
        .entry  kernal1,^m<r7,r8,r9>
        moval   nocrash,(fp)                    ;Establish a kernal mode
                                                ; excpetion handler.
 
        movl    ioc$gl_devlist,r9               ;Get first ddb
 
        clrl    r6                              ;Count of operators
 
5$:     clrl    r7                              ;Clear unit counter
        movl    ddb$l_ucb(r9),r8                ;Get first ucb on this ddb
        cmpb    ucb$b_devclass(r8),#dc$_term    ;Is this a terminal ddb/ucb?
        bneq    20$                             ;if neq, no
;
; Check all ucbs on all ddbs, if op bit is set, then save name of terminal,
; for output when we're not in kmode.
;
10$:    bbc     #dev$v_opr,ucb$l_devchar(r8),15$ ;Operator enabled on this ucb?
        movl    ddb$t_name(r9),ttname[r6]       ;get device name
        movw    ucb$w_unit(r8),ttunit[r6]       ;get unit name
 
        incl    r6                              ;Bump op count
        movl    r6,ttcnt                        ;Save it
 
15$:    incl    r7
        movl    ucb$l_link(r8),r8               ;Get next ucb
        tstl    r8                              ;More ucbs?
        bneq    10$                             ;if neq, yes
 
20$:    movl    ddb$l_link(r9),r9               ;Get next ddb
        tstl    r9                              ;More ddbs?
        bneq    5$                              ;if neq, yes
 
        movl    #ss$_normal,r0
        ret                                     ;back to caller
;
        .sbttl  KMODE_EXCEPTION_HANDLER
;
; Provides some reasonable safeguard against crashing your system.
; (From Bruce Elliot, thanks.)
;
reason: .long   80
        .address        10$
10$:    .blkb   80
 
control_reason:
        .ascid  /Access violation at VA = !XL & PC = !XL/
 
        .entry  nocrash,^m<r2>
        movl    4(ap),r2                ;Get address of signal array
        cmpl    4(r2),#ss$_accvio       ;if it's an access violation,
                                        ; display and get out.
        bneq    not_access_violation
        $fao_s  outbuf=reason,outlen=reason,ctrstr=control_reason,-
                p1=12(r2),p2=16(r2)
        pushal  reason
        calls   #1,g^lib$put_output     ;Display the reason for the crash.
        $exit_s                         ;kill the process
 
not_access_violation:
        movl    #ss$_resignal,r0        ;Pass the buck
        ret
 
        .END MAIN
---------- END CUT ------------------------------------------------------------
ARPA: RGERBER%NYBVX1.BITNET@WISCVM.WISC.EDU
BITNET: RGERBER@NYBVX1
CCNET: NYBVX1::RGERBER
 
*** There are no opions here, just facts - so a disclaimer is no necessary! ***
