home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / modcomp / rdata. < prev    next >
Text File  |  1987-01-25  |  8KB  |  231 lines

  1.       INTEGER FUNCTION RDATA (X)
  2. C
  3. C     ****************************************************************
  4. C
  5. C              KERMIT for the MODCOMP MAXIV operating system
  6. C
  7. C        Compliments of:
  8. C
  9. C                         SETPOINT, Inc.
  10. C                      10245 Brecksville Rd.
  11. C                      Brecksville, Ohio 44141
  12. C
  13. C
  14. C      KERMIT is a copyrighted protocol of Columbia Univ. The authors
  15. C      of this version hereby grant permission to copy this software
  16. C      provided that it is not used for an explicitly commercial
  17. C      purpose and that proper credit be given. SETPOINT, Inc. makes
  18. C      no warranty whatsoever regarding the accuracy of this package
  19. C      and will assume no liability resulting from it's use.
  20. C
  21. C     ****************************************************************
  22. C
  23. C     Abstract:  Read a data packet from the other KERMIT.
  24. C
  25. C     MODIFICATION HISTORY
  26. C
  27. C     BY            DATE     REASON            PROGRAMS AFFECTED
  28. C
  29. C     ****************************************************************
  30. C
  31. C     Author: BOB BORGESON          Version: A.0    Date: Oct-86
  32. C
  33. C     Calling Parameters:
  34. C
  35. C           X           - JUNK VARIABLE NEEDED FOR FORTRAN
  36. C
  37. C     ****************************************************************
  38. C
  39. C     Messages generated by this module :  None
  40. C
  41. C     ****************************************************************
  42. C
  43. C     Subroutines called directly :  BUFEMP, CMWI4, DPUTLI, RNOUT,
  44. C                                    RPACK, SPACK, SPAR
  45. C
  46. C     ****************************************************************
  47. C
  48. C     Files referenced :  None
  49. C
  50. C     ****************************************************************
  51. C
  52. C     Local variable definitions :
  53. C
  54. C      MAXTRY - MAXIMUM NUMBER OF TRIES TO GET PACKET
  55. C      N      - PACKET # MODULO 64
  56. C      NUMTRY - # OF TRIES ON THIS PACKET
  57. C      OLDTRY - # OF TRIES ON LAST PACKET
  58. C
  59. C     ****************************************************************
  60. C
  61. C     Commons referenced :  None
  62. C
  63. C     ****************************************************************
  64. C
  65. C     (*$END.DOCUMENT*)
  66. C
  67. C     ****************************************************************
  68. C     *                                                              *
  69. C     *         D I M E N S I O N   S T A T E M E N T S              *
  70. C     *                                                              *
  71. C     ****************************************************************
  72. C
  73.       IMPLICIT INTEGER (A-Z)
  74. C
  75. C     ****************************************************************
  76. C     *                                                              *
  77. C     *         T Y P E   S T A T E M E N T S                        *
  78. C     *                                                              *
  79. C     ****************************************************************
  80. C
  81. C
  82. C     ****************************************************************
  83. C     *                                                              *
  84. C     *         C O M M O N   S T A T E M E N T S                    *
  85. C     *                                                              *
  86. C     ****************************************************************
  87. C
  88.       INCLUDE USL/KERCOM
  89.       INCLUDE USL/KERPMC
  90.       INCLUDE USL/UFTTBC
  91. C
  92. C     ****************************************************************
  93. C     *                                                              *
  94. C     *         E Q U I V A L E N C E   S T A T E M E N T S          *
  95. C     *                                                              *
  96. C     ****************************************************************
  97. C
  98. C
  99. C     ****************************************************************
  100. C     *                                                              *
  101. C     *         D A T A   S T A T E M E N T S                        *
  102. C     *                                                              *
  103. C     ****************************************************************
  104. C
  105. C
  106. C     ****************************************************************
  107. C
  108. C     Code starts here :
  109. C
  110.       IF(NUMTRY.LE.MAXTRY)GO TO 200
  111. C                                     !EXCEEDED MAXTRY , GIVES UP
  112.          RDATA=BIGA
  113.          RETURN
  114.   200 CONTINUE
  115. C                                     !TRY IT AGAIN
  116.           NUMTRY=NUMTRY+1
  117. C                                     !READ A PACKET
  118.       STATUS=RPACK(LEN,NUM,PACKET)
  119. C                                     !IF WE ARE RUNNING IN REMOTE
  120. C                                     !MODE DISPLAY THE PACKET #
  121.       IF(HOSTON.EQ.NO) WRITE(LOCALO,100)NUM
  122. C                                     !WE GOT THE DATA PACKET
  123.       IF(STATUS.NE.BIGD)GO TO 1000
  124.          IF(NUM.EQ.N)GO TO 900
  125.             IF(OLDTRY.LE.MAXTRY)GO TO 300
  126.                RDATA=BIGA
  127.                RETURN
  128.   300       CONTINUE
  129.                 OLDTRY=OLDTRY+1
  130.             IF(NUM.NE.(N-1))GO TO 400
  131. C                                     !WE GOT A DUPLICTED PACKET
  132.                CALL SPAR(PACKET)
  133. C                                     !JUST ACK IT
  134.                TV1=BIGY
  135.                TV2=6
  136.                CALL SPACK(TV1,NUM,TV2,PACKET)
  137.                NUMTRY=0
  138.                RDATA=STATE
  139.                RETURN
  140.   400       CONTINUE
  141.                 RDATA=BIGA
  142.                 RETURN
  143. C                                    !WRITE THE DATA PACKET JUST RECEIVE
  144.   900     CONTINUE
  145.          CALL BUFEMP(PACKET,LEN)
  146. C                                    !INTO THE RECEIVING DISK FILE
  147.          TNUM=N
  148.          TV1=BIGY
  149.          TV2=TNUM
  150.          TV3=0
  151.          TV4=0
  152. C                                    !ACK THE JUST RECEIVED PACKET
  153.          CALL SPACK(TV1,TV2,TV3,TV4)
  154.          OLDTRY=NUMTRY
  155.          NUMTRY=0
  156.          N=MOD((N+1),64)
  157.          RDATA=BIGD
  158.          RETURN
  159.  1000 CONTINUE
  160. C
  161.       IF(STATUS.NE.BIGF)GO TO 2000
  162. C                                        !THE PACKET IS THE FILE HEADER
  163. C                                        !WE SHOULD HAVE ALREADY GOTTEN
  164.               IF(OLDTRY.LE.MAXTRY)GO TO 1100
  165. C                                        !EXCEEDED NUMBER OF RETRY, GIVE
  166.                  RDATA=BIGA
  167.                  RETURN
  168.  1100         CONTINUE
  169.                   OLDTRY=OLDTRY+1
  170. C                                        !WE GOT DUPLICATE FILE HEADER P
  171.               IF(NUM.NE.(N-1))GO TO 1200
  172.                  TV1=BIGY
  173.                  TV2=0
  174.                  TV3=0
  175. C                                             !JUST ACK IT
  176.                  CALL SPACK(TV1,NUM,TV2,TV3)
  177.                  NUMTRY=0
  178.                  RDATA=STATE
  179.                  RETURN
  180.  1200         CONTINUE
  181.                   RDATA=BIGA
  182.                   RETURN
  183. C                                             !WE GOT THE EOF PACKET
  184.  2000 CONTINUE
  185.       IF(STATUS.NE.BIGZ)GO TO 3000
  186.               IF(NUM.EQ.N)GO TO 2100
  187.                  RDATA=BIGA
  188.                  RETURN
  189.  2100         CONTINUE
  190.               TNUM=N
  191.               TV1=BIGY
  192.               TV2=0
  193.               TV3=0
  194. C                                           !ACK IT
  195.               CALL SPACK(TV1,TNUM,TV2,TV3)
  196. C                                           !CLOSE THE RECEIVING DISK FI
  197.              CALL RNOUT
  198.              CALL WEOF4 (IUFT(1,8))
  199. C                                          WRITE OUT THE FILE NAME
  200. C
  201.              CALL CMWI4(IUFT(2,5),40)
  202.              CALL DPUTLIN(FILNAM,5)
  203.              CALL RNOUT
  204. C
  205.               N=MOD((N+1),64)
  206. C                                           !CHANGE THE STATE TO LOOK FO
  207.               RDATA=BIGF
  208. C                                           !ANOTHER FILE HEADER
  209.               RETURN
  210. C
  211.  3000 CONTINUE
  212. C
  213.       IF(STATUS.NE.BAD)GO TO 4000
  214. C                                           !THERE WAS AN ERROR IN THE
  215.               RDATA=STATE
  216. C                                           !CHECKSUM
  217.               TNUM=N
  218.               TV1=BIGN
  219.               TV2=0
  220.               TV3=0
  221. C                                           !NAK IT
  222.               CALL SPACK(TV1,TNUM,TV2,TV3)
  223.               RETURN
  224.  4000 CONTINUE
  225. C                                        !WE GOT A UNKNOWN PACKET TYPE
  226.           RDATA=BIGA
  227. C                                        !GIVES UP
  228.       RETURN
  229. 100   FORMAT('+PACKET #',I3,'  ')
  230.       END
  231.