Author: ekohl Date: Sat May 1 22:17:11 2010 New Revision: 47076
URL: http://svn.reactos.org/svn/reactos?rev=47076&view=rev Log: [CMLIB/NEWINFLIB/MKHIVE] - Make cmlib, newinflib and mkhive use the Wine unicode lib instead of the host_wcsfuncs lib. - Only the header file include/host/wcsfuncs.h is still used to map str*W functions to wcs* functions in WIN32 builds. - Remove obsolete rtl functions. - Make mkhive use the newinflib instead of inflib.
ATTENTION: This might break the build bot although it has been tested on Windows and Linux!!!
Removed: trunk/reactos/lib/newinflib/infrosrtl.c Modified: trunk/reactos/include/host/wcsfuncs.h trunk/reactos/lib/cmlib/cminit.c trunk/reactos/lib/cmlib/cmlib.h trunk/reactos/lib/cmlib/cmlib.rbuild trunk/reactos/lib/newinflib/builddep.h trunk/reactos/lib/newinflib/infget.c trunk/reactos/lib/newinflib/inflib.rbuild trunk/reactos/tools/mkhive/mkhive.rbuild trunk/reactos/tools/mkhive/reginf.c trunk/reactos/tools/mkhive/registry.c trunk/reactos/tools/mkhive/rtl.c
Modified: trunk/reactos/include/host/wcsfuncs.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/host/wcsfuncs.h?rev... ============================================================================== --- trunk/reactos/include/host/wcsfuncs.h [iso-8859-1] (original) +++ trunk/reactos/include/host/wcsfuncs.h [iso-8859-1] Sat May 1 22:17:11 2010 @@ -11,14 +11,19 @@
#ifdef USE_HOST_WCSFUNCS /* Function prototypes */ - SIZE_T utf16_wcslen(PCWSTR str); - PWSTR utf16_wcschr(PWSTR str, WCHAR c); - INT utf16_wcsncmp(PCWSTR string1, PCWSTR string2, size_t count); + #else - /* Define the utf16_ functions to the CRT functions */ - #define utf16_wcslen wcslen - #define utf16_wcschr wcschr - #define utf16_wcsncmp wcsncmp + /* Map str*W functions to wcs* function */ + + #define isspaceW iswspace + #define strchrW wcschr + #define strcmpiW _wcsicmp + #define strcpyW wcscpy + #define strlenW wcslen + #define strncmpW wcsncmp + #define strtolW wcstol + #define strtoulW wcstoul + #endif
#endif
Modified: trunk/reactos/lib/cmlib/cminit.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/cminit.c?rev=4707... ============================================================================== --- trunk/reactos/lib/cmlib/cminit.c [iso-8859-1] (original) +++ trunk/reactos/lib/cmlib/cminit.c [iso-8859-1] Sat May 1 22:17:11 2010 @@ -21,7 +21,7 @@ SIZE_T NameSize;
/* Allocate the cell */ - NameSize = utf16_wcslen(Name) * sizeof(WCHAR); + NameSize = strlenW(Name) * sizeof(WCHAR); RootCellIndex = HvAllocateCell(Hive, FIELD_OFFSET(CM_KEY_NODE, Name) + NameSize, Stable,
Modified: trunk/reactos/lib/cmlib/cmlib.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/cmlib.h?rev=47076... ============================================================================== --- trunk/reactos/lib/cmlib/cmlib.h [iso-8859-1] (original) +++ trunk/reactos/lib/cmlib/cmlib.h [iso-8859-1] Sat May 1 22:17:11 2010 @@ -13,6 +13,7 @@ #define _CMLIB_DEBUG_ 1
#ifdef CMLIB_HOST + #include <wine/unicode.h> #include <host/typedefs.h> #include <stdio.h> #include <string.h>
Modified: trunk/reactos/lib/cmlib/cmlib.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/cmlib.rbuild?rev=... ============================================================================== --- trunk/reactos/lib/cmlib/cmlib.rbuild [iso-8859-1] (original) +++ trunk/reactos/lib/cmlib/cmlib.rbuild [iso-8859-1] Sat May 1 22:17:11 2010 @@ -14,6 +14,8 @@ <file>hivewrt.c</file> </module> <module name="cmlibhost" type="hoststaticlibrary"> + <define name="WINE_UNICODE_API">" "</define> + <include base="unicode" /> <include base="cmlibhost">.</include> <define name="__NO_CTYPE_INLINES" /> <define name="_NTOSKRNL_" />
Modified: trunk/reactos/lib/newinflib/builddep.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/newinflib/builddep.h?re... ============================================================================== --- trunk/reactos/lib/newinflib/builddep.h [iso-8859-1] (original) +++ trunk/reactos/lib/newinflib/builddep.h [iso-8859-1] Sat May 1 22:17:11 2010 @@ -8,6 +8,7 @@
/* Definitions native to the host on which we're building */
+#include <wine/unicode.h> #include <host/typedefs.h>
#include <stdarg.h> @@ -65,15 +66,6 @@
extern PVOID InfpHeap;
-INT isspaceW(WCHAR c); -INT strlenW(PCWSTR s); -PWSTR strcpyW(PWSTR d, PCWSTR s); -PWSTR strncpyW(PWSTR d, PCWSTR s, SIZE_T c); -INT strcmpiW(PCWSTR s1, PCWSTR s2); -LONG strtolW(PCWSTR s, PWSTR *e, INT r); -ULONG strtoulW(PCWSTR s, PWSTR *e, INT r); - - #define FREE(Area) RtlFreeHeap(InfpHeap, 0, (Area)) #define MALLOC(Size) RtlAllocateHeap(InfpHeap, 0, (Size)) #define ZEROMEMORY(Area, Size) RtlZeroMemory((Area), (Size)) @@ -90,4 +82,6 @@
#endif /* INFLIB_HOST */
+#include <host/wcsfuncs.h> + /* EOF */
Modified: trunk/reactos/lib/newinflib/infget.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/newinflib/infget.c?rev=... ============================================================================== --- trunk/reactos/lib/newinflib/infget.c [iso-8859-1] (original) +++ trunk/reactos/lib/newinflib/infget.c [iso-8859-1] Sat May 1 22:17:11 2010 @@ -41,7 +41,7 @@ return &percent; }
- strncpyW(ValueName, str, *len); + memcpy(ValueName, str, *len * sizeof(WCHAR)); ValueName[*len] = 0;
DPRINT("Value name: %S\n", ValueName);
Modified: trunk/reactos/lib/newinflib/inflib.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/newinflib/inflib.rbuild... ============================================================================== --- trunk/reactos/lib/newinflib/inflib.rbuild [iso-8859-1] (original) +++ trunk/reactos/lib/newinflib/inflib.rbuild [iso-8859-1] Sat May 1 22:17:11 2010 @@ -9,16 +9,16 @@ <file>infrosgen.c</file> <file>infrosget.c</file> <file>infrosput.c</file> - <file>infrosrtl.c</file> </module> <module name="newinflibhost" type="hoststaticlibrary" allowwarnings="true"> + <define name="WINE_UNICODE_API">" "</define> + <include base="unicode" /> <include base="newinflibhost">.</include> <define name="__NO_CTYPE_INLINES" /> + <define name="USE_HOST_WCSFUNCS" /> <group compilerset="gcc"> + <compilerflag>-Wwrite-strings</compilerflag> <compilerflag>-Wpointer-arith</compilerflag> - <compilerflag>-Wconversion</compilerflag> - <compilerflag>-Wstrict-prototypes</compilerflag> - <compilerflag>-Wmissing-prototypes</compilerflag> </group> <define name="INFLIB_HOST" /> <file>infcore.c</file>
Removed: trunk/reactos/lib/newinflib/infrosrtl.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/newinflib/infrosrtl.c?r... ============================================================================== --- trunk/reactos/lib/newinflib/infrosrtl.c [iso-8859-1] (original) +++ trunk/reactos/lib/newinflib/infrosrtl.c (removed) @@ -1,51 +1,0 @@ -/* - * PROJECT: .inf file parser - * LICENSE: GPL - See COPYING in the top level directory - * PROGRAMMER: Eric Kohl - */ - -/* INCLUDES *****************************************************************/ - -#include "inflib.h" -#include "infhost.h" - -#define NDEBUG -#include <debug.h> - - -/* FUNCTIONS ****************************************************************/ - -INT isspaceW(WCHAR c) -{ - return iswspace(c); -} - -INT strlenW(PCWSTR s) -{ - return wcslen(s); -} - -PWSTR strcpyW(PWSTR d, PCWSTR s) -{ - return wcscpy(d, s); -} - -PWSTR strncpyW(PWSTR d, PCWSTR s, SIZE_T c) -{ - return wcsncpy(d, s, c); -} - -INT strcmpiW(PCWSTR s1, PCWSTR s2) -{ - return wcsicmp(s1, s2); -} - -LONG strtolW(PCWSTR s, PWSTR *e, INT r) -{ - return wcstol(s, e, r); -} - -ULONG strtoulW(PCWSTR s, PWSTR *e, INT r) -{ - return wcstoul(s, e, r); -}
Modified: trunk/reactos/tools/mkhive/mkhive.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/mkhive/mkhive.rbuild?... ============================================================================== --- trunk/reactos/tools/mkhive/mkhive.rbuild [iso-8859-1] (original) +++ trunk/reactos/tools/mkhive/mkhive.rbuild [iso-8859-1] Sat May 1 22:17:11 2010 @@ -1,15 +1,17 @@ <?xml version="1.0"?> <!DOCTYPE module SYSTEM "../../tools/rbuild/project.dtd"> <module name="mkhive" type="buildtool"> - <include base="inflibhost">.</include> + <define name="WINE_UNICODE_API">" "</define> + <include base="unicode" /> + <include base="newinflibhost">.</include> <include base="cmlibhost">.</include> <include base="zlibhost">.</include> <include base="rtl">.</include> <define name="MKHIVE_HOST" /> <compilerflag compilerset="gcc">-fshort-wchar</compilerflag> - <library>inflibhost</library> + <library>newinflibhost</library> <library>cmlibhost</library> - <library>host_wcsfuncs</library> + <library>unicode</library> <file>binhive.c</file> <file>cmi.c</file> <file>mkhive.c</file>
Modified: trunk/reactos/tools/mkhive/reginf.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/mkhive/reginf.c?rev=4... ============================================================================== --- trunk/reactos/tools/mkhive/reginf.c [iso-8859-1] (original) +++ trunk/reactos/tools/mkhive/reginf.c [iso-8859-1] Sat May 1 22:17:11 2010 @@ -48,37 +48,51 @@ #define FLG_ADDREG_TYPE_MASK (0xFFFF0000 | FLG_ADDREG_BINVALUETYPE)
+static const WCHAR HKCR[] = {'H','K','C','R',0}; +static const WCHAR HKCU[] = {'H','K','C','U',0}; +static const WCHAR HKLM[] = {'H','K','L','M',0}; +static const WCHAR HKU[] = {'H','K','U',0}; +static const WCHAR HKR[] = {'H','K','R',0}; + +static const WCHAR HKCRPath[] = {'\','R','e','g','i','s','t','r','y','\','M','a','c','h','i','n','e','\','S','O','F','T','W','A','R','E','\','C','l','a','s','s','e','s','\',0}; +static const WCHAR HKCUPath[] = {'\','R','e','g','i','s','t','r','y','\','U','s','e','r','\','.','D','E','F','A','U','L','T','\',0}; +static const WCHAR HKLMPath[] = {'\','R','e','g','i','s','t','r','y','\','M','a','c','h','i','n','e','\',0}; +static const WCHAR HKUPath[] = {'\','R','e','g','i','s','t','r','y','\','U','s','e','r','\',0}; + +static const WCHAR AddReg[] = {'A','d','d','R','e','g',0}; +static const WCHAR DelReg[] = {'D','e','l','R','e','g',0}; + /* FUNCTIONS ****************************************************************/
static BOOL -GetRootKey (PCHAR Name) +GetRootKey (PWCHAR Name) { - if (!strcasecmp (Name, "HKCR")) - { - strcpy (Name, "\Registry\Machine\SOFTWARE\Classes\"); + if (!strcmpiW (Name, HKCR)) + { + strcpyW (Name, HKCRPath); return TRUE; }
- if (!strcasecmp (Name, "HKCU")) - { - strcpy (Name, "\Registry\User\.DEFAULT\"); + if (!strcmpiW (Name, HKCU)) + { + strcpyW (Name, HKCUPath); return TRUE; }
- if (!strcasecmp (Name, "HKLM")) - { - strcpy (Name, "\Registry\Machine\"); + if (!strcmpiW (Name, HKLM)) + { + strcpyW (Name, HKLMPath); return TRUE; }
- if (!strcasecmp (Name, "HKU")) - { - strcpy (Name, "\Registry\User\"); + if (!strcmpiW (Name, HKU)) + { + strcpyW (Name, HKUPath); return TRUE; }
#if 0 - if (!strcasecmp (Name, "HKR")) + if (!strcmpiW (Name, HKR)) return FALSE; #endif
@@ -94,19 +108,19 @@ static VOID AppendMultiSzValue ( IN HKEY KeyHandle, - IN PCHAR ValueName, - IN PCHAR Strings, + IN PWCHAR ValueName, + IN PWCHAR Strings, IN SIZE_T StringSize) { SIZE_T Size; ULONG Type; size_t Total; - PCHAR Buffer; - PCHAR p; + PWCHAR Buffer; + PWCHAR p; size_t len; LONG Error;
- Error = RegQueryValueExA ( + Error = RegQueryValueExW ( KeyHandle, ValueName, NULL, @@ -117,11 +131,11 @@ (Type != REG_MULTI_SZ)) return;
- Buffer = malloc (Size + StringSize); + Buffer = malloc ((Size + StringSize) * sizeof(WCHAR)); if (Buffer == NULL) return;
- Error = RegQueryValueExA ( + Error = RegQueryValueExW ( KeyHandle, ValueName, NULL, @@ -135,10 +149,10 @@ Total = Size; while (*Strings != 0) { - len = strlen (Strings) + 1; - - for (p = Buffer; *p != 0; p += strlen (p) + 1) - if (!strcasecmp (p, Strings)) + len = strlenW(Strings) + 1; + + for (p = Buffer; *p != 0; p += strlenW(p) + 1) + if (!strcmpiW(p, Strings)) break;
if (*p == 0) /* not found, need to append it */ @@ -152,14 +166,14 @@
if (Total != Size) { - DPRINT ("setting value %s to %s\n", ValueName, Buffer); - RegSetValueExA ( + DPRINT ("setting value %S to %S\n", ValueName, Buffer); + RegSetValueExW ( KeyHandle, ValueName, 0, REG_MULTI_SZ, (PUCHAR)Buffer, - (ULONG)Total); + (ULONG)Total * sizeof(WCHAR)); }
done: @@ -175,11 +189,11 @@ static BOOL do_reg_operation( IN HKEY KeyHandle, - IN PCHAR ValueName, + IN PWCHAR ValueName, IN PINFCONTEXT Context, IN ULONG Flags) { - CHAR EmptyStr = (CHAR)0; + WCHAR EmptyStr = (CHAR)0; ULONG Type; ULONG Size; LONG Error; @@ -188,11 +202,11 @@ { if (ValueName) { - RegDeleteValueA (KeyHandle, ValueName); + RegDeleteValueW (KeyHandle, ValueName); } else { - RegDeleteKeyA (KeyHandle, NULL); + RegDeleteKeyW (KeyHandle, NULL); }
return TRUE; @@ -203,7 +217,7 @@
if (Flags & (FLG_ADDREG_NOCLOBBER | FLG_ADDREG_OVERWRITEONLY)) { - Error = RegQueryValueExA ( + Error = RegQueryValueExW ( KeyHandle, ValueName, NULL, @@ -253,7 +267,7 @@ if (!(Flags & FLG_ADDREG_BINVALUETYPE) || (Type == REG_DWORD && InfHostGetFieldCount (Context) == 5)) { - PCHAR Str = NULL; + PWCHAR Str = NULL;
if (Type == REG_MULTI_SZ) { @@ -262,7 +276,7 @@
if (Size) { - Str = malloc (Size); + Str = malloc (Size * sizeof(WCHAR)); if (Str == NULL) return FALSE;
@@ -292,7 +306,7 @@
if (Size) { - Str = malloc (Size); + Str = malloc (Size * sizeof(WCHAR)); if (Str == NULL) return FALSE;
@@ -302,11 +316,11 @@
if (Type == REG_DWORD) { - ULONG dw = Str ? strtoul (Str, NULL, 0) : 0; - - DPRINT("setting dword %s to %x\n", ValueName, dw); - - RegSetValueExA ( + ULONG dw = Str ? strtoulW (Str, NULL, 0) : 0; + + DPRINT("setting dword %S to %x\n", ValueName, dw); + + RegSetValueExW ( KeyHandle, ValueName, 0, @@ -316,27 +330,27 @@ } else { - DPRINT("setting value %s to %s\n", ValueName, Str); + DPRINT("setting value %S to %S\n", ValueName, Str);
if (Str) { - RegSetValueExA ( + RegSetValueExW ( KeyHandle, ValueName, 0, Type, (PVOID)Str, - (ULONG)Size); + (ULONG)Size * sizeof(WCHAR)); } else { - RegSetValueExA ( + RegSetValueExW ( KeyHandle, ValueName, 0, Type, (PVOID)&EmptyStr, - (ULONG)sizeof(CHAR)); + (ULONG)sizeof(WCHAR)); } } free (Str); @@ -354,11 +368,11 @@ 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); }
- RegSetValueExA ( + RegSetValueExW ( KeyHandle, ValueName, 0, @@ -378,10 +392,10 @@ * Called once for each AddReg and DelReg entry in a given section. */ static BOOL -registry_callback (HINF hInf, PCHAR Section, BOOL Delete) +registry_callback (HINF hInf, PWCHAR Section, BOOL Delete) { - CHAR Buffer[MAX_INF_STRING_LENGTH]; - PCHAR ValuePtr; + WCHAR Buffer[MAX_INF_STRING_LENGTH]; + PWCHAR ValuePtr; ULONG Flags; size_t Length;
@@ -403,11 +417,11 @@ continue;
/* get key */ - Length = strlen (Buffer); + Length = strlenW (Buffer); 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) { @@ -424,17 +438,17 @@
if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY)) { - if (RegOpenKeyA (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS) - { - DPRINT("RegOpenKey(%s) failed\n", Buffer); + if (RegOpenKeyW (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS) + { + DPRINT("RegOpenKey(%S) failed\n", Buffer); continue; /* ignore if it doesn't exist */ } } else { - if (RegCreateKeyA (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS) - { - DPRINT("RegCreateKey(%s) failed\n", Buffer); + if (RegCreateKeyW (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS) + { + DPRINT("RegCreateKey(%S) failed\n", Buffer); continue; } } @@ -469,18 +483,18 @@ ULONG ErrorLine;
/* Load inf file from install media. */ - if (InfHostOpenFile(&hInf, FileName, &ErrorLine) != 0) + if (InfHostOpenFile(&hInf, FileName, 0, &ErrorLine) != 0) { DPRINT1 ("InfHostOpenFile(%s) failed\n", FileName); return FALSE; }
- if (!registry_callback (hInf, "DelReg", TRUE)) + if (!registry_callback (hInf, (PWCHAR)DelReg, TRUE)) { DPRINT1 ("registry_callback() for DelReg failed\n"); }
- if (!registry_callback (hInf, "AddReg", FALSE)) + if (!registry_callback (hInf, (PWCHAR)AddReg, FALSE)) { DPRINT1 ("registry_callback() for AddReg failed\n"); }
Modified: trunk/reactos/tools/mkhive/registry.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/mkhive/registry.c?rev... ============================================================================== --- trunk/reactos/tools/mkhive/registry.c [iso-8859-1] (original) +++ trunk/reactos/tools/mkhive/registry.c [iso-8859-1] Sat May 1 22:17:11 2010 @@ -127,7 +127,7 @@ LocalKeyName = (PWSTR)KeyName; for (;;) { - End = (PWSTR) utf16_wcschr(LocalKeyName, '\'); + End = (PWSTR)strchrW(LocalKeyName, '\'); if (End) { KeyString.Buffer = LocalKeyName; @@ -138,9 +138,9 @@ RtlInitUnicodeString(&KeyString, LocalKeyName);
/* Redirect from 'CurrentControlSet' to 'ControlSet001' */ - if (!utf16_wcsncmp(LocalKeyName, L"CurrentControlSet", 17) && - ParentKey->NameSize == 12 && - !memcmp(ParentKey->Name, L"SYSTEM", 12)) + if (!strncmpW(LocalKeyName, L"CurrentControlSet", 17) && + ParentKey->NameSize == 12 && + !memcmp(ParentKey->Name, L"SYSTEM", 12)) RtlInitUnicodeString(&KeyString, L"ControlSet001");
/* Check subkey in memory structure */
Modified: trunk/reactos/tools/mkhive/rtl.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/mkhive/rtl.c?rev=4707... ============================================================================== --- trunk/reactos/tools/mkhive/rtl.c [iso-8859-1] (original) +++ trunk/reactos/tools/mkhive/rtl.c [iso-8859-1] Sat May 1 22:17:11 2010 @@ -59,7 +59,7 @@
if(SourceString) { - DestSize = utf16_wcslen(SourceString) * sizeof(WCHAR); + DestSize = strlenW(SourceString) * sizeof(WCHAR); DestinationString->Length = (USHORT)DestSize; DestinationString->MaximumLength = (USHORT)DestSize + sizeof(WCHAR); }