	.title	rclose 	Disconnect a stream number
	.ident	"V02.00"
;+
; Index		Disconnect a stream number
;
; Usage
;
;	rclose(stream, options)
;	int stream;          /* Stream number to disconnect */
;	char *options;       /* String of options */
;
; Description
;
;	rclose() disconnects a stream number from a file. It returns 1
;	if successful and 0 if an error occurred.
;
; 	Options:
;	     m - mark file for delete on final
;		 stream disconnect.
;	     s - send file to spooler if dprot
;		 is PROTECTED or EXCLUSIVE and file
;		 is ASCII sequential.
;	     t - truncate file to logical end-of-file
;		 if dprot is EXCLUSIVE.
;-
; Edit History
; V02.00 18-Oct-82 TTC		Rework of old CS library
;

	.MCALL	FSDEF$
	FSDEF$

	.psect	c$strn
;
; Disconnect options.
;
mark:	.ascii	"m"
spool:	.ascii	"s"
trunc:	.ascii	"t"
	.even

	.psect	c$data
;
; Disconnect option table.
;
clopt:	.word	mark,	O.MKD
	.word	spool,	O.SPL
	.word	trunc,	O.TRN
	.word	0

	.psect	c$code
rclose::
	mov	4(sp),r0		; r0 --> list of passed options
	mov	#clopt,r1		; r1 --> option table
	call	option			; check options
	tst	r0			; error?
	beq	20$			; (Yes)
	mov	#fsqio+q.iopl,r0	; r0 --> fsqio parameter list
	call	prmclr			; Clear parameter list
	mov	#fsqio,r0		; r0 --> fsqio for xqiow
	mov	#FS.DIS,q.iofn(r0)	; Function: FS.DIS
	mov	2(sp),q.iopl(r0)	; Parameter #1: Stream Number
	mov	r1,q.iopl+12(r0)	; Parameter #6: Incl-or of opts
	call	.xqiow			; execute qiow
	mov	#1,r0			; Assume successful
	cmp	$dsw,#is.suc		; How'd it go
	blo	10$
	cmpb	f.iosb,#is.suc
	beq	20$
10$:	clr	r0			; Branch here if error, r0 = 0
20$:	return
	.end
