Commit in reactos on MAIN
ChangeLog+51.222 -> 1.223
subsys/system/usetup/bootsup.c+79-61.11 -> 1.12
+84-6
2 modified files
2004-03-10  Casper S. Hornstrup  <chorns@users.sourceforge.net>

	* subsys/system/usetup/bootsup.c (UpdateFreeLoaderIni): Use existing
	ReactOS entry if available.

reactos
ChangeLog 1.222 -> 1.223
diff -u -r1.222 -r1.223
--- ChangeLog	9 Mar 2004 22:08:03 -0000	1.222
+++ ChangeLog	10 Mar 2004 16:57:36 -0000	1.223
@@ -1,3 +1,8 @@
+2004-03-10  Casper S. Hornstrup  <chorns@users.sourceforge.net>
+
+	* subsys/system/usetup/bootsup.c (UpdateFreeLoaderIni): Use existing
+	ReactOS entry if available.
+
 2004-03-09  Casper S. Hornstrup  <chorns@users.sourceforge.net>
 
 	* regtests/Makefile: Make REGTEST_TARGETS depend on *.c.

reactos/subsys/system/usetup
bootsup.c 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- bootsup.c	1 Dec 2003 18:28:54 -0000	1.11
+++ bootsup.c	10 Mar 2004 16:57:36 -0000	1.12
@@ -380,10 +380,13 @@
   UNICODE_STRING Name;
   PINICACHE IniCache;
   PINICACHESECTION IniSection;
+  PINICACHESECTION OsIniSection;
   WCHAR SectionName[80];
   WCHAR OsName[80];
+  WCHAR SystemPath[200];
+  WCHAR SectionName2[200];
   PWCHAR KeyData;
-  ULONG i;
+  ULONG i,j;
   NTSTATUS Status;
 
   RtlInitUnicodeString(&Name,
@@ -399,9 +402,12 @@
   IniSection = IniCacheGetSection(IniCache,
 				  L"Operating Systems");
   if (IniSection == NULL)
+  {
+    IniCacheDestroy(IniCache);
     return(STATUS_UNSUCCESSFUL);
+  }
 
-  /* Find an unused section name */
+  /* Find an existing usable or an unused section name */
   i = 1;
   wcscpy(SectionName, L"ReactOS");
   wcscpy(OsName, L"\"ReactOS\"");
@@ -413,6 +419,77 @@
     if (!NT_SUCCESS(Status))
       break;
 
+    /* Get operation system section */
+    if (KeyData[0] == '"')
+    {
+      wcscpy(SectionName2, &KeyData[1]);
+      j = wcslen(SectionName2);
+      if (j > 0)
+      {
+        SectionName2[j-1] = 0;
+      }
+    }
+    else
+    {
+      wcscpy(SectionName2, KeyData);
+    }
+
+    OsIniSection = IniCacheGetSection(IniCache,
+      SectionName2);
+    if (OsIniSection != NULL)
+    {
+      BOOLEAN UseExistingEntry = TRUE;
+
+      /* Check BootType */
+      Status = IniCacheGetKey(OsIniSection,
+        L"BootType",
+        &KeyData);
+      if (NT_SUCCESS(Status))
+      {
+        if (KeyData == NULL
+          || (_wcsicmp(KeyData, L"ReactOS") != 0
+          && _wcsicmp(KeyData, L"\"ReactOS\"") != 0))
+        {
+          /* This is not a ReactOS entry */
+          UseExistingEntry = FALSE;
+        }
+      }
+      else
+      {
+        UseExistingEntry = FALSE;
+      }
+
+      if (UseExistingEntry)
+      {
+        /* BootType is ReactOS. Now check SystemPath */
+        Status = IniCacheGetKey(OsIniSection,
+          L"SystemPath",
+          &KeyData);
+        if (NT_SUCCESS(Status))
+        {
+          swprintf(SystemPath, L"\"%S\"", ArcPath);
+          if (KeyData == NULL
+            || (_wcsicmp(KeyData, ArcPath) != 0
+            && _wcsicmp(KeyData, SystemPath) != 0))
+          {
+            /* This entry is a ReactOS entry, but the SystemRoot does not
+               match the one we are looking for */
+            UseExistingEntry = FALSE;
+          }
+        }
+        else
+        {
+          UseExistingEntry = FALSE;
+        }
+      }
+
+      if (UseExistingEntry)
+      {
+        IniCacheDestroy(IniCache);
+        return(STATUS_SUCCESS);
+      }
+    }
+
     swprintf(SectionName, L"ReactOS_%lu", i);
     swprintf(OsName, L"\"ReactOS %lu\"", i);
     i++;
@@ -1608,7 +1685,6 @@
 			FALSE);
   if (!NT_SUCCESS(Status))
   {
-CHECKPOINT1;
     return(Status);
   }
 
@@ -1616,7 +1692,6 @@
 			       L"operating systems");
   if (Section == NULL)
   {
-CHECKPOINT1;
     IniCacheDestroy(Cache);
     return(STATUS_UNSUCCESSFUL);
   }
@@ -1631,7 +1706,6 @@
 			    &FileAttribute);
   if (!NT_SUCCESS(Status))
   {
-CHECKPOINT1;
     IniCacheDestroy(Cache);
     return(Status);
   }
@@ -1640,7 +1714,6 @@
 			BootIniPath);
   if (!NT_SUCCESS(Status))
   {
-CHECKPOINT1;
     IniCacheDestroy(Cache);
     return(Status);
   }
CVSspam 0.2.8