home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / wininst.zip / WINSTALL.CMD < prev   
OS/2 REXX Batch file  |  1996-08-09  |  37KB  |  796 lines

  1. /* ╔═════════════════════════════════════════════════════════════╗ */
  2. /* ║    !!! DO NOT MODIFY THIS FILE UNDER ANY CIRCUMSTANCES !!!  ║ */
  3. /* ╚═════════════════════════════════════════════════════════════╝ */
  4. /* ┌─────────────────────────────────────────────────────────────┐ */
  5. /* │                Adding WINOS2 Audio Support                  │ */
  6. /* ├─────────────────────────────────────────────────────────────┤ */
  7. /* │                                                             │ */
  8. /* │ This REXX program installs the WIN-OS2 audio support        │ */
  9. /* │ for the following current OS/2-supported audio adapters:    │ */
  10. /* │                                                             │ */
  11. /* │        -   The IBM M-Audio Adapter                          │ */
  12. /* │        -   The Sound Blaster Non-Pro ISA or MCV Adapter     │ */
  13. /* │        -   The Sound Blaster Pro OPL2 Adapter               │ */
  14. /* │        -   The Sound Blaster Pro MCV or OPL3 Adapter        │ */
  15. /* │        -   The Sound Blaster 16 / PnP                       │ */
  16. /* │        -   The Pro Audio Spectrum 16                        │ */
  17. /* │        -   The Media Vision Jazz 16 Adapter                 │ */
  18. /* │        -   The Aztech Sound Galaxy NOVA 16 EXTRA            │ */
  19. /* │        -   The Aztech Sound Galaxy Wave 32 +                │ */
  20. /* │        -   The ESS-688 Audio Adapter                        │ */
  21. /* │        -   The ESS-1688 Audio Adapter                       │ */
  22. /* │        -   The ESS-1788 Audio Adapter                       │ */
  23. /* │        -   The ESS-1868 Audio Adapter                       │ */
  24. /* │        -   The ESS-1888 Audio Adapter                       │ */
  25. /* │        -   The Sound Blaster AME 32 Adapter / PnP           │ */
  26. /* │        -   The Crystal Semi CS4231 Adapter                  │ */
  27. /* │        -   The Crystal Semi CS4232/4236 PnP Adapter         │ */
  28. /* │        -   The IBM Thinkpad Audio - Crystal Semi 4231       │ */
  29. /* │                                                             │ */
  30. /* │ Usage:                                                      │ */
  31. /* │        At an OS/2 prompt, type:                             │ */
  32. /* │                                                             │ */
  33. /* │            WINSTALL                                         │ */
  34. /* │                                                             │ */
  35. /* │                                                             │ */
  36. /* │ (C) Copyright International Business Machines Corp.  1996   │ */
  37. /* └─────────────────────────────────────────────────────────────┘ */
  38.  
  39. '@echo off'
  40. trace 'o'
  41. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  42. call SysLoadFuncs
  43.  
  44. call SysCls
  45. say
  46. say '  ╔═════════════════════════════════════════════════════════════╗'
  47. say '  ║                                                             ║'
  48. say '  ║    Updating WIN-OS2 system files now.  Please wait ...      ║'
  49. say '  ║                                                             ║'
  50. say '  ╚═════════════════════════════════════════════════════════════╝'
  51.  
  52.  
  53. /*******************************************************************/
  54. /*                                                                 */
  55. /*   Get the BOOTDRIVE of OS/2 using environment variable PATH     */
  56. /*   All files to be modified will be on this BOOTDRIVE            */
  57. /*                                                                 */
  58. /*******************************************************************/
  59.  
  60. BootDrvSpec = SysSearchPath('PATH', 'CMD.EXE')
  61. OSDrvCheck  = SysSearchPath('PATH', 'OS2KRNL')
  62. if (BootDrvSpec = '') then
  63.         call NON_OS2_PARTITION_ERROR
  64. if (OSDrvCheck = '') then
  65.         call NON_OS2_PARTITION_ERROR
  66.  
  67.               /* if reached here, boot drive is an OS/2 partition */
  68. BootDrv = left(OSDrvCheck, 2)
  69.  
  70. /*******************************************************************/
  71. /*                                                                 */
  72. /*   Check whether WINOS2 is installed; if yes, is SYSTEM.INI file */
  73. /*   there?  This file is essential for WINOS2 audio to work       */
  74. /*                                                                 */
  75. /*******************************************************************/
  76.  
  77. WinOS2Check = SysSearchPath('PATH', 'SYSTEM.INI')
  78. if (WinOS2Check = '') then
  79. do
  80.         call SysFileTree BootDrv||'\OS2\MDOS\WINOS2\SYSTEM.INI', ini_check, 'F'
  81.         if ini_check.0 = 0 then
  82.                 call NO_WINOS2_INSTALLED_ERROR
  83. end
  84.  
  85. /*******************************************************************/
  86. /*                                                                 */
  87. /*   "Auto-detect' the WinOS2 audio driver by looking in the       */
  88. /*   \OS2\DRIVERS directory;                                       */
  89. /*                                                                 */
  90. /*       . if more than one driver found, we will install the      */
  91. /*         default audio device currently set in MMPM2.INI;        */
  92. /*       . if none found, exit with error message;                 */
  93. /*       . if one found, go ahead install it;                      */
  94. /*                                                                 */
  95. /*******************************************************************/
  96.  
  97. DefaultFound = 0
  98. WinDriverList = BootDrv||'\OS2\DRIVERS\*.'
  99. call SysFileTree WinDriverList, WinDrivers, 'OD'
  100.  
  101.             /* if no Windows driver found, exit with error message */
  102.  
  103. if WinDrivers.0 = 0 then
  104.         call NO_WIN_DRIVERS_ERROR
  105.  
  106. WinDriver = WinDrivers.1
  107.  
  108.  
  109.             /* if more than one driver found, install the          */
  110.             /* OS2-default audio device found in MMPM2.INI         */
  111.  
  112. if WinDrivers.0 > 1 then             /* more than one device found */
  113. do
  114.   do i=1 to WinDrivers.0
  115.         call IsDefault WinDrivers.i
  116.         if result = 1 then
  117.           do
  118.                 WinDriver = WinDrivers.i
  119.                 i = WinDrivers.0 + 1    /* done do loop */
  120.                 DefaultFound = 1
  121.           end
  122.   end
  123.  
  124.   if (DefaultFound <> 1) then           /* no OS2 audio installed           */
  125.     do                                  /* but WINOS2 audio will still work */
  126.                                         /* list the choices to user         */
  127.         say
  128.         say '     ┌─────────────────────────────────────────────────────────────┐'
  129.         say '     │                                                             │'
  130.         say '     │    No corresponding OS/2 audio driver detected on your      │'
  131.         say '     │    system; you can however still install WINOS2 driver.     │'
  132.         say '     │                                                             │'
  133.         say '     │    Please select one audio device from the following list:  │'
  134.         say '     │                                                             │'
  135.         say '     └─────────────────────────────────────────────────────────────┘'
  136.         say
  137.         do k = 1 to WinDrivers.0
  138.                 parse value WinDrivers.k with '\OS2\DRIVERS\' WinDriver_o
  139.                 say '            Device ' k '= ' WinDriver_o
  140.         end
  141.         say
  142.         say '           Select a device by typing in the number:'
  143.         pull n
  144.         do while ((n > WinDrivers.0) | (n < 1))
  145.                 say '          Select a valid number listed:'
  146.                 pull n
  147.         end
  148.         WinDriver = WinDrivers.n
  149.     end
  150. end /* if WinDrivers.0 */
  151.  
  152.  
  153. /*******************************************************************/
  154. /*                                                                 */
  155. /*    If only one audio device found, fall through here ...        */
  156. /*    At this point, we got WinDriver, which is also the name of   */
  157. /*    the .ctl file; for example, WinDriver = es1688dd, then we    */
  158. /*    expect a file es1688dd.ctl in the \OS2\DRIVERS\ES1688DD dir  */
  159. /*                                                                 */
  160. /*    We also know:                                                */
  161. /*                                                                 */
  162. /*      .  the .ctl file exists;                                   */
  163. /*      .  it is a valid file for this audio device;               */
  164. /*      .  source directory where to copy the WIN-OS2 drivers from */
  165. /*      .  Boot drive: BootDrv                                     */
  166. /*                                                                 */
  167. /*    Start parsing the .ctl file here; error handling done here   */
  168. /*                                                                 */
  169. /*******************************************************************/
  170.  
  171.                                    /* Get all the global variables */
  172.  
  173. parse value WinDriver with '\OS2\DRIVERS\' win_driver
  174. control_file = WinDriver||'\'||win_driver||'.ctl'
  175. call SysFileTree control_file, ctl_check, 'F'
  176. if ctl_check.0 = 0 then
  177.         call FILE_NOT_EXISTENT_OUTPUT control_file
  178.  
  179. /* say 'copying control file ' control_file */
  180. copy control_file WinDriver||'\'||win_driver||'.JUK'
  181. control_file2 = WinDriver||'\'||win_driver||'.JUK'      /* for a subroutine                 */
  182. TargetDir     = BootDrv||'\OS2\MDOS\WINOS2\SYSTEM\'     /* official place to put the driver */
  183. IniFileDir    = BootDrv||'\OS2\MDOS\WINOS2\'            /* where system.ini is              */
  184. copy IniFileDir||'system.ini' IniFileDir||'system.org > NUL' /* back up system.ini          */
  185. copy IniFileDir||'system.ini' IniFileDir||'system.bak > NUL' /* back up system.ini          */
  186. copy IniFileDir||'system.ini' IniFileDir||'system.juk > NUL' /* temp system.ini for source  */
  187.  
  188. /*******************************************************************/
  189. /*                                                                 */
  190. /*   From the .ctl file, get the names of driver files to be       */
  191. /*   copied and copy them from the source directory to the target  */
  192. /*   directory; exit if any of those files do not exist; WINOS2    */
  193. /*   audio will not work if these files are missing                */
  194. /*                                                                 */
  195. /*******************************************************************/
  196.  
  197.                     /* Get [COPIED_FILES] section in the .ctl file */
  198.  
  199. call SysFileSearch '[COPIED_FILES]', control_file, 'DrvFiles.', 'N'
  200. if DrvFiles.0 = 0 then
  201.         call CONTROL_FILE_ERROR_OUTPUT control_file
  202. else
  203.         parse value DrvFiles.1 with startline ' '
  204.  
  205. do startline
  206.         line = linein(control_file)     /* brings to the first line  */
  207.                                         /* of [COPIED_FILES] section */
  208. end
  209. line = linein(control_file)
  210. parse value line with '"' NumFiles '"'  /* parse out number of files */
  211.  
  212. do i = 1 to NumFiles                    /* parse out the files and   */
  213.         line = linein(control_file)     /* copy them; check errors   */
  214.         parse value line with '"' DriverFile '"' '"' CopyToDir '"'
  215.         call SysFileTree WinDriver||'\'||DriverFile, 'check', 'FSO'     /* 'FSO' works best  */
  216.         if (check.0 = 0) then                                           /* with copy command */
  217.                 call FILE_NOT_EXISTENT_OUTPUT DriverFile
  218.         copy check.1 BootDrv||CopyToDir' > NUL'
  219. end
  220.  
  221.  
  222. /*******************************************************************/
  223. /*                                                                 */
  224. /*   Get [MODIFY] section and start modifying the .INI file(s)     */
  225. /*   under the \OS2\MDOS\WINOS2 directory                          */
  226. /*                                                                 */
  227. /*******************************************************************/
  228.  
  229. call lineout(control_file)         /* close it to reset all values */
  230. call SysFileSearch '[MODIFY]', control_file, 'Modify.', 'N'
  231. if Modify.0 = 0 then
  232.         call CONTROL_FILE_ERROR_OUTPUT control_file
  233. else
  234.         parse value Modify.1 with startline ' '
  235.  
  236. do startline
  237.         line = linein(control_file)     /* brings to the first line  */
  238.                                         /* of that section           */
  239. end
  240. line = linein(control_file)
  241. parse value line with '"' num_files_modify '"'
  242.  
  243.  
  244. /*******************************************************************/
  245. /*                                                                 */
  246. /*    The following section contains nested loops.  The basic      */
  247. /*    structure is as follows:                                     */
  248. /*                                                                 */
  249. /*    Number of FILES to be modified                               */
  250. /*      Number of SECTIONS in each FILE to be modified/created     */
  251. /*        Number of LINES in each SECTION to be added              */
  252. /*        end                                                      */
  253. /*      end                                                        */
  254. /*    end                                                          */
  255. /*                                                                 */
  256. /*******************************************************************/
  257.  
  258. do nth =1 to num_files_modify
  259.  
  260.      /* need to go to the line describing how to modify 'nth' file */
  261.   cur_file = 0
  262.   call lineout(control_file)        /* close it if opened to reset */
  263.   do while cur_file <> nth
  264.         line = linein(control_file)
  265.         parse value line with '"' NumSections '"' '"' file_path '"' '"' file_name '"' '"<FILE' cur_file '>"'
  266.  
  267.   end
  268.   /*
  269.         say 'File #' cur_file 'Numsections = ' NumSections
  270.         say 'File #' cur_file 'Filepath    = ' BootDrv||file_path
  271.         say 'File #' cur_file 'FileName    = ' file_name
  272.   */
  273.                                /* make a backup of this file first */
  274.   say
  275.   say ' Backing up file: ' file_name ' ...'
  276.   parse value file_name with prefix '.' junk
  277.   copy BootDrv||file_path||'\'||file_name BootDrv||file_path||'\'||prefix||'.org > NUL'
  278.   copy BootDrv||file_path||'\'||file_name BootDrv||file_path||'\'||prefix||'.juk > NUL'
  279.  
  280.  
  281.   /******************************************************/
  282.   /*   Modify the sections now in file gotten above     */
  283.   /******************************************************/
  284.  
  285.   original_file = BootDrv||file_path||'\'||prefix||'.juk'
  286.   modified_file = BootDrv||file_path||'\'||file_name
  287.  
  288.   do i = 1 to NumSections                    /* parse out the lines which  */
  289.         Current = 0                          /* to put in the system.ini   */
  290.         current_file = 0
  291.         call lineout modified_file,,1        /* open; set at 1             */
  292.         do while (Current <> i & current_file <> nth)     /* Skip non-related lines */
  293.                 line = linein(control_file)
  294.                 parse value line with '"' Current '"' '"[' SectionName ']"' '"<FILE' current_file '>"'
  295.         end
  296.         line = linein(control_file)
  297.         parse value line with '"' NumLines '"'
  298.         call SysFileSearch '['SectionName']', original_file, 'iniSection.', 'N'
  299.         if iniSection.0 = 0 then
  300.           do
  301.                 call lineout(modified_file)
  302.                 insertThis = ' '
  303.                 call lineout modified_file, insertThis
  304.                 insertThis = '['SectionName']'
  305.                 call lineout modified_file, insertThis
  306.                 do while (lines(original_file) <> 0)
  307.                    junk = linein(original_file)
  308.                 end          /* force to be at the end of ini file */
  309.                              /* New section will be added at end   */
  310.           end
  311.         else
  312.           do
  313.                 parse value iniSection.1 with startline ' '
  314.                 do startline                            /* write from beginning to */
  315.                     iniLine = Linein(original_file)     /* insertion point         */
  316.                     call lineout modified_file, iniLine
  317.                 end
  318.           end
  319.         do j = 1 to NumLines            /* ready to insert additional lines */
  320.                 line = linein(control_file)
  321.                 parse value line with '"' insertThis '"'
  322.  
  323.                 /* check if this line needs value parsed from config.sys */
  324.                 /* The .ctl file tells which parameter to parse          */
  325.  
  326.                 parse value insertThis with junk '=' test_param
  327.                 if (left(test_param, 1) = '*') then     /* need setting from config.sys */
  328.                   do
  329.                         /* get default value now */
  330.                         parse value line with '"' replace_line '"' '"' default_val '"'
  331.                         parse value replace_line with left_part '=*' param_name '*'
  332.                         new_value = default_val
  333.                         call GetOS2ParamValue control_file2||'=='||param_name        /* result will have the value */
  334.                         if (result = -1) then   /* nothing found in config.sys */
  335.                                 nop             /* do nothing, so use default  */
  336.                         else
  337.                                 new_value = result
  338.                         insertThis = left_part||'='||new_value
  339.                   end
  340.                 call lineout modified_file, insertThis
  341.         end
  342.  
  343.         do while (lines(original_file) <> 0)       /* finish writing the rest section */
  344.                 iniLine = linein(original_file)
  345.                 call lineout modified_file, iniLine
  346.         end
  347.  
  348.         call lineout(modified_file)    /* closes files so sys calls */
  349.         call lineout(original_file)    /* can re-new values         */
  350.         copy modified_file BootDrv||file_path||'\'||prefix||'.juk > NUL' /* back up file modified so far */
  351.   end
  352.  
  353.   /* cleaning up .juk files */
  354.   call SysFileDelete original_file
  355.   backed_up = BootDrv||file_path||'\'||prefix||'.org'
  356.   say
  357. /*  say '  File 'original_file' is updated successfully.' */
  358.   say '  File 'file_name' is updated successfully.'
  359.   say '  Original version is backed up to 'backed_up'.'
  360.   say
  361.  
  362. end /* of do loop for number of files */
  363.  
  364. /*******************************************************************/
  365. /*                                                                 */
  366. /*   Get [WINOS2_SETTINGS] section and start modifying WINOS2      */
  367. /*   settings.                                                     */
  368. /*                                                                 */
  369. /*******************************************************************/
  370.  
  371. call lineout(control_file)         /* close it to reset all values */
  372. call SysFileSearch '[WINOS2_SETTINGS]', control_file, 'winos2.', 'N'
  373. if winos2.0 = 0 then
  374.         call CONTROL_FILE_ERROR_OUTPUT control_file
  375. else
  376.         parse value winos2.1 with startline ' '
  377.  
  378. do startline
  379.         line = linein(control_file)     /* brings to the first line  */
  380.                                         /* of that section           */
  381. end
  382. line = linein(control_file)
  383. parse value line with '"' num_settings_modify '"'
  384. do j=1 to num_settings_modify
  385.         line = linein(control_file)     /* get one setting each time */
  386.         parse value line with '"' current_setting '"'
  387.         call UPDATE_WIN_OS2_SETTINGS current_setting
  388. end
  389.  
  390.  
  391.  
  392. /*******************************************************************/
  393. /*                                                                 */
  394. /*   Get [SPECIAL_SETTINGS] section and start modifying WINOS2 or  */
  395. /*   DOS_DEVICE settings in which values may need to be parsed from*/
  396. /*   OS/2's config.sys file.                                       */
  397. /*                                                                 */
  398. /*******************************************************************/
  399.  
  400. call lineout(control_file)         /* close it to reset all values */
  401. call SysFileSearch '[SPECIAL_SETTINGS]', control_file, 'special.', 'N'
  402. if special.0 = 0 then
  403.         nop             /* if this section does not exist, do nothing */
  404. else
  405.   do
  406.         parse value special.1 with startline ' '
  407.  
  408.         do startline
  409.             line = linein(control_file)     /* brings to the first line  */
  410.                                             /* of that section           */
  411.         end
  412.         line = linein(control_file)
  413.         parse value line with '"' num_special_modify '"'
  414.         do j=1 to num_special_modify
  415.           line = linein(control_file)     /* get one setting each time */
  416.  
  417.           /* start reconstructing a new line with parsed values */
  418.           parse value line with '"' num_parsed '"' '"' String '"'
  419.           leftover = String
  420.           new_string = ''
  421.           do i=1 to num_parsed
  422.             parse value leftover with prefix '*' var_name '*' '<' default '>' leftover
  423.             /* get default value now */
  424.             var_value = default
  425.             if compare(var_name, 'BOOTDRV') = 0 then    /* special case */
  426.                 var_value = BootDrv
  427.             else
  428.               do
  429.                 call GetOS2ParamValue control_file2||'=='||var_name        /* result will have the value */
  430.                 if (result = -1) then   /* nothing found in config.sys */
  431.                         nop             /* do nothing, so use default  */
  432.                 else
  433.                         var_value = result
  434.               end /* else */
  435.  
  436.             /* keep appending finished values -- reconstructing String */
  437.             new_string = new_string||prefix||var_value
  438.           end /* do i=1 */
  439.           new_string = new_string||leftover     /* get trailing stuff */
  440.           call UPDATE_WIN_OS2_SETTINGS new_string
  441.         end /* num_special_modify */
  442.   end /* else */
  443.  
  444.  
  445. /*******************************************************************/
  446. /*                                                                 */
  447. /*   Cleaning up ...                                               */
  448. /*                                                                 */
  449. /*******************************************************************/
  450.  
  451. call SysFileDelete control_file2
  452. say
  453. say '  ╔═════════════════════════════════════════════════════════════╗'
  454. say '  ║                                                             ║'
  455. say '  ║    WINOS2 Audio is updated successfully.                    ║'
  456. say '  ║    To get WINOS2 sound, switch to a WIN-OS2 Session now.    ║'
  457. say '  ║                                                             ║'
  458. say '  ╚═════════════════════════════════════════════════════════════╝'
  459. say
  460. exit
  461.  
  462.  
  463.  
  464. /*******************************************************************/
  465. /*                                                                 */
  466. /*   Procedures called by the main program above                   */
  467. /*                                                                 */
  468. /*******************************************************************/
  469.  
  470. CONTROL_FILE_ERROR_OUTPUT: PROCEDURE
  471. do
  472.         arg control_file
  473.         say
  474.         say 'Error: file 'control_file' contains invalid formats;'
  475.         say '       Install cannot proceed without a valid control file.'
  476.         exit
  477. end
  478.  
  479. FILE_NOT_EXISTENT_OUTPUT: procedure
  480. do
  481.         arg FileName
  482.         say
  483.         say 'Error: file 'FileName' does not exist on your system;'
  484.         say '       In order to install WIN-OS2 audio, you must have'
  485.         say '       this file.'
  486.         say
  487.         say 'Suggestion: Use Selective Install to install the corresponding'
  488.         say '            OS/2 driver for your audio device.'
  489.         say
  490.         exit
  491. end
  492.  
  493. UPDATE_WIN_OS2_SETTINGS: PROCEDURE
  494. do
  495.         arg new_setting
  496.         /* say '::UPDATE_WIN_OS2..., param passed in is ' new_setting */
  497.         call SysSetObjectData '<WP_WINFS>',   new_setting
  498.         call SysSetObjectData '<WP_WIN2WIN>', new_setting
  499.         return
  500. end
  501.  
  502. NON_OS2_PARTITION_ERROR: PROCEDURE
  503. do
  504.         say
  505.         say 'ERROR: Either OS/2 is not running, or this program is not running'
  506.         say 'from an OS/2 Window.  Please run this command from an OS/2 window.'
  507.         say
  508.         exit
  509. end
  510.  
  511. NO_WINOS2_INSTALLED_ERROR: PROCEDURE
  512. do
  513.         say
  514.         say 'ERROR: WIN-OS2 is not installed in your system.'
  515.         say 'If you have WARP Full Pack, use Selective Install to'
  516.         say 'install WIN-OS2.  Then, try this program.'
  517.         say
  518.         exit
  519. end
  520.  
  521. NO_WIN_DRIVERS_ERROR: PROCEDURE
  522. do
  523.         say
  524.         say 'Error: No valid drivers found under \OS2\DRIVERS directory;'
  525.         say '       In order to install WIN-OS2 audio, you must have'
  526.         say '       driver files which reside under a particular diectory.'
  527.         say
  528.         say 'Suggestion: Use Selective Install to install the corresponding'
  529.         say '            OS/2 driver for your audio device.'
  530.         say
  531.         exit
  532. end
  533.  
  534.  
  535. /*******************************************************************/
  536. /*                                                                 */
  537. /*   PROCEDURE: IsDefault                                          */
  538. /*                                                                 */
  539. /*              Check to see if driver name passed in is a default */
  540. /*              OS/2 device; we need the settings such as port     */
  541. /*              address, interrupt level, etc. from the OS/2 driver*/
  542. /*              if it is default, then return 1 (true); if not,    */
  543. /*              return 0 (false).                                  */
  544. /*                                                                 */
  545. /*   Input    : Driver name.  For example, ES1688DD.SYS            */
  546. /*   Output   : 1 if yes; 0 if no                                  */
  547. /*                                                                 */
  548. /*******************************************************************/
  549.  
  550. IsDefault: PROCEDURE
  551. do
  552.         arg DriverPathName
  553.         call CheckControlFile DriverPathName     /* if exists, return; otherwise, exit */
  554.         BootDrv = left(DriverPathName, 2)
  555.         parse value DriverPathName with '\OS2\DRIVERS\' control_file
  556.         control_file = DriverPathName||'\'||control_file||'.CTL'
  557.  
  558.         call SysFileTree control_file, ctl_check, 'F'
  559.         if ctl_check.0 = 0 then
  560.                 call FILE_NOT_EXISTENT_OUTPUT
  561.  
  562.         call SysFileSearch '[PDD_INFO]', control_file, 'params.', 'N'
  563.         if DrvFiles.0 = 0 then
  564.                 call CONTROL_FILE_ERROR_OUTPUT
  565.         else
  566.                 parse value params.1 with startline ' '
  567.  
  568.         /* say '::IsDefault, startline for [PDD_INFO] = ' startline */
  569.         do startline
  570.                 line = linein(control_file)     /* brings to the first line  */
  571.                                                 /* of [PDD_INFO] section */
  572.         end
  573.         line = linein(control_file)
  574.         parse upper value line with '"' pdd_name '"'
  575.         /* say '::IsDefault, line starts with OS/2 audio driver:' pdd_name */
  576.         line = linein(control_file)            /* get number of params */
  577.         parse upper value line with '"' vdd_name '"'
  578.         line = linein(control_file)
  579.         parse value line with '"' num_params '"'
  580.  
  581.         /* with pdd_name and vdd_name, it is sufficient to find out default  */
  582.         /* OS/2 audio device; search for [defaultnames] section in MMPM2.INI */
  583.  
  584.  
  585. /*?*/
  586.         call lineout(BootDrv||'\MMOS2\MMPM2.INI')    /* close mmpm2.ini for later search */
  587.  
  588.  
  589.  
  590.         call SysFileSearch '[defaultnames]', BootDrv||'\MMOS2\MMPM2.INI', 'd_names.', 'N'
  591.         if d_names.0 = 0 then
  592.         do
  593.                 call lineout(control_file)     /* close file if opened       */
  594.                 return 1                       /* none or 1 device installed */
  595.         end
  596.         parse value d_names.1 with startline ' ' junk
  597.         do startline
  598.                 line = linein(BootDrv||'\MMOS2\MMPM2.INI')
  599.         end
  600.  
  601.         w_word = ' '
  602.         count = 0
  603.         do while (compare('WAVEAUDIO', w_word, ' ') & count < 10)
  604.                 line = linein(BootDrv||'\MMOS2\MMPM2.INI')
  605.                 parse upper value line with w_word '=' wave_device
  606.                 w_word = right(w_word, 9)       /* forget blanks */
  607.                 count = count + 1               /* if mmpm2.ini is corrupted */
  608.                                                 /* this will stop infinite loop */
  609.         end
  610.  
  611.         call lineout(BootDrv||'\MMOS2\MMPM2.INI')    /* close mmpm2.ini for later search */
  612.                                                      /* VERY IMPORTANT!!                  */
  613.         call SysFileSearch '['||wave_device||']', BootDrv||'\MMOS2\MMPM2.INI', 'waveaudio.', 'N'
  614.         if ( waveaudio.0 = 0) then
  615.                 call MMPM2_CORRUPTED_ERROR
  616.         /* say 'waveaudio section found = ' waveaudio.1 */
  617.         parse value waveaudio.1 with startline ' '
  618.         do startline
  619.                 line = linein(BootDrv||'\MMOS2\MMPM2.INI')
  620.         end
  621.  
  622.         pdd_word = ''
  623.         count = 0
  624.         do while (compare(pdd_word, 'PDDNAME') & count < 50)
  625.                 line = linein(BootDrv||'\MMOS2\MMPM2.INI')
  626.                 parse upper value line with pdd_word '=' pdd_name_ini
  627.                 pdd_word = right(pdd_word, 7)   /* need just PDDNAME */
  628.                 count = count + 1               /* if mmpm2.ini is corrupted, stop at 50 lines */
  629.         end
  630.         if (compare(pdd_name_ini, vdd_name) <> 0) then
  631.           do
  632.                 call lineout(control_file)      /* close file before return */
  633.                 return 0
  634.           end
  635.         else
  636.           do
  637.                 call lineout(control_file)      /* close file before return */
  638.                 return 1
  639.           end
  640.  
  641. end /* IsDefault */
  642.  
  643.  
  644. /*******************************************************************/
  645. /*                                                                 */
  646. /*   Procedure : CheckControlFile                                  */
  647. /*                                                                 */
  648. /*               Check the existence of the WIN-OS2 driver passed  */
  649. /*               in by checking the corresponding directories      */
  650. /*               under \OS2\DRIVERS\. The directory name is the    */
  651. /*               name of the control file with extension .ctl.     */
  652. /*               For example, for ES1688DD, the control file is    */
  653. /*               es1688dd.ctl.                                     */
  654. /*                                                                 */
  655. /*   Input     : Directory name for the WIN-OS2 audio driver       */
  656. /*   Output    : just return if found; exit if not there           */
  657. /*                                                                 */
  658. /*******************************************************************/
  659.  
  660. CheckControlFile: PROCEDURE
  661. do
  662.  
  663.   arg WinDriverDir
  664.  
  665.   /* is the .ctl file there? */
  666.  
  667.   parse value WinDriverDir with '\OS2\DRIVERS\' WinDriver
  668.   call SysFileTree WinDriverDir||'\'||WinDriver||'.CTL', control_file, 'FS'
  669.   if  control_file.0 = 0  then
  670.     do
  671.         say
  672.         say 'Error: 'WinDriver'.CTL does not exist.'
  673.         say 'This file is essential for installing this WIN-OS2 driver.'
  674.         say
  675.         say 'Suggestion: Selective Install the corresponding OS/2 driver.'
  676.         say
  677.         exit
  678.     end
  679.   else /* .ctl file found */
  680.         return
  681. end /* of CheckControlFile */
  682.  
  683.  
  684. MMPM2_CORRUPTED_ERROR: PROCEDURE
  685. do
  686.         say
  687.         say 'ERROR: MMPM2.INI file may be corrupted;'
  688.         say '       Please re-install Multimedia.'
  689.         say
  690.         exit
  691. end
  692.  
  693.  
  694. /*******************************************************************/
  695. /*                                                                 */
  696. /*   Procedure : GetOS2ParamValue                                  */
  697. /*                                                                 */
  698. /*               Use parameter name, such as /A:, to search the    */
  699. /*               config.sys file to find out its setting, such as  */
  700. /*               240.  If no lettered parameter passed, it is      */
  701. /*               positional, meaning 1 for 1st parameter that      */
  702. /*               follow the DEVICE line.                           */
  703. /*                                                                 */
  704. /*   Input     : Packed information: control file location and     */
  705. /*               the name of the parameter.                        */
  706. /*                                                                 */
  707. /*   Output    : -1 if no valid value found; the value if valid.   */
  708. /*                                                                 */
  709. /*******************************************************************/
  710.  
  711. GetOS2ParamValue: PROCEDURE
  712. do
  713.         arg packed_info
  714.         parse value packed_info with control_file '==' param_name
  715.         /* say '::GetOS2ParamValue, control_file is = ' control_file */
  716.         BootDrv = left(control_file, 2)
  717.         config_sys = BootDrv||'\'||CONFIG.SYS
  718.         call SysFileSearch param_name, control_file, 'file.'
  719.         if (file.0 = 0) then
  720.           do
  721.                 say
  722.                 say 'Error in the control file.'
  723.                 say 'Please check the [PDD_INFO] section and [MODIFY] section'
  724.                 sya 'in 'control_file'.'
  725.                 call lineout(control_file)      /* close file before return */
  726.                 return -1                       /* junk value, will be checked upon return */
  727.           end
  728.         parse value file.1 with '"' param_letter '"' '"' junk '"'
  729.  
  730.         /* get PDD name from the .ctl file */
  731.         /* it is used to search in config.sys */
  732.  
  733.         call SysFileSearch '[PDD_INFO]', control_file, 'pdd_info.', 'N'
  734.         if (pdd_info.0 = 0) then
  735.                 call CONTROL_FILE_ERROR_OUTPUT
  736.         else
  737.                 parse value pdd_info.1 with startline ' '
  738.  
  739.         do startline
  740.                 line = linein(control_file)     /* brings to the first line  */
  741.         end                                   /* of [PDD_INFO] section     */
  742.         line = linein(control_file)
  743.         parse value line with '"' pdd_sys '"'
  744.  
  745.         call SysFileSearch pdd_sys, config_sys, 'sys_line.', 'N'
  746.         if (sys_line.0 = 0) then      /* no DEVICE line found for pdd_sys */
  747.           do
  748.                 call lineout(control_file)
  749.                 return -1
  750.           end
  751.  
  752.         /* add REM line checking here if desired */
  753.  
  754.  
  755.         /* is parameter without a letter-indicator? */
  756.         /* if yes, it is positional.                */
  757.  
  758.         if (verify(param_letter, '1234567890') = 0) then   /* no param letter */
  759.         do                                                 /* only ith param  */
  760.           parse value sys_line.1 with getrid1 ':' getrid2 ' ' left_over
  761.           do while (left(left_over, 1) = ' ')
  762.             parse value left_over with getrid ' ' left_over
  763.           end
  764.           do n=1 to param_letter-1
  765.             parse value left_over with getrid ' ' left_over
  766.             do while (left(left_over, 1) = ' ') /* get rid of leading blanks */
  767.               parse value left_over with ' ' left_over
  768.             end
  769.           end /* do n=1 to param_letter */
  770.           parse value left_over with param_value ' ' throw_away
  771.           call lineout(control_file)    /* close before return */
  772.           return param_value
  773.         end /* if (verify...) */
  774.  
  775.         /* otherwise, search for the letter parameter indicator */
  776.  
  777.         parse value sys_line.1 with junk1 ':' junk2 ' ' rest_line
  778.         do while (left(rest_line, 1) = ' ')     /* get rid of leading blanks */
  779.           parse value rest_line with ' ' rest_line
  780.         end
  781.         do while (left(rest_line, length(param_letter)) <> param_letter)
  782.           parse value rest_line with junk ' ' rest_line
  783.           do while (left(rest_line, 1) = ' ')     /* get rid of leading blanks */
  784.             parse value rest_line with ' ' rest_line
  785.           end
  786.         end /* do while (left(rest_line... */
  787.  
  788.         /* found the parameter that we want */
  789.         rest_line = right(rest_line, length(rest_line) - length(param_letter))
  790.         parse value rest_line with param_value ' ' throw_away
  791.         call lineout(control_file)
  792.         return param_value
  793. end
  794.  
  795. /* last modified 7/17/96 */
  796.