[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!!!

svn path=/trunk/; revision=47076
This commit is contained in:
Eric Kohl 2010-05-01 20:17:11 +00:00
parent 35ff67b13e
commit 4f7643e5b3
12 changed files with 101 additions and 134 deletions

View file

@ -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

View file

@ -21,7 +21,7 @@ CmCreateRootNode(
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,

View file

@ -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>

View file

@ -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_" />

View file

@ -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 @@ BOOLEAN NTAPI RtlIsTextUnicode( PVOID buf, INT len, INT *pf );
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 @@ ULONG strtoulW(PCWSTR s, PWSTR *e, INT r);
#endif /* INFLIB_HOST */
#include <host/wcsfuncs.h>
/* EOF */

View file

@ -41,7 +41,7 @@ InfpGetSubstitutionString(PINFCACHE Inf,
return &percent;
}
strncpyW(ValueName, str, *len);
memcpy(ValueName, str, *len * sizeof(WCHAR));
ValueName[*len] = 0;
DPRINT("Value name: %S\n", ValueName);

View file

@ -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>

View file

@ -1,51 +0,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);
}

View file

@ -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>

View file

@ -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"))
if (!strcmpiW (Name, HKCR))
{
strcpy (Name, "\\Registry\\Machine\\SOFTWARE\\Classes\\");
strcpyW (Name, HKCRPath);
return TRUE;
}
if (!strcasecmp (Name, "HKCU"))
if (!strcmpiW (Name, HKCU))
{
strcpy (Name, "\\Registry\\User\\.DEFAULT\\");
strcpyW (Name, HKCUPath);
return TRUE;
}
if (!strcasecmp (Name, "HKLM"))
if (!strcmpiW (Name, HKLM))
{
strcpy (Name, "\\Registry\\Machine\\");
strcpyW (Name, HKLMPath);
return TRUE;
}
if (!strcasecmp (Name, "HKU"))
if (!strcmpiW (Name, HKU))
{
strcpy (Name, "\\Registry\\User\\");
strcpyW (Name, HKUPath);
return TRUE;
}
#if 0
if (!strcasecmp (Name, "HKR"))
if (!strcmpiW (Name, HKR))
return FALSE;
#endif
@ -94,19 +108,19 @@ GetRootKey (PCHAR Name)
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 @@ AppendMultiSzValue (
(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 @@ AppendMultiSzValue (
Total = Size;
while (*Strings != 0)
{
len = strlen (Strings) + 1;
len = strlenW(Strings) + 1;
for (p = Buffer; *p != 0; p += strlen (p) + 1)
if (!strcasecmp (p, Strings))
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 @@ AppendMultiSzValue (
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 @@ done:
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 @@ do_reg_operation(
{
if (ValueName)
{
RegDeleteValueA (KeyHandle, ValueName);
RegDeleteValueW (KeyHandle, ValueName);
}
else
{
RegDeleteKeyA (KeyHandle, NULL);
RegDeleteKeyW (KeyHandle, NULL);
}
return TRUE;
@ -203,7 +217,7 @@ do_reg_operation(
if (Flags & (FLG_ADDREG_NOCLOBBER | FLG_ADDREG_OVERWRITEONLY))
{
Error = RegQueryValueExA (
Error = RegQueryValueExW (
KeyHandle,
ValueName,
NULL,
@ -253,7 +267,7 @@ do_reg_operation(
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 @@ do_reg_operation(
if (Size)
{
Str = malloc (Size);
Str = malloc (Size * sizeof(WCHAR));
if (Str == NULL)
return FALSE;
@ -292,7 +306,7 @@ do_reg_operation(
if (Size)
{
Str = malloc (Size);
Str = malloc (Size * sizeof(WCHAR));
if (Str == NULL)
return FALSE;
@ -302,11 +316,11 @@ do_reg_operation(
if (Type == REG_DWORD)
{
ULONG dw = Str ? strtoul (Str, NULL, 0) : 0;
ULONG dw = Str ? strtoulW (Str, NULL, 0) : 0;
DPRINT("setting dword %s to %x\n", ValueName, dw);
DPRINT("setting dword %S to %x\n", ValueName, dw);
RegSetValueExA (
RegSetValueExW (
KeyHandle,
ValueName,
0,
@ -316,27 +330,27 @@ do_reg_operation(
}
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 @@ do_reg_operation(
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 @@ do_reg_operation(
* 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 @@ registry_callback (HINF hInf, PCHAR Section, BOOL Delete)
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 @@ registry_callback (HINF hInf, PCHAR Section, BOOL Delete)
if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY))
{
if (RegOpenKeyA (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
if (RegOpenKeyW (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
{
if (RegCreateKeyA (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
if (RegCreateKeyW (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
{
DPRINT("RegCreateKey(%s) failed\n", Buffer);
DPRINT("RegCreateKey(%S) failed\n", Buffer);
continue;
}
}
@ -469,18 +483,18 @@ ImportRegistryFile(PCHAR FileName)
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");
}

View file

@ -127,7 +127,7 @@ RegpOpenOrCreateKey(
LocalKeyName = (PWSTR)KeyName;
for (;;)
{
End = (PWSTR) utf16_wcschr(LocalKeyName, '\\');
End = (PWSTR)strchrW(LocalKeyName, '\\');
if (End)
{
KeyString.Buffer = LocalKeyName;
@ -138,9 +138,9 @@ RegpOpenOrCreateKey(
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 */

View file

@ -59,7 +59,7 @@ RtlInitUnicodeString(
if(SourceString)
{
DestSize = utf16_wcslen(SourceString) * sizeof(WCHAR);
DestSize = strlenW(SourceString) * sizeof(WCHAR);
DestinationString->Length = (USHORT)DestSize;
DestinationString->MaximumLength = (USHORT)DestSize + sizeof(WCHAR);
}