.MCALL .MODULE .MODULE FIND,RELEASE=V01,VERSION=00,COMMENT=,AUDIT=YES .ENABLE LC ; FIND will locate a file or files on any device on the ; system. It also looks at any sub device file for ; the file. ; The subdevices which are searched must have a file ; type of DSK, but it can be changed. ; ; A single additional physical device can be searched by ; including it in the command string as though it were an ; output device. ; FIND filespec [dev:] ; filespec can be any combination of filename and ; wild card (*) input. ; dev: is optional and specifies an optional ; physical device to be searched after the built in ; devices are searched. ; Author: ; D. N. Tanner ; Livermore, Ca 94550 .MCALL .PRINT, .EXIT, .LOOKUP, .CLOSE, .SERR, .GTLIN, .TTYIN .GLOBL FIND, IOASC, NAMCAT, TSTFIL, INDEX .GLOBL FETCH, DATEI, GETFIL, R50ASC, IRAD50 DEVTYP:: .RAD50 /DSK/ ;Default subdevice file type PAGSIZ:: .WORD 22. TERTYP:: .WORD 1. ;0 none, 1=VT100, 2=VT52 PHYDEV:: .RAD50 /DL0/ .WORD 0,0,0,0,0,0,0,0,0,0 .WORD 0,0,0,0,0,0,0,0,0,0 ;Up to 20 devices are allowed. DSKNAM: .BLKW 1200. ;Space for 300 subdevice file names. FIND:: MOV #DSKNAM,R1 MOV #1200.,R2 1$: CLR (R1)+ ;Clear the disk name area. SOB R2,1$ .SERR ;Allow all errors MOV #100.,LINE ;Line count, force a new page .GTLIN #FILNAM,#GREET ;Get the file name line. TSTB FILNAM ;Was a line typed? BEQ EXIT ;no, quit. ; look for an additional physical device. ; it could be in the form dev:=filespec or filspec dev: MOV #ARG9,R5 ;Look for filspec dev: first JSR PC,INDEX ;look for the space. TST R0 BEQ 4$ ;Not found, try dev:=filespec DEC R0 BEQ EXIT ;exit on leading space. ADD #FILNAM,R0 ;add location of input array CLRB (R0)+ ;terminate the file with a null MOV #ALTDEV,R2 ;pointer to alternate device name MOVB (R0)+,(R2)+ ;Copy 3 characters to altdev BEQ 2$ MOVB (R0)+,(R2)+ BEQ 2$ MOVB (R0)+,(R2)+ 2$: MOV #FILNAM,R1 ;reset pointer BR 8$ ;Finish copying the file name part 4$: MOV #ARG7,R5 ;dev:=filespec JSR PC,INDEX ;search for the = TST R0 BEQ 5$ ;= not found MOV #ALTDEV,R2 ;must be dev:=filespec MOV #FILNAM,R1 6$: MOVB (R1)+,R0 BEQ EXIT CMPB #':,R0 BEQ 7$ ;End of the device CMPB #'=,R0 BEQ 8$ ;also allow device without the : MOVB R0,(R2)+ BR 6$ 7$: TSTB (R1)+ ;Skip over the "=" 8$: CLRB (R2)+ ;Terminate with a null CLRB (R2)+ MOV #FILNAM,R2 9$: MOVB (R1)+,R0 BEQ 10$ MOVB R0,(R2)+ ;copy the filespec to the start of ; FILNAM BR 9$ 10$: CLRB (R2)+ MOV #ARG8,R5 JSR PC,IRAD50 ;Convert the device name to RAD50 MOV #PHYDEV,R1 11$: TST (R1) BEQ 12$ TST (R1)+ BR 11$ 12$: MOV ALTRAD,(R1)+ 5$: MOV #ARG2,R5 JSR PC,NAMCAT ;Characterized the file name. ;Info is put into /INFIL/ common area MOV R0,NAMSTA ;Save the status MOV #PHYDEV,DEVPTR CLR CHAN MOV #DSKNAM,FILPTR CLR SUBPTR ;Used to flag device vs subdevice files ;And as a pointer to DSKNAM for output. NXTDEV: MOV DEVPTR,R1 MOV (R1)+,DEVNAM BEQ SUBDEV ;End of physical device search MOV R1,DEVPTR CLR BLKEY ;Tells GETFIL that there is no block in memory MOV #ARG3,R5 JSR PC,FETCH ;Fetch the handler, if required. TST R0 ;Did it work? BEQ L1 ;YES JMP EFETCH EXIT: .EXIT L1: 1$: CLR R1 .LOOKUP #AREA, R1, #DEVNAM ;Do an absolute lookup of the dev. BCC 2$ JMP ELOOK 2$: MOV #ARG4,R5 JSR PC,GETFIL ;Get the next file from the current device TST IFLG BGT 10$ ;End of this directory BLT NXTDEV ; Don't ABORT for now CMP TYPE,DEVTYP ;Is this a subdevice file. BNE 3$ ;No, test the name MOV FILPTR,R1 ;Yes, store the name for later MOV DEVNAM,(R1)+ MOV NAME,(R1)+ MOV NAME+2,(R1)+ MOV TYPE,(R1)+ MOV R1,FILPTR 3$: MOV #ARG5,R5 JSR PC,R50ASC ;Convert the name to ASCII MOV #FTYP+3,R1 ;Shift the file type over one MOV R1,R2 ; and put a . in front INC R2 MOVB -(R1),-(R2) MOVB -(R1),-(R2) MOVB -(R1),-(R2) MOVB #'.,FTYP MOV #FNAME,R1 MOV R1,R2 4$: MOVB (R1)+,R0 ;Remove spaces from the name BEQ 5$ ;Done CMPB R0,#40 ;A space? BEQ 4$ MOVB R0,(R2)+ BR 4$ 5$: CLRB (R2)+ ;Terminate with a null MOV #ARG6,R5 JSR PC,TSTFIL ;Test the name TST R0 BLT 2$ ;No match, next file JSR PC, PFILE ;print the file information BR 2$ ;Next file 10$: .CLOSE CHAN BR NXTDEV ;Next physical device SUBDEV: MOV #DSKNAM,SUBPTR NXTSUB: 1$: CLR BLKEY ;no dir block in memory MOV SUBPTR,R1 TST @R1 BEQ DONE ;No more subdevice files MOV (R1)+,SNAME MOV (R1)+,SNAME+2 MOV (R1)+,SNAME+4 MOV (R1)+,SNAME+6 MOV R1,SUBPTR .LOOKUP #AREA, CHAN, #SNAME BCC 2$ JMP ELOOKS 2$: MOV #ARG4,R5 JSR PC,GETFIL ;Get the next file from the current device TST IFLG BGT 10$ ;End of this directory BLT ABORTS ; This section is not implemented, No nested subdevice files ; CMP TYPE,DEVTYP ;Is this a subdevice file. ; BNE 3$ ;No, test the name ; ; MOV FILPTR,R1 ;Yes, store the name for later ; MOV DEVNAM,(R1)+ ; MOV NAME,(R1)+ ; MOV NAME+2,(R1)+ ; MOV TYPE,(R1)+ ; MOV R1,FILPTR 3$: MOV #ARG5,R5 JSR PC,R50ASC ;Convert the name to ASCII MOV #FTYP+3,R1 ;Shift the file type over one MOV R1,R2 ; and put a . in front INC R2 MOVB -(R1),-(R2) MOVB -(R1),-(R2) MOVB -(R1),-(R2) MOVB #'.,FTYP MOV #FNAME,R1 MOV R1,R2 4$: MOVB (R1)+,R0 ;Remove spaces from the name BEQ 5$ ;Done CMPB R0,#40 ;A space? BEQ 4$ MOVB R0,(R2)+ BR 4$ 5$: CLRB (R2)+ ;Terminate with a null MOV #ARG6,R5 JSR PC,TSTFIL ;Test the name TST R0 BLT 2$ ;No match, next file JSR PC, PFILE ;print the file information BR 2$ ;Next file 10$: .CLOSE CHAN BR 1$ ;Next physical device EFETCH: .PRINT #MSG1 BR NXT ELOOK: .PRINT #MSG2 BR NXT ABORT: .PRINT #MSG3 NXT: .CLOSE CHAN JMP NXTDEV ;Ignore errors ELOOKS: ABORTS: .CLOSE CHAN JMP NXTSUB ;Ignore errors DONE: CMP LINE,#100. ;Did we find any files? BNE 1$ ;YES .PRINT #NOFIL ;Tell user no files found 1$: .EXIT .PAGE ; PFILE ; Prints current file name on the terminal. PFILE: MOV #P1,R5 ;File Date JSR PC,DATEI MOV #P2,R5 ;File size JSR PC,IOASC TST SUBPTR ;Doing a subdirectory BNE 1$ ;Yes MOV #P3,R5 ;Physical Disk JSR PC,R50ASC ;Device name MOV #P3B,R5 JSR PC,R50ASC MOV #P4,R5 JSR PC,R50ASC MOVB #40,DOT BR 2$ 1$: MOV #P3A,R5 ;Subdevice file name JSR PC,R50ASC MOV #P3C,R5 JSR PC,R50ASC MOV #P4A,R5 JSR PC,R50ASC MOVB #'.,DOT 2$: TST PAGSIZ ;Skip the heading and the page if ;Pagsiz is set to zero BEQ 3$ CMP LINE,PAGSIZ BLT 3$ CMP LINE,#100. ;Is this the first time thru. BEQ 6$ ;Prompt for continue message .PRINT #CONT ; Wait for a return 7$: .TTYIN CMPB R0,#12 ;Look for a line feed BNE 7$ ;continue waiting 6$: CMP TERTYP,#1 BLT 4$ BGT 5$ .PRINT #VT100 BR 4$ 5$: .PRINT #VT52 4$: .PRINT #H1 .PRINT #FILNAM .PRINT #H2 MOV #3,LINE 3$: INC LINE MOV #P5,R5 ;File name JSR PC,R50ASC MOV #P6,R5 JSR PC,R50ASC .PRINT #DSK RTS PC .NLIST BIN P1: .WORD 2, FDAT, DATE P2: .WORD 3, SIZE, N4, FSIZ P3: .WORD 3, N3, DEVNAM, DSK P3B: .WORD 3, N6, DEVNAM+2, FN P4: .WORD 3, N3, DEVNAM+6, FT P3A: .WORD 3, N3, SNAME, DSK P3C: .WORD 3, N6, SNAME+2, FN P4A: .WORD 3, N3, SNAME+6, FT P5: .WORD 3, N6, NAME, FN1 P6: .WORD 3, N3, TYPE, FT1 ESC=33 VT100: .ASCII /[2J//[H/<200> VT52: .ASCII /E//H/<200> H1: .ASCII / Search for: /<200> H2: .ASCIZ /Dev. Directory File File Name Size Date/ CONT: .ASCII /Continue .../<200> .EVEN NOFIL: .ASCII /No Files Found/<15><12><0> DSK: .ASCII / : / FN: .ASCII / / DOT: .ASCII / / FT: .ASCII / / .ASCII / / FN1: .ASCii / ./ FT1: .ASCII / / .ASCII / / FSIZ: .ASCII / / FDAT: .ASCII / - - / .BYTE 0,0 .EVEN .PAGE .NLIST BIN ;DATA AREA LINE: .WORD 0 IS: .BLKW 20. FILPTR: .WORD 0 SUBPTR: .WORD 0 SNAME: .WORD 0,0,0,0 FNAME: .WORD 0,0,0 FTYP: .WORD 0,0 ZERO: .WORD 0 DEVPTR: .WORD 0 DEVNAM: .WORD 0, 0, 0, 0, 0 IFLG: .WORD 0 N9: .WORD 9. N3: .WORD 3. N4: .WORD 4. N6: .WORD 6. ARG2: .WORD 2, FILNAM, N1 ARG3: .WORD 1, DEVNAM ARG4: .WORD 1, IFLG ARG5: .WORD 3, N9, NAME, FNAME ARG6: .WORD 2, FNAME, IFLG ARG7: .WORD 2, FILNAM, EQUAL ARG8: .WORD 3, N3, ALTDEV, ALTRAD ARG9: .WORD 2, FILNAM, SPACE AREA: .WORD 0,0,0,0,0 GREET: .ASCII /FIND V01.00> /<200> .EVEN EQUAL: .ASCIZ /=/ SPACE: .ASCIZ / / ALTDEV: .WORD 0,0,0 ALTRAD: .WORD 0 MSG1: .ASCIZ /Fetch error/ MSG2: .ASCIZ /Lookup error/ MSG3: .ASCIZ /FIND-F Directory error, not a valid directory/ .EVEN .PSECT INFIL,GBL,OVR,D INFIL: .WORD FILNAM NAMSTA: .WORD 0 N0: .WORD 0 N1: .WORD 0,0,0 N2: .WORD 0,0,0 T1: .WORD 0,0 T2: .WORD 0,0 FILNAM: .BLKW 40. .WORD 0 ; COMMON /FILE/ .PSECT FILE,GBL,OVR,D NAME: .BLKW 2 TYPE: .BLKW 1 DATE: .BLKW 1 SIZE: .BLKW 1 CHAN: .BLKW 1 ; BLKEY - Directory block in memory, 0 means no block. BLKEY: .BLKW 1 .END FIND