Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-01 - 43,50212/protec.mac
There are no other files named protec.mac in the archive.
	TITLE	PROTEC
	ENTRY	PROTEC
;THIS ROUTINE PROTECTS <155> A FILE 'FILNAM.EXT'
;THE CALLING SEQUENCE IS CALL PROTEC('FILNA','M.EXT')
;BE SURE THE FILE HAS BEEN ENDFILED BEFORE CALLING PROTEC
	CHR=0			;AC'S
	BPT=1
	CTR=2
	TAC=3
	BPT2=4
	CNT=5
	FIL=6
	FEL=7
	DOT=16			;PERIOD
	D=12			;CHANNEL
	PROT=155		;PROTECTION CODE
	DEFINE	TTYOUT	(ADR)<TTCALL 3,ADR>
	DEFINE 	TTYIN	(ADR)<TTCALL 4,ADR>
PROTEC:	0
	MOVSI	0,1
	HRRI	0,ACSAV
	BLT	ACSAV+16		;SAVE AC'S
	INIT	D,17
	SIXBIT/DSK/
	0
	JRST	NOTAVL
	MOVE	FIL,@(16)		;GET FIRST ARG
	MOVE	FEL,@1(16)			;GET SECOND ARG
	MOVE	BPT2,[POINT 7,FIL]		;POINT TO FILENAME
	MOVEI	CNT,12				;ONLY LOOK AT 10 CHARACTERS
	MOVEI	CTR,6		;TO STORE SIX CHARS
	MOVE	BPT,[POINT 6,UFD]
	CLEARM	UFD		;FILNAME
	CLEARM	UFD+1		;EXT
	CLEARM	UFD+2		;PROTECTION
GETNAM:	ILDB	CHR,BPT2	;READ CHARACTER
	SUBI	CHR,40		;CONVERT TO SIXBIT
	JUMPE	CHR,COUNT	;SKIP BLANKS
	CAIN	CHR,DOT		;TEST FOR PERIOD
	JRST	EXT		;PERIOD--EXT FOLLOWS
	SOSL	CTR		;STORE ONLY LEGAL LIMIT
	IDPB	CHR,BPT		;ALPHANUMERIC--STORE
COUNT:	SOSG	CNT		;DECREMENT CHARACTER COUNTER
	JRST	LOOKUP		;DONE, GO PROTECT FILE
	JRST 	GETNAM		;GET NEXT CHARACTER
EXT:	MOVE	BPT,[POINT 6,UFD+1]
	MOVEI	CTR,3		;TO STORE THREE CHARS
	JRST	COUNT		;GO GET EXT
LOOKUP:	LOOKUP	D,UFD		;LOOKUP FILE
	JRST 	NONEXF		;NO FILE BY THAT NAME
	CLOSE	D,
	CALLI	TAC,24		;GET PRJ,PRG #
	MOVEM	TAC,UFD+3		;SO WE CAN PROTEC LARGE FILES
	MOVE	TAC,[EXP<PROT>B8]	;LOAD PROTECTION
	MOVEM	TAC,UFD+2
	RENAME	D,UFD		;PROTECT
	JRST	NOCLSE
	CLOSE	D,
EXIT:	MOVSI	0,ACSAV
	HRRI	0,1
	BLT	0,17
	JRA	16,(16)		;DONE
NOTAVL:	TTYOUT	[ASCIZ"DEVICE NOT AVAILABLE"]
	CALLI	12
NOCLSE:	TTYOUT	[ASCIZ"FILE "]
	TTYOUT	FIL
	TTYOUT	[ASCIZ" STILL OPEN...CANT PROTECT"]
	TTYOUT	CRLF
	JRST	EXIT
NONEXF:	TTYOUT	[ASCIZ"?CANT FIND FILE NAMED "]
	TTYOUT	FIL
	TTYOUT	CRLF
	JRST	EXIT		;RETURN
CRLF:	BYTE(7) 015, 012
ACSAV:	BLOCK 17
UFD:	BLOCK 4
	END