Trailing-Edge
-
PDP-10 Archives
-
AP-4178E-RM
-
swskit-sources/rev.mac
There are 15 other files named rev.mac in the archive. Click here to see a list.
TITLE REV FILE REVIEWER
SUBTTL DEFINITIONS
;WRITTEN BY DAVID I. BELL, AT DIGITAL IN MARLBORO, MASS.
;THIS PROGRAM ALLOWS THE USER TO SCAN SELECTED FILES ONE BY ONE,
;AND INDIVIDUALLY PROCESS COMMANDS FOR EACH. EXAMPLES OF THINGS
;THAT CAN BE DONE ARE DELETE, RENAME, COPY, PRINT, TYPE, READ
;PARAMETERS, AND SET PARAMETERS OF A FILE. THIS IS MUCH EASIER
;THAN DOING THINGS LIKE TYPE, DIRECT, DELETE, OVER AND OVER.
SEARCH MACSYM,MONSYM ;NEEDED DEFINITIONS
SALL
;VERSION INFORMATION:
VMAJOR==1 ;MAJOR VERSION
VMINOR==0 ;MINOR VERSION
VEDIT==131 ;EDIT NUMBER
VWHO==1 ;WHO EDITED LAST
;ACCUMULATORS:
F=0 ;FLAGS
T1=1 ;TEMP AC'S
T2=2
T3=3
T4=4
T5=5
I=6 ;INDEX FOR TYPEOUT LOOP
ZZ=7 ;CONTAINS ZERO
P=17 ;STACK
;MACROS:
DEFINE ND(SYM,VAL),<
IFNDEF SYM,<SYM==VAL>
>
DEFINE TEXT(STRING),<
XLIST
ASCIZ @STRING@
LIST
>
DEFINE AA(SWITCH,ADDR,BITS),<
IFB <BITS>,<
XWD [ASCIZ/SWITCH/],ADDR
>
IFNB <BITS>,<
XWD [EXP CM%FW!<BITS>
ASCIZ/SWITCH/],ADDR
>
>
DEFINE ILLARG(TEXT),<
JRST [HRROI T1,[ASCIZ/
? TEXT
/]
JRST ERRPRT]
>
;FLAGS IN RIGHT HALF OF AC F:
FR.ADV==1 ;WE HAVE ADVANCED GJFN EARLY
FR.OPN==2 ;FILE CURRENTLY WORKING ON IS OPENED
FR.MAP==4 ;FILE CURRENTLY WORKING ON IS MAPPED IN CORE
FR.QIT==10 ;THE QUIT COMMAND HAS BEEN GIVEN
FR.AGN==20 ;CURRENT FILE IS TO BE PROCESSED AGAIN
FR.NXD==40 ;USER WANTS TO GO TO NEXT DIRECTORY
FR.NXS==100 ;USER WANTS TO GO TO NEXT STRUCTURE
FR.NXT==200 ;USER WANTS TO GO TO NEXT FILE TYPE
FR.NXF==400 ;USER WANTS TO GO TO NEXT FILE NAME
FR.OP2==1000 ;OUTPUT FILE HAS BEEN OPENED
FR.ADL==2000 ;ALLOW REVIEWING OF DELETED FILES
FR.AUD==4000 ;ALLOW REVIEWING OF UNDELETED FILES
FR.HDR==10000 ;HEADER LINE IS NEEDED FOR NEXT SPEC
;DEFAULT PARAMETERS:
ND PDLLEN,100 ;SIZE OF PUSH-DOWN STACK
ND TXTLEN,^D200 ;SIZE OF TEXT BUFFERS FOR COMMANDS
ND CTLE,0 ;CHANNEL TO USE FOR ^E INTERRUPT
ND MAXUP,^D101 ;NUMBER OF FILES WE CAN BACK UP
ND SPECSZ,^D50 ;WORDS NEEDED TO HOLD A FILE SPEC
ND ERRSIZ,^D10 ;SIZE OF ERROR STAKING AREA
SUBTTL INITIALIZATION
ENTRY: JRST REV ;ENTRY VECTOR
JRST REV ;REENTER ADDRESS
BYTE (3)VWHO(9)VMAJOR(6)VMINOR(18)VEDIT ;VERSION
REV: RESET ;RESET EVERYTHING
MOVE P,[IOWD PDLLEN,PDL] ;INITIALIZE STACK
SETZB ZZ,GJFN ;AND AC AND MAIN JFN
SETZM JFN ;CLEAR ANOTHER JFN
SETZM JFNOUT ;CLEAR OUTPUT JFN
MOVEI F,FR.AUD ;INITIALIZE FLAGS
MOVEI T1,ERRBUF ;GET ADDRESS OF SAVING AREA
MOVEM T1,ERRPTR ;INITIALIZE POINTER INTO AREA
MOVEI T1,MONRET ;GET ADDRESS TO GO TO ON BIG ERROR
PUSHJ P,ERRSET ;SET IT UP IN CASE IT HAPPENS
MOVEI T1,.FHSLF ;GET MY PROCESS
MOVE T2,[LEVTAB,,CHNTAB] ;POINT TO INTERRUPT TABLES
SIR ;TELL MONITOR WHERE THEY ARE
ERJMP ERRSTR ;SHOULDN'T FAIL
MOVEI T1,.FHSLF ;GET READY
MOVX T2,1B<CTLE> ;GET BIT FOR CHANNEL
AIC ;ACTIVATE THE CHANNEL
ERJMP ERRSTR ;LOSE
MOVEI T1,.FHSLF ;ONE MORE TIME
EIR ;ENABLE INTERRUPTS
ERJMP ERRSTR ;CAN'T
MOVEI T1,LAST+777 ;GET LAST ADDRESS NEEDED FOR PMAP
IDIVI T1,1000 ;PUT FIRST ADDRESS IN PAGE BOUNDARY
MOVEM T1,PAGNUM ;SAVE PAGE NUMBER WE WILL USE
IMULI T1,1000 ;TURN INTO ADDRESS
MOVEM T1,PAGADR ;SAVE ADDRESS OF PAGE ALSO
ADDI T1,1000 ;INCREMENT TO NEXT PAGE
MOVEM T1,PAGAD2 ;SAVE AS ADDRESS OF SECOND PAGE
IDIVI T1,1000 ;GET PAGE NUMBER OF SECOND PAGE
MOVEM T1,PAGNU2 ;SAVE IT TOO
SETZ T1, ;GET READY
RSCAN ;SEE IF THERE IS ANY INPUT FOR US
ERJMP ERRSTR ;FAILURE, COMPLAIN
JUMPE T1,NEWCMD ;NO, JUST GO GET A COMMAND
;HERE IF THERE IS SOMETHING TO BE RESCANNED IN THE RESCAN BUFFER.
;IT MIGHT HAVE A FILE SPEC FOLLOWING OUR PROGRAM NAME. IF SO,
;WE WANT TO DEFAULT TO THE "REVIEW" COMMAND. ANY ERROR HERE IS NOT
;FATAL, SINCE WE DON'T KNOW IF THE TYPE-IN IS REASONABLE OR NOT.
MOVEI T1,CMDBLK ;POINT TO COMMAND BLOCK
HRROI T2,ZZ ;GET A POINTER TO A NULL STRING
MOVEM T2,CMDBLK+.CMRTY ;SAVE AS CONTROL-R POINTER
MOVEI T2,[FLDDB. (.CMINI)] ;GET SET
PUSHJ P,COMMND ;INITIALIZE IT
MOVX T2,GJ%OFG ;GET FLAGS
MOVEM T2,JFNBLK ;SET UP GTJFN BLOCK
MOVEI T2,[FLDDB. (.CMFIL)] ;WANT TO READ A FILE SPEC
COMND ;DO IT
ERJMP EATLIN ;FAILED, JUST GO EAT LINE
TXNE T1,CM%NOP ;DIDN'T PARSE?
JRST EATLIN ;YES, GO EAT LINE
HRROI T1,SPECS ;POINT TO STORAGE
MOVX T3,FLD (.JSAOF,JS%NAM) ;SET UP TO STORE ONLY NAME
JFNS ;DO IT
ERJMP EATLIN ;FAILED
IDPB ZZ,T1 ;MAKE IT ASCIZ
MOVE T1,T2 ;GET JFN
RLJFN ;RELEASE IT
ERJMP EATLIN ;FAILED
GETNM ;NOW GET OUR USER NAME
ERJMP EATLIN ;FAILED
MOVE T3,[POINT 7,SPECS] ;POINT TO STRING
CMPLOP: ILDB T4,T3 ;GET NEXT CHAR OF FILE NAME
JUMPE T4,CMPFIN ;DONE IF GET A NULL
SETZ T2, ;CLEAR AC
ROTC T1,6 ;SHIFT IN NEXT CHAR OF OUR NAME
CAIE T4," "(T2) ;CHARACTERS MATCH EACH OTHER?
JRST EATLIN ;NO, THEN CAN'T BE WANTED COMMAND LINE
JRST CMPLOP ;LOOP
CMPFIN: JUMPE T1,GETSPC ;JUMP IF GOT MATCH WITH OUR NAME
;OTHERWISE EAT LINE
;HERE WHEN WE HAVE FOUND SOMETHING IN THE RESCAN BUFFER, BUT IT
;DID NOT LOOK LIKE OUR PROGRAM NAME. WE HAVE TO EAT UP THE REST
;OF THE LINE, AND THEN GET A NORMAL COMMAND.
EATLIN: MOVEI T1,CMDBLK ;SET UP TO THE COMMAND BLOCK
MOVEI T2,[FLDDB. (.CMCFM)] ;CONFIRM FUNCTION
COMND ;READ TO THE END OF LINE
ERJMP NEWCMD ;IGNORE ANY ERROR
JRST NEWCMD ;OK, GO GET A NORMAL COMMAND
;HERE WHEN WE KNOW HE TYPED OUR NAME AS THE COMMAND. WE NOW WANT
;TO LOOK FOR ANY SPECIFICATION FOLLOWING SO WE CAN USE IT IN THE
;IMPLICIT "REVIEW" COMMAND. ERRORS HERE NOW CAN BE TOLD ABOUT.
GETSPC: MOVEI T1,CMDBLK ;POINT TO COMMAND BLOCK AGAIN
MOVX T2,GJ%OLD+GJ%IFG+GJ%FLG+GJ%ACC+.GJALL ;GET FLAGS
MOVEM T2,JFNBLK ;STORE IN GTJFN BLOCK
MOVEI T2,[FLDDB. (.CMCFM,,,,,<[FLDDB. (.CMFIL)]>)]
PUSHJ P,COMMND ;PARSE IT LOOKING FOR CRLF OR SPEC
TSC T3,T3 ;COMPARE FIRST AND LAST FUNCTION BLOCK
JUMPE T3,NEWCMD ;NO SPEC WAS TYPED, GO GET A COMMAND
MOVEM T2,GJFN ;HAVE THE SPEC, SAVE THE JFN
PUSHJ P,CONFRM ;CONFIRM THE SPEC
PUSHJ P,ACTRVD ;GO REVIEW THE GIVEN FILES NOW
PUSHJ P,CLOSE ;ALL DONE, CLOSE THE FILES
PUSHJ P,CRLF ;TYPE A FINAL CRLF
JRST MONRET ;THEN EXIT
SUBTTL MAIN COMMAND SCANNER
;HERE TO INPUT A COMMAND FOR THE PROGRAM. GOTTEN TO IF THE RESCANNED
;TEXT LOOKED INCORRECT OR HAD NO FILE SPECIFICATION GIVEN.
NEWCMD: MOVEI T1,NEWCMD ;GET ADDRESS TO GO TO IF ANY ERRORS
PUSHJ P,ERRSET ;REMEMBER IT
NEWCMA: HRROI T1,[ASCIZ/REV>/] ;GET THE PROMPT
MOVEM T1,CMDBLK+.CMRTY ;AND SET UP CONTROL-R BUFFER
MOVX T1,GJ%OLD+GJ%IFG+GJ%FLG+GJ%ACC+.GJALL ;GET FLAGS
MOVEM T1,JFNBLK ;AND STORE IN BLOCK
MOVEI T1,CMDBLK ;GET ADDRESS OF BLOCK
MOVEI T2,[FLDDB. (.CMINI)] ;AND INITIALIZE FUNCTION
PUSHJ P,COMMND ;PARSE THE COMMAND
MOVEM P,SAVEP ;REMEMBER STACK FOR REPARSING
NEWPAR: MOVE P,SAVEP ;RESTORE STACK
MOVEI T1,CMDBLK ;POINT TO BLOCK
MOVEI T2,[FLDDB. (.CMKEY,,ACTTAB)] ;POINT TO TABLE
PUSHJ P,COMMND ;PARSE THE COMMAND
MOVE T2,(T2) ;GET ADDRESS OF ROUTINE
PUSHJ P,(T2) ;CALL IT FOR THIS COMMAND
JRST NEWCMA ;DONE, GO GET ANOTHER COMMAND
SUBTTL THE SIMPLE COMMANDS
;HERE TO DO ALL THE TRIVIAL COMMANDS: EXIT, HELP, ALLOW, ETC.
ACTHLP: PUSHJ P,CONFRM ;CONFIRM THE EOL
HRROI T1,TXTHLP ;POINT TO STRING
PSOUT ;TYPE IT
HRROI T1,HLPTXT ;POINT TO OTHER TEXT
PSOUT ;AND OUTPUT IT TOO
POPJ P, ;THEN RETURN
TXTHLP: TEXT <
REV is a program which lists files one by one and gives you the
option of typing, changing, or deleting each file separately.
The commands are:
ALLOW arg Allow the specified type of files to be reviewed.
The arg can be one of DELETED, UNDELETED, or ALL.
DISALLOW arg Do not review the specified type of file.
HELP Type this text.
EXIT Exit from the program.
REVIEW file Go over the indicated files one by one.
WHAT Tell which kind of files we are set to review.
>
ACTXIT: PUSHJ P,CONFRM ;LOOK FOR END OF LINE
PUSHJ P,CRLF ;TYPE ANOTHER CRLF
MONRET: RESET ;RESET EVERYTHING
HALTF ;STOP
JRST .-1 ;STAY DEAD
SUBTTL ROUTINE TO SET WHICH FILES ARE TO BE REVIEWED
;COMMAND TO SET THE PROPER FLAG BITS TO INDICATE WHICH FILES
;ARE TO BE REVIEWED. THE "ALLOW" AND "DISALLOW" COMMANDS.
ACTDIS: SKIPA T5,[ANDCMI F,0] ;GET INSTRUCTION
ACTALW: MOVSI T5,(IORI F,0) ;OR THE OTHER ONE
MOVEI T2,[ASCIZ/REVIEWING OF/] ;NOISE
PUSHJ P,NOISE ;PARSE IT
MOVEI T2,[FLDDB. (.CMKEY,,ALWTAB)] ;FUNCTION
PUSHJ P,COMMND ;READ IT
HRR T5,(T2) ;PUT IN THE PROPER BITS
MOVEI T2,[ASCIZ/FILES/] ;MORE NOISE
PUSHJ P,NOISE ;PARSE IT
PUSHJ P,CONFRM ;END THE LINE
XCT T5 ;SET OR CLEAR THE BITS
POPJ P, ;AND RETURN
ALWTAB: ALWLEN,,ALWLEN ;HEADER FOR TABLE
AA ALL,FR.ADL+FR.AUD ;ALLOW ALL FILES
AA DELETED,FR.ADL ;ALLOW DELETED FILES
AA UNDELETED,FR.AUD ;ALLOW UNDELETED FILES
ALWLEN==.-ALWTAB-1 ;NUMBER OF COMMANDS
SUBTTL ROUTINE TO TELL ABOUT WHAT WE CAN REVIEW
;THIS ROUTINE TELLS THE USER WHAT KIND OF FILES HE IS SET TO
;REVIEW. IS THE "WHAT" COMMAND.
ACTWHT: MOVEI T2,[ASCIZ/FILES ARE TO BE REVIEWED/] ;GET TEXT
PUSHJ P,NOISE ;PARSE IT
PUSHJ P,CONFRM ;AND CONFIRM IT
HRROI T1,[ASCIZ/
DELETED files will be reviewed./] ;GET TEXT
TRNE F,FR.ADL ;ALLOWING THE FILES?
PSOUT ;YES, TYPE THE TEXT
HRROI T1,[ASCIZ/
UNDELETED files will be reviewed./] ;GET MORE TEXT
TRNE F,FR.AUD ;ALLOWING THEM?
PSOUT ;YES, TYPE THE TEXT
HRROI T1,[ASCIZ/
No files will be reviewed./] ;GET FINAL TEXT
TRNN F,FR.ADL+FR.AUD ;ALLOWING NOTHING?
PSOUT ;YES, SAY THAT
PUSHJ P,CRLF ;TYPE ONE CRLF
JRST CRLF ;AND THEN GO TYPE ANOTHER
SUBTTL ROUTINE TO DO THE REVIEW COMMAND
;HERE TO DO MAIN COMMAND OF PROGRAM. READ IN A FILE SPEC, AND
;LOOP OVER ALL FILES ASKING WHAT TO DO WITH EACH ONE.
;CALLED AT ACTRVD WHEN DOING A SPEC WHICH WE RESCANNED.
ACTREV: MOVEI T2,[ASCIZ/FILES/] ;GET NOISE WORD
PUSHJ P,NOISE ;PARSE IT
MOVX T2,GJ%DEL ;GET DELETED FILE BIT
ANDCAM T2,JFNBLK ;CLEAR IT IN GTJFN BLOCK
TRNE F,FR.ADL ;WANTS TO ALLOW THEM?
IORM T2,JFNBLK ;YES, THEN TURN ON BIT
MOVEI T2,[FLDDB. (.CMFIL,CM%HPP+CM%SDH,,<files to review>)]
PUSHJ P,COMMND ;READ THE COMMAND
MOVEM T2,GJFN ;SAVE JFN OF FILE SPEC
MOVEI T1,CMDBLK ;POINT TO GTJFN BLOCK
PUSHJ P,CONFRM ;LOOK FOR THE END OF THE COMMAND
ACTRVD: HRRZ T1,GJFN ;GET JFN
DVCHR ;FIND OUT ABOUT DEVICE
ERJMP ERRSTR ;SHOULDN'T FAIL
LDB T1,[POINT 9,T1,17] ;GET DEVICE TYPE
CAIE T1,.DVDSK ;IS IT A REAL DISK?
ILLARG Device must be a disk
ANDCMI F,FR.AGN+FR.QIT ;CLEAR FLAGS
IORI F,FR.HDR ;AND SET THIS ONE
ACTRVS: SETZM SPCPTR ;INITIALIZE STRING POINTER
SETZM BACNUM ;AND NUMBER OF FILES BACKED UP
PUSHJ P,CHKNXD ;SEE IF THIS FILE IS WANTED
SKIPA ;NO
JRST LOOP ;YES, GO BEGIN MAIN LOOP
PUSHJ P,NEXT ;ADVANCE TO THE NEXT FILE
ILLARG No files found
JRST ACTRVS ;THEN SEE IF IT IS OK
;HERE TO HANDLE NEXT FILE:
LOOP: PUSHJ P,CPYJFN ;CREATE A JFN AND STORE FILE SPEC
SOSGE BACNUM ;DECREMENT FILES WE ARE BACKED UP BY
AOS BACNUM ;BUT DON'T GO NEGATIVE
ANDCMI F,FR.NXD+FR.NXS+FR.NXT+FR.NXF ;CLEAR FLAGS
PUSHJ P,DOFILE ;GO TYPE OUT FILE AND GET RESPONSE
PUSHJ P,CLOSE ;MAKE SURE ALL FILES ARE RELEASED
TRZE F,FR.QIT ;USER WANTS TO QUIT?
JRST DONE ;YES, GO ABORT THIS
PUSHJ P,NEXT ;ADVANCE TO NEXT FILE
JRST CRLF ;NO MORE FILES, ALL DONE
JRST LOOP ;THEN GO WORK ON NEW FILE
;HERE WHEN USER WANTS TO ABORT EVERYTHING:
DONE: HRRZ T1,GJFN ;GET JFN
RLJFN ;RELEASE IT
ERJMP ERRSTR ;SHOULDN'T FAIL
JRST CRLF ;GIVE CRLF AND RETURN
SUBTTL SUBROUTINE CALLED FOR EACH FILE
;THIS ROUTINE ACTUALLY DOES THE WORK FOR EACH FILE. WE TYPE OUT
;THE FILE SPECIFICATION, AND ASK THE USER WHAT HE WANTS TO DO
;WITH THIS FILE. WE RETURN WHEN THIS FILE IS PROCESSED.
DOFILE: MOVEI T1,BADKEY ;GET ADDRESS OF ERROR ROUTINE
PUSHJ P,ERRSET ;REMEMBER IT
DOFILA: ANDCMI F,FR.AGN ;CLEAR FLAG
TRZE F,FR.HDR ;CHECK AND CLEAR HEADER FLAG
PUSHJ P,TYPHDR ;WANTED IT TYPED, DO IT
HRRZ T1,JFN ;GET JFN
MOVSI T2,.FBLWR+1 ;GET HIGHEST FDB ENTRY WANTED
MOVEI T3,FDB ;AND PLACE TO STORE INFO
GTFDB ;READ THE INFORMATION
ERJMP ERRSTR ;LOSE
MOVE T1,[POINT 7,FILTXT] ;SET UP POINTER TO BUFFER
MOVE T2,FDB+.FBCTL ;GET STATUS BITS
MOVEI T3," " ;GET A SPACE
TXNE T2,FB%DEL ;IS FILE DELETED?
MOVEI T3,"D" ;YES, CHANGE TO A D
IDPB T3,T1 ;STORE RESULT
MOVEI T3," " ;AND SET UP A SPACE
TXNE T2,FB%BAT ;SOME PAGES IN FILE BAD MAYBE?
MOVEI T3,"*" ;YES, REPLACE SPACE
IDPB T3,T1 ;STORE RESULT AGAIN
HRRZ T2,JFN ;GET JFN
MOVE T3,[1B8+1B11+1B14+1B17+JS%PAF] ;AND FLAGS
JFNS ;STORE STRING FILE.TYPE.GEN
MOVEI T2,^D25 ;GET COLUMN TO JUSTIFY TO
PUSHJ P,JUSTFY ;DO THE JUSTIFICATION
HRRZ T2,FDB+.FBBYV ;GET PAGE COUNT
PUSHJ P,DECOUT ;OUTPUT IT
MOVEI T2,^D29 ;GET COLUMN TO JUSTIFY TO
PUSHJ P,JUSTFY ;DO IT
PUSHJ P,EOFOUT ;TYPE OUT THE EOF POINTER
MOVEI T2,^D40 ;GET COLUMN TO JUSTIFY TO
PUSHJ P,JUSTFY ;DO IT
MOVE T2,FDB+.FBWRT ;GET LAST DATE FILE WAS WRITTEN
MOVX T3,OT%NTM ;SET TO OUTPUT DATE ONLY, STANDARD FORMAT
PUSHJ P,DATOUT ;GO TYPE THE DATE
MOVEI T2,[ASCIZ/ : /] ;GET STRING TO PROMPT USER
PUSHJ P,STROUT ;STORE IT IN BUFFER
IDPB ZZ,T1 ;STORE NULL ALSO TO MAKE ASCIZ
MOVEI T1,.PRIIN ;PRIMARY INPUT
CFIBF ;CLEAR INPUT IN CASE OF FLAKEY TTY
;HERE TO READ THE COMMAND FOR THIS FILE:
KEYCMD: MOVEI T1,KEYBLK ;POINT TO KEYWORD BLOCK
MOVEI T2,[FLDDB. (.CMINI)] ;INITIALIZATION
PUSHJ P,COMMND ;DO IT
MOVEM P,SAVEP ;SAVE STACK FOR REPARSING
KEYPAR: MOVE P,SAVEP ;RESTORE STACK
MOVEI T1,KEYBLK ;SET UP FOR COMND JSYS
MOVEI T2,[FLDDB. (.CMCFM,CM%HPP+CM%SDH,,CRLF for next file,,<[FLDDB. (.CMKEY,,KEYTAB)]>)]
PUSHJ P,COMMND ;READ THE COMMAND
TSC T3,T3 ;COMPARE FUNCTION BLOCKS
JUMPE T3,CPOPJ ;IF THE SAME, JUST CRLF WAS TYPED
MOVE T2,(T2) ;GET TABLE ENTRY OF MATCH
PUSHJ P,(T2) ;CALL ROUTINE FOR THIS SWITCH
TRNE F,FR.AGN ;HAVE TO PROCESS FILE AGAIN?
JRST DOFILA ;YES, GO DO IT
POPJ P, ;ALL DONE, RETURN
BADKEY: IORI F,FR.AGN ;SET FLAG SO JFN IS NOT RELEASED
PUSHJ P,CLOSE ;UNMAP AND CLOSE THE FILE IF NEEDED
JRST DOFILE ;AND REDO THIS FILE
SUBTTL SIMPLE ROUTINES CALLED TO DO THINGS TO A FILE
;COMMAND TO QUIT THIS WHOLE BUSINESS, AND RETURN TO COMMAND LEVEL
;IMMEDIATELY. THE "ABORT" COMMAND.
CMDABT: MOVEI T2,[ASCIZ/THIS COMMAND/] ;GET STRING
PUSHJ P,NOISE ;PARSE THE NOISE
PUSHJ P,CONFRM ;CONFIRM THE COMMAND
IORI F,FR.QIT ;SET FLAG TO QUIT
POPJ P, ;RETURN
;COMMAND TO DELETE THE FILE WITHOUT EXPUNGING IT.
;THE "DELETE" COMMAND.
CMDDEL: PUSHJ P,CONFRM ;CONFIRM THE COMMAND FIRST
HRRZ T1,JFN ;GET JFN OF FILE
TLO T1,(DF%NRJ) ;SET NOT TO RELEASE JFN
DELF ;DELETE THE FILE
ERJMP ERRSTR ;ERROR, NON-SKIP RETURN
POPJ P, ;OK, RETURN
;ROUTINE TO TYPE HELP MESSAGE GIVING WHAT EACH COMMAND DOES.
;THE "HELP" COMMAND.
CMDHLP: PUSHJ P,CONFRM ;CONFIRM THE COMMAND
HRROI T1,HLPTXT ;POINT TO TEXT
PSOUT ;TYPE MESSAGE
IORI F,FR.AGN ;SAY TO DO FILE AGAIN
POPJ P, ;THEN RETURN
;COMMAND TO UNDELETE FILES WHICH ARE DELETED. THE "UNDELETE" COMMAND.
CMDUND: PUSHJ P,CONFRM ;CONFIRM IT
MOVSI T1,.FBCTL ;GET WORD IN FDB TO CHANGE
HRR T1,JFN ;AND THE JFN
MOVX T2,FB%DEL ;AND MASK FOR THE DELETED BIT
SETZ T3, ;WANT TO TURN IT OFF
CHFDB ;UNDELETE THE FILE
ERJMP ERRSTR ;FAILED
POPJ P, ;RETURN
;COMMAND TO EXIT TO MONITOR LEVEL. ON A CONTINUE, WE RETYPE THE
;FILE SPEC AND GO BACK TO WHERE WE WAS. IS THE "EXIT" COMMAND.
CMDXIT: PUSHJ P,CONFRM ;CONFIRM THE END OF LINE
PUSHJ P,CRLF ;TYPE A CRLF TO LOOK NICE
HALTF ;EXIT WITHOUT RESETTING
IORI F,FR.AGN+FR.HDR ;SAY TO REDO THE FILE
POPJ P, ;AND RETURN
SUBTTL ROUTINE TO DO A PUSH COMMAND
;COMMAND TO GET AN EXEC AS AN INFERIOR PROCESS. WHEN THE EXEC
;TERMINATES, WE REPROCESS THE CURRENT FILE SPEC AGAIN. THE
;"PUSH" COMMAND.
CMDPSH: MOVEI T2,[ASCIZ/COMMAND LEVEL/] ;GET NOISE
PUSHJ P,NOISE ;PARSE IT
PUSHJ P,CONFRM ;CONFIRM COMMAND
MOVX T1,GJ%OLD+GJ%PHY+GJ%SHT ;GET BITS READY
HRROI T2,[ASCIZ/PS:<SYSTEM>EXEC.EXE/] ;AND SPEC
PUSHJ P,FORK ;GET IT IN INFERIOR FORK
PSHFIN: MOVE T1,HANDLE ;GET READY
SETZ T2, ;START AT NORMAL ADDRESS
SFRKV ;DO IT
ERJMP ERRSTR ;CAN'T
WFORK ;WAIT FOR IT TO RETURN
ERJMP ERRSTR ;LOSE
KFORK ;THEN KILL IT OFF
ERJMP ERRSTR ;FAILED
SETZM HANDLE ;NO LONGER HAVE A HANDLE ON IT
IORI F,FR.AGN+FR.HDR ;REMEMBER TO DO THIS FILE AGAIN
POPJ P, ;AND RETURN
SUBTTL ROUTINE TO CALL FILDDT FOR THIS FILE
;THE "FILDDT" COMMAND. WE GET FILDDT ON AN INFERIOR FORK, AND
;START IT UP. WE GIVE IT THE FILE SPECIFICATION OF OUR FILE
;BY TYPING IT TO OUR INPUT BUFFER.
DD.NOS==1 ;DON'T TELL FILDDT THE FILE SPEC
DD.PAT==2 ;ENABLE PATCHING OF FILE
DD.DAT==4 ;ENABLE DATA ONLY MODE
CMDDDT: SETZ T5, ;CLEAR FLAGS
CMDDDL: MOVEI T2,[FLDDB. (.CMCFM,,,<
>,,<[FLDDB. (.CMKEY,,DDTTAB)]>)] ;GET READY
PUSHJ P,COMMND ;READ KEYWORD OR A CRLF
TSC T3,T3 ;COMPARE LAST DESCRIPTOR BLOCK USED
JUMPE T3,DDTDO ;WAS CRLF, GO DO IT NOW
MOVE T2,(T2) ;GET BITS FOR THIS KEYWORD
IORI T5,(T2) ;REMEMBER THEM
JRST CMDDDL ;LOOP FOR MORE
DDTDO: PUSHJ P,CRLF ;TYPE A CRLF FIRST
MOVX T1,GJ%OLD+GJ%SHT ;GET FLAGS
HRROI T2,[ASCIZ/SYS:FILDDT.EXE/] ;AND THE SPEC
PUSHJ P,FORK ;READ IT INTO INFERIOR FORK
MOVEI T1,.PRIIN ;GET READY
CFIBF ;CLEAR INPUT BUFFER
MOVEI T3,[ASCIZ/Enable patching
/] ;GET STRING
TRNE T5,DD.PAT ;WANT TO PATCH?
PUSHJ P,STISTR ;YES, PUT STRING IN BUFFER
MOVEI T3,[ASCIZ/Enable data-file
/] ;GET STRING
TRNE T5,DD.DAT ;WANT DATA MODE?
PUSHJ P,STISTR ;YES, STORE STRING
TRNE T5,DD.NOS ;DOESN'T WANT THE SPEC TYPED?
JRST PSHFIN ;YES, THEN ALL DONE
MOVEI T3,[ASCIZ/Get /] ;GET TEXT
PUSHJ P,STISTR ;TYPE STRING INTO INPUT BUFFER
MOVE T2,SPCPTR ;GET POINTER TO CURRENT STRING
IDIVI T2,MAXUP ;GET INDEX INTO TABLES
IMULI T3,SPECSZ ;MULTIPLY BY SIZE OF A SPEC
MOVEI T3,SPECS(T3) ;POINT TO SPEC
PUSHJ P,STISTR ;TYPE IT TO INPUT
MOVEI T3,[BYTE (7)15] ;GET JUST A CRLF
PUSHJ P,STISTR ;TYPE IT TO END LINE
JRST PSHFIN ;THEN GO JOIN OTHER CODE
;TABLE OF POSSIBLE KEYWORDS:
DDTTAB: DDTLEN,,DDTLEN ;LENGTH OF TABLE
AA DATA-FILE,DD.DAT ;ENABLE DATA MODE ONLY
AA NO-FILE,DD.NOS ;DON'T TYPE SPEC
AA PATCHING,DD.PAT ;ENABLE PATCHING
DDTLEN==.-DDTTAB-1 ;LENGTH
;SUBROUTINE TO STORE A STRING INTO OUR INPUT BUFFER.
STISTR: HRLI T3,(POINT 7,) ;MAKE BYTE POINTER
STISTL: ILDB T2,T3 ;GET CHAR
JUMPE T2,CPOPJ ;DONE, RETURN
MOVEI T1,.CTTRM ;GET MY TERMINAL DESIGNATOR
STI ;PUT CHAR INTO INPUT BUFFER
ERJMP ERRSTR ;FAILED
JRST STISTL ;LOOP OVER WHOLE STRING
SUBTTL ROUTINE TO SKIP OVER FILES
;COMMAND TO SKIP TO THE NEXT DIRECTORY OR THE NEXT STRUCTURE.
;THE "NEXT" COMMAND.
CMDNXT: MOVEI T2,[FLDDB. (.CMKEY,,NXTTAB,<
>,<DIRECTORY>)] ;SET UP MORE
PUSHJ P,COMMND ;GET ARGUMENT
HRRZ T4,(T2) ;GET BITS FROM TABLE
PUSHJ P,CONFRM ;CONFIRM THE COMMAND
IORI F,(T4) ;SET PROPER BITS
POPJ P, ;AND RETURN
NXTTAB: NXTLEN,,NXTLEN ;HEADER FOR TABLE
AA DIRECTORY,FR.NXD ;NEXT DIRECTORY
AA FILE,FR.NXF ;NEXT FILE
AA STRUCTURE,FR.NXS ;NEXT STRUCTURE
AA TYPE,FR.NXT ;NEXT FILE TYPE
NXTLEN==.-NXTTAB-1 ;NUMBER OF COMMANDS
SUBTTL ROUTINE TO TYPE OUT A FILE
;COMMAND TO TYPE THE FILE TO THE TERMINAL. THE "TYPE" COMMAND.
;USER CAN ABORT THE TYPEOUT WITH A ^E.
CMDTYP: MOVEI T2,[ASCIZ/FROM PAGE/] ;GET NOISE TEXT
PUSHJ P,NOISE ;GOBBLE THE NOISE
MOVEI T2,[FLDDB. (.CMNUM,,^D10,,<0>)] ;NUMBER FUNCTION
PUSHJ P,COMMND ;READ IT
TLNE T2,-1 ;ILLEGAL PAGE NUMBER GIVEN?
ILLARG Illegal page number specified
SUBI T2,1 ;CHANGE TO PREVIOUS PAGE
MOVEM T2,PAGE ;SAVE AS PAGE TO START FROM
PUSHJ P,CONFRM ;CONFIRM THE END OF LINE IS OK
PUSHJ P,OPEN ;OPEN THE FILE FOR READING
PUSHJ P,CRLF ;START WITH A CRLF
MOVE T1,[.TICCE,,CTLE] ;GET CODE AND CHANNEL
ATI ;ASSIGN ^E TO CHANNEL
ERJMP ERRSTR ;ERROR
TYPLOP: PUSHJ P,PAGMAP ;MAP IN THE NEXT PAGE OF FILE
JRST TYPDON ;NO MORE PAGES
MOVEI T1,.PRIOU ;OUTPUT DESIGNATOR
HRRO T2,PAGADR ;TEXT TO BE TYPED
MOVNI T3,1000*5 ;WHOLE PAGE OF TEXT
SOUT ;TYPE IT
ERJMP ERRSTR ;FAILED
JRST TYPLOP ;AND LOOP FOR NEXT PAGE
;HERE WHEN A ^E IS TYPED, TO ABORT:
TYPINT: MOVEI T1,TYPABT ;GET ADDRESS TO RETURN TO
MOVEM T1,CHNPC1 ;SAVE AS PC TO GO TO WHEN WE RETURN
DEBRK ;RETURN FROM INTERRUPT
ERJMP ERRSTR ;SHOULDN'T HAPPEN
TYPABT: MOVEI T1,.PRIOU ;GET OUTPUT DESIGNATOR
CFOBF ;CLEAR OUTPUT BUFFER
PUSHJ P,CRLF ;LOOK NICE BECAUSE OF ABORTED OUTPUT
;HERE WHEN ALL DONE WITH TYPING THE FILE:
TYPDON: MOVEI T1,.TICCE ;GET CHARACTER CODE TO RELEASE
DTI ;REMOVE CONTROL-E INTERRUPT
IORI F,FR.AGN ;SAY WE WILL REPROCESS THE FILE
PUSHJ P,CLOSE ;UNMAP AND CLOSE THE FILE
JRST CRLF ;GIVE A CRLF AND RETURN
SUBTTL COMMAND TO PRINT INFORMATION ABOUT A FILE
;THIS ROUTINE HANDLES THE "INFO" COMMAND. IT WILL TYPE
;OUT EITHER INFORMATION ABOUT THE FDB OF A FILE, OR ABOUT ITS
;USE OF PAGES. DEFAULT IS TO TYPE OUT ABOUT THE FDB.
CMDINF: MOVEI T2,[ASCIZ/ABOUT/] ;GET NOISE
PUSHJ P,NOISE ;PARSE IT
MOVEI T2,[FLDDB. (.CMKEY,,INFTAB,<
>,<FDB>)] ;GET READY
PUSHJ P,COMMND ;READ A KEYWORD
MOVE T4,(T2) ;GET DISPATCH ADDRESS
PUSHJ P,CONFRM ;CONFIRM THE COMMAND
JRST (T4) ;GO HANDLE THE COMMAND
INFTAB: INFLEN,,INFLEN ;HEADER WORD
AA FDB,INFFDB ;TYPE OUT FDB INFO
AA PAGES,INFMAP ;TYPE OUT PAGE MAP INFO
INFLEN==.-INFTAB-1 ;NUMBER OF ENTRIES
SUBTTL ROUTINE TO MAP OUT THE USED PAGES OF A FILE
;ROUTINE TO TYPE OUT WHICH PAGES OF A FILE ARE IN USE. USEFUL
;TO EXAMINE FILES WHICH HAVE HOLES IN THEM. THE "INFO PAGES"
;COMMAND.
INFMAP: PUSHJ P,OPEN ;OPEN THE FILE FOR READING
MOVE T1,[POINT 7,LINBUF] ;GET POINTER
MOVEI T2,[ASCIZ/
Used pages: /] ;GET TEXT
PUSHJ P,STROUT ;START OFF OUTPUT WITH THAT
SETOM PAGE ;INITIALIZE PAGE NUMBER
SETOM PAGBEG ;CLEAR FIRST PAGE OF A RANGE
SETZB T5,PAGTOT ;INITIALIZE FLAG AND TOTAL PAGES
MAPLOP: MOVEM T1,LINPTR ;SAVE CURRENT BYTE POINTER
AOS T1,PAGE ;INCREMENT TO NEXT PAGE
TLNE T1,-1 ;OVERFLOWED HALFWORD?
JRST MAPDON ;YES, ALL DONE
HRL T1,JFN ;INSERT THE JFN
FFUFP ;FIND THE NEXT USED PAGE
ERJMP MAPEND ;FAILED, GO SEE WHY
HRRZM T1,PAGE ;SAVE PAGE NUMBER
AOS PAGTOT ;INCREMENT TOTAL NUMBER OF PAGES
MOVE T1,LINPTR ;RESTORE BYTE POINTER
SKIPGE PAGBEG ;STARTED ON A NEW RANGE YET?
JRST MAPRNB ;NO, GO START IT
MOVE T2,PAGE ;YES, GET THIS PAGE NUMBER
SUBI T2,1 ;DECREMENT TO PREVIOUS ONE
CAME T2,PAGEND ;MATCH THE OLD TOP OF RANGE?
JRST MAPRNE ;NO, THIS RANGE IS DONE
AOS PAGEND ;YES, ADVANCE TOP OF RANGE
JRST MAPLOP ;AND LOOP
MAPRNE: PUSHJ P,MAPTYP ;TYPE OUT THE RANGE WE FOUND
MAPRNB: MOVE T2,PAGE ;GET CURRENT PAGE NUMBER
MOVEM T2,PAGBEG ;SET AS START OF NEW RANGE
MOVEM T2,PAGEND ;AND AS END OF IT TOO
JRST MAPLOP ;AND LOOP
;HERE WHEN ALL DONE, TO TYPE OUT FINAL STUFF:
MAPEND: CAIE T1,FFUFX3 ;NO MORE PAGES TO DO?
JRST ERRSTR ;OTHER ERROR, GO COMPLAIN
MAPDON: MOVE T1,LINPTR ;GET BYTE POINTER BACK
SKIPN T2,PAGTOT ;GET TOTAL NUMBER OF PAGES
JRST [MOVEI T2,[ASCIZ/ None
/] ;WAS NONE, GET TEXT
JRST MAPFIN] ;AND GO FINISH
SKIPL PAGBEG ;IS THERE A RANGE LEFT TO TELL ABOUT?
PUSHJ P,MAPTYP ;YES, TYPE IT
MOVEI T2,[ASCIZ/
Total pages: /] ;GET TEXT
PUSHJ P,STROUT ;OUTPUT THAT
MOVE T2,PAGTOT ;GET COUNT
PUSHJ P,DECOUT ;OUTPUT IT
MOVEI T2,[ASCIZ/
/] ;GET A COUPLE OF CRLFS
MAPFIN: PUSHJ P,STROUT ;STORE IT
IDPB ZZ,T1 ;CREATE ASCIZ STRING
HRROI T1,LINBUF ;POINT TO STRING
PSOUT ;OUTPUT IT
IORI F,FR.AGN ;WANT TO DO FILE AGAIN
JRST CLOSE ;CLOSE FILE AND REDO IT
;SUBROUTINE USED FOR THE INFMAP ROUTINE. OUTPUTS A RANGE OF NUMBERS
;WHICH ARE IN LOCATIONS PAGBEG AND PAGEND. IF THEY ARE THE SAME,
;WE ONLY OUTPUT ONE NUMBER. BYTE POINTER FOR OUTPUT IS IN AC T1.
;AC T5 IS A FLAG ON WHETHER OR NOT WE HAVE BEEN CALLED BEFORE.
MAPTYP: MOVEI T2,"," ;GET A COMMA
TROE T5,-1 ;FIRST TIME THIS WAS CALLED?
IDPB T2,T1 ;NO, OUTPUT THE COMMA
MOVEI T2,(T1) ;GET CURRENT ADDRESS POINTER IS AT
CAIGE T2,LINBUF+^D11 ;GETTING NEAR THE END OF THE LINE?
JRST MAPTYC ;NO, SKIP THE CRLF NOW
MOVEI T2,[ASCIZ/
/] ;YES, GET A CRLF
PUSHJ P,STROUT ;OUTPUT IT
IDPB ZZ,T1 ;MAKE STRING ASCIZ
HRROI T1,LINBUF ;POINT TO IT
PSOUT ;AND OUTPUT IT
MOVE T1,[POINT 7,LINBUF] ;REINITIALIZE BYTE POINTER
MAPTYC: MOVEI T2," " ;GET A SPACE
IDPB T2,T1 ;SPACE OVER FROM LAST OUTPUT
MOVE T2,PAGBEG ;GET FIRST PAGE OF THE RANGE
PUSHJ P,DECOUT ;OUTPUT IT
MOVE T2,PAGEND ;GET SECOND PAGE OF THE RANGE
CAMN T2,PAGBEG ;SAME AS FIRST PAGE?
POPJ P, ;YES, DON'T TYPE IT
MOVEI T3,"-" ;GET A DASH
IDPB T3,T1 ;STORE IT
JRST DECOUT ;OUTPUT SECOND NUMBER AND RETURN
SUBTTL ROUTINE TO TYPE INFO ABOUT A FILE
;THIS ROUTINE TYPES OUT THE VARIOUS PARAMETERS OF A FILE. IS THE
;ROUTINE TO PROCESS THE "INFO FDB" COMMAND.
INFFDB: HRROI T1,[ASCIZ/
FDB for file /] ;GET TEXT
PSOUT ;TYPE IT
MOVE T1,SPCPTR ;GET SPEC POINTER
IDIVI T1,MAXUP ;GET MODULP NUMBER OF SPECS
IMULI T2,SPECSZ ;MULTIPLY BY SIZE OF EACH SPEC
HRROI T1,SPECS(T2) ;POINT TO SPEC
PSOUT ;TYPE IT
PUSHJ P,CRLF ;AND A CRLF
PUSHJ P,CRLF ;AND ANOTHER
MOVSI I,-TABNUM ;GET READY TO LOOP OVER ALL FIELDS
VERLOP: SKIPGE TABTXT(I) ;FIELD ALWAYS TO BE OUTPUT EVEN IF ZERO?
JRST VERLP0 ;YES, GO DO IT
LDB T1,TABPTR(I) ;NO, GET FIELD VALUE
JUMPE T1,VERLPN ;IF ZERO, SKIP THE OUTPUT
VERLP0: MOVE T1,[POINT 7,LINBUF] ;GET POINTER TO BUFFER
MOVE T2,TABMSK(I) ;GET MASK FOR FIELD
AOJE T2,VERLP1 ;JUMP IF WAS FOR WHOLE WORD
MOVEI T2,[ASCIZ/ /] ;PARTIAL WORD, GET SOME SPACES
PUSHJ P,STROUT ;INDENT THIS LINE
MOVE T2,TABSYM(I) ;GET SYMBOL FOR THIS FIELD
PUSHJ P,SIXOUT ;OUTPUT IT
MOVEI T2,[ASCIZ/ (/] ;GET TEXT
PUSHJ P,STROUT ;TYPE IT
MOVE T3,TABPTR(I) ;GET BYTE POINTER FOR FIELD
HRRI T3,[-1] ;POINT TO ALL ONES
LDB T2,T3 ;GET BYTE
PUSHJ P,OCTOUT ;TYPE THE FIELD
MOVEI T2,"B" ;GET CHARACTER
IDPB T2,T1 ;STORE IT
MOVEI T2,^D35 ;GET BIT COUNT READY
LDB T3,[POINT 6,TABPTR(I),5] ;GET BYTE POSITION
SUBI T2,(T3) ;SUBTRACT TO GET POSITION
PUSHJ P,DECOUT ;OUTPUT IT
MOVEI T2,")" ;GET TRAILING PARANTHESIS
IDPB T2,T1 ;STORE IT
JRST VERLP2 ;AND GO FINISH UP
VERLP1: MOVE T2,TABWRD(I) ;FULL WORD VALUE, GET OFFSET
MOVEI T3," " ;GET A SPACE READY
CAIGE T2,^O10 ;NEED TWO DIGITS?
IDPB T3,T1 ;NO, THEN SPACE OVER
PUSHJ P,OCTOUT ;TYPE OFFSET
MOVEI T2,[ASCIZ/ /] ;GET A FEW MORE SPACES
PUSHJ P,STROUT ;OUTPUT THEM
MOVE T2,TABSYM(I) ;GET SYMBOL FOR WORD
PUSHJ P,SIXOUT ;OUTPUT IT
VERLP2: MOVEI T2,[ASCIZ/ - /] ;MORE TEXT
PUSHJ P,STROUT ;TYPE IT
MOVE T2,TABTXT(I) ;GET TEXT STRING FOR FIELD
PUSHJ P,STROUT ;OUTPUT THAT TOO
MOVEI T2,[ASCIZ/: /] ;GET FINAL TEXT
PUSHJ P,STROUT ;TYPE THAT
PUSHJ P,@TABADR(I) ;GO TYPE VALUE
MOVEI T2,[ASCIZ/
/] ;GET A CRLF
PUSHJ P,STROUT ;OUTPUT IT ALSO
IDPB ZZ,T1 ;MAKE WHOLE STRING ASCIZ
HRROI T1,LINBUF ;POINT TO BUFFER
PSOUT ;TYPE THE LINE
VERLPN: AOBJN I,VERLOP ;LOOP OVER ALL FIELDS TO TYPE
IORI F,FR.AGN ;SAY TO DO FILE AGAIN
JRST CRLF ;GIVE A CRLF AND RETURN
SUBTTL ROUTINES USED IN TYPEOUT OF FIELDS
;ALL ROUTINES HERE SEND THEIR OUTPUT TO A STRING USING THE BYTE
;POINTER IN AC T1. ARGUMENTS FOR TYPEOUT ALWAYS GO INTO AC T2.
TYPDEC: LDB T2,TABPTR(I) ;GET NUMBER TO TYPE
TYPDC1: PUSHJ P,DECOUT ;OUTPUT IT
MOVEI T2,"." ;GET A PERIOD
IDPB T2,T1 ;OUTPUT IT TO INDICATE DECIMAL NUMBER
POPJ P, ;RETURN
TYPHLF: LDB T5,TABPTR(I) ;GET NUMBER
TLNN T5,-1 ;LARGER THAN A HALFWORD?
JRST TYPHLR ;NO, SKIP SOME
HLRZ T2,T5 ;YES, GET LEFT HALF
PUSHJ P,OCTOUT ;OUTPUT IT
MOVEI T2,[ASCIZ/,,/] ;GET SOME COMMAS
PUSHJ P,STROUT ;OUTPUT IT
TYPHLR: HRRZ T2,T5 ;GET RIGHT HALF
JRST OCTOUT ;OUTPUT IT AND RETURN
TYPHLD: LDB T5,TABPTR(I) ;GET VALUE TO TYPE
HLRZ T2,T5 ;GET LEFT HALF
PUSHJ P,TYPDC1 ;OUTPUT IT IN DECIMAL
MOVEI T2,[ASCIZ/,,/] ;GET COMMAS
PUSHJ P,STROUT ;OUTPUT THEM
HRRZ T2,T5 ;GET OTHER HALF
JRST TYPDC1 ;OUTPUT IN DECIMAL AND RETURN
TYPBIT: LDB T3,TABPTR(I) ;GET ONE BIT QUANTITY
MOVEI T2,[ASCIZ/YES/] ;GET POSSIBLE STRING
JUMPN T3,STROUT ;IF TRUE, TYPE OUT STRING
MOVEI T2,[ASCIZ/NO/] ;NOT TRUE, GET OTHER STRING
JRST STROUT ;AND OUTPUT THAT
TYPDAT: LDB T2,TABPTR(I) ;GET DATE AND TIME
SETZ T3, ;FULL OUTPUT
DATOUT: JUMPE T2,DATNON ;ZERO, GO TYPE NONE
ODTIM ;OUTPUT IT
ERJMP ERRSTR ;FAILED
POPJ P, ;AND RETURN
DATNON: MOVEI T2,[ASCIZ/ NEVER/] ;GET TEXT
JRST STROUT ;OUTPUT IT AND RETURN
TYPAUT: SKIPA T2,[Z (.GFAUT)] ;GET FUNCTION FOR AUTHOR
TYPLWR: MOVSI T2,.GFLWR ;GET FUNCTION FOR LAST WRITER
PUSH P,T2 ;SAVE FUNCTION
LDB T2,TABPTR(I) ;GET DATA
PUSHJ P,TYPHLF ;TYPE IT
MOVEI T2,[ASCIZ/ ==> /] ;GET TEXT
PUSHJ P,STROUT ;TYPE IT
MOVE T2,T1 ;MOVE BYTE POINTER
POP P,T1 ;RESTORE FUNCTION CODE
HRR T1,JFN ;AND PUT IN JFN
GFUST ;STORE THE DATA
ERJMP ERRSTR ;CAN'T
MOVE T1,T2 ;MOVE BYTE POINTER BACK
POPJ P, ;DONE
TYPACT: LDB T2,TABPTR(I) ;GET DATA
PUSHJ P,TYPHLF ;TYPE IT
MOVEI T2,[ASCIZ/ ==> /] ;GET TEXT
PUSHJ P,STROUT ;OUTPUT IT
MOVE T2,JFN ;GET JFN OF FILE
MOVX T3,FLD (.JSAOF,JS%ACT) ;GET BITS FOR ACCOUNT TYPEOUT
JFNS ;STORE THE ACCOUNT STRING
ERJMP ERRSTR ;FAILED
POPJ P, ;DONE
SUBTTL ROUTINE TO SET PARAMETERS OF FILE
;THIS IS THE COMPLEMENTARY COMMAND TO VERBOSE. WE ASK HIM WHAT HE
;WANTS TO CHANGE AND THEN WE DO IT WITH A CHFDB. THE "SET" COMMAND.
CMDSET: MOVEI T2,[FLDDB. (.CMKEY,,SETTAB,<
>)] ;SET UP
PUSHJ P,COMMND ;READ A KEYWORD
MOVE T2,(T2) ;GET DISPATCH ADDRESS
PUSHJ P,(T2) ;CALL ROUTINE FOR THIS ARG
IORI F,FR.AGN ;SAY TO DO FILE AGAIN
POPJ P, ;RETURN
SETTAB: SETLEN,,SETLEN ;HEADER FOR TABLE
AA 1ST-BACKUP-WORD,SET1BW ;FIRST BACKUP WORD
AA 2ND-BACKUP-WORD,SET2BW ;SECOND BACKUP WORD
AA 3RD-BACKUP-WORD,SET3BW ;THIRD BACKUP WORD
AA 4TH-BACKUP-WORD,SET4BW ;FOURTH BACKUP WORD
AA 5TH-BACKUP-WORD,SET5BW ;FIFTH BACKUP WORD
AA ACCOUNT,SETACT ;ACCOUNT
AA AUTHOR,SETAUT ;AUTHOR OF FILE
AA BYTE-COUNT,SETBYC ;SET COUNT OF BYTES
AA COUNT-OF-REFERENCES,SETRFC ;NUMBER OF REFERENCES
AA CREATION-DATE,SETCRV ;DATE FILE WAS CREATED
AA DATE-LAST-WRITTEN,SETWRT ;DATE FILE WAS WRITTEN
AA FILE-CLASS-FIELD,SETCLS ;SET FILE CLASS FIELD
AA GENERATION-RETENTION-COUNT,SETRET ;RETENTION COUNT
AA LAST-WRITER,SETLWR ;LAST WRITER
AA MODE-LAST-WRITTEN,SETMOD ;DATA MODE
AA NOT,SETNOT ;SET NOT ARGUMENT
AA P,PROTCM,CM%ABR+CM%INV ;ABBREVIATION OF PROTECTION
AA PAGE-COUNT,SETPAG ;SET PAGE COUNT
AA PERMANENT,SETPER ;SET FILE AS PERMANENT
PROTCM: AA PROTECTION,SETPRT ;SET FILE PROTECTION
AA REFERENCED-LAST-DATE,SETREF ;DATE WAS LAST REFERENCED
AA SAVED-BY-BACKUP-SYSTEM,SETSAV ;SAVED BY DUMPER
AA SIZE-OF-BYTES,SETBYS ;SET BYTE SIZE
AA SYSTEM-DATE-WRITTEN,SETCRE ;DATE WAS WRITTEN (SYSTEM)
AA TEMPORARY,SETTMP ;SET FILE AS TEMPORARY
AA USER-SETTABLE-WORD,SETUSW ;USER SETTABLE WORD
AA WRITE-COUNT,SETWRC ;NUMBER OF WRITES
SETLEN==.-SETTAB-1 ;NUMBER OF ENTRIES IN TABLE
SETNTB: SETNLN,,SETNLN ;HEADER FOR NOT TABLE
AA PERMANENT,SETNPR ;SET NOT PERMANENT
AA SAVED-BY-BACKUP-SYSTEM,SETNSV ;SET NOT TO BE SAVED
AA TEMPORARY,SETNTE ;SET NOT TEMPORARY
SETNLN==.-SETNTB-1 ;NUMBER OF ENTRIES
;ROUTINES TO SET VARIOUS PARAMETERS OF THE FILE. IF ANY ERROR
;ENCOUNTERED, THEY DO NOT RETURN, BUT INSTEAD TRAP TO ERRSTR.
SETPRT: MOVEI T2,[FLDDB. (.CMNUM,,^D8)] ;SET FOR OCTAL INPUT
PUSHJ P,COMMND ;READ IT
MOVE T4,T2 ;SAVE IT
PUSHJ P,CONFRM ;END THE LINE
TLNE T4,-1 ;GIVE ILLEGAL VALUE?
ILLARG Illegal protection specified
MOVSI T1,.FBPRT ;SET UP FDB INDEX
MOVEI T2,-1 ;AND MASK
MOVE T3,T4 ;MOVE PROTECTION TO RIGHT AC
CHGFDB: HRR T1,JFN ;PUT IN JFN OF FILE TO CHANGE
CHFDB ;CHANGE THE PARAMETER
ERJMP ERRSTR ;FAILED
POPJ P, ;DID IT, RETURN
SETBYC: MOVEI T2,[FLDDB. (.CMNUM,,^D10)] ;SET UP
PUSHJ P,COMMND ;READ VALUE
MOVE T4,T2 ;SAVE IT
PUSHJ P,CONFRM ;CONFIRM THE COMMAND
MOVE T3,T4 ;PUT VALUE IN RIGHT AC
SETO T2, ;MASK IS ALL ONES
MOVSI T1,.FBSIZ ;OFFSET INTO THE FDB
JRST CHGFDB ;GO CHANGE IT AND RETURN
SETBYS: MOVEI T2,[FLDDB. (.CMNUM,,^D10)] ;SET UP
PUSHJ P,COMMND ;READ THE NUMBER
MOVE T4,T2 ;SAVE IT
PUSHJ P,CONFRM ;CONFIRM THE COMMAND
MOVX T2,FB%BSZ ;GET MASK
MOVSI T1,.FBBYV ;AND INDEX INTO FDB
MOVE T3,T4 ;PUT VALUE IN RIGHT AC
ROT T3,^D24 ;POSITION THE NUMBER
TDNE T3,[-1-FB%BSZ] ;TYPED ILLEGAL VALUE?
ILLARG Illegal byte size specified
JRST CHGFDB ;IS OK, GO CHANGE IT
SETRET: MOVEI T2,[FLDDB. (.CMNUM,,^D10)] ;GET READY
PUSHJ P,COMMND ;READ VALUE
MOVE T4,T2 ;SAVE IT
PUSHJ P,CONFRM ;CONFIRM THE VALUE
MOVSI T1,.FBBYV ;SET UP INDEX
MOVX T2,FB%RET ;GET MASK
MOVE T3,T4 ;PUT VALUE IN RIGHT AC
ROT T3,-6 ;POSITION IT
TDNE T3,[-1-FB%RET] ;EXTRA JUNK?
ILLARG Illegal generation retention count specified
JRST CHGFDB ;IS OK, GO CHANGE IT
SETNOT: MOVEI T2,[FLDDB. (.CMKEY,,SETNTB,<
>)] ;SET UP
PUSHJ P,COMMND ;READ KEYWORD
MOVE T4,(T2) ;GET ADDRESS TO GO TO
PUSHJ P,CONFRM ;END THE COMMAND
JRST (T4) ;GO DO THE FUNCTION
SETPER: PUSHJ P,CONFRM ;END THE COMMAND
MOVSI T1,.FBCTL ;GET ADDRESS TO SET
MOVX T2,FB%PRM ;GET MASK
MOVE T3,T2 ;AND VALUE
JRST CHGFDB ;GO CHANGE VALUE
SETTMP: PUSHJ P,CONFRM ;CONFIRM THE COMMAND
MOVSI T1,.FBCTL ;ADDRESS TO CHANGE
MOVX T2,FB%TMP ;AND BIT TO CHANGE
MOVE T3,T2 ;COPY IT
JRST CHGFDB ;GO DO IT
SETNPR: SKIPA T2,[EXP FB%PRM] ;GET BIT TO CLEAR
SETNTE: MOVX T2,FB%TMP ;OR OTHER BIT
MOVSI T1,.FBCTL ;ADDRESS TO CHANGE
SETZ T3, ;CLEAR THE BIT
JRST CHGFDB ;DO DO IT
SETUSW: MOVEI T2,[FLDDB. (.CMNUM,,^D8)] ;FUNCTION FOR OCTAL
PUSHJ P,COMMND ;READ IT
MOVE T4,T2 ;SAVE IT
PUSHJ P,CONFRM ;END LINE
MOVSI T1,.FBUSW ;WORD TO SET
SETO T2, ;WHOLE WORD
MOVE T3,T4 ;GET VALUE
JRST CHGFDB ;GO DO IT
SETWRT: SKIPA T5,[.RSWRT] ;GET CODE FOR DATE LAST WRITTEN
SETCRV: MOVEI T5,.RSCRV ;GET CODE FOR CREATION DATE
JRST SETDAT ;GO SET THE DATE
SETREF: SKIPA T5,[.RSREF] ;GET CODE FOR DATE LAST REFERENCED
SETCRE: MOVEI T5,.RSCRE ;GET CODE FOR SYSTEM DATE OF WRITE
SETDAT: MOVEI T2,[FLDDB. (.CMTAD,,CM%IDA+CM%ITM)] ;GET SET
PUSHJ P,COMMND ;READ DATE AND TIME
MOVE T4,T2 ;SAVE IT
PUSHJ P,CONFRM ;CONFIRM THE COMMAND
HRRZ T1,JFN ;GET JFN OF FILE
MOVEI T2,DATBLK ;POINT TO BLOCK OF DATES
MOVE T3,[DATBLK,,DATBLK+1] ;GET READY
SETOM DATBLK ;CLEAR FIRST WORD OF BLOCK
BLT T3,DATBLK+3 ;CLEAR REST ALSO
MOVEI T3,4 ;GET NUMBER OF ARGUMENTS
MOVEM T4,DATBLK(T5) ;STORE PROPER DATE AWAY
SFTAD ;SET IT
ERJMP ERRSTR ;FAILED
POPJ P, ;OK, RETURN
SETAUT: SKIPA T4,[.SFAUT] ;GET CODE FOR AUTHOR
SETLWR: MOVEI T4,.SFLWR ;OR FOR LAST WRITER
MOVEI T2,[FLDDB. (.CMUSR)] ;FUNCTION TO READ USER NAME
PUSHJ P,COMMND ;READ IT
MOVE T2,[ATMBUF,,TMPBUF] ;GET READY
BLT T2,TMPBUF+TXTLEN/5 ;COPY ATOM BUFFER
PUSHJ P,CONFRM ;CONFIRM THE COMMAND
MOVSI T1,(T4) ;SET UP CODE
HRR T1,JFN ;AND JFN OF FILE
HRROI T2,TMPBUF ;POINT TO USER NAME
SFUST ;SET AUTHOR OR LAST WRITER
ERJMP ERRSTR ;FAILED
POPJ P, ;OK, RETURN
SETPAG: MOVEI T2,[FLDDB. (.CMNUM,,^D10)] ;SET UP
PUSHJ P,COMMND ;READ IT
MOVE T4,T2 ;SAVE IT
PUSHJ P,CONFRM ;EAT REST OF LINE
MOVSI T1,.FBBYV ;GET OFFSET IN FDB
MOVX T2,FB%PGC ;AND MASK
MOVE T3,T4 ;GET ARG
TLNE T3,-1 ;ILLEGAL?
ILLARG Illegal page count specified
JRST CHGFDB ;NO, GO SET IT
SET1BW: JSP T4,SETBAC ;FIRST BACKUP WORD
SET2BW: JSP T4,SETBAC ;SECOND WORD
SET3BW: JSP T4,SETBAC ;AND THIRD
SET4BW: JSP T4,SETBAC ;AND FOURTH
SET5BW: JSP T4,SETBAC ;AND FIFTH
SETBAC: SUBI T4,SET2BW ;COMPUTE OFFSET OF WORD TO SET
MOVEI T2,[FLDDB. (.CMNUM,,^D8)] ;GET READY
PUSHJ P,COMMND ;READ IT
MOVE T5,T2 ;SAVE IT
PUSHJ P,CONFRM ;THEN EAT END OF LINE
MOVSI T1,.FBBK0(T4) ;GET WORD TO BE CHANGED
SETO T2, ;THE WHOLE WORD
MOVE T3,T5 ;GET THE VALUE
JRST CHGFDB ;GO SET IT
SETACT: MOVEI T2,[FLDDB. (.CMFLD,,,<account string>)] ;SET UP
PUSHJ P,COMMND ;DO IT
MOVE T2,[ATMBUF,,TMPBUF] ;GET SET
BLT T2,TMPBUF+TXTLEN/5 ;COPY TEXT TO GOOD PLACE
PUSHJ P,CONFRM ;THEN LOOK FOR END OF LINE
HRRZ T1,JFN ;GET JFN OF FILE
HRROI T2,TMPBUF ;POINT TO TEXT
SACTF ;SET THE ACCOUNT STRING
ERJMP ERRSTR ;FAILED
POPJ P, ;OK, RETURN
SETMOD: MOVEI T2,[FLDDB. (.CMNUM,,^D8)] ;SET TO READ OCTAL
PUSHJ P,COMMND ;DO IT
MOVE T4,T2 ;SAVE NUMBER
PUSHJ P,CONFRM ;THEN EAT LINE
MOVSI T1,.FBBYV ;GET WORD
MOVX T2,FB%MOD ;AND MASK
MOVE T3,T4 ;PUT ARG IN RIGHT AC
ROT T3,^D18 ;POSITION IT CORRECTLY
TDNE T3,[-1-FB%MOD] ;ILLEGAL ARGUMENT?
ILLARG Illegal data mode specified
JRST CHGFDB ;OK, GO SET IT
SETRFC: SKIPA T5,[777777] ;GET MASK FOR REFERENCE COUNT
SETWRC: MOVSI T5,-1 ;OR FOR WRITE COUNT
MOVEI T2,[FLDDB. (.CMNUM,,^D10)] ;GET READY
PUSHJ P,COMMND ;READ NUMBER
MOVE T4,T2 ;SAVE IT
PUSHJ P,CONFRM ;CONFIRM COMMAND
MOVSI T1,.FBCNT ;GET WORD TO CHANGE
MOVE T2,T5 ;GET HALFWORD WE ARE SETTING
MOVE T3,T4 ;GET VALUE
TLNE T3,-1 ;ILLEGAL?
ILLARG Illegal count specified
TRNN T2,-1 ;VALUE GOES IN LEFT HALF?
MOVSI T3,(T3) ;YES, PUT IT THERE
JRST CHGFDB ;AND GO SET IN FDB
SETSAV: PUSHJ P,CONFRM ;CONFIRM THE LINE
MOVSI T1,.FBCTL ;GET WORD BIT IS IN
MOVX T2,FB%NOD ;AND MASK
SETZ T3, ;SET TO CLEAR BIT
JRST CHGFDB ;GO DO IT
SETNSV: MOVSI T1,.FBCTL ;GET WORD TO CHANGE
MOVX T2,FB%NOD ;AND BIT
SETO T3, ;SAY TO TURN IT ON
JRST CHGFDB ;GO DO IT
SETCLS: MOVEI T2,[FLDDB. (.CMNUM,,^D8)] ;SET UP
PUSHJ P,COMMND ;PARSE IT
MOVE T4,T2 ;SAVE IT
PUSHJ P,CONFRM ;END THE LINE
MOVSI T1,.FBCTL ;GET OFFSET IN FDB
MOVX T2,FB%FCF ;AND MASK
MOVS T3,T4 ;AND VALUE
TDNE T3,[-1-FB%FCF] ;ILLEGAL VALUE?
ILLARG Illegal class field specified
JRST CHGFDB ;OK, GO SET IT
SUBTTL ROUTINE TO PRINT FILE ON LINE PRINTER
;THIS ROUTINE COPIES THE FILE TO DEVICE LPT:. THE "LIST" COMMAND.
;IS ESSENTIALLY THE SAME AS THE COMMAND "COPY (TO) LPT:"
CMDLST: MOVEI T2,[ASCIZ/TO LPT/] ;GET NOISE TEXT
PUSHJ P,NOISE ;PARSE IT
PUSHJ P,CONFRM ;CONFIRM IT
MOVE T1,[POINT 7,TMPBUF] ;POINT TO A BUFFER
MOVEI T2,[ASCIZ/LPT:/] ;GET DEVICE
PUSHJ P,STROUT ;COPY STRING TO BUFFER
HRRZ T2,JFN ;GET JFN OF FILE
MOVE T3,[1B8+1B11+JS%PAF] ;GET FLAGS
JFNS ;STORE FILENAME AND EXTENSION
ERJMP ERRSTR ;FAILED
IDPB ZZ,T1 ;MAKE ASCIZ STRING
MOVX T1,GJ%SHT+GJ%NEW+GJ%PHY ;GET BITS
HRROI T2,TMPBUF ;POINT TO BUFFER
GTJFN ;GET A JFN
ERJMP ERRSTR ;FAILED
HRRZM T1,JFNOUT ;AND SAVE IT
JRST DOCOPY ;AND JOIN COPY CODE
SUBTTL ROUTINE TO COPY A FILE
;THIS ROUTINE IS USED TO COPY THE FILE WE ARE CURRENTLY WORKING
;ON TO ANOTHER FILE. THE DEFAULT DEVICE AND DIRECTORY IS THE
;CONNECTED DIRECTORY, WHILE THE DEFAULT FILE NAME IS THE SAME
;AS THE INPUT. CAN ONLY COPY TO ANOTHER DISK FILE. THE "COPY"
;COMMAND.
CMDCPY: MOVEI T2,[ASCIZ/TO/] ;GET NOISE
PUSHJ P,NOISE ;PROCESS IT
PUSHJ P,DEFALN ;DEFAULT JUST THE FILE NAME
MOVEI T1,KEYBLK ;RESET POINTER TO COMND BLOCK
MOVEI T2,[FLDDB. (.CMFIL)] ;FILE SPEC FUNCTION
PUSHJ P,COMMND ;READ IT
HRRZM T2,JFNOUT ;SAVE OUTPUT JFN
PUSHJ P,CONFRM ;CONFIRM THE COMMAND
DOCOPY: PUSHJ P,OPEN ;OPEN THE FILE FOR READING
HRRZ T1,JFN ;GET JFN AGAIN
MOVSI T2,.FBLWR+1 ;GET READY TO READ FDB AGAIN
MOVEI T3,FDB ;SINCE RACE CONDITION COULD HAPPEN
GTFDB ;DO IT
ERJMP ERRSTR ;CAN'T
MOVE T1,JFNOUT ;GET OUTPUT FILE
MOVX T2,OF%WR+OF%NWT ;AND FLAGS
OPENF ;OPEN IT FOR WRITING
ERJMP ERRSTR ;CAN'T
IORI F,FR.OP2 ;REMEMBER HAVE IT OPEN
SETOM PAGE ;INITIALIZE PAGE COUNTER
;HERE TO LOOP OVER ALL PAGES, DOING THE COPY:
CPYLOP: PUSHJ P,PAGMAP ;MAP IN THE NEXT PAGE
JRST CPYDON ;NO MORE, GO FINISH UP
MOVS T1,PAGADR ;GET ADDRESS TO COPY FROM
HRR T1,PAGAD2 ;AND ADDRESS TO COPY TO
MOVE T2,PAGAD2 ;GET ADDRESS OF OUTPUT PAGE
BLT T1,777(T2) ;COPY IT ALL
MOVE T1,PAGNU2 ;GET PAGE NUMBER
HRLI T1,.FHSLF ;AND MY OWN PROCESS HANDLE
MOVE T2,PAGE ;GET PAGE OF FILE WE ARE WRITING
HRL T2,JFNOUT ;AND JFN OF FILE
MOVX T3,PM%WR ;WANT TO WRITE THE PAGE
PMAP ;OUTPUT THE PAGE
ERJMP ERRSTR ;ERROR
JRST CPYLOP ;THEN LOOP FOR NEXT PAGE
;HERE WHEN ALL DONE, TO CLOSE FILES AND UPDATE FDBS:
CPYDON: MOVE T1,JFNOUT ;GET JFN AGAIN
HRLI T1,.FBSIZ(CF%NUD) ;SET BIT AND OFFSET
SETO T2, ;WANT WHOLE WORD CHANGED
MOVE T3,FDB+.FBSIZ ;GET INFORMATION FROM FILE
CHFDB ;SET IT
ERJMP ERRSTR ;FAILED
HRLI T1,.FBBYV ;GET OFFSET TO CHANGE NOW
MOVX T2,FB%BSZ ;WANT TO CHANGE BYTE SIZE ONLY
MOVE T3,FDB+.FBBYV ;GET DATA FROM INPUT FILE
CHFDB ;SET THAT TOO
ERJMP ERRSTR ;CAN'T
HRRZ T1,JFNOUT ;GET JFN
CLOSF ;CLOSE THE FILE
ERJMP ERRSTR ;ERROR
ANDCMI F,FR.OP2 ;FILE NO LONGER OPENED
SETZM JFNOUT ;AND JFN NO LONGER ASSIGNED
POPJ P, ;RETURN
SUBTTL ROUTINE TO RENAME A FILE
;COMMAND TO RENAME A FILE TO ANOTHER NAME. NOTICE THAT ALL DEFAULTS
;WILL BE THAT OF THE INPUT FILE, EVEN THE DEVICE AND DIRECTORY, FOR
;THAT IS WAS IS GENERALLY WANTED. THE "RENAME" COMMAND.
CMDREN: MOVEI T2,[ASCIZ/TO/] ;GET NOISE WORD
PUSHJ P,NOISE ;PARSE IT
PUSHJ P,DEFALT ;SET UP FULL DEFAULT
MOVEI T1,KEYBLK ;POINT TO COMND BLOCK TO USE
MOVEI T2,[FLDDB. (.CMFIL)] ;FUNCTION FOR OUTPUT FILE
PUSHJ P,COMMND ;READ IT
HRRZM T2,JFNOUT ;SAVE OUTPUT JFN
PUSHJ P,CONFRM ;LOOK FOR THE END OF LINE
MOVE T5,SPCPTR ;SAVE CURRENT SPEC POINTER
PUSHJ P,NEXT ;ADVANCE TO NEXT SPEC SO CAN DO RENAME
JFCL ;DON'T CARE IF NO MORE FILES
IORI F,FR.ADV ;REMEMBER WE ADVANCED ALREADY
MOVE T1,JFN ;GET JFN OF FILE TO RENAME
MOVE T2,JFNOUT ;AND JFN OF FILE TO RENAME TO
RNAMF ;RENAME THE FILE
ERJMP ERRSTR ;FAILED, RETURN
SETZM JFN ;RENAME CLEARS THE JFN
MOVE T1,T5 ;GET POINTER FOR SPEC WE RENAMED
IDIVI T1,MAXUP ;GET INDEX INTO FLAG TABLE
HLLZS FLAGS(T2) ;CLEAR RIGHT HALF OF FLAG WORD
POPJ P, ;RETURN
SUBTTL ROUTINE TO BACK UP TO A PREVIOUS FILE
;CALLED TO GO BACK AND REDO THE PREVIOUS FILE SPECIFICATION BEFORE
;THE PRESENT ONE. THE "BACKUP" COMMAND. USED IF THE USER TYPED
;A CRLF FOR A FILE, AND REGRETTED IT. CAN ONLY BACK UP A CERTAIN
;NUMBER OF FILES TOTAL, SINCE WE HAVE TO STORE ALL THE FILE SPECS.
CMDBAC: MOVEI T2,[ASCIZ/BY/] ;GET NOISE
PUSHJ P,NOISE ;EAT IT UP
MOVEI T2,[FLDDB. (.CMNUM,,^D10,,<1>)] ;SET UP TO GET NUMBER
PUSHJ P,COMMND ;READ ARGUMENT
MOVEM T2,BACTRY ;SAVE NUMBER OF SPECS TO BACK UP BY
MOVEI T2,[ASCIZ/FILES/] ;MORE NOISE
PUSHJ P,NOISE ;PARSE IT
PUSHJ P,CONFRM ;LOOK FOR A GOOD END OF LINE
MOVEI T1,-1 ;GET A LARGE VALUE
SKIPGE BACTRY ;DID HE SPECIFY A NEGATIVE NUMBER?
MOVEM T1,BACTRY ;YES, REPLACE VALUE
SETZ T1, ;CLEAR NUMBER OF FILES BACKED UP SO FAR
BACLOP: SKIPG BACTRY ;BACKED UP ALL FILES WE ASKED FOR?
JRST BACDON ;YES, GO SET THINGS NOW
MOVE T2,BACNUM ;GET NUMBER OF FILES ALREADY BACKED UP
ADD T2,T1 ;ADD NUMBER WE ARE ALSO BACKING UP BY
CAIGE T2,MAXUP-1 ;MAKE SURE AREN'T EXCEEDING OUR STORAGE
CAML T1,SPCPTR ;AND THAT WE AREN'T GOING OFF THE TOP
JRST BACDON ;TOO FAR BACK, STOP NOW
MOVE T2,SPCPTR ;GET CURRENT SPEC POINTER
SUB T2,T1 ;COMPUTE POINTER TO SPEC BACKING UP TO
IDIVI T2,MAXUP ;GET INDEX INTO FLAG TABLE
MOVE T2,FLAGS(T3) ;GET FLAGS FOR THIS SPEC
TLNE T2,(GN%STR+GN%DIR) ;CHANGING DIRECTORIES?
IORI F,FR.HDR ;YES, REMEMBER TO TYPE A HEADER
SOSGE T3 ;BACK UP TO PREVIOUS FLAG WORD
MOVEI T3,MAXUP-1 ;WRAPPED AROUND, RESET TO END
MOVE T2,FLAGS(T3) ;GET FLAGS FOR SPEC BACKING UP TO
TRNE T2,-1 ;WAS THAT SPEC EXPUNGED OR RENAMED?
SOS BACTRY ;NO, THEN DECREMENT COUNT OF FILES TO DO
AOJA T1,BACLOP ;COUNT BACKUP AND LOOK AT NEXT FILE
;HERE WHEN WE HAVE BACKED UP ALL THE AMOUNT WE WERE SUPPOSED TO.
;FIX THINGS UP SO WE WILL START AT THE RIGHT PLACE.
BACDON: ADDM T1,BACNUM ;ADD TO NUMBER OF SPECS ALREADY BACKED UP
MOVN T1,T1 ;GET NEGATIVE
ADDM T1,SPCPTR ;DECREMENT SPEC POINTER BY AMOUNT ALSO
PUSHJ P,CLOSE ;RELEASE THE PRESENT JFN
PUSHJ P,CPYJFN ;GET A NEW ONE FOR WHERE WE ARE
IORI F,FR.AGN ;SAY WE WANT TO DO FILE "AGAIN"
POPJ P, ;AND RETURN
SUBTTL ROUTINE TO DELETE AND EXPUNGE A FILE
;ROUTINE TO EXPUNGE A FILE TOTALLY. THE "EXPUNGE" COMMAND.
;NO WAY TO GET THE FILE BACK WITH THIS COMMAND, SO USUALLY
;PEOPLE SHOULD USE THE DELETE COMMAND INSTEAD.
CMDEXP: MOVEI T2,[ASCIZ/!!/] ;GET NOISE WORD TO WARN HIM
PUSHJ P,NOISE ;PARSE IT
PUSHJ P,CONFRM ;MAKE SURE CRLF WAS TYPED
MOVE T5,SPCPTR ;GET POINTER FOR PRESENT SPEC
PUSHJ P,NEXT ;ADVANCE TO NEXT FILE NOW SO CAN EXPUNGE
JFCL ;DON'T CARE IF NO MORE FILES
IORI F,FR.ADV ;SAY WE ADVANCED ALREADY
MOVE T1,JFN ;GET JFN OF FILE
HRLI T1,(DF%EXP) ;SET THE EXPUNGE BIT
DELF ;DELETE AND EXPUNGE THE FILE
ERJMP ERRSTR ;FAILED, RETURN
SETZM JFN ;JFN WAS RELEASED BY THE EXPUNGE
MOVE T1,T5 ;GET POINTER TO SPEC WE DELETED
IDIVI T1,MAXUP ;COMPUTE OFFSET INTO FLAG WORD
HLLZS FLAGS(T2) ;CLEAR RIGHT HALF
POPJ P, ;AND RETURN
SUBTTL ROUTINE TO COPY A JFN AND SAVE SPECIFICATION
;CALLED TO STORE THE FULL FILE SPECIFICATION FOR A FILE
;CURRENTLY POINTED TO MY THE MAIN JFN, AND TO GET ANOTHER JFN
;ON THE FILE WHICH WE WILL ACTUALLY USE.
CPYJFN: MOVE T3,SPCPTR ;GET STORAGE POINTER
IDIVI T3,MAXUP ;DIVIDE BY NUMBER OF SPECS
IMULI T4,SPECSZ ;MULTIPLY BY SIZE OF A SPEC
SKIPLE BACNUM ;BACKED UP ANY FILES?
JRST NEWJFN ;YES, JUST GO REGET A JFN
HRROI T1,SPECS(T4) ;POINT TO STORAGE FOR SPEC
HRRZ T2,GJFN ;GET JFN
MOVE T3,[1B2+1B5+1B8+1B11+1B14+JS%PAF] ;GET BITS
JFNS ;STORE THE SPECIFICATION
ERJMP ERRSTR ;FAILED
IDPB ZZ,T1 ;STORE NULL TO MAKE ASCIZ
NEWJFN: MOVX T1,GJ%OLD+GJ%DEL+GJ%PHY+GJ%SHT+GJ%ACC ;GET FLAGS
HRROI T2,SPECS(T4) ;POINT TO STRING
GTJFN ;GET ANOTHER JFN FOR FILE
ERJMP ERRSTR ;CAN'T
MOVEM T1,JFN ;SAVE JFN FOR USE LATER
POPJ P, ;OK, RETURN
SUBTTL ROUTINES TO DEFAULT OUTPUT SPECIFICATIONS
;CALLED TO SET UP COMND BLOCK SO THAT THE DEFAULT SPEC IS
;THE SAME AS THE INPUT FILE. CALLING DEFALT SETS UP DEFAULTS
;ON EVERYTHING, CALLING DEFALN ONLY SETS UP DEFAULT FOR
;FILE NAME AND EXTENSION.
DEFALN: SETZM KEYJFB+.GJDEV ;CLEAR DEFAULT DEVICE
SETZM KEYJFB+.GJDIR ;AND DEFAULT DIRECTORY
HRRZ T2,JFN ;GET JFN OF INPUT FILE
JRST DEFAL1 ;AND GO STORE OTHER DEFAULTS
DEFALT: HRROI T1,DFTDEV ;POINT TO DEVICE STORAGE
MOVEM T1,KEYJFB+.GJDEV ;SAVE IN COMND BLOCK
HRRZ T2,JFN ;GET JFN OF INPUT FILE
MOVX T3,FLD (.JSAOF,JS%DEV) ;SET UP
JFNS ;STORE DEVICE DEFAULT
ERJMP ERRSTR ;FAILED
IDPB ZZ,T1 ;MAKE SURE NULL FOLLOWS
HRROI T1,DFTDIR ;POINT TO DIRECTORY STORAGE
MOVEM T1,KEYJFB+.GJDIR ;SAVE IN COMND BLOCK
MOVX T3,FLD (.JSAOF,JS%DIR) ;SET UP
JFNS ;STORE DIRECTORY DEFAULT
ERJMP ERRSTR ;FAILED
IDPB ZZ,T1 ;APPEND A NULL
DEFAL1: HRROI T1,DFTNAM ;POINT TO NAME STORAGE
MOVX T3,FLD (.JSAOF,JS%NAM) ;SET UP
JFNS ;STORE FILE NAME DEFAULT
ERJMP ERRSTR ;LOSE
IDPB ZZ,T1 ;APPEND A NULL
HRROI T1,DFTTYP ;POINT TO FILE "TYPE" STORAGE
MOVX T3,FLD (.JSAOF,JS%TYP) ;SET UP
JFNS ;STORE IT
ERJMP ERRSTR ;LOSE
IDPB ZZ,T1 ;AND APPEND A NULL
POPJ P, ;THEN RETURN
SUBTTL ROUTINE TO ADVANCE TO NEXT FILE
;ROUTINE TO ADVANCE TO THE NEXT FILE. THIS ROUTINE WILL
;DO THE GNJFN ON THE MAIN JFN, AND SAVE AWAY THE FLAG BITS
;IN THE STORAGE BLOCK. SKIP RETURN IF HAVE A NEW FILE, NON-SKIP
;IF HAVE LOOKED AT ALL FILES.
NEXT: TRZN F,FR.ADV ;ALREADY ADVANCED TO NEXT SPEC?
JRST NEXTDO ;NO, GO DO IT NOW
SKIPG BACNUM ;BACKED UP ANY FILES?
SKIPE GJFN ;OR MORE FILES TO DO?
CPOPJ1: AOS (P) ;YES, SKIP RETURN
CPOPJ: POPJ P, ;RETURN
NEXTDO: AOS T2,SPCPTR ;INCREMENT TO NEXT SPEC
IDIVI T2,MAXUP ;GET MODULO NUMBER OF SPECS
SKIPLE BACNUM ;BACKED UP ANY FILES?
JRST NXTBAC ;YES, GO DO THAT
SETZM FLAGS(T3) ;CLEAR THE FLAG WORD FOR THE SPEC
NEXTGT: MOVE T1,GJFN ;GET JFN AND FLAG BITS
GNJFN ;ADVANCE TO NEXT FILE
ERJMP NEXTDN ;ERROR, GO SEE IF FINISHED
IORM T1,FLAGS(T3) ;STORE THE FLAGS FOR THIS SPEC
TLNE T1,(GN%STR+GN%DIR) ;NEED A NEW HEADER?
IORI F,FR.HDR ;YES, REMEMBER TO TYPE IT
PUSHJ P,CHKNXD ;SEE IF WE HAVE SKIPPED TO WANTED FILE
JRST NEXTGT ;NO, KEEP LOOKING THEN
JRST CPOPJ1 ;YES, RETURN WITH IT
NEXTDN: HRRZ T4,GJFN ;GET THE JFN
SETZM GJFN ;AND CLEAR IT
CAIE T1,GNJFX1 ;DID WE REALLY RUN OUT OF FILES?
JRST ERRSTR ;NOPE, GO DIE
POPJ P, ;YES, RETURN
NXTBAC: MOVE T1,FLAGS(T3) ;GET FLAGS FOR THIS FILE
TLNE T1,(GN%STR+GN%DIR) ;NEED A NEW HEADER?
IORI F,FR.HDR ;YES, REMEMBER THAT
TRNE T1,-1 ;CHECK FOR FILE NO LONGER AVAILABLE
PUSHJ P,CHKNXT ;SEE IF WENT TO DESIRED FILE YET?
SOSA T1,BACNUM ;NO, DECREMENT COUNT OF BACKED UP FILES
JRST CPOPJ1 ;YES, SKIP RETURN
JRST NEXT ;SEE IF DONE YET
SUBTTL ROUTINE TO SEE IF A FILE IS WANTED
;ROUTINE TO SEE IF WE ARE SATISFIED WITH A FILE FOUND BY GNJFN.
;CALLED WITH BITS IN AC T1 DESCRIBING WHICH PARTS OF A SPECIFICATION
;HAVE CHANGED. SKIP RETURN IF CONDITION IS SATISFIED.
;CALL AT CHKNXD IF WE ARE CHECKING FOR UNDELETED FILES.
CHKNXD: PUSHJ P,CHKNXT ;SEE IF FILE IS IGNORED NORMALLY
POPJ P, ;YES, RETURN
TRNE F,FR.AUD ;UNDELETED FILES OK?
JRST CPOPJ1 ;YES, SKIP RETURN
HRRZ T1,GJFN ;GET JFN OF FILE
MOVE T2,[1,,.FBCTL] ;ONE WORD TO BE READ
MOVEI T3,T3 ;READ INTO AC T3
GTFDB ;GET THE INFORMATION
ERJMP ERRSTR ;FAILED
TXNE T3,FB%DEL ;WAS THIS FILE DELETED?
AOS (P) ;YES, SKIP RETURN
POPJ P, ;RETURN
CHKNXT: TRNN F,FR.NXT ;WANTS TO SKIP TO NEXT FILE TYPE?
JRST NEXT1 ;NO, GO ON
TLNN T1,(GN%STR+GN%DIR+GN%NAM+GN%EXT) ;DID IT CHANGE?
POPJ P, ;NO, LOOK AT NEXT FILE
NEXT1: TRNN F,FR.NXF ;WANTS TO SKIP TO NEXT FILENAME?
JRST NEXT2 ;NO, GO ON
TLNN T1,(GN%STR+GN%DIR+GN%NAM) ;YES, DID IT CHANGE?
POPJ P, ;NO, WANT NEXT FILE
NEXT2: TRNN F,FR.NXD ;WANTS TO SKIP TO NEXT DIRECTORY?
JRST NEXT3 ;NO, SKIP ON
TLNN T1,(GN%STR+GN%DIR) ;YES, DID IT CHANGE?
POPJ P, ;NOPE, KEEP WANTING NEW FILE
NEXT3: TRNE F,FR.NXS ;WANTS TO SKIP TO NEXT STRUCTURE?
TLNE T1,(GN%STR) ;YES, DID STRUCTURE CHANGE?
AOS (P) ;A GOOD FILE, SET FOR SKIP RETURN
POPJ P, ;RETURN
SUBTTL ROUTINE TO OPEN THE FILE FOR READING
;THIS ROUTINE GETS THE FILE OPENED FOR READING ONLY. WE TRY TO
;OPEN THE FILE FIRST WITH EXCLUSIVE ACCESS, IF THAT FAILS THEN
;WE TRY SIMULTANEOUS ACCESS. NO RETURN IF FAIL TO GET FILE.
OPEN: HRRZ T1,JFN ;GET JFN OF FILE
MOVX T2,OF%RD+OF%PDT+OF%NWT ;READ ONLY, NO UPDATING OF DATES
OPENF ;TRY TO OPEN FILE
ERJMP OPENTW ;FAILED, GO TRY OPENING IT THAWED
IORI F,FR.OPN ;OK, REMEMBER IT IS OPEN
POPJ P, ;AND RETURN
OPENTW: CAIE T1,OPNX9 ;IS FAILURE DUE TO INVALID SIMULTAN. ACCESS?
JRST ERRSTR ;NO, GO LOSE
HRRZ T1,JFN ;YES, THEN GET BACK JFN
MOVX T2,OF%RD+OF%PDT+OF%NWT+OF%THW ;INCLUDE THAWED BIT
OPENF ;NOW TRY TO OPEN IT
ERJMP ERRSTR ;STILL FAILED, GO COMPLAIN
IORI F,FR.OPN ;OK, REMEMBER IT IS OPEN
POPJ P, ;AND RETURN
SUBTTL ROUTINE TO MAP IN NEXT PAGE OF CURRENT FILE
;CALLED TO FIND THE NEXT USED PAGE OF THE INPUT FILE, AND TO MAP
;IT INTO THE USUAL PAGE. THE LAST PAGE MAPPED WAS IN LOCATION PAGE.
;SKIP RETURN IF NEW PAGE MAPPED IN, PAGE NUMBER IS IN LOCATION PAGE.
;NON-SKIP IF NO MORE PAGES REMAIN IN THE FILE.
PAGMAP: AOS T1,PAGE ;INCREMENT TO NEXT PAGE NUMBER
TLNE T1,-1 ;OVERFLOWED THE HALFWORD?
POPJ P, ;YES, ALL DONE
HRL T1,JFN ;GET JFN OF INPUT FILE
FFUFP ;FIND THE NEXT USED PAGE
ERJMP PAGDON ;ERROR, GO CHECK IT OUT
HRRZM T1,PAGE ;SAVE PAGE NUMBER
HRL T1,JFN ;GET JFN AGAIN
MOVE T2,PAGNUM ;GET PAGE NUMBER USED FOR MAPPING
HRLI T2,.FHSLF ;AND MY PROCESS
MOVX T3,PM%RD ;WANT TO ONLY READ THE PAGE
IORI F,FR.MAP ;REMEMBER WE HAVE PAGE MAPPED
PMAP ;MAP THE PAGE
ERJMP ERRSTR ;FAILED
SKIPA @PAGADR ;TOUCH THE PAGE TO MAKE SURE ITS OK
ERJMP ERRSTR ;IT ISN'T, LOSE
JRST CPOPJ1 ;ALL DONE, SKIP RETURN
PAGDON: CAIE T1,FFUFX3 ;FAILED BECAUSE NO MORE PAGES EXIST?
JRST ERRSTR ;NO, GO LOSE
POPJ P, ;YES, RETURN
SUBTTL ROUTINE TO CLEAN UP ALL FILES
;ROUTINE TO CLOSE OFF AND RELEASE ALL FILES WHICH MAY BE OPEN.
;THIS ROUTINE WILL ALSO RELEASE ALL JFNS EXCEPT FOR THE MAIN JFN.
;FILES WILL BE UNMAPPED IF THAT IS NECESSARY.
CLOSE: TRZN F,FR.MAP ;WAS FILE MAPPED?
JRST CLOSE1 ;NO, SKIP UNMAP THEN
SETO T1, ;-1 MEANS TO UNMAP PAGE
MOVE T2,PAGNUM ;GET PAGE WE WERE MAPPED IN AT
HRLI T2,.FHSLF ;IN MY OWN PROCESS
SETZ T3, ;ONLY THE ONE PAGE
PMAP ;RELEASE THE PAGE
ERJMP ERRSTR ;IF CAN'T, FATAL ERROR
CLOSE1: TRZN F,FR.OPN ;WAS THE FILE OPENED AT ALL?
JRST CLOSE2 ;NO, GO ON
HRRZ T1,JFN ;YES, GET JFN OF FILE
TLO T1,(CO%NRJ) ;SET BIT NOT TO RELEASE JFN
CLOSF ;CLOSE THE FILE
ERJMP ERRSTR ;SHOULD WORK, IF NOT FATAL
CLOSE2: SKIPE T1,JFN ;WAS JFN NOT OPEN?
TRNE F,FR.AGN ;OR WE GOING TO DO FILE AGAIN?
JRST CLOSE3 ;YES, GO LOOK AT OUTPUT FILE NOW
SETZM JFN ;NO, CLEAR IT
RLJFN ;AND RELEASE JFN
ERJMP ERRSTR ;ERROR
CLOSE3: TRZN F,FR.OP2 ;OUTPUT FILE OPEN?
JRST CLOSE4 ;NO, GO CHECK MORE
HRRZ T1,JFNOUT ;YES, GET JFN
CLOSF ;CLOSE IT
ERJMP ERRSTR ;ERROR
SETZM JFNOUT ;CLEAR WORD
POPJ P, ;AND RETURN
CLOSE4: SKIPN T1,JFNOUT ;HAVE A JFN FOR OUTPUT FILE?
POPJ P, ;NO, ALL DONE
SETZM JFNOUT ;YES, CLEAR IT
RLJFN ;AND RELEASE IT
ERJMP ERRSTR ;SHOULDN'T FAIL
POPJ P, ;AND ALL DONE
SUBTTL ROUTINE TO READ IN A FILE INTO INFERIOR FORK
;THIS ROUTINE IS CALLED TO CREATE AN INFERIOR FORK, AND TO
;READ IN THE DESIRED EXE FILE INTO IT. THE FORK HANDLE IS
;SAVED IN LOCATION HANDLE. THE FORK IS NOT STARTED. CALL
;REQUIRES BITS FOR GTJFN IN AC T1, AND STRING POINTER TO
;THE SPECIFICATION IN AC T2.
FORK: GTJFN ;GET A JFN ON THE FILE
ERJMP ERRSTR ;FAILED
MOVEM T1,JFNOUT ;SAVE IT
MOVX T1,CR%CAP ;SET UP BITS TO KEEP CAPABILITIES
CFORK ;CREATE AN INFERIOR
ERJMP ERRSTR ;CAN'T
MOVEM T1,HANDLE ;SAVE THE HANDLE
MOVS T1,T1 ;PUT IN LEFT HALF
HRR T1,JFNOUT ;GET JFN OF THE FILE
GET ;READ IN THE PROG INTO THE FORK
ERJMP ERRSTR ;LOSE
MOVE T1,JFNOUT ;GET JFN WE USED
RLJFN ;RELEASE IT
ERJMP CPOPJ ;IGNORE ERROR WHICH CAN OCCUR
SETZM JFNOUT ;JFN IS NO LONGER IN USE
POPJ P, ;RETURN
SUBTTL ROUTINES TO OUTPUT DATA INTO CORE STORAGE
;THE FOLLOWING ROUTINES OUTPUT USING A BYTE POINTER WHICH IS
;SUPPLIED IN AC T1. ALL ROUTINES EXCEPT FOR EOFOUT TAKE THEIR DATA
;FROM AC T2.
STROUT: HRLI T2,(POINT 7,) ;CREATE FULL BYTE POINTER
STROUL: ILDB T3,T2 ;GET NEXT CHAR OF STRING
JUMPE T3,CPOPJ ;RETURN WHEN GET A NULL
IDPB T3,T1 ;STORE CHAR
JRST STROUL ;AND LOOP FOR ALL CHARS
DECOUT: SKIPA T4,[^D10] ;GET RADIX
OCTOUT: MOVEI T4,^D8 ;OR OCTAL
NUMOUT: LSHC T2,-^D35 ;TURN NUMBER INTO DOUBLE-WORD
LSH T3,-1 ; THAT IS UNSIGNED
DIVI T2,(T4) ;GET A DIGIT
JUMPE T2,NUMFIN ;IF ZERO, ALL DONE
HRLM T3,(P) ;MORE TO GET, SAVE THIS ONE
PUSHJ P,NUMOUT ;AND GET ANOTHER
HLRZ T3,(P) ;GET BACK A DIGIT
NUMFIN: ADDI T3,"0" ;CONVERT TO ASCII CHARACTER
IDPB T3,T1 ;STORE IT AWAY
POPJ P, ;AND RETURN
SIXOUT: MOVEI T4,6 ;SET UP TO DO SIX TIMES
SIXOUL: SETZ T3, ;CLEAR NEXT AC
ROTC T2,6 ;GET NEXT CHAR TO TYPE
ADDI T3," " ;CONVERT TO ASCII
IDPB T3,T1 ;STORE IT IN STRING
SOJG T4,SIXOUL ;LOOP FOR ALL CHARS
POPJ P, ;RETURN
EOFOUT: HRRZ T2,FDB+.FBSIZ ;GET NUMBER OF BYTES IN FILE
PUSHJ P,DECOUT ;OUTPUT IT
MOVEI T2,"(" ;GET A LEFT PARENTHESIS
IDPB T2,T1 ;STORE IT
LDB T2,[POINT 6,FDB+.FBBYV,11] ;GET BYTE SIZE
PUSHJ P,DECOUT ;OUTPUT IT
MOVEI T2,")" ;GET CLOSING PARENTHESIS
IDPB T2,T1 ;STORE IT ALSO
POPJ P, ;AND RETURN
SUBTTL ROUTINES TO HANDLE COMND JSYSES
;SIMPLE ROUTINES TO DO THE COMND JSYS, WHILE CHECKING FOR ERRORS.
;NO RETURN IF ERROR DETECTED, NORMAL RETURN IF PARSED OK. AC T1
;CONTAINS THE ADDRESS OF THE COMND BLOCK TO USE.
CONFRM: MOVEI T2,[FLDDB. (.CMCFM)] ;GET CONFIRMATION FUNCTION
COMMND: COMND ;PARSE THE END OF LINE
ERJMP ERRSTR ;ERROR IN COMMAND, GO COMPLAIN
TXNE T1,CM%NOP ;DID IT PARSE CORRECTLY?
JRST ERRSTR ;NO, GO COMPLAIN
POPJ P, ;YES, RETURN
NOISE: HRROM T2,NOIBLK+.CMDAT ;SAVE POINTER AS DATA
MOVEI T2,NOIBLK ;POINT TO DATA BLOCK
JRST COMMND ;GO READ IT AND RETURN
SUBTTL SUBROUTINE TO JUSTIFY OUTPUT OF A LINE
;CALLED WHEN STORING THE PARTS OF A LINE DESCRIBING A FILE, TO
;JUSTIFY IT ON NICE BOUNDARIES BY OUTPUTTING THE REQUIRED NUMBER
;OF SPACES. CALL IS:
;
; MOVE T1,POINTER ;GET BYTE POINTER WHICH STARTED AT FILTXT
; MOVEI T2,BYTE NUMBER ;GET BYTE TO JUSTIFY TO
; PUSHJ P,JUSTFY ;DO THE JUSTIFICATION
; (RETURN) ;ALL DONE
;
;USES AC'S T2, T3, AND T4.
JUSTFY: LDB T3,[POINT 6,T1,5] ;GET POSITION FROM POINTER
MOVEI T4,^D36 ;GET BITS TO A WORD
SUBM T4,T3 ;SUBTRACT TO GET BIT POSITION
IDIVI T3,7 ;DIVIDE BY BITS TO A BYTE
MOVEI T4,(T1) ;GET CURRENT WORD POINTER IS AT
SUBI T4,FILTXT ;SUBTRACT ADDRESS OF START OF BUFFER
IMULI T4,5 ;MULTIPLY BY BYTES TO A WORD
ADDI T4,(T3) ;ADD IN BYTES IN PARTIAL WORD
SUBI T2,(T4) ;SUBTRACT BYTES ALREADY USED
MOVEI T3," " ;GET A SPACE TO DO JUSTIFYING WITH
IDPB T3,T1 ;ALWAYS OUTPUT AT LEAST ONE
SOJG T2,.-1 ;LOOP UNTIL JUSTIFIED
POPJ P, ;THEN RETURN
SUBTTL ROUTINES TO TYPE SIMPLE THINGS TO TTY
;HERE WHEN THE STRUCTURE OR DIRECTORY HAS CHANGED, TO TYPE THEM
;OUT SO THE USER KNOWS WHERE THE FILES ARE COMING FROM.
TYPHDR: HRROI T1,[ASCIZ/
/] ;GET A CRLF, TAB
PSOUT ;OUTPUT IT TO START OFF
MOVEI T1,.PRIOU ;SET PRIMARY OUTPUT
HRRZ T2,JFN ;JFN OF FILE
MOVE T3,[1B2+1B5+JS%PAF] ;SET TO OUTPUT DEV:<USER>
JFNS ;TYPE IT OUT
ERJMP ERRSTR ;FAILED
;THEN FALL INTO CRLF CODE
;HERE TO TYPE A CRLF TO THE TTY.
CRLF: HRROI T1,[ASCIZ/
/] ;GET A CRLF
PSOUT ;OUTPUT IT
POPJ P, ;AND RETURN
SUBTTL ERROR HANDLING ROUTINES
;THE FOLLOWING SUBROUTINES ARE USED TO HANDLE HORRIBLE ERRORS WHICH
;OCCUR INSIDE ROUTINES WHICH HAVE NO ERROR RETURN. WE ESSENTIALLY
;HAVE A STACK OF PUSH-DOWN STACKS AND ERROR HANDLING ROUTINES.
;TO SET UP ERROR HANDLING FOR A SUBROUTINE, IT DOES:
;
; MOVEI T1,ADDRESS ;GET ADDRESS OF ROUTINE TO HANDLE ERROR
; PUSHJ P,ERRSET ;GO SET UP FOR ANY ERRORS
; (RETURN) ;DID IT
;
;USES ONLY AC T1. IF ANY ERROR THEN OCCURS IN THE CALLING ROUTINE
;OR LOWER, CONTROL WILL BE PASSED TO THE GIVEN ADDRESS. THESE CALLS
;CAN BE NESTED.
ERRSET: HRRZM T1,@ERRPTR ;SAVE ROUTINE TO CALL IN CASE OF ERROR
AOS T1,ERRPTR ;INCREMENT POINTER INTO SAVE AREA
CAIGE T1,ERRBUF+ERRSIZ ;TOO MUCH DEPTH?
JRST ERRSE1 ;NO, GO ON
HRROI T1,[ASCIZ/
? Error handling depth exceeded
/] ;GET STRING
PSOUT ;TYPE IT
JRST MONRET ;AND EXIT
ERRSE1: MOVEM P,@ERRPTR ;SAVE STACK AT THIS POINT IN TIME TOO
AOS ERRPTR ;AND INCREMENT STACK AGAIN
MOVEI T1,ERRBAC ;GET ROUTINE TO CALL WHEN HE POPJ'S
EXCH T1,(P) ;SWITCH OUR RETURN ADDRESS
JRST (T1) ;RETURN TO CALLER
;HERE WHEN THE CALLER FINALLY DOES A POPJ, WE RETURN HERE TO FIX
;UP THE ERROR STACK, AND ALSO TO GIVE A SKIP RETURN IF NECESSARY.
ERRBAC: JRST .+2 ;NORMAL RETURN
AOS (P) ;SKIP RETURN, PASS IT ON
SOS ERRPTR ;BUMP ERROR POINTER
SOS ERRPTR ;TO RESTORE LEVEL OF ERROR HANDLING
POPJ P, ;RETURN TO CALLER OF ROUTINE
;HERE IF AN ERROR OCCURRED IN THE SUBROUTINE. THE ROUTINE WITH THE
;ERROR HAS JUMPED TO US TO FIX THINGS UP. COME TO ERRMSG IF THE
;ERROR WAS A STANDARD JSYS ERROR WHICH WE CAN ERRSTR TO THE TERMINAL.
;COME TO ERRPRT IF WE HAVE OUR OWN ERROR MESSAGE READY TO TYPE.
;WE RETURN TO THE ADDRESS ORIGINALLY GIVEN TO US IN THE CALL
;TO ERRSET, WITH THE STACK RESTORED PROPERLY.
ERRSTR: HRROI T1,[ASCIZ/
? /] ;GET PRILIMARY TEXT
PSOUT ;TYPE IT
MOVEI T1,.PRIOU ;SET UP
HRLOI T2,.FHSLF ;WANT LAST ERROR IN MY PROCESS
SETZ T3, ;NO LIMIT ON ERROR TEXT
ERSTR ;TYPE THE ERROR
JFCL ;CAN'T DO MUCH ELSE
JFCL
HRROI T1,[ASCIZ/
/] ;GET A COUPLE OF CRLFS
ERRPRT: PSOUT ;TYPE THE TEXT
MOVEI T1,.PRIIN ;GET READY
CFIBF ;CLEAR INPUT BUFFER
SOS ERRPTR ;DECREMENT ERROR POINTER
MOVE P,@ERRPTR ;RESTORE STACK POINTER
POP P,T1 ;REMOVE CALL TO ERRSET FROM BEFORE
SOS ERRPTR ;DECREMENT AGAIN
ANDCMI F,FR.HDR ;PREVENT OUTPUT OF HEADER NOW
MOVE T1,@ERRPTR ;GET ADDRESS TO GO TO ON THE ERROR
JRST (T1) ;AND GO TO IT
HLPTXT: TEXT <
For each file indicated, type either just a carriage return or
one of the commands listed below. Carriage return just moves
down to the next file.
ABORT Return to command level now.
BACKUP n Go backwards "n" files to reprocess them again.
The default number is 1, and the maximum is 100.
COPY file Copy the file to the desired specification. The
default device and directory are the ones you are
connected to.
DELETE Deletes the file.
EXIT Returns to the EXEC. A "CONTINUE" command will
reprocess the current file.
EXPUNGE Deletes and expunges a file. A file can not be
undeleted if this command is used, since the disk
space is freed immediately.
FILDDT args Get FILDDT in an inferior fork so that you can use
it on the file. When FILDDT exits, the current
file is reprocessed. The args are any of NO-FILE,
DATA-FILE, or PATCHING.
INFO arg Type out information about the file. Arg can be
one of FDB or PAGES. FDB is the default.
LIST Print the file on the line printer.
NEXT arg Skip over files until a new "arg" is found. The arg
can be one of STRUCTURE, DIRECTORY, FILE, or TYPE.
DIRECTORY is the default argument.
PUSH PUSH to an inferior EXEC. When a POP is done, the
current file will be reprocessed.
RENAME file Rename the file to the given file specification. The
defaults for the output file are the same as the input.
SET arg Set the specified parameter of the file. Type a
question mark to list the fields that can be changed.
TYPE page Type out the file starting at the given page number.
Default page number is 0 (I.E., start of the file).
Typing ^E will abort the typeout.
UNDELETE Undelete the file.
>
SUBTTL TABLES FOR THE DESCRIPTION AND SETTING OF FDB INFO
;THE FOLLOWING MACRO IS USED TO GENERATE THE TABLES WHICH ARE USED
;TO DESCRIBE OR SET THE VARIOUS FIELDS IN A FILE'S FDB. THE
;IMBEDDED XX MACRO HAS THE FOLLOWING ARGUMENTS:
;
; XX SYMBOL-NAME,WORD,MASK,TYPE-ADDR,DESCRIPTION,FLAG
;
;WHERE SYMBOL-NAME IS THE NAME AS DOCUMENTED IN THE REFERENCE MANUAL,
;WORD IS THE OFFSET IN THE FDB OF THIS FIELD, MASK IS THE PART OF THE
;WORD THE FIELD IS IN, TYPE-ADDR IS THE ROUTINE TO TYPE THE FIELD,
;SET-ADDR IS THE ROUTINE TO SET THE FIELD, DESCRIPTION IS THE TEXT
;EXPLAINING THE FIELD, AND FLAG IS 1 IF THIS FIELD IS ALWAYS OUTPUT.
XALL ;SHOW EXPANSIONS OF MACROS
DEFINE FDBDAT,<
XX .FBHDR,.FBHDR,-1,TYPHLF,Header word,1
XX .FBCTL,.FBCTL,-1,TYPHLF,Status bits
XX FB%TMP,.FBCTL,FB%TMP,TYPBIT,File is temporary
XX FB%PRM,.FBCTL,FB%PRM,TYPBIT,File is permanent
XX FB%NEX,.FBCTL,FB%NEX,TYPBIT,File does not have a file type
XX FB%DEL,.FBCTL,FB%DEL,TYPBIT,File is deleted
XX FB%NXF,.FBCTL,FB%NXF,TYPBIT,First write is not complete
XX FB%LNG,.FBCTL,FB%LNG,TYPBIT,File is longer than 512 pages
XX XXX1,.FBCTL,1B6,TYPHLF,Unused
XX FB%DIR,.FBCTL,FB%DIR,TYPBIT,File is a directory
XX FB%NOD,.FBCTL,FB%NOD,TYPBIT,File is not to be saved
XX FB%BAT,.FBCTL,FB%BAT,TYPBIT,File has bad pages
XX FB%SDR,.FBCTL,FB%SDR,TYPBIT,Directory has subdirectories
XX XXX2,.FBCTL,7B13,TYPHLF,Unused
XX FB%FCF,.FBCTL,FB%FCF,TYPHLF,File class field
XX .FBEXL,.FBEXL,-1,TYPHLF,Link to FDB of next file type
XX .FBADR,.FBADR,-1,TYPHLF,Disk address of index block,1
XX .FBPRT,.FBPRT,-1,TYPHLF,File access bits,1
XX .FBCRE,.FBCRE,-1,TYPDAT,Time of last write,1
XX .FBAUT,.FBAUT,-1,TYPAUT,Author of file,1
XX .FBGEN,.FBGEN,-1,TYPHLF,Generation and directory numbers,1
XX FB%GEN,.FBGEN,FB%GEN,TYPDEC,Generation number,1
XX FB%DRN,.FBGEN,FB%DRN,TYPHLF,Directory number
XX .FBACT,.FBACT,-1,TYPACT,Account designator,1
XX .FBBYV,.FBBYV,-1,TYPHLF,File I/O information,1
XX FB%RET,.FBBYV,FB%RET,TYPDEC,Retention count,1
XX FB%BSZ,.FBBYV,FB%BSZ,TYPDEC,File byte size,1
XX XXX3,.FBBYV,3B13,TYPHLF,Unused
XX FB%MOD,.FBBYV,FB%MOD,TYPHLF,Data mode written in,1
XX FB%PGC,.FBBYV,FB%PGC,TYPDEC,Page count of file,1
XX .FBSIZ,.FBSIZ,-1,TYPDEC,Number of bytes in file,1
XX .FBCRV,.FBCRV,-1,TYPDAT,Creation time of file,1
XX .FBWRT,.FBWRT,-1,TYPDAT,Time of last user write,1
XX .FBREF,.FBREF,-1,TYPDAT,Time of last nonwrite access,1
XX .FBCNT,.FBCNT,-1,TYPHLD,<Count of writes,,references>,1
XX .FBBK0,.FBBK0,-1,TYPHLF,Backup word 1
XX .FBBK1,.FBBK1,-1,TYPHLF,Backup word 2
XX .FBBK2,.FBBK2,-1,TYPHLF,Backup word 3
XX .FBBK3,.FBBK3,-1,TYPHLF,Backup word 4
XX .FBBK4,.FBBK4,-1,TYPHLF,Backup word 5
XX .FBUSW,.FBUSW,-1,TYPHLF,User settable word
XX .FBGNL,.FBGNL,-1,TYPHLF,Address of FDB of next generation
XX .FBNAM,.FBNAM,-1,TYPHLF,Pointer to filename block,1
XX .FBEXT,.FBEXT,-1,TYPHLF,Pointer to file type block,1
XX .FBLWR,.FBLWR,-1,TYPLWR,Last writer to file,1
>
;EXPAND MACRO AS REQUIRED. FIRST SYMBOL NAMES:
DEFINE XX(S,W,M,T,D,F),<
EXP SIXBIT/S/ ;Symbol for D
>
TABSYM: FDBDAT
TABNUM==.-TABSYM ;NUMBER OF FIELDS
;THEN OFFSETS IN THE FDBS:
DEFINE XX(S,W,M,T,D,F),<
EXP W ;Offset in FDB for D
>
TABWRD: FDBDAT
;THEN MASK BITS IN THE WORD:
DEFINE XX(S,W,M,T,D,F),<
EXP M ;Mask for D
>
TABMSK: FDBDAT
;THEN BYTE POINTERS TO THE FIELD:
DEFINE XX(S,W,M,T,D,F),<
PTR==POINTR(<FDB+W>,<M>) ;GET BYTE POINTER
EXP PTR ;Byte pointer to D
>
TABPTR: FDBDAT
;THEN DISPATCH ADDRESS FOR TYPEOUT OF FIELDS:
DEFINE XX(S,W,M,T,D,F),<
EXP T ;Routines for D
>
TABADR: FDBDAT
;FINALLY FLAG BITS AND THE ASCII STRINGS THEMSELVES:
DEFINE XX(S,W,M,T,D,F<0>),<
XWD F'B18,[ASCIZ "D"]
>
TABTXT: FDBDAT
SUBTTL DATA AREA
SALL ;RETURN TO GOOD LISTING FORMAT
;COMMAND BLOCK FOR FILE SPEC.
CMDBLK: 0,,NEWPAR ;FLAGS,,REPARSE ADDRESS
.PRIIN,,.PRIOU ;INPUT,,OUTPUT JFNS
-1,,[ASCIZ/REV>/] ;CONTROL-R BUFFER
-1,,TXTBUF ;POINTER TO TEXT BUFFER
-1,,TXTBUF ;POINTER TO CURRENT POSITION
TXTLEN ;NUMBER OF CHARACTERS IN BUFFER
0 ;NUMBER OF UNPARSED CHARS
-1,,ATMBUF ;POINTER TO THE ATOM BUFFER
TXTLEN ;LENGTH OF ATOM BUFFER
EXP JFNBLK ;POINTER TO GTJFN BLOCK
;GTJFN BLOCK FOR INITIAL COMMAND.
JFNBLK: GJ%OLD+GJ%IFG+GJ%FLG+GJ%ACC+.GJALL ;FLAG BITS,,GENERATION NUMBER
.PRIIN,,.PRIOU ;INPUT,,OUTPUT JFNS
0 ;DEFAULT DEVICE, NONE
0 ;DEFAULT DIRECTORY, NONE
-1,,[ASCIZ/*/] ;DEFAULT FILENAME, WILD
-1,,[ASCIZ/*/] ;DEFAULT FILETYPE, WILD
0 ;DEFAULT PROTECTION, NONE
0 ;DEFAULT ACCOUNT, NONE
0 ;JFN TO ASSIGN, NONE
0 ;NO EXTENDED BLOCK
BLOCK 10 ;OTHER ARGS NOT USED EITHER
;COMMAND BLOCK FOR PARSING COMMANDS TO HANDLE EACH FILE.
KEYBLK: 0,,KEYPAR ;FLAGS,,REPARSE ADDRESS
.PRIIN,,.PRIOU ;INPUT,,OUTPUT JFNS
-1,,FILTXT ;CONTROL-R BUFFER
-1,,TXTBUF ;POINTER TO TEXT BUFFER
-1,,TXTBUF ;POINTER TO CURRENT POSITION
TXTLEN ;NUMBER OF CHARS IN BUFFER
0 ;NUMBER OF UNPARSED CHARS
-1,,ATMBUF ;POINTER TO ATOM BUFFER
TXTLEN ;LENGTH
EXP KEYJFB ;POINTER TO GTJFN BLOCK
;GTJFN BLOCK FOR OUTPUT SPECIFICATIONS.
KEYJFB: GJ%DEL+GJ%ACC+GJ%FOU ;FLAG BITS,,GENERATION NUMBER
.PRIIN,,.PRIOU ;INPUT,,OUTPUT JFNS
0 ;DEFAULT DEVICE, FILLED IN LATER
0 ;DEFAULT DIRECTORY, FILLED IN TOO
-1,,DFTNAM ;DEFAULT NAME, SAME AS INPUT
-1,,DFTTYP ;DEFAULT TYPE, SAME AS INPUT
0 ;DEFAULT PROTECTION, NONE
0 ;DEFAULT ACCOUNT, NONE
0 ;JFN TO ASSIGN, NONE
0 ;NO EXTENDED BLOCK
BLOCK 10 ;OTHER ARGS NOT USED
;TABLE OF COMMANDS FOR PROGRAM.
ACTTAB: ACTLEN,,ACTLEN ;NUMBER OF ENTRIES
AA ALLOW,ACTALW ;ALLOW DELETED FILES
AA DISALLOW,ACTDIS ;DISALLOW DELETED FILES
AA EXIT,ACTXIT ;LEAVE PROGRAM
AA HELP,ACTHLP ;TYPE OUT HELP TEXT
AA REVIEW,ACTREV ;REVIEW SOME FILES
AA WHAT,ACTWHT ;TELL WHICH KIND OF FILES WE REVIEW
ACTLEN==.-ACTTAB-1 ;NUMBER OF COMMANDS
;TABLE OF COMMANDS FOR EACH FILE.
KEYTAB: KEYLEN,,KEYLEN ;NUMBER OF ENTRIES
AA ABORT,CMDABT ;RETURN TO COMMAND LEVEL
AA BACKUP,CMDBAC ;BACKUP TO A PREVIOUS FILE
AA COPY,CMDCPY ;COPY FILE
AA DELETE,CMDDEL ;DELETE THE FILE
AA E,EXITCM,CM%ABR+CM%INV ;EXIT ABBREVIATION
AA EX,EXITCM,CM%ABR+CM%INV ;ANOTHER ONE
EXITCM: AA EXIT,CMDXIT ;EXIT FROM PROGRAM NOW
AA EXPUNGE,CMDEXP ;DELET