home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / ck190b.zip / INSTALL.CMD < prev    next >
OS/2 REXX Batch file  |  1994-08-26  |  49KB  |  1,536 lines

  1. /*
  2.   File INSTALL.CMD (CKOINS.CMD)
  3.  
  4.   Wed Aug 24 12:08:58 1994
  5.  
  6.   A Rexx Program to install OS/2 C-Kermit 5A(190).
  7.   Written by Jeffrey Altman, Altmania Productions,
  8.   and Frank da Cruz, Columbia University, June 1993 - present.
  9.   All rights assigned to Columbia University.
  10.  
  11.   Copyright (C) 1985, 1994, Trustees of Columbia University in the City of New
  12.   York.  The C-Kermit software may not be, in whole or in part, licensed or
  13.   sold for profit as a software product itself, nor may it be included in or
  14.   distributed with commercial products or otherwise distributed by commercial
  15.   concerns to their clients or customers without written permission of the
  16.   Office of Kermit Development and Distribution, Columbia University.  This
  17.   copyright notice must not be removed, altered, or obscured.
  18. */
  19.  
  20. /*
  21.   All the files to be installed must be in the same directory as INSTALL.CMD.
  22.   This script:
  23.  
  24.   . Installs either the 16-bit or 32-bit version of C-Kermit
  25.     depending on the version of OS/2 being used, and which one(s)
  26.     is/are on the install disk.
  27.  
  28.   . Creates a directory for C-Kermit if necessary.
  29.  
  30.   . Creates a C-Kermit program object on the OS/2 2.x Desktop.
  31.  
  32.   . Customizes the CKERMOD.INI file according to the user's preferences.
  33.  
  34.   . Installs the network DLL, CKOTCP{16,32}.DLL.
  35.  
  36.   . Updates the CONFIG.SYS file only at the user's request.
  37.  
  38.   - New for version 190:
  39.  
  40.   . TCP/IP-only installation - no questions about serial ports & modems.
  41.  
  42.   . Does not overwrite existing CKERMOD.INI, KDD or KSD files.
  43.  
  44.   . CKERMIT.CMD matches CKERMOD.INI settings.
  45.  
  46.   . Sets up full VT220 key mappings in CKERMOD.INI if user says to.
  47.  
  48.   . Uses Rexx procedures and subroutines.
  49.  
  50.   . Optional command-line parameter to specify the destination directory
  51. */
  52.  
  53. Revision = 190
  54. RexxUtils = LoadRexxUtils()
  55. os2ver = WhichOS2Version( RexxUtils )
  56. bootdrive = GetBootDrive( RexxUtils )
  57. startdir = ChangeToSourceDirectory()
  58. spacerequired = HowMuchSpaceRequired( RexxUtils ) 
  59. CALL ClearScreen
  60. CALL Welcome
  61. CKOVer = WhichKermitVersion() 
  62. CALL GetDir( ARG(1) )
  63. CALL CheckSpace
  64. CALL CreateDir
  65. tcpip = IsIBMTCPIPInstalled( RexxUtils )
  66.  
  67. newInstall = \ FileExists( destination || 'ckermod.ini' )
  68. IF newInstall THEN DO
  69. serial = InstallSerialSupport( tcpip )
  70. IF serial
  71.   THEN DO
  72.     CALL GetModem
  73.     CALL GetPort
  74.     CALL GetSpeed
  75.   END
  76.   ELSE DO
  77.     modem = ""
  78.     port = ""
  79.     speed = ""
  80.   END
  81. CALL GetRunMode
  82. vt220 = InstallVT220KeyMap()
  83. END
  84. ELSE DO
  85.   serial = 0
  86.   modem = ""
  87.   port = ""
  88.   speed = ""
  89.   vt220 = 0
  90. END
  91.  
  92. CALL InstallFiles
  93. CALL SetIcon
  94. CALL BuildFolderObject
  95. CALL BuildProgramObject
  96. CALL BuildUpdatesObject
  97. CALL UpdateConfigSys
  98. CALL Done
  99. EXIT
  100.  
  101. /*******************************************************************/
  102.  
  103. INSTALLFILES : PROCEDURE EXPOSE RexxUtils OS2Ver CKOVer destination updest,
  104.                                 destnopath runmode serial tcpip vt220,
  105.                                 modem port speed revision ;
  106. CALL InstallCKermitExe
  107. CALL InstallCKOTcpIpDll
  108. CALL InstallSyslevelFiles
  109. CALL InstallCKermitIco
  110. CALL InstallDocs
  111. CALL InstallCkermitIni
  112. CALL InstallCkermodIni
  113. CALL InstallRexxCmdFiles
  114. CALL InstallDialingSupportFiles
  115. CALL InstallExternalProtocols
  116. CALL InstallCkermitCmd
  117. CALL InstallKeyboardDefs
  118. CALL InstallCharSets
  119. RETURN /* InstallFiles */
  120.  
  121. /*******************************************************************/
  122.  
  123. LOADREXXUTILS: PROCEDURE ;
  124. /* Load RexxUtil if available */
  125.  
  126. SIGNAL ON SYNTAX NAME NoRexxUtil
  127. IF RxFuncQuery('SysLoadFuncs') 
  128.   THEN CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' 
  129. CALL SysLoadFuncs
  130.  
  131. SAY "RexxUtils installed. :-)"
  132. SIGNAL OFF SYNTAX
  133. RETURN 1
  134.  
  135. NOREXXUTIL:
  136. SAY "RexxUtils not installed. :-("
  137. CALL RxFuncDrop 'SysLoadFuncs'
  138. SIGNAL OFF SYNTAX
  139. RETURN 0 /* LoadRexxUtils */
  140.  
  141. /*******************************************************************/
  142.  
  143. WhichOS2Version : PROCEDURE ;
  144. RexxUtils = ARG(1)
  145. /* Determine OS/2 Version */
  146. IF RexxUtils
  147.   THEN OS2Ver = SysOS2Ver()
  148.   ELSE OS2Ver = 1.x           
  149. /* We assume this because RexxUtils is missing and Rexx is installed */
  150. /* I have no other way of determining what the version is without    */
  151. /* SysOS2Ver()                                                       */
  152. SAY "OS/2 Version is "OS2Ver
  153. RETURN OS2Ver /* WhichOS2Version */
  154.  
  155. /*******************************************************************/
  156.  
  157. GetBootDrive : PROCEDURE ;
  158. RexxUtils = ARG(1)
  159. /* Determining Boot information */
  160. IF RexxUtils
  161.   THEN bootpath = SysSearchPath( 'PATH', 'COUNTRY.SYS' )
  162.   ELSE bootpath = MySearchPath( 'PATH', 'COUNTRY.SYS' )
  163. RETURN FILESPEC( "drive", bootpath ) /* GetBootDrive */
  164.  
  165. /*******************************************************************/
  166.  
  167. ChangeToSourceDirectory : PROCEDURE EXPOSE sourcedir ;
  168. /* Save Current Directory and change to Source Directory */
  169. startdir = DIRECTORY()
  170. PARSE SOURCE system calltype command
  171. drive = FILESPEC( "DRIVE", command )
  172. path = FILESPEC( "PATH", command )
  173. IF SUBSTR( path, LENGTH(path), 1 ) = '\'
  174.   THEN sourcedir = DIRECTORY( drive || SUBSTR( path, 1, LENGTH(path)-1 ) )
  175.   ELSE sourcedir = DIRECTORY( drive || path )
  176. RETURN startdir /* ChangeToSourceDirectory */
  177.  
  178. /*******************************************************************/
  179.  
  180. HowMuchSpaceRequired : PROCEDURE ;
  181. RexxUtils = ARG(1)
  182. /* SpaceRequired is the amount of free space required to install C-Kermit */
  183. IF RexxUtils
  184.   THEN DO
  185.     spacerequired = 0
  186.     rc = SysFileTree( '*.*', 'file', 'F' )
  187.     DO i = 1 to file.0
  188.       PARSE VAR file.i date time size atts name
  189.       spacerequired = spacerequired + 1024 + size
  190.       END
  191.     END
  192.   ELSE spacerequired = 720000 
  193. RETURN spacerequired /* HowMuchSpaceRequired */
  194.  
  195. /*******************************************************************/
  196.  
  197. ClearScreen : PROCEDURE EXPOSE RexxUtils ;
  198. /* Clear screen and prompt user for drive and path */
  199. '@echo off'
  200. IF RexxUtils
  201.   THEN CALL SysCls
  202.   ELSE "CLS" 
  203. RETURN /* ClearScreen */
  204.  
  205. /*******************************************************************/
  206.  
  207. Welcome : PROCEDURE ;
  208. SAY "+======================================================================+"
  209. SAY "|        Welcome to the OS/2 C-Kermit Installation Procedure.          |"
  210. SAY "|         You are about to install C-Kermit on your computer.          |"
  211. SAY "|                Press <Ctrl-C> to cancel at any time.                 |"
  212. SAY "+======================================================================+"
  213. SAY ""
  214. RETURN /* Welcome */
  215.  
  216. /*******************************************************************/
  217.  
  218. WhichKermitVersion : PROCEDURE EXPOSE RexxUtils startdir ;
  219. CKOVer = 0
  220.   IF FileExists("ckoker16.exe")
  221.     THEN CKOVer = 16
  222.  
  223.   IF FileExists("ckoker32.exe") 
  224.     THEN DO
  225.       IF CKOVer = 16
  226.         THEN CKOVer = "16/32"
  227.  
  228.       IF CKOVer = 0
  229.         THEN CKOVer = "32"
  230.     END
  231.  
  232. IF CKOVer = 0 
  233.   THEN DO
  234.     SAY "Sorry, but the source directory" DIRECTORY()
  235.     SAY "does not contain either the 16-bit or 32-bit version"
  236.     SAY "of C-Kermit."
  237.     SAY ""
  238.     SAY "Unable to complete the installation."
  239.     rc = DIRECTORY( startdir )
  240.     EXIT
  241.   END
  242. RETURN CKOVer /* WhichKermitVersion */
  243.  
  244. /*******************************************************************/
  245.  
  246. InstallCKermitExe :  PROCEDURE EXPOSE OS2Ver CKOVer RexxUtils destination ;
  247. SAY "Installing the C-Kermit application, CKERMIT.EXE..."
  248. SELECT 
  249.   WHEN substr(OS2Ver,1,1) = "1" & (CKOVer = 16 | CKOVer = "16/32")
  250.     THEN DO
  251.       CALL Install 'ckoker16.exe', ckermit.exe
  252.     END
  253.           
  254.   WHEN substr(OS2Ver,1,1) = "2" & CKOVer = 16 
  255.     THEN DO
  256.       CALL Install 'ckoker16.exe', ckermit.exe
  257.     END
  258.  
  259.   WHEN substr(OS2Ver,1,1) = "2" & (CKOVer = 32 | CKOVer = "16/32")
  260.     THEN DO
  261.       CALL Install 'ckoker32.exe', ckermit.exe
  262.     END
  263.  
  264. OTHERWISE
  265.   SAY "Can't install" CKOVer"-bit version of C-Kermit on OS/2 version" OS2Ver
  266.   CALL UnableToCompleteInstallation
  267. END
  268. SAY ""
  269. RETURN /* InstallCKermitExe */
  270.  
  271. /*******************************************************************/
  272.  
  273. InstallCKOTcpIpDll :  PROCEDURE EXPOSE OS2Ver CKOVer RexxUtils destination ;
  274. SAY "Installing the C-Kermit TCP/IP Support DLL..."
  275. SELECT 
  276.   WHEN substr(OS2Ver,1,1) = "1" & (CKOVer = 16 | CKOVer = "16/32")
  277.     THEN DO
  278.       CALL Install 'ckotcp16.dll'
  279.     END
  280.           
  281.   WHEN substr(OS2Ver,1,1) = "2" & CKOVer = 16 
  282.     THEN DO
  283.       CALL Install 'ckotcp16.dll'
  284.     END
  285.  
  286.   WHEN substr(OS2Ver,1,1) = "2" & (CKOVer = 32 | CKOVer = "16/32")
  287.     THEN DO
  288.       CALL Install 'ckotcp32.dll'
  289.     END
  290.  
  291. OTHERWISE
  292.   SAY "Can't install" CKOVer"-bit version of C-Kermit on OS/2 version" OS2Ver
  293.   CALL UnableToCompleteInstallation
  294. END
  295. SAY ""
  296. RETURN /* InstallCKOTcpIpDll */
  297.  
  298. /*******************************************************************/
  299.  
  300. InstallSyslevelFiles : PROCEDURE EXPOSE OS2Ver CKOVer RexxUtils,
  301.                                         destination ;
  302. SAY "Installing the Syslevel data file, SYSLEVEL.CKO..."
  303. SELECT 
  304.   WHEN substr(OS2Ver,1,1) = "1" & (CKOVer = 16 | CKOVer = "16/32")
  305.     THEN DO
  306.       CALL Install 'ckosysl.ck1', syslevel.cko
  307.     END
  308.           
  309.   WHEN substr(OS2Ver,1,1) = "2" & CKOVer = 16 
  310.     THEN DO
  311.       CALL Install 'ckosysl.ck1', syslevel.cko
  312.     END
  313.  
  314.   WHEN substr(OS2Ver,1,1) = "2" & (CKOVer = 32 | CKOVer = "16/32")
  315.     THEN DO
  316.       CALL Install 'ckosysl.ck2', syslevel.cko
  317.     END
  318.  
  319. OTHERWISE
  320.   NOP
  321. END
  322. SAY ""
  323. RETURN /* InstallSyslevelFiles */
  324.  
  325. /*******************************************************************/
  326.  
  327. InstallCkermitIco : PROCEDURE EXPOSE RexxUtils destination ;
  328.  
  329. SAY "Installing the C-Kermit Icon..."
  330. CALL Install 'ckermit.ico', 'ckermit.ico'
  331. SAY ""
  332. RETURN /* InstallCkermitIco */
  333.  
  334. /*******************************************************************/
  335.  
  336. InstallRexxCmdFiles : PROCEDURE EXPOSE RexxUtils destination ;
  337.  
  338. SAY "Installing the C-Kermit Rexx Command Files..."
  339. CALL Install 'xsend.cmd', 'xsend.cmd'
  340. SAY ""
  341. RETURN /* InstallRexxCmdFiles */
  342.  
  343. /*******************************************************************/
  344.  
  345. InstallDocs : PROCEDURE EXPOSE RexxUtils destination ;
  346.  
  347. SAY "Installing distribution information file, READ.ME..."
  348. CALL Install 'read.me', 'read.me'
  349. SAY ""
  350.  
  351. SAY "Installing documentation for recent C-Kermit updates, CKERMIT.UPD..."
  352. CALL Install 'ckermit.upd'
  353. SAY ""
  354. RETURN /* InstallDocs */
  355.  
  356. /*******************************************************************/
  357.  
  358. InstallExternalProtocols : PROCEDURE EXPOSE RexxUtils destination ;
  359.  
  360. SAY "Installing scripts for accessing external protocols..."
  361. CALL Install 'm2zmodem.ini', 'm2zodem.ini'
  362. CALL Install 'p101.ini', 'p101.ini'
  363. CALL Install 'p200.ini', 'p200.ini'
  364. SAY ""
  365. RETURN /* InstallExternalProtocols */
  366.  
  367. /*******************************************************************/
  368.  
  369. InstallCkermitIni : PROCEDURE EXPOSE RexxUtils destination ;
  370.  
  371. SAY "Installing the standard C-Kermit initialization file, CKERMIT.INI..."
  372. CALL Install 'ckermit.ini'
  373. SAY ""
  374. RETURN /* InstallCkermitIni */
  375.  
  376. /*******************************************************************/
  377.  
  378. InstallCkermodIni : PROCEDURE EXPOSE RexxUtils destination vt220 serial ,
  379.                                      modem port speed revision ;
  380.  
  381. IF FileExists( destination || 'ckermod.ini' ) 
  382. THEN DO
  383.   SAY "Installing new C-Kermit customization file, CKERMOD." || revision || '.'
  384.   CALL Install 'ckermod.ini', 'ckermod.'revision
  385.   END
  386. ELSE DO  
  387.   SAY "Installing your C-Kermit customization file, CKERMOD.INI..."
  388.   /*
  389.     Backup ckermod.ini if necessary,
  390.     Read ckermod.ini from diskette,
  391.     write ckermod.ini to dest directory with changes from previous dialog.
  392.   */
  393.  
  394.   CALL Backup 'ckermod.ini'
  395.   modini = destination"ckermod.ini"
  396.  
  397. /*  IF FileExists( destination || 'Backup\ckermod.ini' )      
  398.     THEN modinisrc = destination || 'Backup\ckermod.ini'
  399.     ELSE modinisrc = 'ckermod.ini'
  400. */
  401.   modinisrc = 'ckermod.ini'
  402.  
  403.   os2section = 0
  404.   LINEIN( modinisrc, 1, 0 )
  405.   DO WHILE lines( modinisrc ) <> 0
  406.     linetxt = LINEIN( modinisrc )
  407.     upperlinetxt = TRANSLATE(linetxt)
  408.     SELECT
  409.       WHEN (substr( upperlinetxt, 1, 5) = ':OS/2') & (os2section = 0)
  410.         THEN DO
  411.           /* SAY "...Entering OS/2 section" */
  412.           rc = LINEOUT( modini, linetxt )
  413.           os2section = 1
  414.         END
  415.  
  416.       WHEN (substr( upperlinetxt, 1, 9 ) = "SET MODEM") & (os2section = 1)
  417.         THEN IF serial 
  418.           THEN rc = LINEOUT( modini, 'set modem' modem )
  419.         ELSE rc = LINEOUT( modini, ';set modem <modem>')
  420.         
  421.       WHEN (substr( upperlinetxt, 1, 10 ) = ";SET MODEM") & (os2section = 1)
  422.         THEN IF serial 
  423.           THEN rc = LINEOUT( modini, 'set modem' modem )
  424.           ELSE rc = LINEOUT( modini, ';set modem <modem>')
  425.  
  426.       WHEN (substr( upperlinetxt, 1, 8 ) = "SET PORT") & (os2section = 1)
  427.         THEN IF serial
  428.           THEN rc = LINEOUT( modini, 'set port' port )
  429.           ELSE rc = LINEOUT( modini, ';set port <port>')
  430.           
  431.       WHEN (substr( upperlinetxt, 1, 9 ) = ";SET PORT") & (os2section = 1)
  432.         THEN IF serial
  433.           THEN rc = LINEOUT( modini, 'set port' port )
  434.           ELSE rc = LINEOUT( modini, ';set port <port>')
  435.  
  436.       WHEN (substr( upperlinetxt, 1, 9 ) = "SET SPEED") & (os2section = 1)
  437.         THEN IF serial
  438.           THEN rc = LINEOUT( modini, 'set speed' speed )
  439.           ELSE rc = LINEOUT( modini, ';set speed <speed>')
  440.  
  441.       WHEN (substr( upperlinetxt, 1, 10 ) = ";SET SPEED") & (os2section = 1)
  442.         THEN IF serial
  443.           THEN rc = LINEOUT( modini, 'set speed' speed )
  444.           ELSE rc = LINEOUT( modini, ';set speed <speed>')
  445.  
  446.       WHEN (substr( upperlinetxt, 1, 3 ) = 'END') & (os2section = 1)
  447.         THEN DO
  448.           /* SAY "...Leaving OS/2 section" */
  449.      /* linetxt = 'take' TRANSLATE( destination, '/', '\' ) || 'ckovtk2.ini' */
  450.       linetxt = 'take \m(_inidir)ckovtk2.ini'
  451.           IF vt220
  452.             THEN rc = LINEOUT( modini, linetxt )
  453.           rc = LINEOUT( modini, "end" )
  454.           os2section = 0
  455.         END
  456.  
  457.       OTHERWISE
  458.         rc = LINEOUT( modini, linetxt )
  459.     END
  460.   END
  461. END
  462.  
  463. /* Close files */
  464. rc = STREAM( modini, 'C', 'CLOSE' )
  465. rc = STREAM( modinisrc, 'C', 'CLOSE' )
  466. SAY ""
  467. RETURN /* InstallCkermodIni */
  468.  
  469. /*******************************************************************/
  470.  
  471. InstallDialingSupportFiles: PROCEDURE EXPOSE RexxUtils destination ;
  472.  
  473. IF \ FileExists( destination || 'ckermit.kdd' )
  474.   THEN DO
  475.     SAY "Installing Sample C-Kermit dialing directory file, CKERMIT.KDD..."
  476.     CALL Install 'ckermit.kdd'
  477.     END
  478.   ELSE DO 
  479.     SAY "Existing C-Kermit dialing directory file, CKERMIT.KDD, ", 
  480.         || "has been preserved."
  481.     END
  482. SAY ""
  483.  
  484. IF \ FileExists( destination || 'ckermit.ksd' )
  485.   THEN DO
  486.     SAY "Installing sample C-Kermit services directory file, CKERMIT.KSD..."
  487.     CALL Install 'ckermit.ksd'
  488.     END
  489.   ELSE DO 
  490.     SAY "Existing C-Kermit services directory file, CKERMIT.KSD, ",
  491.         || "has been preserved."
  492.     END
  493. SAY ""
  494. RETURN /* InstallDialingSupportFiles */
  495.  
  496. /*******************************************************************/
  497.  
  498. InstallCkermitCmd : PROCEDURE EXPOSE RexxUtils destination serial port ;
  499.  
  500. IF FileExists( destination || 'ckermit.cmd' )
  501. THEN DO
  502.   SAY "Existing C-kermit startup file, CKERMIT.CMD, has been preserved."
  503.   END
  504. ELSE DO
  505.   SAY "Installing sample C-Kermit startup file, CKERMIT.CMD..."
  506.   CALL Backup 'ckermit.cmd'
  507. /*  IF FileExists( destination || 'Backup\ckermit.cmd' )
  508.     THEN cmdsrc = destination || 'Backup\ckermit.cmd'
  509.     ELSE cmdsrc = 'ckermit.cmd'
  510. */
  511.   cmdsrc = 'ckermit.cmd'
  512.   cmdfile = destination || 'ckermit.cmd'
  513.  
  514.   LINEIN( cmdsrc, 1, 0 )
  515.   DO WHILE lines( cmdsrc ) <> 0
  516.     linetxt = LINEIN( cmdsrc )
  517.     upperlinetxt = TRANSLATE( linetxt )
  518.     SELECT
  519.       WHEN substr( upperlinetxt, 1, 8 ) = 'MODE COM'
  520.         THEN IF serial
  521.           THEN DO
  522.             newlinetxt = 'MODE ' || port,
  523.                     || substr( linetxt, 10, length( linetxt ) -9 )
  524.             rc = LINEOUT( cmdfile, newlinetxt )
  525.             END
  526.           ELSE rc = LINEOUT( cmdfile, 'REM ' || linetxt )
  527.             
  528.       WHEN substr( upperlinetxt, 1, 9 ) = '"MODE COM'
  529.         THEN IF serial
  530.           THEN DO
  531.             newlinetxt = '"MODE ' || port,  
  532.                           || substr( linetxt, 11, length( linetxt ) -10 )
  533.             rc = LINEOUT( cmdfile, newlinetxt )
  534.             END
  535.           ELSE rc = LINEOUT( cmdfile,,
  536.                         '"REM 'SUBSTR( linetxt, 2, LENGTH(linetxt)-1 ) )
  537.             
  538.       WHEN substr( upperlinetxt, 1, 12 ) = 'REM MODE COM'
  539.         THEN IF serial
  540.           THEN DO
  541.             newlinetxt = 'MODE ' || port,
  542.                           || substr( linetxt, 14, length( linetxt ) -13 )
  543.             rc = LINEOUT( cmdfile, newlinetxt )
  544.             END
  545.           ELSE rc = LINEOUT( cmdfile, linetxt )
  546.       
  547.       WHEN substr( upperlinetxt, 1, 13 ) = '"REM MODE COM'
  548.         THEN IF serial
  549.           THEN DO
  550.             newlinetxt = '"MODE ' || port,
  551.                           || substr( linetxt, 15, length( linetxt ) -14 )
  552.             rc = LINEOUT( cmdfile, newlinetxt )
  553.             END
  554.           ELSE rc = LINEOUT( cmdfile, linetxt )
  555.       
  556.       OTHERWISE 
  557.         rc = LINEOUT( cmdfile, linetxt )
  558.   
  559.     END
  560.   END
  561.  
  562.   rc = STREAM( cmdfile, 'C', 'CLOSE' )
  563.   rc = STREAM( cmdsrc, 'C', 'CLOSE' )
  564. END
  565. SAY ""
  566. RETURN /* InstallCkermitCmd */
  567.  
  568. /*******************************************************************/
  569.  
  570. InstallKeyboardDefs : PROCEDURE EXPOSE RexxUtils destination revision ;
  571.  
  572. IF FileExists( destination || ckovtk2.ini ) 
  573. THEN DO
  574.   SAY "Installing new C-Kermit VT220 keyboard definitions file as CKOVTK2.",
  575.     || revision
  576.   CALL Install 'ckovtk2.ini', 'ckovtk2.'revision
  577.   SAY "Your old copy has been preserved as" destination || "ckovtk2.ini."
  578.   END
  579. ELSE DO
  580.   SAY "Installing C-Kermit VT220 keyboard definitions file, CKOVTK2.INI..."
  581.   CALL Install 'ckovtk2.ini'
  582.   END
  583. SAY ""
  584. RETURN /* InstallKeyboardDefs */
  585.  
  586. /*******************************************************************/
  587.  
  588. InstallCharSets : PROCEDURE EXPOSE RexxUtils destination ;
  589.  
  590. SAY "Installing character-set tables CP437.TXT, CP850.TXT, and LATIN1.TXT..."
  591. CALL Install 'cp437.txt'
  592. CALL Install 'cp850.txt'
  593. CALL Install 'latin1.txt'
  594. SAY ""
  595. RETURN /* InstallCharSets */
  596.  
  597. /*******************************************************************/
  598.  
  599. SetIcon : PROCEDURE EXPOSE RexxUtils destination updest ;
  600.  
  601. IF RexxUtils
  602.   THEN DO
  603.     SAY "Assigning the C-Kermit icon to" updest || CKERMIT.EXE || "..."
  604.     rc = SysSetIcon( destination || 'ckermit.exe',,
  605.                      destination || 'ckermit.ico' )
  606.     SAY ""
  607.   END
  608. RETURN /* SetIcon */
  609.  
  610. /*******************************************************************/
  611.  
  612. BuildFolderObject : PROCEDURE EXPOSE RexxUtils destination OS2Ver,
  613.                                       newInstall ;
  614.  
  615. /* Build C-Kermit Folder Object if version 2.x */
  616. IF RexxUtils & SUBSTR( OS2Ver,1,1 ) = "2" 
  617.   THEN DO
  618.       title = "C-Kermit for OS/2"
  619.     classname = 'WPFolder'
  620.     location = '<WP_DESKTOP>'
  621.     setup = 'OBJECTID=<CK_FOLDER>'
  622.     IF \ newInstall 
  623.       THEN DO
  624.         option = 'update'
  625.         SAY "Updating C-Kermit Folder..."
  626.       END
  627.       ELSE DO
  628.         option = 'update'      
  629.         SAY "Building C-Kermit Folder..."
  630.       END
  631.  
  632.     rc = SysCreateObject(classname, title, location, setup, option)
  633.     SAY ""
  634.   END
  635. RETURN /* BuildFolderObject */
  636.  
  637. /*******************************************************************/
  638.  
  639. BuildUpdatesObject : PROCEDURE EXPOSE RexxUtils destination OS2Ver,
  640.                                       newInstall ;
  641.  
  642. /* Build C-Kermit Updates Object if version 2.x */
  643. IF RexxUtils & SUBSTR( OS2Ver,1,1 ) = "2" 
  644.   THEN DO
  645.     title = "Updates to Using C-Kermit"
  646.     classname = 'WPProgram'
  647.     location = '<CK_FOLDER>'
  648.     setup = 'EXENAME=e.exe;STARTUPDIR=',
  649.             destination';PARAMETERS=ckermit.upd'
  650. /* replace with the following when the INF file is finished 
  651.     setup = 'EXENAME=view.exe;STARTUPDIR=',
  652.             destination';PARAMETERS=ckermit.inf'
  653. */
  654.     option = 'update'      
  655.     SAY "Building Using C-Kermit Updates Object..."
  656.  
  657.     rc = SysCreateObject(classname, title, location, setup, option)
  658.     SAY ""
  659.   END
  660. RETURN /* BuildUpdatesObject */
  661.  
  662. /*******************************************************************/
  663.  
  664. BuildProgramObject : PROCEDURE EXPOSE RexxUtils destination OS2Ver runmode,
  665.                                       newInstall ;
  666.  
  667. /* Build C-Kermit Program Object if version 2.x */
  668. IF RexxUtils & SUBSTR( OS2Ver,1,1 ) = "2" 
  669.   THEN DO
  670.     IF CKOVer = "16"
  671.       THEN title = "OS/2 C-Kermit (16-bit)"
  672.       ELSE title = "OS/2 C-Kermit (32-bit)"
  673.     classname = 'WPProgram'
  674.     location = '<CK_FOLDER>' 
  675.     IF \ newInstall 
  676.       THEN DO
  677.         setup = 'EXENAME='destination'ckermit.exe;STARTUPDIR=',
  678.             destination';ICON='destination'ckermit.ico;PARAMETERS=%'
  679.         option = 'update'
  680.         SAY "Updating C-Kermit Program Object..."
  681.       END
  682.       ELSE DO
  683.         IF TRANSLATE(runmode) = "WINDOW"
  684.           THEN setup = 'EXENAME='destination'ckermit.exe;STARTUPDIR=',
  685.             destination';PROGTYPE=WINDOWABLEVIO;ICON='destination,
  686.             'ckermit.ico;PARAMETERS=%'
  687.           ELSE setup = 'EXENAME='destination'ckermit.exe;STARTUPDIR=',
  688.             destination';PROGTYPE=FULLSCREEN;ICON='destination,
  689.             'ckermit.ico;PARAMETERS=%'
  690.  
  691.         option = 'update'      
  692.         SAY "Building C-Kermit Program Object..."
  693.       END
  694.  
  695.     rc = SysCreateObject(classname, title, location, setup, option)
  696.     SAY ""
  697.   END
  698. RETURN /* BuildProgramObject */
  699.  
  700. /*******************************************************************/
  701.  
  702. UpdateConfigSys : PROCEDURE EXPOSE RexxUtils destination tcpip bootdrive,
  703.                                 vt220 updest destnoslash configupdate ckover ;
  704.  
  705. SAY "Your CONFIG.SYS file defines several environment variables that determine"
  706. SAY "how OS/2 and your applications work.  With your permission, this program"
  707. SAY "will modify two or three of them:"
  708. SAY ""
  709. SAY " 1. The C-Kermit directory," destination || ", will be added to your PATH"
  710. SAY "    to allow C-Kermit to be executed from any OS/2 Command Line session."
  711. SAY ""
  712. SAY " 2. The C-Kermit directory," destination || ", will be added to your DPATH"
  713. SAY "    to allow the C-Kermit Dialing Directory Maintenance Utility to find"
  714. SAY "    the CKERMIT.KDD and CKERMIT.KSD files."
  715. SAY ""
  716. SAY "Please enter 'Yes' to allow this program to update your CONFIG.SYS file."
  717. SAY "A backup copy will be made in the root directory of your boot drive."
  718. SAY "Update CONFIG.SYS? (Yes/No):"
  719.  
  720. CALL Confirmation
  721. IF RESULT <> 'Y'
  722.   THEN DO
  723.     configupdate = 0
  724.     SAY ""
  725.     SAY "  OK, your CONFIG.SYS file has not been changed."
  726.     CALL Done
  727.   END
  728.  
  729. configupdate = 1
  730. SAY ""
  731.  
  732. /* Back up the existing CONFIG.SYS file. */
  733. IF RexxUtils 
  734.   THEN DO 
  735.     tempname = bootdrive || "\CONFIG.???"
  736.     backup = SysTempFileName( tempname )
  737.     END
  738.   ELSE DO
  739.     n = 100
  740.     backup = bootdrive || "\CONFIG." || n
  741.     CALL STREAM backup, 'c', 'query exists'
  742.     DO WHILE "\"RESULT <> "\"
  743.       n = n + 1
  744.       backup = bootdrive || "\CONFIG." || n
  745.       CALL STREAM backup, 'c', 'query exists'
  746.       END
  747.     END
  748.  
  749. SAY "Backing up CONFIG.SYS to" backup || "..."
  750. copy bootdrive || "\Config.Sys" backup "> NUL"
  751. SAY ""
  752.  
  753. /* Generate a temporary file name for the new CONFIG.SYS file */
  754. IF RexxUtils
  755.   THEN DO
  756.     tempname = bootdrive || "\CONFIG??.INS"
  757.     temp = SysTempFileName( tempname )
  758.     END
  759.   ELSE DO 
  760.     n = 10
  761.     temp = bootdrive || "\CONFIG" || n || ".INS"
  762.     CALL STREAM temp, 'c', 'query exists'
  763.     DO WHILE "\"RESULT <> "\"
  764.       n = n + 1
  765.       temp = bootdrive || "\CONFIG" || n || ".INS"
  766.       CALL STREAM temp, 'c', 'query exists'
  767.       END
  768.     END
  769.  
  770. /* Generate the temporary CONFIG.SYS file. */
  771. SAY "Updating CONFIG.SYS..."
  772.  
  773. /* Change to a neutral directory so that SearchPath searches will succeed */
  774. rc = DIRECTORY( bootdrive"\OS2" )
  775. LINEIN( bootdrive || "\Config.sys", 1, 0 )
  776.  
  777. DO WHILE lines( bootdrive || "\Config.sys" ) <> 0
  778.   linetxt = LINEIN( bootdrive || "\Config.sys" )
  779.   upperlinetxt = TRANSLATE(linetxt)
  780.   SELECT
  781.     WHEN COMPARE( upperlinetxt, "SET PATH" ) = 9 
  782.       THEN DO
  783.         SETLOCAL
  784.         len = LENGTH(linetxt)
  785.         rc = VALUE('PATH', SUBSTR( upperlinetxt, 10, len - 10 ),,
  786.                    'OS2ENVIRONMENT' )
  787.         IF RexxUtils
  788.           THEN ckfound = SysSearchPath( 'PATH', ckermit.exe )
  789.           ELSE ckfound = MySearchPath( 'PATH', ckermit.exe )
  790.         IF ckfound'\' = '\'
  791.           THEN IF SUBSTR( linetxt, len, 1 ) = ';'
  792.             THEN rc = LINEOUT( temp, linetxt || destnoslash || ';' )
  793.             ELSE rc = LINEOUT( temp, linetxt || ';' || destnoslash || ';' )
  794.           ELSE DO
  795.             ckpath = FILESPEC('DRIVE', ckfound ) || FILESPEC('PATH', ckfound )
  796.             IF ckpath = updest
  797.               THEN rc = LINEOUT( temp, linetxt )
  798.               ELSE DO
  799.                 ckpathnoslash = SUBSTR( ckpath, 1, LENGTH( ckpath ) - 1 )
  800.                 pos = POS( ckpathnoslash, upperlinetxt )
  801.                 rc = LINEOUT( temp, SUBSTR( linetxt, 1, pos - 1 ) ,
  802.                                     || destnoslash';' ,
  803.                                     || SUBSTR( linetxt, pos, len - pos + 1 ) )
  804.                 SAY ""
  805.                 SAY "  WARNING:"
  806.                 SAY "    An earlier version of 'CKERMIT.EXE' exists in",
  807.                     "    directory" ckpath || "."
  808.                 END
  809.           END
  810.         ENDLOCAL
  811.         END
  812.  
  813.     WHEN COMPARE( upperlinetxt, "SET DPATH" ) = 10
  814.       THEN DO
  815.         SETLOCAL
  816.         len = LENGTH(linetxt)
  817.         rc = VALUE('DPATH', SUBSTR( upperlinetxt, 11, len - 11 ),,
  818.                    'OS2ENVIRONMENT' )
  819.         IF RexxUtils
  820.           THEN ckfound = SysSearchPath( 'DPATH', ckermit.ini )
  821.           ELSE ckfound = MySearchPath( 'DPATH', ckermit.ini )
  822.         IF ckfound = "" | ckfound = DIRECTORY()"\CKERMIT.INI"
  823.           THEN IF SUBSTR( linetxt, len, 1 ) = ';'
  824.             THEN rc = LINEOUT( temp, linetxt || destnoslash || ';' )
  825.             ELSE rc = LINEOUT( temp, linetxt || ';' || destnoslash || ';' )
  826.           ELSE DO
  827.             ckpath = FILESPEC('DRIVE', ckfound ) || FILESPEC('PATH', ckfound )
  828.             IF ckpath = updest
  829.               THEN rc = LINEOUT( temp, linetxt )
  830.               ELSE DO
  831.                 ckpathnoslash = SUBSTR( ckpath, 1, LENGTH( ckpath ) - 1 )
  832.                 pos = POS( ckpathnoslash, upperlinetxt )
  833.                 rc = LINEOUT( temp, SUBSTR( linetxt, 1, pos - 1 ) ,
  834.                                     || destnoslash';' ,
  835.                                     || SUBSTR( linetxt, pos, len - pos + 1 ) )
  836.                 SAY ""
  837.                 SAY "  WARNING:"
  838.                 SAY "    An earlier version of 'CKERMIT.INI' exists in",
  839.                     "    directory" ckpath || "."
  840.                 END
  841.           END
  842.         ENDLOCAL
  843.         END
  844.  
  845.     WHEN COMPARE( upperlinetxt, "SET BOOKSHELF" ) = 13
  846.       THEN DO
  847.         SETLOCAL
  848.         len = LENGTH(linetxt)
  849.         rc = VALUE('BOOKSHELF', SUBSTR( upperlinetxt, 14, len - 14 ),,
  850.                    'OS2ENVIRONMENT' )
  851.         IF RexxUtils
  852.           THEN ckfound = SysSearchPath( 'BOOKSHELF', ckermit.inf )
  853.           ELSE ckfound = MySearchPath( 'BOOKSHELF', ckermit.inf )
  854.         IF ckfound = "" | ckfound = DIRECTORY()"\CKERMIT.INF"
  855.           THEN IF SUBSTR( linetxt, len, 1 ) = ';'
  856.             THEN rc = LINEOUT( temp, linetxt || destnoslash || ';' )
  857.             ELSE rc = LINEOUT( temp, linetxt || ';' || destnoslash || ';' )
  858.           ELSE DO
  859.             ckpath = FILESPEC('DRIVE', ckfound ) || FILESPEC('PATH', ckfound )
  860.             IF ckpath = updest
  861.               THEN rc = LINEOUT( temp, linetxt )
  862.               ELSE DO
  863.                 ckpathnoslash = SUBSTR( ckpath, 1, LENGTH( ckpath ) - 1 )
  864.                 pos = POS( ckpathnoslash, upperlinetxt )
  865.                 rc = LINEOUT( temp, SUBSTR( linetxt, 1, pos - 1 ) ,
  866.                                     || destnoslash';' ,
  867.                                     || SUBSTR( linetxt, pos, len - pos + 1 ) )
  868.                 SAY ""
  869.                 SAY "  WARNING:"
  870.                 SAY "    An earlier version of 'CKERMIT.INF' exists in",
  871.                     "    directory" ckpath || "."
  872.                 END
  873.           END
  874.         ENDLOCAL
  875.         END
  876.  
  877.     WHEN (COMPARE( upperlinetxt, "LIBPATH" ) = 8) & (tcpip = 0) 
  878.       THEN DO
  879.         SETLOCAL
  880.         len = LENGTH(linetxt)
  881.         rc = VALUE('LIBPATH', SUBSTR( upperlinetxt, 9, len - 9 ),,
  882.                    'OS2ENVIRONMENT' )
  883.         IF RexxUtils 
  884.           THEN ckfound = SysSearchPath( 'LIBPATH', tcpipdll.dll )
  885.           ELSE ckfound = MySearchPath( 'LIBPATH', tcpipdll.dll )
  886.         IF ckfound'\' = '\'
  887.           THEN IF SUBSTR( linetxt, len, 1 ) = ';'
  888.             THEN rc = LINEOUT( temp, linetxt || destnoslash || ';' )
  889.             ELSE rc = LINEOUT( temp, linetxt || ';' || destnoslash || ';' )
  890.           ELSE DO
  891.             ckpath = FILESPEC('DRIVE', ckfound ) || FILESPEC('PATH', ckfound )
  892.             IF ckpath = updest
  893.               THEN rc = LINEOUT( temp, linetxt )
  894.               ELSE DO
  895.                 ckpathnoslash = SUBSTR( ckpath, 1, LENGTH( ckpath ) - 1 )
  896.                 pos = POS( ckpathnoslash, upperlinetxt )
  897.                 rc = LINEOUT( temp, SUBSTR( linetxt, 1, pos - 1 ) ,
  898.                                     || destnoslash';' ,
  899.                                     || SUBSTR( linetxt, pos, len - pos + 1 ) )
  900.                 SAY ""
  901.                 SAY "  WARNING:"
  902.                 SAY "    An earlier version of 'TCPIPDLL.DLL' exists in",
  903.                     "    directory" ckpath || "."
  904.               END
  905.           END
  906.         ENDLOCAL
  907.         END
  908.  
  909.     OTHERWISE
  910.       rc = LINEOUT( temp, linetxt )
  911.   END
  912. END
  913.  
  914. /* Close files */
  915. rc = STREAM( temp, 'C', 'CLOSE' )
  916. rc = STREAM( bootdrive || "\Config.sys", 'C', 'CLOSE' )
  917.  
  918. COPY temp bootdrive || "\Config.sys > NUL" 
  919. IF RexxUtils 
  920.   THEN rc = SysFileDelete( temp )
  921.   ELSE "CMD /C DEL" temp "> NUL"
  922.  
  923. SAY ""
  924. SAY "  Your CONFIG.SYS file has been updated."
  925. SAY "  Your old CONFIG.SYS has been copied to " backup || "."
  926. SAY "  After reading the following message,"
  927. SAY "  Please Shutdown and Restart OS/2."
  928.  
  929. RETURN /* UpdateConfigSys */
  930.  
  931. /*******************************************************************/
  932.  
  933. Done : PROCEDURE EXPOSE RexxUtils destination OS2Ver vt220 updest startdir,
  934.                         configupdate ;
  935.  
  936. SAY ""
  937. SAY "C-Kermit has been successfully installed in the directory" updest || "."
  938. SAY ""
  939. IF SUBSTR( OS2Ver, 1, 1 ) = "2"
  940.   THEN SAY "  To start C-Kermit from the desktop, click on its icon."
  941. IF configupdate
  942.   THEN 
  943.     SAY "  To start C-Kermit from a command window, just type CKERMIT."
  944.   ELSE DO
  945.     SAY "  To start C-Kermit from a command window, just type CKERMIT,"
  946.     SAY "  or if" updest "is not in your PATH, type" updest || "CKERMIT."
  947.   END
  948. SAY ""
  949. IF vt220
  950.   THEN SAY "Read the" updest || "CKOVTK2.INI file for VT220 key mappings."
  951. SAY "Please consult the book 'Using C-Kermit' for complete instructions, and"
  952. SAY "also read the update file in" updest "for other important information:"
  953. SAY "CKERMIT.UPD.  If you don't have the book, please call +1 212 854-3703"
  954. SAY "or +1 800 366-2665 (USA) to order."
  955. SAY ""
  956. SAY "In particular, see pages 419-427 for additional installation and"
  957. SAY "startup options."
  958. SAY ""
  959. IF RexxUtils
  960.   THEN DO 
  961.     SAY "Press any key to exit from the C-Kermit installation procedure."
  962.     PARSE UPPER VALUE SysGetKey('NOECHO') WITH confirm
  963.     END
  964.   ELSE DO
  965.     SAY "Press <Enter> to exit from the C-kermit installation procedure."
  966.     IF SUBSTR(OS2Ver, 1, 1 ) > 1
  967.       THEN CALL CHAROUT ,">"
  968.     PARSE PULL dummy
  969.   END
  970. rc = DIRECTORY( startdir )
  971. EXIT
  972. RETURN /* Done */
  973.  
  974. /*******************************************************************/
  975.  
  976. Install : PROCEDURE EXPOSE RexxUtils destination ; 
  977.  
  978. IF "\"ARG(2) = "\"
  979.   THEN destname = ARG(1)
  980.   ELSE destname = ARG(2) 
  981. CALL Backup destname
  982. COPY ARG(1) destination || destname "> NUL"
  983.  
  984. IF RC > 0 
  985.   THEN DO
  986.     CALL BEEP 262, 750
  987.     SAY "ERROR:" destname "could not be installed in directory" destination
  988.     SAY ""
  989.     CALL FAILURE
  990.   END
  991. RETURN RC /* Install */
  992.  
  993. /*******************************************************************/
  994.  
  995. Backup : PROCEDURE EXPOSE RexxUtils destination ;
  996.  
  997. IF RexxUtils
  998.   THEN DO 
  999.     CALL SysFileTree destination || ARG(1), 'file', 'FO'
  1000.     IF file.0 > 0
  1001.       THEN DO
  1002.         CALL SysFileTree destination || 'BACKUP', 'dir', 'DO'
  1003.         IF dir.0 = 0
  1004.           THEN CALL SysMkDir destination || 'BACKUP'
  1005.  
  1006.         CALL SysFileTree destination || 'BACKUP\' || ARG(1), 'file', 'FO'
  1007.         IF file.0 > 0
  1008.           THEN CALL SysFileDelete destination || 'BACKUP\' || ARG(1)
  1009.  
  1010.         COPY destination || ARG(1) destination || 'BACKUP\' || ARG(1) '> NUL'
  1011.         CALL SysFileDelete destination || ARG(1)
  1012.       END 
  1013.     END
  1014.   ELSE DO
  1015.     CALL STREAM destination || ARG(1), 'c', 'query exists'
  1016.     IF "\"RESULT <> "\"
  1017.       THEN DO
  1018.     "CMD /C DIR" destination || "BACKUP > NUL"
  1019.         IF RC <> 0
  1020.           THEN 'CMD /C MD' destination || 'BACKUP > NUL'
  1021.  
  1022.         CALL STREAM destination || "BACKUP\" || ARG(1), 'c', 'query exists'
  1023.         IF "\"RESULT <> "\"
  1024.           THEN "CMD /C DEL" destination || "BACKUP\" || ARG(1) "> NUL"
  1025.  
  1026.       COPY destination || ARG(1) destination || 'BACKUP\' || ARG(1) '> NUL'
  1027.     "CMD /C DEL" destination || ARG(1)
  1028.         END
  1029.     END
  1030. RETURN /* Backup */
  1031.  
  1032. /*******************************************************************/
  1033.  
  1034. Confirmation: PROCEDURE EXPOSE OS2Ver ;
  1035.  
  1036. retval = ""
  1037. DO WHILE retval = ""
  1038.   IF SUBSTR(OS2Ver, 1, 1 ) > 1
  1039.     THEN CALL CHAROUT ,">"
  1040.   PARSE PULL response
  1041.   SELECT
  1042.     WHEN ( TRANSLATE( response ) = 'N' | TRANSLATE( response ) = 'NO' )
  1043.       THEN retval = 'N'
  1044.  
  1045.     WHEN ( TRANSLATE( response ) = 'Y' | TRANSLATE( response ) = 'YES' )
  1046.       THEN retval = 'Y'
  1047.  
  1048.     OTHERWISE
  1049.       SAY ""
  1050.       SAY "Invalid response.  Please type Y or Yes or N or No."
  1051.   END
  1052. END
  1053. RETURN retval /* Confirmation */
  1054.  
  1055. /*******************************************************************/
  1056. /* This procedure duplicates as best as possible the RexxUtil      */
  1057. /* function SysSearchPath.                                         */
  1058.  
  1059. MySearchPath : PROCEDURE ;
  1060.  
  1061. _path = VALUE( ARG(1), , "OS2ENVIRONMENT" )
  1062. IF SUBSTR( _path, LENGTH(_path), 1 ) <> ";"
  1063.   THEN _path = _path || ";"
  1064. PARSE UPPER VAR _path _dir ";" _path
  1065. DO WHILE ("\"_dir <> "\") | ("\"_path <> "\")
  1066.   CALL STREAM _dir || "\" || ARG(2), 'c', 'query exists'
  1067.   IF "\"RESULT <> "\"
  1068.     THEN RETURN _dir || "\" || ARG(2)
  1069.     ELSE PARSE UPPER VAR _path _dir ";" _path
  1070.   END
  1071. RETURN "" /* MySearchPath */
  1072.  
  1073. /*******************************************************************/
  1074.  
  1075. IsIBMTCPIPInstalled: PROCEDURE ;
  1076. RexxUtils = ARG(1)
  1077. etcpath = VALUE( "ETC", , "OS2ENVIRONMENT" )
  1078. len = LENGTH(etcpath) 
  1079. IF len = 0 
  1080.   THEN tcpip = 0
  1081. ELSE DO
  1082.   IF SUBSTR( etcpath, len, 1 ) = ';'
  1083.     THEN DO
  1084.       etcpath = SUBSTR( etcpath, 1, len - 1 )
  1085.       len = len - 1
  1086.     END
  1087.   IF SUBSTR( etcpath, len, 1 ) = '\'
  1088.     THEN DO
  1089.       etcpath = SUBSTR( etcpath, 1, len - 1 )
  1090.       len = len - 1
  1091.     END
  1092.   tcppath = SUBSTR( etcpath, 1, len - 3 )
  1093.   IF RexxUtils
  1094.     THEN DO 
  1095.       CALL SysFileTree tcppath || "\dll\tcpipdll.dll", 'file', 'FO' 
  1096.       tcpip = file.0
  1097.     END
  1098.   ELSE DO
  1099.     CALL STREAM tcppath || "\dll\tcpipdll.dll", "C", "QUERY EXISTS" 
  1100.     IF "\"RESULT <> "\"
  1101.       THEN tcpip = 1
  1102.       ELSE tcpip = 0
  1103.   END
  1104. END
  1105. RETURN tcpip /* IsIBMTCPIPInstalled */
  1106.  
  1107. /*******************************************************************/
  1108.  
  1109. GETDIR : PROCEDURE EXPOSE RexxUtils destination OS2Ver updest destnoslash,
  1110.                           sourcedir installdrive ;
  1111. IF ARG(1) = "" THEN DO
  1112.   SAY "Please enter the complete path where you want C-Kermit to be installed."
  1113.   SAY "Just press the Enter key to accept the default path, C:\CKERMIT\..."
  1114.   IF SUBSTR(OS2Ver, 1, 1 ) > 1
  1115.     THEN CALL CHAROUT ,">"
  1116.   PARSE PULL destination
  1117.   END
  1118. ELSE destination = ARG(1) 
  1119. destination = TRANSLATE( destination, '\', '/' )
  1120.  
  1121. /* Use default if nothing was entered */
  1122. IF "\"destination = "\"
  1123.   THEN destination = "C:\CKERMIT\"
  1124.  
  1125. /* Check to make sure there is a trailing backslash */
  1126. IF SUBSTR( destination, LENGTH(destination), 1 ) <> "\"
  1127.   THEN destination = destination || "\"
  1128.  
  1129. /* Check to make sure a drive is specified - use startup drive if not */
  1130. installdrive = FILESPEC("DRIVE",destination)
  1131. IF installdrive = ""
  1132.   THEN installdrive = FILESPEC("DRIVE", startdir) 
  1133.  
  1134. /* Check to make sure a path is specified - use root if not */
  1135. installpath  = FILESPEC("PATH", destination)
  1136. IF installpath = ""
  1137.   THEN installpath= "\"
  1138.  
  1139. /* Build fully qualified destination directory name */
  1140. destination = installdrive || installpath 
  1141.  
  1142. /* And guaranteed-uppercase version */
  1143. updest = TRANSLATE(destination)
  1144.  
  1145. /* And a version without a slash */
  1146. destnoslash = SUBSTR( destination, 1, LENGTH( destination ) - 1 )
  1147.  
  1148. /* Ensure that source and destination directories are different */
  1149. IF sourcedir"\" = TRANSLATE(destination)
  1150.   THEN DO
  1151.     SAY ""
  1152.     SAY "The source and destination directories must be different."
  1153.     CALL GETDIR
  1154.     RETURN
  1155.   END
  1156.  
  1157. /* Validate the install drive */
  1158. IF RexxUtils
  1159.   THEN 
  1160.     IF POS( TRANSLATE( installdrive ), "A: B: " || SysDriveMap() ) <> 0
  1161.       THEN valid = 1
  1162.       ELSE valid = 0
  1163.   ELSE DO
  1164.     'CMD /C DIR' installdrive '> NUL'
  1165.     IF rc = 0
  1166.       THEN valid = 1
  1167.       ELSE valid = 0
  1168.     END
  1169. IF \ valid
  1170.   THEN DO
  1171.     SAY ""
  1172.     SAY installdrive "is not a valid drive."
  1173.     CALL GETDIR
  1174.     RETURN
  1175.   END
  1176.  
  1177. /* Confirm destination directory */
  1178. SAY ""
  1179. SAY "You have asked that C-Kermit be installed in" destination || "."
  1180. SAY "Is this correct? (Yes/No):"
  1181. CALL Confirmation
  1182. IF RESULT <> 'Y' 
  1183.   THEN DO
  1184.     CALL GETDIR
  1185.     RETURN
  1186.   END
  1187. SAY ""
  1188. RETURN /* GetDir */
  1189.  
  1190. /*******************************************************************/
  1191.  
  1192. CheckSpace : PROCEDURE EXPOSE RexxUtils destination installdrive,
  1193.                               spacerequired OS2Ver ;
  1194.  
  1195. /* Check Available Drive Space */
  1196. IF RexxUtils
  1197.   THEN DO
  1198.   PARSE UPPER VALUE SysDriveInfo( installdrive ) WITH sysinfodrive freespace,
  1199.     drivesize volumelabel
  1200.  
  1201.   IF freespace < spacerequired 
  1202.     THEN DO
  1203.       SAY "Drive" installdrive "does not have enough free space for C-Kermit."
  1204.       SAY "C-Kermit needs" spacerequired "bytes.  Drive" installdrive,
  1205.         "only has" freespace "bytes free."
  1206.       SAY "Enter 'Yes' to choose another drive, or 'No' to cancel."
  1207.       CALL Confirmation
  1208.       IF RESULT = 'Y'
  1209.         THEN DO
  1210.           CALL GETDIR
  1211.           CALL CheckSpace
  1212.           RETURN
  1213.         END
  1214.         ELSE DO
  1215.           SAY ""
  1216.           EXIT
  1217.         END
  1218.       END  
  1219.   END /* RexxUtils */
  1220. RETURN /* CheckSpace */
  1221.  
  1222. /*******************************************************************/
  1223.  
  1224. CreateDir : PROCEDURE EXPOSE RexxUtils destination startdir OS2Ver,
  1225.                              spacerequired ;
  1226.  
  1227. SAY "Creating destination directory" destination || "..."
  1228. IF RexxUtils
  1229.   THEN rc = SysMkDir(SUBSTR(destination,1,LENGTH(destination)-1))
  1230.   ELSE 'CMD /C MD' SUBSTR(destination,1,LENGTH(destination)-1) '> NUL'
  1231.  
  1232. SELECT
  1233.   WHEN rc = 0 
  1234.     THEN SAY ""
  1235.  
  1236.   WHEN ( rc = 5 & RexxUtils ) | ( rc = 1 & \ RexxUtils )
  1237.     THEN DO
  1238.       SAY "Directory" destination "already exists."
  1239.       SAY "Enter 'Yes' to continue or 'No' to choose a new directory."
  1240.       CALL Confirmation
  1241.       IF RESULT <> 'Y'
  1242.         THEN DO
  1243.           CALL GETDIR
  1244.           CALL CheckSpace
  1245.           CALL CreateDir
  1246.           RETURN
  1247.         END
  1248.       SAY ""
  1249.     END
  1250.  
  1251.   OTHERWISE 
  1252.     DO
  1253.       SAY "Can't create destination directory" destination
  1254.       SAY ""
  1255.       rc = DIRECTORY( startdir )
  1256.       CALL GETDIR
  1257.       CALL CheckSpace
  1258.       CALL CreateDir
  1259.       RETURN
  1260.     END
  1261. END
  1262. RETURN /* CreateDir */
  1263.  
  1264. /*******************************************************************/
  1265.  
  1266. GETMODEM : PROCEDURE EXPOSE RexxUtils OS2Ver modem  ;
  1267.  
  1268. SAY ""
  1269. SAY "C-Kermit is designed to work with many different brands of modems."
  1270. SAY "Please choose your preferred modem type from the following list:"
  1271. SAY ""
  1272. SAY " attdtdm            attisn             attmodem           att7300"
  1273. SAY " ccitt-v25bis       cermetek           concord            courier"
  1274. SAY " df03-ac            df100-series       df200-series       digitel-dt22"
  1275. SAY " gdc-212a/ed        hayes              microcom           none"
  1276. SAY " penril             pep-telebit        racalvadic         rolm"
  1277. SAY " slow-telebit       sportster          telebit            unknown"
  1278. SAY " usrobotics-212a    v32-telebit        v42-telebit        ventel"
  1279. SAY ""
  1280. SAY "Pressing the Enter key by itself selects HAYES..."
  1281. IF SUBSTR(OS2Ver, 1, 1 ) > 1
  1282.   THEN CALL CHAROUT ,">"
  1283. PARSE PULL modem
  1284.  
  1285. /* Use Hayes if nothing was entered */
  1286. IF modem = ""
  1287.   THEN modem = "hayes"
  1288.  
  1289. umodem = TRANSLATE(modem)
  1290. IF  (umodem \= "ATTDTDM") & (Umodem \= "ATTISN") & (Umodem \= "ATTMODEM"), 
  1291.   & (Umodem \= "ATT7300") & (Umodem \= "CCITT-V25BIS"),
  1292.   & (Umodem \= "CERMETEK"),
  1293.   & (Umodem \= "CONCORD") & (Umodem \= "COURIER") & (Umodem \= "DF03-AC"),
  1294.   & (Umodem \= "DF100-SERIES") & (Umodem \= "DF200-SERIES"),
  1295.   & (Umodem \= "DIGITAL-DT22") & (Umodem \= "GDC-212A/ED"),
  1296.   & (Umodem \= "HAYES"), 
  1297.   & (Umodem \= "MICROCOM") & (Umodem \= "NONE") & (Umodem \= "PENRIL"),
  1298.   & (Umodem \= "PEP-TELEBIT") & (Umodem \= "RACALVADIC") & (Umodem \= "ROLM"),
  1299.   & (Umodem \= "SLOW-TELEBIT") & (Umodem \= "SPORTSTER"),
  1300.   & (Umodem \= "TELEBIT"),
  1301.   & (Umodem \= "UNKNOWN") & (Umodem \= "USROBOTICS-212A"),
  1302.   & (Umodem \= "V32-TELEBIT"),
  1303.   & (Umodem \= "V42-TELEBIT") & (Umodem \= "VENTEL")
  1304.   THEN DO
  1305.     SAY "'"modem"' is not a valid choice."
  1306.     CALL GETMODEM
  1307.     RETURN
  1308.   END
  1309.  
  1310. SAY "You have chosen '"modem"' as your default modem."
  1311. SAY "Is this correct? (Yes/No):"
  1312.  
  1313. CALL Confirmation
  1314. IF RESULT <> 'Y'
  1315.   THEN DO
  1316.     CALL GETMODEM
  1317.     RETURN
  1318.   END
  1319. RETURN /* GetModem */
  1320.  
  1321. /*******************************************************************/
  1322.  
  1323. GETPORT : PROCEDURE EXPOSE RexxUtils OS2Ver port ;
  1324.  
  1325. SAY ""
  1326. SAY "C-Kermit can work with all valid serial communication devices."
  1327. SAY "ISA and EISA machines support COM1 through COM4."
  1328. SAY "MicroChannel machines support COM1 through COM8."
  1329. SAY "However, most computers have only COM1 and COM2 regardless of"
  1330. SAY "their architecture."
  1331. SAY ""
  1332. SAY "Please choose the communications port to which your" modem "modem is"
  1333. SAY "connected.  Pressing <Enter> by itself selects COM1..."
  1334. IF SUBSTR(OS2Ver, 1, 1 ) > 1
  1335.   THEN CALL CHAROUT ,">"
  1336. PARSE PULL port
  1337.  
  1338. /* Use com1 if nothing was entered */
  1339. IF port = ""
  1340.   THEN port = "com1"
  1341.  
  1342. IF LENGTH( port ) <> 4 | TRANSLATE( SUBSTR( port, 1, 3 ) ) <> "COM",
  1343.   | SUBSTR( port, 4, 1) < 1 | SUBSTR( port, 4, 1 ) > 8
  1344.   THEN DO
  1345.     SAY "'"port"' is not a valid choice."
  1346.     CALL GETPORT
  1347.     RETURN
  1348.   END
  1349.  
  1350. SAY "You have chosen '"port"' as your default communications port."
  1351. SAY "Is this correct? (Yes/No):"
  1352.  
  1353. CALL Confirmation
  1354. IF RESULT <> 'Y'
  1355.   THEN DO
  1356.     CALL GETPORT
  1357.     RETURN
  1358.   END
  1359. RETURN /* GetPort */
  1360.  
  1361. /*******************************************************************/
  1362.  
  1363. GETSPEED : PROCEDURE EXPOSE RexxUtils OS2Ver speed ;
  1364.  
  1365. SAY ""
  1366. SAY "C-Kermit can communicate at all hardware-supported transmission"
  1367. SAY "speeds.  Please select one of the following speeds, measured in"
  1368. SAY "bits per second, as the default speed for port" port || "."
  1369. SAY ""
  1370. SAY "  50    200   2400   9600   57600"
  1371. SAY "  75    300   3600  14400   76800"
  1372. SAY " 110    600   4800  19200  115200"
  1373. SAY " 150   1200   7200  38400        "
  1374. SAY ""
  1375. SAY "Pressing <Enter> by itself selects 9600 bps..."
  1376. IF SUBSTR(OS2Ver, 1, 1 ) > 1
  1377.   THEN CALL CHAROUT ,">"
  1378. PARSE PULL speed
  1379.  
  1380. /* Use 9600 if nothing was entered */
  1381. IF speed = ""
  1382.   THEN speed = "9600"
  1383.  
  1384. IF speed <> "50" & speed <> "75" & speed <> "110" & speed <> "150" ,
  1385.   & speed <> "200" & speed <> "300" & speed <> "600" & speed <> "1200",
  1386.   & speed <> "2400" & speed <> "3600" & speed <> "4800" & speed <> "7200",
  1387.   & speed <> "9600" & speed <> "14400" & speed <> "19200" & speed <> "38400",
  1388.   & speed <> "57600" & speed <> "76800" & speed <> "115200"
  1389.   THEN DO 
  1390.     SAY "'"speed"' is not a valid choice."
  1391.     CALL GETSPEED
  1392.     RETURN
  1393.   END
  1394.  
  1395. SAY "You have chosen '"speed"' as your default transmission speed."
  1396. SAY "Is this correct? (Yes/No):"
  1397.  
  1398. CALL Confirmation
  1399. IF RESULT <> 'Y'
  1400.   THEN DO
  1401.     CALL GETSPEED
  1402.     RETURN
  1403.   END
  1404. RETURN /* GetSpeed */
  1405.  
  1406. /*******************************************************************/
  1407.  
  1408. GETRUNMODE : PROCEDURE EXPOSE RexxUtils OS2Ver runmode ;
  1409.  
  1410. IF SUBSTR( OS2Ver, 1, 1 ) = "2"
  1411.   THEN DO
  1412.     SAY ""
  1413.     SAY "C-Kermit may be run either in a full screen session or in a window."
  1414.     SAY "Full screen sessions are faster, window sessions give you access to"
  1415.     SAY "more OS/2 features, like cut and paste.  Please select either:"
  1416.     SAY ""
  1417.     SAY "  Fullscreen"
  1418.     SAY "  Window"
  1419.     SAY ""
  1420.     SAY "Pressing <Enter> by itself selects Window..."
  1421.     IF SUBSTR(OS2Ver, 1, 1 ) > 1
  1422.       THEN CALL CHAROUT ,">"
  1423.     PARSE PULL runmode
  1424.  
  1425.     /* Run in a window if nothing was entered */
  1426.     IF runmode = ''
  1427.       THEN runmode = "Window"
  1428.  
  1429.     Urunmode = TRANSLATE( runmode )
  1430.     IF Urunmode <> "WINDOW"    & Urunmode <> "W" &,
  1431.       Urunmode <> "FULLSCREEN" & Urunmode <> "F"
  1432.       THEN DO
  1433.         SAY "'"runmode"' is not a valid choice."
  1434.         CALL GETRUNMODE
  1435.         RETURN
  1436.       END
  1437.  
  1438.     IF Urunmode = "W"
  1439.       THEN runmode = "Window"
  1440.  
  1441.     IF Urunmode = "F"
  1442.       THEN runmode = "Fullscreen"
  1443.  
  1444.     SAY "You have chosen to run C-Kermit in a" runmode "session."
  1445.     SAY "Is this correct? (Yes/No):"
  1446.  
  1447.     CALL Confirmation
  1448.     IF RESULT <> 'Y'
  1449.       THEN DO
  1450.         CALL GETRUNMODE
  1451.         RETURN
  1452.       END
  1453.     SAY ""
  1454.   END
  1455. RETURN /* GetRunMode */
  1456.  
  1457. /*******************************************************************/
  1458.  
  1459. UnableToCompleteInstallation : PROCEDURE EXPOSE startdir ;
  1460.  
  1461. rc = Directory( startdir )
  1462. SAY ""
  1463. SAY "The above error has prevented the successful completion of the"
  1464. SAY "C-Kermit Installation routine.  Please take corrective actions"
  1465. SAY "and retry this operation."
  1466. SAY ""
  1467. EXIT
  1468. RETURN /* UnableToCompleteInstallation */
  1469.  
  1470. /*******************************************************************/
  1471.  
  1472. InstallSerialSupport : PROCEDURE EXPOSE OS2Ver ;
  1473.  
  1474. retval = 0 
  1475. IF \ARG(1)
  1476.   THEN retval = 1
  1477.   ELSE DO
  1478.     SAY "IBM TCP/IP is installed on this machine, and C-Kermit will be"  
  1479.     SAY "configured to use it.  Do you also wish to use C-Kermit for serial"
  1480.     SAY "communications via modems or direct serial-port connections?"
  1481.     SAY "(Yes/No): "
  1482.     IF Confirmation() = 'Y'
  1483.       THEN retval = 1
  1484.     
  1485.     SAY ""
  1486.   END
  1487. RETURN retval /* InstallSerialSupport */
  1488.  
  1489. /*******************************************************************/
  1490.  
  1491. InstallVT220KeyMap : PROCEDURE ;
  1492.  
  1493. retval = 0 
  1494.   SAY "Do you want full VT220 terminal key mappings installed? (Yes/No): "
  1495.   IF Confirmation() = 'Y'
  1496.     THEN retval = 1
  1497.   SAY ""
  1498. RETURN retval /* InstallVT220KeyMap */
  1499.  
  1500. /*******************************************************************/
  1501.  
  1502. FileExists : PROCEDURE EXPOSE RexxUtils ;
  1503. Retval = 0
  1504. IF RexxUtils
  1505.   THEN DO
  1506.     CALL SysFileTree ARG(1), "file", "FO"
  1507.     IF file.0 > 0
  1508.       THEN Retval = 1
  1509.     END
  1510.   ELSE DO
  1511.     CALL STREAM ARG(1), 'c', 'query exists'
  1512.     IF "\"RESULT <> "\"
  1513.       THEN Retval = 1
  1514.     END 
  1515. RETURN Retval
  1516.  
  1517. /*******************************************************************/
  1518.  
  1519. Failure : PROCEDURE
  1520.  
  1521. SAY "C-Kermit Installation has failed. :-(" 
  1522. SAY "" 
  1523. SAY "The installation process has encountered an error which prevents it"
  1524. SAY "from installing one or more files.  Possible causes are: "
  1525. SAY "   (1) the source file is missing;"
  1526. SAY "   (2) the destination filename already exists and is marked"
  1527. SAY "       read-only or system; or"
  1528. SAY "   (3) the destination filename is an EXE or DLL and is currently"
  1529. SAY "       in use by an active application."
  1530. SAY ""
  1531. SAY "Please take corrective actions and reexecute the installation procedure."
  1532. EXIT 
  1533. RETURN 
  1534.  
  1535. /* End OS/2 C-Kermit INSTALL.CMD */
  1536.