1 ! ! P R O T E C 2! Program: PROTEC 3! Version: V01A 4! Edit: 03 7! Edit Date: 11-Aug-80 9! Author: Brant Cheikes 15 EXTEND ! Set up BASIC-PLUS EXTEND mode processing 20 ! & & & ! M o d i f i c a t i o n H i s t o r y & & & ! Version/Edit Edit Date Reason & 21! V01A-01 23-Jun-80 New release & ! V01A-02 08-Jul-80 Fix protect Y/N bug & ! V01A-03 11-Aug-80 Fix PPN set & 50 ! & & & ! P r o g r a m D e s c r i p t i o n & & & 60 ! PROTEC is designed to set the PROTECTED bit (bit 5, value 32% ! of the USTAT byte) in any file's UFD entry. It allows both & ! setting and resetting of this bit. PROTEC requires privileges & ! to run. & ! & ! The user must specify the exact filename to be protected, since & ! PROTEC does not handle wildcards. The default PPN is the current & ! user account. & ! & 900 ! & & & ! D i m e n s i o n S t a t e m e n t s & & & 910 DIM M%(30%) & ! Set up matrix for SYS call returns & 920 DIM #1%, UFD%(3583%,7%) & ! Dimension UFD as a virtual array & 1000 ! & & & ! M a i n P r o g r a m C o d i n g & & & 1010 V$ = "V01A-03" & ! Set up version/edit level & 1020 ON ERROR GOTO 30000 & \ PRINT & \ PRINT "PROTEC "+V$+" "+ & CVT$$(RIGHT(SYS(CHR$(6%)+CHR$(9%)),3%),4%) & \ PRINT "File Protecter" & \ PRINT & ! Output the system header & 1030 PRINT "File"; & \ INPUT LINE INFIL$ & ! Get the file & 1035 P% = 0% & \ INPUT "Protect? (Yes/No) ";P$ & \ P$ = LEFT(P$,1%) & \ IF P$ = "Y" OR P$ = '' THEN P% = -1% ELSE IF P$ <> "N" THEN PRINT & "Please type a valid response, you idiot" & \ PRINT & \ GOTO 1035 & ! Find out what must be done & 1040 CHANGE SYS(CHR$(6%)+CHR$(-10%)+INFIL$) TO M% & \ S0% = M%(27%)+SWAP%(M%(28%)) & \ S0% = S0% AND 1024% & \ PROJ% = M%(6%) & \ PROG% = M%(5%) & \ P3% = PEEK(PEEK(PEEK(520%)+8%)+24%) & \ PROJ% = SWAP%(P3%) AND 255% UNLESS S0% & \ PROG% = P3% AND 255% UNLESS S0% & \ UFD$ = "["+NUM1$(PROJ%)+","+NUM1$(PROG%)+"]" & \ UFD$ = "SY:"+UFD$ & \ NAM$ = RAD$(M%(7%)+SWAP%(M%(8%)))+RAD$(M%(9%)+SWAP%(M%(10%)))+'.'+ & RAD$(M%(11%)+SWAP%(M%(12%))) & ! Push input spec through a filename string scan; set up UFD as a & ! string and set up name & 1050 OPEN UFD$ FOR INPUT AS FILE 1%, MODE 16384% & \ GOTO 10020 UNLESS SWAP%(CVT$%(MID(SYS(CHR$(12%)),13%,2%))) & ! Open the UFD with write access; see if it's empty & 1060 U1% = UFD%(0%,0%) & \ F% = UFD%(31%,0%) & ! Get cluster and init pointers & 1070 U% = FNL%(U1%,F%) & \ GOTO 10000 UNLESS U% & \ USTAT% = UFD%(U%,4%) & \ U1% = UFD%(U%,0%) & \ GOTO 1070 IF UFD%(U%,4%) AND 64% & ! Peruse the UFD looking for the given file & 1080 NAM1$ = RAD$(UFD%(U%,1%))+RAD$(UFD%(U%,2%))+'.'+RAD$(UFD%(U%,3%)) & \ GOTO 1070 UNLESS NAM1$ = NAM$ & ! Check current name; skip out if wrong & 1090 IF P% THEN UST% = USTAT% OR 32% ELSE UST% = USTAT% AND (NOT 32%) & ! Set up new USTAT byte & 1100 UFD%(U%,4%) = UST% & \ CLOSE #1% & \ PRINT NAM$;" in ";UFD$; & \ PRINT " marked non-deletable" IF P% & \ PRINT " reset to deletable" IF NOT P% & \ PRINT & \ GOTO 1030 & ! Set the new USTAT byte; make it permanent; go back for more & 10000 ! & & & ! S u b r o u t i n e s & & & 10010 PRINT "?No directory for ";NAM$;" in ";UFD$ & \ CLOSE #1% & \ PRINT & \ GOTO 1030 & 10020 PRINT "?A null UFD?" & \ CLOSE #1% & \ PRINT & \ GOTO 1030 & 20000 ! & & & ! F u n c t i o n s & & & 20010 DEF* FNL%(Q%,Q1%)= & (((Q% AND 3584%)/512%)*Q1%+ & (SWAP%(Q% AND -4096%)/16%))*32%+((Q% AND 496%)/16%) & ! Beats me what the hell this does & 30000 ! & & & ! E r r o r H a n d l i n g & & & 30010 IF ERR=2% AND ERL=1040% THEN PRINT "?Illegal filename" & \ PRINT & \ RESUME 1030 & ! Handle bad names & 30020 IF ERR = 5% THEN PRINT "?No such UFD on disk" & \ PRINT & \ RESUME 1030 & ! Handle missing UFDs & 30800 RESUME 32000 IF ERR = 11% & ! Exit fast on CTRL/Z & 32000 ! & & & ! E x i t & & & 32600 NO EXTEND ! Disable EXTEND mode processing 32700 S$ = SYS(CHR$(9%)) ! Clear core and exit fast 32767 END