/
/ New I/O.
/ Spool a file.
/

	.globl	fspool

SDAT	=	71. + [5.<<8.]
RQST	=	11. + [7.<<8.]
WSIG	=	49. + [1.<<8.]
GLUN	=	 5. + [3.<<8.]

PRT	=	63344
DOTS	=	131574

/
/ fspool(fp);
/ FILE *fp;
/ This routine calls fclose on the supplied
/ file pointer, then sends a message to the
/ print spooler to print it.
/ 0 is returned if all is ok. Otherwise the
/ DSW is returned.
/

fspool:	jsr	r0,_save
	sub	$32,sp
	mov	12(r5),r4

	mov	r5,-(sp)	/ Get `real' name of device.
	sub	$32,(sp)
	mov	V_LUN(r4),-(sp)
	mov	$GLUN,-(sp)
	emt	377
	bcc	0f
	mov	_dsw,r0
	br	1f

0:	mov	-32(r5),r2	/ Name
	mov	-30(r5),r3	/ Unit
	bic	$!377,r3

	mov	r5,r0		/ Make send packet.
	sub	$32,r0
	mov	r4,r1
	add	$V_FNAM,r1
	mov	(r1)+,(r0)+
	mov	(r1)+,(r0)+
	mov	(r1)+,(r0)+
	mov	(r1)+,(r0)+
	mov	(r1)+,(r0)+
	mov	r2,(r0)+
	mov	r3,(r0)+
	mov	r4,r1
	add	$V_FID,r1
	mov	(r1)+,(r0)+
	mov	(r1)+,(r0)+
	mov	(r1)+,(r0)+
	mov	r4,r1
	add	$V_DID,r1
	mov	(r1)+,(r0)+
	mov	(r1)+,(r0)+
	mov	(r1)+,(r0)+

	mov	r4,(sp)		/ Close file.
	call	fclose

0:	clr	-(sp)		/ No flag.
	mov	r5,-(sp)	/ Buffer
	sub	$32,(sp)
	mov	$DOTS,-(sp)	/ PRT...
	mov	$PRT,-(sp)
	mov	$SDAT,-(sp)
	emt	377		/ Send message to spooler.
	bcc	0f
	mov	_dsw,r0
	cmp	r0,$IE.UPN
	bne	1f
	mov	$WSIG,-(sp)
	emt	377
	br	0b

0:	mov	_uic,-(sp)	/ UIC for RQST$
	clr	-(sp)		/ Priority
	clr	-(sp)		/ Partition
	clr	-(sp)
	mov	$DOTS,-(sp)	/ PRT...
	mov	$PRT,-(sp)
	mov	$RQST,-(sp)	/ D.I.C.
	emt	377		/ Goose the spooler.
	bcc	0f
	mov	_dsw,r0
	cmp	r0,$IE.UPN
	bne	1f
	mov	$WSIG,-(sp)
	emt	377
	br	0b

0:	clr	r0
1:	jmp	_ret
