/*
   Title: CD-ROM Manager 2.2
    Type: BBS CLI/StdIO Door
      By: Vis Naidu
     NET: NAIDUVV@MEENA.CC.UREGINA.CA
    Date: June 5.96
    MODE: InterNET
*/

OPTIONS RESULTS

arg scrlen datap timeleft
len=scrlen-2
datapath=strip(datap)
starttime=time('M')

serdev='BaudBandit.device'

a=0
say ' '
say ''
say 'Loading [ PATH NAMES ]...'
call open('vis',datapath,'R')
do while ~eof('vis')
   a=a+1
   data=readln('vis')
   newdat=substr(strip(data),2)
   volume='inet_0295:'
   filepath.a=volume''newdat'/'
end
call close('vis')
libnum=a-1
a=1

Menu:
   newtime=time('M')
   timediff=newtime-starttime
   if timediff >= timeleft then do
      say ' '
      say '[1;31mOut of Time, Aborting[0m...'
      call Done
   end
   if timediff <= timeleft then do
      newleft=timeleft-timediff
   end
   say ' '
   say ''
   say ' '
   say '[1;37m-:[0m[ [1mCDM v2.2 [0m][1m:-                                         [0mCD[1m: [0m[ [1mInterNET Info [0m]'
   say ' '
   say '[0;32mFile Path[37m: [1m'filepath.a
   say '[0;32mTime Left[37m: [1m'newleft' [0mMins'
   say '[0;36mÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄ ÄÄÄ ÄÄ Ä'
   say '[37m[ L ] List Files in this Area          [ V ] View Contents of an Archive'
   say '[ T ] Type/Display a File              [ C ] Change to a Different Path'
   say '[ D ] Download File                    [ Q ] Quit to BBS'
   say '[36mÄ ÄÄ ÄÄÄ ÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ'
   say ' '
   options prompt '[32m< [0mRETURN=Quit[32m, [0mEnter CHOICE [32m>[0m: '
   pull choice
   choice=upper(choice)
   if choice = ''  then call Done
   if choice = 'L' then call LstFiles
   if choice = 'T' then call ViewFl
   if choice = 'V' then call ViewArc
   if choice = 'D' then call DlFile
   if choice = 'C' then call ChgArea
   if choice = 'A' then call About
   if choice = 'Q' then call Done
   call Menu
end

LstFiles:
   say ' '
   say '[0m[1mOne Moment[0m...'
   if ~exists(filepath.a) then do
      say ' '
      say '[1mDirectory is Empty, or Does Not Exist[0m...'
      say ' '
      options prompt '[0mPress [1m[[0mRETURN[1m] [0mto Continue[1m:[0m '
      pull cont
      call Menu
   end
   address command 'ls >ram:flist -l -f -H -F "[%7s] (%12d)  %n\n" 'filepath.a
   datafile='ram:flist'
   say ' '
   say ''
   call open('reader',datafile,'R')
   yes=1
   b=2
   numlist=0
   do while yes=1
      if b >= len then do
         b=0
         say ' '
         options prompt '[RETURN] to Continue, [Q] to Quit, [D] to Download , [T] to Type File: '
         pull dude
         dude=upper(dude)
         if dude = 'Q' then do
            call close('reader')
            call Menu
         end
         if dude = 'D' then do
            call close('reader')
            call DLFile
            call Menu
         end
         if dude = 'T' then do
            call close('reader')
            call ViewFl
            call Menu
         end
         say ' '
      end
      if eof('reader') then yes=0
      if ~eof('reader') then do
         dat=readln('reader')
         say dat
      end
      b=b+1
   end
   call close('reader')
   options prompt '[RETURN] to Continue, [D] to Download, [T] to Type File: '
   pull dudley
   dudley=upper(dudley)
   if dudley='D' then call DlFile
   if dudley='T' then call ViewFl
   yes=1
Return

ViewFl:
   say ' '
   options prompt '[0mEnter filename to [1mType/Display[0m: '
   pull flinfo
   flinfo=upper(flinfo)
   if flinfo='RESULT' then call Menu
   if flinfo='' then call Menu
   say ' '
   say '[0m[1mPlease Wait[0m...'
   if ~exists(filepath.a||flinfo) then do
       say ' '
       say '[0m[32mFile does not exist[0m...'
       say ' '
       options prompt '[0mPress [1m[[0mRETURN[1m][0m to Continue[1m:[0m '
       pull cont
   end
   if exists(filepath.a||flinfo) then do
      address command 'tc 'filepath.a||flinfo' ram:newlist o >ram:cmd.tc'
      say ' '
      say ''
      say '[0mReading File[1m:[0m 'flinfo'... [1mPlease Wait[0m...'
      say '[0m[36mÄ ÄÄ ÄÄÄ ÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄ ÄÄÄ ÄÄ Ä[0m'
      address command 'rx rexx:CDType.Rexx 'len' ram:newlist'
      say '[0m[36mÄ ÄÄ ÄÄÄ ÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄ ÄÄÄ ÄÄ Ä[0m'
      options prompt '[0mPress [1m[[0mRETURN[1m][0m to Continue[1m:[0m '
      pull cont
      call Menu
   end
Return

ViewArc:
   say ' '
   say '[0m[1mArchive formats supported [0m->'
   say ' '
   say '[0m[32m.LZH .LHA .ZIP .ZOO .ARC .SIT .ARJ .DMS .TAR .GZ .Z[0m'
   say ' '
   options prompt '[0mEnter filename to [1mView[0m [Max. 25 Chars][1m:[0m '
   pull flname
   flname=upper(flname)
   if flname='' then call Menu
   if flname='RESULT' then call Menu
   say ' '
   say 'Please Wait...'
   if ~exists(filepath.a||flname) then do
      say ' '
      say '[0m[32mFile does not exist[0m...'
      say ' '
      options prompt '[0mPress [1m[[0mRETURN[1m][0m to Continue[1m:[0m '
      pull cont
   end
   if exists(filepath.a||flname) then do
      arc.1 = '.LHA';arccmd.1 = 'LHA v'
      arc.2 = '.LZH';arccmd.2 = 'LHA v'
      arc.3 = '.ZIP';arccmd.3 = 'UNZIP -v'
      arc.4 = '.ZOO';arccmd.4 = 'ZOO v'
      arc.5 = '.ARC';arccmd.5 = 'ARC v'
      arc.6 = '.ARJ';arccmd.6 = 'UNARJ v'
      arc.7 = '.SIT';arccmd.7 = 'UNSIT v'
      arc.8 = '.DMS';arccmd.8 = 'DMS View'
      arc.9 = '.TAR';arccmd.9 = 'TAR -v'
      arc.10 = '.GZ';arccmd.10 = 'GZIP -l'
      arc.11 = '.Z';arccmd.11 = 'GZIP -l'
      c=0
      do while c<12
         c=c+1
         if index(flname,arc.c) > 0 then do
            say ' '
            say '[0m[1mOne Moment, Reading File Contents[0m...'
            address command arccmd.c' 'filepath.a||flname' >ram:vlist'
            say ' '
            say '[0mContents of File[1m:[0m 'flname
            say '[0m[36mÄ ÄÄ ÄÄÄ ÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄ ÄÄÄ ÄÄ Ä[0m'
            say ' '
            address command 'rx rexx:CDType.Rexx 'len' ram:vlist'
            say '[0m[36mÄ ÄÄ ÄÄÄ ÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄ ÄÄÄ ÄÄ Ä[0m'
            say ' '
            options prompt '[0mPress [1m[[0mRETURN[1m][0m to Continue[1m:[0m '
            pull cont
            call Menu
         end
      end
      say ' '
      say '[0m[32mFile chosen is NOT an Archive[0m...'
      say ' '
      options prompt '[0mPress [1m[[0mRETURN[1m][0m to Continue[1m:[0m '
      pull cont
      say ' '
   end
Return

DLFile:
   say ' '
   options prompt '[0mEnter filename to [1mDownload[0m [Max. 25 Chars][1m:[0m '
   pull filedl
   filedl=upper(filedl)
   if filedl='' then call Menu
   say ' '
   say '[0m[1mPlease Wait[0m...'
   if ~exists(filepath.a||filedl) then do
      say ' '
      say '[0m[32mFile does not exist[0m...'
      say ' '
      options prompt '[0mPress [1m[[0mRETURN[1m][0m to Continue[1m:[0m '
      pull cont
   end
   if exists(filepath.a||filedl) then do
      say ' '
      say ''
      say ' '
      say '[0m[32m Transfer Protocols[0m:'
      say 'ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿'
      say '³ 1 - XModem         ³'
      say '³ 2 - XModem CRC     ³'
      say '³ 3 - XModem 1K      ³'
      say '³ 4 - YModem [Batch] ³'
      say '³ 5 - YModem-G       ³'
      say '³ 6 - ZModem         ³'
      say 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ'
      say ' '
      options prompt '[0m[32m< [0mRETURN=Abort[32m, [0mEnter CHOICE [32m>[0m: '
      pull prot
      if prot = '' then call Menu
      say ' '
      if prot = '1' then do
         say 'Sending Filename: 'filedl', using X-Modem CheckSum...'
         say ' '
         address command 'doors:xprd/xprd -lxprxmodem.library -oT0,C0,K0 -d'serdev' -u0 -s -q send 'filepath.a''filedl' >ram:dlist'
         address command 'run <nil: >nil: delete ram:dlist'
         say ' '
      end
      if prot = '2' then do
         say 'Sending Filename: 'filedl', using X-Modem CRC...'
         say ' '
         address command 'doors:xprd/xprd -lxprxmodem.library -oT0,C1,K0 -d'serdev' -u0 -s -q send 'filepath.a''filedl' >ram:dlist'
         address command 'run <nil: >nil: delete ram:dlist'
         say ' '
      end
      if prot = '3' then do
         say 'Sending Filename: 'filedl', using X-Modem 1K...'
         say ' '
         address command 'doors:xprd/xprd -lxprxmodem.library -oT0,C1,K1 -d'serdev' -u0 -s -q send 'filepath.a''filedl' >ram:dlist'
         address command 'run <nil: >nil: delete ram:dlist'
         say ' '
      end
      if prot = '4' then do
         say 'Sending Filename: 'filedl', using Y-Modem [Batch]...'
         say ' '
         address command 'cd 'filepath.a
         address command 'doors:xprd/xprd -lxprymodem.library -oZ0,B1,C1 -d'serdev' -u0 -s -q send 'filedl' >ram:dlist'
         address command 'run <nil: >nil: delete ram:dlist'
         say ' '
      end
      if prot = '5' then do
         say 'Sending Filename: 'filedl', using Y-Modem G...'
         say ' '
         address command 'cd 'filepath.a
         address command 'doors:xprd/xprd -lxprgmodem.library -oB1,C1,YG,Z -d'serdev' -u0 -s -q send 'filedl' >ram:dlist'
         address command 'run <nil: >nil: delete ram:dlist'
         say ' '
      end
      if prot = '6' then do
         say 'Sending Filename: 'filedl', using Z-Modem...'
         say ' '
         address command 'doors:xprd/xprd -lxprzmodem.library -d'serdev' -u0 -s -q send 'filepath.a''filedl' >ram:dlist'
         address command 'run <nil: >nil: delete ram:dlist'
         say ' '
      end
   end
Return

ChgArea:
   say ' '
   say ''
   address command 'rx rexx:CDType2.Rexx 'len' 'datapath
   say ' '
   options prompt '[0mSelect [1mPath # [0m[1-'LibNum'][1m:[0m '
   pull newlib
   if newlib='RESULT' then do
      newlib=1
   end
   if newlib < 1 | newlib > libnum then call Menu
   if newlib >=1 & newlib <= libnum then do
      a=newlib
   end
Return

About:
   say ' '
   say ''
   say 'About This Program...'
   say 'Ä ÄÄ ÄÄÄ ÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄ ÄÄÄ ÄÄ Ä'
   say 'Author : Vis Naidu'
   say '         Running M A X''s BBS 1.54 [PD]'
   say 'BBS    : The TeKKnoZone'
   say 'Tel. # : (306) 586-2111'
   say 'Baud   : 300-14400 bps'
   say 'Ä ÄÄ ÄÄÄ ÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄ ÄÄÄ ÄÄ Ä'
   say 'Door   : CDM [CD-ROM Manager] 2.2'
   say '         CD-ROM Utility to Access CDs Online'
   say '         Release : June 5, 1996'
   say 'Ä ÄÄ ÄÄÄ ÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄ ÄÄÄ ÄÄ Ä'
   say ' '
   options prompt '[0mPress [1m[[0mRETURN[1m][0m to Continue[1m:[0m '
   pull cont
Return

Done:
exit 0

/* End of CD-ROM Manager 2.2 */

