LOGICAL FUNCTION GET_FILE (FILES) C C Routine to transfer a file from the remote. C INCLUDE 'COM.INC/NOLIST' CHARACTER*(*) FILES LOGICAL*1 CODE(1) LOGICAL GET_VAXFILE, GET_REMFILE LOGICAL PARSE_CMD, REPORT_ERROR, GET_RESPONSE INTEGER*4 B, S, E GET_FILE = .FALSE. ! Initialize to bad return. ASSIGN 9999 TO ABORT ! Go here for aborted transmission. C C Parse the command line to check for file names. C B = 1 ! Start at first character. CALL PARSE_CMD (FILES,B,S,E) ! Parse the remote file name. IF (.NOT. GET_REMFILE(FILES(S:E))) RETURN ! Get/open remote file. CALL PARSE_CMD (FILES,B,S,E) ! Parse the VAX file name. IF (.NOT. GET_VAXFILE(FILES(S:E))) RETURN ! Get/open VAX file. CALL REPORT_HOWTO() ! Tell user how to abort transfer. CALL ENABLE_OUT_OF_BAND() ! Enable out of band AST's. CALL INIT_TIMER() ! Initialize the timer. C C Synchronize with remote CPU. C 300 IF (CONTROLC_TYPED) GO TO ABORT ! Abort operation. CALL SEND_SYN() ! Send SYNC byte. IF (.NOT. GET_RESPONSE(CODE,.FALSE.)) GO TO ABORT IF (CODE(1) .EQ. NAK) GO TO 300 ! Transmission error. IF (CODE(1) .EQ. CAN) GO TO ABORT ! Cancel transmission. C C Loop reading from the remote CPU. C CALL CLEAR_COUNTS() ! Initialize the counters. ASSIGN 400 TO LOOP ! Loop reading from remote. ASSIGN 600 TO ERROR ! Transmission error. ASSIGN 700 TO REOF ! Received end of file. 400 IF (CONTROLC_TYPED) GO TO ABORT IF (READ_REMOTE(RBUFFER,READ_SIZE) .EQ. SS$_ABORT) GO TO ABORT IF (RBYTE_COUNT .GT. 6) GO TO 405 IF (RBUFFER(1) .EQ. EOF) THEN GO TO REOF ! Received end of file. ELSEIF (RBUFFER(1) .EQ. ENQ) THEN CALL RESEND_CODE() ! Resend last code, GO TO LOOP ! and try again. ELSE GO TO ERROR ! Transmission error. ENDIF C C Get the byte count and the checksum (4 and 3 bytes respectively). C 405 DECODE (7,410,RBUFFER(1),ERR=600) NBYTES, CHECKSUM 410 FORMAT (I4,I3) C C Now check the following things: make sure length of record is right, C that the length of a binary transfer is a multiple of 8, and that C the checksum checks. C IF (RBYTE_COUNT .NE. NBYTES+7 .OR. 1 (GET_CHECKSUM(RBUFFER(8),NBYTES) .NE. CHECKSUM)) 1 GO TO ERROR C C If here, everything is OK. Write the record to the output file. C IF (NBYTES .GT. 0) THEN WRITE (FILE_UNIT,500) (RBUFFER(I+7),I=1,NBYTES) 500 FORMAT (A1) ELSE WRITE (FILE_UNIT,510) 510 FORMAT () ENDIF CALL UPDATE_TOTALS(NBYTES) ! Update the totals. CALL SEND_ACK() ! Send remote an ACK. GO TO LOOP ! And get next record. C C Here to send NAK to remote for tranmission error. C 600 IF (REPORT_ERROR(.TRUE.)) THEN ! Report the transmission error. CALL SEND_NAK() ! Tell remote to resend last record. GO TO LOOP ! And try again. ELSE CALL SEND_CAN() ! Limit exceeded, abort transmission. GO TO ABORT ! Report the abortion ... ENDIF C C Here to process end of file. C 700 CLOSE (UNIT=FILE_UNIT) ! Close the input file CALL SEND_ACK() ! Tell remote we got EOF. CALL GET_RESPONSE(CODE,.TRUE.) ! Expect EOT next (for now). CALL SEND_ACK() ! Tell remote we got EOT. CALL REPORT_SUCCESS() ! Report the transmission success. GET_FILE = .TRUE. ! Return success. RETURN C C Here to report failure. C 9999 CLOSE (UNIT=FILE_UNIT) ! Close the input file. CALL REPORT_ABORT() ! Report the aborted transmission. END