      SUBROUTINE MAIN
      LOGICAL*1 NAME(40)
      INTEGER GETARG, OPEN, CTOI
      INTEGER FD, I, J
      COMMON /CPRINT/ MAR1, MAR2, BMAR, DOHEAD, DOTAIL, PLEN
      INTEGER MAR1
      INTEGER MAR2
      INTEGER BMAR
      INTEGER DOHEAD
      INTEGER DOTAIL
      INTEGER PLEN
      LOGICAL*1 NULL(1)
      DATA NULL(1)/0/
      MAR1 = 3
      MAR2 = 2
      BMAR = 3
      DOHEAD = 1
      PLEN = 66
      FD = -3
      I = 1
23000 IF(.NOT.(GETARG(I, NAME, 40) .NE. -1))GOTO 23002
      IF(.NOT.(NAME(1) .EQ. 63 .AND. NAME(2) .EQ. 0))GOTO 23003
      CALL ERROR (24Husage:  pr [-ln] [file].)
23003 CONTINUE
      IF(.NOT.(NAME(1) .EQ. 45 .AND. NAME(2) .NE. 0))GOTO 23005
      IF(.NOT.(NAME(2) .EQ. 108 .OR. NAME(2) .EQ. 76))GOTO 23007
      J = 3
      PLEN = CTOI(NAME, J)
      IF(.NOT.((PLEN-MAR1-MAR2-BMAR-2) .LE. 0))GOTO 23009
      CALL ERROR (15Hpage too small.)
23009 CONTINUE
      GOTO 23008
23007 CONTINUE
      CALL REMARK (26Hignoring invalid argument.)
23008 CONTINUE
      GOTO 23006
23005 CONTINUE
      IF(.NOT.(NAME(1) .EQ. 45 .AND. NAME(2) .EQ. 0))GOTO 23011
      FD = 1
      CALL FPRINT (NULL, 1)
      GOTO 23012
23011 CONTINUE
      FD = OPEN(NAME, 1)
      IF(.NOT.(FD .EQ. -3))GOTO 23013
      CALL CANT(NAME)
23013 CONTINUE
      CALL FPRINT(NAME, FD)
      CALL CLOSE(FD)
23012 CONTINUE
23006 CONTINUE
23001 I = I + 1
      GOTO 23000
23002 CONTINUE
      IF(.NOT.(FD .EQ.-3))GOTO 23015
      CALL FPRINT(NULL, 1)
23015 CONTINUE
      RETURN
      END
      SUBROUTINE FPRINT(NAME, FD)
      INTEGER LINE(400), NAME(100)
      INTEGER GETLIN
      INTEGER FD, LINENO, PAGENO
      COMMON /CPRINT/ MAR1, MAR2, BMAR, DOHEAD, DOTAIL, PLEN
      INTEGER MAR1
      INTEGER MAR2
      INTEGER BMAR
      INTEGER DOHEAD
      INTEGER DOTAIL
      INTEGER PLEN
      PAGENO = 0
      LINENO = 0
23017 IF(.NOT.(GETLIN(LINE, FD) .NE. -1))GOTO 23018
      IF(.NOT.(LINENO .EQ. 0))GOTO 23019
      PAGENO = PAGENO + 1
      IF(.NOT.(DOHEAD .EQ. 1))GOTO 23021
      CALL SKIP(MAR1)
      CALL HEAD(NAME, PAGENO)
      CALL SKIP(MAR2)
      LINENO = MAR1 + MAR2 + 1
23021 CONTINUE
23019 CONTINUE
      CALL PUTLIN(LINE, 2)
      LINENO = LINENO + 1
      IF(.NOT.(LINENO + BMAR .GE. PLEN))GOTO 23023
      CALL SKIP(BMAR)
      LINENO = 0
23023 CONTINUE
      GOTO 23017
23018 CONTINUE
      IF(.NOT.(LINENO .GT. 0))GOTO 23025
      CALL SKIP(PLEN-LINENO)
      CALL SKIP(BMAR)
23025 CONTINUE
      RETURN
      END
      SUBROUTINE SKIP(N)
      INTEGER I, N
      I = 1
23027 IF(.NOT.(I .LE. N))GOTO 23029
      CALL PUTC(10)
23028 I = I + 1
      GOTO 23027
23029 CONTINUE
      RETURN
      END
      SUBROUTINE HEAD(NAME, PAGENO)
      INTEGER NAME(100)
      INTEGER PAGENO
      LOGICAL*1 PAGE(8)
      DATA PAGE(1)/32/,PAGE(2)/80/,PAGE(3)/97/,PAGE(4)/103/,PAGE(5)/101/
     *,PAGE(6)/32/,PAGE(7)/32/,PAGE(8)/0/
      CALL PUTLIN(NAME, 2)
      CALL PUTLIN(PAGE, 2)
      CALL PUTDEC(PAGENO, 1)
      CALL PUTC(10)
      RETURN
      END
