.TITLE UIC_GET FIND A UIC WHICH MAY BE GOOD ; ; THIS ROUTINE EXAMINES DIRECTORIES TO SEE IF THE FILES CONTAINED ; IN THE DIRECTORY SHOULD BE EXAMINED AND IF SO IT CALLS NEXT_UIC ; TO DO THE EXAMINATION ; ; WRITTEN BY LOU PERAZZOLI 10-JUN-1978 ; ; LOCAL MACROS .MACRO TEXT TXXT,?LAB1,?LAB2 .LONG LAB2-LAB1 .LONG LAB1 LAB1: .ASCII /TXXT/ LAB2: .ENDM .MACRO STATUS ERROR_NUM,INST,?A BLBS R0,A MOVL #ERROR_NUM,R1 BSBW ERROR INST A: .ENDM .MACRO ERROR ERROR_NUM,INST MOVL #ERROR_NUM,R1 BSBW ERROR INST .ENDM ; .PSECT CODE1 LONG UIC_GET:: .WORD ^M ;CALL WITH 4(AP)=CHAR DESCRIPTOR OF INPUT STRING ; 8(AP)=STRING FOUND SO FAR MOVL 4(AP),R6 ;ADDRESS OF CHAR STRING DESC TSTL (R6) ;IS STRING NULL BEQL 5$ ;BR IF NULL CMPB @4(R6),#^A/]/ ;END OF STRING BNEQ 100$ ;BR IF NOT ; APPEND ".DIR" TO STRING SO FAR 5$: MOVL 8(AP),R6 ;ADDRESS OF STRING SO FAR DESC ADDL3 (R6),4(R6),R10 ;ADDRESS OF LAST CHAR IN STRING+1 ; FIND THE LAST . IN THE NAME AND REPLACE IT WITH A ] MOVL (R6),R0 ;LEN OF STRING TO R0 MOVL 4(R6),R1 ;START OF STRING TO R1 10$: MOVL R1,R2 ;SAVE START OR LOCATION OF "."+1 AS A REFERENCE LOCC #^A/./,R0,(R1) ;TRY TO FIND A . INCL R1 ;MOVE OVER . IF IT WAS FOUND DECL R0 ;ADJUST LEN OVER THE . AS WELL BGEQ 10$ ;IF R0 DID NOT GO NEGATIVE THEN A . WAS FOUND CMPL R2,4(R6) ;DID WE FIND A . (R2 WOULD HAVE BEEN UPDATED) BNEQ 20$ ;BRANCH IF A . WAS FOUND SUBL3 #1,(R6),R1 ;SINCE NO DOT WAS FOUND REMOVE FIRST CHAR("[") ADDL3 #1,4(R6),R0 ;ALSO ADJUST LEN 1 LESS BRB 50$ ;CONTINUE 20$: DECL R2 ;POINT BACK TO . MOVB #^A/]/,(R2) ;REPLACE THE . WITH A ] MOVL (R6),R1 ;LEN TO R1 AGAIN MOVL 4(R6),R0 ;START TO R0 50$: PUSHL R0 ;MOVE ADDRESS TO STRING TO STACK (DESC) PUSHL R1 ;MOVE NUMBER OF CHARACTERS TO STACK PUSHL SP ;ADDRESS OF ARG TO STACK CALLS #1,W^NEXT_UIC ;CALL NEXT_UIC TO DO IT ROUTINE RET 100$: ;ISOLATE NAME OF DIRECTORY INCL 4(R6) ;MOVE OVER . OR [ DECL (R6) ;ONE LESS CHAR IN NAME LOCC #^A/./,(R6),@4(R6) ;FIND NEXT . BNEQ 200$ ;BR IF FOUND LOCC #^A/]/,(R6),@4(R6) ;FIND ] IN NAME BNEQ 200$ BPT ;INVALID NAME -SHOULD NEVER GET HERE 200$: PUSHL R1 ;ADDRESS OF STRING LEFT TO ANALYZE PUSHL R0 ;LEN OF STRING MOVL SP,R7 ;SAVE ADDRESS OF DESC FOR CALL ; ISOLATE NAME JUST FOUND MOVL (R6),R10 ;LEN OF STRING SUBL R0,R10 ;SUBTRACT OFF # OF CHARS LEFT CMPB #^A/*/,@4(R6) ;IS THE CHARACTER A * BEQL 300$ ;BR IF SO LOCC #^A/#/,R10,@4(R6) ;IS NAME WILD BNEQ 300$ ;BR IF YES LOCC #^A/?/,R10,@4(R6) ;IS NAME WILD BNEQ 300$ ;BR IF YES ;NAME IS NOT WILD - APPEND TO STRING SO FAR DECL 4(R6) ;RESET STRING INCL (R6) ;RESET COUNT INCL R10 ;ADD 1 TO LEN SPANNED MOVL 8(AP),R11 ;DESC OF STRING SO FAR ADDL3 (R11),4(R11),R1 ;POINT TO END OF STRING +1 MOVC3 R10,@4(R6),(R1) ;ADD SUBSTRING TO STRING SO FAR PUSHL 4(R11) ADDL3 R10,(R11),-(SP) ;PUSH STRING DESC TO STACK PUSHL SP ;CALLING ARG -START OF DESC PUSHL R7 ;OTHER CALLING ARG CALLS #2,UIC_GET ;CALL AGAIN RET 300$: ; REBUILD STRING WE MESSED UP AND ALSO STRING DESC FOR ARGUMENT FOR COMPARE ; PUSHL 4(R6) ;ADDRESS OF STRING PUSHL R10 ;LEN OF STRING DECL 4(R6) ;FIX STRING BACK THE WAY IT WAS INCL (R6) ;FIX LEN MOVL SP,R6 ;POINTER TO STRING DESC ; UIC IS WILD - MUST BUILD A RAB AND FAB AND OPEN THE NAME SO FAR ; CLRL R8 ;INDICATOR OF REPLACING A . WITH A ] MOVL 8(AP),R11 ;DESC OF STRING SO FAR TSTL (R11) ;IS STRING NULL BNEQ 400$ ;BR IF NOT NULL MOVAL W^ZERO_DIR,R11 ;DESC OF DEFAULT NAME STRING MOVL (R11),R0 ;LEN OF STRING MOVL 4(R11),R1 ;ADDRESS OF STRING BRB 500$ 400$: ;BUILD NAME OF DIRECTORY MOVL (R11),R0 ;LEN OF STRING SO FAR TO R0 MOVL 4(R11),R1 ;START OF STRING 410$: MOVL R1,R2 ;SAVE LOCATION LOCC #^A/./,R0,(R1) ;TRY TO FIND A . INCL R1 ;MOVE R1 OVER . DECL R0 ;DECREASE SIZE OF REMAINING STRING BGEQ 410$ ;BR IF FOUND A . CMPL R2,4(R11) ;DID WE FIND AT LEAST 1 . BNEQ 430$ ;BR IF SO SUBL3 #1,(R11),R0 ;LEN OF STRING -1 ADDL3 #1,R2,R1 ;START OF STRING +1 (SKIP OVER "[") BRB 500$ ;OPEN THE FILE 430$: ;REPLACE . WITH A ] DECL R2 ;POINT R2 TO . MOVL R2,R8 ;SAVE LOCATION OF . MOVB #^A/]/,(R8) ;REPLACE . WITH A ] MOVL (R11),R0 ;LEN OF STRING MOVL 4(R11),R1 ;START OF STRING 500$: SUBL #FAB$C_BLN,SP ;UPDATE SP, SUBTRACT OFF FAB LEN MOVL SP,R10 MOVQ R0,-(SP) MOVQ R0,W^DIR_DESC ;MOVE DESC OF NAME TO DIR_DESC ;FOR THE NOACCESS ROUTINE MOVC5 #0,(SP),#0,#FAB$C_BLN,(R10) ;CLEAR THE FAB -NO ONE ELSE WILL MOVQ (SP)+,R0 $FAB_STORE FAB=R10,FNA=(R1),FNS=R0,SHR=GET,FAC=GET,- DNS=DEFAULT_NAME_SZ,DNA=DEFAULT_NAME MOVB #FAB$C_BID,FAB$B_BID(R10) ;***BUG MOVB #FAB$C_BLN,FAB$B_BLN(R10) ;***BUG SUBL #RAB$C_BLN,SP ;SUBRTACT OFF SIZE OF RAB MOVL SP,R11 MOVC5 #0,(SP),#0,#RAB$C_BLN,(R11) ;CLEAR THE RAB $RAB_STORE RAB=R11,FAB=(R10),UBF=ZERO_BUF,USZ=#1024 MOVB #RAB$C_BID,RAB$B_BID(R11) ;***BUG MOVB #RAB$C_BLN,RAB$B_BLN(R11) ;***BUG $OPEN FAB=(R10) BLBS R0,510$ CMPL R0,#RMS$_PRV ;IS THIS A PRIVILEGE VIOLATION BNEQ 505$ ;BR IF NOT BSBW NO_ACCESS ;WRITE NOACCESS MESSAGE ON SYSOUT 505$: BRW 800$ ;NO GO TRY ANOTHER ONE 510$: $CONNECT RAB=(R11) BLBS R0,515$ ERROR MFD_ERR, ;ERROR OPENING FILE 515$: TSTL R8 ;DID WE REPLACE A . WITH A ] IN STRING BEQL 520$ ;BRANCH IF NOT MOVB #^A/./,(R8) ;REPLACE ] WITH A . 520$: $GET RAB=(R11) BLBS R0,540$ CMPL R0,#RMS$_EOF BEQL 530$ ERROR MFD_GET, ;ERROR DURING GET 530$: BRW 700$ ;ALL DONE CLOSE THE FILES 540$: MOVZBL W^ZERO_BUF+3,R8 ;LEN OF NAME ; MAKE SURE NAME IS NOT 000000.DIR, SINCE [000000] HAS 000000.DIR AS AN ENTRY ; AND THIS WILL CAUSE ALOT OF RECURSION ON [*.*.*.*], ETC. MATCHC #10,W^ZERODIR+8,R8,W^ZERO_BUF+4 ;IS IT 000000.DIR BEQL 520$ ;IF YES -GO GET ANOTHER NAME ;MAKE SURE NAME HAS .DIR EXTENSION MATCHC #4,W^ZERODIR+14,R8,W^ZERO_BUF+4 ;CHECK FOR .DIR EXTENSION BNEQ 520$ ;TRY AGAIN SUBL #4,R8 ;SUBTRACT OFF .DIR LEN CMPB #^A/*/,@4(R6) ;IS THE NAME WILD IF SO MATCH ALL .DIR BEQL 580$ MOVL R8,W^CHECK_DIR ;BUILD A DESC MOVAB W^ZERO_BUF+4,W^CHECK_DIR+4 ;REST OF DESC PUSHL R6 ;PUSH ARGUMENT PUSHAB W^CHECK_DIR CALLS #2,W^COMPARE BLBC R0,520$ ;BR IF NOT FOUND ; ; COMPARE WAS SUCCESSFUL - ADD TO STRING SO FAR 580$: ;CHECK THE FILE HEADER TO MAKE SURE IT REALLY IS A DIRECTORY FILE ;ISOLATE POSITION IN INDEX FILE TO R2 AND BSBW VALIDATE_DIR ADDL3 #11,R8,R2 ;ADD THE 4 BACK IN +1 TO ROUND UP ;AND ADD IN 6 FOR THE OFFSET OF INDEX BBCC #0,R2,590$ ;MAKE WORD ALIGNED (CLEAR LOW BIT IF SET 590$: ADDW3 W^ZERO_BUF(R2),W^HEAD_OFFSET,R2 ;GET VBN IN INDEX FILE TO R6 BSBW VALIDATE_DIR BLBS R0,595$ ;BR IF OKAY BRW 520$ ;IGNORE THIS FILE - NOT A DIRECTORY 595$: MOVL 8(AP),R9 ;DESC OF STRING SO FAR ADDL3 (R9),4(R9),R1 ;POINT TO END OF STRING +1 TSTL (R9) ;IS STRING NULL BEQL 600$ ;BR IF NULL MOVB #^A/./,(R1)+ ;MOVE IN THE . BRB 610$ 600$: MOVB #^A/[/,(R1)+ ;MOVE IN THE [ 610$: MOVC3 R8,W^ZERO_BUF+4,(R1) ;ADD TO NAME SO FAR PUSHL 4(R9) ;STARTING ADDRESS OF STRING ADDL (R9),R8 ;UPDATE SIZE ADDL3 #1,R8,-(SP) ;MOVE LEN TO STACK PUSHL SP ;ARGUMENT POINT TO DESC OF NAME PUSHL R7 ;NAME ARGUEMENT CALLS #2,UIC_GET BRW 520$ ;DO IT AGAIN 700$: ;CLOSE ALL FILES AND RETURN $DISCONNECT RAB=(R11) $CLOSE FAB=(R10) 800$: RET .ALIGN LONG DIR_END: .ASCII /].DIR/ .ALIGN LONG .ALIGN LONG NAME_SO_FAR:: .LONG 0 .LONG NAME_SO_FAR1 NAME_SO_FAR1:: .BLKB 100 .ALIGN LONG CHECK_DIR: .LONG 0,0 ZERO_BUF: .BLKB 1024 ZERO_DIR: .LONG 18 .LONG ZERODIR ZERODIR: .ASCII /[000000]000000.DIR/ .END