      SUBROUTINE MAIN
      LOGICAL*1 BUF(512)
      INTEGER GETARG, OPEN
      INTEGER I, INT, VERBOS, NF
      CALL QUERY(27Husage:  cat [-v] [file] ...)
      VERBOS = 0
      NF = 0
      I=1
23000 IF (.NOT.(GETARG(I, BUF, 512) .NE. -1))GOTO 23002
      IF (.NOT.(BUF(1) .EQ. 45))GOTO 23003
      IF (.NOT.(BUF(2) .EQ. 0))GOTO 23005
      INT = 1
      GOTO 23006
23005 CONTINUE
      IF (.NOT.(BUF(2) .EQ. 118 .OR. BUF(2) .EQ. 86))GOTO 23007
      VERBOS = 1
      GOTO 23008
23007 CONTINUE
      CALL BADARG(BUF)
23008 CONTINUE
      GOTO 23001
23006 CONTINUE
      GOTO 23004
23003 CONTINUE
      INT = OPEN(BUF, 1)
23004 CONTINUE
      IF (.NOT.(INT .EQ. -3))GOTO 23009
      CALL CANT(BUF)
23009 CONTINUE
      NF = NF + 1
      CALL CATEN8(INT, 2, VERBOS)
      IF (.NOT.(INT .NE. 1))GOTO 23011
      CALL CLOSE(INT)
23011 CONTINUE
23001 I=I+1
      GOTO 23000
23002 CONTINUE
      IF (.NOT.(NF .EQ. 0))GOTO 23013
      CALL CATEN8(1, 2, VERBOS)
23013 CONTINUE
      RETURN
      END
      SUBROUTINE CATEN8(IN, OUT, VERBOS)
      INTEGER IN, OUT
      INTEGER VERBOS
      LOGICAL*1 C
      LOGICAL*1 GETCH
23015 IF (.NOT.(GETCH(C, IN) .NE. -1))GOTO 23016
      IF (.NOT.(VERBOS .EQ. 1))GOTO 23017
      IF (.NOT.(C .NE. 10 .AND. (C .LT. 32 .OR. C .EQ. 127)))GOTO 23019
      CALL PUTCH(94, OUT)
      IF (.NOT.(C .EQ. 127))GOTO 23021
      C = 63
      GOTO 23022
23021 CONTINUE
      C = C + 64
23022 CONTINUE
      GOTO 23020
23019 CONTINUE
      IF (.NOT.(C .EQ. 10))GOTO 23023
      CALL PUTCH(36, OUT)
23023 CONTINUE
23020 CONTINUE
23017 CONTINUE
      CALL PUTCH(C, OUT)
      GOTO 23015
23016 CONTINUE
      RETURN
      END
