      SUBROUTINE UFTINI
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:  Initialize the UFTs required for the MAX IV Kermit
C                package.
C
C     MODIFICATION HISTORY
C
C     BY            DATE     REASON            PROGRAMS AFFECTED
C
C     ****************************************************************
C
C     Author:  Rick Burke           Version: A.0    Date: Aug-86
C
C     Calling Parameters:  None
C
C     ****************************************************************
C
C     Messages generated by this module :  None
C
C     ****************************************************************
C
C     Subroutines called directly :  BLDUFT, REWIND
C
C     ****************************************************************
C
C     Files referenced :  None
C
C     ****************************************************************
C
C     Local variable definitions :
C
C     DEV1         - Logical device to which KE2 is assigned
C     DEV2         - Logical device to which KE4 is assigned
C     HANOPT       - Handler options word from TASS4
C     LDEVST       - Logical device status returned from TASS4
C     LFNAM        - CAN code of base value of LFN for Kermit I/O
C     RECSIZ       - Record size returned by TASS4
C     SUCCES       - Success indicator of TASS4 calls
C
C     ****************************************************************
C
C     Commons referenced :  KER, KERPAR, and UFTTBL local commons
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
      DATA LFNAM /3@KE0/
C
C     ****************************************************************
C
C     Code starts here :
C
      CALL BLDUFT (IUFT(1,1),0,LFNAM+1,4ZA000)
      CALL BLDUFT (IUFT(1,2),0,LFNAM+2,4ZE000)
      CALL BLDUFT (IUFT(1,3),0,LFNAM+3,4ZC280)
      CALL BLDUFT (IUFT(1,4),0,LFNAM+4,4ZD380,0,0,0,4Z8000,0,BLIN(1,1),
     >             132)
      CALL BLDUFT (IUFT(1,5),0,LFNAM+5,4ZA000)
      CALL BLDUFT (IUFT(1,7),0,LFNAM+7,4ZA000)
      CALL BLDUFT (IUFT(1,8),0,LFNAM+8,4ZA000)
      CALL BLDUFT (IUFT(1,9),0,LFNAM+9,4ZA000)
      CALL BLDUFT (IUFT(1,10),0,LFNAM+4,4ZD380,0,0,0,4Z8000,0,BLIN(1,2),
     >             132)
C
C                 NOW REWIND THE DISK FILES WE WILL ACCESS
C
      CALL REW4 (IUFT(1,5))
      CALL REW4 (IUFT(1,8))
C
      CALL WEOF4 (IUFT(1,8))
C
C----->  If the terminal I/O and Kermit I/O ports are pointing
C----->  at the I/O channel then set HOSTON = YES and defer
C----->  issuing a read to KE4 until either a SEND or
C----->  RECEIVE are issued.
C
      CALL TASS4 (IUFT(1,2),SUCCES,LDEVST,RECSIZ,DEV1,HANOPT)
      IF (SUCCES .NE. 1) CALL EXIT
      CALL TASS4 (IUFT(1,4),SUCCES,LDEVST,RECSIZ,DEV2,HANOPT)
      IF (SUCCES .NE. 1) CALL EXIT
C
C----->  Zero out the buffers we will use for Kermit data.
C
      DO 10 I = 1,132
      BLIN(I,1) = 0
      BLIN(I,2) = 0
   10 CONTINUE
      IF (DEV1 .NE. DEV2) GO TO 20
C
C----->  Kermit has been activated from a remote device, so set
C----->  the HOSTON flag and don't queue an initial read.
C
      HOSTON = YES
      CHRCHN = 0
      RETURN
   20 CONTINUE
C
C----->  Kermit has been activated by a local terminal, so issue
C----->  the initial read, in anticipation of incoming data.
C
      HOSTON = NO
      CURCHN = 1
      CALL READ4 (IUFT(1,4),BLIN(1,CURCHN),132,.FALSE.)
      RETURN
      END
