home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / ckc190.zip / ckoins.cmd < prev    next >
OS/2 REXX Batch file  |  1994-10-26  |  52KB  |  1,607 lines

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