.TITLE SNDFIL - SEND A FILE TO THE REMOTE .IDENT /3.3/ .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: SNDFIL ; Author: Gary Larsen & Robin Miller ; Date: April 16, 1982 ; ; Description: ; ; This module will transfer a file from the local system to the remote. ; SNDRCV must previously have been started on the remote. ; ; Modification History: ; ;- .ENABL AMA .NLIST BEX .MCALL CLOSE$, DIR$, GET$, QIOW$S, QIO$S, WTSE$S ; Local equates: BELL = 7 ; BELL LF = 10. ; LINE FEED CR = 13. ; CARRIAGE RETURN REMFIL:: .BLKB 50. ; REMOTE OUTPUT FILE NAME BUFFER REMLEN:: .WORD 0 ; LENGTH OF OUTPUT FILE NAME ENDUIC:: .WORD 0 ; POINTER TO END OF INPUT UIC BUFFER WLDUIC:: .WORD 0 ; WILD CARD UIC FLAG FILCNT:: .WORD 0 ; NUMBER OF FILES TRANSMITTED ; Messages: LFILEQ:: .ASCIZ "Enter the name of the RSX file(s): " RFILEQ:: .ASCIZ "Enter the name of the REMOTE file: " SLFILH: .ASCIZ "SEND RSX_FILE" SRFILH: .ASCIZ "SEND REMOTE_FILE" SRDIRH: .ASCIZ "SEND REMOTE_DIRECTORY" WFILEQ: .ASCIZ "Enter the name of the REMOTE directory: " .EVEN ;+ ; ; SNDFIL - SEND A FILE TO THE REMOTE SYSTEM. ; ; Description: ; ; This module will transfer a file from the local system to the remote. ; SNDRCV must previously have been started on the remote. ; ; ; All registers are preserved. ; ;- SNDFIL:: CALL $SAVAL ; SAVE THE REGISTERS CALL INTALL ; INITIALIZE ALL COUNTERS MOV #SEND,MODE ; SHOW IN SEND MODE CALL INIT ; SEE IF REMOTE IS INITIALIZED BCC 10$ ; IF CC, YES JMP 170$ ; ELSE EXIT ; Get the local file name(s). 10$: MOV #INCMD,R1 ; ADDRESS TO STORE INPUT MOV #LFILEQ,R2 ; ADDRESS OF THE PROMPT MOV #SLFILH,HLPADR ; ADDRESS OF HELP STRING CALL PROMPT ; GO ASK THE QUESTION TST BCKFLG ; USER WANT TO BACKUP ? BEQ 20$ ; IF EQ, NO (CONTINUE) JMP 170$ ; YES, JUST RETURN ; Request and open the local file for read. 20$: TSTB (R1) ; IS THERE A FILSPEC ? BEQ 10$ ; IF EQ, NO (TRY AGAIN) MOV R1,R2 ; COPY THE INPUT ADDRESS MOV #INFDB,R0 ; ADDRESS OF INPUT FDB ; Check for command file input. CMPB (R2),#'@ ; IS THERE AN @ SIGN ? BNE 25$ ; IF NE, NO CALL CMDFIL ; YES, OPEN THE FILE BCS 10$ ; IF CS, ERROR BR 30$ ; ELSE, CONTINUE ... 25$: 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 BR 10$ ; AND TRY AGAIN 30$: CALL MAKNAM ; MAKE THE FILE NAME ; Get the remote file name. 40$: CLR ABOFLG ; INITIALIZE THE ABORT FLAG CLR FILCNT ; INITIALIZE THE FILE COUNT MOV #REMFIL,R1 ; ADDRESS TO STORE INPUT MOV #RFILEQ,R2 ; ADDRESS OF THE PROMPT MOV #SRFILH,HLPADR ; ADDRESS OF HELP STRING TST CMDFLG ; IS A COMMAND FILE OPEN ? BNE 45$ ; IF NE, YES (TREAT LIKE WILDCARD) TST WLDFLG ; WILD CARDS SPECIFIED ? BEQ 50$ ; IF EQ, NO 45$: MOV #WFILEQ,R2 ; ADDRESS OF THE PROMPT MOV #SRDIRH,HLPADR ; ADDRESS OF HELP STRING ; Request the remote file name or directory name.' 50$: CALL PROMPT ; GO ASK THE QUESTION TST BCKFLG ; USER WANT TO BACKUP ? BNE 10$ ; IF NE, YES (ASK FOR LOCAL FILE) CLR WLDUIC ; CLEAR WILD CARD UIC FLAG MOV #REMFIL,ENDUIC ; INIT UIC POINTER TST CMDFLG ; INPUT FROM COMMAND FILE ? BNE 55$ ; IF NE, YES TST WLDFLG ; WILD CARDS SPECIFIED ? BNE 55$ ; IF NE, YES TSTB (R1) ; REMOTE FILE SPECIFIED ? BEQ 70$ ; IF EQ, NO (USE LOCAL NAME) MOV LIOSB+2,REMLEN ; YES, SAVE THE LENGTH BR 85$ ; AND CONTINUE ... ; ; Wildcard directory specified for local files. ; ; Options: ; 1.) If is typed, use the default directory on the remote. ; We will send only the file name. ; 2.) If "*" is typed, we will send the entire file specification. ; 3.) If anything else is typed, presume a directory name. ; The file name will be appeneded to the directory name. ; 55$: CMPB (R1),#'* ; USE WILD CARD UIC'S ? BNE 60$ ; IF NE, NO MOV #-1,WLDUIC ; SHOW WILDCARD UIC OUTPUT BR 70$ ; AND CONTINUE ... 60$: TSTB (R1) ; USE DEFAULT UIC ON REMOTE ? BEQ 70$ ; IF EQ, YES (CONTINUE) ADD LIOSB+2,ENDUIC ; POINT PAST DIRECTORY NAME ; Setup the file name to send the remote system. 70$: MOV ENDUIC,R0 ; COPY OUTPUT FILE ADDRESS MOV SOFNAM,R1 ; LOCAL FILE NAME ADDRESS TST WLDUIC ; USE DEFAULT UIC ON REMOTE ? BEQ 80$ ; IF EQ, YES MOV SOFUIC,R1 ; NO, COPY THE UIC ALSO 80$: MOVB (R1)+,(R0)+ ; MOVE THE FILE NAME CMPB (R1),#CR ; ARE WE AT END OF VERSION # ? BNE 80$ ; IF NE, NO (CONTINUE) CLRB (R0) ; TERMINATE REMOTE NAME SUB #REMFIL,R0 ; CALCULATE THE BYTE COUNT MOV R0,REMLEN ; AND SAVE THE LENGTH 85$: CALL INTFIL ; CLEAR NEXT FILE COUNTERS ; Send the filename to the remote and wait for response. 90$: TST ABOFLG ; CTRL/C TYPED TO ABORT ? BNE 130$ ; IF NE, YES (CLOSE FILE) MOV #REMFIL,R2 ; OUTPUT FILE NAME ADDRESS MOV REMLEN,R3 ; FILE NAME BYTE COUNT 100$: MOV #-1,NRETRY ; DISABLE RETRYS FOR NOW CALL GETRES ; SEND IT TO THE REMOTE CMPB CODE,#NAK ; WAS IT A NAK ? BEQ 40$ ; IF EQ, YES (BAD FILE NAME) TST FILCNT ; IS THIS THE FIRST FILE ? BNE 105$ ; IF NE, NO CALL WRTCCM ; YES, TELL USER HOW TO ABORT 105$: INC FILCNT ; COUNT NUMBER OF FILES CLR NRETRY ; ALLOW RETRANSMISSIONS ; Read a record, calculate checksum, and send it to the remote. 110$: TST ABOFLG ; CTRL/C TYPED TO ABORT ? BNE 130$ ; IF NE, YES (CLOSE FILE) GET$ #INFDB,#LBUFF,#FILSIZ ; GET THE NEXT RECORD BCS 130$ ; IF CS, ERROR MOV F.NRBD+2(R0),R2 ; COPY THE BUFFER ADDRESS MOV F.NRBD(R0),R3 ; COPY THE BYTE COUNT MOV R2,R4 ; COPY FOR CHECKSUM MOV R3,R5 ; COPY FOR CHECKSUM MOV #XBUFF,R0 ; ADDRESS OF TRANSMIT BUFFER MOV R3,R1 ; BYTE COUNT TO BE CONVERTED MOV #23012,R2 ; SET THE CONVERSION PARAMETERS CALL $CBTA ; AND DOIT CALL CHKSUM ; CALCULATE THE CHECKSUM MOV #17012,R2 ; CONVERSION PARAMETERS FOR CHECKSUM CALL $CBTA ; CONVERT IT ; Append data to end of bytecount and checksum characters. 120$: MOVB (R4)+,(R0)+ ; NOW MOVE THE RECORD DEC R5 ; DECREMENT THE BYTE COUNTER BGT 120$ ; IF GT, THERE ARE MORE MOV #XBUFF,R2 ; ADDRESS OF BUFFER TO BE TRANSMITTED ADD #7,R3 ; ADD IN BYTECOUNT AND CHECKSUM CALL GETRES ; SEND IT OFF TO BE TRANSMITTED BCS 130$ ; IF CS, UNEXPECTED ERROR CMPB CODE,#ACK ; WAS THE TRANSMISSION SUCCESSFUL BNE 130$ ; IF NE, NO (PRESUME CANCEL) SUB #7,R3 ; REMOVE C.S. AND B.C TOTALS FROM STATS CALL RSTAT ; YES, SO UPDATE THE STATISTICS BR 110$ ; GO PROCESS NEXT RECORD ; Finished or error encountered. 130$: MOV #INFDB,R0 ; SET ADDRESS OF THE FDB CALL TBLANK ; WRITE BLANK LINE TO TTY TST ABOFLG ; WERE WE ABORTED ? BNE 140$ ; IF NE, YES (NO FCS ERROR) CMPB F.ERR(R0),#IE.EOF ; ENCOUNTER END OF FILE ? BEQ 140$ ; IF EQ, YES MOV #-1,ABOFLG ; ELSE SET ABORT FLAG CALL FILERR ; AND REPORT THE ERROR 140$: CLOSE$ R0 ; CLOSE THE FILE TST ABOFLG ; ARE WE ABORTING ? BNE 160$ ; IF NE, YES CALL WRTSUC ; ELSE YES AND LET EM KNOW IT MOV #INFDB,R0 ; ADDRESS OF INPUT FDB MOV #INFDB+F.FNB,R1 ; ADDRESS OF THE FNB CALL SEOF ; WRITE END OF FILE CALL ONEXT ; OPEN THE NEXT FILE BCC 150$ ; IF CC, ANOTHER FILE CALL NXTFIL ; CHECK FOR COMMAND FILE INPUT BCC 150$ ; IF CC, GOT ANOTHER FILE CALL SEOT ; ELSE, TELL REMOTE WE'RE DONE BR 165$ ; AND CONTINUE ... 150$: CALL MAKNAM ; SETUP THE NEXT FILE NAME JMP 70$ ; AND SEND IT TO THE REMOTE ; We had an unexpected error reading from the file. 160$: CALL CLOCMD ; CLOSE COMMAND FILE (IF OPEN) CALL WRTABO ; AND WRITE ABORT MESSAGE CALL SCAN ; CANCEL THE TRANSMISSION ; Get the status report from the SNDRCV program. 165$: CALL GETSTA ; GET THE STATUS REPORT 170$: RETURN .END