/* Copyright (c) Oracle Corporation 1995.  All Rights Reserved */
/*****************************************************************************
  NAME
    rsf73.ins - WinNT V3 installation script for ORACLE Required Support Files.

  DESCRIPTION
    This script installs the RSF files.

  OWNER
    Tony Rodgers

  MODIFIED    DD-MMM-YY Reason
    ekhor     10/03/97  reboot to complete install for WIN_95 if msvc dlls are in used
    mhclau    22-SEP-97 Copy NLS resource.
    rxfernan  09/97     OCSM Compliance
    rpingte   09/22/96  7.3.3.0.0 add trace
    mmacdona  06/28/96  7.3.2.2.0
    mmacdona  06/24/96  install olepro32.dll
    mmacdona  03/13/96  Make Win32 Common
    ljiang    07/20/95  7.2
    syau      07/01/94  7.1.3
    HA!       04/28/94  7.1.2 and 3.0.10.2
    trodgers  10-APR-92 Created.
*****************************************************************************/
{
  /**************************************************************************
      Start main logic...
   **************************************************************************/
  if (doit)
    {
      ins_ratchet = "7.3.4.1.1";

      execute("%installer_home%\%operating_system%.ins");

      permit_retry_operations = TRUE;

      ui_product(product_label);

      ui_action(instantiate(installing_scripts));
      copy(deinstl, nls_abbreviation);
      if (registered("ntrsf70"))
        copy(deinstl70, nls_abbreviation);
      if (registered("ntrsf71"))
        copy(deinstl71, nls_abbreviation);

      ui_action(instantiate(installing_dlls));


      permit_retry_operations = FALSE;
      overwrite_mode = 'UPDATE;

      /* rsf_in_use is a boolean which is true until the copy(*) command is succesful. */
      /* This is how we allow the user to stop services and/or applications using RSF and continue installing */
      rsf_in_use = TRUE;
      while(rsf_in_use)
      {
         write_error_occured = FALSE;
         { copy(dll); }
         [  'WRITE_ERROR:
            {
               /* If in silent mode signal an error to avoid an infinite loop. */
               if(silent_mode)
                signal('CANCEL, inUse_prompt);

               information_dialog(inUse_prompt, inUse_content, inUse_help);
               write_error_occured = TRUE;
               continue();
            }
         ]
         if(not(write_error_occured))
         {
            rsf_in_use = FALSE;
         }
      }

      /* rsf_in_use is a boolean which is true until the copy(*) command is succesful. */
      /* This is how we allow the user to stop services and/or applications using RSF and continue installing */
      rsf_in_use = TRUE;
      while(rsf_in_use)
      {
         write_error_occured = FALSE;
         { copy(commdll); }
         [  'WRITE_ERROR:
            {
               /* If in silent mode signal an error to avoid an infinite loop. */
               if(silent_mode)
                signal('CANCEL, inUse_prompt);

               information_dialog(inUse_prompt, inUse_content, inUse_help);
               write_error_occured = TRUE;
               continue();
            }
         ]
         if(not(write_error_occured))
         {
            rsf_in_use = FALSE;
         }
      }

      permit_retry_operations = TRUE;

      copy(msvcdll);
      copy(mfcdll);

      permit_retry_operations = FALSE;


      /* rsf_in_use is a boolean which is true until the copy(*) command is succesful. */
      /* This is how we allow the user to stop services and/or applications using RSF and continue installing */
      rsf_in_use = TRUE;
      while(rsf_in_use)
      {
         write_error_occured = FALSE;
         { copy(oledll); }
         [  'WRITE_ERROR:
            {
               /* If in silent mode signal an error to avoid an infinite loop. */
               if(silent_mode)
                signal('CANCEL, inUse_prompt);

               information_dialog(inUse_prompt, inUse_content, inUse_help);
               write_error_occured = TRUE;
               continue();
            }
         ]
         if(not(write_error_occured))
         {
            rsf_in_use = FALSE;
         }
      }

      if (platform() == "nt")
        permit_retry_operations = TRUE;

      wininit = "%windir%\wininit.ini";
      rename_group = "rename";
      copy_msft_dlls = true;

      msvcrt40 = "%winsys%\msvcrt40.dll";
      msvcrt40new = "%winsys%\msvcrt40.new";
      msvcrt40old = "%winsys%\msvcrt40.old";
      if (not(exists(msvcrt40)))
      {
        { move_file(msvcrt40new, msvcrt40); }
        [ 'DEFAULT: copy_file(msvcrt40new, msvcrt40); ]
      }

      else
      {
        { version_no = windows_file_version(msvcrt40); }
        [ 'OS_ERROR: version_no = "0.0.0.0.0.0.0"; ]

        { version_new = windows_file_version(msvcrt40new); }
        [ 'OS_ERROR: version_new = "0.0.0.0.0.0.0"; ]

        if (earlier_version(version_no, version_new))
        {
          {
          move_file(msvcrt40, msvcrt40old);
          move_file(msvcrt40new, msvcrt40);
          }
          [ 'DEFAULT: { if (platform() == "nt")
                          copy_file(msvcrt40new, msvcrt40);
                        else
                        {
                          copy_msft_dlls = false;
                          modify(msvcrt40old,msvcrt40,wininit,rename_group);
                          modify(msvcrt40,msvcrt40new,wininit,rename_group);
                        }
                      }
          ]
        }
        else
        {
          { remove_file(msvcrt40new); }
          [ 'DEFAULT: continue(); ]
        }
      }

      msvcrt = "%winsys%\msvcrt.dll";
      msvcrtnew = "%winsys%\msvcrt.new";
      msvcrtold = "%winsys%\msvcrt.old";
      if (not(exists(msvcrt)))
      {
        { move_file(msvcrtnew, msvcrt); }
        [ 'DEFAULT: copy_file(msvcrtnew, msvcrt); ]
      }

      else
      {
        { version_no = windows_file_version(msvcrt); }
        [ 'OS_ERROR: version_no = "0.0.0.0.0.0.0"; ]

        { version_new = windows_file_version(msvcrtnew); }
        [ 'OS_ERROR: version_new = "0.0.0.0.0.0.0"; ]

        if (earlier_version(version_no, version_new))
        {
          {
          move_file(msvcrt, msvcrtold);
          move_file(msvcrtnew, msvcrt);
          }
          [ 'DEFAULT: { if (platform() == "nt")
                          copy_file(msvcrtnew, msvcrt);
                        else
                        {
                          copy_msft_dlls = false;
                          modify(msvcrtold,msvcrt,wininit,rename_group);
                          modify(msvcrt,msvcrtnew,wininit,rename_group);
                        }
                      }
          ]
        }
        else
        {
          { remove_file(msvcrtnew); }
          [ 'DEFAULT: continue(); ]
        }
      }

      msvcirt = "%winsys%\msvcirt.dll";
      msvcirtnew = "%winsys%\msvcirt.new";
      msvcirtold = "%winsys%\msvcirt.old";
      if (not(exists(msvcirt)))
      {
        { move_file(msvcirtnew, msvcirt); }
        [ 'DEFAULT: copy_file(msvcirtnew, msvcirt); ]
      }

      else
      {
        { version_no = windows_file_version(msvcirt); }
        [ 'OS_ERROR: version_no = "0.0.0.0.0.0.0"; ]

        { version_new = windows_file_version(msvcirtnew); }
        [ 'OS_ERROR: version_new = "0.0.0.0.0.0.0"; ]

        if (earlier_version(version_no, version_new))
        {
          {
          move_file(msvcirt, msvcirtold);
          move_file(msvcirtnew, msvcirt);
          }
          [ 'DEFAULT: { if (platform() == "nt")
                          copy_file(msvcirtnew, msvcirt);
                        else
                        {
                          copy_msft_dlls = false;
                          modify(msvcirtold,msvcirt,wininit,rename_group);
                          modify(msvcirt,msvcirtnew,wininit,rename_group);
                        }
                      }
          ]
        }
        else
        {
          { remove_file(msvcirtnew); }
          [ 'DEFAULT: continue(); ]
        }
      }

      mfc40 = "%winsys%\mfc40.dll";
      mfc40new = "%winsys%\mfc40.new";
      mfc40old = "%winsys%\mfc40.old";
      if (not(exists(mfc40)))
      {
        { move_file(mfc40new, mfc40); }
        [ 'DEFAULT: copy_file(mfc40new, mfc40); ]
      }

      else
      {
        { version_no = windows_file_version(mfc40); }
        [ 'OS_ERROR: version_no = "0.0.0.0.0.0.0"; ]

        { version_new = windows_file_version(mfc40new); }
        [ 'OS_ERROR: version_new = "0.0.0.0.0.0.0"; ]

        if (earlier_version(version_no, version_new))
        {
          {
          move_file(mfc40, mfc40old);
          move_file(mfc40new, mfc40);
          }
          [ 'DEFAULT: { if (platform() == "nt")
                          copy_file(mfc40new, mfc40);
                        else
                        {
                          copy_msft_dlls = false;
                          modify(mfc40old,mfc40,wininit,rename_group);
                          modify(mfc40,mfc40new,wininit,rename_group);
                        }
                      }
          ]
        }
        else
        {
          { remove_file(mfc40new); }
          [ 'DEFAULT: continue(); ]
        }
      }

      mfc42 = "%winsys%\mfc42.dll";
      mfc42new = "%winsys%\mfc42.new";
      mfc42old = "%winsys%\mfc42.old";
      if (not(exists(mfc42)))
      {
        { move_file(mfc42new, mfc42); }
        [ 'DEFAULT: copy_file(mfc42new, mfc42); ]
      }

      else
      {
        { version_no = windows_file_version(mfc42); }
        [ 'OS_ERROR: version_no = "0.0.0.0.0.0.0"; ]

        { version_new = windows_file_version(mfc42new); }
        [ 'OS_ERROR: version_new = "0.0.0.0.0.0.0"; ]

        if (earlier_version(version_no, version_new))
        {
          {
          move_file(mfc42, mfc42old);
          move_file(mfc42new, mfc42);
          }
          [ 'DEFAULT: { if (platform() == "nt")
                          copy_file(mfc42new, mfc42);
                        else
                        {
                          copy_msft_dlls = false;
                          modify(mfc42old,mfc42,wininit,rename_group);
                          modify(mfc42,mfc42new,wininit,rename_group);
                        }
                      }
          ]
        }
        else
        {
          { remove_file(mfc42new); }
          [ 'DEFAULT: continue(); ]
        }
      }

      olepro32 = "%winsys%\olepro32.dll";
      olepro32new = "%winsys%\olepro32.new";
      olepro32old = "%winsys%\olepro32.old";
      if (not(exists(olepro32)))
      {
        { move_file(olepro32new, olepro32); }
        [ 'DEFAULT: copy_file(olepro32new, olepro32); ]
      }

      else
      {
        { version_no = windows_file_version(olepro32); }
        [ 'OS_ERROR: version_no = "0.0.0.0.0.0.0"; ]

        { version_new = windows_file_version(olepro32new); }
        [ 'OS_ERROR: version_new = "0.0.0.0.0.0.0"; ]

        if (earlier_version(version_no, version_new))
        {
          {
          move_file(olepro32, olepro32old);
          move_file(olepro32new, olepro32);
          }
          [ 'DEFAULT: { if (platform() == "nt")
                          copy_file(olepro32new, olepro32);
                        else
                        {
                          copy_msft_dlls = false;
                          modify(olepro32old,olepro32,wininit,rename_group);
                          modify(olepro32,olepro32new,wininit,rename_group);
                        }
                      }
          ]
        }
        else
        {
          { remove_file(olepro32new); }
          [ 'DEFAULT: continue(); ]
        }
      }

      msvcrt20 = "%winsys%\msvcrt20.dll";
      msvcrt20new = "%winsys%\msvcrt20.new";
      msvcrt20old = "%winsys%\msvcrt20.old";
      if (not(exists(msvcrt20)))
      {
        { move_file(msvcrt20new, msvcrt20); }
        [ 'DEFAULT: copy_file(msvcrt20new, msvcrt20); ]
      }

      else
      {
        { version_no = windows_file_version(msvcrt20); }
        [ 'OS_ERROR: version_no = "0.0.0.0.0.0.0"; ]

        { version_new = windows_file_version(msvcrt20new); }
        [ 'OS_ERROR: version_new = "0.0.0.0.0.0.0"; ]

        if (earlier_version(version_no, version_new))
        {
          {
          move_file(msvcrt20, msvcrt20old);
          move_file(msvcrt20new, msvcrt20);
          }
          [ 'DEFAULT: { if (platform() == "nt")
                          copy_file(msvcrt20new, msvcrt20);
                        else
                        {
                          copy_msft_dlls = false;
                          modify(msvcrt20old,msvcrt20,wininit,rename_group);
                          modify(msvcrt20,msvcrt20new,wininit,rename_group);
                        }
                      }
          ]
        }
        else
        {
          { remove_file(msvcrt20new); }
          [ 'DEFAULT: continue(); ]
        }
      }

      msvcrt2x = "%winsys%\msvcrt2x.dll";
      msvcrt2xnew = "%winsys%\msvcrt2x.new";
      msvcrt2xold = "%winsys%\msvcrt2x.old";
      if (not(exists(msvcrt2x)))
      {
        { move_file(msvcrt2xnew, msvcrt2x); }
        [ 'DEFAULT: copy_file(msvcrt2xnew, msvcrt2x); ]
      }

      else
      {
        { version_no = windows_file_version(msvcrt2x); }
        [ 'OS_ERROR: version_no = "0.0.0.0.0.0.0"; ]

        { version_new = windows_file_version(msvcrt2xnew); }
        [ 'OS_ERROR: version_new = "0.0.0.0.0.0.0"; ]

        if (earlier_version(version_no, version_new))
        {
          {
          move_file(msvcrt2x, msvcrt2xold);
          move_file(msvcrt2xnew, msvcrt2x);
          }
          [ 'DEFAULT: { if (platform() == "nt")
                          copy_file(msvcrt2xnew, msvcrt2x);
                        else
                        {
                          copy_msft_dlls = false;
                          modify(msvcrt2xold,msvcrt2x,wininit,rename_group);
                          modify(msvcrt2x,msvcrt2xnew,wininit,rename_group);
                        }
                      }
          ]
        }
        else
        {
          { remove_file(msvcrt2xnew); }
          [ 'DEFAULT: continue(); ]
        }
      }

      if (platform() == "nt")
         permit_retry_operations = TRUE;

      overwrite_mode = 'ALWAYS;

      ui_action(instantiate(installing_msbs));
      copy(msg, nls_abbreviation);

      ui_action(instantiate(installing_sql));
      copy(sql);

      ui_action(instantiate(installing_nlsdata));
      copy(nlsdata);

      /* copy release notes */
      permit_retry_operations = false;

      { copy(user, user_release_grp) ;}
      [ 'DEFAULT : continue() ; ]
      permit_retry_operations = true;

      if (platform() == "nt")
        if (doSmartStart)
          {
            ss_decrypt_file(product_key,
                          "%s_location%NT_X86/V7/RSF/CORENT23.DLL",
                          "%oracle_home%\bin\CORENT23.DLL");
            ss_decrypt_file(product_key,
                          "%s_location%NT_X86/V7/RSF/ORASPAWN.DLL",
                          "%oracle_home%\bin\ORASPAWN.DLL");
          }


      if (set_rdbms73)
        {
          ui_action(instantiate(modifying_config));
          modify("RDBMS73",RDBMS73,ora_config,product_filename(current_product));
        }

      if (set_trace73)
        {
          ui_action(instantiate(modifying_config));
          modify("OTRACE73",OTRACE73,ora_config,product_filename(current_product));
        }

      if (set_plsql23)
        {
          ui_action(instantiate(modifying_config));
          modify("PLSQL23",PLSQL23,ora_config,product_filename(current_product));
        }

      if (set_pro18)
        {
          ui_action(instantiate(modifying_config));
          modify("PRO18",PRO18,ora_config,product_filename(current_product));
        }

      if (set_nlsrtl32)
        {
          ui_action(instantiate(modifying_config));
          modify("NLSRTL32",NLSRTL32,ora_config,product_filename(current_product));
        }

      if (set_ora_nls)
        {
          ui_action(instantiate(modifying_config));
          modify("ORA_NLS32",ORA_NLS32,ora_config,product_filename(current_product));
        }

      ui_action(instantiate(registering));
      register(current_product);
      if (member(selected_products,current_product))
        reference(current_product);

      if (not(copy_msft_dlls))
        if(not(member(remind_list, rsf_note)))
          add(remind_list, rsf_note);

      permit_retry_operations = FALSE;

        /* OCSM Compliance */
        { Win32_register_OCSM_product(); }
        [ 'default: win32_ocsm_register_product(); ]

        /* Copy shrdll group. */
        copy(shrdll);

        /* Register the groups in the map file and specify which should get
           copied over under the three OCSM installation modes. */
        win32_register_ocsm_group(deinstl,   nls_abbreviation, 'MAXMODE);
        win32_register_ocsm_group(commdll,                     'MAXMODE);
        win32_register_ocsm_group(dll,                         'MAXMODE);
        win32_register_ocsm_group(msg,       nls_abbreviation, 'MAXMODE);
        win32_register_ocsm_group(sql,                         'MAXMODE);
        win32_register_ocsm_group(nlsdata,                     'MAXMODE);
        win32_register_ocsm_group(user,                        'MAXMODE);

        win32_register_ocsm_group(deinstl,   nls_abbreviation, 'MEDMODE);
        win32_register_ocsm_group(commdll,                     'MEDMODE);
        win32_register_ocsm_group(dll,                         'MEDMODE);
        win32_register_ocsm_group(msg,       nls_abbreviation, 'MEDMODE);
        win32_register_ocsm_group(sql,                         'MEDMODE);
        win32_register_ocsm_group(nlsdata,                     'MEDMODE);
        win32_register_ocsm_group(user,                        'MEDMODE);

        win32_register_ocsm_group(deinstl,   nls_abbreviation, 'MINMODE);
        win32_register_ocsm_group(commdll,                     'MINMODE);
        win32_register_ocsm_group(dll,                         'MINMODE);
        win32_register_ocsm_group(msg,       nls_abbreviation, 'MINMODE);
        win32_register_ocsm_group(sql,                         'MINMODE);
        win32_register_ocsm_group(nlsdata,                     'MINMODE);
        win32_register_ocsm_group(user,                        'MINMODE);

        /* Register the deinst groups depending on whether 7.1 or 7.2 */
        /* of RSF has been installed.                                 */
        if(registered("ntrsf70"))
        {
                win32_register_ocsm_group(deinstl70, nls_abbreviation, 'MAXMODE);
                win32_register_ocsm_group(deinstl70, nls_abbreviation, 'MEDMODE);
                win32_register_ocsm_group(deinstl70, nls_abbreviation, 'MINMODE);
        }
        if(registered("ntrsf71"))
        {
                win32_register_ocsm_group(deinstl71, nls_abbreviation, 'MAXMODE);
                win32_register_ocsm_group(deinstl71, nls_abbreviation, 'MEDMODE);
                win32_register_ocsm_group(deinstl71, nls_abbreviation, 'MINMODE);
        }

        /* Register variables in the map file that are not Installer variables. */
        win32_register_map_variable("NLSRTL32");
        win32_register_map_variable("OTRACE73");
        win32_register_map_variable("PLSQL23");
        win32_register_map_variable("PRO18");
        win32_register_map_variable("RDBMS73");
        win32_register_map_variable("WINSYS");
        win32_register_map_variable("SYSDIR");

        /* Register product variables or keys created in the Windows registry by   */
        /* this INS script.  Associated with calls to: modify(...) in this script. */

        /* Define the key and subkey. */
        okey    = "HKEY_LOCAL_MACHINE";
        osubkey = "SOFTWARE\ORACLE";

        win32_register_key(okey, osubkey, "RDBMS73",   'REPLICATE);
        win32_register_key(okey, osubkey, "OTRACE73",  'REPLICATE);
        win32_register_key(okey, osubkey, "PLSQL23",   'REPLICATE);
        win32_register_key(okey, osubkey, "PRO18",     'REPLICATE);
        win32_register_key(okey, osubkey, "NLSRTL32",  'REPLICATE);
        win32_register_key(okey, osubkey, "ORA_NLS32", 'REPLICATE);

        /* End OCSM Compliance */
    }
}
