ntdll: Export some Unicode string functions for use in other Unix libraries.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
a3ef7a13c8
commit
035f8ad8ad
|
@ -612,7 +612,7 @@ static unsigned int decode_utf8_char( unsigned char ch, const char **str, const
|
|||
|
||||
|
||||
/******************************************************************
|
||||
* ntdll_umbstowcs
|
||||
* ntdll_umbstowcs (ntdll.so)
|
||||
*/
|
||||
DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen )
|
||||
{
|
||||
|
@ -657,7 +657,7 @@ DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen )
|
|||
|
||||
|
||||
/******************************************************************
|
||||
* ntdll_wcstoumbs
|
||||
* ntdll_wcstoumbs (ntdll.so)
|
||||
*/
|
||||
int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BOOL strict )
|
||||
{
|
||||
|
@ -758,8 +758,35 @@ int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BO
|
|||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* ntdll_wcsicmp (ntdll.so)
|
||||
*/
|
||||
int ntdll_wcsicmp( const WCHAR *str1, const WCHAR *str2 )
|
||||
{
|
||||
int ret;
|
||||
for (;;)
|
||||
{
|
||||
if ((ret = ntdll_towupper( *str1 ) - ntdll_towupper( *str2 )) || !*str1) return ret;
|
||||
str1++;
|
||||
str2++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* ntdll_wcsnicmp (ntdll.so)
|
||||
*/
|
||||
int ntdll_wcsnicmp( const WCHAR *str1, const WCHAR *str2, int n )
|
||||
{
|
||||
int ret;
|
||||
for (ret = 0; n > 0; n--, str1++, str2++)
|
||||
if ((ret = ntdll_towupper(*str1) - ntdll_towupper(*str2)) || !*str1) break;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* ntdll_get_build_dir
|
||||
* ntdll_get_build_dir (ntdll.so)
|
||||
*/
|
||||
const char *ntdll_get_build_dir(void)
|
||||
{
|
||||
|
@ -768,7 +795,7 @@ const char *ntdll_get_build_dir(void)
|
|||
|
||||
|
||||
/***********************************************************************
|
||||
* ntdll_get_data_dir
|
||||
* ntdll_get_data_dir (ntdll.so)
|
||||
*/
|
||||
const char *ntdll_get_data_dir(void)
|
||||
{
|
||||
|
|
|
@ -411,72 +411,6 @@ enum loadorder
|
|||
extern void set_load_order_app_name( const WCHAR *app_name ) DECLSPEC_HIDDEN;
|
||||
extern enum loadorder get_load_order( const UNICODE_STRING *nt_name ) DECLSPEC_HIDDEN;
|
||||
|
||||
static inline size_t ntdll_wcslen( const WCHAR *str )
|
||||
{
|
||||
const WCHAR *s = str;
|
||||
while (*s) s++;
|
||||
return s - str;
|
||||
}
|
||||
|
||||
static inline WCHAR *ntdll_wcscpy( WCHAR *dst, const WCHAR *src )
|
||||
{
|
||||
WCHAR *p = dst;
|
||||
while ((*p++ = *src++));
|
||||
return dst;
|
||||
}
|
||||
|
||||
static inline WCHAR *ntdll_wcscat( WCHAR *dst, const WCHAR *src )
|
||||
{
|
||||
ntdll_wcscpy( dst + ntdll_wcslen(dst), src );
|
||||
return dst;
|
||||
}
|
||||
|
||||
static inline int ntdll_wcscmp( const WCHAR *str1, const WCHAR *str2 )
|
||||
{
|
||||
while (*str1 && (*str1 == *str2)) { str1++; str2++; }
|
||||
return *str1 - *str2;
|
||||
}
|
||||
|
||||
static inline int ntdll_wcsncmp( const WCHAR *str1, const WCHAR *str2, int n )
|
||||
{
|
||||
if (n <= 0) return 0;
|
||||
while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
|
||||
return *str1 - *str2;
|
||||
}
|
||||
|
||||
static inline WCHAR *ntdll_wcschr( const WCHAR *str, WCHAR ch )
|
||||
{
|
||||
do { if (*str == ch) return (WCHAR *)(ULONG_PTR)str; } while (*str++);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline WCHAR *ntdll_wcsrchr( const WCHAR *str, WCHAR ch )
|
||||
{
|
||||
WCHAR *ret = NULL;
|
||||
do { if (*str == ch) ret = (WCHAR *)(ULONG_PTR)str; } while (*str++);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline WCHAR *ntdll_wcspbrk( const WCHAR *str, const WCHAR *accept )
|
||||
{
|
||||
for ( ; *str; str++) if (ntdll_wcschr( accept, *str )) return (WCHAR *)(ULONG_PTR)str;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline SIZE_T ntdll_wcsspn( const WCHAR *str, const WCHAR *accept )
|
||||
{
|
||||
const WCHAR *ptr;
|
||||
for (ptr = str; *ptr; ptr++) if (!ntdll_wcschr( accept, *ptr )) break;
|
||||
return ptr - str;
|
||||
}
|
||||
|
||||
static inline SIZE_T ntdll_wcscspn( const WCHAR *str, const WCHAR *reject )
|
||||
{
|
||||
const WCHAR *ptr;
|
||||
for (ptr = str; *ptr; ptr++) if (ntdll_wcschr( reject, *ptr )) break;
|
||||
return ptr - str;
|
||||
}
|
||||
|
||||
static inline WCHAR ntdll_towupper( WCHAR ch )
|
||||
{
|
||||
return ch + uctable[uctable[uctable[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0x0f)];
|
||||
|
@ -494,37 +428,6 @@ static inline WCHAR *ntdll_wcsupr( WCHAR *str )
|
|||
return ret;
|
||||
}
|
||||
|
||||
static inline int ntdll_wcsicmp( const WCHAR *str1, const WCHAR *str2 )
|
||||
{
|
||||
int ret;
|
||||
for (;;)
|
||||
{
|
||||
if ((ret = ntdll_towupper( *str1 ) - ntdll_towupper( *str2 )) || !*str1) return ret;
|
||||
str1++;
|
||||
str2++;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int ntdll_wcsnicmp( const WCHAR *str1, const WCHAR *str2, int n )
|
||||
{
|
||||
int ret;
|
||||
for (ret = 0; n > 0; n--, str1++, str2++)
|
||||
if ((ret = ntdll_towupper(*str1) - ntdll_towupper(*str2)) || !*str1) break;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define wcslen(str) ntdll_wcslen(str)
|
||||
#define wcscpy(dst,src) ntdll_wcscpy(dst,src)
|
||||
#define wcscat(dst,src) ntdll_wcscat(dst,src)
|
||||
#define wcscmp(s1,s2) ntdll_wcscmp(s1,s2)
|
||||
#define wcsncmp(s1,s2,n) ntdll_wcsncmp(s1,s2,n)
|
||||
#define wcschr(str,ch) ntdll_wcschr(str,ch)
|
||||
#define wcsrchr(str,ch) ntdll_wcsrchr(str,ch)
|
||||
#define wcspbrk(str,ac) ntdll_wcspbrk(str,ac)
|
||||
#define wcsspn(str,ac) ntdll_wcsspn(str,ac)
|
||||
#define wcscspn(str,rej) ntdll_wcscspn(str,rej)
|
||||
#define wcsicmp(s1, s2) ntdll_wcsicmp(s1,s2)
|
||||
#define wcsnicmp(s1, s2,n) ntdll_wcsnicmp(s1,s2,n)
|
||||
#define wcsupr(str) ntdll_wcsupr(str)
|
||||
#define towupper(c) ntdll_towupper(c)
|
||||
#define towlower(c) ntdll_towlower(c)
|
||||
|
|
|
@ -256,41 +256,11 @@ static inline BOOL set_ntstatus( NTSTATUS status )
|
|||
return !status;
|
||||
}
|
||||
|
||||
static inline WCHAR *win32u_wcsrchr( const WCHAR *str, WCHAR ch )
|
||||
{
|
||||
WCHAR *ret = NULL;
|
||||
do { if (*str == ch) ret = (WCHAR *)(ULONG_PTR)str; } while (*str++);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline WCHAR win32u_towupper( WCHAR ch )
|
||||
{
|
||||
return RtlUpcaseUnicodeChar( ch );
|
||||
}
|
||||
|
||||
static inline WCHAR *win32u_wcschr( const WCHAR *str, WCHAR ch )
|
||||
{
|
||||
do { if (*str == ch) return (WCHAR *)(ULONG_PTR)str; } while (*str++);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline int win32u_wcsicmp( const WCHAR *str1, const WCHAR *str2 )
|
||||
{
|
||||
int ret;
|
||||
for (;;)
|
||||
{
|
||||
if ((ret = win32u_towupper( *str1 ) - win32u_towupper( *str2 )) || !*str1) return ret;
|
||||
str1++;
|
||||
str2++;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int win32u_wcscmp( const WCHAR *str1, const WCHAR *str2 )
|
||||
{
|
||||
while (*str1 && (*str1 == *str2)) { str1++; str2++; }
|
||||
return *str1 - *str2;
|
||||
}
|
||||
|
||||
static inline LONG win32u_wcstol( LPCWSTR s, LPWSTR *end, INT base )
|
||||
{
|
||||
BOOL negative = FALSE, empty = TRUE;
|
||||
|
@ -385,10 +355,6 @@ static inline ULONG win32u_wcstoul( const WCHAR *s, WCHAR **end, int base )
|
|||
}
|
||||
|
||||
#define towupper(c) win32u_towupper(c)
|
||||
#define wcschr(s,c) win32u_wcschr(s,c)
|
||||
#define wcscmp(s1,s2) win32u_wcscmp(s1,s2)
|
||||
#define wcsicmp(s1,s2) win32u_wcsicmp(s1,s2)
|
||||
#define wcsrchr(s,c) win32u_wcsrchr(s,c)
|
||||
#define wcstol(s,e,b) win32u_wcstol(s,e,b)
|
||||
#define wcstoul(s,e,b) win32u_wcstoul(s,e,b)
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ extern const char *ntdll_get_build_dir(void);
|
|||
extern const char *ntdll_get_data_dir(void);
|
||||
extern DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen );
|
||||
extern int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BOOL strict );
|
||||
extern int ntdll_wcsicmp( const WCHAR *str1, const WCHAR *str2 );
|
||||
extern int ntdll_wcsnicmp( const WCHAR *str1, const WCHAR *str2, int n );
|
||||
extern NTSTATUS ntdll_init_syscalls( ULONG id, SYSTEM_SERVICE_TABLE *table, void **dispatcher );
|
||||
|
||||
/* exception handling */
|
||||
|
@ -78,6 +80,87 @@ extern void ntdll_set_exception_jmp_buf( __wine_jmp_buf *jmp );
|
|||
} \
|
||||
} while (0);
|
||||
|
||||
/* wide char string functions */
|
||||
|
||||
static inline size_t ntdll_wcslen( const WCHAR *str )
|
||||
{
|
||||
const WCHAR *s = str;
|
||||
while (*s) s++;
|
||||
return s - str;
|
||||
}
|
||||
|
||||
static inline WCHAR *ntdll_wcscpy( WCHAR *dst, const WCHAR *src )
|
||||
{
|
||||
WCHAR *p = dst;
|
||||
while ((*p++ = *src++));
|
||||
return dst;
|
||||
}
|
||||
|
||||
static inline WCHAR *ntdll_wcscat( WCHAR *dst, const WCHAR *src )
|
||||
{
|
||||
ntdll_wcscpy( dst + ntdll_wcslen(dst), src );
|
||||
return dst;
|
||||
}
|
||||
|
||||
static inline int ntdll_wcscmp( const WCHAR *str1, const WCHAR *str2 )
|
||||
{
|
||||
while (*str1 && (*str1 == *str2)) { str1++; str2++; }
|
||||
return *str1 - *str2;
|
||||
}
|
||||
|
||||
static inline int ntdll_wcsncmp( const WCHAR *str1, const WCHAR *str2, int n )
|
||||
{
|
||||
if (n <= 0) return 0;
|
||||
while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
|
||||
return *str1 - *str2;
|
||||
}
|
||||
|
||||
static inline WCHAR *ntdll_wcschr( const WCHAR *str, WCHAR ch )
|
||||
{
|
||||
do { if (*str == ch) return (WCHAR *)(ULONG_PTR)str; } while (*str++);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline WCHAR *ntdll_wcsrchr( const WCHAR *str, WCHAR ch )
|
||||
{
|
||||
WCHAR *ret = NULL;
|
||||
do { if (*str == ch) ret = (WCHAR *)(ULONG_PTR)str; } while (*str++);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline WCHAR *ntdll_wcspbrk( const WCHAR *str, const WCHAR *accept )
|
||||
{
|
||||
for ( ; *str; str++) if (ntdll_wcschr( accept, *str )) return (WCHAR *)(ULONG_PTR)str;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline SIZE_T ntdll_wcsspn( const WCHAR *str, const WCHAR *accept )
|
||||
{
|
||||
const WCHAR *ptr;
|
||||
for (ptr = str; *ptr; ptr++) if (!ntdll_wcschr( accept, *ptr )) break;
|
||||
return ptr - str;
|
||||
}
|
||||
|
||||
static inline SIZE_T ntdll_wcscspn( const WCHAR *str, const WCHAR *reject )
|
||||
{
|
||||
const WCHAR *ptr;
|
||||
for (ptr = str; *ptr; ptr++) if (ntdll_wcschr( reject, *ptr )) break;
|
||||
return ptr - str;
|
||||
}
|
||||
|
||||
#define wcslen(str) ntdll_wcslen(str)
|
||||
#define wcscpy(dst,src) ntdll_wcscpy(dst,src)
|
||||
#define wcscat(dst,src) ntdll_wcscat(dst,src)
|
||||
#define wcscmp(s1,s2) ntdll_wcscmp(s1,s2)
|
||||
#define wcsncmp(s1,s2,n) ntdll_wcsncmp(s1,s2,n)
|
||||
#define wcschr(str,ch) ntdll_wcschr(str,ch)
|
||||
#define wcsrchr(str,ch) ntdll_wcsrchr(str,ch)
|
||||
#define wcspbrk(str,ac) ntdll_wcspbrk(str,ac)
|
||||
#define wcsspn(str,ac) ntdll_wcsspn(str,ac)
|
||||
#define wcscspn(str,rej) ntdll_wcscspn(str,rej)
|
||||
#define wcsicmp(s1, s2) ntdll_wcsicmp(s1,s2)
|
||||
#define wcsnicmp(s1, s2,n) ntdll_wcsnicmp(s1,s2,n)
|
||||
|
||||
#endif /* WINE_UNIX_LIB */
|
||||
|
||||
#endif /* __WINE_WINE_UNIXLIB_H */
|
||||
|
|
Loading…
Reference in New Issue