From:	MERC::"uunet!WKUVX1.BITNET!MacroMan" 22-MAY-1992 19:21:27.21
To:	MACRO32@WKUVX1.BITNET
CC:	
Subj:	loginout_hack.share (2/2)

-+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+
X`009CMPL`009R1,#`094x7FFEDF68`009`009;*CROCK* is it the new SYS$IMGSTA?
X`009BEQL`00930$`009`009`009;If EQL yes, don't call it.
X`009CALLG`009(AP),(R1)`009`009;Else call this entry point
X`009BLBC`009R0,40$`009`009`009;Lossage!
X
X30$:`009SOBGTR`009R3,20$`009`009`009;Loop through the entire array
X`009MOVL`009#SS$_NORMAL,R0`009`009;Success
X
X40$:`009BRW`009ERROR_EXIT`009`009;Lossage.
X
X`009.Page
X`009.Subtitle`009CTSS_LOGIN`009- Grab a CTSS login line
X
X;+
X;
X; ----- CTSS_LOGIN:  Grab a CTSS login line
X;
X;
X; This routine is called to collect the CTSS login line.  We display
X; the herald message (if we have one) and prompt for input.  If the
X; user types  `094\ then we'll return and crank the real loginout.  If
X; the user  types `094Z then we'll  exit.  Otherwise we take what gets
X; typed  and fire it  off to the gateway,  who  will grab  onto our
X; terminal and do its thing.
X;
X; Inputs:
X;
X;`009None.
X;
X; Outputs:
X;
X;`009As described above.
X;
X;-
X
XCTSS_LOGIN:`009`009`009`009;Grab a CTSS login line
X
X; Get a channel to our SYS$INPUT.
X
X`009$ASSIGN_S DEVNAM=SYS$INPUT,-`009;Get a channel
X`009`009CHAN=TT_CHAN`009`009; to our terminal
X
X; Get an out-of-band AST for `094\.
X
X`009MOVAL`009OOB_MASK,R1`009`009;Address the OOB mask
X`009$QIOW_S`009CHAN=TT_CHAN,-`009`009;Get an out-of-band AST
X`009`009FUNC=#IO$_SETMODE!IO$M_OUTBAND!IO$M_TT_ABORT,- ;(abort the read)
X`009`009P1=OOB_AST,-`009`009;AST here
X`009`009P2=R1`009`009`009;Here's the OOB mask
X
X; Translate SDSC$CTSS_HERALD and if there is one then dump it out onto
X; the terminal.
X
X`009$TRNLNM_S LOGNAM=HERALD,-`009;Translate this logical name
X`009`009TABNAM=LNM$PROCESS,-`009;Translate from this table
X`009`009ITMLST=LNM_LIST`009`009;Get this stuff.
X`009MOVL`009HERALD_LENG,R1`009`009;Anything to say?
X`009BEQL`00910$`009`009`009;If EQL no.
X`009$QIOW_S`009CHAN=TT_CHAN,-`009`009;Else say it.
X`009`009FUNC=#IO$_WRITELBLK,-`009;Write
X`009`009P1=HERALD_BUFF,-`009; this
X`009`009P2=R1,-`009`009`009;  message
X`009`009P4=#`094x01020000`009`009;(carriage control)
X
X; Start building the message we'll send to the gateway.  Stuff in the physic
Val
X; device name as a counted string.
X
X10$:`009MOVAB`009MBX_BUFF,R3`009`009;Address our mailbox message buffer
X`009MOVL`009R3,R6`009`009`009;Twice.
X`009MOVB`009DEV_LENG,(R3)+`009`009;Stuff the device name length
X`009MOVC3`009DEV_LENG,DEVICE,(R3)`009;Copy the device name
X
X; Next, prompt the user and collect a CTSS login line.  Exit if:
X;
X;`009- we time out.
X;`009- the user types `094Z
X
X20$:`009MOVAB`009PROMPT,R1`009`009;Address our prompt
X`009MOVZBL`009(R1)+,R0`009`009;Get the length
X`009$QIOW_S`009CHAN=TT_CHAN,-`009`009;Read
X`009`009FUNC=#IO$_READPROMPT!IO$M_TIMED,- ; with prompt`032
X`009`009IOSB=IOSB,-`009`009;I/O status here
X`009`009P1=1(R3),-`009`009;Buffer here
X`009`009P2=#128,-`009`009;Up to this much stuff
X`009`009P3=LGI_PWD_TMO,-`009;Timeout after this long
X`009`009P5=R1,P6=R0`009`009;Prompt address & length
X`009BLBC`009R0,40$`009`009`009;Eh?
X`009MOVZWL`009IOSB,R0`009`009`009;Check here, too
X`009BLBC`009R0,40$`009`009`009;Eh?
X
X; Check for a `094Z terminator.
X
X`009CMPB`009#`094x1A,IOSB+4`009`009;`094Z?
X`009BNEQ`00930$`009`009`009;Nope go try for the `094\
X`009BRW`009ERROR_EXIT`009`009;Yep, lose now.
X
X; Check for AST`032
X
X30$:`009BLBS`009AST_HIT,60$`009`009;Did OOB_AST hit? If so go login.
X
X40$:`009BLBC`009R0,ERROR_EXIT`009`009;If LBC then error
X
X; Copy the user's input into the mailbox message buffer.
X
X`009MOVZBL`009IOSB+2,R0`009`009;Any input?
X`009BNEQ`00950$`009`009`009;Go get length
X`009BRW`00920$`009`009`009;If EQL, ask again
X
X; Check for VMS or UNICOS from Netty
X
X50$:`009BICB3`009#<`094a"a"-`094a"A">,1(R3),R1`009;Upcase the input
X`009CMPB`009#`094a"U",R1`009`009;UNICOS?
X`009BEQL`00960$`009`009`009;If EQL yes, fake a `094\
X`009CMPB`009#`094a"V",R1`009`009;VMS?
X`009BEQL`00960$`009`009`009;If EQL yes, fake a `094\
X`009MOVB`009R0,(R3)+`009`009;Stash the length
X`009ADDL`009R0,R3`009`009`009;Compute the
X`009SUBL`009R6,R3`009`009`009; final length
X
X; Fire the message off to the CTSS gateway.  Once the gateway has set things
V up
X; for this connection it will just $DELPRC us ...
X
X`009$SCHDWK_S DAYTIM=DELTA_30`009;Schedule a wakeup in 30 seconds just in ca
Vse
X`009$QIO_S`009CHAN=MBX_CHAN,-`009`009;Fire the
X`009`009FUNC=#IO$_WRITELBLK,-`009; message off
X`009`009P1=(R6),P2=R3`009`009;  to the gateway
X`009$HIBER_S`009`009`009;Hibernate
X
X; If we get here the gateway didn't respond.  Argh.
X
X`009MOVZWL`009#SS$_TIMEOUT,R0`009`009;Die with
X`009BRB`009ERROR_EXIT`009`009; a timeout
X
X; Here to crank the real loginout.
X
X60$:`009RSB`009`009`009`009;Just crank the real loginout.
X
X; Out-of-band AST service routine for `094\
X
XOOB_AST: .Word`0090`009`009`009;World's 2nd shortest AST routine
X
X`009MNEGL`009#1,AST_HIT`009`009;Bang!
X`009RET`009`009`009`009;That's easy
X
X`009.Page
X`009.Subtitle`009ERROR_EXIT`009- Error exit
X
X;+
X;
X; ----- ERROR_EXIT:  Error exit
X;
X;
X; This routine is called to display an error message on SYS$OUTPUT
X; and then exit.
X;
X; Inputs:
X;
X;`009R0`009- Error code
X;
X; Outputs:
X;
X;`009Error text displayed and program exits with status.
X;
X;-
X
XERROR_EXIT:`009`009`009`009;Error exit
X
X`009BSBW`009LOSE_SYSPRV`009`009;Lose SYSPRV if necessary
X`009BISL3`009#STS$M_INHIB_MSG,R0,R2`009;Save the error code
X`009BBS`009#STS$V_INHIB_MSG,R0,10$`009;Inhibit message?
X`009BLBS`009R0,10$`009`009`009;Error?
X`009$GETMSG_S MSGID=R0,-`009`009;Get the error message text
X`009`009MSGLEN=OUT_DESC,-`009;Return the length here
X`009`009BUFADR=OUT_DESC,-`009;Here's the output buffer
X`009`009FLAGS=#1`009`009;Text only
X`009PUSHAQ`009OUT_DESC`009`009;Stack the descriptor address
X`009CALLS`009#1,G`094LIB$PUT_OUTPUT`009;Display same
X
X10$:`009$EXIT_S`009R2`009`009`009;Exit with status
X
X`009.Page
X`009.Subtitle`009LOSE_SYSPRV`009- Lose SYSPRV if we don't deserve it
X
X;+
X;
X; ----- LOSE_SYSPRV:  Lose SYSPRV if we don't deserve it
X;
X;
X; This routine will lose SYSPRV if we don't deserve to have it (not in
X; our process privilege mask and we don't have a system UIC).
X;
X; Inputs:
X;
X;`009UIC_GROUP`009- Our UIC group
X;`009MAXSYSGROUP`009- The maximum system UIC group
X;`009PROCPRIV`009- Our process default privilege mask
X;
X; Outputs:
X;
X;`009SYSPRV disabled unless we deserve it.
X;
X;-
X
XLOSE_SYSPRV:`009`009`009`009   ;Lose SYSPRV if we don't deserve it
X
X`009BBS`009#PRV$V_SYSPRV,PROCPRIV,10$ ;Branch if we have it
X`009CMPL`009UIC_GROUP,MAXSYSGROUP`009   ;Do we have a system UIC?
X`009BLEQ`00910$`009`009`009   ;If LEQ yes
X`009$SETPRV_S ENBFLG=#0,PRVADR=SYSPRV  ;Lose SYSPRV otherwise
X
X10$:`009RSB`009`009`009`009   ;Done
X
X`009`009
X
X`009.End`009START
$ CALL UNPACK LOGINOUT_HACK.MAR;28 741968244
$ v=f$verify(v)
$ EXIT
--
gkn     Gerard K. Newman        gkn@tgv.com     619.591.4717 (voice/fax)
        TGV, Inc.               ucsd!gkn        408.427.4366
        603 Mission Street
        Santa Cruz, CA  95060
