From 473fbcb781a2d42dd93d05680dfdef88999349fa Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 18 Apr 2006 20:30:43 +0200 Subject: [PATCH] ntdll: Add wrappers for the string functions. --- dlls/ntdll/ntdll.spec | 96 ++++----- dlls/ntdll/string.c | 441 +++++++++++++++++++++++++++++++++++++++++- dlls/ntdll/wcstring.c | 9 + 3 files changed, 491 insertions(+), 55 deletions(-) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index b2001ae3b2..e5ec40d2e0 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -1249,18 +1249,18 @@ @ cdecl -private _i64tow(double ptr long) @ cdecl -private _itoa(long ptr long) @ cdecl -private _itow(long ptr long) -@ cdecl -private _lfind(ptr ptr ptr long ptr) lfind +@ cdecl -private _lfind(ptr ptr ptr long ptr) @ cdecl -private _ltoa(long ptr long) @ cdecl -private _ltow(long ptr long) -@ cdecl -private _memccpy(ptr ptr long long) memccpy -@ cdecl -private _memicmp(str str long) NTDLL__memicmp -@ varargs -private _snprintf(ptr long ptr) snprintf +@ cdecl -private _memccpy(ptr ptr long long) +@ cdecl -private _memicmp(str str long) +@ varargs -private _snprintf(ptr long ptr) @ varargs -private _snwprintf(wstr long wstr) @ cdecl -private _splitpath(str ptr ptr ptr ptr) -@ cdecl -private _strcmpi(str str) strcasecmp -@ cdecl -private _stricmp(str str) strcasecmp +@ cdecl -private _strcmpi(str str) _stricmp +@ cdecl -private _stricmp(str str) @ cdecl -private _strlwr(str) -@ cdecl -private _strnicmp(str str long) strncasecmp +@ cdecl -private _strnicmp(str str long) @ cdecl -private _strupr(str) # @ stub -private _tolower # @ stub -private _toupper @@ -1268,8 +1268,8 @@ @ cdecl -private _ui64tow(double ptr long) @ cdecl -private _ultoa(long ptr long) @ cdecl -private _ultow(long ptr long) -@ cdecl -private _vsnprintf(ptr long str ptr) vsnprintf -@ cdecl -private _vsnwprintf(ptr long wstr ptr) vsnprintfW +@ cdecl -private _vsnprintf(ptr long str ptr) +@ cdecl -private _vsnwprintf(ptr long wstr ptr) @ cdecl -private _wcsicmp(wstr wstr) NTDLL__wcsicmp @ cdecl -private _wcslwr(wstr) NTDLL__wcslwr @ cdecl -private _wcsnicmp(wstr wstr long) NTDLL__wcsnicmp @@ -1279,68 +1279,68 @@ @ cdecl -private _wtol(wstr) @ cdecl -private abs(long) @ cdecl -private atan(double) -@ cdecl -private atoi(str) -@ cdecl -private atol(str) -@ cdecl -private bsearch(ptr ptr long long ptr) +@ cdecl -private atoi(str) NTDLL_atoi +@ cdecl -private atol(str) NTDLL_atol +@ cdecl -private bsearch(ptr ptr long long ptr) NTDLL_bsearch @ cdecl -private ceil(double) @ cdecl -private cos(double) @ cdecl -private fabs(double) @ cdecl -private floor(double) -@ cdecl -private isalnum(long) -@ cdecl -private isalpha(long) -@ cdecl -private iscntrl(long) -@ cdecl -private isdigit(long) -@ cdecl -private isgraph(long) -@ cdecl -private islower(long) -@ cdecl -private isprint(long) -@ cdecl -private ispunct(long) -@ cdecl -private isspace(long) -@ cdecl -private isupper(long) +@ cdecl -private isalnum(long) NTDLL_isalnum +@ cdecl -private isalpha(long) NTDLL_isalpha +@ cdecl -private iscntrl(long) NTDLL_iscntrl +@ cdecl -private isdigit(long) NTDLL_isdigit +@ cdecl -private isgraph(long) NTDLL_isgraph +@ cdecl -private islower(long) NTDLL_islower +@ cdecl -private isprint(long) NTDLL_isprint +@ cdecl -private ispunct(long) NTDLL_ispunct +@ cdecl -private isspace(long) NTDLL_isspace +@ cdecl -private isupper(long) NTDLL_isupper @ cdecl -private iswalpha(long) NTDLL_iswalpha @ cdecl -private iswctype(long long) NTDLL_iswctype @ cdecl -private iswdigit(long) NTDLL_iswdigit @ cdecl -private iswlower(long) NTDLL_iswlower @ cdecl -private iswspace(long) NTDLL_iswspace @ cdecl -private iswxdigit(long) NTDLL_iswxdigit -@ cdecl -private isxdigit(long) +@ cdecl -private isxdigit(long) NTDLL_isxdigit @ cdecl -private labs(long) @ cdecl -private log(double) @ cdecl -private mbstowcs(ptr str long) NTDLL_mbstowcs -@ cdecl -private memchr(ptr long long) -@ cdecl -private memcmp(ptr ptr long) +@ cdecl -private memchr(ptr long long) NTDLL_memchr +@ cdecl -private memcmp(ptr ptr long) NTDLL_memcmp @ cdecl -private memcpy(ptr ptr long) NTDLL_memcpy -@ cdecl -private memmove(ptr ptr long) -@ cdecl -private memset(ptr long long) +@ cdecl -private memmove(ptr ptr long) NTDLL_memmove +@ cdecl -private memset(ptr long long) NTDLL_memset @ cdecl -private pow(double double) -@ cdecl -private qsort(ptr long long ptr) +@ cdecl -private qsort(ptr long long ptr) NTDLL_qsort @ cdecl -private sin(double) -@ varargs -private sprintf(str str) +@ varargs -private sprintf(str str) NTDLL_sprintf @ cdecl -private sqrt(double) -@ varargs -private sscanf(str str) -@ cdecl -private strcat(str str) -@ cdecl -private strchr(str long) -@ cdecl -private strcmp(str str) -@ cdecl -private strcpy(ptr str) -@ cdecl -private strcspn(str str) -@ cdecl -private strlen(str) -@ cdecl -private strncat(str str long) -@ cdecl -private strncmp(str str long) -@ cdecl -private strncpy(ptr str long) -@ cdecl -private strpbrk(str str) -@ cdecl -private strrchr(str long) -@ cdecl -private strspn(str str) -@ cdecl -private strstr(str str) -@ cdecl -private strtol(str ptr long) -@ cdecl -private strtoul(str ptr long) +@ varargs -private sscanf(str str) NTDLL_sscanf +@ cdecl -private strcat(str str) NTDLL_strcat +@ cdecl -private strchr(str long) NTDLL_strchr +@ cdecl -private strcmp(str str) NTDLL_strcmp +@ cdecl -private strcpy(ptr str) NTDLL_strcpy +@ cdecl -private strcspn(str str) NTDLL_strcspn +@ cdecl -private strlen(str) NTDLL_strlen +@ cdecl -private strncat(str str long) NTDLL_strncat +@ cdecl -private strncmp(str str long) NTDLL_strncmp +@ cdecl -private strncpy(ptr str long) NTDLL_strncpy +@ cdecl -private strpbrk(str str) NTDLL_strpbrk +@ cdecl -private strrchr(str long) NTDLL_strrchr +@ cdecl -private strspn(str str) NTDLL_strspn +@ cdecl -private strstr(str str) NTDLL_strstr +@ cdecl -private strtol(str ptr long) NTDLL_strtol +@ cdecl -private strtoul(str ptr long) NTDLL_strtoul @ varargs -private swprintf(wstr wstr) NTDLL_swprintf @ cdecl -private tan(double) -@ cdecl -private tolower(long) -@ cdecl -private toupper(long) +@ cdecl -private tolower(long) NTDLL_tolower +@ cdecl -private toupper(long) NTDLL_toupper @ cdecl -private towlower(long) NTDLL_towlower @ cdecl -private towupper(long) NTDLL_towupper @ stdcall vDbgPrintEx(long long str ptr) @ stdcall vDbgPrintExWithPrefix(str long long str ptr) -@ cdecl -private vsprintf(ptr str ptr) +@ cdecl -private vsprintf(ptr str ptr) NTDLL_vsprintf @ cdecl -private wcscat(wstr wstr) NTDLL_wcscat @ cdecl -private wcschr(wstr long) NTDLL_wcschr @ cdecl -private wcscmp(wstr wstr) NTDLL_wcscmp diff --git a/dlls/ntdll/string.c b/dlls/ntdll/string.c index 45d36d8eaf..4128d6986d 100644 --- a/dlls/ntdll/string.c +++ b/dlls/ntdll/string.c @@ -25,12 +25,219 @@ #include #include +#include +#include #include +#include #include "windef.h" #include "winternl.h" +/********************************************************************* + * memchr (NTDLL.@) + */ +void * __cdecl NTDLL_memchr( const void *ptr, int c, size_t n ) +{ + return memchr( ptr, c, n ); +} + + +/********************************************************************* + * memcmp (NTDLL.@) + */ +int __cdecl NTDLL_memcmp( const void *ptr1, const void *ptr2, size_t n ) +{ + return memcmp( ptr1, ptr2, n ); +} + + +/********************************************************************* + * memcpy (NTDLL.@) + * + * NOTES + * Behaves like memmove. + */ +void * __cdecl NTDLL_memcpy( void *dst, const void *src, size_t n ) +{ + return memmove( dst, src, n ); +} + + +/********************************************************************* + * memmove (NTDLL.@) + */ +void * __cdecl NTDLL_memmove( void *dst, const void *src, size_t n ) +{ + return memmove( dst, src, n ); +} + + +/********************************************************************* + * memset (NTDLL.@) + */ +void * __cdecl NTDLL_memset( void *dst, int c, size_t n ) +{ + return memset( dst, c, n ); +} + + +/********************************************************************* + * bsearch (NTDLL.@) + */ +void * __cdecl NTDLL_bsearch( const void *key, const void *base, size_t nmemb, + size_t size, int (*compar)(const void *, const void *) ) +{ + return bsearch( key, base, nmemb, size, compar ); +} + + +/********************************************************************* + * qsort (NTDLL.@) + */ +void __cdecl NTDLL_qsort( void *base, size_t nmemb, size_t size, + int(*compar)(const void *, const void *) ) +{ + return qsort( base, nmemb, size, compar ); +} + + +/********************************************************************* + * _lfind (NTDLL.@) + */ +void * __cdecl _lfind( const void *key, const void *base, size_t *nmemb, + size_t size, int(*compar)(const void *, const void *) ) +{ + return lfind( key, base, nmemb, size, compar ); +} + + +/********************************************************************* + * strcat (NTDLL.@) + */ +char * __cdecl NTDLL_strcat( char *dst, const char *src ) +{ + return strcat( dst, src ); +} + + +/********************************************************************* + * strchr (NTDLL.@) + */ +char * __cdecl NTDLL_strchr( const char *str, int c ) +{ + return strchr( str, c ); +} + + +/********************************************************************* + * strcmp (NTDLL.@) + */ +int __cdecl NTDLL_strcmp( const char *str1, const char *str2 ) +{ + return strcmp( str1, str2 ); +} + + +/********************************************************************* + * strcpy (NTDLL.@) + */ +char * __cdecl NTDLL_strcpy( char *dst, const char *src ) +{ + return strcpy( dst, src ); +} + + +/********************************************************************* + * strcspn (NTDLL.@) + */ +size_t __cdecl NTDLL_strcspn( const char *str, const char *reject ) +{ + return strcspn( str, reject ); +} + + +/********************************************************************* + * strlen (NTDLL.@) + */ +size_t __cdecl NTDLL_strlen( const char *str ) +{ + return strlen( str ); +} + + +/********************************************************************* + * strncat (NTDLL.@) + */ +char * __cdecl NTDLL_strncat( char *dst, const char *src, size_t len ) +{ + return strncat( dst, src, len ); +} + + +/********************************************************************* + * strncmp (NTDLL.@) + */ +int __cdecl NTDLL_strncmp( const char *str1, const char *str2, size_t len ) +{ + return strncmp( str1, str2, len ); +} + + +/********************************************************************* + * strncpy (NTDLL.@) + */ +char * __cdecl NTDLL_strncpy( char *dst, const char *src, size_t len ) +{ + return strncpy( dst, src, len ); +} + + +/********************************************************************* + * strpbrk (NTDLL.@) + */ +char * __cdecl NTDLL_strpbrk( const char *str, const char *accept ) +{ + return strpbrk( str, accept ); +} + + +/********************************************************************* + * strrchr (NTDLL.@) + */ +char * __cdecl NTDLL_strrchr( const char *str, int c ) +{ + return strrchr( str, c ); +} + + +/********************************************************************* + * strspn (NTDLL.@) + */ +size_t __cdecl NTDLL_strspn( const char *str, const char *accept ) +{ + return strspn( str, accept ); +} + + +/********************************************************************* + * strstr (NTDLL.@) + */ +char * __cdecl NTDLL_strstr( const char *haystack, const char *needle ) +{ + return strstr( haystack, needle ); +} + + +/********************************************************************* + * _memccpy (NTDLL.@) + */ +void * __cdecl _memccpy( void *dst, const void *src, int c, size_t n ) +{ + return memccpy( dst, src, c, n ); +} + + /********************************************************************* * _memicmp (NTDLL.@) * @@ -49,7 +256,7 @@ * Any Nul characters in s1 or s2 are ignored. This function always * compares up to len bytes or the first place where s1 and s2 differ. */ -INT __cdecl NTDLL__memicmp( LPCSTR s1, LPCSTR s2, DWORD len ) +INT __cdecl _memicmp( LPCSTR s1, LPCSTR s2, DWORD len ) { int ret = 0; while (len--) @@ -63,14 +270,21 @@ INT __cdecl NTDLL__memicmp( LPCSTR s1, LPCSTR s2, DWORD len ) /********************************************************************* - * memcpy (NTDLL.@) - * - * NOTES - * Behaves like memmove. + * _stricmp (NTDLL.@) + * _strcmpi (NTDLL.@) */ -void * __cdecl NTDLL_memcpy( void *dst, const void *src, size_t n ) +int __cdecl _stricmp( LPCSTR str1, LPCSTR str2 ) { - return memmove( dst, src, n ); + return strcasecmp( str1, str2 ); +} + + +/********************************************************************* + * _strnicmp (NTDLL.@) + */ +int __cdecl _strnicmp( LPCSTR str1, LPCSTR str2, size_t n ) +{ + return strncasecmp( str1, str2, n ); } @@ -114,6 +328,159 @@ LPSTR __cdecl _strlwr( LPSTR str ) } +/********************************************************************* + * tolower (NTDLL.@) + */ +int __cdecl NTDLL_tolower( int c ) +{ + return tolower( c ); +} + + +/********************************************************************* + * toupper (NTDLL.@) + */ +int __cdecl NTDLL_toupper( int c ) +{ + return toupper( c ); +} + + +/********************************************************************* + * isalnum (NTDLL.@) + */ +int __cdecl NTDLL_isalnum( int c ) +{ + return isalnum( c ); +} + + +/********************************************************************* + * isalpha (NTDLL.@) + */ +int __cdecl NTDLL_isalpha( int c ) +{ + return isalpha( c ); +} + + +/********************************************************************* + * iscntrl (NTDLL.@) + */ +int __cdecl NTDLL_iscntrl( int c ) +{ + return iscntrl( c ); +} + + +/********************************************************************* + * isdigit (NTDLL.@) + */ +int __cdecl NTDLL_isdigit( int c ) +{ + return isdigit( c ); +} + + +/********************************************************************* + * isgraph (NTDLL.@) + */ +int __cdecl NTDLL_isgraph( int c ) +{ + return isgraph( c ); +} + + +/********************************************************************* + * islower (NTDLL.@) + */ +int __cdecl NTDLL_islower( int c ) +{ + return islower( c ); +} + + +/********************************************************************* + * isprint (NTDLL.@) + */ +int __cdecl NTDLL_isprint( int c ) +{ + return isprint( c ); +} + + +/********************************************************************* + * ispunct (NTDLL.@) + */ +int __cdecl NTDLL_ispunct( int c ) +{ + return ispunct( c ); +} + + +/********************************************************************* + * isspace (NTDLL.@) + */ +int __cdecl NTDLL_isspace( int c ) +{ + return isspace( c ); +} + + +/********************************************************************* + * isupper (NTDLL.@) + */ +int __cdecl NTDLL_isupper( int c ) +{ + return isupper( c ); +} + + +/********************************************************************* + * isxdigit (NTDLL.@) + */ +int __cdecl NTDLL_isxdigit( int c ) +{ + return isxdigit( c ); +} + + +/********************************************************************* + * strtol (NTDLL.@) + */ +long __cdecl NTDLL_strtol( const char *nptr, char **endptr, int base ) +{ + return strtol( nptr, endptr, base ); +} + + +/********************************************************************* + * strtoul (NTDLL.@) + */ +unsigned long __cdecl NTDLL_strtoul( const char *nptr, char **endptr, int base ) +{ + return strtoul( nptr, endptr, base ); +} + + +/********************************************************************* + * atoi (NTDLL.@) + */ +int __cdecl NTDLL_atoi( const char *nptr ) +{ + return atoi( nptr ); +} + + +/********************************************************************* + * atol (NTDLL.@) + */ +long __cdecl NTDLL_atol( const char *nptr ) +{ + return atol( nptr ); +} + + /********************************************************************* * _ultoa (NTDLL.@) * @@ -384,6 +751,66 @@ LONGLONG __cdecl _atoi64( char *str ) } +/********************************************************************* + * sprintf (NTDLL.@) + */ +int __cdecl NTDLL_sprintf( char *str, const char *format, ... ) +{ + int ret; + va_list valist; + va_start( valist, format ); + ret = vsprintf( str, format, valist ); + va_end( valist ); + return ret; +} + + +/********************************************************************* + * vsprintf (NTDLL.@) + */ +int __cdecl NTDLL_vsprintf( char *str, const char *format, va_list args ) +{ + return vsprintf( str, format, args ); +} + + +/********************************************************************* + * _snprintf (NTDLL.@) + */ +int __cdecl _snprintf( char *str, size_t len, const char *format, ... ) +{ + int ret; + va_list valist; + va_start( valist, format ); + ret = vsnprintf( str, len, format, valist ); + va_end( valist ); + return ret; +} + + +/********************************************************************* + * _vsnprintf (NTDLL.@) + */ +int __cdecl _vsnprintf( char *str, size_t len, const char *format, va_list args ) +{ + return vsnprintf( str, len, format, args ); +} + + +/********************************************************************* + * sscanf (NTDLL.@) + */ +int __cdecl NTDLL_sscanf( const char *str, const char *format, ... ) +{ + int ret; + va_list valist; + va_start( valist, format ); + ret = vsscanf( str, format, valist ); + va_end( valist ); + return ret; +} + + /********************************************************************* * _splitpath (NTDLL.@) * diff --git a/dlls/ntdll/wcstring.c b/dlls/ntdll/wcstring.c index d42f4925dd..eea1fab44c 100644 --- a/dlls/ntdll/wcstring.c +++ b/dlls/ntdll/wcstring.c @@ -755,3 +755,12 @@ int __cdecl NTDLL_swprintf(WCHAR *str, const WCHAR *format, ...) va_end(valist); return retval; } + + +/*********************************************************************** + * _vsnwprintf (NTDLL.@) + */ +int __cdecl _vsnwprintf( WCHAR *str, unsigned int len, const WCHAR *format, va_list args ) +{ + return vsnprintfW( str, len, format, args ); +}