.mcall	.module
.module	CI, release=V01, version=06, comment=<CLI Handleroid>, audit=yes
.rem	|
------------------------------------------------------------------------------
Another handleroid brought to you by:

	William K. Walker
	Monsanto Research Corp.
	P. O. Box 32   A-152
	Miamisburg, OH  45342
	(513) 865-3557

This handleroid allows you to turn the various RT-11 Command Line Interpreters
(CLI's) on or off using SET commands.  It will also show which CLI's are
enabled.  There are four CLI's: UCF (User Commands First), DCL (Digital
Command Language), CCL (Concise Command Language), and UCL (User Command
Linkage).  Refer to the documentation for RT-11 V05.02 for an explanation of
each.  The possible SET commands for the CI (Command Interpreter) handleroid
are:

	SET CI [NO]UCF	--  turn UCF on/off
	SET CI [NO]DCL	--  turn DCL on/off
	SET CI [NO]CCL	--  turn CCL on/off
	SET CI [NO]UCL	--  turn UCL on/off
	SET CI HELP	--  display SET commands and version/release of CI
	SET CI RESET	--  same as SET CI NOUCF,DCL,CCL,UCL
	SET CI SHOW	--  display the active CLI's

By default, RT-11 has all CLI's enabled except UCF.  In other words, the
normal situation is equivalent to

			SET CI NOUCF,DCL,CCL,UCL

Thus, if you issued a SET CI SHOW command under an unaltered monitor, CI would
report

			?CI-I-CLI's enabled: DCL CCL UCL

Note that SET CI RESET restores/insures the above default condition.

It is not possible to INSTALL CI.  This is because CI contains only SET code.
As there is no executable handler code, there is no reason why CI should be
installable -- it would just waste a device slot in the monitor tables that
could be used for something else.  The monitor will execute the SET options as
long as CI has the right name and resides on SY:.  Thus, for the RT-11 SJ and
FB monitors, the file should be SY:CI.SYS.  If you are going to use it under
XM, make a copy named SY:CIX.SYS.

NOTE:  CI will not run under versions of RT-11 prior to V05.02.  I don't go to
the trouble of checking for TSX-Plus, so if you try to use CI with TSX it's
your funeral.

*****************************************************************************
* WARNING:  Turning off both DCL and CCL effectively turns off the monitor. *
*****************************************************************************
-----------------------------------------------------------------------------|
jsw	= 44	;Address of job status word
edit$	= 20	;JSW disable SL editor bit
sysver	= 276	;Offset to RT-11 version/release data
$inddv	= 426	;RMON fixed offset pointer to IND device name, unit

ucf$	= 1	;CLI enable bits in CLIFLG byte...
dcl$	= 2
ccl$	= 4
ucl$	= 10

lf	= 012	;Linefeed
cr	= 015	;Carriage return

.mcall	.addr, .assume, .drdef, .gtlin, .print

.drdef	ci, 377, ronly$!wonly$, 0, 0, 0

; "Installation" code...

	.drins	ci
	nop
	sec		;Always fail to install...
	return

; SET option tables...

	.drset	  UCF,             ucf$, o.ucf, no
	.drset	  DCL,             dcl$, o.dcl, no
	.drset	  CCL,             ccl$, o.ccl, no
	.drset	  UCL,             ucl$, o.ucl, no
	.drset	 HELP,                1, o.help
	.drset	RESET, <dcl$!ccl$!ucl$>, o.rset
	.drset	 SHOW,                5, o.show

; SET CI [NO]UCF, [NO]DCL, [NO]CCL, [NO]UCL

o.ucf:
o.dcl:
o.ccl:
o.ucl:	br	o.set		;Branch to code to turn a CLI on
	nop
o.clr:	call	o.ciwd		;R0 => 1 word past CLIFLG/CLITYP word
	mov	-(r0),r1	;Save CLIFLG/CLITYP value
	mov	r0,-(sp)	;Save CLIFLG/CLITYP address on stack
	bic	#^C<6>,r1	;Mask for DCL, CCL bits
	bic	r3,r1		;See if we would have neither
	bne	10$		;Branch if at least one left active
	bis	#edit$,@#jsw	;Disable SL editor
	.addr	#mwarn,r2	;R2 => warning message
	mov	#250,r1		;R1 => input buffer
	.gtlin	r1,r2		;Issue warning, get response
	bicb	#^C<137>,(r1)	;Did the idiot answer "yes"?...
	cmpb	(r1),#'Y
	bne	20$		;Just go quit if not
	mov	pc,r0		;Issue Pontius Pilate message...
	add	#mstupd-.,r0
	.print
10$:	bic	r3,@(sp)	;Clear requested bit
20$:	tst	(sp)+		;Clean up the stack
	br	o.good		; and quit

o.set:	call	o.ciwd		;R0 => 1 word past CLIFLG/CLITYP word
	bis	r3,-(r0)	;Turn on the selected CLI
	return

; SET CI RESET

o.rset:	call	o.ciwd		;R0 => 1 word past CLIFLG/CLITYP word
	bis	r3,-(r0)	;Restore default CLI's...
	bic	#1,(r0)
	return

; SET CI HELP

o.help:	mov	pc,r0		;Calculate address of help test...
	add	#mhelp-.,r0
	.print			;Print it
	br	o.good		;Quit with carry clear

; SET CI SHOW

o.show:	call	o.ciwd		;Make R0 point at INDDEV (1 word past CLIFLG)
	mov	-(r0),r2	;Put CLIFLG/CLITYP word in R2
	.addr	#m,r1		;"...CLI's enabled:"...
	.print	r1
	add	#m1-m,r1	;Point at first one to check...
	br	20$
10$:	add	#m2-m1-1,r1	;Point at next
20$:	bitb	(r1)+,r2	;This CLI active?
	beq	30$		;Branch if not
	.print	r1		;Otherwise, print following text
30$:	sob	r3,10$		;Go look at next one until done
	br	o.good		;Quit with no error

; Routine to check for RT-11 version and return with address of INDDEV in R0.

o.ciwd:	.addr	#o.area,r1	;Get version/release of RT-11 (pic-style)...
	mov	r1,r0
	emt	375

	swab	r0		;Are we running V05.02 or later?...
	cmp	r0,#<5*400!2>
	bge	10$		;Branch if so
	add	#10,r1		;If not, point R1 at error message
	.print	r1		;"...Wrong version of RT-11"
	tst	(sp)+		;Pop stack to force a return to monitor
	br	o.bad		;Go quit

10$:	add	#4,r1		;Get pointer to INDDEV word
	mov	r1,r0		; (1 word past CLIFLG)...
	emt	375
o.good:	tst	(pc)+		;Return with carry clear...
o.bad:	sec
	return

.assume	. le 1000	message=<;*** SET CODE IS TOO LARGE ***>

	.drbeg	ci
ciint::	.drfin	ci
	.drend	ci

; Data area...don't mess with the order of this stuff!!!

o.area:	.byte	0, 34		;Argument area for EMT's used by O.CIWD...
	.word	sysver
	.byte	0, 34
	.word	$inddv
	.nlist	bex
	.nlcsi	type=i, part=prefix	;ASCII stuff...
	.asciz	"F-Wrong version of RT-11"
m:	.nlcsi	type=i,part=prefix
	.ascii	"I-CLI's enabled:"<200>
m1:	.ascii	< 1>" UCF"<200>
m2:	.ascii	< 2>" DCL"<200>
	.ascii	< 4>" CCL"<200>
	.ascii	<10>" UCL"<200><17><0>
mhelp:	.byte	cr, lf
	.nlcsi	type=i
	.byte	cr, lf, lf
	.ascii	"SET CI [NO]UCF -- turn UCF on/off"<cr><lf>
	.ascii	"SET CI [NO]DCL -- turn DCL on/off"<cr><lf>
	.ascii	"SET CI [NO]CCL -- turn CCL on/off"<cr><lf>
	.ascii	"SET CI [NO]UCL -- turn UCL on/off"<cr><lf>
	.ascii	"SET CI HELP    -- display this text"<cr><lf>
	.ascii	"SET CI RESET   -- same as SET CI NOUCF,DCL,CCL,UCL"<cr><lf>
	.asciz	"SET CI SHOW    -- display active CLI's"
mwarn:	.ascii	"Disable access to monitor commands/utilities; "
	.ascii	"Are you sure? "<200>
mstupd:	.ascii	"OK...it's your funeral!"
	.even
	.list	bex

.assume <.-cistrt> le 1000	message=<;*** EXCEEDED HANDLER BLOCK 1 ***>
	.end
