      SUBROUTINE MAIN
      LOGICAL*1 C, LIN(512)
      LOGICAL*1 IFILE(40), OFILE(512)
      LOGICAL*1 CLOWER
      INTEGER IFD, OFD
      INTEGER CREATE, OPEN
      INTEGER ARG, JUNK, VERBOS
      INTEGER GETARG, GETLIN, ISEND, ISSUBR
      VERBOS = 0
      CALL QUERY( 28Husage:  sepfor [-v] file ...)
      ARG = 1 
23000 IF (.NOT.(GETARG( ARG, IFILE, 40) .NE. -1 ))GOTO 23002
      IF (.NOT.( IFILE(1) .EQ. 45 ))GOTO 23003
      C = CLOWER(IFILE(2))
      IF (.NOT.( C .EQ. 118 ))GOTO 23005
      VERBOS = 1
23005 CONTINUE
      CALL DELARG(ARG)
      ARG = ARG - 1
      GOTO 23001
23003 CONTINUE
      CALL DOMAIN( IFILE, ARG)
      IFD = OPEN( IFILE, 1)
      IF (.NOT.( IFD .EQ. -3 ))GOTO 23007
      CALL CANT(IFILE)
23007 CONTINUE
23009 IF (.NOT.( GETLIN( LIN, IFD) .NE. -1 ))GOTO 23010
      IF (.NOT.( ISSUBR( LIN, OFILE) .EQ. 1 ))GOTO 23011
      OFD = CREATE( OFILE, 2)
      IF (.NOT.( OFD .EQ. -3 ))GOTO 23013
      CALL CANT(OFILE)
23013 CONTINUE
      IF (.NOT.( VERBOS .EQ. 1 ))GOTO 23015
      CALL PUTLIN( OFILE, 2)
      CALL PUTCH( 10, 2)
23015 CONTINUE
      CALL PUTLIN( LIN, OFD)
23017 CONTINUE
      JUNK = GETLIN( LIN, IFD)
      CALL PUTLIN( LIN, OFD)
23018 IF (.NOT.( ISEND(LIN) .EQ. 1 ))GOTO 23017
23019 CONTINUE
23011 CONTINUE
      CALL CLOSE(OFD)
      GOTO 23009
23010 CONTINUE
23001 ARG = ARG + 1 
      GOTO 23000
23002 CONTINUE
      RETURN
      END
      SUBROUTINE DOMAIN( IFILE, N)
      LOGICAL*1 LIN(512), NUM(20)
      LOGICAL*1 IFILE(100), NAM(512), OFILE(40)
      INTEGER IFD, OFD
      INTEGER CREATE, OPEN
      INTEGER JUNK, N
      INTEGER GETLIN, ISSUBR, ITOC
      LOGICAL*1 MAIN(5)
      DATA MAIN(1)/109/,MAIN(2)/97/,MAIN(3)/105/,MAIN(4)/110/,MAIN(5)/0/
      JUNK = ITOC( N, NUM, 20)
      CALL CONCAT( MAIN, NUM, OFILE)
      OFD = CREATE( OFILE, 2)
      IF (.NOT.( OFD .EQ. -3 ))GOTO 23020
      CALL CANT(OFILE)
23020 CONTINUE
      IFD = OPEN( IFILE, 1)
      IF (.NOT.( IFD .EQ. -3 ))GOTO 23022
      CALL CANT(IFILE)
23022 CONTINUE
23024 IF (.NOT.( GETLIN( LIN, IFD) .NE. -1 ))GOTO 23025
      IF (.NOT.( ISSUBR( LIN, NAM) .EQ. 1 ))GOTO 23026
      GOTO 23025
23026 CONTINUE
      CALL PUTLIN( LIN, OFD)
      GOTO 23024
23025 CONTINUE
      CALL CLOSE(IFD)
      CALL CLOSE(OFD)
      RETURN
      END
      INTEGER FUNCTION ISEND(LIN)
      LOGICAL*1 BUF(512), LIN(100), WRD(512)
      INTEGER I, LEN
      INTEGER EQUAL, GETWRD
      LOGICAL*1 DOSTR(3)
      LOGICAL*1 ENDSTR(4)
      LOGICAL*1 IFSTR(3)
      DATA DOSTR(1)/100/,DOSTR(2)/111/,DOSTR(3)/0/
      DATA ENDSTR(1)/101/,ENDSTR(2)/110/,ENDSTR(3)/100/,ENDSTR(4)/0/
      DATA IFSTR(1)/105/,IFSTR(2)/102/,IFSTR(3)/0/
      ISEND = 0
      CALL STRCPY( LIN, BUF)
      CALL FOLD(BUF)
      I = 1
      LEN = GETWRD( BUF, I, WRD)
      IF (.NOT.( LEN .GT. 0 ))GOTO 23028
      IF (.NOT.( EQUAL( ENDSTR, WRD) .EQ. 1 ))GOTO 23030
      ISEND = 1
23030 CONTINUE
      IF (.NOT.( GETWRD( BUF, I, WRD) .GT. 0 ))GOTO 23032
      IF (.NOT.( EQUAL( IFSTR, WRD) .EQ. 1 .OR. EQUAL( DOSTR, WRD) .EQ. 
     *1 ))GOTO 23034
      ISEND = 0
23034 CONTINUE
23032 CONTINUE
23028 CONTINUE
      RETURN
      END
      INTEGER FUNCTION ISSUBR( LIN, NAM)
      LOGICAL*1 BUF(512), LIN(100), NAM(100)
      INTEGER I, J, LEN
      INTEGER EQUAL, GETWRD, INDEXC
      LOGICAL*1 FUNC(9)
      LOGICAL*1 SUBR(11)
      DATA FUNC(1)/102/,FUNC(2)/117/,FUNC(3)/110/,FUNC(4)/99/,FUNC(5)/11
     *6/,FUNC(6)/105/,FUNC(7)/111/,FUNC(8)/110/,FUNC(9)/0/
      DATA SUBR(1)/115/,SUBR(2)/117/,SUBR(3)/98/,SUBR(4)/114/,SUBR(5)/11
     *1/,SUBR(6)/117/,SUBR(7)/116/,SUBR(8)/105/,SUBR(9)/110/,SUBR(10)/10
     *1/,SUBR(11)/0/
      NAM(1) = 0
      CALL STRCPY( LIN, BUF)
      CALL FOLD(BUF)
      ISSUBR = 0
      I = 1
      IF (.NOT.( GETWRD( BUF, I, NAM) .GT. 0 ))GOTO 23036
      IF (.NOT.( EQUAL( NAM, SUBR) .EQ. 1 ))GOTO 23038
      LEN = GETWRD( BUF, I, NAM)
      ISSUBR = 1
      GOTO 23039
23038 CONTINUE
      IF (.NOT.( GETWRD( BUF, I, NAM) .GT. 0 ))GOTO 23040
      IF (.NOT.( EQUAL( NAM, FUNC) .EQ. 1 ))GOTO 23042
      LEN = GETWRD( BUF, I, NAM)
      ISSUBR = 1
      GOTO 23043
23042 CONTINUE
      IF (.NOT.( GETWRD( BUF, I, NAM) .GT. 0 ))GOTO 23044
      IF (.NOT.( EQUAL( NAM, FUNC) .EQ. 1 ))GOTO 23046
      LEN = GETWRD( BUF, I, NAM)
      ISSUBR = 1
23046 CONTINUE
23044 CONTINUE
23043 CONTINUE
23040 CONTINUE
23039 CONTINUE
23036 CONTINUE
      IF (.NOT.( ISSUBR .EQ. 1 ))GOTO 23048
      CALL STRCPY( NAM, BUF)
      I = INDEXC( BUF, 40)
      IF (.NOT.( I .GT. 0 ))GOTO 23050
      BUF(I) = 0
23050 CONTINUE
      J = 1
      I = 1 
23052 IF (.NOT.(BUF(I) .NE. 0 ))GOTO 23054
      IF (.NOT.( BUF(I) .NE. 36 .AND. BUF(I) .NE. 95 ))GOTO 23055
      NAM(J) = BUF(I)
      J = J + 1
23055 CONTINUE
23053 I = I + 1 
      GOTO 23052
23054 CONTINUE
      NAM(J) = 0
      NAM(10) = 0
23048 CONTINUE
      RETURN
      END
