      REM IMPORT-WEB
*PIC-LAN
*
*ALL
*PC
*Y
*
*
*
*
******************************************************************************
******************************************************************************
***                                                                        ***
*** (C) Copyright 1990-2005 Doug Dumitru, All Rights Reserved.             ***
***                                                                        ***
*** This program is licensed under the terms of the GNU General Public     ***
*** License, version 2.0 with attached notices.                            ***
***                                                                        ***
*** The full text can be found in the LICENSE.TXT file in the              ***
*** PLIP.BP database file (the /usr/qmweb/PLIP.BP/PLIP.BP directory).      ***
***                                                                        ***
******************************************************************************
******************************************************************************
*
      INCLUDE SYS.TYPE.INCLUDE
*
      INCLUDE PL.COMMON
      INCLUDE PL.COMMON.DEFS
      INCLUDE PL.DEFS
      INCLUDE PLIP.COMMON
      INCLUDE PLW.COMMON
      INCLUDE PL.INIT.INCLUDE
*
      CALL PLIP.INIT.SUB
*
      OPEN 'WWW.CTRL' TO CTRL.FD ELSE CALL PLXX.STOP(201,'WWW.CTRL')
*
      S.OPT = ( INDEX(SENT<2>,'S',1) # 0 )
*
      LOC.FILE = SENT<1,2>
      HST.ROOT = SENT<1,3>
*
      PRINT 'LOC.FILE = ' : LOC.FILE
      PRINT 'HST.ROOT = ' : HST.ROOT
      PRINT 'S.OPT = ' : S.OPT
*
      OPEN LOC.FILE TO DATA.FD ELSE CALL PLXX.STOP(201,LOC.FILE)
*
      IF S.OPT THEN
         DIR.OPT = 'ND'
      END ELSE
         DIR.OPT = 'N'
      END
*
      FNAMES = ''
      DNAMES = '/'
      LOOP
         IF DNAMES<1> = '/' THEN
            PATH = HST.ROOT
         END ELSE
            PATH = HST.ROOT : '/' : DNAMES<1>
         END
         D = DIR(PATH)
         FOR I = 1 TO DCOUNT(D,AM)
            BEGIN CASE
               CASE D<I,2> = 'D' AND S.OPT
                  IF DNAMES<1> = '/' THEN
                     DNAMES<-1> = D<I,1>
                  END ELSE
                     DNAMES<-1> = DNAMES<1> : '/' : D<I,1>
                  END
               CASE D<I,2> = 'F'
                  IF DNAMES<1> = '/' THEN
                     FNAMES<-1> = D<I,1>
                  END ELSE
                     FNAMES<-1> = DNAMES<1> : '/' : D<I,1>
                  END
            END CASE
         NEXT I
         DNAMES = DELETE(DNAMES,1,0,0)
      WHILE DNAMES <> '' DO REPEAT
      
      FOR I = 1 TO DCOUNT(FNAMES,AM)
         FILENAME = FNAMES<I>
         PRINT I 'R#3' : ' ' : FILENAME 'L#40' : ' ' :
         IF INDEX(FILENAME,'.',1) THEN
            FILE.TP = FIELD(FIELD(FILENAME,'/',DCOUNT(FILENAME,'/')),'.',DCOUNT(FILENAME,'.'))
         END ELSE
            FILE.TP = ''
         END
#IF UNIX
         FILE.TP = OCONV(FILE.TP,'MCU')
#END
         READ MIME.TP FROM CTRL.FD , 'MIME*' : FILE.TP THEN
            BEGIN CASE
               CASE MIME.TP<2> = 'HEX'
                  OPT = 'X'
                  OPT2 = ''
               CASE MIME.TP<2> = 'AM'
                  OPT = 'a'
                  OPT2 = 'A'
               CASE YES
                  OPT = AM
                  PRINT '   invalid MIME type encoding.' :
            END CASE
         END ELSE
            OPT = AM
            PRINT '   extension not supported.' :
         END
*
         IF OPT <> AM THEN
display HST.ROOT : '/' : FILENAME : ' ' : OPT2
            CALL PLHOST.IMPORT(HST.ROOT:'/':FILENAME,OPT2,D)
#IF UNIX
            FILENAME = OCONV(FILENAME,'MCU')
#END
            WRITE D ON DATA.FD , FILENAME
         END
*
         PRINT
      NEXT I
   END
