From:	SMTP%"MACRO32%WKUVX1.BITNET@uu7.psi.com"  7-MAY-1993 09:32:55.34
To:	EVERHART
CC:	
Subj:	OPCOM stuff:  ENABLE.FOR  (Old OPCOM interface.)

Message-Id: <9305070415.AA11223@uu7.psi.com>
X-Listname: "VMS Internals, MACRO, & BLISS Discussions" <MACRO32@WKUVX1.BITNET>
Warnings-To: <>
Errors-To: MacroMan%WKUVX1.BITNET@uu7.psi.com
Sender: MacroMan%WKUVX1.BITNET@uu7.psi.com
Date: Thu,  6 May 93 09:27 PST
From: "Derek S. Haining, Univ. of Washington, (206) 543-5579"
      <DEREK%MAX.BITNET@uu7.psi.com>
Reply-To: MACRO32%WKUVX1.BITNET@uu7.psi.com
Subject: OPCOM stuff:  ENABLE.FOR  (Old OPCOM interface.)
To: MACRO32@WKUVX1.BITNET
Original_To:  JNET%WKUVX1::MACRO32


        PROGRAM ENABLE TAPE OPERATOR TERMINAL

        INCLUDE '($DVIDEF)      /NOLIST'
        INCLUDE '($OPCDEF)      /NOLIST'

! Structures for $GETJPI
        CHARACTER  *  12        the_user

        INTEGER    *   4        jpilist ( 4 ), SYS$GETJPI, pid
        INTEGER    *   2        jpiword ( 8 )

        EQUIVALENCE             ( jpilist, jpiword )
        EXTERNAL                JPI$_USERNAME

! Structures for $SNDOPR
        STRUCTURE       /MESSAGE/
           UNION
              MAP
                BYTE            type, enable (3)
                INTEGER   *  4  mask
                INTEGER   *  2  ounit
                CHARACTER * 14  oname
              END MAP
              MAP
                CHARACTER * 24  string
              END MAP
           END UNION
        END STRUCTURE

        RECORD  /MESSAGE/       msgbuf

        INTEGER * 4     oname_length
        INTEGER * 4     status
        INTEGER * 4     LIB$GETDVI
        INTEGER * 4     SYS$SNDOPR

C  -------------------------------------------------------

        JPIWORD ( 1 )  =  LEN  ( the_user )
        JPIWORD ( 2 )  =  %LOC ( JPI$_USERNAME )
        JPILIST ( 2 )  =  %LOC ( the_user )
        JPILIST ( 3 )  =  0
        JPILIST ( 4 )  =  0


        status = SYS$GETJPI ( ,,,JPILIST,,, )
        IF (.NOT. status) CALL SYS$EXIT (%VAL (status))

        IF ((the_user .NE. 'PREVIEW     ') .AND.
     >      (the_user .NE. 'DEREK       ')) CALL EXIT

!  Format the operator request.
        msgbuf.type       = OPC$_RQ_TERME
        msgbuf.enable (1) = 1
        msgbuf.mask       = OPC$M_NM_TAPES

        status = LIB$GETDVI (DVI$_UNIT,, 'SYS$OUTPUT', msgbuf.ounit,,)
        IF (.NOT. status) CALL LIB$SIGNAL (%VAL (status))

        status = LIB$GETDVI (DVI$_FULLDEVNAM,, 'SYS$OUTPUT',,
     >                       msgbuf.oname, oname_length)
        IF (.NOT. status) CALL LIB$SIGNAL (%VAL (status))

        status = INDEX (msgbuf.oname, '$') + 1

        DO status = status, oname_length, 1
           IF ((msgbuf.oname (status:status) .GE. '0') .AND.
     >         (msgbuf.oname (status:status) .LE. '9')) THEN
                oname_length = status - 1
                GOTO 100
           ENDIF
        END DO

100     CONTINUE
!  Shift the device name right one byte to create a counted string.
        msgbuf.oname (2:)  = msgbuf.oname (1:oname_length)
        msgbuf.oname (1:1) = CHAR (oname_length)

!  Enable the terminal
        status = SYS$SNDOPR (msgbuf.string,)
        CALL SYS$EXIT (%VAL (status))

        END
