Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-05 - 43,50337/24/findin.mac
There are 2 other files named findin.mac in the archive. Click here to see a list.
Comment * SIMULA specification;
OPTIONS(/E:CODE,findinfile);
REF(Infile)PROCEDURE findinfile(filespec);
VALUE filespec; TEXT filespec;
COMMENT If an Infile according to the specification can be opened,
then return a file ref, otherwise NONE;

! *;! MACRO-10 code *;!

	TITLE	findinfile
	SUBTTL	SIMULA utility, Lars Enderin Oct 1975

;!*** Copyright 1975 by the Swedish Defence Research Institute. ***
;!*** Copying is allowed.					***

	ENTRY	findinfile
	sall
	search	simmac,simmcr,simrpa
	macinit

	result==ZBI%S
	filespec==result+1
	.ACRED==5	;! Parameter to signify read access to CHKACC
	OPDEF	CHKACC	[CALLI	100]

findinfile:
	PROC
	EXEC	CPNE	;! Allocate a file object
	XWD	0,IOIN	;! Infile prototype
	SETON	ZFIFND(XWAC1)	;! Flag special case
	LD	X0,filespec(XCB)	;! Copy the parameter
	STD	X0,OFFSET(ZFISPC)(XWAC1)
	EXEC	CSEN
	IF	;! Found
		IFOFF	ZIFEND(XWAC1)
		GOTO	FALSE
	THEN	;! Check access rights further
		LF	XWAC4,ZFIPT(XWAC1)
		IFON	ZFIDE(XWAC1)
		LF	XWAC4,ZXBPT(XWAC1)
		HRLI	XWAC4,.ACRED	;! Read access to be checked
		CALLI	XWAC5,24	;! User ppn
		 CAI	;! In case of JACCT
		SKIPN	XWAC6,OFFSET(ZFIPPN)(XWAC1)	;! File ppn
		L	XWAC6,XWAC5
		LI	XWAC4
		CHKACC
		SETZ	;! Assume access allowed on error return
		JUMPN	FALSE
		ST	XWAC1,result(XCB)
		SETOFF	ZFIFND(XWAC1)
	ELSE	;! Close to get rid of core claimed etc
		EXEC	IOCL
	FI
	BRANCH	CSEP
	EPROC
	END;