LOGICAL FUNCTION SEND_FILE(FILES) C C Routine to send a file to the remote. C INCLUDE 'COM.INC/NOLIST' CHARACTER*(*) FILES LOGICAL*1 CODE(1) LOGICAL GET_VAXFILE, GET_REMFILE, REPORT_ERROR LOGICAL GET_RESPONSE, NEXT_REMFILE INTEGER*4 B, S, E SEND_FILE = .FALSE. ! Initialize to bad return. C C Parse the file names (if any). C B = 1 ! Start at first character. CALL PARSE_CMD(FILES,B,S,E) ! Parse the file name (if any). IF (.NOT. GET_VAXFILE(FILES(S:E))) RETURN ! Get/open the VAX file. CALL PARSE_CMD(FILES,B,S,E) ! Parse the file name (if any). IF (.NOT. GET_REMFILE(FILES(S:E))) RETURN ! Get/open the REMOTE file. C C We're all ready to go ... C 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. CALL CLEAR_COUNTS() ! Initialize the counters. C C Main send loop. C 100 IF (CONTROLC_TYPED) GO TO 9999 ! Return if aborted. READ (FILE_UNIT,110,END=9900) NBYTES,(XBUFFER(I+7),I=1,NBYTES) 110 FORMAT (Q,A1) C C Prepare the record to send the remote. C C Format: bbbbcccrrr...rrr C C Where: b = bytecount, c = checksum, r = record. C 200 IF (CONTROLC_TYPED) GO TO 9999 ! Return if aborted. CHECKSUM = GET_CHECKSUM(XBUFFER(8),NBYTES) ! Calculate checksum. ENCODE (7,210,XBUFFER(1)) NBYTES, CHECKSUM ! Put it in buffer. 210 FORMAT (I4,I3) C C Write it to the remote and wait for a response. C CALL WRITE_REMOTE(XBUFFER,NBYTES+7) IF (GET_RESPONSE(CODE,.TRUE.)) THEN IF (CODE(1) .EQ. ACK) THEN CALL UPDATE_TOTALS(NBYTES) ! Update the totals GO TO 100 ! and send next record. ELSE IF (REPORT_ERROR(.TRUE.)) THEN GO TO 200 ! Retransmit the last record. ENDIF ENDIF ENDIF C C We get here if we're aborting the transmission. C CALL SEND_CAN() ! Tell the remote to abort. GO TO 9999 C C Here for EOF on input. C 9900 CALL SEND_EOF() ! Send EOF (CTRL/Z) to remote. IF (GET_RESPONSE(CODE,.TRUE.)) THEN ! Get response from remote. IF (CODE(1) .EQ. NAK) GO TO 9900 ! Transmission error. ENDIF C C Either send the next file name or EOT (End of transmission). C CLOSE (UNIT=FILE_UNIT) ! Close the output file. CALL REPORT_SUCCESS() ! Report transmission success. IF (NEXT_REMFILE()) THEN CALL COUNT_FILES() ! Count the files transferred. GO TO 100 ! Go send the next file. ENDIF 9910 CALL SEND_EOT() ! Send end of transmission. IF (GET_RESPONSE(CODE,.TRUE.)) THEN ! Get response from remote. IF (CODE(1) .EQ. NAK) GO TO 9910 ! Resend send of transmission. ENDIF SEND_FILE = .TRUE. ! Show success. RETURN C C Here to report failure. C 9999 CLOSE (UNIT=FILE_UNIT) ! Close the output file. CALL REPORT_ABORT() ! Report aborted transmission. RETURN END