.TITLE TSTFIL V1.0 .ENABLE LC ; This routines does a comparison between an ASCII file ; with wild cards and a provided RAD50 file name. ; The return is in R0 and is 0 if a match is found and ; is -1 if no match is found. ; The input file name can be of the form: ; Code Name Type ; 0 A B ; 1 A* B* ; 2 *A *B ; 3 *A* *B* ; 4 * * ; - A*B A*B This is a combination of ; Types 1 and 2 ; A is converted to A.* ; A. is left as is. ; A* is converted to A*.* ; Where 'A' and 'B' can be 1 or more characters. The * indicates ; Wild card, where any character or characters will match. ; If the file type is omitted and no period (.) is included in ; the name the file type of * is assumed. If a period is ; included then a blank file type is assumed. ; Call from fortran or equal. ; CALL TSTFIL(FILDIR, IFLG) ; Author: D. N. Tanner ; Livermore, Ca 94550 ; NAMSTA Bit values NAMFLG = 1 ;An * occurred in file name DOT = 2 ;A . occurred in the file name TYPFLG = 4 ;An * occurred in the file type NAMCHR = 8. ;There were characters in the file name TYPCHR = 16. ;There were characters in the file type NAMANY = 32. ;There were char surrounded by *'s in the name TYPANY = 64. ;There were char surrounded by *'s in the type TYPCLR = DOT!TYPFLG!TYPCHR!TYPANY ;All file type bits NAMCLR = NAMFLG!DOT!NAMCHR!NAMANY ;All file name bits NAM0 = NAMCHR NAM1 = NAMCHR!NAMFLG NAM2 = NAM1 NAM3 = NAMCHR!NAMFLG!NAMANY NAM4 = NAMFLG TYP0 = TYPCHR TYP1 = TYPCHR!TYPFLG TYP2 = TYP1 TYP3 = TYPCHR!TYPFLG!TYPANY TYP4 = TYPFLG .GLOBL TSTFIL, NAMCAT, ISCOMP, IVERIF TSTFIL: TST (R5)+ MOV (R5)+,FILDIR ;File from the directory MOV (R5)+,IFLG MOV #ARG1,R5 JSR PC, NAMCAT ;Categorize the FILDIR MOV NAMSTA,R0 BIC #TYPCLR,R0 CMP #NAM0,R0 ;Is it a type 0 file name "A" BEQ 1$ CMP #NAM1,R0 ;Is it a type 1 BEQ 2$ CMP #NAM3,R0 ;Type 3 BEQ 3$ CMP #NAM4,R0 ;TYPE 4 BEQ 4$ ; ; IF WE GET HERE SOMETHING IS WRONG BR 22$ 1$: MOV #ARG3,R5 ;Type 0, "A" JSR PC, ISCOMP ;Compare N1 with D1 TST R0 ;Did they match BEQ TYPE ;Yes, now test the file type BR 22$ ;Exit, no match 2$: TSTB N1 ;Type 1 or 2 BEQ 25$ ;Type 2 "*A" MOV #N1,R1 ;Type 1 "A*" MOV #D1,R2 21$: MOVB (R1)+,R0 BEQ 23$ MOVB (R2)+,R3 BEQ 22$ CMPB R0,R3 BEQ 21$ ; No Match 22$: MOV #-1,R0 MOV R0,@IFLG RTS PC 23$: TSTB N2 ;Is this also a type 2? (actually A*B) BNE 25$ ;Yes, test the *B part JMP TYPE ;Match, test file type 25$: MOV #T1,R1 ;Type 2 "*A" MOV #D2,R2 26$: TSTB -(R1) ;START AT END AND BACKUP BEQ 26$ 27$: TSTB -(R2) ;Backup in the directory name BEQ 27$ CMPB @R1,@R2 ;Do the characters match? BNE 22$ 28$: MOVB -(R1),R0 BEQ TYPE ;End, means a match MOVB -(R2),R3 BEQ 22$ CMPB R0,R3 BEQ 28$ 29$: JMP 22$ 3$: MOV #ARG4,R5 ;Type 3 "*A*" Search for N2 in D1 JSR PC, IVERIF TST R0 BEQ TYPE BR 22$ ;No match 4$: BR TYPE ;Type 4 "*" always match TYPE: MOV NAMSTA,R0 BIC #NAMCLR,R0 CMP #TYP0,R0 ;Is it a type 0 file TYPe "A" BEQ 1$ CMP #TYP1,R0 ;Is it a type 1 BEQ 2$ CMP #TYP3,R0 ;Type 3 BEQ 3$ CMP #TYP4,R0 ;TYPE 4 BEQ 4$ 1$: MOV #ARG5,R5 ;Type 0, "A" JSR PC, ISCOMP ;Compare T1 with DT1 TST R0 ;Did they match BEQ DONE ;Yes, they match BR 22$ ;Exit, no match 2$: TSTB T1 ;Type 1 or 2 BEQ 25$ ;Type 2 "*A" MOV #T1,R1 ;Type 1 "A*" MOV #DT1,R2 21$: MOVB (R1)+,R0 BEQ 23$ MOVB (R2)+,R3 BEQ 22$ CMPB R0,R3 BEQ 21$ ; No Match 22$: MOV #-1,R0 MOV R0,@IFLG RTS PC 23$: TSTB T2 ;Is this a type 1 and 2 (B*B) BNE 25$ ;Yes JMP DONE ;Type 1 only, match is done 25$: MOV #FILNAM,R1 ;Type 2 "*A" MOV #DT2,R2 26$: TSTB -(R1) ;START AT END AND BACKUP BEQ 26$ 27$: TSTB -(R2) ;Backup in the directory name BEQ 27$ CMPB @R1,@R2 ;Do the characters match? BNE 22$ 28$: MOVB -(R1),R0 BEQ DONE ;End, means a match MOVB -(R2),R3 BEQ 22$ CMPB R0,R3 BEQ 28$ 29$: JMP 22$ 3$: MOV #ARG6,R5 ;Type 3 "*A*" Search for T2 in DT1 JSR PC, IVERIF TST R0 BEQ DONE BR 22$ ;No match 4$: BR DONE ;Type 4 "*" always match DONE: CLR @IFLG ;A match RTS PC D0: .WORD 0 D1: .WORD 0,0,0 D2: .WORD 0,0,0 DT1: .WORD 0,0 DT2: .WORD 0,0 IFLG: .WORD 0 ARG1: .WORD 2 FILDIR: .WORD 0, D1 ARG3: .WORD 2, N1, D1 ARG4: .WORD 2, N2, D1 ARG5: .WORD 2, T1, DT1 ARG6: .WORD 2, T2, DT1 .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 .END