.TITLE CMDFIL - READ FILES FROM COMMAND FILE .IDENT /01.1/ .ENABL LC ;+ ; ; Free software BY ; Project Software & Development, Inc. ; ; This software is furnished for free and may be used and copied as ; desired. This software or any other copies thereof may be provided or ; otherwise made available to any other person. No title to and ; ownership of the software is hereby transferred or allowed. ; ; The information in this software is subject to change without notice ; and should not be construed as a commitment by PROJECT SOFTWARE ; AND DEVELOPMENT, INC. ; ; PROJECT SOFTWARE assumes no responsibility for the use or reliability ; of this software on any equipment whatsoever. ; ; Project Software & Development, Inc. ; 14 Story St. ; Cambridge, Ma. 02138 ; 617-661-1444 ; ; ; Title: CMDFIL ; Author: Robin Miller ; Date: April 23, 1982 ; ; Description: ; ; This module is called to open a command file when sending the ; remote file(s). The command file is openned, the file name is read ; from the command file, and then it too is openned. ; ; Modification History: ; ;- .ENABL AMA .NLIST BEX .MCALL CLOSE$, GET$ ; Local storage: CMDFLG::.WORD 0 ; COMMAND FILE OPEN FLAG <> 0 = TRUE ; Messages: BADNAM: .ASCIZ " >>> The last file specification was: " .EVEN .SBTTL CMDFIL - OPEN THE COMMAND FILE ;+ ; ; CMDFIL - Open the specified command file. ; ; Inputs: ; R2 = address of the command file name. ; ; Outputs: ; C clear/set = success/failure. ; ; All registers are preserved. ; ;- CMDFIL:: CALL $SAVAL ; SAVE ALL REGISTERS INC R2 ; SKIP OVER THE @ SIGN CLR CMDFLG ; SHOW COMMAND FILE NOT OPEN MOV #CMDFDB,R0 ; ADDRESS OF COMMAND FDB MOV #CMDFDB+F.FNB,R1 ; ADDRESS OF THE FNB MOV #'R,R3 ; SET TO OPEN FOR READ CALL OPEN ; TRY TO OPEN THE FILE BCS 20$ ; IF CS, OPEN FAILED MOV #-1,CMDFLG ; SHOW COMMAND FILE OPEN CALL NXTFIL ; READ FILE NAME AND OPEN IT 10$: RETURN ; RETURN STATUS FROM NXTFIL ; Error openning the command file. 20$: CALL FILERR ; REPORT THE ERROR SEC ; SHOW FAILURE RETURN .SBTTL NXTFIL - READ NEXT FILE NAME AND OPEN IT ;+ ; ; NXTFIL - Read the next file name from the command file and open it. ; ; Inputs: ; Command file previously openned. ; ; Outputs: ; C clear/set = success/failure ; ; All registers are preserved. ; ;- NXTFIL:: CALL $SAVAL ; SAVE ALL REGISTERS TST CMDFLG ; IS A COMMAND FILE OPEN ? BEQ 110$ ; IF EQ, NO (RETURN) ; Read the next file name from the command file. 10$: MOV #INCMD,R2 ; INPUT BUFFER ADDRESS GET$ #CMDFDB,R2,#80. ; READ NEXT FILE NAME BCS 100$ ; IF CS, ERROR MOV F.NRBD(R0),R1 ; COPY THE BYTE COUNT BEQ 10$ ; IF EQ, BLANK LINE MOV R2,R0 ; COPY THE BUFFER ADDRESS MOV R2,R3 ; POINT TO ADD R1,R3 ; END OF INPUT CLRB (R3) ; AND SET TERMINATOR ; Do a little bit of syntax checking. CMPB (R0),#'* ; SPECIFY WILDCARD ? BEQ 20$ ; YEP, THIS IS ALLOWED CMPB (R0),#'0 ; IS THIS A POSSIBLE FILE ? BLT 10$ ; IF LT, NO CMPB (R0),#'9 ; MAYBE, IS IT REALLY ? BLE 20$ ; IF LE, YES CMPB (R0),#'A ; BAD FILE NAME ? BLT 10$ ; IF LT, YES ; Convert the file name to uppercase. 20$: CALL CUPPER ; CONVERT TO UPPER CASE TSTB (R0)+ ; AT END OF COMMAND ? BNE 20$ ; IF NE, NO (LOOP) ; Now attempt to open the file for read. R2 is setup. MOV #INFDB,R0 ; ADDRESS OF INPUT FDB MOV #INFDB+F.FNB,R1 ; ADDRESS OF THE FNB MOV #'R,R3 ; SET FOR READ CALL OPEN ; TRY TO OPEN THE FILE BCC 30$ ; IF CC, SUCCESS CALL FILERR ; ELSE REPORT THE ERROR MOV #BADNAM,R4 ; ADDRESS OF BAD NAME MSG CALL WRITE ; WRITE IT MOV #INCMD,R4 ; NOW WRITE CALL WRITE ; THE FILE NAME CALL BLANK ; AND A BLANK LINE BR 10$ ; AND GET NEXT FILE 30$: RETURN ; RETURN SUCCESS ; Error occured reading from the command file. 100$: CMPB F.ERR(R0),#IE.EOF ; IS IT END OF FILE BEQ 110$ ; IF EQ, YES (EXPECTED) CALL FILERR ; ELSE, REPORT THE ERROR 110$: CALL CLOCMD ; CLOSE THE COMMAND FILE SEC ; SHOW FAILURE RETURN ;+ ; ; CLOCMD - This routine closes the command file. ; ;- CLOCMD:: TST CMDFLG ; IS THE COMAND FILE OPEN ? BEQ 10$ ; IF EQ, NO CLOSE$ #CMDFDB ; ELSE CLOSE IT CLR CMDFLG ; SHOW COMMAND FILE CLOSED 10$: RETURN ; AND RETURN .END