mirror of
https://github.com/reactos/reactos.git
synced 2025-08-01 00:13:16 +00:00
Added more crt functions and fixed some.
svn path=/trunk/; revision=607
This commit is contained in:
parent
69dc48c09f
commit
e7cf9302fa
23 changed files with 1081 additions and 148 deletions
|
@ -66,7 +66,7 @@ GetEnvironmentVariableW(
|
|||
|
||||
while (i < nEnvVar)
|
||||
{
|
||||
if ( wcsnicmp(Environment[i].Name.Buffer,lpName,min(NameLen,Environment[i].Name.Length/sizeof(WCHAR))) != 0 ) {
|
||||
if ( _wcsnicmp(Environment[i].Name.Buffer,lpName,min(NameLen,Environment[i].Name.Length/sizeof(WCHAR))) != 0 ) {
|
||||
lstrcpynW(lpBuffer,Environment[i].Value.Buffer,min(nSize,Environment[i].Value.Length/sizeof(WCHAR)));
|
||||
|
||||
return lstrlenW(Environment[i].Value.Buffer);
|
||||
|
@ -130,7 +130,7 @@ SetEnvironmentVariableW(
|
|||
|
||||
while (i < nEnvVar)
|
||||
{
|
||||
if ( wcsnicmp(Environment[i].Name.Buffer,lpName,min(NameLen,Environment[i].Name.Length/sizeof(WCHAR))) != 0 ) {
|
||||
if ( _wcsnicmp(Environment[i].Name.Buffer,lpName,min(NameLen,Environment[i].Name.Length/sizeof(WCHAR))) != 0 ) {
|
||||
if ( lpValue != NULL ) {
|
||||
lstrcpynW(Environment[i].Value.Buffer,lpValue,min(ValueLen,Environment[i].Value.MaximumLength/sizeof(WCHAR)));
|
||||
return TRUE;
|
||||
|
|
|
@ -89,8 +89,7 @@ lstrcmpiW(
|
|||
LPCWSTR lpString2
|
||||
)
|
||||
{
|
||||
return wcsicmp(lpString1,lpString2);
|
||||
|
||||
return _wcsicmp(lpString1,lpString2);
|
||||
}
|
||||
|
||||
LPWSTR
|
||||
|
@ -135,8 +134,3 @@ lstrlenW(
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -421,34 +421,59 @@ ZwWriteVirtualMemory@20
|
|||
ZwW32Call@20
|
||||
ZwYieldExecution@0
|
||||
RtlAllocateHeap@12
|
||||
RtlAnsiStringToUnicodeSize
|
||||
RtlAnsiStringToUnicodeString
|
||||
RtlAppendUnicodeStringToString
|
||||
RtlAppendUnicodeToString
|
||||
RtlCharToInteger
|
||||
RtlCreateHeap@24
|
||||
RtlCompactHeap@8
|
||||
RtlCompareString
|
||||
RtlCompareUnicodeString
|
||||
RtlCopyString
|
||||
RtlCopyUnicodeString
|
||||
RtlDestroyHeap@4
|
||||
RtlFreeHeap@12
|
||||
RtlGetProcessHeap@0
|
||||
RtlLockHeap@4
|
||||
RtlReAllocHeap@16
|
||||
RtlSizeHeap@12
|
||||
RtlUnlockHeap@4
|
||||
RtlValidateHeap@12
|
||||
RtlAnsiStringToUnicodeString
|
||||
RtlEnlargedIntegerMultiply
|
||||
RtlEnlargedUnsignedMultiply
|
||||
RtlEqualString
|
||||
RtlEqualUnicodeString
|
||||
RtlExtendedIntegerMultiply
|
||||
RtlFreeAnsiString
|
||||
RtlFreeHeap@12
|
||||
RtlFreeUnicodeString
|
||||
RtlGetProcessHeap@0
|
||||
RtlInitAnsiString
|
||||
RtlInitString
|
||||
RtlInitUnicodeString
|
||||
RtlIntegerToUnicodeString
|
||||
RtlLargeIntegerAdd
|
||||
RtlLargeIntegerDivide
|
||||
RtlLengthSecurityDescriptor
|
||||
RtlLockHeap@4
|
||||
RtlNtStatusToDosError
|
||||
RtlReAllocHeap@16
|
||||
RtlSizeHeap@12
|
||||
RtlUnlockHeap@4
|
||||
RtlUnicodeStringToAnsiSize
|
||||
RtlUnicodeStringToAnsiString
|
||||
RtlUnicodeStringToInteger
|
||||
RtlUpcaseString
|
||||
RtlUpcaseUnicodeString
|
||||
RtlValidateHeap@12
|
||||
_memccpy
|
||||
_memicmp
|
||||
_splitpath
|
||||
_strcmpi
|
||||
_stricmp
|
||||
_strlwr
|
||||
_strnicmp
|
||||
_strupr
|
||||
_tolower
|
||||
_toupper
|
||||
_wcsicmp
|
||||
_wcslwr
|
||||
_wcsnicmp
|
||||
_wcsupr
|
||||
atoi
|
||||
atol
|
||||
isalpha
|
||||
|
@ -456,11 +481,14 @@ isalnum
|
|||
iscntrl
|
||||
isdigit
|
||||
isgraph
|
||||
islower
|
||||
isprint
|
||||
ispunct
|
||||
isspace
|
||||
isupper
|
||||
iswlower
|
||||
isxdigit
|
||||
memchr
|
||||
memcmp
|
||||
memcpy
|
||||
memmove
|
||||
memset
|
||||
|
@ -470,25 +498,32 @@ strchr
|
|||
strcmp
|
||||
strcpy
|
||||
strcspn
|
||||
strlen
|
||||
strncat
|
||||
strncmp
|
||||
strncpy
|
||||
strlen
|
||||
strpbrk
|
||||
strrchr
|
||||
strspn
|
||||
strstr
|
||||
strtol
|
||||
strtoul
|
||||
tolower
|
||||
toupper
|
||||
towlower
|
||||
towupper
|
||||
vsprintf
|
||||
wcscat
|
||||
wcschr
|
||||
wcscmp
|
||||
wcscpy
|
||||
wcsncpy
|
||||
wcscspn
|
||||
wcslen
|
||||
wcsncat
|
||||
wcsncmp
|
||||
wcsncpy
|
||||
wcspbrk
|
||||
wcsrchr
|
||||
wcsicmp
|
||||
wcsnicmp
|
||||
vsprintf
|
||||
wcsspn
|
||||
wcsstr
|
||||
LdrMapNTDllForProcess
|
||||
|
|
|
@ -421,34 +421,59 @@ ZwWriteVirtualMemory=ZwWriteVirtualMemory@20
|
|||
ZwW32Call=ZwW32Call@20
|
||||
ZwYieldExecution=ZwYieldExecution@0
|
||||
RtlAllocateHeap=RtlAllocateHeap@12
|
||||
RtlAnsiStringToUnicodeSize
|
||||
RtlAnsiStringToUnicodeString
|
||||
RtlAppendUnicodeStringToString
|
||||
RtlAppendUnicodeToString
|
||||
RtlCharToInteger
|
||||
RtlCreateHeap=RtlCreateHeap@24
|
||||
RtlCompactHeap=RtlCompactHeap@8
|
||||
RtlCompareString
|
||||
RtlCompareUnicodeString
|
||||
RtlCopyString
|
||||
RtlCopyUnicodeString
|
||||
RtlDestroyHeap=RtlDestroyHeap@4
|
||||
RtlFreeHeap=RtlFreeHeap@12
|
||||
RtlGetProcessHeap=RtlGetProcessHeap@0
|
||||
RtlLockHeap=RtlLockHeap@4
|
||||
RtlReAllocHeap=RtlReAllocHeap@16
|
||||
RtlSizeHeap=RtlSizeHeap@12
|
||||
RtlUnlockHeap=RtlUnlockHeap@4
|
||||
RtlValidateHeap=RtlValidateHeap@12
|
||||
RtlAnsiStringToUnicodeString
|
||||
RtlEnlargedIntegerMultiply
|
||||
RtlEnlargedUnsignedMultiply
|
||||
RtlEqualString
|
||||
RtlEqualUnicodeString
|
||||
RtlExtendedIntegerMultiply
|
||||
RtlFreeAnsiString
|
||||
RtlFreeHeap=RtlFreeHeap@12
|
||||
RtlFreeUnicodeString
|
||||
RtlGetProcessHeap=RtlGetProcessHeap@0
|
||||
RtlInitAnsiString
|
||||
RtlInitString
|
||||
RtlInitUnicodeString
|
||||
RtlIntegerToUnicodeString
|
||||
RtlLargeIntegerAdd
|
||||
RtlLargeIntegerDivide
|
||||
RtlLengthSecurityDescriptor
|
||||
RtlLockHeap=RtlLockHeap@4
|
||||
RtlNtStatusToDosError
|
||||
RtlReAllocHeap=RtlReAllocHeap@16
|
||||
RtlSizeHeap=RtlSizeHeap@12
|
||||
RtlUnlockHeap=RtlUnlockHeap@4
|
||||
RtlUnicodeStringToAnsiSize
|
||||
RtlUnicodeStringToAnsiString
|
||||
RtlUnicodeStringToInteger
|
||||
RtlUpcaseString
|
||||
RtlUpcaseUnicodeString
|
||||
RtlValidateHeap=RtlValidateHeap@12
|
||||
_memccpy
|
||||
_memicmp
|
||||
_splitpath
|
||||
_strcmpi
|
||||
_stricmp
|
||||
_strlwr
|
||||
_strnicmp
|
||||
_strupr
|
||||
_tolower
|
||||
_toupper
|
||||
_wcsicmp
|
||||
_wcslwr
|
||||
_wcsnicmp
|
||||
_wcsupr
|
||||
atoi
|
||||
atol
|
||||
isalpha
|
||||
|
@ -456,11 +481,14 @@ isalnum
|
|||
iscntrl
|
||||
isdigit
|
||||
isgraph
|
||||
islower
|
||||
isprint
|
||||
ispunct
|
||||
isspace
|
||||
isupper
|
||||
iswlower
|
||||
isxdigit
|
||||
memchr
|
||||
memcmp
|
||||
memcpy
|
||||
memmove
|
||||
memset
|
||||
|
@ -470,25 +498,32 @@ strchr
|
|||
strcmp
|
||||
strcpy
|
||||
strcspn
|
||||
strlen
|
||||
strncat
|
||||
strncmp
|
||||
strncpy
|
||||
strlen
|
||||
strpbrk
|
||||
strrchr
|
||||
strspn
|
||||
strstr
|
||||
strtol
|
||||
strtoul
|
||||
tolower
|
||||
toupper
|
||||
towlower
|
||||
towupper
|
||||
vsprintf
|
||||
wcscat
|
||||
wcschr
|
||||
wcscmp
|
||||
wcscpy
|
||||
wcsncpy
|
||||
wcscspn
|
||||
wcslen
|
||||
wcsncat
|
||||
wcsncmp
|
||||
wcsncpy
|
||||
wcspbrk
|
||||
wcsrchr
|
||||
wcsicmp
|
||||
wcsnicmp
|
||||
vsprintf
|
||||
wcsspn
|
||||
wcsstr
|
||||
LdrMapNTDllForProcess
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: makefile,v 1.20 1999/07/22 21:31:39 ekohl Exp $
|
||||
# $Id: makefile,v 1.21 1999/07/29 21:14:02 ekohl Exp $
|
||||
#
|
||||
# ReactOS Operating System
|
||||
#
|
||||
|
@ -27,12 +27,14 @@ RTL_OBJECTS = rtl/critical.o rtl/error.o rtl/heap.o rtl/largeint.o \
|
|||
STDLIB_OBJECTS = stdlib/atoi.o stdlib/atol.o stdlib/splitp.o \
|
||||
stdlib/strtol.o stdlib/strtoul.o
|
||||
|
||||
STRING_OBJECTS = string/ctype.o string/memcpy.o string/memmove.o \
|
||||
string/memset.o string/strcat.o string/strchr.o \
|
||||
string/strcmp.o string/strcspn.o \
|
||||
string/strcpy.o string/stricmp.o string/strlen.o string/strlwr.o \
|
||||
string/strncat.o string/strncmp.o string/strncpy.o \
|
||||
string/strnicmp.o string/strnlen.o string/strrchr.o \
|
||||
STRING_OBJECTS = string/ctype.o string/memccpy.o string/memchr.o \
|
||||
string/memcmp.o string/memcpy.o string/memicmp.o\
|
||||
string/memmove.o string/memset.o string/strcat.o \
|
||||
string/strchr.o string/strcmp.o string/strcspn.o \
|
||||
string/strcpy.o string/stricmp.o string/strlen.o \
|
||||
string/strlwr.o string/strncat.o string/strncmp.o \
|
||||
string/strncpy.o string/strnicmp.o string/strnlen.o \
|
||||
string/strpbrk.o string/strrchr.o string/strspn.o \
|
||||
string/strstr.o string/strupr.o string/wstring.o
|
||||
|
||||
OBJECTS = napi.o ldr/startup.o $(RTL_OBJECTS) \
|
||||
|
|
|
@ -404,6 +404,13 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ULONG RtlUnicodeStringToAnsiSize(IN PUNICODE_STRING UnicodeString)
|
||||
{
|
||||
return UnicodeString->Length/2;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
|
||||
IN PUNICODE_STRING SourceString,
|
||||
IN BOOLEAN AllocateDestinationString)
|
||||
|
@ -430,7 +437,8 @@ NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
|
|||
SourceString->Buffer-=SourceString->Length;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
|
||||
OUT PULONG Value)
|
||||
|
|
|
@ -383,19 +383,12 @@ int wsprintfW(unsigned short * buf, const unsigned short *fmt, ...)
|
|||
}
|
||||
#endif
|
||||
|
||||
unsigned short towupper(unsigned short w)
|
||||
{
|
||||
if ( w < L'A' )
|
||||
return w + 'A';
|
||||
else
|
||||
return w;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int iswlower(wint_t w)
|
||||
{
|
||||
if ( w < L'A' )
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,73 +1,101 @@
|
|||
|
||||
#include <ctype.h>
|
||||
|
||||
#define upalpha ('A' - 'a')
|
||||
|
||||
int isalpha(char c)
|
||||
int isalpha(int c)
|
||||
{
|
||||
return(((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')));
|
||||
}
|
||||
|
||||
int isalnum(char c)
|
||||
int isalnum(int c)
|
||||
{
|
||||
return(isalpha(c)||isdigit(c));
|
||||
}
|
||||
|
||||
int iscntrl(char c)
|
||||
int iscntrl(int c)
|
||||
{
|
||||
return((c >=0x00 && c <= 0x1f) || c == 0x7f);
|
||||
}
|
||||
|
||||
int isdigit(char c)
|
||||
int isdigit(int c)
|
||||
{
|
||||
return((c>='0') && (c<='9'));
|
||||
}
|
||||
|
||||
int isgraph(char c)
|
||||
int isgraph(int c)
|
||||
{
|
||||
return(c>=0x21 && c<=0x7e);
|
||||
}
|
||||
|
||||
int islower(char c)
|
||||
int islower(int c)
|
||||
{
|
||||
return((c>='a') && (c<='z'));
|
||||
}
|
||||
|
||||
int isprint(char c)
|
||||
int isprint(int c)
|
||||
{
|
||||
return(c>=0x20 && c<=0x7e);
|
||||
}
|
||||
|
||||
int ispunct(char c)
|
||||
int ispunct(int c)
|
||||
{
|
||||
return((c>=0x21 && c<=0x2f)||(c>=0x3a && c<=0x40)||(c>=0x5b && c<=0x60));
|
||||
}
|
||||
|
||||
int isspace(char c)
|
||||
int isspace(int c)
|
||||
{
|
||||
return(c==' '||c=='\t');
|
||||
}
|
||||
|
||||
int isupper(char c)
|
||||
int isupper(int c)
|
||||
{
|
||||
return((c>='A') && (c<='Z'));
|
||||
}
|
||||
|
||||
int isxdigit(char c)
|
||||
int isxdigit(int c)
|
||||
{
|
||||
return(((c>='0') && (c<='9')) || ((toupper(c)>='A') && (toupper(c)<='Z')));
|
||||
}
|
||||
|
||||
|
||||
char tolower(char c)
|
||||
int _tolower(int c)
|
||||
{
|
||||
if (c>='A' && c <= 'Z')
|
||||
return (c - upalpha);
|
||||
return(c);
|
||||
}
|
||||
|
||||
char toupper(char c)
|
||||
int _toupper(int c)
|
||||
{
|
||||
if ((c>='a') && (c<='z'))
|
||||
return (c+upalpha);
|
||||
return(c);
|
||||
}
|
||||
|
||||
int tolower(int c)
|
||||
{
|
||||
if (c>='A' && c <= 'Z')
|
||||
return (c - upalpha);
|
||||
return(c);
|
||||
}
|
||||
|
||||
int toupper(int c)
|
||||
{
|
||||
if ((c>='a') && (c<='z'))
|
||||
return (c+upalpha);
|
||||
return(c);
|
||||
}
|
||||
|
||||
wchar_t towlower(wchar_t c)
|
||||
{
|
||||
if (c>='A' && c <= 'Z')
|
||||
return (c - upalpha);
|
||||
return(c);
|
||||
}
|
||||
|
||||
wchar_t towupper(wchar_t c)
|
||||
{
|
||||
if ((c>='a') && (c<='z'))
|
||||
return (c+upalpha);
|
||||
return(c);
|
||||
}
|
||||
|
|
9
reactos/lib/ntdll/string/memccpy.c
Normal file
9
reactos/lib/ntdll/string/memccpy.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include <string.h>
|
||||
|
||||
|
||||
void *
|
||||
_memccpy (void *to, const void *from,int c,size_t count)
|
||||
{
|
||||
memcpy(to,from,count);
|
||||
return memchr(to,c,count);
|
||||
}
|
18
reactos/lib/ntdll/string/memchr.c
Normal file
18
reactos/lib/ntdll/string/memchr.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
|
||||
|
||||
#include <crtdll/string.h>
|
||||
|
||||
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;
|
||||
}
|
17
reactos/lib/ntdll/string/memcmp.c
Normal file
17
reactos/lib/ntdll/string/memcmp.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
memcmp(const void *s1, const void *s2, size_t n)
|
||||
{
|
||||
if (n != 0)
|
||||
{
|
||||
const unsigned char *p1 = s1, *p2 = s2;
|
||||
|
||||
do {
|
||||
if (*p1++ != *p2++)
|
||||
return (*--p1 - *--p2);
|
||||
} while (--n != 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
20
reactos/lib/ntdll/string/memicmp.c
Normal file
20
reactos/lib/ntdll/string/memicmp.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int
|
||||
_memicmp(const void *s1, const void *s2, size_t n)
|
||||
{
|
||||
if (n != 0)
|
||||
{
|
||||
const unsigned char *p1 = s1, *p2 = s2;
|
||||
|
||||
do {
|
||||
if (toupper(*p1) != toupper(*p2))
|
||||
return (*p1 - *p2);
|
||||
p1++;
|
||||
p2++;
|
||||
} while (--n != 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
18
reactos/lib/ntdll/string/strpbrk.c
Normal file
18
reactos/lib/ntdll/string/strpbrk.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <string.h>
|
||||
|
||||
|
||||
char *
|
||||
strpbrk(const char *s1, const char *s2)
|
||||
{
|
||||
const char *scanp;
|
||||
int c, sc;
|
||||
|
||||
while ((c = *s1++) != 0)
|
||||
{
|
||||
for (scanp = s2; (sc = *scanp++) != 0;)
|
||||
if (sc == c)
|
||||
return (char *)(s1 - 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
16
reactos/lib/ntdll/string/strspn.c
Normal file
16
reactos/lib/ntdll/string/strspn.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <string.h>
|
||||
|
||||
size_t
|
||||
strspn(const char *s1, const char *s2)
|
||||
{
|
||||
const char *p = s1, *spanp;
|
||||
char c, sc;
|
||||
|
||||
cont:
|
||||
c = *p++;
|
||||
for (spanp = s2; (sc = *spanp++) != 0;)
|
||||
if (sc == c)
|
||||
goto cont;
|
||||
return (p - 1 - s1);
|
||||
}
|
|
@ -20,14 +20,56 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
int wcsnicmp(const wchar_t* ws1, const wchar_t* ws2, size_t size)
|
||||
int _wcsicmp(const wchar_t* cs,const wchar_t * ct)
|
||||
{
|
||||
while (towlower(*cs) == towlower(*ct))
|
||||
{
|
||||
if (*cs == 0)
|
||||
return 0;
|
||||
cs++;
|
||||
ct++;
|
||||
}
|
||||
return towlower(*cs) - towlower(*ct);
|
||||
}
|
||||
|
||||
int wcsicmp(const wchar_t* ws1, const wchar_t* ws2)
|
||||
|
||||
wchar_t* _wcslwr(wchar_t *x)
|
||||
{
|
||||
wchar_t *y=x;
|
||||
|
||||
while (*y) {
|
||||
*y=towlower(*y);
|
||||
y++;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
int _wcsnicmp(const wchar_t * cs,const wchar_t * ct,size_t count)
|
||||
{
|
||||
wchar_t *save = (wchar_t *)cs;
|
||||
while (towlower(*cs) == towlower(*ct) && (int)(cs - save) < count)
|
||||
{
|
||||
if (*cs == 0)
|
||||
return 0;
|
||||
cs++;
|
||||
ct++;
|
||||
}
|
||||
return towlower(*cs) - towlower(*ct);
|
||||
}
|
||||
|
||||
|
||||
wchar_t *_wcsupr(wchar_t *x)
|
||||
{
|
||||
wchar_t *y=x;
|
||||
|
||||
while (*y) {
|
||||
*y=towupper(*y);
|
||||
y++;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
wchar_t* wcscat(wchar_t *dest, const wchar_t *src)
|
||||
{
|
||||
int i, j;
|
||||
|
@ -81,6 +123,26 @@ wchar_t* wcscpy(wchar_t* str1, const wchar_t* str2)
|
|||
}
|
||||
|
||||
|
||||
size_t wcscspn(const wchar_t *str,const wchar_t *reject)
|
||||
{
|
||||
wchar_t *s;
|
||||
wchar_t *t;
|
||||
s=(wchar_t *)str;
|
||||
do {
|
||||
t=(wchar_t *)reject;
|
||||
while (*t) {
|
||||
if (*t==*s)
|
||||
break;
|
||||
t++;
|
||||
}
|
||||
if (*t)
|
||||
break;
|
||||
s++;
|
||||
} while (*s);
|
||||
return s-str; /* nr of wchars */
|
||||
}
|
||||
|
||||
|
||||
size_t wcslen(const wchar_t *s)
|
||||
{
|
||||
unsigned int len = 0;
|
||||
|
@ -114,6 +176,19 @@ wcsncat(wchar_t *dest, const wchar_t *src, size_t count)
|
|||
}
|
||||
|
||||
|
||||
int wcsncmp(const wchar_t * cs,const wchar_t * ct,size_t count)
|
||||
{
|
||||
while ((*cs) == (*ct) && count > 0)
|
||||
{
|
||||
if (*cs == 0)
|
||||
return 0;
|
||||
cs++;
|
||||
ct++;
|
||||
count--;
|
||||
}
|
||||
return (*cs) - (*ct);
|
||||
}
|
||||
|
||||
|
||||
wchar_t* wcsncpy(wchar_t *dest, const wchar_t *src, size_t count)
|
||||
{
|
||||
|
@ -133,8 +208,24 @@ wchar_t* wcsncpy(wchar_t *dest, const wchar_t *src, size_t count)
|
|||
}
|
||||
|
||||
|
||||
wchar_t *
|
||||
wcsrchr(const wchar_t *str, wchar_t ch)
|
||||
wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2)
|
||||
{
|
||||
const wchar_t *scanp;
|
||||
int c, sc;
|
||||
|
||||
while ((c = *s1++) != 0)
|
||||
{
|
||||
for (scanp = s2; (sc = *scanp++) != 0;)
|
||||
if (sc == c)
|
||||
{
|
||||
return (wchar_t *)(--s1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
wchar_t * wcsrchr(const wchar_t *str, wchar_t ch)
|
||||
{
|
||||
unsigned int len = 0;
|
||||
while (str[len] != ((wchar_t)0))
|
||||
|
@ -154,4 +245,44 @@ wcsrchr(const wchar_t *str, wchar_t ch)
|
|||
}
|
||||
|
||||
|
||||
size_t wcsspn(const wchar_t *str,const wchar_t *accept)
|
||||
{
|
||||
wchar_t *s;
|
||||
wchar_t *t;
|
||||
s=(wchar_t *)str;
|
||||
do {
|
||||
t=(wchar_t *)accept;
|
||||
while (*t) {
|
||||
if (*t==*s)
|
||||
break;
|
||||
t++;
|
||||
}
|
||||
if (!*t)
|
||||
break;
|
||||
s++;
|
||||
} while (*s);
|
||||
return s-str; /* nr of wchars */
|
||||
}
|
||||
|
||||
|
||||
wchar_t *wcsstr(const wchar_t *s,const wchar_t *b)
|
||||
{
|
||||
wchar_t *x;
|
||||
wchar_t *y;
|
||||
wchar_t *c;
|
||||
x=(wchar_t *)s;
|
||||
while (*x) {
|
||||
if (*x==*b) {
|
||||
y=x;
|
||||
c=(wchar_t *)b;
|
||||
while (*y && *c && *y==*c) {
|
||||
c++;
|
||||
y++;
|
||||
}
|
||||
if (!*c)
|
||||
return x;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -213,20 +213,11 @@ STUB(_itoa)
|
|||
STUB(_itow)
|
||||
STUB(_ltoa)
|
||||
STUB(_ltow)
|
||||
STUB(_memccpy)
|
||||
STUB(_memicmp)
|
||||
STUB(_snprintf)
|
||||
STUB(_snwprintf)
|
||||
//STUB(_strlwr)
|
||||
STUB(_tolower)
|
||||
STUB(_toupper)
|
||||
STUB(_ultoa)
|
||||
STUB(_ultow)
|
||||
STUB(_vsnprintf)
|
||||
STUB(_wcsicmp)
|
||||
STUB(_wcslwr)
|
||||
STUB(_wcsnicmp)
|
||||
STUB(_wcsupr)
|
||||
STUB(_wtoi)
|
||||
STUB(_wtoi64)
|
||||
STUB(_wtol)
|
||||
|
@ -241,15 +232,11 @@ STUB(iswctype)
|
|||
STUB(labs)
|
||||
STUB(log)
|
||||
STUB(mbstowcs)
|
||||
STUB(memchr)
|
||||
STUB(memcmp)
|
||||
STUB(pow)
|
||||
STUB(qsort)
|
||||
STUB(sin)
|
||||
STUB(sqrt)
|
||||
STUB(sscanf)
|
||||
STUB(strpbrk)
|
||||
STUB(strspn)
|
||||
STUB(swprintf)
|
||||
STUB(tan)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: makefile_rex,v 1.28 1999/07/17 23:10:25 ea Exp $
|
||||
# $Id: makefile_rex,v 1.29 1999/07/29 21:25:04 ekohl Exp $
|
||||
#
|
||||
# ReactOS Operating System
|
||||
#
|
||||
|
@ -15,11 +15,11 @@ NT_OBJECTS = nt/port.o nt/channel.o nt/ntevent.o nt/nttimer.o nt/atom.o \
|
|||
nt/evtpair.o nt/ntsem.o nt/mutant.o nt/misc.o nt/plugplay.o \
|
||||
nt/profile.o nt/nt.o nt/zw.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_OBJECTS = rtl/vsprintf.o rtl/lookas.o rtl/unicode.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/memmove.o rtl/memset.o \
|
||||
rtl/memchr.o
|
||||
rtl/memchr.o rtl/string.o rtl/stdlib.o
|
||||
|
||||
KE_OBJECTS = ke/main.o ke/timer.o ke/error.o ke/catch.o \
|
||||
ke/dpc.o ke/wait.o ke/kqueue.o ke/dispatch.o \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.def,v 1.13 1999/07/17 23:10:26 ea Exp $
|
||||
; $Id: ntoskrnl.def,v 1.14 1999/07/29 21:25:04 ekohl Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -87,6 +87,7 @@ KeInitializeEvent
|
|||
KeInitializeSpinLock
|
||||
KeInsertQueueDpc
|
||||
KeLowerIrql
|
||||
KeQuerySystemTime
|
||||
KeStallExecutionProcessor
|
||||
KeSynchronizeExecution
|
||||
KeRaiseIrql
|
||||
|
@ -265,24 +266,83 @@ ZwWaitForMultipleObjects@20
|
|||
ZwWaitForSingleObject@12
|
||||
ZwWriteFile@36
|
||||
ZwYieldExecution@0
|
||||
;_abnormal_termination
|
||||
;_alldiv
|
||||
;_allmul
|
||||
;_allrem
|
||||
;_allshl
|
||||
;_allshr
|
||||
;_aulldiv
|
||||
;_aullrem
|
||||
;_aullshr
|
||||
;_except_handler2
|
||||
;_global_unwind2
|
||||
;_itoa
|
||||
;_local_unwind2
|
||||
;_purecall
|
||||
;_snprintf
|
||||
;_snwprintf
|
||||
_stricmp
|
||||
_strlwr
|
||||
_strnicmp
|
||||
_strnset
|
||||
_strrev
|
||||
_strset
|
||||
_strupr
|
||||
;_vsnprintf
|
||||
_wcsicmp
|
||||
_wcslwr
|
||||
_wcsnicmp
|
||||
_wcsnset
|
||||
_wcsrev
|
||||
_wcsupr
|
||||
;atoi
|
||||
;atol
|
||||
isdigit
|
||||
islower
|
||||
isprint
|
||||
isspace
|
||||
isupper
|
||||
isxdigit
|
||||
;mbstowcs
|
||||
;mbtowc
|
||||
memchr
|
||||
memcpy
|
||||
memmove
|
||||
memset
|
||||
strtok
|
||||
;qsort
|
||||
rand
|
||||
sprintf
|
||||
srand
|
||||
strcat
|
||||
strchr
|
||||
strcmp
|
||||
strcpy
|
||||
strlen
|
||||
strncat
|
||||
strncmp
|
||||
strcpy
|
||||
strrchr
|
||||
strspn
|
||||
strstr
|
||||
;strtok
|
||||
;swprintf
|
||||
tolower
|
||||
toupper
|
||||
towlower
|
||||
towupper
|
||||
vsprintf
|
||||
wcscat
|
||||
wcschr
|
||||
wcscmp
|
||||
wcscpy
|
||||
wcscspn
|
||||
wcslen
|
||||
wcsncpy
|
||||
wcsncat
|
||||
wcsncmp
|
||||
wcsncpy
|
||||
wcsrchr
|
||||
wcsspn
|
||||
wcsstr
|
||||
;wcstombs
|
||||
;wctomb
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.edf,v 1.1 1999/07/17 23:10:26 ea Exp $
|
||||
; $Id: ntoskrnl.edf,v 1.2 1999/07/29 21:25:04 ekohl Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -87,6 +87,7 @@ KeInitializeEvent
|
|||
KeInitializeSpinLock
|
||||
KeInsertQueueDpc
|
||||
KeLowerIrql
|
||||
KeQuerySystemTime
|
||||
KeStallExecutionProcessor
|
||||
KeSynchronizeExecution
|
||||
KeRaiseIrql
|
||||
|
@ -265,24 +266,83 @@ ZwWaitForMultipleObjects=ZwWaitForMultipleObjects@20
|
|||
ZwWaitForSingleObject=ZwWaitForSingleObject@12
|
||||
ZwWriteFile=ZwWriteFile@36
|
||||
ZwYieldExecution=ZwYieldExecution@0
|
||||
;_abnormal_termination
|
||||
;_alldiv
|
||||
;_allmul
|
||||
;_allrem
|
||||
;_allshl
|
||||
;_allshr
|
||||
;_aulldiv
|
||||
;_aullrem
|
||||
;_aullshr
|
||||
;_except_handler2
|
||||
;_global_unwind2
|
||||
;_itoa
|
||||
;_local_unwind2
|
||||
;_purecall
|
||||
;_snprintf
|
||||
;_snwprintf
|
||||
_stricmp
|
||||
_strlwr
|
||||
_strnicmp
|
||||
_strnset
|
||||
_strrev
|
||||
_strset
|
||||
_strupr
|
||||
;_vsnprintf
|
||||
_wcsicmp
|
||||
_wcslwr
|
||||
_wcsnicmp
|
||||
_wcsnset
|
||||
_wcsrev
|
||||
_wcsupr
|
||||
;atoi
|
||||
;atol
|
||||
isdigit
|
||||
islower
|
||||
isprint
|
||||
isspace
|
||||
isupper
|
||||
isxdigit
|
||||
;mbstowcs
|
||||
;mbtowc
|
||||
memchr
|
||||
memcpy
|
||||
memmove
|
||||
memset
|
||||
strtok
|
||||
;qsort
|
||||
rand
|
||||
sprintf
|
||||
srand
|
||||
strcat
|
||||
strchr
|
||||
strcmp
|
||||
strcpy
|
||||
strlen
|
||||
strncat
|
||||
strncmp
|
||||
strcpy
|
||||
strrchr
|
||||
strspn
|
||||
strstr
|
||||
;strtok
|
||||
;swprintf
|
||||
tolower
|
||||
toupper
|
||||
towlower
|
||||
towupper
|
||||
vsprintf
|
||||
wcscat
|
||||
wcschr
|
||||
wcscmp
|
||||
wcscpy
|
||||
wcscspn
|
||||
wcslen
|
||||
wcsncpy
|
||||
wcsncat
|
||||
wcsncmp
|
||||
wcsncpy
|
||||
wcsrchr
|
||||
wcsspn
|
||||
wcsstr
|
||||
;wcstombs
|
||||
;wctomb
|
||||
|
|
|
@ -72,10 +72,10 @@ VOID ObAddEntryDirectory(PDIRECTORY_OBJECT Parent,
|
|||
{
|
||||
KIRQL oldlvl;
|
||||
POBJECT_HEADER Header = BODY_TO_HEADER(Object);
|
||||
|
||||
|
||||
RtlInitUnicodeString(&Header->Name, wcsdup(Name));
|
||||
Header->Parent = Parent;
|
||||
|
||||
|
||||
KeAcquireSpinLock(&Parent->Lock, &oldlvl);
|
||||
InsertTailList(&Parent->head, &Header->Entry);
|
||||
KeReleaseSpinLock(&Parent->Lock, oldlvl);
|
||||
|
@ -108,7 +108,7 @@ PVOID ObpFindEntryDirectory(PDIRECTORY_OBJECT DirectoryObject,
|
|||
DPRINT("Scanning %w %w\n",current_obj->Name.Buffer, Name);
|
||||
if (Attributes & OBJ_CASE_INSENSITIVE)
|
||||
{
|
||||
if (wcsicmp(current_obj->Name.Buffer, Name)==0)
|
||||
if (_wcsicmp(current_obj->Name.Buffer, Name)==0)
|
||||
{
|
||||
DPRINT("Found it %x\n",HEADER_TO_BODY(current_obj));
|
||||
return(HEADER_TO_BODY(current_obj));
|
||||
|
|
86
reactos/ntoskrnl/rtl/stdlib.c
Normal file
86
reactos/ntoskrnl/rtl/stdlib.c
Normal file
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/rtl/stdlib.c
|
||||
* PURPOSE: Standard library functions
|
||||
* PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
||||
* UPDATE HISTORY:
|
||||
* 1999/07/29 ekohl Created
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* GLOBALS ****************************************************************/
|
||||
|
||||
static unsigned long long next = 0;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
#if 0
|
||||
int atoi(const char *str)
|
||||
{
|
||||
return (int)strtol(str, 0, 10);
|
||||
}
|
||||
|
||||
long atol(const char *str)
|
||||
{
|
||||
return strtol(str, 0, 10);
|
||||
}
|
||||
|
||||
char *_itoa(int value, char *string, int radix)
|
||||
{
|
||||
char tmp[33];
|
||||
char *tp = tmp;
|
||||
int i;
|
||||
unsigned v;
|
||||
int sign;
|
||||
char *sp;
|
||||
|
||||
if (string == 0)
|
||||
return NULL;
|
||||
|
||||
if (radix > 36 || radix <= 1)
|
||||
{
|
||||
__set_errno(EDOM);
|
||||
return 0;
|
||||
}
|
||||
|
||||
sign = (radix == 10 && value < 0);
|
||||
if (sign)
|
||||
v = -value;
|
||||
else
|
||||
v = (unsigned)value;
|
||||
while (v || tp == tmp)
|
||||
{
|
||||
i = v % radix;
|
||||
v = v / radix;
|
||||
if (i < 10)
|
||||
*tp++ = i+'0';
|
||||
else
|
||||
*tp++ = i + 'a' - 10;
|
||||
}
|
||||
|
||||
if (sign)
|
||||
*sp++ = '-';
|
||||
while (tp > tmp)
|
||||
*sp++ = *--tp;
|
||||
*sp = 0;
|
||||
return string;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int rand(void)
|
||||
{
|
||||
next = next * 0x5deece66dLL + 11;
|
||||
return (int)((next >> 16) & RAND_MAX);
|
||||
}
|
||||
|
||||
|
||||
void srand(unsigned seed)
|
||||
{
|
||||
next = seed;
|
||||
}
|
304
reactos/ntoskrnl/rtl/string.c
Normal file
304
reactos/ntoskrnl/rtl/string.c
Normal file
|
@ -0,0 +1,304 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/rtl/string.c
|
||||
* PURPOSE: Ascii string functions
|
||||
* PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
||||
* UPDATE HISTORY:
|
||||
* 1999/07/29 ekohl Created
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
int _stricmp(const char *s1, const char *s2)
|
||||
{
|
||||
while (toupper(*s1) == toupper(*s2))
|
||||
{
|
||||
if (*s1 == 0)
|
||||
return 0;
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)(s2));
|
||||
}
|
||||
|
||||
|
||||
char * _strlwr(char *x)
|
||||
{
|
||||
char *y=x;
|
||||
|
||||
while (*y)
|
||||
{
|
||||
*y=tolower(*y);
|
||||
y++;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
int _strnicmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
if (n == 0)
|
||||
return 0;
|
||||
do
|
||||
{
|
||||
if (toupper(*s1) != toupper(*s2++))
|
||||
return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)--s2);
|
||||
if (*s1++ == 0)
|
||||
break;
|
||||
}
|
||||
while (--n != 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* _strnset(char* szToFill, int szFill, size_t sizeMaxFill)
|
||||
{
|
||||
char *t = szToFill;
|
||||
int i = 0;
|
||||
while (*szToFill != 0 && i < sizeMaxFill)
|
||||
{
|
||||
*szToFill = szFill;
|
||||
szToFill++;
|
||||
i++;
|
||||
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
char * _strrev(char *s)
|
||||
{
|
||||
char *e;
|
||||
char a;
|
||||
|
||||
e = s;
|
||||
while (*e)
|
||||
e++;
|
||||
|
||||
while (s<e)
|
||||
{
|
||||
a = *s;
|
||||
*s = *e;
|
||||
*e = a;
|
||||
s++;
|
||||
e--;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
char* _strset(char* szToFill, int szFill)
|
||||
{
|
||||
char *t = szToFill;
|
||||
while (*szToFill != 0)
|
||||
{
|
||||
*szToFill = szFill;
|
||||
szToFill++;
|
||||
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
char *_strupr(char *x)
|
||||
{
|
||||
char *y=x;
|
||||
|
||||
while (*y)
|
||||
{
|
||||
*y=toupper(*y);
|
||||
y++;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
char *strcat(char *s, const char *append)
|
||||
{
|
||||
char *save = s;
|
||||
|
||||
for (; *s; ++s);
|
||||
while ((*s++ = *append++));
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
char *strchr(const char *s, int c)
|
||||
{
|
||||
char cc = c;
|
||||
|
||||
while (*s)
|
||||
{
|
||||
if (*s == cc)
|
||||
return (char *)s;
|
||||
s++;
|
||||
}
|
||||
|
||||
if (cc == 0)
|
||||
return (char *)s;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
while (*s1 == *s2)
|
||||
{
|
||||
if (*s1 == 0)
|
||||
return 0;
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
||||
return *(unsigned const char *)s1 - *(unsigned const char *)(s2);
|
||||
}
|
||||
|
||||
|
||||
char* strcpy(char *to, const char *from)
|
||||
{
|
||||
char *save = to;
|
||||
|
||||
for (; (*to = *from); ++from, ++to);
|
||||
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
size_t strlen(const char *str)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
if (str == 0)
|
||||
return 0;
|
||||
for (s = str; *s; ++s);
|
||||
|
||||
return s-str;
|
||||
}
|
||||
|
||||
|
||||
char *strncat(char *dst, const char *src, size_t n)
|
||||
{
|
||||
if (n != 0)
|
||||
{
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
|
||||
while (*d != 0)
|
||||
d++;
|
||||
do
|
||||
{
|
||||
if ((*d = *s++) == 0)
|
||||
break;
|
||||
d++;
|
||||
}
|
||||
while (--n != 0);
|
||||
*d = 0;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
||||
int strncmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
if (n == 0)
|
||||
return 0;
|
||||
do
|
||||
{
|
||||
if (*s1 != *s2++)
|
||||
return *(unsigned const char *)s1 - *(unsigned const char *)--s2;
|
||||
if (*s1++ == 0)
|
||||
break;
|
||||
}
|
||||
while (--n != 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char *strncpy(char *dst, const char *src, size_t n)
|
||||
{
|
||||
if (n != 0)
|
||||
{
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
|
||||
do
|
||||
{
|
||||
if ((*d++ = *s++) == 0)
|
||||
{
|
||||
while (--n != 0)
|
||||
*d++ = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (--n != 0);
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
||||
char *strrchr(const char *s, int c)
|
||||
{
|
||||
char cc = c;
|
||||
const char *sp=(char *)0;
|
||||
|
||||
while (*s)
|
||||
{
|
||||
if (*s == cc)
|
||||
sp = s;
|
||||
s++;
|
||||
}
|
||||
|
||||
if (cc == 0)
|
||||
sp = s;
|
||||
|
||||
return (char *)sp;
|
||||
}
|
||||
|
||||
|
||||
size_t strspn(const char *s1, const char *s2)
|
||||
{
|
||||
const char *p = s1, *spanp;
|
||||
char c, sc;
|
||||
|
||||
cont:
|
||||
c = *p++;
|
||||
for (spanp = s2; (sc = *spanp++) != 0;)
|
||||
if (sc == c)
|
||||
goto cont;
|
||||
|
||||
return (p - 1 - s1);
|
||||
}
|
||||
|
||||
|
||||
char *strstr(const char *s, const char *find)
|
||||
{
|
||||
char c, sc;
|
||||
size_t len;
|
||||
|
||||
if ((c = *find++) != 0)
|
||||
{
|
||||
len = strlen(find);
|
||||
do
|
||||
{
|
||||
do
|
||||
{
|
||||
if ((sc = *s++) == 0)
|
||||
return 0;
|
||||
}
|
||||
while (sc != c);
|
||||
}
|
||||
while (strncmp(s, find, len) != 0);
|
||||
s--;
|
||||
}
|
||||
|
||||
return (char *)s;
|
||||
}
|
|
@ -6,7 +6,8 @@
|
|||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
* 1998/12/04 RJJ Cleaned up and added i386 def checks
|
||||
* 1998/12/04 RJJ Cleaned up and added i386 def checks.
|
||||
* 1999/07/29 ekohl Added missing functions.
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
@ -18,21 +19,91 @@
|
|||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* GLOBALS *****************************************************************/
|
||||
|
||||
wchar_t * ___wcstok = NULL;
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
wchar_t* wcsdup(wchar_t* src)
|
||||
int _wcsicmp (const wchar_t* cs, const wchar_t* ct)
|
||||
{
|
||||
wchar_t* dest;
|
||||
|
||||
dest = ExAllocatePool(NonPagedPool, (wcslen(src)+1)*2);
|
||||
wcscpy(dest,src);
|
||||
return(dest);
|
||||
while (*cs != '\0' && *ct != '\0' && towupper(*cs) == towupper(*ct))
|
||||
{
|
||||
cs++;
|
||||
ct++;
|
||||
}
|
||||
return *cs - *ct;
|
||||
}
|
||||
|
||||
wchar_t * _wcslwr (wchar_t *x)
|
||||
{
|
||||
wchar_t *y=x;
|
||||
|
||||
while (*y)
|
||||
{
|
||||
*y=towlower(*y);
|
||||
y++;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
int _wcsnicmp (const wchar_t * cs,const wchar_t * ct,size_t count)
|
||||
{
|
||||
wchar_t *save = (wchar_t *)cs;
|
||||
while (towlower(*cs) == towlower(*ct) && (int)(cs - save) < count)
|
||||
{
|
||||
if (*cs == 0)
|
||||
return 0;
|
||||
cs++;
|
||||
ct++;
|
||||
}
|
||||
return towlower(*cs) - towlower(*ct);
|
||||
}
|
||||
|
||||
|
||||
wchar_t* _wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill)
|
||||
{
|
||||
wchar_t *t = wsToFill;
|
||||
int i = 0;
|
||||
while( *wsToFill != 0 && i < sizeMaxFill)
|
||||
{
|
||||
*wsToFill = wcFill;
|
||||
wsToFill++;
|
||||
i++;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
wchar_t * _wcsrev(wchar_t *s)
|
||||
{
|
||||
wchar_t *e;
|
||||
wchar_t a;
|
||||
e=s;
|
||||
while (*e)
|
||||
e++;
|
||||
while (s<e)
|
||||
{
|
||||
a=*s;
|
||||
*s=*e;
|
||||
*e=a;
|
||||
s++;
|
||||
e--;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
wchar_t *_wcsupr(wchar_t *x)
|
||||
{
|
||||
wchar_t *y=x;
|
||||
|
||||
while (*y)
|
||||
{
|
||||
*y=towupper(*y);
|
||||
y++;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
wchar_t * wcscat(wchar_t *dest, const wchar_t *src)
|
||||
{
|
||||
int i, j;
|
||||
|
@ -48,8 +119,7 @@ wchar_t * wcscat(wchar_t *dest, const wchar_t *src)
|
|||
return dest;
|
||||
}
|
||||
|
||||
wchar_t *
|
||||
wcschr(const wchar_t *str, wchar_t ch)
|
||||
wchar_t * wcschr(const wchar_t *str, wchar_t ch)
|
||||
{
|
||||
while ((*str) != ((wchar_t) 0))
|
||||
{
|
||||
|
@ -63,15 +133,6 @@ wcschr(const wchar_t *str, wchar_t ch)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int wcsicmp(const wchar_t* cs, const wchar_t* ct)
|
||||
{
|
||||
while (*cs != '\0' && *ct != '\0' && towupper(*cs) == towupper(*ct))
|
||||
{
|
||||
cs++;
|
||||
ct++;
|
||||
}
|
||||
return *cs - *ct;
|
||||
}
|
||||
|
||||
int wcscmp(const wchar_t *cs, const wchar_t *ct)
|
||||
{
|
||||
|
@ -83,6 +144,7 @@ int wcscmp(const wchar_t *cs, const wchar_t *ct)
|
|||
return *cs - *ct;
|
||||
}
|
||||
|
||||
|
||||
wchar_t* wcscpy(wchar_t* str1, const wchar_t* str2)
|
||||
{
|
||||
wchar_t* s = str1;
|
||||
|
@ -97,11 +159,38 @@ wchar_t* wcscpy(wchar_t* str1, const wchar_t* str2)
|
|||
return(str1);
|
||||
}
|
||||
|
||||
size_t wcscspn(const wchar_t *cs, const wchar_t *ct)
|
||||
|
||||
size_t wcscspn(const wchar_t *str,const wchar_t *reject)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
wchar_t *s;
|
||||
wchar_t *t;
|
||||
s=(wchar_t *)str;
|
||||
do {
|
||||
t=(wchar_t *)reject;
|
||||
while (*t) {
|
||||
if (*t==*s)
|
||||
break;
|
||||
t++;
|
||||
}
|
||||
if (*t)
|
||||
break;
|
||||
s++;
|
||||
} while (*s);
|
||||
return s-str; /* nr of wchars */
|
||||
}
|
||||
|
||||
|
||||
/* this function is NOT exported */
|
||||
wchar_t* wcsdup(wchar_t* src)
|
||||
{
|
||||
wchar_t* dest;
|
||||
|
||||
dest = ExAllocatePool (NonPagedPool, (wcslen (src)+1)*2);
|
||||
wcscpy (dest,src);
|
||||
return (dest);
|
||||
}
|
||||
|
||||
|
||||
size_t wcslen(const wchar_t *s)
|
||||
{
|
||||
unsigned int len = 0;
|
||||
|
@ -114,8 +203,8 @@ size_t wcslen(const wchar_t *s)
|
|||
return len;
|
||||
}
|
||||
|
||||
wchar_t *
|
||||
wcsncat(wchar_t *dest, const wchar_t *src, size_t count)
|
||||
|
||||
wchar_t * wcsncat(wchar_t *dest, const wchar_t *src, size_t count)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
@ -134,8 +223,8 @@ wcsncat(wchar_t *dest, const wchar_t *src, size_t count)
|
|||
return dest;
|
||||
}
|
||||
|
||||
int
|
||||
wcsncmp(const wchar_t *cs, const wchar_t *ct, size_t count)
|
||||
|
||||
int wcsncmp(const wchar_t *cs, const wchar_t *ct, size_t count)
|
||||
{
|
||||
while (*cs != '\0' && *ct != '\0' && *cs == *ct && --count)
|
||||
{
|
||||
|
@ -165,14 +254,7 @@ wcsncpy(wchar_t *dest, const wchar_t *src, size_t count)
|
|||
}
|
||||
|
||||
|
||||
int wcsnicmp(const wchar_t *cs, const wchar_t *ct, size_t count)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
wchar_t *
|
||||
wcsrchr(const wchar_t *str, wchar_t ch)
|
||||
wchar_t * wcsrchr(const wchar_t *str, wchar_t ch)
|
||||
{
|
||||
unsigned int len = 0;
|
||||
while (str[len] != ((wchar_t)0))
|
||||
|
@ -191,20 +273,50 @@ wcsrchr(const wchar_t *str, wchar_t ch)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
size_t
|
||||
wcsspn(const wchar_t *cs, const wchar_t *ct)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
wchar_t * wcsstr(const wchar_t *cs, const wchar_t *ct)
|
||||
size_t wcsspn(const wchar_t *str,const wchar_t *accept)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
wchar_t * wcstok(wchar_t * s,const wchar_t * ct)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
wchar_t *s;
|
||||
wchar_t *t;
|
||||
s=(wchar_t *)str;
|
||||
do
|
||||
{
|
||||
t=(wchar_t *)accept;
|
||||
while (*t)
|
||||
{
|
||||
if (*t==*s)
|
||||
break;
|
||||
t++;
|
||||
}
|
||||
if (!*t)
|
||||
break;
|
||||
s++;
|
||||
} while (*s);
|
||||
return s-str; /* nr of wchars */
|
||||
}
|
||||
|
||||
|
||||
wchar_t *wcsstr(const wchar_t *s,const wchar_t *b)
|
||||
{
|
||||
wchar_t *x;
|
||||
wchar_t *y;
|
||||
wchar_t *c;
|
||||
x=(wchar_t *)s;
|
||||
while (*x)
|
||||
{
|
||||
if (*x==*b)
|
||||
{
|
||||
y=x;
|
||||
c=(wchar_t *)b;
|
||||
while (*y && *c && *y==*c)
|
||||
{
|
||||
c++;
|
||||
y++;
|
||||
}
|
||||
if (!*c)
|
||||
return x;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue