From b09592bf32feb471309f46ada5a873c1d5f2cc6d Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 20 Nov 1999 21:49:23 +0000 Subject: [PATCH] Major update to Rtl string functions. svn path=/trunk/; revision=786 --- reactos/include/ddk/rtl.h | 208 +-- reactos/lib/ntdll/def/ntdll.def | 26 +- reactos/lib/ntdll/def/ntdll.edf | 17 +- reactos/lib/ntdll/rtl/nls.c | 334 +++-- reactos/lib/ntdll/rtl/unicode.c | 1668 +++++++++++++++++-------- reactos/lib/psxdll/misc/rtl.c | 190 ++- reactos/lib/psxdll/psxdll.def | 10 +- reactos/lib/psxdll/psxdll.edf | 10 +- reactos/ntoskrnl/ntoskrnl.def | 11 +- reactos/ntoskrnl/ntoskrnl.edf | 11 +- reactos/ntoskrnl/rtl/nls.c | 130 +- reactos/ntoskrnl/rtl/unicode.c | 728 ++++++++--- reactos/ntoskrnl/rtl/unicode.c.new | 529 -------- reactos/subsys/win32k/objects/brush.c | 4 +- reactos/subsys/win32k/stubs/stubs.c | 4 +- reactos/subsys/win32k/win32k.def | 18 +- 16 files changed, 2399 insertions(+), 1499 deletions(-) delete mode 100644 reactos/ntoskrnl/rtl/unicode.c.new diff --git a/reactos/include/ddk/rtl.h b/reactos/include/ddk/rtl.h index cf596ddbae2..b59230add4d 100644 --- a/reactos/include/ddk/rtl.h +++ b/reactos/include/ddk/rtl.h @@ -1,4 +1,4 @@ -/* $Id: rtl.h,v 1.17 1999/11/15 15:55:00 ekohl Exp $ +/* $Id: rtl.h,v 1.18 1999/11/20 21:44:09 ekohl Exp $ * */ @@ -18,29 +18,29 @@ typedef struct _CONTROLLER_OBJECT } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT; typedef struct _STRING -{ - USHORT Length; - USHORT MaximumLength; - PCHAR Buffer; -} STRING, *PSTRING; - -typedef struct _ANSI_STRING { /* * Length in bytes of the string stored in buffer */ USHORT Length; - + /* * Maximum length of the string */ USHORT MaximumLength; - + /* * String */ PCHAR Buffer; -} ANSI_STRING, *PANSI_STRING; +} STRING, *PSTRING; + +typedef STRING ANSI_STRING; +typedef PSTRING PANSI_STRING; + +typedef STRING OEM_STRING; +typedef PSTRING POEM_STRING; + typedef struct _TIME_FIELDS { @@ -189,10 +189,18 @@ RemoveTailList ( PLIST_ENTRY ListHead ); +PVOID +STDCALL +RtlAllocateHeap ( + HANDLE Heap, + ULONG Flags, + ULONG Size + ); + WCHAR STDCALL RtlAnsiCharToUnicodeChar ( - PCHAR AnsiChar + CHAR AnsiChar ); ULONG @@ -330,8 +338,15 @@ RtlCreateSecurityDescriptor ( BOOLEAN STDCALL RtlCreateUnicodeString ( - PUNICODE_STRING Destination, - PWSTR Source + OUT PUNICODE_STRING Destination, + IN PWSTR Source + ); + +BOOLEAN +STDCALL +RtlCreateUnicodeStringFromAsciiz ( + OUT PUNICODE_STRING Destination, + IN PCSZ Source ); NTSTATUS @@ -342,6 +357,14 @@ RtlDeleteRegistryValue ( PWSTR ValueName ); +NTSTATUS +STDCALL +RtlDowncaseUnicodeString ( + IN OUT PUNICODE_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ); + LARGE_INTEGER RtlEnlargedIntegerMultiply ( LONG Multiplicand, @@ -377,6 +400,13 @@ RtlEqualUnicodeString ( BOOLEAN CaseInSensitive ); +/* RtlEraseUnicodeString is exported by ntdll.dll only! */ +VOID +STDCALL +RtlEraseUnicodeString ( + IN PUNICODE_STRING String + ); + LARGE_INTEGER RtlExtendedIntegerMultiply ( LARGE_INTEGER Multiplicand, @@ -422,7 +452,7 @@ RtlFreeAnsiString ( VOID STDCALL RtlFreeOemString ( - PSTRING OemString + POEM_STRING OemString ); VOID @@ -459,73 +489,21 @@ RtlInitUnicodeString ( PCWSTR SourceString ); +NTSTATUS +STDCALL +RtlIntegerToChar ( + IN ULONG Value, + IN ULONG Base, + IN ULONG Length, + IN OUT PCHAR String + ); + NTSTATUS STDCALL RtlIntegerToUnicodeString ( - ULONG Value, - ULONG Base, - PUNICODE_STRING String - ); - -LARGE_INTEGER -RtlLargeIntegerAdd ( - LARGE_INTEGER Addend1, - LARGE_INTEGER Addend2 - ); - -VOID -RtlLargeIntegerAnd ( - PLARGE_INTEGER Result, - LARGE_INTEGER Source, - LARGE_INTEGER Mask - ); - -/* MISSING FUNCTIONS GO HERE */ - -LARGE_INTEGER -RtlEnlargedIntegerMultiply ( - LONG Multiplicand, - LONG Multiplier - ); - -ULONG -RtlEnlargedUnsignedDivide ( - ULARGE_INTEGER Dividend, - ULONG Divisor, - PULONG Remainder - ); - -LARGE_INTEGER -RtlEnlargedUnsignedMultiply ( - ULONG Multiplicand, - ULONG Multipler - ); - -LARGE_INTEGER -RtlExtendedIntegerMultiply ( - LARGE_INTEGER Multiplicand, - LONG Multiplier - ); - -LARGE_INTEGER -RtlExtendedLargeIntegerDivide ( - LARGE_INTEGER Dividend, - ULONG Divisor, - PULONG Remainder - ); - -LARGE_INTEGER -RtlExtendedMagicDivide ( - LARGE_INTEGER Dividend, - LARGE_INTEGER MagicDivisor, - CCHAR ShiftCount - ); - -LARGE_INTEGER -ExInterlockedAddLargeInteger ( - PLARGE_INTEGER Addend, - LARGE_INTEGER Increment, - PKSPIN_LOCK Lock + IN ULONG Value, + IN ULONG Base, + IN OUT PUNICODE_STRING String ); LARGE_INTEGER @@ -677,14 +655,14 @@ RtlMultiByteToUnicodeSize ( ULONG STDCALL RtlOemStringToUnicodeSize ( - PANSI_STRING AnsiString + POEM_STRING AnsiString ); NTSTATUS STDCALL RtlOemStringToUnicodeString ( PUNICODE_STRING DestinationString, - PANSI_STRING SourceString, + POEM_STRING SourceString, BOOLEAN AllocateDestinationString ); @@ -772,8 +750,8 @@ RtlZeroMemory ( ); typedef struct { - ULONG Length; - ULONG Unknown[11]; + ULONG Length; + ULONG Unknown[11]; } RTL_HEAP_DEFINITION, *PRTL_HEAP_DEFINITION; // Heap creation routine @@ -789,14 +767,6 @@ RtlCreateHeap ( PRTL_HEAP_DEFINITION Definition ); -PVOID -STDCALL -RtlAllocateHeap ( - HANDLE Heap, - ULONG Flags, - ULONG Size - ); - BOOLEAN STDCALL @@ -837,7 +807,7 @@ RtlUnicodeStringToOemSize ( NTSTATUS STDCALL RtlUnicodeStringToOemString ( - IN OUT PANSI_STRING DestinationString, + IN OUT POEM_STRING DestinationString, IN PUNICODE_STRING SourceString, IN BOOLEAN AllocateDestinationString ); @@ -870,12 +840,60 @@ RtlUnicodeToOemN ( ULONG UnicodeSize ); +WCHAR +STDCALL +RtlUpcaseUnicodeChar ( + WCHAR Source + ); + NTSTATUS STDCALL RtlUpcaseUnicodeString ( - PUNICODE_STRING DestinationString, - PUNICODE_STRING SourceString, - BOOLEAN AllocateDestinationString + IN OUT PUNICODE_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ); + +NTSTATUS +STDCALL +RtlUpcaseUnicodeStringToAnsiString ( + IN OUT PANSI_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ); + +NTSTATUS +STDCALL +RtlUpcaseUnicodeStringToOemString ( + IN OUT POEM_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ); + +NTSTATUS +STDCALL +RtlUpcaseUnicodeToMultiByteN ( + PCHAR MbString, + ULONG MbSize, + PULONG ResultSize, + PWCHAR UnicodeString, + ULONG UnicodeSize + ); + +NTSTATUS +STDCALL +RtlUpcaseUnicodeToOemN ( + PCHAR OemString, + ULONG OemSize, + PULONG ResultSize, + PWCHAR UnicodeString, + ULONG UnicodeSize + ); + +CHAR +STDCALL +RtlUpperChar ( + CHAR Source ); VOID diff --git a/reactos/lib/ntdll/def/ntdll.def b/reactos/lib/ntdll/def/ntdll.def index 76937afe662..428815f26a1 100644 --- a/reactos/lib/ntdll/def/ntdll.def +++ b/reactos/lib/ntdll/def/ntdll.def @@ -1,4 +1,4 @@ -; $Id: ntdll.def,v 1.22 1999/11/15 15:57:55 ekohl Exp $ +; $Id: ntdll.def,v 1.23 1999/11/20 21:46:16 ekohl Exp $ ; ; ReactOS Operating System ; @@ -433,10 +433,14 @@ RtlAllocateHeap@12 RtlAnsiCharToUnicodeChar@4 RtlAnsiStringToUnicodeSize@4 RtlAnsiStringToUnicodeString@12 +RtlAppendAsciizToString@12 +RtlAppendStringToString@12 RtlAppendUnicodeStringToString@12 RtlAppendUnicodeToString@12 RtlCharToInteger@12 RtlCreateHeap@24 +RtlCreateUnicodeString@8 +RtlCreateUnicodeStringFromAsciiz@8 RtlCreateUserProcess@32 RtlCreateUserThread@40 RtlCompactHeap@8 @@ -447,23 +451,27 @@ RtlConvertUlongToLargeInteger RtlCopyString@8 RtlCopyUnicodeString@8 RtlDestroyHeap@4 +RtlDowncaseUnicodeString@12 RtlEnlargedIntegerMultiply RtlEnlargedUnsignedDivide RtlEnlargedUnsignedMultiply RtlEqualString@12 RtlEqualUnicodeString@12 +RtlEraseUnicodeString@4 RtlExtendedIntegerMultiply RtlExtendedLargeIntegerDivide RtlExtendedMagicDivide RtlFillMemory@12 RtlFreeAnsiString@4 RtlFreeHeap@12 +RtlFreeOemString@4 RtlFreeUnicodeString@4 RtlGetProcessHeap@0 RtlInitAnsiString@8 RtlInitializeContext@20 RtlInitString@8 RtlInitUnicodeString@8 +RtlIntegerToChar@16 RtlIntegerToUnicodeString@12 RtlLargeIntegerAdd RtlLargeIntegerArithmeticShift @@ -477,19 +485,29 @@ RtlLockHeap@4 RtlMoveMemory@12 RtlMultiByteToUnicodeN@20 RtlNtStatusToDosError +RtlOemStringToUnicodeSize@4 +RtlOemStringToUnicodeString@12 +RtlOemToUnicodeN@20 RtlReAllocateHeap@16 RtlSizeHeap@12 RtlUnlockHeap@4 RtlUnicodeStringToAnsiSize@4 RtlUnicodeStringToAnsiString@12 RtlUnicodeStringToInteger@12 +RtlUnicodeStringToOemSize@4 +RtlUnicodeStringToOemString@12 RtlUnicodeToMultiByteN@20 RtlUnicodeToMultiByteSize@12 +RtlUnicodeToOemN@20 RtlUnwind@0 -RtlUpcaseString@8 -RtlUpcaseUnicodeChar +RtlUpcaseUnicodeChar@4 RtlUpcaseUnicodeString@12 -RtlUpcaseUnicodeToMultiByteN@0 +RtlUpcaseUnicodeStringToAnsiString@12 +RtlUpcaseUnicodeStringToOemString@12 +RtlUpcaseUnicodeToMultiByteN@20 +RtlUpcaseUnicodeToOemN@20 +RtlUpperChar@4 +RtlUpperString@8 RtlValidateHeap@12 RtlZeroMemory@8 _memccpy diff --git a/reactos/lib/ntdll/def/ntdll.edf b/reactos/lib/ntdll/def/ntdll.edf index 45eae2773b5..d3ec2b002b3 100644 --- a/reactos/lib/ntdll/def/ntdll.edf +++ b/reactos/lib/ntdll/def/ntdll.edf @@ -1,4 +1,4 @@ -; $Id: ntdll.edf,v 1.11 1999/11/15 15:57:55 ekohl Exp $ +; $Id: ntdll.edf,v 1.12 1999/11/20 21:46:16 ekohl Exp $ ; ; ReactOS Operating System ; @@ -437,6 +437,8 @@ RtlAppendUnicodeStringToString=RtlAppendUnicodeStringToString@8 RtlAppendUnicodeToString=RtlAppendUnicodeToString@8 RtlCharToInteger=RtlCharToInteger@12 RtlCreateHeap=RtlCreateHeap@24 +RtlCreateUnicodeString=RtlCreateUnicodeString@8 +RtlCreateUnicodeStringFromAsciiz=RtlCreateUnicodeStringFromAsciiz@8 RtlCreateUserProcess=RtlCreateUserProcess@32 RtlCreateUserThread=RtlCreateUserThread@40 RtlCompactHeap=RtlCompactHeap@8 @@ -447,11 +449,13 @@ RtlConvertUlongToLargeInteger RtlCopyString=RtlCopyString@8 RtlCopyUnicodeString=RtlCopyUnicodeString@8 RtlDestroyHeap=RtlDestroyHeap@4 +RtlDowncaseUnicodeString=RtlDowncaseUnicodeString@12 RtlEnlargedIntegerMultiply RtlEnlargedUnsignedDivide RtlEnlargedUnsignedMultiply RtlEqualString=RtlEqualString@12 RtlEqualUnicodeString=RtlEqualUnicodeString@12 +RtlEraseUnicodeString=RtlEraseUnicodeString@4 RtlExtendedIntegerMultiply RtlExtendedLargeIntegerDivide RtlExtendedMagicDivide @@ -464,6 +468,7 @@ RtlInitAnsiString=RtlInitAnsiString@8 RtlInitializeContext=RtlInitializeContext@20 RtlInitString=RtlInitString@8 RtlInitUnicodeString=RtlInitUnicodeString@8 +RtlIntegerToChar=RtlIntegerToChar@16 RtlIntegerToUnicodeString=RtlIntegerToUnicodeString@12 RtlLargeIntegerAdd RtlLargeIntegerArithmeticShift @@ -486,10 +491,14 @@ RtlUnicodeStringToInteger=RtlUnicodeStringToInteger@12 RtlUnicodeToMultiByteN=RtlUnicodeToMultiByteN@20 RtlUnicodeToMultiByteSize=RtlUnicodeToMultiByteSize@12 RtlUnwind=RtlUnwind@0 -RtlUpcaseString=RtlUpcaseString@8 -RtlUpcaseUnicodeChar=RtlUpcaseUnicodeChar@0 +RtlUpcaseUnicodeChar=RtlUpcaseUnicodeChar@4 RtlUpcaseUnicodeString=RtlUpcaseUnicodeString@12 -RtlUpcaseUnicodeToMultiByteN=RtlUpcaseUnicodeToMultiByteN@0 +RtlUpcaseUnicodeStringToAnsiString=RtlUpcaseUnicodeStringToAnsiString@12 +RtlUpcaseUnicodeStringToOemString=RtlUpcaseUnicodeStringToOemString@12 +RtlUpcaseUnicodeToMultiByteN=RtlUpcaseUnicodeToMultiByteN@20 +RtlUpcaseUnicodeToOemN=RtlUpcaseUnicodeToOemN@20 +RtlUpperChar=RtlUpperChar@4 +RtlUpperString=RtlUpperString@8 RtlValidateHeap=RtlValidateHeap@12 RtlZeroMemory=RtlZeroMemory@8 _memccpy diff --git a/reactos/lib/ntdll/rtl/nls.c b/reactos/lib/ntdll/rtl/nls.c index d72d02d8bc4..62af79024da 100644 --- a/reactos/lib/ntdll/rtl/nls.c +++ b/reactos/lib/ntdll/rtl/nls.c @@ -1,8 +1,8 @@ -/* $Id: nls.c,v 1.1 1999/11/15 15:59:29 ekohl Exp $ +/* $Id: nls.c,v 1.2 1999/11/20 21:46:46 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel - * FILE: ntoskrnl/rtl/nls.c + * FILE: lib/ntdll/rtl/nls.c * PURPOSE: National Language Support (NLS) functions * UPDATE HISTORY: * 20/08/99 Created by Emanuele Aliberti @@ -59,8 +59,8 @@ STDCALL RtlGetDefaultCodePage (PUSHORT AnsiCodePage, PUSHORT OemCodePage) { - *AnsiCodePage = NlsAnsiCodePage; - *OemCodePage = NlsOemCodePage; + *AnsiCodePage = NlsAnsiCodePage; + *OemCodePage = NlsOemCodePage; } @@ -72,39 +72,39 @@ RtlMultiByteToUnicodeN(PWCHAR UnicodeString, PCHAR MbString, ULONG MbSize) { - ULONG Size = 0; - ULONG i; + ULONG Size = 0; + ULONG i; - if (NlsMbCodePageTag == FALSE) - { - /* single-byte code page */ - if (MbSize > (UnicodeSize / sizeof(WCHAR))) - Size = UnicodeSize / sizeof(WCHAR); - else - Size = MbSize; + if (NlsMbCodePageTag == FALSE) + { + /* single-byte code page */ + if (MbSize > (UnicodeSize / sizeof(WCHAR))) + Size = UnicodeSize / sizeof(WCHAR); + else + Size = MbSize; - if (ResultSize != NULL) - *ResultSize = Size * sizeof(WCHAR); + if (ResultSize != NULL) + *ResultSize = Size * sizeof(WCHAR); - for (i = 0; i < Size; i++) - { - *UnicodeString = *MbString; + for (i = 0; i < Size; i++) + { + *UnicodeString = *MbString; #if 0 - *UnicodeString = AnsiToUnicodeTable[*MbString]; + *UnicodeString = AnsiToUnicodeTable[*MbString]; #endif - UnicodeString++; - MbString++; - }; - } - else - { - /* multi-byte code page */ - /* FIXME */ + UnicodeString++; + MbString++; + } + } + else + { + /* multi-byte code page */ + /* FIXME */ - } + } - return STATUS_SUCCESS; + return STATUS_SUCCESS; } @@ -114,19 +114,63 @@ RtlMultiByteToUnicodeSize(PULONG UnicodeSize, PCHAR MbString, ULONG MbSize) { - if (NlsMbCodePageTag == FALSE) - { - /* single-byte code page */ - *UnicodeSize = MbSize * sizeof (WCHAR); - } - else - { - /* multi-byte code page */ - /* FIXME */ + if (NlsMbCodePageTag == FALSE) + { + /* single-byte code page */ + *UnicodeSize = MbSize * sizeof (WCHAR); + } + else + { + /* multi-byte code page */ + /* FIXME */ - } + } - return STATUS_SUCCESS; + return STATUS_SUCCESS; +} + + +NTSTATUS +STDCALL +RtlOemToUnicodeN(PWCHAR UnicodeString, + ULONG UnicodeSize, + PULONG ResultSize, + PCHAR OemString, + ULONG OemSize) +{ + ULONG Size = 0; + ULONG i; + + if (NlsMbOemCodePageTag == FALSE) + { + /* single-byte code page */ + if (OemSize > (UnicodeSize / sizeof(WCHAR))) + Size = UnicodeSize / sizeof(WCHAR); + else + Size = OemSize; + + if (ResultSize != NULL) + *ResultSize = Size * sizeof(WCHAR); + + for (i = 0; i < Size; i++) + { + *UnicodeString = *OemString; +#if 0 + *UnicodeString = OemToUnicodeTable[*OemString]; +#endif + + UnicodeString++; + OemString++; + }; + } + else + { + /* multi-byte code page */ + /* FIXME */ + + } + + return STATUS_SUCCESS; } @@ -138,39 +182,39 @@ RtlUnicodeToMultiByteN(PCHAR MbString, PWCHAR UnicodeString, ULONG UnicodeSize) { - ULONG Size = 0; - ULONG i; + ULONG Size = 0; + ULONG i; - if (NlsMbCodePageTag == FALSE) - { - /* single-byte code page */ - if (UnicodeSize > (MbSize * sizeof(WCHAR))) - Size = MbSize; - else - Size = UnicodeSize / sizeof(WCHAR); + if (NlsMbCodePageTag == FALSE) + { + /* single-byte code page */ + if (UnicodeSize > (MbSize * sizeof(WCHAR))) + Size = MbSize; + else + Size = UnicodeSize / sizeof(WCHAR); - if (ResultSize != NULL) - *ResultSize = Size; + if (ResultSize != NULL) + *ResultSize = Size; - for (i = 0; i < Size; i++) - { - *MbString = *UnicodeString; + for (i = 0; i < Size; i++) + { + *MbString = *UnicodeString; #if 0 - *MbString = UnicodeToAnsiTable[*UnicodeString]; + *MbString = UnicodeToAnsiTable[*UnicodeString]; #endif - MbString++; - UnicodeString++; - }; - } - else - { - /* multi-byte code page */ - /* FIXME */ + MbString++; + UnicodeString++; + } + } + else + { + /* multi-byte code page */ + /* FIXME */ - } + } - return STATUS_SUCCESS; + return STATUS_SUCCESS; } @@ -180,19 +224,157 @@ RtlUnicodeToMultiByteSize(PULONG MbSize, PWCHAR UnicodeString, ULONG UnicodeSize) { - if (NlsMbCodePageTag == FALSE) - { - /* single-byte code page */ - *MbSize = UnicodeSize / sizeof (WCHAR); - } - else - { - /* multi-byte code page */ - /* FIXME */ + if (NlsMbCodePageTag == FALSE) + { + /* single-byte code page */ + *MbSize = UnicodeSize / sizeof (WCHAR); + } + else + { + /* multi-byte code page */ + /* FIXME */ - } + } - return STATUS_SUCCESS; + return STATUS_SUCCESS; +} + + +NTSTATUS +STDCALL +RtlUnicodeToOemN(PCHAR OemString, + ULONG OemSize, + PULONG ResultSize, + PWCHAR UnicodeString, + ULONG UnicodeSize) +{ + ULONG Size = 0; + ULONG i; + + if (NlsMbOemCodePageTag == FALSE) + { + /* single-byte code page */ + if (UnicodeSize > (OemSize * sizeof(WCHAR))) + Size = OemSize; + else + Size = UnicodeSize / sizeof(WCHAR); + + if (ResultSize != NULL) + *ResultSize = Size; + + for (i = 0; i < Size; i++) + { + *OemString = *UnicodeString; +#if 0 + *OemString = UnicodeToOemTable[*UnicodeString]; +#endif + + OemString++; + UnicodeString++; + }; + } + else + { + /* multi-byte code page */ + /* FIXME */ + + } + + return STATUS_SUCCESS; +} + + +NTSTATUS +STDCALL +RtlUpcaseUnicodeToMultiByteN ( + PCHAR MbString, + ULONG MbSize, + PULONG ResultSize, + PWCHAR UnicodeString, + ULONG UnicodeSize + ) +{ + ULONG Size = 0; + ULONG i; + + if (NLS_MB_CODE_PAGE_TAG == FALSE) + { + /* single-byte code page */ + if (UnicodeSize > (MbSize * sizeof(WCHAR))) + Size = MbSize; + else + Size = UnicodeSize / sizeof(WCHAR); + + if (ResultSize != NULL) + *ResultSize = Size; + + for (i = 0; i < Size; i++) + { + /* FIXME: Upcase!! */ + *MbString = *UnicodeString; +#if 0 + *MbString = UnicodeToAnsiTable[*UnicodeString]; +#endif + + MbString++; + UnicodeString++; + } + } + else + { + /* multi-byte code page */ + /* FIXME */ + + } + + return STATUS_SUCCESS; +} + + +NTSTATUS +STDCALL +RtlUpcaseUnicodeToOemN ( + PCHAR OemString, + ULONG OemSize, + PULONG ResultSize, + PWCHAR UnicodeString, + ULONG UnicodeSize + ) +{ + ULONG Size = 0; + ULONG i; + + if (NLS_MB_OEM_CODE_PAGE_TAG == FALSE) + { + /* single-byte code page */ + if (UnicodeSize > (OemSize * sizeof(WCHAR))) + Size = OemSize; + else + Size = UnicodeSize / sizeof(WCHAR); + + if (ResultSize != NULL) + *ResultSize = Size; + + for (i = 0; i < Size; i++) + { + /* FIXME: Upcase !! */ + *OemString = *UnicodeString; +#if 0 + *OemString = UnicodeToOemTable[*UnicodeString]; +#endif + + OemString++; + UnicodeString++; + } + } + else + { + /* multi-byte code page */ + /* FIXME */ + + } + + return STATUS_SUCCESS; } /* EOF */ diff --git a/reactos/lib/ntdll/rtl/unicode.c b/reactos/lib/ntdll/rtl/unicode.c index 368f5311a41..dd1c643e5f4 100644 --- a/reactos/lib/ntdll/rtl/unicode.c +++ b/reactos/lib/ntdll/rtl/unicode.c @@ -1,4 +1,4 @@ -/* $Id: unicode.c,v 1.8 1999/11/15 15:58:24 ekohl Exp $ +/* $Id: unicode.c,v 1.9 1999/11/20 21:46:46 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -10,11 +10,8 @@ */ #include -#include - //#include - #define NDEBUG #include @@ -27,604 +24,965 @@ extern unsigned long simple_strtoul(const char *cp, char **endp, WCHAR STDCALL -RtlAnsiCharToUnicodeChar(PCHAR AnsiChar) +RtlAnsiCharToUnicodeChar ( + CHAR AnsiChar + ) { - ULONG Size; - WCHAR UnicodeChar; + ULONG Size; + WCHAR UnicodeChar; - Size = 1; + Size = 1; #if 0 - Size = (NlsLeadByteInfo[*AnsiChar] == 0) ? 1 : 2; + Size = (NlsLeadByteInfo[AnsiChar] == 0) ? 1 : 2; #endif - RtlMultiByteToUnicodeN (&UnicodeChar, - sizeof(WCHAR), - NULL, - AnsiChar, - Size); + RtlMultiByteToUnicodeN (&UnicodeChar, + sizeof(WCHAR), + NULL, + &AnsiChar, + Size); - return UnicodeChar; + return UnicodeChar; } ULONG STDCALL -RtlAnsiStringToUnicodeSize(IN PANSI_STRING AnsiString) +RtlAnsiStringToUnicodeSize ( + IN PANSI_STRING AnsiString + ) { - ULONG Size; + ULONG Size; - RtlMultiByteToUnicodeSize (&Size, - AnsiString->Buffer, - AnsiString->Length); + RtlMultiByteToUnicodeSize (&Size, + AnsiString->Buffer, + AnsiString->Length); - return Size; + return Size; } NTSTATUS STDCALL RtlAnsiStringToUnicodeString( - IN OUT PUNICODE_STRING DestinationString, - IN PANSI_STRING SourceString, - IN BOOLEAN AllocateDestinationString) + IN OUT PUNICODE_STRING DestinationString, + IN PANSI_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) { - NTSTATUS Status; - ULONG Length; + NTSTATUS Status; + ULONG Length; - if (NlsMbCodePageTag == TRUE) - Length = RtlAnsiStringToUnicodeSize (SourceString); - else - Length = SourceString->Length * sizeof(WCHAR); + if (NlsMbCodePageTag == TRUE) + Length = RtlAnsiStringToUnicodeSize (SourceString); + else + Length = SourceString->Length * sizeof(WCHAR); - if (Length > 65535) - return STATUS_INVALID_PARAMETER_2; + if (Length > 65535) + return STATUS_INVALID_PARAMETER_2; - DestinationString->Length = Length; + DestinationString->Length = Length; - if (AllocateDestinationString == TRUE) - { - DestinationString->MaximumLength = Length + sizeof(WCHAR); - DestinationString->Buffer = - RtlAllocateHeap (RtlGetProcessHeap (), - 0, - DestinationString->MaximumLength); - if (DestinationString->Buffer == NULL) - return STATUS_NO_MEMORY; - } - else - { - if (Length > DestinationString->Length) - return STATUS_BUFFER_OVERFLOW; - } + if (AllocateDestinationString == TRUE) + { + DestinationString->MaximumLength = Length + sizeof(WCHAR); + DestinationString->Buffer = + RtlAllocateHeap (RtlGetProcessHeap (), + 0, + DestinationString->MaximumLength); + if (DestinationString->Buffer == NULL) + return STATUS_NO_MEMORY; + } + else + { + if (Length > DestinationString->Length) + return STATUS_BUFFER_OVERFLOW; + } - RtlZeroMemory (DestinationString->Buffer, - DestinationString->Length); + RtlZeroMemory (DestinationString->Buffer, + DestinationString->Length); - Status = RtlMultiByteToUnicodeN (DestinationString->Buffer, - DestinationString->Length, - NULL, - SourceString->Buffer, - SourceString->Length); - if (!NT_SUCCESS(Status)) - { - if (AllocateDestinationString) - RtlFreeHeap (RtlGetProcessHeap (), - 0, - DestinationString->Buffer); - return Status; - } + Status = RtlMultiByteToUnicodeN (DestinationString->Buffer, + DestinationString->Length, + NULL, + SourceString->Buffer, + SourceString->Length); + if (!NT_SUCCESS(Status)) + { + if (AllocateDestinationString) + { + RtlFreeHeap (RtlGetProcessHeap (), + 0, + DestinationString->Buffer); + } + return Status; + } - DestinationString->Buffer[Length / sizeof(WCHAR)] = 0; + DestinationString->Buffer[Length / sizeof(WCHAR)] = 0; - return STATUS_SUCCESS; + return STATUS_SUCCESS; } NTSTATUS STDCALL -RtlAppendUnicodeStringToString(IN OUT PUNICODE_STRING Destination, - IN PUNICODE_STRING Source) +RtlAppendAsciizToString ( + IN OUT PSTRING Destination, + IN PCSZ Source + ) { - PWCHAR Src; - PWCHAR Dest; - ULONG i; + ULONG Length; + PCHAR Ptr; - if ((Source->Length + Destination->Length) >= Destination->MaximumLength) - return STATUS_BUFFER_TOO_SMALL; + if (Source == NULL) + return STATUS_SUCCESS; - Src = Source->Buffer; - Dest = Destination->Buffer + (Destination->Length / sizeof (WCHAR)); - for (i = 0; i < (Source->Length / sizeof(WCHAR)); i++) - { - *Dest = *Src; - Dest++; - Src++; - } - *Dest = 0; + Length = strlen (Source); + if (Destination->Length + Length >= Destination->MaximumLength) + return STATUS_BUFFER_TOO_SMALL; - Destination->Length += Source->Length; + Ptr = Destination->Buffer + Destination->Length; + memmove (Ptr, + Source, + Length); + Ptr += Length; + *Ptr = 0; - return STATUS_SUCCESS; + Destination->Length += Length; + + return STATUS_SUCCESS; } + NTSTATUS STDCALL -RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination, - IN PWSTR Source) +RtlAppendStringToString ( + PSTRING Destination, + PSTRING Source + ) { - PWCHAR Src; - PWCHAR Dest; - ULONG i; - ULONG slen; + PCHAR Ptr; - slen = wcslen (Source); + if (Source->Length == 0) + return STATUS_SUCCESS; - if (Destination->Length + slen >= Destination->MaximumLength) - return STATUS_BUFFER_TOO_SMALL; + if (Destination->Length + Source->Length >= Destination->MaximumLength) + return STATUS_BUFFER_TOO_SMALL; - Src = Source; - Dest = Destination->Buffer + (Destination->Length / sizeof (WCHAR)); + Ptr = Destination->Buffer + Destination->Length; + memmove (Ptr, + Source->Buffer, + Source->Length); + Ptr += Source->Length; + *Ptr = 0; - for (i = 0; i < slen; i++) - { - *Dest = *Src; - Dest++; - Src++; - }; - *Dest = 0; + Destination->Length += Source->Length; - Destination->Length += (slen * sizeof(WCHAR)); - - return STATUS_SUCCESS; + return STATUS_SUCCESS; } + NTSTATUS STDCALL -RtlCharToInteger(IN PCSZ String, IN ULONG Base, IN OUT PULONG Value) +RtlAppendUnicodeStringToString ( + IN OUT PUNICODE_STRING Destination, + IN PUNICODE_STRING Source + ) { - *Value=simple_strtoul((const char *)String, NULL, Base); - return(STATUS_SUCCESS); + PWCHAR Src; + PWCHAR Dest; + ULONG i; + + if ((Source->Length + Destination->Length) >= Destination->MaximumLength) + return STATUS_BUFFER_TOO_SMALL; + + Src = Source->Buffer; + Dest = Destination->Buffer + (Destination->Length / sizeof (WCHAR)); + for (i = 0; i < (Source->Length / sizeof(WCHAR)); i++) + { + *Dest = *Src; + Dest++; + Src++; + } + *Dest = 0; + + Destination->Length += Source->Length; + + return STATUS_SUCCESS; } + +NTSTATUS +STDCALL +RtlAppendUnicodeToString ( + IN OUT PUNICODE_STRING Destination, + IN PWSTR Source + ) +{ + PWCHAR Src; + PWCHAR Dest; + ULONG i; + ULONG slen; + + slen = wcslen (Source); + + if (Destination->Length + slen >= Destination->MaximumLength) + return STATUS_BUFFER_TOO_SMALL; + + Src = Source; + Dest = Destination->Buffer + (Destination->Length / sizeof (WCHAR)); + + for (i = 0; i < slen; i++) + { + *Dest = *Src; + Dest++; + Src++; + } + *Dest = 0; + + Destination->Length += (slen * sizeof(WCHAR)); + + return STATUS_SUCCESS; +} + + +NTSTATUS +STDCALL +RtlCharToInteger ( + IN PCSZ String, + IN ULONG Base, + IN OUT PULONG Value) +{ + *Value=simple_strtoul((const char *)String, NULL, Base); + return STATUS_SUCCESS; +} + + LONG STDCALL -RtlCompareString(PSTRING String1, - PSTRING String2, - BOOLEAN CaseInsensitive) +RtlCompareString ( + PSTRING String1, + PSTRING String2, + BOOLEAN CaseInsensitive + ) { - unsigned long i; - char c1, c2; + ULONG i; + CHAR c1, c2; + PCHAR p1, p2; - if (String1->Length!=String2->Length) - return String1->Length-String2->Length; + if (String1->Length!=String2->Length) + return String1->Length-String2->Length; - for (i=0; iLength; i++) - { - if(CaseInsensitive==TRUE) - { - c1=toupper(*String1->Buffer); - c2=toupper(*String2->Buffer); - } - else - { - c1=*String1->Buffer; - c2=*String2->Buffer; - } + p1 = String1->Buffer; + p2 = String2->Buffer; - if(c1!=c2) - { - String1->Buffer-=i; - String2->Buffer-=i; - return c1-c2; - } - String1->Buffer++; - String2->Buffer++; - } - String1->Buffer-=i; - String2->Buffer-=i; + for (i = 0; i < String1->Length; i++) + { + if (CaseInsensitive == TRUE) + { + c1 = RtlUpperChar (*p1); + c2 = RtlUpperChar (*p2); + } + else + { + c1 = *p1; + c2 = *p2; + } - return 0; + if (c1 != c2) + return c1-c2; + + p1++; + p2++; + } + + return 0; } + LONG STDCALL -RtlCompareUnicodeString(PUNICODE_STRING String1, - PUNICODE_STRING String2, - BOOLEAN CaseInsensitive) +RtlCompareUnicodeString ( + PUNICODE_STRING String1, + PUNICODE_STRING String2, + BOOLEAN CaseInsensitive + ) { - unsigned long i; - WCHAR wc1, wc2; - PWCHAR pw1, pw2; + ULONG i; + WCHAR wc1, wc2; + PWCHAR pw1, pw2; - if (String1->Length != String2->Length) - return String1->Length-String2->Length; + if (String1->Length != String2->Length) + return String1->Length-String2->Length; - pw1 = String1->Buffer; - pw2 = String2->Buffer; + pw1 = String1->Buffer; + pw2 = String2->Buffer; - for(i = 0; i < (String1->Length / sizeof(WCHAR)); i++) - { - if(CaseInsensitive == TRUE) - { - wc1 = towupper (*pw1); - wc2 = towupper (*pw2); - } - else - { - wc1 = *pw1; - wc2 = *pw2; - } + for (i = 0; i < (String1->Length / sizeof(WCHAR)); i++) + { + if (CaseInsensitive == TRUE) + { + wc1 = RtlUpcaseUnicodeChar (*pw1); + wc2 = RtlUpcaseUnicodeChar (*pw2); + } + else + { + wc1 = *pw1; + wc2 = *pw2; + } - if (wc1 != wc2) - { - return wc1 - wc2; - } + if (wc1 != wc2) + return wc1 - wc2; - pw1++; - pw2++; - } + pw1++; + pw2++; + } - return 0; + return 0; } + VOID STDCALL -RtlCopyString(IN OUT PSTRING DestinationString, IN PSTRING SourceString) +RtlCopyString ( + IN OUT PSTRING DestinationString, + IN PSTRING SourceString + ) { - unsigned long copylen, i; + ULONG copylen, i; + PCHAR Src, Dest; - if(SourceString==NULL) - { - DestinationString->Length=0; - } - else - { - if(SourceString->LengthMaximumLength) - { - copylen=SourceString->Length; - } - else - { - copylen=DestinationString->MaximumLength; - } + if (SourceString == NULL) + { + DestinationString->Length = 0; + return; + } - for(i=0; iBuffer=*SourceString->Buffer; - DestinationString->Buffer++; - SourceString->Buffer++; - } + copylen = min (DestinationString->MaximumLength - sizeof(CHAR), + SourceString->Length); + Src = SourceString->Buffer; + Dest = DestinationString->Buffer; - *DestinationString->Buffer=0; - DestinationString->Buffer-=copylen; - SourceString->Buffer-=copylen; - } + for (i = 0; i < copylen; i++) + { + *Dest = *Src; + Dest++; + Src++; + } + *Dest = 0; + + DestinationString->Length = copylen; } + VOID STDCALL -RtlCopyUnicodeString(IN OUT PUNICODE_STRING DestinationString, - IN PUNICODE_STRING SourceString) +RtlCopyUnicodeString ( + IN OUT PUNICODE_STRING DestinationString, + IN PUNICODE_STRING SourceString + ) { - unsigned long copylen, i; - PWCHAR Src, Dest; - - if(SourceString==NULL) - { - DestinationString->Length=0; - } - else - { - copylen = min(DestinationString->MaximumLength - sizeof(WCHAR), - SourceString->Length); - Src = SourceString->Buffer; - Dest = DestinationString->Buffer; + ULONG copylen, i; + PWCHAR Src, Dest; - for (i = 0; i < (copylen / sizeof (WCHAR)); i++) - { - *Dest = *Src; - Dest++; - Src++; - } - *Dest = 0; + if (SourceString == NULL) + { + DestinationString->Length = 0; + return; + } - DestinationString->Length = copylen; - } + copylen = min (DestinationString->MaximumLength - sizeof(WCHAR), + SourceString->Length); + Src = SourceString->Buffer; + Dest = DestinationString->Buffer; + + for (i = 0; i < (copylen / sizeof (WCHAR)); i++) + { + *Dest = *Src; + Dest++; + Src++; + } + *Dest = 0; + + DestinationString->Length = copylen; } + BOOLEAN STDCALL -RtlEqualString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive) +RtlCreateUnicodeString ( + PUNICODE_STRING Destination, + PWSTR Source + ) { - unsigned long s1l=String1->Length; - unsigned long s2l=String2->Length; - unsigned long i; - char c1, c2; + ULONG Length; - if(s1l!=s2l) return FALSE; + Length = (wcslen (Source) + 1) * sizeof(WCHAR); - for(i=0; iBuffer; - c2=*String2->Buffer; + Destination->Buffer = RtlAllocateHeap (RtlGetProcessHeap (), + 0, + Length); + if (Destination->Buffer == NULL) + return FALSE; - if(CaseInsensitive==TRUE) { - c1=toupper(c1); - c2=toupper(c2); - }; + memmove (Destination->Buffer, + Source, + Length); - if(c1!=c2) { - String1->Buffer-=i; - String2->Buffer-=i; - return FALSE; - }; + Destination->MaximumLength = Length; + Destination->Length = Length - sizeof (WCHAR); - String1->Buffer++; - String2->Buffer++; - }; - - String1->Buffer-=i; - String2->Buffer-=i; - - return TRUE; + return TRUE; } + BOOLEAN STDCALL -RtlEqualUnicodeString(PUNICODE_STRING String1, - PUNICODE_STRING String2, - BOOLEAN CaseInsensitive) +RtlCreateUnicodeStringFromAsciiz ( + OUT PUNICODE_STRING Destination, + IN PCSZ Source + ) { - unsigned long s1l = String1->Length / sizeof(WCHAR); - unsigned long s2l = String2->Length / sizeof(WCHAR); - unsigned long i; - WCHAR wc1, wc2; - PWCHAR pw1, pw2; + ANSI_STRING AnsiString; + NTSTATUS Status; - if (s1l != s2l) - return FALSE; + RtlInitAnsiString (&AnsiString, + Source); - pw1 = String1->Buffer; - pw2 = String2->Buffer; + Status = RtlAnsiStringToUnicodeString (Destination, + &AnsiString, + TRUE); - for (i = 0; i < s1l; i++) - { - if(CaseInsensitive == TRUE) - { - wc1 = towupper (*pw1); - wc2 = towupper (*pw2); - } - else - { - wc1 = *pw1; - wc2 = *pw2; - } - - if (wc1 != wc2) - return FALSE; - - pw1++; - pw2++; - } - - return TRUE; + return NT_SUCCESS(Status); } -VOID -STDCALL -RtlFreeAnsiString(IN PANSI_STRING AnsiString) -{ - RtlFreeHeap (RtlGetProcessHeap (), - 0, - AnsiString->Buffer); -} - -VOID -STDCALL -RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString) -{ - RtlFreeHeap (RtlGetProcessHeap (), - 0, - UnicodeString->Buffer); -} - -VOID -STDCALL -RtlInitAnsiString(IN OUT PANSI_STRING DestinationString, - IN PCSZ SourceString) -{ - unsigned long DestSize; - - if(SourceString==NULL) { - DestinationString->Length=0; - DestinationString->MaximumLength=0; - } else { - DestSize=strlen((const char *)SourceString); - DestinationString->Length=DestSize; - DestinationString->MaximumLength=DestSize+1; - }; - DestinationString->Buffer=(PCHAR)SourceString; -}; - -VOID -STDCALL -RtlInitString(IN OUT PSTRING DestinationString, - IN PCSZ SourceString) -{ - ULONG DestSize; - - if (SourceString == NULL) - { - DestinationString->Length = 0; - DestinationString->MaximumLength = 0; - DestinationString->Buffer = NULL; - } - else - { - DestSize = strlen((const char *)SourceString); - DestinationString->Length = DestSize; - DestinationString->MaximumLength = DestSize + sizeof(CHAR); - DestinationString->Buffer = (PCHAR)SourceString; - } -} - -VOID -STDCALL -RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString, - IN PCWSTR SourceString) -{ - ULONG DestSize; - - if (SourceString==NULL) - { - DestinationString->Length=0; - DestinationString->MaximumLength=0; - DestinationString->Buffer = NULL; - } - else - { - DestSize = wcslen((PWSTR)SourceString) * sizeof(WCHAR); - DestinationString->Length = DestSize; - DestinationString->MaximumLength = DestSize + sizeof(WCHAR); - DestinationString->Buffer = (PWSTR)SourceString; - } -} NTSTATUS STDCALL -RtlIntegerToUnicodeString(IN ULONG Value, - IN ULONG Base, /* optional */ - IN OUT PUNICODE_STRING String) +RtlDowncaseUnicodeString ( + IN OUT PUNICODE_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) { -// UNIMPLEMENTED; + ULONG i; + PWCHAR Src, Dest; - return STATUS_NOT_IMPLEMENTED; -#if 0 - char *str; - unsigned long len, i; + if (AllocateDestinationString == TRUE) + { + DestinationString->Length = SourceString->Length; + DestinationString->MaximumLength = SourceString->Length + sizeof(WCHAR); + DestinationString->Buffer = RtlAllocateHeap (RtlGetProcessHeap (), + 0, + SourceString->Length + sizeof(WCHAR)); + } + else + { + if (SourceString->Length >= DestinationString->MaximumLength) + return STATUS_BUFFER_OVERFLOW; + } - str=ExAllocatePool(NonPagedPool, 1024); - if(Base==16) { - sprintf(str, "%x", Value); - } else - if(Base==8) { - sprintf(str, "%o", Value); - } else - if(Base==2) { - sprintf(str, "%b", Value); - } else { - sprintf(str, "%u", (unsigned int)Value); - }; + Src = SourceString->Buffer; + Dest = DestinationString->Buffer; + for (i=0; i < SourceString->Length / sizeof(WCHAR); i++) + { + if (*Src < L'A') + { + *Dest = *Src; + } + else if (*Src <= L'Z') + { + *Dest = (*Src + (L'a' - L'A')); + } + else + { + /* FIXME: characters above 'Z' */ + *Dest = *Src; + } - len=strlen(str); - if(String->MaximumLengthBuffer=*str; - String->Buffer++; - str++; - }; - *String->Buffer=0; - String->Buffer-=len; - String->Length=len; - str-=len; - ExFreePool(str); + return STATUS_SUCCESS; +} - return STATUS_SUCCESS; -#endif + +BOOLEAN +STDCALL +RtlEqualString ( + PSTRING String1, + PSTRING String2, + BOOLEAN CaseInsensitive + ) +{ + ULONG i; + CHAR c1, c2; + PCHAR p1, p2; + + if (String1->Length != String2->Length) + return FALSE; + + p1 = String1->Buffer; + p2 = String2->Buffer; + for (i = 0; i < String1->Length; i++) + { + if (CaseInsensitive == TRUE) + { + c1 = RtlUpperChar (*p1); + c2 = RtlUpperChar (*p2); + } + else + { + c1 = *p1; + c2 = *p2; + } + + if (c1 != c2) + return FALSE; + + p1++; + p2++; + } + + return TRUE; +} + + +BOOLEAN +STDCALL +RtlEqualUnicodeString ( + PUNICODE_STRING String1, + PUNICODE_STRING String2, + BOOLEAN CaseInsensitive + ) +{ + ULONG i; + WCHAR wc1, wc2; + PWCHAR pw1, pw2; + + if (String1->Length != String2->Length) + return FALSE; + + pw1 = String1->Buffer; + pw2 = String2->Buffer; + + for (i = 0; i < String1->Length / sizeof(WCHAR); i++) + { + if (CaseInsensitive == TRUE) + { + wc1 = RtlUpcaseUnicodeChar (*pw1); + wc2 = RtlUpcaseUnicodeChar (*pw2); + } + else + { + wc1 = *pw1; + wc2 = *pw2; + } + + if (wc1 != wc2) + return FALSE; + + pw1++; + pw2++; + } + + return TRUE; +} + + +VOID +STDCALL +RtlEraseUnicodeString ( + IN PUNICODE_STRING String + ) +{ + if (String->Buffer == NULL) + return; + + if (String->MaximumLength == 0) + return; + + memset (String->Buffer, + 0, + String->MaximumLength); + + String->Length = 0; +} + + +VOID +STDCALL +RtlFreeAnsiString ( + IN PANSI_STRING AnsiString + ) +{ + if (AnsiString->Buffer == NULL) + return; + + RtlFreeHeap (RtlGetProcessHeap (), + 0, + AnsiString->Buffer); + + AnsiString->Buffer = NULL; + AnsiString->Length = 0; + AnsiString->MaximumLength = 0; +} + + +VOID +STDCALL +RtlFreeOemString ( + IN POEM_STRING OemString + ) +{ + if (OemString->Buffer == NULL) + return; + + RtlFreeHeap (RtlGetProcessHeap (), + 0, + OemString->Buffer); + + OemString->Buffer = NULL; + OemString->Length = 0; + OemString->MaximumLength = 0; +} + + +VOID +STDCALL +RtlFreeUnicodeString ( + IN PUNICODE_STRING UnicodeString + ) +{ + if (UnicodeString->Buffer == NULL) + return; + + RtlFreeHeap (RtlGetProcessHeap (), + 0, + UnicodeString->Buffer); + + UnicodeString->Buffer = NULL; + UnicodeString->Length = 0; + UnicodeString->MaximumLength = 0; +} + + +VOID +STDCALL +RtlInitAnsiString ( + IN OUT PANSI_STRING DestinationString, + IN PCSZ SourceString + ) +{ + ULONG DestSize; + + if(SourceString==NULL) + { + DestinationString->Length = 0; + DestinationString->MaximumLength = 0; + } + else + { + DestSize = strlen ((const char *)SourceString); + DestinationString->Length = DestSize; + DestinationString->MaximumLength = DestSize + 1; + } + DestinationString->Buffer = (PCHAR)SourceString; +} + + +VOID +STDCALL +RtlInitString ( + IN OUT PSTRING DestinationString, + IN PCSZ SourceString + ) +{ + ULONG DestSize; + + if (SourceString == NULL) + { + DestinationString->Length = 0; + DestinationString->MaximumLength = 0; + } + else + { + DestSize = strlen((const char *)SourceString); + DestinationString->Length = DestSize; + DestinationString->MaximumLength = DestSize + sizeof(CHAR); + } + DestinationString->Buffer = (PCHAR)SourceString; +} + + +VOID +STDCALL +RtlInitUnicodeString ( + IN OUT PUNICODE_STRING DestinationString, + IN PCWSTR SourceString + ) +{ + ULONG DestSize; + + if (SourceString==NULL) + { + DestinationString->Length=0; + DestinationString->MaximumLength=0; + } + else + { + DestSize = wcslen((PWSTR)SourceString) * sizeof(WCHAR); + DestinationString->Length = DestSize; + DestinationString->MaximumLength = DestSize + sizeof(WCHAR); + } + DestinationString->Buffer = (PWSTR)SourceString; +} + + +NTSTATUS +STDCALL +RtlIntegerToChar ( + IN ULONG Value, + IN ULONG Base, + IN ULONG Length, + IN OUT PCHAR String + ) +{ + ULONG Radix; + CHAR temp[33]; + ULONG v = 0; + ULONG i; + PCHAR tp; + PCHAR sp; + + Radix = Base; + if (Radix == 0) + Radix = 10; + + if ((Radix != 2) && (Radix != 8) && + (Radix != 10) && (Radix != 16)) + return STATUS_INVALID_PARAMETER; + + tp = temp; + while (v || tp == temp) + { + i = v % Radix; + v = v / Radix; + if (i < 10) + *tp = i + '0'; + else + *tp = i + 'a' - 10; + tp++; + } + + if (tp - temp >= Length) + return STATUS_BUFFER_TOO_SMALL; + + sp = String; + while (tp > temp) + *sp++ = *--tp; + *sp = 0; + + return STATUS_SUCCESS; +} + + +NTSTATUS +STDCALL +RtlIntegerToUnicodeString ( + IN ULONG Value, + IN ULONG Base, /* optional */ + IN OUT PUNICODE_STRING String + ) +{ + ANSI_STRING AnsiString; + CHAR Buffer[33]; + NTSTATUS Status; + + Status = RtlIntegerToChar (Value, + Base, + 33, + Buffer); + if (!NT_SUCCESS(Status)) + return Status; + + AnsiString.Buffer = Buffer; + AnsiString.Length = strlen (Buffer); + AnsiString.MaximumLength = 33; + + Status = RtlAnsiStringToUnicodeString (String, + &AnsiString, + FALSE); + + return Status; } ULONG STDCALL -RtlOemStringToUnicodeSize(IN PANSI_STRING OemString) +RtlOemStringToUnicodeSize ( + IN POEM_STRING OemString + ) { - ULONG Size; + ULONG Size; - RtlMultiByteToUnicodeSize (&Size, - OemString->Buffer, - OemString->Length); + RtlMultiByteToUnicodeSize (&Size, + OemString->Buffer, + OemString->Length); - return Size; + return Size; } + +NTSTATUS +STDCALL +RtlOemStringToUnicodeString ( + PUNICODE_STRING DestinationString, + POEM_STRING SourceString, + BOOLEAN AllocateDestinationString + ) +{ + NTSTATUS Status; + ULONG Length; + + if (NlsMbCodePageTag == TRUE) + Length = RtlAnsiStringToUnicodeSize (SourceString); + else + Length = SourceString->Length * sizeof(WCHAR); + + if (Length > 65535) + return STATUS_INVALID_PARAMETER_2; + + DestinationString->Length = Length; + + if (AllocateDestinationString == TRUE) + { + DestinationString->MaximumLength = Length + sizeof(WCHAR); + DestinationString->Buffer = + RtlAllocateHeap (RtlGetProcessHeap (), + 0, + DestinationString->MaximumLength); + if (DestinationString->Buffer == NULL) + return STATUS_NO_MEMORY; + } + else + { + if (Length > DestinationString->Length) + return STATUS_BUFFER_OVERFLOW; + } + + memset (DestinationString->Buffer, + 0, + DestinationString->Length); + + Status = RtlOemToUnicodeN (DestinationString->Buffer, + DestinationString->Length, + NULL, + SourceString->Buffer, + SourceString->Length); + if (!NT_SUCCESS(Status)) + { + if (AllocateDestinationString) + { + RtlFreeHeap (RtlGetProcessHeap (), + 0, + DestinationString->Buffer); + } + return Status; + } + + DestinationString->Buffer[Length / sizeof(WCHAR)] = 0; + + return STATUS_SUCCESS; +} + + ULONG STDCALL -RtlUnicodeStringToAnsiSize(IN PUNICODE_STRING UnicodeString) +RtlUnicodeStringToAnsiSize ( + IN PUNICODE_STRING UnicodeString + ) { - ULONG Size; + ULONG Size; - RtlUnicodeToMultiByteSize (&Size, - UnicodeString->Buffer, - UnicodeString->Length); + RtlUnicodeToMultiByteSize (&Size, + UnicodeString->Buffer, + UnicodeString->Length); - return Size; + return Size; +} + + +NTSTATUS +STDCALL +RtlUnicodeStringToAnsiString ( + IN OUT PANSI_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) +{ + NTSTATUS Status; + ULONG Length; + + if (NlsMbCodePageTag == TRUE) + Length = RtlUnicodeStringToAnsiSize (SourceString); + else + Length = SourceString->Length / sizeof(WCHAR); + + /* this doesn't make sense */ +// if (Length > 65535) +// return STATUS_INVALID_PARAMETER_2; + + DestinationString->Length = Length; + + if (AllocateDestinationString == TRUE) + { + DestinationString->MaximumLength = Length + sizeof(CHAR); + DestinationString->Buffer = + RtlAllocateHeap (RtlGetProcessHeap (), + 0, + DestinationString->MaximumLength); + if (DestinationString->Buffer == NULL) + return STATUS_NO_MEMORY; + } + else + { + if (Length >= DestinationString->Length) + return STATUS_BUFFER_OVERFLOW; + } + + RtlZeroMemory (DestinationString->Buffer, + DestinationString->Length); + + Status = RtlUnicodeToMultiByteN (DestinationString->Buffer, + DestinationString->Length, + NULL, + SourceString->Buffer, + SourceString->Length); + if (!NT_SUCCESS(Status)) + { + if (AllocateDestinationString) + RtlFreeHeap (RtlGetProcessHeap (), + 0, + DestinationString->Buffer); + return Status; + } + + DestinationString->Buffer[Length] = 0; + + return STATUS_SUCCESS; } NTSTATUS STDCALL -RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString, - IN PUNICODE_STRING SourceString, - IN BOOLEAN AllocateDestinationString) +RtlUnicodeStringToInteger ( + IN PUNICODE_STRING String, + IN ULONG Base, + OUT PULONG Value) { - NTSTATUS Status; - ULONG Length; - - if (NlsMbCodePageTag == TRUE) - Length = RtlUnicodeStringToAnsiSize (SourceString); - else - Length = SourceString->Length / sizeof(WCHAR); - - /* this doesn't make sense */ -// if (Length > 65535) -// return STATUS_INVALID_PARAMETER_2; - - DestinationString->Length = Length; - - if (AllocateDestinationString == TRUE) - { - DestinationString->MaximumLength = Length + sizeof(CHAR); - DestinationString->Buffer = - RtlAllocateHeap (RtlGetProcessHeap (), - 0, - DestinationString->MaximumLength); - if (DestinationString->Buffer == NULL) - return STATUS_NO_MEMORY; - } - else - { - if (Length >= DestinationString->Length) - return STATUS_BUFFER_OVERFLOW; - } - - RtlZeroMemory (DestinationString->Buffer, - DestinationString->Length); - - Status = RtlUnicodeToMultiByteN (DestinationString->Buffer, - DestinationString->Length, - NULL, - SourceString->Buffer, - SourceString->Length); - if (!NT_SUCCESS(Status)) - { - if (AllocateDestinationString) - RtlFreeHeap (RtlGetProcessHeap (), - 0, - DestinationString->Buffer); - return Status; - } - - DestinationString->Buffer[Length] = 0; - - return STATUS_SUCCESS; -} - -NTSTATUS -STDCALL -RtlUnicodeStringToInteger(IN PUNICODE_STRING String, - IN ULONG Base, - OUT PULONG Value) -{ - return STATUS_NOT_IMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; #if 0 char *str; unsigned long i, lenmin=0; @@ -688,69 +1046,337 @@ RtlUnicodeStringToInteger(IN PUNICODE_STRING String, #endif } + +ULONG +STDCALL +RtlUnicodeStringToOemSize ( + IN PUNICODE_STRING UnicodeString + ) +{ + ULONG Size; + + RtlUnicodeToMultiByteSize (&Size, + UnicodeString->Buffer, + UnicodeString->Length); + + return Size; +} + + NTSTATUS STDCALL -RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString, - IN PUNICODE_STRING SourceString, - IN BOOLEAN AllocateDestinationString) +RtlUnicodeStringToOemString ( + IN OUT POEM_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) { - ULONG i; - PWCHAR Src, Dest; + NTSTATUS Status; + ULONG Length; - if(AllocateDestinationString==TRUE) - { - DestinationString->Buffer = - RtlAllocateHeap (RtlGetProcessHeap (), - 0, - SourceString->Length + sizeof(WCHAR)); - DestinationString->Length=SourceString->Length; - DestinationString->MaximumLength=SourceString->Length+sizeof(WCHAR); - } + if (NlsMbOemCodePageTag == TRUE) + Length = RtlUnicodeStringToAnsiSize (SourceString); + else + Length = SourceString->Length / sizeof(WCHAR); - Src = SourceString->Buffer; - Dest = DestinationString->Buffer; - for (i=0; i < SourceString->Length / sizeof(WCHAR); i++) - { - *Dest = towupper (*Src); - Dest++; - Src++; - } - *Dest = 0; +// if (Length > 65535) +// return STATUS_INVALID_PARAMETER_2; - return STATUS_SUCCESS; + DestinationString->Length = Length; + + if (AllocateDestinationString == TRUE) + { + DestinationString->MaximumLength = Length + sizeof(CHAR); + DestinationString->Buffer = + RtlAllocateHeap (RtlGetProcessHeap (), + 0, + DestinationString->MaximumLength); + if (DestinationString->Buffer == NULL) + return STATUS_NO_MEMORY; + } + else + { + if (Length >= DestinationString->Length) + return STATUS_BUFFER_OVERFLOW; + } + + RtlZeroMemory (DestinationString->Buffer, + DestinationString->Length); + + Status = RtlUnicodeToOemN (DestinationString->Buffer, + DestinationString->Length, + NULL, + SourceString->Buffer, + SourceString->Length); + if (!NT_SUCCESS(Status)) + { + if (AllocateDestinationString) + { + RtlFreeHeap (RtlGetProcessHeap (), + 0, + DestinationString->Buffer); + } + return Status; + } + + DestinationString->Buffer[Length] = 0; + + return STATUS_SUCCESS; } + +WCHAR +STDCALL +RtlUpcaseUnicodeChar ( + WCHAR Source + ) +{ + if (Source < L'a') + return Source; + + if (Source <= L'z') + return (Source - (L'a' - L'A')); + + /* FIXME: characters above 'z' */ + + return Source; +} + + +NTSTATUS +STDCALL +RtlUpcaseUnicodeString ( + IN OUT PUNICODE_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) +{ + ULONG i; + PWCHAR Src, Dest; + + DestinationString->Length = SourceString->Length; + + if (AllocateDestinationString == TRUE) + { + DestinationString->MaximumLength=SourceString->Length+sizeof(WCHAR); + DestinationString->Buffer = RtlAllocateHeap (RtlGetProcessHeap (), + 0, + SourceString->Length + sizeof(WCHAR)); + if (DestinationString->Buffer == NULL) + return STATUS_NO_MEMORY; + } + + Src = SourceString->Buffer; + Dest = DestinationString->Buffer; + for (i = 0; i < SourceString->Length / sizeof(WCHAR); i++) + { + *Dest = RtlUpcaseUnicodeChar (*Src); + Dest++; + Src++; + } + *Dest = 0; + + return STATUS_SUCCESS; +} + + +NTSTATUS +STDCALL +RtlUpcaseUnicodeStringToAnsiString ( + IN OUT PANSI_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) +{ + NTSTATUS Status; + ULONG Length; + + if (NlsMbCodePageTag == TRUE) + Length = RtlUnicodeStringToAnsiSize (SourceString); + else + Length = SourceString->Length / sizeof(WCHAR); + +// if (Length > 65535) +// return STATUS_INVALID_PARAMETER_2; + + DestinationString->Length = Length; + + if (AllocateDestinationString == TRUE) + { + DestinationString->MaximumLength = Length + sizeof(CHAR); + DestinationString->Buffer = RtlAllocateHeap (RtlGetProcessHeap (), + 0, + DestinationString->MaximumLength); + if (DestinationString->Buffer == NULL) + return STATUS_NO_MEMORY; + } + else + { + if (Length >= DestinationString->Length) + return STATUS_BUFFER_OVERFLOW; + } + + RtlZeroMemory (DestinationString->Buffer, + DestinationString->Length); + + Status = RtlUpcaseUnicodeToMultiByteN (DestinationString->Buffer, + DestinationString->Length, + NULL, + SourceString->Buffer, + SourceString->Length); + if (!NT_SUCCESS(Status)) + { + if (AllocateDestinationString) + { + RtlFreeHeap (RtlGetProcessHeap (), + 0, + DestinationString->Buffer); + } + return Status; + } + + DestinationString->Buffer[Length] = 0; + + return STATUS_SUCCESS; +} + + +/* +RtlUpcaseUnicodeStringToCountedOemString +*/ + + +NTSTATUS +STDCALL +RtlUpcaseUnicodeStringToOemString ( + IN OUT POEM_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) +{ + NTSTATUS Status; + ULONG Length; + + if (NlsMbOemCodePageTag == TRUE) + Length = RtlUnicodeStringToAnsiSize (SourceString); + else + Length = SourceString->Length / sizeof(WCHAR); + +// if (Length > 65535) +// return STATUS_INVALID_PARAMETER_2; + + DestinationString->Length = Length; + + if (AllocateDestinationString == TRUE) + { + DestinationString->MaximumLength = Length + sizeof(CHAR); + DestinationString->Buffer = RtlAllocateHeap (RtlGetProcessHeap (), + 0, + DestinationString->MaximumLength); + if (DestinationString->Buffer == NULL) + return STATUS_NO_MEMORY; + } + else + { + if (Length >= DestinationString->Length) + return STATUS_BUFFER_OVERFLOW; + } + + RtlZeroMemory (DestinationString->Buffer, + DestinationString->Length); + + Status = RtlUpcaseUnicodeToOemN (DestinationString->Buffer, + DestinationString->Length, + NULL, + SourceString->Buffer, + SourceString->Length); + if (!NT_SUCCESS(Status)) + { + if (AllocateDestinationString) + { + RtlFreeHeap (RtlGetProcessHeap (), + 0, + DestinationString->Buffer); + } + return Status; + } + + DestinationString->Buffer[Length] = 0; + + return STATUS_SUCCESS; +} + + +/* +RtlUpcaseUnicodeToCustomCP +*/ + + +CHAR +STDCALL +RtlUpperChar ( + CHAR Source + ) +{ + WCHAR Unicode; + CHAR Destination; + + if (NlsMbCodePageTag == FALSE) + { + /* single-byte code page */ + /* ansi->unicode */ + Unicode = (WCHAR)Source; +#if 0 + Unicode = NlsAnsiToUnicodeData[Source]; +#endif + + /* upcase conversion */ + Unicode = RtlUpcaseUnicodeChar (Unicode); + + /* unicode -> ansi */ + Destination = (CHAR)Unicode; +#if 0 + Destination = NlsUnicodeToAnsiData[Unicode]; +#endif + } + else + { + /* single-byte code page */ + /* FIXME: implement the multi-byte stuff!! */ + Destination = Source; + } + + return Destination; +} + + VOID STDCALL -RtlUpcaseString(IN OUT PSTRING DestinationString, - IN PSTRING SourceString) +RtlUpperString ( + PSTRING DestinationString, + PSTRING SourceString + ) { - unsigned long i, len; - PCHAR Src, Dest; + ULONG Length; + ULONG i; + PCHAR Src; + PCHAR Dest; - if(SourceString->Length>DestinationString->MaximumLength) { - len=DestinationString->MaximumLength; - } else { - len=SourceString->Length; - }; + Length = min(SourceString->Length, DestinationString->MaximumLength - 1); - for(i=0; iBuffer=toupper(*SourceString->Buffer); - DestinationString->Buffer++; - SourceString->Buffer++; - }; - *DestinationString->Buffer=0; + Src = SourceString->Buffer; + Dest = DestinationString->Buffer; + for (i = 0; i < Length; i++) + { + *Dest = RtlUpperChar (*Src); + Src++; + Dest++; + } + *Dest = 0; - DestinationString->Buffer-=len; - SourceString->Buffer-=len; + DestinationString->Length = SourceString->Length; } -VOID -STDCALL -RtlUpperString(PSTRING DestinationString, PSTRING SourceString) -{ -// UNIMPLEMENTED; -} VOID STDCALL @@ -760,24 +1386,4 @@ RtlUnwind ( { } - -VOID -STDCALL -RtlUpcaseUnicodeChar ( - VOID - ) -{ -} - - -VOID -STDCALL -RtlUpcaseUnicodeToMultiByteN ( - VOID - ) -{ -} - - - /* EOF */ diff --git a/reactos/lib/psxdll/misc/rtl.c b/reactos/lib/psxdll/misc/rtl.c index fe6ef8de391..749672f051a 100644 --- a/reactos/lib/psxdll/misc/rtl.c +++ b/reactos/lib/psxdll/misc/rtl.c @@ -1,4 +1,4 @@ -/* $Id: rtl.c,v 1.2 1999/11/15 16:02:50 ekohl Exp $ +/* $Id: rtl.c,v 1.3 1999/11/20 21:47:38 ekohl Exp $ * * reactos/lib/psxdll/misc/rtl.c * @@ -12,16 +12,28 @@ #include #include + WCHAR STDCALL RtlAnsiCharToUnicodeChar ( - PCHAR AnsiChar + CHAR AnsiChar ) { - /* FIXME: it should probably call RtlMultiByteToUnicodeN - * with length==1. - */ - return (WCHAR) *AnsiChar; + ULONG Size; + WCHAR UnicodeChar; + + Size = 1; +#if 0 + Size = (NlsLeadByteInfo[AnsiChar] == 0) ? 1 : 2; +#endif + + RtlMultiByteToUnicodeN (&UnicodeChar, + sizeof(WCHAR), + NULL, + &AnsiChar, + Size); + + return UnicodeChar; } @@ -59,41 +71,114 @@ RtlMoveMemory ( NTSTATUS STDCALL -RtlMultiByteToUnicodeN ( - PWCHAR UnicodeString, - ULONG UnicodeSize, - PULONG ResultSize, - PCHAR MbString, - ULONG MbSize - ) +RtlMultiByteToUnicodeN(PWCHAR UnicodeString, + ULONG UnicodeSize, + PULONG ResultSize, + PCHAR MbString, + ULONG MbSize) { - return STATUS_NOT_IMPLEMENTED; + ULONG Size = 0; + ULONG i; + + if (NLS_MB_CODE_PAGE_TAG == FALSE) + { + /* single-byte code page */ + if (MbSize > (UnicodeSize / sizeof(WCHAR))) + Size = UnicodeSize / sizeof(WCHAR); + else + Size = MbSize; + + if (ResultSize != NULL) + *ResultSize = Size * sizeof(WCHAR); + + for (i = 0; i < Size; i++) + { + *UnicodeString = *MbString; +#if 0 + *UnicodeString = AnsiToUnicodeTable[*MbString]; +#endif + + UnicodeString++; + MbString++; + } + } + else + { + /* multi-byte code page */ + /* FIXME */ + + } + + return STATUS_SUCCESS; } NTSTATUS STDCALL RtlUnicodeToMultiByteN ( - PCHAR MbString, - ULONG MbSize, - PULONG ResultSize, - PWCHAR UnicodeString, - ULONG UnicodeSize + PCHAR MbString, + ULONG MbSize, + PULONG ResultSize, + PWCHAR UnicodeString, + ULONG UnicodeSize ) { - return STATUS_NOT_IMPLEMENTED; + ULONG Size = 0; + ULONG i; + + if (NLS_MB_CODE_PAGE_TAG == FALSE) + { + /* single-byte code page */ + if (UnicodeSize > (MbSize * sizeof(WCHAR))) + Size = MbSize; + else + Size = UnicodeSize / sizeof(WCHAR); + + if (ResultSize != NULL) + *ResultSize = Size; + + for (i = 0; i < Size; i++) + { + *MbString = *UnicodeString; +#if 0 + *MbString = UnicodeToAnsiTable[*UnicodeString]; +#endif + + MbString++; + UnicodeString++; + } + } + else + { + /* multi-byte code page */ + /* FIXME */ + + } + + return STATUS_SUCCESS; } NTSTATUS STDCALL RtlUnicodeToMultiByteSize ( - PULONG MbSize, - PWCHAR UnicodeString, - ULONG UnicodeSize + PULONG MbSize, + PWCHAR UnicodeString, + ULONG UnicodeSize ) { - return STATUS_NOT_IMPLEMENTED; + if (NLS_MB_CODE_PAGE_TAG == FALSE) + { + /* single-byte code page */ + *MbSize = UnicodeSize / sizeof (WCHAR); + } + else + { + /* multi-byte code page */ + /* FIXME */ + } + + return STATUS_SUCCESS; } @@ -106,26 +191,71 @@ RtlUnwind ( } -VOID +WCHAR STDCALL RtlUpcaseUnicodeChar ( - VOID + WCHAR Source ) { + if (Source < L'a') + return Source; + + if (Source <= L'z') + return (Source - (L'a' - L'A')); + + /* FIXME: characters above 'z' */ + + return Source; } -VOID +NTSTATUS STDCALL RtlUpcaseUnicodeToMultiByteN ( - VOID + PCHAR MbString, + ULONG MbSize, + PULONG ResultSize, + PWCHAR UnicodeString, + ULONG UnicodeSize ) { + ULONG Size = 0; + ULONG i; + + if (NLS_MB_CODE_PAGE_TAG == FALSE) + { + /* single-byte code page */ + if (UnicodeSize > (MbSize * sizeof(WCHAR))) + Size = MbSize; + else + Size = UnicodeSize / sizeof(WCHAR); + + if (ResultSize != NULL) + *ResultSize = Size; + + for (i = 0; i < Size; i++) + { + /* FIXME: Upcase!! */ + *MbString = *UnicodeString; +#if 0 + *MbString = UnicodeToAnsiTable[*UnicodeString]; +#endif + + MbString++; + UnicodeString++; + } + } + else + { + /* multi-byte code page */ + /* FIXME */ + + } + + return STATUS_SUCCESS; } - - VOID STDCALL RtlZeroMemory ( diff --git a/reactos/lib/psxdll/psxdll.def b/reactos/lib/psxdll/psxdll.def index 5aedf9eaf08..3d91d1adfcd 100644 --- a/reactos/lib/psxdll/psxdll.def +++ b/reactos/lib/psxdll/psxdll.def @@ -1,4 +1,4 @@ -; $Id: psxdll.def,v 1.5 1999/11/15 16:02:36 ekohl Exp $ +; $Id: psxdll.def,v 1.6 1999/11/20 21:47:22 ekohl Exp $ ; ; psxdll.def ; @@ -18,8 +18,8 @@ ntdll.RtlMultiByteToUnicodeN@20 ntdll.RtlUnicodeToMultiByteN@20 ntdll.RtlUnicodeToMultiByteSize@12 ntdll.RtlUnwind@0 -ntdll.RtlUpcaseUnicodeChar@0 -ntdll.RtlUpcaseUnicodeToMultiByteN@0 +ntdll.RtlUpcaseUnicodeChar@4 +ntdll.RtlUpcaseUnicodeToMultiByteN@20 ntdll.RtlZeroMemory@8 EXPORTS @@ -35,8 +35,8 @@ RtlMultiByteToUnicodeN@20 RtlUnicodeToMultiByteN@20 RtlUnicodeToMultiByteSize@12 RtlUnwind@0 -RtlUpcaseUnicodeChar@0 -RtlUpcaseUnicodeToMultiByteN@0 +RtlUpcaseUnicodeChar@4 +RtlUpcaseUnicodeToMultiByteN@20 RtlZeroMemory@8 __PdxGetCmdLine@0 __PdxInitializeData@8 diff --git a/reactos/lib/psxdll/psxdll.edf b/reactos/lib/psxdll/psxdll.edf index e1c1493c49a..ddd365e1413 100644 --- a/reactos/lib/psxdll/psxdll.edf +++ b/reactos/lib/psxdll/psxdll.edf @@ -1,4 +1,4 @@ -; $Id: psxdll.edf,v 1.4 1999/11/15 16:02:36 ekohl Exp $ +; $Id: psxdll.edf,v 1.5 1999/11/20 21:47:22 ekohl Exp $ ; ; psxdll.edf ; @@ -18,8 +18,8 @@ ntdll.RtlMultiByteToUnicodeN@20 ntdll.RtlUnicodeToMultiByteN@20 ntdll.RtlUnicodeToMultiByteSize@12 ntdll.RtlUnwind@0 -ntdll.RtlUpcaseUnicodeChar@0 -ntdll.RtlUpcaseUnicodeToMultiByteN@0 +ntdll.RtlUpcaseUnicodeChar@4 +ntdll.RtlUpcaseUnicodeToMultiByteN@20 ntdll.RtlZeroMemory@8 EXPORTS @@ -35,8 +35,8 @@ RtlMultiByteToUnicodeN=RtlMultiByteToUnicodeN@20 RtlUnicodeToMultiByteN=RtlUnicodeToMultiByteN@20 RtlUnicodeToMultiByteSize=RtlUnicodeToMultiByteSize@12 RtlUnwind=RtlUnwind@0 -RtlUpcaseUnicodeChar=RtlUpcaseUnicodeChar@0 -RtlUpcaseUnicodeToMultiByteN=RtlUpcaseUnicodeToMultiByteN@0 +RtlUpcaseUnicodeChar=RtlUpcaseUnicodeChar@4 +RtlUpcaseUnicodeToMultiByteN=RtlUpcaseUnicodeToMultiByteN@20 RtlZeroMemory=RtlZeroMemory@8 __PdxGetCmdLine=__PdxGetCmdLine@0 __PdxInitializeData=__PdxInitializeData@8 diff --git a/reactos/ntoskrnl/ntoskrnl.def b/reactos/ntoskrnl/ntoskrnl.def index 24870e090e3..bd454c0cccc 100644 --- a/reactos/ntoskrnl/ntoskrnl.def +++ b/reactos/ntoskrnl/ntoskrnl.def @@ -1,4 +1,4 @@ -; $Id: ntoskrnl.def,v 1.25 1999/11/15 15:56:16 ekohl Exp $ +; $Id: ntoskrnl.def,v 1.26 1999/11/20 21:44:34 ekohl Exp $ ; ; reactos/ntoskrnl/ntoskrnl.def ; @@ -191,6 +191,7 @@ RtlCopyMemory RtlCopyString@8 RtlCopyUnicodeString@8 RtlCreateUnicodeString@8 +RtlDowncaseUnicodeString@12 RtlEnlargedIntegerMultiply RtlEnlargedUnsignedDivide RtlEnlargedUnsignedMultiply @@ -208,6 +209,7 @@ RtlGetDefaultCodePage@8 RtlInitAnsiString@8 RtlInitString@8 RtlInitUnicodeString@8 +RtlIntegerToChar@16 RtlIntegerToUnicodeString@12 RtlLargeIntegerAdd RtlLargeIntegerArithmeticShift @@ -236,8 +238,13 @@ RtlUnicodeStringToOemString@12 RtlUnicodeToMultiByteN@20 RtlUnicodeToMultiByteSize@12 RtlUnicodeToOemN@20 +RtlUpcaseUnicodeChar@4 RtlUpcaseUnicodeString@12 -RtlUpcaseString@8 +RtlUpcaseUnicodeStringToAnsiString@12 +RtlUpcaseUnicodeStringToOemString@12 +RtlUpcaseUnicodeToMultiByteN@20 +RtlUpcaseUnicodeToOemN@20 +RtlUpperChar@4 RtlUpperString@8 RtlZeroMemory@8 ZwAccessCheckAndAuditAlarm@44 diff --git a/reactos/ntoskrnl/ntoskrnl.edf b/reactos/ntoskrnl/ntoskrnl.edf index 51560569673..b42adf0ced8 100644 --- a/reactos/ntoskrnl/ntoskrnl.edf +++ b/reactos/ntoskrnl/ntoskrnl.edf @@ -1,4 +1,4 @@ -; $Id: ntoskrnl.edf,v 1.12 1999/11/15 15:56:16 ekohl Exp $ +; $Id: ntoskrnl.edf,v 1.13 1999/11/20 21:44:34 ekohl Exp $ ; ; reactos/ntoskrnl/ntoskrnl.def ; @@ -191,6 +191,7 @@ RtlCopyMemory RtlCopyString=RtlCopyString@8 RtlCopyUnicodeString=RtlCopyUnicodeString@8 RtlCreateUnicodeString=RtlCreateUnicodeString@8 +RtlDowncaseUnicodeString=RtlDowncaseUnicodeString@12 RtlEnlargedIntegerMultiply RtlEnlargedUnsignedDivide RtlEnlargedUnsignedMultiply @@ -208,6 +209,7 @@ RtlGetDefaultCodePage=RtlGetDefaultCodePage@8 RtlInitAnsiString=RtlInitAnsiString@8 RtlInitString=RtlInitString@8 RtlInitUnicodeString=RtlInitUnicodeString@8 +RtlIntegerToChar=RtlIntegerToChar@16 RtlIntegerToUnicodeString=RtlIntegerToUnicodeString@12 RtlLargeIntegerAdd RtlLargeIntegerArithmeticShift @@ -234,8 +236,13 @@ RtlUnicodeStringToOemSize=RtlUnicodeStringToOemSize@4 RtlUnicodeStringToOemString=RtlUnicodeStringToOemString@12 RtlUnicodeToMultiByteN=RtlUnicodeToMultiByteN@20 RtlUnicodeToMultiByteSize=RtlUnicodeToMultiByteSize@12 +RtlUpcaseUnicodeChar=RtlUpcaseUnicodeChar@4 RtlUpcaseUnicodeString=RtlUpcaseUnicodeString@12 -RtlUpcaseString=RtlUpcaseString@8 +RtlUpcaseUnicodeStringToAnsiString=RtlUpcaseUnicodeStringToAnsiString@12 +RtlUpcaseUnicodeStringToOemString=RtlUpcaseUnicodeStringToOemString@12 +RtlUpcaseUnicodeToMultiByteN=RtlUpcaseUnicodeToMultiByteN@20 +RtlUpcaseUnicodeToOemN=RtlUpcaseUnicodeToOemN@20 +RtlUpperChar=RtlUpperChar@4 RtlUpperString=RtlUpperString@8 RtlZeroMemory=RtlZeroMemory@8 ZwAccessCheckAndAuditAlarm=ZwAccessCheckAndAuditAlarm@44 diff --git a/reactos/ntoskrnl/rtl/nls.c b/reactos/ntoskrnl/rtl/nls.c index 37344c87dd1..64d96b27a7e 100644 --- a/reactos/ntoskrnl/rtl/nls.c +++ b/reactos/ntoskrnl/rtl/nls.c @@ -1,4 +1,4 @@ -/* $Id: nls.c,v 1.1 1999/11/15 15:57:01 ekohl Exp $ +/* $Id: nls.c,v 1.2 1999/11/20 21:45:20 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -56,8 +56,10 @@ CHAR UnicodeToOemTable [65536]; VOID STDCALL -RtlGetDefaultCodePage (PUSHORT AnsiCodePage, - PUSHORT OemCodePage) +RtlGetDefaultCodePage ( + PUSHORT AnsiCodePage, + PUSHORT OemCodePage + ) { *AnsiCodePage = NlsAnsiCodePage; *OemCodePage = NlsOemCodePage; @@ -66,11 +68,13 @@ RtlGetDefaultCodePage (PUSHORT AnsiCodePage, NTSTATUS STDCALL -RtlMultiByteToUnicodeN(PWCHAR UnicodeString, - ULONG UnicodeSize, - PULONG ResultSize, - PCHAR MbString, - ULONG MbSize) +RtlMultiByteToUnicodeN ( + PWCHAR UnicodeString, + ULONG UnicodeSize, + PULONG ResultSize, + PCHAR MbString, + ULONG MbSize + ) { ULONG Size = 0; ULONG i; @@ -95,7 +99,7 @@ RtlMultiByteToUnicodeN(PWCHAR UnicodeString, UnicodeString++; MbString++; - }; + } } else { @@ -110,9 +114,11 @@ RtlMultiByteToUnicodeN(PWCHAR UnicodeString, NTSTATUS STDCALL -RtlMultiByteToUnicodeSize(PULONG UnicodeSize, - PCHAR MbString, - ULONG MbSize) +RtlMultiByteToUnicodeSize ( + PULONG UnicodeSize, + PCHAR MbString, + ULONG MbSize + ) { if (NlsMbCodePageTag == FALSE) { @@ -161,7 +167,7 @@ RtlOemToUnicodeN(PWCHAR UnicodeString, UnicodeString++; OemString++; - }; + } } else { @@ -205,7 +211,7 @@ RtlUnicodeToMultiByteN(PCHAR MbString, MbString++; UnicodeString++; - }; + } } else { @@ -271,7 +277,101 @@ RtlUnicodeToOemN(PCHAR OemString, OemString++; UnicodeString++; - }; + } + } + else + { + /* multi-byte code page */ + /* FIXME */ + + } + + return STATUS_SUCCESS; +} + + +NTSTATUS +STDCALL +RtlUpcaseUnicodeToMultiByteN ( + PCHAR MbString, + ULONG MbSize, + PULONG ResultSize, + PWCHAR UnicodeString, + ULONG UnicodeSize + ) +{ + ULONG Size = 0; + ULONG i; + + if (NlsMbCodePageTag == FALSE) + { + /* single-byte code page */ + if (UnicodeSize > (MbSize * sizeof(WCHAR))) + Size = MbSize; + else + Size = UnicodeSize / sizeof(WCHAR); + + if (ResultSize != NULL) + *ResultSize = Size; + + for (i = 0; i < Size; i++) + { + /* FIXME: Upcase !! */ + *MbString = *UnicodeString; +#if 0 + *MbString = UnicodeToAnsiTable[*UnicodeString]; +#endif + + MbString++; + UnicodeString++; + } + } + else + { + /* multi-byte code page */ + /* FIXME */ + + } + + return STATUS_SUCCESS; +} + + +NTSTATUS +STDCALL +RtlUpcaseUnicodeToOemN ( + PCHAR OemString, + ULONG OemSize, + PULONG ResultSize, + PWCHAR UnicodeString, + ULONG UnicodeSize + ) +{ + ULONG Size = 0; + ULONG i; + + if (NlsMbOemCodePageTag == FALSE) + { + /* single-byte code page */ + if (UnicodeSize > (OemSize * sizeof(WCHAR))) + Size = OemSize; + else + Size = UnicodeSize / sizeof(WCHAR); + + if (ResultSize != NULL) + *ResultSize = Size; + + for (i = 0; i < Size; i++) + { + /* FIXME: Upcase !! */ + *OemString = *UnicodeString; +#if 0 + *OemString = UnicodeToOemTable[*UnicodeString]; +#endif + + OemString++; + UnicodeString++; + } } else { diff --git a/reactos/ntoskrnl/rtl/unicode.c b/reactos/ntoskrnl/rtl/unicode.c index 4bf32cd6265..24f073e9730 100644 --- a/reactos/ntoskrnl/rtl/unicode.c +++ b/reactos/ntoskrnl/rtl/unicode.c @@ -1,4 +1,4 @@ -/* $Id: unicode.c,v 1.8 1999/11/15 15:57:01 ekohl Exp $ +/* $Id: unicode.c,v 1.9 1999/11/20 21:45:20 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -10,16 +10,11 @@ */ #include -#include - //#include - #define NDEBUG #include -#define STR_FIX - extern unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base); @@ -28,20 +23,20 @@ extern unsigned long simple_strtoul(const char *cp, char **endp, WCHAR STDCALL -RtlAnsiCharToUnicodeChar(PCHAR AnsiChar) +RtlAnsiCharToUnicodeChar(CHAR AnsiChar) { ULONG Size; WCHAR UnicodeChar; Size = 1; #if 0 - Size = (NlsLeadByteInfo[*AnsiChar] == 0) ? 1 : 2; + Size = (NlsLeadByteInfo[AnsiChar] == 0) ? 1 : 2; #endif RtlMultiByteToUnicodeN (&UnicodeChar, sizeof(WCHAR), NULL, - AnsiChar, + &AnsiChar, Size); return UnicodeChar; @@ -64,9 +59,11 @@ RtlAnsiStringToUnicodeSize(PANSI_STRING AnsiString) NTSTATUS STDCALL -RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, - PANSI_STRING SourceString, - BOOLEAN AllocateDestinationString) +RtlAnsiStringToUnicodeString ( + PUNICODE_STRING DestinationString, + PANSI_STRING SourceString, + BOOLEAN AllocateDestinationString + ) { NTSTATUS Status; ULONG Length; @@ -120,8 +117,10 @@ RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, NTSTATUS STDCALL -RtlAppendAsciizToString(IN OUT PSTRING Destination, - IN PCSZ Source) +RtlAppendAsciizToString ( + IN OUT PSTRING Destination, + IN PCSZ Source + ) { ULONG Length; PCHAR Ptr; @@ -148,8 +147,10 @@ RtlAppendAsciizToString(IN OUT PSTRING Destination, NTSTATUS STDCALL -RtlAppendStringToString(PSTRING Destination, - PSTRING Source) +RtlAppendStringToString ( + PSTRING Destination, + PSTRING Source + ) { PCHAR Ptr; @@ -174,8 +175,10 @@ RtlAppendStringToString(PSTRING Destination, NTSTATUS STDCALL -RtlAppendUnicodeStringToString(IN OUT PUNICODE_STRING Destination, - IN PUNICODE_STRING Source) +RtlAppendUnicodeStringToString ( + IN OUT PUNICODE_STRING Destination, + IN PUNICODE_STRING Source + ) { PWCHAR Src, Dest; ULONG i; @@ -201,8 +204,10 @@ RtlAppendUnicodeStringToString(IN OUT PUNICODE_STRING Destination, NTSTATUS STDCALL -RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination, - IN PWSTR Source) +RtlAppendUnicodeToString ( + IN OUT PUNICODE_STRING Destination, + IN PWSTR Source + ) { PWCHAR Src; PWCHAR Dest; @@ -242,9 +247,11 @@ RtlCharToInteger(IN PCSZ String, IN ULONG Base, IN OUT PULONG Value) LONG STDCALL -RtlCompareString(PSTRING String1, - PSTRING String2, - BOOLEAN CaseInsensitive) +RtlCompareString ( + PSTRING String1, + PSTRING String2, + BOOLEAN CaseInsensitive + ) { unsigned long i; char c1, c2; @@ -256,8 +263,8 @@ RtlCompareString(PSTRING String1, { if (CaseInsensitive == TRUE) { - c1 = toupper(*String1->Buffer); - c2 = toupper(*String2->Buffer); + c1 = RtlUpperChar (*String1->Buffer); + c2 = RtlUpperChar (*String2->Buffer); } else { @@ -285,9 +292,11 @@ RtlCompareString(PSTRING String1, LONG STDCALL -RtlCompareUnicodeString(PUNICODE_STRING String1, - PUNICODE_STRING String2, - BOOLEAN CaseInsensitive) +RtlCompareUnicodeString ( + PUNICODE_STRING String1, + PUNICODE_STRING String2, + BOOLEAN CaseInsensitive + ) { unsigned long i; WCHAR wc1, wc2; @@ -303,8 +312,8 @@ RtlCompareUnicodeString(PUNICODE_STRING String1, { if(CaseInsensitive == TRUE) { - wc1 = towupper (*pw1); - wc2 = towupper (*pw2); + wc1 = RtlUpcaseUnicodeChar (*pw1); + wc2 = RtlUpcaseUnicodeChar (*pw2); } else { @@ -313,9 +322,7 @@ RtlCompareUnicodeString(PUNICODE_STRING String1, } if (wc1 != wc2) - { return wc1 - wc2; - } pw1++; pw2++; @@ -327,75 +334,76 @@ RtlCompareUnicodeString(PUNICODE_STRING String1, VOID STDCALL -RtlCopyString(IN OUT PSTRING DestinationString, IN PSTRING SourceString) +RtlCopyString ( + IN OUT PSTRING DestinationString, + IN PSTRING SourceString + ) { - unsigned long copylen, i; + ULONG copylen, i; + PCHAR Src, Dest; if(SourceString == NULL) { DestinationString->Length = 0; + return; } - else + + copylen = min (DestinationString->MaximumLength - sizeof(CHAR), + SourceString->Length); + Src = SourceString->Buffer; + Dest = DestinationString->Buffer; + + for (i = 0; i < copylen; i++) { - if(SourceString->Length < DestinationString->MaximumLength) - { - copylen = SourceString->Length; - } - else - { - copylen = DestinationString->MaximumLength; - } - - for(i=0; iBuffer = *SourceString->Buffer; - DestinationString->Buffer++; - SourceString->Buffer++; - } - - *DestinationString->Buffer = 0; - DestinationString->Buffer -= copylen; - SourceString->Buffer -= copylen; + *Dest = *Src; + Dest++; + Src++; } + *Dest = 0; + + DestinationString->Length = copylen; } VOID STDCALL -RtlCopyUnicodeString(IN OUT PUNICODE_STRING DestinationString, - IN PUNICODE_STRING SourceString) +RtlCopyUnicodeString ( + IN OUT PUNICODE_STRING DestinationString, + IN PUNICODE_STRING SourceString + ) { - unsigned long copylen, i; + ULONG copylen, i; PWCHAR Src, Dest; if(SourceString==NULL) { DestinationString->Length=0; + return; } - else + + copylen = min(DestinationString->MaximumLength - sizeof(WCHAR), + SourceString->Length); + Src = SourceString->Buffer; + Dest = DestinationString->Buffer; + + for (i = 0; i < (copylen / sizeof (WCHAR)); i++) { - copylen = min(DestinationString->MaximumLength - sizeof(WCHAR), - SourceString->Length); - Src = SourceString->Buffer; - Dest = DestinationString->Buffer; - - for (i = 0; i < (copylen / sizeof (WCHAR)); i++) - { - *Dest = *Src; - Dest++; - Src++; - } - *Dest = 0; - - DestinationString->Length = copylen; + *Dest = *Src; + Dest++; + Src++; } + *Dest = 0; + + DestinationString->Length = copylen; } BOOLEAN STDCALL -RtlCreateUnicodeString (PUNICODE_STRING Destination, - PWSTR Source) +RtlCreateUnicodeString ( + IN OUT PUNICODE_STRING Destination, + IN PWSTR Source + ) { ULONG Length; @@ -419,7 +427,90 @@ RtlCreateUnicodeString (PUNICODE_STRING Destination, BOOLEAN STDCALL -RtlEqualString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive) +RtlCreateUnicodeStringFromAsciiz ( + IN OUT PUNICODE_STRING Destination, + IN PCSZ Source + ) +{ + ANSI_STRING AnsiString; + NTSTATUS Status; + + RtlInitAnsiString (&AnsiString, + Source); + + Status = RtlAnsiStringToUnicodeString (Destination, + &AnsiString, + TRUE); + + return NT_SUCCESS(Status); +} + + +/* +RtlCustomCPToUnicodeN +*/ + + +NTSTATUS +STDCALL +RtlDowncaseUnicodeString ( + IN OUT PUNICODE_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) +{ + ULONG i; + PWCHAR Src, Dest; + + if (AllocateDestinationString == TRUE) + { + DestinationString->Length = SourceString->Length; + DestinationString->MaximumLength = SourceString->Length + sizeof(WCHAR); + DestinationString->Buffer = ExAllocatePool (NonPagedPool, + SourceString->Length + sizeof(WCHAR)); + if (DestinationString->Buffer == NULL) + return STATUS_NO_MEMORY; + } + else + { + if (SourceString->Length >= DestinationString->MaximumLength) + return STATUS_BUFFER_OVERFLOW; + } + + Src = SourceString->Buffer; + Dest = DestinationString->Buffer; + for (i=0; i < SourceString->Length / sizeof(WCHAR); i++) + { + if (*Src < L'A') + { + *Dest = *Src; + } + else if (*Src <= L'Z') + { + *Dest = (*Src + (L'a' - L'A')); + } + else + { + /* FIXME: characters above 'Z' */ + *Dest = *Src; + } + + Dest++; + Src++; + } + *Dest = 0; + + return STATUS_SUCCESS; +} + + +BOOLEAN +STDCALL +RtlEqualString ( + IN PSTRING String1, + IN PSTRING String2, + IN BOOLEAN CaseInsensitive + ) { unsigned long s1l=String1->Length; unsigned long s2l=String2->Length; @@ -436,8 +527,8 @@ RtlEqualString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive) if (CaseInsensitive == TRUE) { - c1 = toupper(c1); - c2 = toupper(c2); + c1 = RtlUpperChar (c1); + c2 = RtlUpperChar (c2); } if (c1 != c2) @@ -460,9 +551,11 @@ RtlEqualString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive) BOOLEAN STDCALL -RtlEqualUnicodeString(PUNICODE_STRING String1, - PUNICODE_STRING String2, - BOOLEAN CaseInsensitive) +RtlEqualUnicodeString ( + IN PUNICODE_STRING String1, + IN PUNICODE_STRING String2, + IN BOOLEAN CaseInsensitive + ) { unsigned long s1l = String1->Length / sizeof(WCHAR); unsigned long s2l = String2->Length / sizeof(WCHAR); @@ -480,8 +573,8 @@ RtlEqualUnicodeString(PUNICODE_STRING String1, { if(CaseInsensitive == TRUE) { - wc1 = towupper (*pw1); - wc2 = towupper (*pw2); + wc1 = RtlUpcaseUnicodeChar (*pw1); + wc2 = RtlUpcaseUnicodeChar (*pw2); } else { @@ -500,9 +593,16 @@ RtlEqualUnicodeString(PUNICODE_STRING String1, } +/* +RtlEraseUnicodeString +*/ + + VOID STDCALL -RtlFreeAnsiString(IN PANSI_STRING AnsiString) +RtlFreeAnsiString ( + IN PANSI_STRING AnsiString + ) { if (AnsiString->Buffer == NULL) return; @@ -517,7 +617,9 @@ RtlFreeAnsiString(IN PANSI_STRING AnsiString) VOID STDCALL -RtlFreeOemString(IN PSTRING OemString) +RtlFreeOemString ( + IN POEM_STRING OemString + ) { if (OemString->Buffer == NULL) return; @@ -532,7 +634,9 @@ RtlFreeOemString(IN PSTRING OemString) VOID STDCALL -RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString) +RtlFreeUnicodeString ( + IN PUNICODE_STRING UnicodeString + ) { if (UnicodeString->Buffer == NULL) return; @@ -547,8 +651,10 @@ RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString) VOID STDCALL -RtlInitAnsiString(IN OUT PANSI_STRING DestinationString, - IN PCSZ SourceString) +RtlInitAnsiString ( + IN OUT PANSI_STRING DestinationString, + IN PCSZ SourceString + ) { ULONG DestSize; @@ -569,8 +675,10 @@ RtlInitAnsiString(IN OUT PANSI_STRING DestinationString, VOID STDCALL -RtlInitString(IN OUT PSTRING DestinationString, - IN PCSZ SourceString) +RtlInitString ( + IN OUT PSTRING DestinationString, + IN PCSZ SourceString + ) { ULONG DestSize; @@ -588,15 +696,19 @@ RtlInitString(IN OUT PSTRING DestinationString, DestinationString->Buffer = (PCHAR)SourceString; } + VOID STDCALL -RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString, - IN PCWSTR SourceString) +RtlInitUnicodeString ( + IN OUT PUNICODE_STRING DestinationString, + IN PCWSTR SourceString + ) { ULONG DestSize; - DPRINT("RtlInitUnicodeString(DestinationString %x, " - "SourceString %x)\n",DestinationString,SourceString); + DPRINT("RtlInitUnicodeString(DestinationString %x, SourceString %x)\n", + DestinationString, + SourceString); if (SourceString == NULL) { @@ -615,52 +727,93 @@ RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString, NTSTATUS STDCALL -RtlIntegerToUnicodeString(IN ULONG Value, - IN ULONG Base, /* optional */ - IN OUT PUNICODE_STRING String) +RtlIntegerToChar ( + IN ULONG Value, + IN ULONG Base, + IN ULONG Length, + IN OUT PCHAR String + ) { - UNIMPLEMENTED; + ULONG Radix; + CHAR temp[33]; + ULONG v = 0; + ULONG i; + PCHAR tp; + PCHAR sp; - return STATUS_NOT_IMPLEMENTED; -#if 0 - char *str; - unsigned long len, i; + Radix = Base; + if (Radix == 0) + Radix = 10; - str=ExAllocatePool(NonPagedPool, 1024); - if(Base==16) { - sprintf(str, "%x", Value); - } else - if(Base==8) { - sprintf(str, "%o", Value); - } else - if(Base==2) { - sprintf(str, "%b", Value); - } else { - sprintf(str, "%u", (unsigned int)Value); - }; + if ((Radix != 2) && (Radix != 8) && + (Radix != 10) && (Radix != 16)) + return STATUS_INVALID_PARAMETER; - len=strlen(str); - if(String->MaximumLengthBuffer=*str; - String->Buffer++; - str++; - }; - *String->Buffer=0; - String->Buffer-=len; - String->Length=len; - str-=len; - ExFreePool(str); + if (tp - temp >= Length) + return STATUS_BUFFER_TOO_SMALL; - return STATUS_SUCCESS; -#endif + sp = String; + while (tp > temp) + *sp++ = *--tp; + *sp = 0; + + return STATUS_SUCCESS; } +NTSTATUS +STDCALL +RtlIntegerToUnicodeString ( + IN ULONG Value, + IN ULONG Base, /* optional */ + IN OUT PUNICODE_STRING String + ) +{ + ANSI_STRING AnsiString; + CHAR Buffer[33]; + NTSTATUS Status; + + Status = RtlIntegerToChar (Value, + Base, + 33, + Buffer); + if (!NT_SUCCESS(Status)) + return Status; + + AnsiString.Buffer = Buffer; + AnsiString.Length = strlen (Buffer); + AnsiString.MaximumLength = 33; + + Status = RtlAnsiStringToUnicodeString (String, + &AnsiString, + FALSE); + + return Status; +} + + +/* +RtlOemStringToCountedUnicodeString +*/ + + ULONG STDCALL -RtlOemStringToUnicodeSize(IN PANSI_STRING OemString) +RtlOemStringToUnicodeSize ( + IN POEM_STRING OemString + ) { ULONG Size; @@ -674,9 +827,11 @@ RtlOemStringToUnicodeSize(IN PANSI_STRING OemString) NTSTATUS STDCALL -RtlOemStringToUnicodeString(PUNICODE_STRING DestinationString, - PANSI_STRING SourceString, - BOOLEAN AllocateDestinationString) +RtlOemStringToUnicodeString ( + IN OUT PUNICODE_STRING DestinationString, + IN POEM_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) { NTSTATUS Status; ULONG Length; @@ -744,9 +899,11 @@ RtlUnicodeStringToAnsiSize(IN PUNICODE_STRING UnicodeString) NTSTATUS STDCALL -RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString, - IN PUNICODE_STRING SourceString, - IN BOOLEAN AllocateDestinationString) +RtlUnicodeStringToAnsiString ( + IN OUT PANSI_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) { NTSTATUS Status; ULONG Length; @@ -764,9 +921,8 @@ RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString, if (AllocateDestinationString == TRUE) { DestinationString->MaximumLength = Length + sizeof(CHAR); - DestinationString->Buffer = - ExAllocatePool (NonPagedPool, - DestinationString->MaximumLength); + DestinationString->Buffer = ExAllocatePool (NonPagedPool, + DestinationString->MaximumLength); if (DestinationString->Buffer == NULL) return STATUS_NO_MEMORY; } @@ -797,20 +953,30 @@ RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString, } +/* +RtlUnicodeStringToCountedOemString +*/ + + NTSTATUS STDCALL -RtlUnicodeStringToInteger(IN PUNICODE_STRING String, - IN ULONG Base, - OUT PULONG Value) +RtlUnicodeStringToInteger ( + IN PUNICODE_STRING String, + IN ULONG Base, + OUT PULONG Value + ) { + return STATUS_NOT_IMPLEMENTED; +#if 0 char *str; unsigned long i, lenmin=0; BOOLEAN addneg=FALSE; str=ExAllocatePool(NonPagedPool, String->Length+1); - for(i=0; iLength; i++) { - *str=*String->Buffer; + for(i=0; iLength; i++) + { + *str=*String->Buffer; if(*str=='b') { Base=2; lenmin++; } else if(*str=='o') { Base=8; lenmin++; } else @@ -834,7 +1000,7 @@ RtlUnicodeStringToInteger(IN PUNICODE_STRING String, return STATUS_INVALID_PARAMETER; } else if((((*str>'9') || (*str<'0')) || - ((toupper(*str)>'F') || (toupper(*str)<'A'))) && (Base==16)) + ((RtlUpperChar(*str)>'F') || (RtlUpperChar(*str)<'A'))) && (Base==16)) { String->Buffer-=i; *Value=0; @@ -843,7 +1009,7 @@ RtlUnicodeStringToInteger(IN PUNICODE_STRING String, str++; String->Buffer++; - }; + } *str=0; String->Buffer-=String->Length; @@ -856,12 +1022,15 @@ RtlUnicodeStringToInteger(IN PUNICODE_STRING String, ExFreePool(str); return(STATUS_SUCCESS); +#endif } ULONG STDCALL -RtlUnicodeStringToOemSize(IN PUNICODE_STRING UnicodeString) +RtlUnicodeStringToOemSize ( + IN PUNICODE_STRING UnicodeString + ) { ULONG Size; @@ -875,9 +1044,11 @@ RtlUnicodeStringToOemSize(IN PUNICODE_STRING UnicodeString) NTSTATUS STDCALL -RtlUnicodeStringToOemString(IN OUT PANSI_STRING DestinationString, - IN PUNICODE_STRING SourceString, - IN BOOLEAN AllocateDestinationString) +RtlUnicodeStringToOemString ( + IN OUT POEM_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) { NTSTATUS Status; ULONG Length; @@ -928,65 +1099,246 @@ RtlUnicodeStringToOemString(IN OUT PANSI_STRING DestinationString, } +WCHAR +STDCALL +RtlUpcaseUnicodeChar ( + WCHAR Source + ) +{ + if (Source < L'a') + return Source; + + if (Source <= L'z') + return (Source - (L'a' - L'A')); + + /* FIXME: characters above 'z' */ + + return Source; +} + + NTSTATUS STDCALL -RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString, - IN PUNICODE_STRING SourceString, - IN BOOLEAN AllocateDestinationString) +RtlUpcaseUnicodeString ( + IN OUT PUNICODE_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) { - ULONG i; - PWCHAR Src, Dest; + ULONG i; + PWCHAR Src, Dest; - if(AllocateDestinationString==TRUE) - { - DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length + sizeof(WCHAR)); - DestinationString->Length=SourceString->Length; - DestinationString->MaximumLength=SourceString->Length+sizeof(WCHAR); - } + if (AllocateDestinationString == TRUE) + { + DestinationString->Length = SourceString->Length; + DestinationString->MaximumLength = SourceString->Length + sizeof(WCHAR); + DestinationString->Buffer = ExAllocatePool (NonPagedPool, + SourceString->Length + sizeof(WCHAR)); + if (DestinationString->Buffer == NULL) + return STATUS_NO_MEMORY; + } + else + { + if (SourceString->Length >= DestinationString->MaximumLength) + return STATUS_BUFFER_OVERFLOW; + } - Src = SourceString->Buffer; - Dest = DestinationString->Buffer; - for (i=0; i < SourceString->Length / sizeof(WCHAR); i++) - { - *Dest = towupper (*Src); - Dest++; - Src++; - } - *Dest = 0; + Src = SourceString->Buffer; + Dest = DestinationString->Buffer; + for (i=0; i < SourceString->Length / sizeof(WCHAR); i++) + { + *Dest = RtlUpcaseUnicodeChar (*Src); + Dest++; + Src++; + } + *Dest = 0; - return STATUS_SUCCESS; + return STATUS_SUCCESS; } -VOID + +NTSTATUS STDCALL -RtlUpcaseString(IN OUT PSTRING DestinationString, - IN PSTRING SourceString) +RtlUpcaseUnicodeStringToAnsiString ( + IN OUT PANSI_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) { - unsigned long i, len; - PCHAR Src, Dest; + NTSTATUS Status; + ULONG Length; - if(SourceString->Length>DestinationString->MaximumLength) { - len=DestinationString->MaximumLength; - } else { - len=SourceString->Length; - }; + if (NlsMbCodePageTag == TRUE) + Length = RtlUnicodeStringToAnsiSize (SourceString); + else + Length = SourceString->Length / sizeof(WCHAR); - for(i=0; iBuffer=toupper(*SourceString->Buffer); - DestinationString->Buffer++; - SourceString->Buffer++; - }; - *DestinationString->Buffer=0; +// if (Length > 65535) +// return STATUS_INVALID_PARAMETER_2; - DestinationString->Buffer-=len; - SourceString->Buffer-=len; + DestinationString->Length = Length; + + if (AllocateDestinationString == TRUE) + { + DestinationString->MaximumLength = Length + sizeof(CHAR); + DestinationString->Buffer = ExAllocatePool (NonPagedPool, + DestinationString->MaximumLength); + if (DestinationString->Buffer == NULL) + return STATUS_NO_MEMORY; + } + else + { + if (Length >= DestinationString->Length) + return STATUS_BUFFER_OVERFLOW; + } + + RtlZeroMemory (DestinationString->Buffer, + DestinationString->Length); + + Status = RtlUpcaseUnicodeToMultiByteN (DestinationString->Buffer, + DestinationString->Length, + NULL, + SourceString->Buffer, + SourceString->Length); + if (!NT_SUCCESS(Status)) + { + if (AllocateDestinationString) + ExFreePool (DestinationString->Buffer); + return Status; + } + + DestinationString->Buffer[Length] = 0; + + return STATUS_SUCCESS; } + +/* +RtlUpcaseUnicodeStringToCountedOemString +*/ + + +NTSTATUS +STDCALL +RtlUpcaseUnicodeStringToOemString ( + IN OUT POEM_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString + ) +{ + NTSTATUS Status; + ULONG Length; + + if (NlsMbOemCodePageTag == TRUE) + Length = RtlUnicodeStringToAnsiSize (SourceString); + else + Length = SourceString->Length / sizeof(WCHAR); + +// if (Length > 65535) +// return STATUS_INVALID_PARAMETER_2; + + DestinationString->Length = Length; + + if (AllocateDestinationString == TRUE) + { + DestinationString->MaximumLength = Length + sizeof(CHAR); + DestinationString->Buffer = ExAllocatePool (NonPagedPool, + DestinationString->MaximumLength); + if (DestinationString->Buffer == NULL) + return STATUS_NO_MEMORY; + } + else + { + if (Length >= DestinationString->Length) + return STATUS_BUFFER_OVERFLOW; + } + + RtlZeroMemory (DestinationString->Buffer, + DestinationString->Length); + + Status = RtlUpcaseUnicodeToOemN (DestinationString->Buffer, + DestinationString->Length, + NULL, + SourceString->Buffer, + SourceString->Length); + if (!NT_SUCCESS(Status)) + { + if (AllocateDestinationString) + ExFreePool (DestinationString->Buffer); + return Status; + } + + DestinationString->Buffer[Length] = 0; + + return STATUS_SUCCESS; +} + + +/* +RtlUpcaseUnicodeToCustomCP +*/ + + +CHAR +STDCALL +RtlUpperChar ( + IN CHAR Source + ) +{ + WCHAR Unicode; + CHAR Destination; + + if (NlsMbCodePageTag == FALSE) + { + /* single-byte code page */ + /* ansi->unicode */ + Unicode = (WCHAR)Source; +#if 0 + Unicode = NlsAnsiToUnicodeData[Source]; +#endif + + /* upcase conversion */ + Unicode = RtlUpcaseUnicodeChar (Unicode); + + /* unicode -> ansi */ + Destination = (CHAR)Unicode; +#if 0 + Destination = NlsUnicodeToAnsiData[Unicode]; +#endif + } + else + { + /* single-byte code page */ + /* FIXME: implement the multi-byte stuff!! */ + Destination = Source; + } + + return Destination; +} + + VOID STDCALL RtlUpperString(PSTRING DestinationString, PSTRING SourceString) { - UNIMPLEMENTED; + ULONG Length; + ULONG i; + PCHAR Src; + PCHAR Dest; + + Length = min(SourceString->Length, DestinationString->MaximumLength - 1); + + Src = SourceString->Buffer; + Dest = DestinationString->Buffer; + for (i = 0; i < Length; i++) + { + *Dest = RtlUpperChar (*Src); + Src++; + Dest++; + } + *Dest = 0; + + DestinationString->Length = SourceString->Length; } /* EOF */ diff --git a/reactos/ntoskrnl/rtl/unicode.c.new b/reactos/ntoskrnl/rtl/unicode.c.new deleted file mode 100644 index 6135ceeb03d..00000000000 --- a/reactos/ntoskrnl/rtl/unicode.c.new +++ /dev/null @@ -1,529 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: ntoskrnl/rtl/unicode.c - * PURPOSE: String functions - * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com) - * UPDATE HISTORY: - * Created 10/08/98 - * Fixed bugs 21/08/98 - */ - -#include -#include -#include -#include -#include -#include - -#define Aa_Difference 'A'-'a'; - -VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString) -{ - UNIMPLEMENTED; -} - -WCHAR wtoupper(WCHAR c) -{ - if((c>='a') && (c<='z')) return c+Aa_Difference; - return c; -}; - -unsigned long wstrlen(PWSTR s) -{ - WCHAR c=' '; - unsigned int len=0; - - while(c!=0) { - c=*s; - s++; - len++; - }; - s-=len; - - return len-1; -}; - -ULONG RtlAnsiStringToUnicodeSize(IN PANSI_STRING AnsiString) -{ - return AnsiString->Length*2; -}; - -NTSTATUS RtlAnsiStringToUnicodeString(IN OUT PUNICODE_STRING DestinationString, - IN PANSI_STRING SourceString, IN BOOLEAN AllocateDestinationString) -{ - unsigned long i; - - if(AllocateDestinationString==TRUE) { - DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length*2+1); - DestinationString->MaximumLength=SourceString->Length; - }; - - DestinationString->Length=SourceString->Length; - memset(DestinationString->Buffer, 0, SourceString->Length*2); - - for (i=0; iLength; i++) - { - *DestinationString->Buffer=*SourceString->Buffer; - - SourceString->Buffer++; - DestinationString->Buffer++; - }; - *DestinationString->Buffer=0; - - SourceString->Buffer-=SourceString->Length; - DestinationString->Buffer-=SourceString->Length; - - return STATUS_SUCCESS; -}; - -NTSTATUS RtlAppendUnicodeStringToString(IN OUT PUNICODE_STRING Destination, - IN PUNICODE_STRING Source) -{ - unsigned long i; - - if(Destination->MaximumLength-Destination->Length-Source->Length<0) - return STATUS_BUFFER_TOO_SMALL; - - Destination->Buffer+=Destination->Length; - for(i=0; iLength; i++) { - *Destination->Buffer=*Source->Buffer; - Destination->Buffer++; - Source->Buffer++; - }; - *Destination->Buffer=0; - Destination->Buffer-=(Destination->Length+Source->Length); - Source->Buffer-=Source->Length; - - Destination->Length+=Source->Length; - return STATUS_SUCCESS; -}; - -NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination, - IN PWSTR Source) -{ - unsigned long i, slen=wstrlen(Source); - - if(Destination->MaximumLength-Destination->Length-slen<0) - return STATUS_BUFFER_TOO_SMALL; - - Destination->Buffer+=Destination->Length; - for(i=0; iBuffer=*Source; - Destination->Buffer++; - Source++; - }; - *Destination->Buffer=0; - Destination->Buffer-=(Destination->Length+slen); - Source-=slen; - - Destination->Length+=slen; - return STATUS_SUCCESS; -}; - -NTSTATUS RtlCharToInteger(IN PCSZ String, IN ULONG Base, IN OUT PULONG Value) -{ - *Value=simple_strtoul((const char *)String, NULL, Base); -}; - -LONG RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive) -{ - unsigned long i; - char c1, c2; - - if(String1->Length!=String2->Length) return String1->Length-String2->Length; - - for(i=0; iLength; i++) { - if(CaseInsensitive==TRUE) { - c1=toupper(*String1->Buffer); - c2=toupper(*String2->Buffer); - } else { - c1=*String1->Buffer; - c2=*String2->Buffer; - }; - if(c1!=c2) { - String1->Buffer-=i; - String2->Buffer-=i; - return c1-c2; - }; - String1->Buffer++; - String2->Buffer++; - }; - String1->Buffer-=i; - String2->Buffer-=i; - - return 0; -}; - -LONG RtlCompareUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, - BOOLEAN CaseInsensitive) -{ - unsigned long i; - WCHAR wc1, wc2; - - if(String1->Length!=String2->Length) return - String1->Length-String2->Length; - - for(i=0; iLength; i++) { - if(CaseInsensitive==TRUE) { - wc1=wtoupper(*String1->Buffer); - wc2=wtoupper(*String2->Buffer); - } else { - wc1=*String1->Buffer; - wc2=*String2->Buffer; - }; - - if(wc1!=wc2) { - String1->Buffer-=i; - String2->Buffer-=i; - return wc1-wc2; - }; - - String1->Buffer++; - String2->Buffer++; - }; - - String1->Buffer-=i; - String2->Buffer-=i; - - return 0; -}; - -VOID RtlCopyString(IN OUT PSTRING DestinationString, IN PSTRING SourceString) -{ - unsigned long copylen, i; - - if(SourceString==NULL) { - DestinationString->Length=0; - } else { - if(SourceString->LengthMaximumLength) { - copylen=SourceString->Length; - } else { - copylen=DestinationString->MaximumLength; - }; - for(i=0; iBuffer=*SourceString->Buffer; - DestinationString->Buffer++; - SourceString->Buffer++; - }; - *DestinationString->Buffer=0; - DestinationString->Buffer-=copylen; - SourceString->Buffer-=copylen; - }; -}; - -VOID RtlCopyUnicodeString(IN OUT PUNICODE_STRING DestinationString, - IN PUNICODE_STRING SourceString) -{ - unsigned long copylen, i; - - if(SourceString==NULL) { - DestinationString->Length=0; - } else { - if(SourceString->LengthMaximumLength) { - copylen=SourceString->Length; - } else { - copylen=DestinationString->MaximumLength; - }; - for(i=0; iBuffer=*SourceString->Buffer; - DestinationString->Buffer++; - SourceString->Buffer++; - }; - *DestinationString->Buffer=0; - DestinationString->Buffer-=copylen; - SourceString->Buffer-=copylen; - }; -}; - -BOOLEAN RtlEqualString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive) -{ - unsigned long s1l=String1->Length; - unsigned long s2l=String2->Length; - unsigned long i; - char c1, c2; - - if(s1l!=s2l) return FALSE; - - for(i=0; iBuffer; - c2=*String2->Buffer; - - if(CaseInsensitive==TRUE) { - c1=toupper(c1); - c2=toupper(c2); - }; - - if(c1!=c2) { - String1->Buffer-=i; - String2->Buffer-=i; - return FALSE; - }; - - String1->Buffer++; - String2->Buffer++; - }; - - String1->Buffer-=i; - String2->Buffer-=i; - - return TRUE; -}; - -BOOLEAN RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, - BOOLEAN CaseInsensitive) -{ - unsigned long s1l=String1->Length; - unsigned long s2l=String2->Length; - unsigned long i; - char wc1, wc2; - - if(s1l!=s2l) return FALSE; - - for(i=0; iBuffer); - wc2=wtoupper(*String2->Buffer); - } else { - wc1=*String1->Buffer; - wc2=*String2->Buffer; - }; - - if(wc1!=wc2) { - String1->Buffer-=i; - String2->Buffer-=i; - return FALSE; - }; - - String1->Buffer++; - String2->Buffer++; - }; - - String1->Buffer-=i; - String2->Buffer-=i; - - return TRUE; -}; - -VOID RtlFreeAnsiString(IN PANSI_STRING AnsiString) -{ - ExFreePool(AnsiString->Buffer); -}; - -VOID RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString) -{ - ExFreePool(UnicodeString->Buffer); -}; - -VOID RtlInitAnsiString(IN OUT PANSI_STRING DestinationString, - IN PCSZ SourceString) -{ - unsigned long DestSize; - - if(SourceString==NULL) { - DestinationString->Length=0; - DestinationString->MaximumLength=0; - } else { - DestSize=strlen((const char *)SourceString); - DestinationString->Length=DestSize; - DestinationString->MaximumLength=DestSize+1; - }; - DestinationString->Buffer=(PCHAR)SourceString; -}; - -VOID RtlInitString(IN OUT PSTRING DestinationString, - IN PCSZ SourceString) -{ - DestinationString->Length=strlen((char *)SourceString); - DestinationString->MaximumLength=strlen((char *)SourceString)+1; - DestinationString->Buffer=SourceString; -}; - -VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString, - IN PCWSTR SourceString) -{ - unsigned long i, DestSize; - UNICODE_STRING Dest=*DestinationString; - - if(SourceString==NULL) { - DestinationString->Length=0; - DestinationString->MaximumLength=0; - DestinationString->Buffer=NULL; - } else { - DestSize=wstrlen((PWSTR)SourceString); - DestinationString->Length=DestSize; - DestinationString->MaximumLength=DestSize+1; - - DestinationString->Buffer=(PWSTR)SourceString; - }; -}; - -NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base, /* optional */ - IN OUT PUNICODE_STRING String) -{ - char *str; - unsigned long len, i; - - str=ExAllocatePool(NonPagedPool, 1024); - if(Base==16) { - sprintf(str, "%x", Value); - } else - if(Base==8) { - sprintf(str, "%o", Value); - } else - if(Base==2) { - sprintf(str, "%b", Value); - } else { - sprintf(str, "%u", Value); - }; - - len=strlen(str); - if(String->MaximumLengthBuffer=*str; - String->Buffer++; - str++; - }; - *String->Buffer=0; - String->Buffer-=len; - String->Length=len; - str-=len; - ExFreePool(str); - - return STATUS_SUCCESS; -}; - -NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString, - IN PUNICODE_STRING SourceString, - IN BOOLEAN AllocateDestinationString) -{ - unsigned long i; - - if(AllocateDestinationString==TRUE) { - - // Causes excetion 14(0) in _Validate_Free_List - DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length+1); - DestinationString->MaximumLength=SourceString->Length+1; - }; - - DestinationString->Length=SourceString->Length; - - for(i=0; iLength; i++) { - *DestinationString->Buffer=*SourceString->Buffer; - DestinationString->Buffer++; - SourceString->Buffer++; - }; - *DestinationString->Buffer=0; - - DestinationString->Buffer-=SourceString->Length; - SourceString->Buffer-=SourceString->Length; - - return STATUS_SUCCESS; -}; - -NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base, - OUT PULONG Value) -{ - char *str; - unsigned long i, lenmin=0; - BOOLEAN addneg=FALSE; - - str=ExAllocatePool(NonPagedPool, String->Length+1); - - for(i=0; iLength; i++) { - *str=*String->Buffer; - - if(*str=='b') { Base=2; lenmin++; } else - if(*str=='o') { Base=8; lenmin++; } else - if(*str=='d') { Base=10; lenmin++; } else - if(*str=='x') { Base=16; lenmin++; } else - if(*str=='+') { lenmin++; } else - if(*str=='-') { addneg=TRUE; lenmin++; } else - if((*str>'1') && (Base==2)) { - String->Buffer-=i; - *Value=0; - return STATUS_INVALID_PARAMETER; - } else - if(((*str>'7') || (*str<'0')) && (Base==8)) { - String->Buffer-=i; - *Value=0; - return STATUS_INVALID_PARAMETER; - } else - if(((*str>'9') || (*str<'0')) && (Base==10)) { - String->Buffer-=i; - *Value=0; - return STATUS_INVALID_PARAMETER; - } else - if((((*str>'9') || (*str<'0')) || - ((toupper(*str)>'F') || (toupper(*str)<'A'))) && (Base==16)) - { - String->Buffer-=i; - *Value=0; - return STATUS_INVALID_PARAMETER; - } else - str++; - - String->Buffer++; - }; - - *str=0; - String->Buffer-=String->Length; - str-=(String->Length-lenmin); - - if(addneg==TRUE) { - *Value=simple_strtoul(str, NULL, Base)*-1; - } else - *Value=simple_strtoul(str, NULL, Base); - - ExFreePool(str); -}; - -NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString, - IN PUNICODE_STRING SourceString, - IN BOOLEAN AllocateDestinationString) -{ - unsigned long i; - - if(AllocateDestinationString==TRUE) { - DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length*2+1); - DestinationString->Length=SourceString->Length; - DestinationString->MaximumLength=SourceString->Length+1; - }; - - for(i=0; iLength; i++) { - *DestinationString->Buffer=wtoupper(*SourceString->Buffer); - DestinationString->Buffer++; - SourceString->Buffer++; - }; - *DestinationString->Buffer=0; - - DestinationString->Buffer-=SourceString->Length; - SourceString->Buffer-=SourceString->Length; - - return STATUS_SUCCESS; -}; - -VOID RtlUpcaseString(IN OUT PSTRING DestinationString, - IN PSTRING SourceString) -{ - unsigned long i, len; - - if(SourceString->Length>DestinationString->MaximumLength) { - len=DestinationString->MaximumLength; - } else { - len=SourceString->Length; - }; - - for(i=0; iBuffer=toupper(*SourceString->Buffer); - DestinationString->Buffer++; - SourceString->Buffer++; - }; - *DestinationString->Buffer=0; - - DestinationString->Buffer-=len; - SourceString->Buffer-=len; -}; diff --git a/reactos/subsys/win32k/objects/brush.c b/reactos/subsys/win32k/objects/brush.c index d5bd4743967..f9fc752a846 100644 --- a/reactos/subsys/win32k/objects/brush.c +++ b/reactos/subsys/win32k/objects/brush.c @@ -1,4 +1,4 @@ -/* $Id: brush.c,v 1.6 1999/11/17 20:54:05 rex Exp $ +/* $Id: brush.c,v 1.7 1999/11/20 21:49:23 ekohl Exp $ */ @@ -7,7 +7,7 @@ #include #include #include -#include +//#include // #define NDEBUG #include diff --git a/reactos/subsys/win32k/stubs/stubs.c b/reactos/subsys/win32k/stubs/stubs.c index 9321b1fdbab..49576bbe1fa 100644 --- a/reactos/subsys/win32k/stubs/stubs.c +++ b/reactos/subsys/win32k/stubs/stubs.c @@ -157,8 +157,8 @@ STUB(RtlRaiseException) //STUB(RtlUnicodeToMultiByteN) //STUB(RtlUnicodeToMultiByteSize) STUB(RtlUnwind) -STUB(RtlUpcaseUnicodeChar) -STUB(RtlUpcaseUnicodeToMultiByteN) +//STUB(RtlUpcaseUnicodeChar) +//STUB(RtlUpcaseUnicodeToMultiByteN) STUB(STROBJ_bEnum) STUB(STROBJ_dwGetCodePage) STUB(STROBJ_vEnumStart) diff --git a/reactos/subsys/win32k/win32k.def b/reactos/subsys/win32k/win32k.def index c022ce3f0fe..28776fe4d92 100644 --- a/reactos/subsys/win32k/win32k.def +++ b/reactos/subsys/win32k/win32k.def @@ -1,4 +1,4 @@ -; $Id: win32k.def,v 1.6 1999/11/15 16:02:00 ekohl Exp $ +; $Id: win32k.def,v 1.7 1999/11/20 21:47:58 ekohl Exp $ ; ; win32k.def ; @@ -154,22 +154,22 @@ PATHOBJ_bPolyLineTo PATHOBJ_vEnumStart PATHOBJ_vEnumStartClipLines PATHOBJ_vGetBounds -; RtlAnsiCharToUnicodeChar = NTOSKRNL.RtlAnsiCharToUnicodeChar -;RtlAnsiCharToUnicodeChar +;RtlAnsiCharToUnicodeChar = NTOSKRNL.RtlAnsiCharToUnicodeChar +;RtlAnsiCharToUnicodeChar@4 ; RtlMultiByteToUnicodeN = NTOSKRNL.RtlMultiByteToUnicodeN -;RtlMultiByteToUnicodeN +;RtlMultiByteToUnicodeN@20 ; RtlRaiseException = NTOSKRNL.RtlRaiseException -RtlRaiseException +;RtlRaiseException ; RtlUnicodeToMultiByteN = NTOSKRNL.RtlUnicodeToMultiByteN -;RtlUnicodeToMultiByteN +;RtlUnicodeToMultiByteN@20 ; RtlUnicodeToMultiByteSize = NTOSKRNL.RtlUnicodeToMultiByteSize -;RtlUnicodeToMultiByteSize +;RtlUnicodeToMultiByteSize@12 ; RtlUnwind = NTOSKRNL.RtlUnwind RtlUnwind ; RtlUpcaseUnicodeChar = NTOSKRNL.RtlUpcaseUnicodeChar -RtlUpcaseUnicodeChar +;RtlUpcaseUnicodeChar@4 ; RtlUpcaseUnicodeToMultiByteN = NTOSKRNL.RtlUpcaseUnicodeToMultiByteN -RtlUpcaseUnicodeToMultiByteN +;RtlUpcaseUnicodeToMultiByteN@20 STROBJ_bEnum STROBJ_dwGetCodePage STROBJ_vEnumStart