[MKHIVE]
authorEric Kohl <eric.kohl@reactos.org>
Mon, 26 Apr 2010 15:35:57 +0000 (15:35 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Mon, 26 Apr 2010 15:35:57 +0000 (15:35 +0000)
Partial revert of r47019 because mkhive failed on Linux machines.

svn path=/trunk/; revision=47038

reactos/tools/mkhive/mkhive.rbuild
reactos/tools/mkhive/reginf.c
reactos/tools/mkhive/rtl.c

index e4778b9..c5d22dc 100644 (file)
@@ -1,13 +1,13 @@
 <?xml version="1.0"?>
 <!DOCTYPE module SYSTEM "../../tools/rbuild/project.dtd">
 <module name="mkhive" type="buildtool">
 <?xml version="1.0"?>
 <!DOCTYPE module SYSTEM "../../tools/rbuild/project.dtd">
 <module name="mkhive" type="buildtool">
-       <include base="newinflibhost">.</include>
+       <include base="inflibhost">.</include>
        <include base="cmlibhost">.</include>
        <include base="zlibhost">.</include>
        <include base="rtl">.</include>
        <define name="MKHIVE_HOST" />
        <compilerflag compilerset="gcc">-fshort-wchar</compilerflag>
        <include base="cmlibhost">.</include>
        <include base="zlibhost">.</include>
        <include base="rtl">.</include>
        <define name="MKHIVE_HOST" />
        <compilerflag compilerset="gcc">-fshort-wchar</compilerflag>
-       <library>newinflibhost</library>
+       <library>inflibhost</library>
        <library>cmlibhost</library>
        <library>host_wcsfuncs</library>
        <file>binhive.c</file>
        <library>cmlibhost</library>
        <library>host_wcsfuncs</library>
        <file>binhive.c</file>
index 9e03c08..50d379b 100644 (file)
 /* FUNCTIONS ****************************************************************/
 
 static BOOL
 /* FUNCTIONS ****************************************************************/
 
 static BOOL
-GetRootKey (PWCHAR Name)
+GetRootKey (PCHAR Name)
 {
 {
-       if (!_wcsicmp (Name, L"HKCR"))
+       if (!strcasecmp (Name, "HKCR"))
        {
        {
-               wcscpy (Name, L"\\Registry\\Machine\\SOFTWARE\\Classes\\");
+               strcpy (Name, "\\Registry\\Machine\\SOFTWARE\\Classes\\");
                return TRUE;
        }
 
                return TRUE;
        }
 
-       if (!_wcsicmp (Name, L"HKCU"))
+       if (!strcasecmp (Name, "HKCU"))
        {
        {
-               wcscpy (Name, L"\\Registry\\User\\.DEFAULT\\");
+               strcpy (Name, "\\Registry\\User\\.DEFAULT\\");
                return TRUE;
        }
 
                return TRUE;
        }
 
-       if (!_wcsicmp (Name, L"HKLM"))
+       if (!strcasecmp (Name, "HKLM"))
        {
        {
-               wcscpy (Name, L"\\Registry\\Machine\\");
+               strcpy (Name, "\\Registry\\Machine\\");
                return TRUE;
        }
 
                return TRUE;
        }
 
-       if (!_wcsicmp (Name, L"HKU"))
+       if (!strcasecmp (Name, "HKU"))
        {
        {
-               wcscpy (Name, L"\\Registry\\User\\");
+               strcpy (Name, "\\Registry\\User\\");
                return TRUE;
        }
 
 #if 0
                return TRUE;
        }
 
 #if 0
-       if (!_wcsicmp (Name, L"HKR"))
+       if (!strcasecmp (Name, "HKR"))
                return FALSE;
 #endif
 
                return FALSE;
 #endif
 
@@ -94,19 +94,19 @@ GetRootKey (PWCHAR Name)
 static VOID
 AppendMultiSzValue (
        IN HKEY KeyHandle,
 static VOID
 AppendMultiSzValue (
        IN HKEY KeyHandle,
-       IN PWCHAR ValueName,
-       IN PWCHAR Strings,
+       IN PCHAR ValueName,
+       IN PCHAR Strings,
        IN SIZE_T StringSize)
 {
        SIZE_T Size;
        ULONG Type;
        size_t Total;
        IN SIZE_T StringSize)
 {
        SIZE_T Size;
        ULONG Type;
        size_t Total;
-       PWCHAR Buffer;
-       PWCHAR p;
+       PCHAR Buffer;
+       PCHAR p;
        size_t len;
        LONG Error;
 
        size_t len;
        LONG Error;
 
-       Error = RegQueryValueExW (
+       Error = RegQueryValueExA (
                KeyHandle,
                ValueName,
                NULL,
                KeyHandle,
                ValueName,
                NULL,
@@ -117,11 +117,11 @@ AppendMultiSzValue (
            (Type != REG_MULTI_SZ))
                return;
 
            (Type != REG_MULTI_SZ))
                return;
 
-       Buffer = malloc (Size + (StringSize * sizeof(WCHAR)));
+       Buffer = malloc (Size + StringSize);
        if (Buffer == NULL)
                return;
 
        if (Buffer == NULL)
                return;
 
-       Error = RegQueryValueExW (
+       Error = RegQueryValueExA (
                KeyHandle,
                ValueName,
                NULL,
                KeyHandle,
                ValueName,
                NULL,
@@ -135,25 +135,25 @@ AppendMultiSzValue (
        Total = Size;
        while (*Strings != 0)
        {
        Total = Size;
        while (*Strings != 0)
        {
-               len = wcslen (Strings) + 1;
+               len = strlen (Strings) + 1;
 
 
-               for (p = Buffer; *p != 0; p += wcslen (p) + 1)
-                       if (!_wcsicmp (p, Strings))
+               for (p = Buffer; *p != 0; p += strlen (p) + 1)
+                       if (!strcasecmp (p, Strings))
                                break;
 
                if (*p == 0)  /* not found, need to append it */
                {
                                break;
 
                if (*p == 0)  /* not found, need to append it */
                {
-                       memcpy (p, Strings, len * sizeof(WCHAR));
+                       memcpy (p, Strings, len);
                        p[len] = 0;
                        p[len] = 0;
-                       Total += len * sizeof(WCHAR);
+                       Total += len;
                }
                Strings += len;
        }
 
        if (Total != Size)
        {
                }
                Strings += len;
        }
 
        if (Total != Size)
        {
-               DPRINT ("setting value %S to %S\n", ValueName, Buffer);
-               RegSetValueExW (
+               DPRINT ("setting value %s to %s\n", ValueName, Buffer);
+               RegSetValueExA (
                        KeyHandle,
                        ValueName,
                        0,
                        KeyHandle,
                        ValueName,
                        0,
@@ -175,11 +175,11 @@ done:
 static BOOL
 do_reg_operation(
        IN HKEY KeyHandle,
 static BOOL
 do_reg_operation(
        IN HKEY KeyHandle,
-       IN PWCHAR ValueName,
+       IN PCHAR ValueName,
        IN PINFCONTEXT Context,
        IN ULONG Flags)
 {
        IN PINFCONTEXT Context,
        IN ULONG Flags)
 {
-       WCHAR EmptyStr = (WCHAR)0;
+       CHAR EmptyStr = (CHAR)0;
        ULONG Type;
        ULONG Size;
        LONG Error;
        ULONG Type;
        ULONG Size;
        LONG Error;
@@ -188,11 +188,11 @@ do_reg_operation(
        {
                if (ValueName)
                {
        {
                if (ValueName)
                {
-                       RegDeleteValueW (KeyHandle, ValueName);
+                       RegDeleteValueA (KeyHandle, ValueName);
                }
                else
                {
                }
                else
                {
-                       RegDeleteKeyW (KeyHandle, NULL);
+                       RegDeleteKeyA (KeyHandle, NULL);
                }
 
                return TRUE;
                }
 
                return TRUE;
@@ -203,7 +203,7 @@ do_reg_operation(
 
        if (Flags & (FLG_ADDREG_NOCLOBBER | FLG_ADDREG_OVERWRITEONLY))
        {
 
        if (Flags & (FLG_ADDREG_NOCLOBBER | FLG_ADDREG_OVERWRITEONLY))
        {
-               Error = RegQueryValueExW (
+               Error = RegQueryValueExA (
                        KeyHandle,
                        ValueName,
                        NULL,
                        KeyHandle,
                        ValueName,
                        NULL,
@@ -253,7 +253,7 @@ do_reg_operation(
        if (!(Flags & FLG_ADDREG_BINVALUETYPE) ||
            (Type == REG_DWORD && InfHostGetFieldCount (Context) == 5))
        {
        if (!(Flags & FLG_ADDREG_BINVALUETYPE) ||
            (Type == REG_DWORD && InfHostGetFieldCount (Context) == 5))
        {
-               WCHAR *Str = NULL;
+               CHAR *Str = NULL;
 
                if (Type == REG_MULTI_SZ)
                {
 
                if (Type == REG_MULTI_SZ)
                {
@@ -262,7 +262,7 @@ do_reg_operation(
 
                        if (Size)
                        {
 
                        if (Size)
                        {
-                               Str = malloc (Size * sizeof(WCHAR));
+                               Str = malloc (Size);
                                if (Str == NULL)
                                        return FALSE;
 
                                if (Str == NULL)
                                        return FALSE;
 
@@ -292,7 +292,7 @@ do_reg_operation(
 
                        if (Size)
                        {
 
                        if (Size)
                        {
-                               Str = malloc (Size * sizeof(WCHAR));
+                               Str = malloc (Size);
                                if (Str == NULL)
                                        return FALSE;
 
                                if (Str == NULL)
                                        return FALSE;
 
@@ -302,11 +302,11 @@ do_reg_operation(
 
                if (Type == REG_DWORD)
                {
 
                if (Type == REG_DWORD)
                {
-                       ULONG dw = Str ? wcstoul (Str, NULL, 0) : 0;
+                       ULONG dw = Str ? strtoul (Str, NULL, 0) : 0;
 
 
-                       DPRINT("setting dword %S to %x\n", ValueName, dw);
+                       DPRINT("setting dword %s to %x\n", ValueName, dw);
 
 
-                       RegSetValueExW (
+                       RegSetValueExA (
                                KeyHandle,
                                ValueName,
                                0,
                                KeyHandle,
                                ValueName,
                                0,
@@ -316,27 +316,27 @@ do_reg_operation(
                }
                else
                {
                }
                else
                {
-                       DPRINT("setting value %S to %S\n", ValueName, Str);
+                       DPRINT("setting value %s to %s\n", ValueName, Str);
 
                        if (Str)
                        {
 
                        if (Str)
                        {
-                               RegSetValueExW (
+                               RegSetValueExA (
                                        KeyHandle,
                                        ValueName,
                                        0,
                                        Type,
                                        (PVOID)Str,
                                        KeyHandle,
                                        ValueName,
                                        0,
                                        Type,
                                        (PVOID)Str,
-                                       (ULONG)Size * sizeof(WCHAR));
+                                       (ULONG)Size);
                        }
                        else
                        {
                        }
                        else
                        {
-                               RegSetValueExW (
+                               RegSetValueExA (
                                        KeyHandle,
                                        ValueName,
                                        0,
                                        Type,
                                        (PVOID)&EmptyStr,
                                        KeyHandle,
                                        ValueName,
                                        0,
                                        Type,
                                        (PVOID)&EmptyStr,
-                                       (ULONG)sizeof(WCHAR));
+                                       (ULONG)sizeof(CHAR));
                        }
                }
                free (Str);
                        }
                }
                free (Str);
@@ -354,11 +354,11 @@ do_reg_operation(
                        if (Data == NULL)
                                return FALSE;
 
                        if (Data == NULL)
                                return FALSE;
 
-                       DPRINT("setting binary data %S len %d\n", ValueName, Size);
+                       DPRINT("setting binary data %s len %d\n", ValueName, Size);
                        InfHostGetBinaryField (Context, 5, Data, Size, NULL);
                }
 
                        InfHostGetBinaryField (Context, 5, Data, Size, NULL);
                }
 
-               RegSetValueExW (
+               RegSetValueExA (
                        KeyHandle,
                        ValueName,
                        0,
                        KeyHandle,
                        ValueName,
                        0,
@@ -378,10 +378,10 @@ do_reg_operation(
  * Called once for each AddReg and DelReg entry in a given section.
  */
 static BOOL
  * Called once for each AddReg and DelReg entry in a given section.
  */
 static BOOL
-registry_callback (HINF hInf, PWCHAR Section, BOOL Delete)
+registry_callback (HINF hInf, PCHAR Section, BOOL Delete)
 {
 {
-       WCHAR Buffer[MAX_INF_STRING_LENGTH];
-       PWCHAR ValuePtr;
+       CHAR Buffer[MAX_INF_STRING_LENGTH];
+       PCHAR ValuePtr;
        ULONG Flags;
        size_t Length;
 
        ULONG Flags;
        size_t Length;
 
@@ -403,11 +403,11 @@ registry_callback (HINF hInf, PWCHAR Section, BOOL Delete)
                        continue;
 
                /* get key */
                        continue;
 
                /* get key */
-               Length = wcslen (Buffer);
+               Length = strlen (Buffer);
                if (InfHostGetStringField (Context, 2, Buffer + Length, MAX_INF_STRING_LENGTH - (ULONG)Length, NULL) != 0)
                        *Buffer = 0;
 
                if (InfHostGetStringField (Context, 2, Buffer + Length, MAX_INF_STRING_LENGTH - (ULONG)Length, NULL) != 0)
                        *Buffer = 0;
 
-               DPRINT("KeyName: <%S>\n", Buffer);
+               DPRINT("KeyName: <%s>\n", Buffer);
 
                if (Delete)
                {
 
                if (Delete)
                {
@@ -424,17 +424,17 @@ registry_callback (HINF hInf, PWCHAR Section, BOOL Delete)
 
                if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY))
                {
 
                if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY))
                {
-                       if (RegOpenKeyW (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
+                       if (RegOpenKeyA (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
                        {
                        {
-                               DPRINT("RegOpenKey(%S) failed\n", Buffer);
+                               DPRINT("RegOpenKey(%s) failed\n", Buffer);
                                continue;  /* ignore if it doesn't exist */
                        }
                }
                else
                {
                                continue;  /* ignore if it doesn't exist */
                        }
                }
                else
                {
-                       if (RegCreateKeyW (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
+                       if (RegCreateKeyA (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
                        {
                        {
-                               DPRINT("RegCreateKey(%S) failed\n", Buffer);
+                               DPRINT("RegCreateKey(%s) failed\n", Buffer);
                                continue;
                        }
                }
                                continue;
                        }
                }
@@ -469,18 +469,18 @@ ImportRegistryFile(PCHAR FileName)
        ULONG ErrorLine;
 
        /* Load inf file from install media. */
        ULONG ErrorLine;
 
        /* Load inf file from install media. */
-       if (InfHostOpenFile(&hInf, FileName, 0, &ErrorLine) != 0)
+       if (InfHostOpenFile(&hInf, FileName, &ErrorLine) != 0)
        {
                DPRINT1 ("InfHostOpenFile(%s) failed\n", FileName);
                return FALSE;
        }
 
        {
                DPRINT1 ("InfHostOpenFile(%s) failed\n", FileName);
                return FALSE;
        }
 
-       if (!registry_callback (hInf, L"DelReg", TRUE))
+       if (!registry_callback (hInf, "DelReg", TRUE))
        {
                DPRINT1 ("registry_callback() for DelReg failed\n");
        }
 
        {
                DPRINT1 ("registry_callback() for DelReg failed\n");
        }
 
-       if (!registry_callback (hInf, L"AddReg", FALSE))
+       if (!registry_callback (hInf, "AddReg", FALSE))
        {
                DPRINT1 ("registry_callback() for AddReg failed\n");
        }
        {
                DPRINT1 ("registry_callback() for AddReg failed\n");
        }
index a68d7a0..e9ed22b 100644 (file)
@@ -207,32 +207,3 @@ unsigned char BitScanReverse(ULONG * const Index, unsigned long Mask)
     }
     return Mask ? 1 : 0;
 }
     }
     return Mask ? 1 : 0;
 }
-
-#undef tolower
-WCHAR towlower(WCHAR ch)
-{
-    if (ch < L'A')
-    {
-        return ch;
-    }
-    else if (ch <= L'Z')
-    {
-        return ch + (L'a' - L'A');
-    }
-
-    return ch;
-}
-
-int _wcsicmp(PCWSTR cs, PCWSTR ct)
-{
-    while (towlower(*cs) == towlower(*ct))
-    {
-        if (*cs == 0)
-            return 0;
-
-        cs++;
-        ct++;
-    }
-
-    return towlower(*cs) - towlower(*ct);
-}