home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
modcomp
/
rdata.
< prev
next >
Wrap
Text File
|
1987-01-25
|
8KB
|
231 lines
INTEGER FUNCTION RDATA (X)
C
C ****************************************************************
C
C KERMIT for the MODCOMP MAXIV operating system
C
C Compliments of:
C
C SETPOINT, Inc.
C 10245 Brecksville Rd.
C Brecksville, Ohio 44141
C
C
C KERMIT is a copyrighted protocol of Columbia Univ. The authors
C of this version hereby grant permission to copy this software
C provided that it is not used for an explicitly commercial
C purpose and that proper credit be given. SETPOINT, Inc. makes
C no warranty whatsoever regarding the accuracy of this package
C and will assume no liability resulting from it's use.
C
C ****************************************************************
C
C Abstract: Read a data packet from the other KERMIT.
C
C MODIFICATION HISTORY
C
C BY DATE REASON PROGRAMS AFFECTED
C
C ****************************************************************
C
C Author: BOB BORGESON Version: A.0 Date: Oct-86
C
C Calling Parameters:
C
C X - JUNK VARIABLE NEEDED FOR FORTRAN
C
C ****************************************************************
C
C Messages generated by this module : None
C
C ****************************************************************
C
C Subroutines called directly : BUFEMP, CMWI4, DPUTLI, RNOUT,
C RPACK, SPACK, SPAR
C
C ****************************************************************
C
C Files referenced : None
C
C ****************************************************************
C
C Local variable definitions :
C
C MAXTRY - MAXIMUM NUMBER OF TRIES TO GET PACKET
C N - PACKET # MODULO 64
C NUMTRY - # OF TRIES ON THIS PACKET
C OLDTRY - # OF TRIES ON LAST PACKET
C
C ****************************************************************
C
C Commons referenced : None
C
C ****************************************************************
C
C (*$END.DOCUMENT*)
C
C ****************************************************************
C * *
C * D I M E N S I O N S T A T E M E N T S *
C * *
C ****************************************************************
C
IMPLICIT INTEGER (A-Z)
C
C ****************************************************************
C * *
C * T Y P E S T A T E M E N T S *
C * *
C ****************************************************************
C
C
C ****************************************************************
C * *
C * C O M M O N S T A T E M E N T S *
C * *
C ****************************************************************
C
INCLUDE USL/KERCOM
INCLUDE USL/KERPMC
INCLUDE USL/UFTTBC
C
C ****************************************************************
C * *
C * E Q U I V A L E N C E S T A T E M E N T S *
C * *
C ****************************************************************
C
C
C ****************************************************************
C * *
C * D A T A S T A T E M E N T S *
C * *
C ****************************************************************
C
C
C ****************************************************************
C
C Code starts here :
C
IF(NUMTRY.LE.MAXTRY)GO TO 200
C !EXCEEDED MAXTRY , GIVES UP
RDATA=BIGA
RETURN
200 CONTINUE
C !TRY IT AGAIN
NUMTRY=NUMTRY+1
C !READ A PACKET
STATUS=RPACK(LEN,NUM,PACKET)
C !IF WE ARE RUNNING IN REMOTE
C !MODE DISPLAY THE PACKET #
IF(HOSTON.EQ.NO) WRITE(LOCALO,100)NUM
C !WE GOT THE DATA PACKET
IF(STATUS.NE.BIGD)GO TO 1000
IF(NUM.EQ.N)GO TO 900
IF(OLDTRY.LE.MAXTRY)GO TO 300
RDATA=BIGA
RETURN
300 CONTINUE
OLDTRY=OLDTRY+1
IF(NUM.NE.(N-1))GO TO 400
C !WE GOT A DUPLICTED PACKET
CALL SPAR(PACKET)
C !JUST ACK IT
TV1=BIGY
TV2=6
CALL SPACK(TV1,NUM,TV2,PACKET)
NUMTRY=0
RDATA=STATE
RETURN
400 CONTINUE
RDATA=BIGA
RETURN
C !WRITE THE DATA PACKET JUST RECEIVE
900 CONTINUE
CALL BUFEMP(PACKET,LEN)
C !INTO THE RECEIVING DISK FILE
TNUM=N
TV1=BIGY
TV2=TNUM
TV3=0
TV4=0
C !ACK THE JUST RECEIVED PACKET
CALL SPACK(TV1,TV2,TV3,TV4)
OLDTRY=NUMTRY
NUMTRY=0
N=MOD((N+1),64)
RDATA=BIGD
RETURN
1000 CONTINUE
C
IF(STATUS.NE.BIGF)GO TO 2000
C !THE PACKET IS THE FILE HEADER
C !WE SHOULD HAVE ALREADY GOTTEN
IF(OLDTRY.LE.MAXTRY)GO TO 1100
C !EXCEEDED NUMBER OF RETRY, GIVE
RDATA=BIGA
RETURN
1100 CONTINUE
OLDTRY=OLDTRY+1
C !WE GOT DUPLICATE FILE HEADER P
IF(NUM.NE.(N-1))GO TO 1200
TV1=BIGY
TV2=0
TV3=0
C !JUST ACK IT
CALL SPACK(TV1,NUM,TV2,TV3)
NUMTRY=0
RDATA=STATE
RETURN
1200 CONTINUE
RDATA=BIGA
RETURN
C !WE GOT THE EOF PACKET
2000 CONTINUE
IF(STATUS.NE.BIGZ)GO TO 3000
IF(NUM.EQ.N)GO TO 2100
RDATA=BIGA
RETURN
2100 CONTINUE
TNUM=N
TV1=BIGY
TV2=0
TV3=0
C !ACK IT
CALL SPACK(TV1,TNUM,TV2,TV3)
C !CLOSE THE RECEIVING DISK FI
CALL RNOUT
CALL WEOF4 (IUFT(1,8))
C WRITE OUT THE FILE NAME
C
CALL CMWI4(IUFT(2,5),40)
CALL DPUTLIN(FILNAM,5)
CALL RNOUT
C
N=MOD((N+1),64)
C !CHANGE THE STATE TO LOOK FO
RDATA=BIGF
C !ANOTHER FILE HEADER
RETURN
C
3000 CONTINUE
C
IF(STATUS.NE.BAD)GO TO 4000
C !THERE WAS AN ERROR IN THE
RDATA=STATE
C !CHECKSUM
TNUM=N
TV1=BIGN
TV2=0
TV3=0
C !NAK IT
CALL SPACK(TV1,TNUM,TV2,TV3)
RETURN
4000 CONTINUE
C !WE GOT A UNKNOWN PACKET TYPE
RDATA=BIGA
C !GIVES UP
RETURN
100 FORMAT('+PACKET #',I3,' ')
END