      SUBROUTINE MAIN
      INTEGER DESC, N, J, I, DDESC
      INTEGER GETARG, GETPAT, OPENDR, GDRPRM, MATCHC, MATCH
      LOGICAL*1 TEMP(40), PAT(128), FILE(40), DEVICE(40), ENTRY(40)
      LOGICAL*1 USESTR(29)
      LOGICAL*1 SYSDEV(5)
      LOGICAL*1 ZZ(6)
      LOGICAL*1 DOTDIR(5)
      DATA USESTR(1)/117/,USESTR(2)/115/,USESTR(3)/97/,USESTR(4)/103/,US
     *ESTR(5)/101/,USESTR(6)/58/,USESTR(7)/32/,USESTR(8)/32/,USESTR(9)/1
     *19/,USESTR(10)/104/,USESTR(11)/101/,USESTR(12)/114/,USESTR(13)/101
     */,USESTR(14)/105/,USESTR(15)/115/,USESTR(16)/32/,USESTR(17)/112/,U
     *SESTR(18)/97/,USESTR(19)/116/,USESTR(20)/32/,USESTR(21)/91/,USESTR
     *(22)/97/,USESTR(23)/110/,USESTR(24)/99/,USESTR(25)/104/,USESTR(26)
     */111/,USESTR(27)/114/,USESTR(28)/93/,USESTR(29)/0/
      DATA SYSDEV(1)/47/,SYSDEV(2)/115/,SYSDEV(3)/121/,SYSDEV(4)/48/,SYS
     *DEV(5)/0/
      DATA ZZ(1)/91/,ZZ(2)/48/,ZZ(3)/44/,ZZ(4)/48/,ZZ(5)/93/,ZZ(6)/0/
      DATA DOTDIR(1)/46/,DOTDIR(2)/100/,DOTDIR(3)/105/,DOTDIR(4)/114/,DO
     *TDIR(5)/0/
      CALL QUERY(USESTR)
      IF (.NOT.(GETARG(1, TEMP, 40) .EQ. -1))GOTO 23000
      CALL ERROR(USESTR)
23000 CONTINUE
      CALL FOLD(TEMP)
      IF (.NOT.(GETPAT(TEMP, PAT) .EQ. -3))GOTO 23002
      CALL ERROR(15Hillegal pattern)
23002 CONTINUE
      IF (.NOT.(GETARG(2, FILE, 40) .EQ. -1))GOTO 23004
      CALL STRCPY(SYSDEV, FILE)
23004 CONTINUE
      CALL FXLATE(FILE,6, DEVICE)
      CALL CONCAT(DEVICE, ZZ, FILE)
      IF (.NOT.(OPENDR(FILE, DESC) .NE. 0))GOTO 23006
      CALL CANT(FILE)
23006 CONTINUE
23008 IF (.NOT.(GDRPRM(DESC, TEMP) .NE. -1))GOTO 23009
      N = MATCHC(TEMP, DOTDIR)
      IF (.NOT.(N .GT. 0))GOTO 23010
      J = 1
      CALL STCOPY(DEVICE, 1, FILE, J)
      CALL CHCOPY(91, FILE, J)
      I=1
23012 IF (.NOT.(I .LE. 3))GOTO 23014
      CALL CHCOPY(TEMP(I), FILE, J)
23013 I=I+1
      GOTO 23012
23014 CONTINUE
      CALL CHCOPY(44, FILE, J)
      I=4
23015 IF (.NOT.(I .LE. 6))GOTO 23017
      CALL CHCOPY(TEMP(I), FILE, J)
23016 I=I+1
      GOTO 23015
23017 CONTINUE
      CALL CHCOPY(93, FILE, J)
      CALL MKPATH(FILE, TEMP)
      IF (.NOT.(OPENDR(TEMP, DDESC) .EQ. -3))GOTO 23018
      CALL PUTLIN(TEMP, 3)
      CALL REMARK(24H: cannot open directory.)
      GOTO 23019
23018 CONTINUE
23020 IF (.NOT.(GDRPRM(DDESC, ENTRY) .NE. -1))GOTO 23021
      IF (.NOT.(MATCH(ENTRY, PAT) .EQ. 1))GOTO 23022
      CALL PUTLIN(TEMP, 2)
      CALL PUTCH(47, 2)
      CALL PUTLIN(ENTRY, 2)
      CALL PUTCH(10, 2)
23022 CONTINUE
      GOTO 23020
23021 CONTINUE
      CALL CLOSDR(DDESC)
23019 CONTINUE
23010 CONTINUE
      GOTO 23008
23009 CONTINUE
      RETURN
      END
