*IDENT UVA1
*I COMCKER.39
      PARAMETER (CSB812=6)
*I 174
      LOGICAL EOCONV
*I 182
      COMMON /PROTO/ EOCONV
      COMMON /PROTO/ BINMODE
*I 298
*     OPERATING SYSTEM/NETWORK FLAGS/CONSTANTS
  
      PARAMETER (CCP=1, CDCNET=2)
      COMMON /OPSYS/ TSTATUS(2)
      COMMON /OPSYS/ NETTYPE
  
*I KERMIT.36
*     3.4  10/05/87 OLAF PORS, UNIVERSITY OF VIRGINIA
*          NOS 2.5.1, LEVEL 664.
*
*       1. ADD SUPPORT FOR 8/12 ASCII BINARY FILES.
*          PACKED BINARY FILES ARE EFFICIENT AND USABLE
*          WITH CDC-RELEASED FILE TRANSFER PROGRAMS,
*          BUT CANNOT ACCURATELY PRESERVE FILE LENGTHS
*          DUE TO FILLER IN THE LAST WORD.  8/12 BINARY
*          TAKES CARE OF THE LIMITATION AND IS COMPATIBLE
*          WITH UTILITIES SUCH AS FCOPY.
*          A SUMMARY OF RELATED KERMIT COMMANDS - 
*
*          "SET FILE-MODE TEXT" (THE DEFAULT) INDICATES THAT
*          A TEXT FILE(S) IS TO BE SENT OR RECEIVED IN
*          THE CURRENT TEXT MODE.  THE CURRENT TEXT MODE
*          IS SET WITH THE "SET TEXT-MODE XXX" COMMAND.
*          XXX IS "AUTO" (THE DEFAULT), "6/12", "DISPLAY", OR
*          "8/12".  AUTO ATTEMPTS TO DETERMINE THE CHARACTER
*          SET OF A CDC FILE BEFORE SENDING IT, AND
*          CREATES A 6/12 CDC FILE IF RECEIVING.
*          THE OTHERS READ/CREATE CDC FILES IN THE
*          RESPECTIVE CHARACTER SET.
*          THE "AUTO" DEFAULT MAY BE CHANGED, DEPENDING
*          ON SITE PREFERENCE, BY PUTTING ONE OF THE
*          FOLLOWING INTO "KERMOD2" DURING INSTALLATION -
*
*             *DEFINE,TEXT612 
*             *DEFINE,TEXTDISP
*          OR *DEFINE,TEXT812 
*
*          "SET FILE-MODE BINARY" ALLOWS THE COMMAND
*          "SET BIN-MODE YYY" TO BE ENTERED.
*          YYY IS "PACKED" (THE DEFAULT) OR "8/12".
*          PACKED READS/STUFFS 7.5 BYTES INTO A CM WORD.
*          8/12 READS/PUTS EACH 8-BIT BYTE INTO A 12-BIT BYTE.
*          THE DEFAULT MAY BE CHANGED AS FOLLOWS -
*
*             *DEFINE,BIN812
*
*       2. MAKE EOR/EOF CONVERSION TO #EOR/#EOF OPTIONAL.
*          #EOR/#EOF LINES CREATED IN/TRANSLATED FROM
*          TEXT FILES ON A MICRO ARE GREAT FOR PRESERVING
*          EOR/EOF MARKS AND FOR USE WITH CDC-RELEASED
*          FILE TRANSFER PACKAGES, BUT ARE EXTREMELY
*          ANNOYING FOR USERS WHO DON'T CARE ABOUT EOR-S
*          AND DON'T USE THE CDC PACKAGES.  THEREFORE,
*          THE "SET EOR-EOF-MODE ZZZ" COMMAND ALLOWS THE USER
*          TO SELECT WHAT HE WANTS.  ZZZ IS "ON" TO
*          CREATE/RECOGNIZE THE LINES, "OFF" IF NOT TO.
*          THE DEFAULT IS "ON", BUT MAY BE CHANGED WITH
*
*             *DEFINE,EORMOFF 
*
*       3. ADD SUPPORT FOR CDCNET.  DIFFERENT 0016 CONTROL BYTE
*          SEQUENCES ARE USED DEPENDING ON WHETHER KERMIT
*          IS ACCESSED FROM A CDCNET OR NPU LINE. 
*
*I KERMIT.424
*     FILMODE IS SET TO TEXT OR BINARY.  IF TEXT, 
*     THEN TXTMODE IS RELEVANT.  TXTMODE IS SET BY THE
*     SET TEXT-MODE COMMAND TO CSNONE, CSDSP, CS812,
*     OR CS612.  IF BINARY, THEN BINMODE IS RELEVANT.
*     BINMODE IS CORRESPONDINGLY SET BY THE SET BIN-MODE
*     COMMAND TO CSB812 OR CSBIN.
*     WHEN A FILE IS BEING READ OR WRITTEN, THE FCSET ENTRY 
*     IS SET TO CSDSP, CS812, CS612, CSTXP, CSBIN OR
*     CSB812, DEPENDING ON THE SETTINGS OF THE ABOVE
*     PARAMETERS, AND, IF FILMODE=TEXT, TXTMODE=NONE,
*     THE CONTENTS OF THE FILE BEING READ.
  
*I KERMIT.429
*IF -DEF,TEXTDISP,3 
*IF -DEF,TEXT612,2
*IF -DEF,TEXT812,1
*I KERMIT.430
*IF DEF,TEXTDISP,1
      DATA TXTMODE          / CSDSP          /
*IF DEF,TEXT612,1
      DATA TXTMODE          / CS612          /
*IF DEF,TEXT812,1
      DATA TXTMODE          / CS812          /
*IF DEF,EORMOFF,1
      DATA EOCONV           / .FALSE.        /
*IF -DEF,EORMOFF,1
      DATA EOCONV           / .TRUE.         /
*IF DEF,BIN812,1
      DATA BINMODE          / CSB812         /
*IF -DEF,BIN812,1
      DATA BINMODE          / CSBIN          /
*D 493,494
      DATA VERSION / '^CYBER-170/^N^O^S ^K^E^R^M^I^T ^VER 3.4    @S\N' /
      DATA HLPASCH / '^DECIMAL, OCTAL (^B), OR HEXADECIMAL (^H) CODE FOR
*D 668,669
      CALL    USTART
      IF ( AND( SHIFT(TSTATUS(2),-48),O"77") .NE. 2 ) THEN
         CALL REMARK(' KERMIT - JOB IS NOT INTERACTIVE')
*I 671
      NETTYPE = SHIFT(TSTATUS(2),-54)
*D 1037,1038
      PARAMETER (TSIZE=12)
      CHARACTER*15 SETTYP(TSIZE)
*D 1041
     +    'TEXT-MODE', 'BIN-MODE', 'EOR-EOF-MODE' /
*D 1046
      GO TO (20,30,40,10,50,70,75,80,90,100,110,120), INDX
*I 1096
  
*     SET BINARY MODE (8/12, PACKED)
  
110   CALL BINMCMD
      RETURN
  
*     SET EOR-EOF LINE MODE (OFF OR ON) 
  
120   CALL EOMDCMD
      RETURN
*D KERMIT.1150
         CALL FPRINTF(STDOUT,'^BINARY (',0,0,0,0) 
         IF(BINMODE .EQ. CSB812) THEN
            CALL FPRINTF(STDOUT,'8/12)',0,0,0,0)
         ELSE
            CALL FPRINTF(STDOUT,'PACKED)',0,0,0,0)
         ENDIF
*I 1160
  
*     DISPLAY THE EOR/EOF FLAG
  
      CALL FPRINTF(STDOUT,'  ^EOR/^EOF LINES: ',0,0,0,0) 
      IF(EOCONV) THEN
         CALL FPRINTF(STDOUT,'^ON\N',0,0,0,0)
      ELSE
         CALL FPRINTF(STDOUT,'^OFF\N',0,0,0,0)
      ENDIF
*D 1213,1214
      CALL FPRINTF(STDOUT,'^INIT PACKET RETRY COUNT: @D     ',MAXRINI,
     +0,0,0)
*I KERMLIB.51
      SUBROUTINE BINMCMD
  
***   BINMCMD - PERFORM A SET BIN-MODE XXXX COMMAND
  
      IMPLICIT INTEGER (A-Z)
      PARAMETER (COMLIS = 0)
*CALL COMCKER
      LOGICAL CONFIRM
      PARAMETER (TSIZE=2)
      CHARACTER*10 MODETYP(TSIZE)
      DATA MODETYP / 'PACKED', '8/12' / 
  
      INDX = MATCH(MODETYP,TSIZE,.FALSE.)
      IF (INDX .LE. 0) RETURN 
      IF (.NOT. CONFIRM(CMDFD)) RETURN
  
      GO TO (10, 20), INDX
  
*     SET PACKED (7.5 BYTES PER CM WORD) BINARY MODE
  
10    BINMODE = CSBIN
      RETURN
  
*     SET 8/12 BINARY MODE
  
20    BINMODE = CSB812
      RETURN
  
      END 
*D 126
            IF (FCSET(FD).EQ.CSBIN .OR. FCSET(FD).EQ.CSB812) THEN
*D KERMLIB.322
          COMMENT CHECK FILES EXISTENCE 
*D 324
**        CFE - CHECK FILES EXISTENCE.
*I KERMLIB.995
      SUBROUTINE EOMDCMD
  
***   EOMDCMD - PERFORM A SET EOR-EOF-MODE XXXX COMMAND
  
      IMPLICIT INTEGER (A-Z)
      PARAMETER (COMLIS = 0)
*CALL COMCKER
      LOGICAL CONFIRM
      PARAMETER (TSIZE=2)
      CHARACTER*5 MODETYP(TSIZE)
      DATA MODETYP / 'OFF', 'ON' /
  
      INDX = MATCH(MODETYP,TSIZE,.FALSE.)
      IF (INDX .LE. 0) RETURN 
      IF (.NOT. CONFIRM(CMDFD)) RETURN
  
      GO TO (10, 20), INDX
  
*     DON'T RECOGNIZE OR PRODUCE EOR/EOF LINES
  
10    EOCONV = .FALSE.
      RETURN
  
*     RECOGNIZE/PRODUCE EOR/EOF LINES
  
20    EOCONV = .TRUE.
      RETURN
  
      END 
*D 1162
*           TEXT MODE AND NOT A CONNECTED FILE
            IF (FCHBUF(1,FD).EQ.EORLINE .AND. EOCONV) THEN
*D 1164
            ELSE IF (FCHBUF(1,FD).EQ.EOFLINE .AND. EOCONV) THEN
*I 1403
*                     = *CSB812* FOR 8/12 BINARY
*D 2059
         IF (FCSET(FD).EQ.CSBIN .OR. FCSET(FD).EQ.CSB812) THEN
*D 2074
         IF (FCSET(FD).EQ.CSBIN .OR. FCSET(FD).EQ.CSB812) THEN
*I 2096
                  IF (EOCONV) THEN
*I 2098
                  ENDIF
*I 2102
                  IF (EOCONV) THEN
*I 2104
                  ENDIF
*I 2107
               IF (EOCONV) THEN
*I 2109
               ELSE 
               NWDS = 0
               ENDIF
*D 2638
      ELSE IF ( FCSET(FD).NE.CSBIN .AND. FCSET(FD).NE.CSB812 ) THEN
*I 2672
                  IF (NETTYPE .EQ. CCP) THEN
*I 2673
                  ELSE
*                 SET IEM=1 FOR CDCNET
                  FCHBUF(FNWDS(FD),FD) = O"0010 4202 4001 4001 0000"
                  ENDIF
*I 2696
         IF (FCSET(FD).EQ.CSB812) THEN
            IF (CH.EQ.0) CH=O"4000"
         ENDIF
*D 3414
            FFD = FOPEN(FILENAM,CREATE,BINMODE)
*D 4156
            FFD = FOPEN(FILENAM,RD,BINMODE)
*D 4159
            SFILE = A
*I 4630
            IF (NETTYPE .EQ. CCP) THEN
*           EP=N
*I 4631
            ELSE
            FCHBUF(1,STDOUT) = O"0010 4332 4001 4000 0000"
            ENDIF
*I 4633
            IF (NETTYPE .EQ. CCP) THEN
*           EP=Y
*I 4634
            ELSE
            FCHBUF(1,STDOUT) = O"0010 4332 4001 4001 0000"
            ENDIF
*I 4642
         IF (NETTYPE .EQ. CCP) THEN
*        SET MULTIMESSAGE TRANSPARENT INPUT.
*        XL=X0D, C4094 (NO TIMEOUT, 2 CARRIAGE RETURNS IN A ROW
*        TERMINATE XPT INPUT), MULTIMESSAGE=YES, EP=N,
*        IN=XPT, TRANSMISSION BLOCK SIZE = 3770B. 
*I 4648
         ELSE
*        EP=NO
*        HOLD-PAGE=NO
*        XPT-TERMINATE-CHAR = 0D OR 8D
*        XPT-FORWARD-CHAR = 0D OR 8D
*        XPT-CHARACTER-MODE = FORWARD-TERMINATE
*        XPT-MESSAGE-LENGTH = 4094
*        XPT-LENGTH-MODE = FORWARD-EXACT
*        INPUT-BLOCK-SIZE = 2000
*        INPUT-EDITING-MODE = XPT
         FCHBUF(1,STDOUT) = O"0010 4332 4001 4000 4311"
         FCHBUF(2,STDOUT) = O"4001 4000 4205 4002 4015"
         FCHBUF(3,STDOUT) = O"4215 4204 4002 4015 4215"
         FCHBUF(4,STDOUT) = O"4203 4001 4003 4210 4002"
         FCHBUF(5,STDOUT) = O"4017 4376 4207 4001 4003"
         FCHBUF(6,STDOUT) = O"4214 4002 4007 4320 4202"
         FCHBUF(7,STDOUT) = O"4001 4001 0000 0000 0000"
         FNWDS(STDOUT) = 7
         ENDIF
*I 4655
            IF (NETTYPE .EQ. CCP) THEN
*           IN = NOT TRANSPARENT
*I 4656
            ELSE
*           IEM = NORMAL
            FCHBUF(1,STDOUT) = O"0010 4202 4001 4000 0000"
            ENDIF
*I 4658
            IF (NETTYPE .EQ. CCP) THEN
*           EP=Y, IN = NOT TRANSPARENT
*I 4660
            ELSE
*           EP=Y, IEM = NORMAL
            FCHBUF(1,STDOUT) = O"0010 4332 4001 4001 4202"
            FCHBUF(2,STDOUT) = O"4001 4000 0000 0000 0000"
            ENDIF
*D 4689
      DATA MODETYP / 'AUTO', 'DISPLAY', '6/12', '8/12' /
*I 4753
  
          USE    /OPSYS/
 TSTATUS  BSS    2
          USE    *
*D 4760
*I 4762
          TSTATUS  TSTATUS
*D  4765,4767
*/ END OF MOD