[mod.computers.vax] DCL Command line buffer flushing

nagy%43198.hepnet@LBL.ARPA.UUCP (04/10/87)

**** The following files come from the VAX86C SIG tape *********
$$$$$$$$$$$$$$$$$$$$ cut here for file AAAREADME.1ST $$$$$$$$$$$$$$$$$
This program causes the recall command buffer to be flushed. It
might be desirable to flush this buffer if it contained an access
control string, or some other sensitive information.

FLUSH requires change mode to executive privilege, and must be linked
with SYS$SYSTEM:DCLDEF.STB and SYS$SYSTEM:SYS.STB. FLUSH should
NOT be run via LIB$DO_COMMAND, LIB$SPAWN, $CREPRC, in a batch job, 
with a CLI other than DCL, etc.

The files in this directory include:

	FLUSH.MAR     - Source code for FLUSH
	FLUSH.OBJ     - Compiled code
	FLUSH.EXE     - Linked code.
	BLD.COM       - DCL procedure to assemble and link FLUSH
	AAAREADME.TXT - This file

The author listed below welcomes any questions or suggestions:

	Mark Oakley
	Battelle Memorial Institute
	505 King Ave
	Columbus, Ohio  43201-2693

	(614) 424-7154

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ cut here for BLD.COM $$$$$$$$$$$$$$$$$$$$$$$
$ MACRO/LIST       FLUSH
$ LINK/MAP/NOTRACE FLUSH,SYS$SYSTEM:DCLDEF.STB/SEL,SYS.STB/SEL
$ EXIT
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$cut here for FLUSH.MAR $$$$$$$$$$$$$$$$$$$$$$$$$
	.TITLE FLUSH Flush recall buffer
	.IDENT	/1.0/
;++
;
; Title:
;	FLUSH.MAR - Flush the recall buffer.
;
; Version:
;	1.0
;
; Facility:
;	User management tool.
;
; Abstract:
;	This program flushes the recall buffer of a process.
;
; Environment:
;	Change mode to executive required;
;	must be linked with SYS$SYSTEM:DCLDEF.STB;
;		=> DON'T invoke via a LIB$DO_COMMAND, LIB$SPAWN, 
;		   $CREPRC, in a batch job, with a CLI other than DCL, etc.
;
; Author:
;	Mark Oakley	Battelle Memorial Institute	09-Dec-1985
;
; Modified:
;	
; 23-May-1986	Mark Oakley	Modified to use CLI and PPD symbols, instead
;				of relying on R11. Also, check for job mode,
;				output device, CLI, and access to buffer, to 
;				make sure we have a command buffer to flush.
;
;--

	.SBTTL	Symbols, Macros, and Data Structures
	.PSECT	FLUSH_DATA RD,WRT,NOEXE,PAGE,SHR,PIC

	$DCDEF		; Device class (disk, terminal, etc.) symbols
	$DVIDEF		; Device information symbols
	$IODEF		; I/O symbols
	$JPIDEF		; Job process symbols
	$SSDEF		; Termination symbols

;
; Macro to handle return codes.
;
	.MACRO	ON_ERR	THERE,?HERE
	BLBS	R0,HERE
	BRW	THERE
HERE:	.ENDM	ON_ERR

MODE_ITMLST:			; JPI item list to determine if we
	.WORD	 4		; are interactive.
	.WORD	 JPI$_MODE
	.ADDRESS MODE
	.LONG	 0
	.LONG 	 0

MODE:				; Mode of job (interactive, batch, etc.).
	.BLKL	1

COMM_DEV:			; Name of device which commands come from.
	.ASCID	/SYS$COMMAND/

DVI_ITMLST:			; Determine what class of output device
	.WORD	 4		; we have (terminal, disk, etc.).
	.WORD	 DVI$_DEVCLASS
	.ADDRESS DEVICE_CLASS
	.LONG	 0
	.LONG	 0

DEVICE_CLASS:			; Terminal, disk, etc.
	.BLKL	1

IOSB:				; Status block for I/O.
	.BLKQ	1

DCL:				; Need to have "DCL" CLI.
	.ASCII	/DCL/

	.SBTTL	Code
	.PSECT	FLUSH_CODE RD,NOWRT,EXE,PAGE,SHR,PIC
	.ENTRY	FLUSH,^M<R2,R3,R4,R5,R6,R7,R8,R9>

	$GETJPI_S -				; Determine mode of this
		ITMLST=MODE_ITMLST,-		; process.
		IOSB=IOSB
	ON_ERR	FLUSH_EXIT
	MOVZWL	IOSB,R0
	ON_ERR	FLUSH_EXIT

	CMPL	#JPI$K_INTERACTIVE,MODE		; Are we running interactively?
	BEQL	20$
	BRW	FLUSH_EXIT			; No, bail out.

20$:
	$GETDVI_S -				; See if we are talking to a 
		DEVNAM=COMM_DEV,-		; terminal.
		ITMLST=DVI_ITMLST,-
		IOSB=IOSB
	ON_ERR	FLUSH_EXIT
	MOVZWL	IOSB,R0
	ON_ERR	FLUSH_EXIT

	CMPL	#DC$_TERM,-			; Are we a terminal?
		DEVICE_CLASS
	BEQL	40$
	MOVL	#SS$_NORMAL,R0			; No, bail out.
	BRW	FLUSH_EXIT

40$:
	MOVZBL	CTL$GT_CLINAME,R6
	CMPC3	R6,CTL$GT_CLINAME+1,DCL		; Is the CLI "DCL"?
	BEQL	60$
	MOVL	#SS$_NORMAL,R0
	BRW	FLUSH_EXIT			; No, bail out.

60$:
	MOVL	CTL$AG_CLIDATA+PPD$Q_CLIREG+4,-	; Get addr of CLI/DCL data.
		R11				; Is greater than zero?
	BGTR	80$
	BRW	FLUSH_EXIT			; No, bail out.

80$:
	MOVAL	PRC_L_RECALLPTR(R11),R7		; Get addr of recall buf ptr.
	MOVL	R7,R8				; Save this addr.
	PROBER	#3,#PRC_C_CMDBUFSIZ,4(R8)	; Can we access this area?
	BNEQ	100$
	MOVL	#SS$_NORMAL,R0			; No, bail out, but return
	BRW	FLUSH_EXIT			; success.

100$:
	$CMEXEC_S -				; Need to do the rest in
		ROUTIN=ZERO_RECALL_BUFFER	; exec mode.
	ON_ERR	FLUSH_EXIT

FLUSH_EXIT:
	RET


;
; This exec-mode routine actually does the zeroing-out.
;

ZERO_RECALL_BUFFER:
	.WORD	0

	MOVC5	#0,.,#0,#PRC_C_CMDBUFSIZ,4(R7)	; Zero out the command buffer.
	ADDL3	#4,R7,(R7)			; Set recall buf ptr to 
						; beginning of recall buffer.

	MOVL	#SS$_NORMAL,R0			; Assume success.
	RET

	.END	FLUSH