From f995cc4ea6ad3ce7efc8509e26501a39d43156be Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 25 Apr 2010 19:20:59 +0000 Subject: [PATCH] [NEWINFLIB] - Use LANGID instead of LCID. - Move LANGID and language macros into the host typedefs header. - Remove dead code. svn path=/trunk/; revision=47018 --- reactos/include/host/typedefs.h | 6 ++++++ reactos/lib/newinflib/builddep.h | 6 ------ reactos/lib/newinflib/infget.c | 6 +++--- reactos/lib/newinflib/infhost.h | 4 ++-- reactos/lib/newinflib/infhostgen.c | 24 +++++------------------- reactos/lib/newinflib/infpriv.h | 2 +- reactos/lib/newinflib/infros.h | 4 ++-- reactos/lib/newinflib/infrosgen.c | 15 +++++---------- 8 files changed, 24 insertions(+), 43 deletions(-) diff --git a/reactos/include/host/typedefs.h b/reactos/include/host/typedefs.h index 42f30ed2294..07146c48220 100644 --- a/reactos/include/host/typedefs.h +++ b/reactos/include/host/typedefs.h @@ -65,6 +65,7 @@ typedef PVOID HANDLE, HKEY, *PHKEY; typedef INT NTSTATUS, POOL_TYPE; typedef LONG HRESULT; typedef ULONG_PTR SIZE_T, *PSIZE_T; +typedef WORD LANGID; #define MAXUSHORT USHRT_MAX @@ -232,6 +233,11 @@ typedef const UNICODE_STRING *PCUNICODE_STRING; #define RtlCopyMemory(Destination, Source, Length) memcpy(Destination, Source, Length) #define RtlMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length) +#define MAKELANGID(p,s) ((((WORD)(s))<<10)|(WORD)(p)) +#define PRIMARYLANGID(l) ((WORD)(l)&0x3ff) +#define SUBLANGID(l) ((WORD)(l)>>10) +#define SUBLANG_NEUTRAL 0x00 + /* Prevent inclusion of some other headers */ #define __INTERNAL_DEBUG #define RTL_H diff --git a/reactos/lib/newinflib/builddep.h b/reactos/lib/newinflib/builddep.h index c768a2ca88b..6930a7d597d 100644 --- a/reactos/lib/newinflib/builddep.h +++ b/reactos/lib/newinflib/builddep.h @@ -30,7 +30,6 @@ typedef char TCHAR, *PTCHAR, *PTSTR; typedef const TCHAR *PCTSTR; -typedef WORD LCID; #define _T(x) x #define _tcsicmp strcasecmp @@ -60,11 +59,6 @@ typedef WORD LCID; #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 3840 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 61440 -#define SUBLANG_NEUTRAL 0 -#define PRIMARYLANGID(lgid) ((WORD)(lgid) & 0x3ff) -#define MAKELANGID(p, s) ((((WORD)(s)) << 10) | (WORD)(p)) - - #else /* ! defined(INFLIB_HOST) */ /* ReactOS definitions */ diff --git a/reactos/lib/newinflib/infget.c b/reactos/lib/newinflib/infget.c index 1cdbebf2ee5..4238f1ce0b5 100644 --- a/reactos/lib/newinflib/infget.c +++ b/reactos/lib/newinflib/infget.c @@ -46,11 +46,11 @@ InfpGetSubstitutionString(PINFCACHE Inf, DPRINT("Value name: %S\n", ValueName); - if (Inf->LocaleId != 0) + if (Inf->LanguageId != 0) { swprintf(StringLangId, L"Strings.%04hx", - Inf->LocaleId); + Inf->LanguageId); Status = InfpFindFirstLine(Inf, StringLangId, @@ -60,7 +60,7 @@ InfpGetSubstitutionString(PINFCACHE Inf, { swprintf(StringLangId, L"Strings.%04hx", - MAKELANGID(PRIMARYLANGID(Inf->LocaleId), SUBLANG_NEUTRAL)); + MAKELANGID(PRIMARYLANGID(Inf->LanguageId), SUBLANG_NEUTRAL)); Status = InfpFindFirstLine(Inf, StringLangId, diff --git a/reactos/lib/newinflib/infhost.h b/reactos/lib/newinflib/infhost.h index 6cdb37cbfa1..62403da83d8 100644 --- a/reactos/lib/newinflib/infhost.h +++ b/reactos/lib/newinflib/infhost.h @@ -23,11 +23,11 @@ extern BOOLEAN NTAPI RtlIsTextUnicode( PVOID buf, INT len, INT *pf ); extern int InfHostOpenBufferedFile(PHINF InfHandle, void *Buffer, ULONG BufferSize, - LCID LocaleId, + LANGID LanguageId, ULONG *ErrorLine); extern int InfHostOpenFile(PHINF InfHandle, const CHAR *FileName, - LCID LocaleId, + LANGID LanguageId, ULONG *ErrorLine); extern int InfHostWriteFile(HINF InfHandle, const CHAR *FileName, diff --git a/reactos/lib/newinflib/infhostgen.c b/reactos/lib/newinflib/infhostgen.c index e5ad1b96e9b..e6269ff6318 100644 --- a/reactos/lib/newinflib/infhostgen.c +++ b/reactos/lib/newinflib/infhostgen.c @@ -20,7 +20,7 @@ int InfHostOpenBufferedFile(PHINF InfHandle, void *Buffer, ULONG BufferSize, - LCID LocaleId, + LANGID LanguageId, ULONG *ErrorLine) { INFSTATUS Status; @@ -59,8 +59,9 @@ InfHostOpenBufferedFile(PHINF InfHandle, ZEROMEMORY(Cache, sizeof(INFCACHE)); - Cache->LocaleId = LocaleId; + Cache->LanguageId = LanguageId; + /* Parse the inf buffer */ if (!RtlIsTextUnicode(FileBuffer, (INT)FileBufferSize, NULL)) { // static const BYTE utf8_bom[3] = { 0xef, 0xbb, 0xbf }; @@ -77,9 +78,6 @@ InfHostOpenBufferedFile(PHINF InfHandle, new_buff = MALLOC(FileBufferSize * sizeof(WCHAR)); if (new_buff != NULL) { -// DWORD len = MultiByteToWideChar( codepage, 0, (char *)FileBuffer + offset, -// FileBufferSize - offset, new_buff, FileBufferSize); - ULONG len; Status = RtlMultiByteToUnicodeN(new_buff, FileBufferSize * sizeof(WCHAR), @@ -111,11 +109,6 @@ InfHostOpenBufferedFile(PHINF InfHandle, ErrorLine); } - /* Parse the inf buffer */ -// Status = InfpParseBuffer (Cache, -// FileBuffer, -// FileBuffer + BufferSize, -// ErrorLine); if (!INF_SUCCESS(Status)) { FREE(Cache); @@ -134,7 +127,7 @@ InfHostOpenBufferedFile(PHINF InfHandle, int InfHostOpenFile(PHINF InfHandle, const CHAR *FileName, - LCID LocaleId, + LANGID LanguageId, ULONG *ErrorLine) { FILE *File; @@ -219,7 +212,7 @@ InfHostOpenFile(PHINF InfHandle, ZEROMEMORY(Cache, sizeof(INFCACHE)); - Cache->LocaleId = LocaleId; + Cache->LanguageId = LanguageId; /* Parse the inf buffer */ if (!RtlIsTextUnicode(FileBuffer, (INT)FileBufferLength, NULL)) @@ -238,9 +231,6 @@ InfHostOpenFile(PHINF InfHandle, new_buff = MALLOC(FileBufferLength * sizeof(WCHAR)); if (new_buff != NULL) { -// DWORD len = MultiByteToWideChar( codepage, 0, (char *)FileBuffer + offset, -// FileLength - offset, new_buff, FileLength); - ULONG len; Status = RtlMultiByteToUnicodeN(new_buff, FileBufferLength * sizeof(WCHAR), @@ -273,10 +263,6 @@ InfHostOpenFile(PHINF InfHandle, ErrorLine); } -// Status = InfpParseBuffer (Cache, -// FileBuffer, -// FileBuffer + FileLength, -// ErrorLine); if (!INF_SUCCESS(Status)) { FREE(Cache); diff --git a/reactos/lib/newinflib/infpriv.h b/reactos/lib/newinflib/infpriv.h index 0d2cea94dc4..c7adededd5d 100644 --- a/reactos/lib/newinflib/infpriv.h +++ b/reactos/lib/newinflib/infpriv.h @@ -55,7 +55,7 @@ typedef struct _INFCACHESECTION typedef struct _INFCACHE { - LCID LocaleId; + LANGID LanguageId; PINFCACHESECTION FirstSection; PINFCACHESECTION LastSection; diff --git a/reactos/lib/newinflib/infros.h b/reactos/lib/newinflib/infros.h index c467af9f3fb..92dbc5133db 100644 --- a/reactos/lib/newinflib/infros.h +++ b/reactos/lib/newinflib/infros.h @@ -18,11 +18,11 @@ extern VOID InfSetHeap(PVOID Heap); extern NTSTATUS InfOpenBufferedFile(PHINF InfHandle, PVOID Buffer, ULONG BufferSize, - LCID LocaleId, + LANGID LanguageId, PULONG ErrorLine); extern NTSTATUS InfOpenFile(PHINF InfHandle, PUNICODE_STRING FileName, - LCID LocaleId, + LANGID LanguageId, PULONG ErrorLine); extern NTSTATUS InfWriteFile(HINF InfHandle, PUNICODE_STRING FileName, diff --git a/reactos/lib/newinflib/infrosgen.c b/reactos/lib/newinflib/infrosgen.c index 8ea53ae58d2..e994b28f030 100644 --- a/reactos/lib/newinflib/infrosgen.c +++ b/reactos/lib/newinflib/infrosgen.c @@ -51,7 +51,7 @@ NTSTATUS InfOpenBufferedFile(PHINF InfHandle, PVOID Buffer, ULONG BufferSize, - LCID LocaleId, + LANGID LanguageId, PULONG ErrorLine) { INFSTATUS Status; @@ -92,8 +92,9 @@ InfOpenBufferedFile(PHINF InfHandle, ZEROMEMORY(Cache, sizeof(INFCACHE)); - Cache->LocaleId = LocaleId; + Cache->LanguageId = LanguageId; + /* Parse the inf buffer */ if (!RtlIsTextUnicode(FileBuffer, FileBufferSize, NULL)) { // static const BYTE utf8_bom[3] = { 0xef, 0xbb, 0xbf }; @@ -110,9 +111,6 @@ InfOpenBufferedFile(PHINF InfHandle, new_buff = MALLOC(FileBufferSize * sizeof(WCHAR)); if (new_buff != NULL) { -// DWORD len = MultiByteToWideChar( codepage, 0, (char *)FileBuffer + offset, -// FileBufferSize - offset, new_buff, FileBufferSize); - ULONG len; Status = RtlMultiByteToUnicodeN(new_buff, FileBufferSize * sizeof(WCHAR), @@ -162,7 +160,7 @@ InfOpenBufferedFile(PHINF InfHandle, NTSTATUS InfOpenFile(PHINF InfHandle, PUNICODE_STRING FileName, - LCID LocaleId, + LANGID LanguageId, PULONG ErrorLine) { OBJECT_ATTRIBUTES ObjectAttributes; @@ -267,7 +265,7 @@ InfOpenFile(PHINF InfHandle, ZEROMEMORY(Cache, sizeof(INFCACHE)); - Cache->LocaleId = LocaleId; + Cache->LanguageId = LanguageId; /* Parse the inf buffer */ if (!RtlIsTextUnicode(FileBuffer, FileBufferLength, NULL)) @@ -286,9 +284,6 @@ InfOpenFile(PHINF InfHandle, new_buff = MALLOC(FileBufferLength * sizeof(WCHAR)); if (new_buff != NULL) { -// DWORD len = MultiByteToWideChar( codepage, 0, (char *)FileBuffer + offset, -// FileLength - offset, new_buff, FileLength); - ULONG len; Status = RtlMultiByteToUnicodeN(new_buff, FileBufferLength * sizeof(WCHAR), -- 2.17.1