diff --git a/reactos/ntoskrnl/exports.lst b/reactos/ntoskrnl/exports.lst index 116bec9489b..d9a38803ff9 100644 --- a/reactos/ntoskrnl/exports.lst +++ b/reactos/ntoskrnl/exports.lst @@ -7,6 +7,9 @@ # # # +CbInitDccb +CbAcquireForRead +CbReleaseFromRead DbgPrint ExAcquireFastMutex ExAcquireFastMutexUnsafe @@ -373,15 +376,24 @@ ZwSetInformationThread ZwSetValueKey ZwUnmapViewOfSection ZwWriteFile +isdigit +islower +isprint +isspace +isupper +isxdigit +memchr +memcpy +memmove +memset sprintf +tolower +toupper +towlower +towupper +vsprintf wcslen wcschr wcscpy wcsncat wcsncpy -CbInitDccb -CbAcquireForRead -CbReleaseFromRead -wtolower -tolower -toupper diff --git a/reactos/ntoskrnl/makefile_rex b/reactos/ntoskrnl/makefile_rex index b187d7b375a..20344e069a3 100644 --- a/reactos/ntoskrnl/makefile_rex +++ b/reactos/ntoskrnl/makefile_rex @@ -12,7 +12,8 @@ NT_OBJECTS = nt/port.o nt/channel.o nt/ntevent.o nt/nttimer.o nt/atom.o \ RTL_OBJECTS = rtl/vsprintf.o rtl/lookas.o rtl/unicode.o rtl/strtok.o \ rtl/time.o rtl/unalign.o rtl/mem.o rtl/largeint.o rtl/ctype.o \ rtl/list.o rtl/slist.o rtl/interlck.o rtl/return.o \ - rtl/wstring.o rtl/memcpy.o + rtl/wstring.o rtl/memcpy.o rtl/memmove.o rtl/memset.o \ + rtl/memchr.o KE_OBJECTS = ke/main.o ke/timer.o ke/error.o ke/catch.o ke/exports.o \ ke/dpc.o ke/wait.o ke/kqueue.o ke/dispatch.o \ diff --git a/reactos/ntoskrnl/ntoskrnl.def b/reactos/ntoskrnl/ntoskrnl.def index 30ea263d899..7e065d679a1 100644 --- a/reactos/ntoskrnl/ntoskrnl.def +++ b/reactos/ntoskrnl/ntoskrnl.def @@ -1,13 +1,7 @@ EXPORTS -memcpy -strtok -toupper -wcschr -wcscpy -wcslen -wcsncpy -wcsncat -wtolower +CbInitDccb +CbAcquireForRead +CbReleaseFromRead DbgPrint ExAllocatePool ExFreePool @@ -62,6 +56,24 @@ RtlLargeIntegerGreaterThan RtlLargeIntegerShiftRight RtlZeroMemory ZwCreateDirectoryObject@12 -CbInitDccb -CbAcquireForRead -CbReleaseFromRead +isdigit +islower +isprint +isspace +isupper +isxdigit +memchr +memcpy +memmove +memset +strtok +tolower +toupper +towlower +towupper +vsprintf +wcschr +wcscpy +wcslen +wcsncpy +wcsncat diff --git a/reactos/ntoskrnl/rtl/ctype.c b/reactos/ntoskrnl/rtl/ctype.c index 60eded49792..3438b3b8460 100644 --- a/reactos/ntoskrnl/rtl/ctype.c +++ b/reactos/ntoskrnl/rtl/ctype.c @@ -35,32 +35,30 @@ _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */ _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ #endif -int toupper(int c) -{ - if ('a' <= c && 'z' >= c) - { - return(c + 'A' - 'a'); - } - return(c); -} -int tolower(int c) +int isdigit(int c) { - if ('A' <= c && 'Z' >= c) - { - return(c + 'a' - 'A'); - } - return(c); + return((c >= '0' && c <= '9')); } int islower(int c) { - return(('a' <= c && 'z' >= c)); + return((c >= 'a' && c <= 'z')); } -int isdigit(int c) +int isprint(int c) { - return(('0' <= c && '9' >= c)); + return((c >= ' ' && c <= '~')); +} + +int isspace(int c) +{ + return((c == ' ' || c == '\t')); +} + +int isupper(int c) +{ + return((c >= 'A') && (c <= 'Z')); } int isxdigit(int c) @@ -68,3 +66,23 @@ int isxdigit(int c) return(('0' <= c && '9' >= c) || ('a' <= 'c' && 'f' >= 'c') || ('A' <= c && 'Z' >= c)); } + +int tolower(int c) +{ + return (c >= 'A' && c <= 'Z') ? c - ( 'A' - 'a' ) : c; +} + +int toupper(int c) +{ + return (c >= 'a' && c <= 'z') ? c + 'A' - 'a' : c; +} + +wchar_t towlower(wchar_t c) +{ + return (c >= 'A' && c <= 'Z') ? c - ( 'A' - 'a' ) : c; +} + +wchar_t towupper(wchar_t c) +{ + return (c >= 'a' && c <= 'z') ? c + 'A' - 'a' : c; +} diff --git a/reactos/ntoskrnl/rtl/memchr.c b/reactos/ntoskrnl/rtl/memchr.c new file mode 100644 index 00000000000..7caf68f1152 --- /dev/null +++ b/reactos/ntoskrnl/rtl/memchr.c @@ -0,0 +1,17 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ + + +#include + +void *memchr(const void *s, int c, size_t n) +{ + if (n) + { + const char *p = s; + do { + if (*p++ == c) + return (void *)(p-1); + } while (--n != 0); + } + return 0; +} diff --git a/reactos/ntoskrnl/rtl/memmove.c b/reactos/ntoskrnl/rtl/memmove.c new file mode 100644 index 00000000000..11038c606fb --- /dev/null +++ b/reactos/ntoskrnl/rtl/memmove.c @@ -0,0 +1,18 @@ +#include + + +void * memmove(void *dest,const void *src,size_t count) +{ + char *char_dest = (char *)dest; + char *char_src = (char *)src; + + while(count > 0 ) + { + *char_dest = *char_src; + char_dest++; + char_src++; + count--; + } + + return dest; +} diff --git a/reactos/ntoskrnl/rtl/memset.c b/reactos/ntoskrnl/rtl/memset.c new file mode 100644 index 00000000000..e74722a2ee9 --- /dev/null +++ b/reactos/ntoskrnl/rtl/memset.c @@ -0,0 +1,14 @@ + +#include + +void * memset(void *src, int val, size_t count) +{ + char *char_src = src; + + while(count>0) { + *char_src = val; + char_src++; + count--; + } + return src; +} diff --git a/reactos/ntoskrnl/rtl/unicode.c b/reactos/ntoskrnl/rtl/unicode.c index f5e3d4f7fe9..e09944ea142 100644 --- a/reactos/ntoskrnl/rtl/unicode.c +++ b/reactos/ntoskrnl/rtl/unicode.c @@ -29,19 +29,6 @@ VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString) UNIMPLEMENTED; } -WCHAR wtoupper(WCHAR c) -{ - if((c>='a') && (c<='z')) return c+Aa_Difference; - return c; -} - -WCHAR wtolower(WCHAR c) -{ -// DPRINT("c %c (c-Aa_Difference) %c\n",(char)c,(char)(c-Aa_Difference)); - if((c>='A') && (c<='Z')) return c-Aa_Difference; - return c; -} - ULONG RtlAnsiStringToUnicodeSize(IN PANSI_STRING AnsiString) { return AnsiString->Length*2; @@ -165,8 +152,8 @@ LONG RtlCompareUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, for(i=0; iLength; i++) { if(CaseInsensitive==TRUE) { - wc1=wtoupper(*String1->Buffer); - wc2=wtoupper(*String2->Buffer); + wc1=towupper(*String1->Buffer); + wc2=towupper(*String2->Buffer); } else { wc1=*String1->Buffer; wc2=*String2->Buffer; @@ -283,8 +270,8 @@ BOOLEAN RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, for(i=0; iBuffer); - wc2=wtoupper(*String2->Buffer); + wc1=towupper(*String1->Buffer); + wc2=towupper(*String2->Buffer); } else { wc1=*String1->Buffer; wc2=*String2->Buffer; @@ -500,7 +487,7 @@ NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString, }; for(i=0; iLength; i++) { - *DestinationString->Buffer=wtoupper(*SourceString->Buffer); + *DestinationString->Buffer=towupper(*SourceString->Buffer); DestinationString->Buffer++; SourceString->Buffer++; }; diff --git a/reactos/ntoskrnl/rtl/wstring.c b/reactos/ntoskrnl/rtl/wstring.c index 7ec299138fc..cb734a5e727 100644 --- a/reactos/ntoskrnl/rtl/wstring.c +++ b/reactos/ntoskrnl/rtl/wstring.c @@ -63,18 +63,6 @@ wcschr(const wchar_t *str, wchar_t ch) return NULL; } -wchar_t towupper(wchar_t w) -{ - if (w < L'A') - { - return(w + 'A'); - } - else - { - return(w); - } -} - int wcsicmp(const wchar_t* cs, const wchar_t* ct) { while (*cs != '\0' && *ct != '\0' && towupper(*cs) == towupper(*ct))