perm filename BAZ[10X,AIL]1 blob sn#148069 filedate 1975-03-03 generic text, type T, neo UTF8
COMPIL(GTJFN,<GTJFN,GTJFNL>,<.SKIP.,SETCHN,CATCHR,X11,X22,X44>,<GTJFN -- GET A JFN>)
DSCR INTEGER SIMPLE PROCEDURE GTJFN(STRING S; INTEGER FLAGS)
	Does a GTJFN.  If S is non-null, it is the filename, otherwise
the routine goes to the user's console for a file.  FLAGS are used for
accumulator 1, and any error code is returned in .SKIP.  The value
of the call is the JFN, if obtained.
	Defaults for FLAGS:  0  means ordinary input, 1 means ordinary
output.  Ordinarily the user will use the OPENFI routine.
⊗

HERE(GTJFN)
	SKIPN 	1,-1(P)
	   MOVSI 1,100001
	CAIN	1,1
	   MOVSI 1,600001	
	TLO	1,1			;MARK FOR SHORT CALL
	HRRZ	2,-1(SP)
	JUMPE	2,[MOVE 2,[100000101]
		  TLO	1,2		;INDICATE XWD JFN,JFN IN 2
		   JRST GOTDEST]
	TLZ	1,2			;INDICATE BYTE-POINTER IN 2
	PUSH	P,[0]			
	PUSHJ	P,CATCHR		;PUT ON A NULL
	MOVE	2,(SP)
GOTDEST: SETZM	.SKIP.			;ASSUME NO ERROR
	PUSH	P,1			;SAVE FLAGS
	JSYS GTJFN
	  JRST GTBAD 		; SOMETHING IS WRONG
	PUSHJ	P,SETCHN	;SETUP A CHANNEL, AND ALLOCATE, GET STATUS, SET CDB
	POP	P,GFL(CDB)	;SAVE FLAGS
GTRET:	SUB	SP,X22
	SUB	P,X22
	JRST	@2(P)

GTBAD:
	
	MOVEM 	1,.SKIP.		; REMEMBER
	POP	P,1			;ADJUST STACK
	SETO 	1, 		; SOMETHING SUSPICIOUS TO RETURN TO USER
	JRST	GTRET
DSCR SIMPLE PROCEDURE OPENF(INTEGER JFN,FLAGS)
	Does an OPENF.

PARAMETERS:
	JFN     the JFN
	FLAGS 	for accumulator 2.
	.SKIP.	the error code (if pertinent)

Some defaults:
	FLAGS		ACTION
	-----------------------
	0		INPUT CHARACTERS
	1		OUTPUT CHARACTERS
	2		INPUT 36-BIT WORDS
	3		OUTPUT 36-BIT WORDS
	4		DUMP MODE INPUT (USE DUMPI FUNCTION)
	5		DUMP MODE OUTPUT (USE DUMPO FUNCTION)
	VALUES 6-10 ARE RESERVED FOR EXPANSION

Other values of FLAGS are interpreted literally.
	Ordinarily the user will use the OPENFI routine.
⊗

HERE(OPENF)
	PUSHJ	P,SAVE
	MOVE	LPSA,X33
	VALCHN	1,-2(P),OPNERR
	SKIPL	2,-1(P)		;GET THE FLAGS
	CAILE	2,5		;CHECK IN RANGE 0-5
	   JRST	GOTFLAGS
	MOVE	2,OPNTBL(2)	;GET CORRECT WORD
GOTFLAGS:
	SETZM	.SKIP.
	PUSH	P,2		;SAVE FLAGS
	JSYS OPENF
	  JRST	NOOPN
	POP     P,OFL(CDB)	;AND SAVE FLAGS
OPNRET:	JRST	RESTR

OPNERR: ERR <Illegal JFN>,1
	SETOM	.SKIP.
	JRST	OPNRET

NOOPN:	MOVEM	1,.SKIP.
	SUB	P,X11		;ADJUST STACK
	JRST	OPNRET

OPNTBL:	070000200000		;7-BIT READ
	070000100000		;7-BIT WRITE
	440000200000		;36-BIT READ
	440000100000		;36-BIT WRITE
	447400200000		;36-BIT DUMP READ
	447400100000		;36-BIT DUMP WRITE