2000-06-23 16:16:30 +00:00
|
|
|
/*
|
|
|
|
* NTDLL wide-char functions
|
|
|
|
*
|
|
|
|
* Copyright 2000 Alexandre Julliard
|
2001-01-22 02:17:29 +00:00
|
|
|
* Copyright 2000 Jon Griffiths
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <ctype.h>
|
2001-01-22 02:17:29 +00:00
|
|
|
#include <limits.h>
|
2000-06-23 16:16:30 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2001-01-22 02:17:29 +00:00
|
|
|
#include <stdio.h>
|
2000-06-23 16:16:30 +00:00
|
|
|
|
2002-09-12 22:07:02 +00:00
|
|
|
#include "winternl.h"
|
2000-06-23 16:16:30 +00:00
|
|
|
#include "wine/unicode.h"
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
2000-06-23 16:16:30 +00:00
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
|
2000-06-23 16:16:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* _wcsicmp (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
INT __cdecl NTDLL__wcsicmp( LPCWSTR str1, LPCWSTR str2 )
|
|
|
|
{
|
|
|
|
return strcmpiW( str1, str2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* _wcslwr (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
LPWSTR __cdecl NTDLL__wcslwr( LPWSTR str )
|
|
|
|
{
|
|
|
|
return strlwrW( str );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* _wcsnicmp (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
INT __cdecl NTDLL__wcsnicmp( LPCWSTR str1, LPCWSTR str2, INT n )
|
|
|
|
{
|
|
|
|
return strncmpiW( str1, str2, n );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* _wcsupr (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
LPWSTR __cdecl NTDLL__wcsupr( LPWSTR str )
|
|
|
|
{
|
|
|
|
return struprW( str );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* towlower (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
WCHAR __cdecl NTDLL_towlower( WCHAR ch )
|
|
|
|
{
|
|
|
|
return tolowerW(ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* towupper (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
WCHAR __cdecl NTDLL_towupper( WCHAR ch )
|
|
|
|
{
|
|
|
|
return toupperW(ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* wcscat (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
LPWSTR __cdecl NTDLL_wcscat( LPWSTR dst, LPCWSTR src )
|
|
|
|
{
|
|
|
|
return strcatW( dst, src );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* wcschr (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
LPWSTR __cdecl NTDLL_wcschr( LPCWSTR str, WCHAR ch )
|
|
|
|
{
|
|
|
|
return strchrW( str, ch );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* wcscmp (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
INT __cdecl NTDLL_wcscmp( LPCWSTR str1, LPCWSTR str2 )
|
|
|
|
{
|
|
|
|
return strcmpW( str1, str2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* wcscpy (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
LPWSTR __cdecl NTDLL_wcscpy( LPWSTR dst, LPCWSTR src )
|
|
|
|
{
|
|
|
|
return strcpyW( dst, src );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* wcscspn (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
INT __cdecl NTDLL_wcscspn( LPCWSTR str, LPCWSTR reject )
|
|
|
|
{
|
|
|
|
LPCWSTR start = str;
|
|
|
|
while (*str)
|
|
|
|
{
|
|
|
|
LPCWSTR p = reject;
|
|
|
|
while (*p && (*p != *str)) p++;
|
|
|
|
if (*p) break;
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
return str - start;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* wcslen (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
INT __cdecl NTDLL_wcslen( LPCWSTR str )
|
|
|
|
{
|
|
|
|
return strlenW( str );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* wcsncat (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
LPWSTR __cdecl NTDLL_wcsncat( LPWSTR s1, LPCWSTR s2, INT n )
|
|
|
|
{
|
|
|
|
LPWSTR ret = s1;
|
|
|
|
while (*s1) s1++;
|
|
|
|
while (n-- > 0) if (!(*s1++ = *s2++)) return ret;
|
|
|
|
*s1 = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* wcsncmp (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
INT __cdecl NTDLL_wcsncmp( LPCWSTR str1, LPCWSTR str2, INT n )
|
|
|
|
{
|
|
|
|
return strncmpW( str1, str2, n );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* wcsncpy (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
LPWSTR __cdecl NTDLL_wcsncpy( LPWSTR s1, LPCWSTR s2, INT n )
|
|
|
|
{
|
2000-08-14 14:41:19 +00:00
|
|
|
return strncpyW( s1, s2, n );
|
2000-06-23 16:16:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* wcspbrk (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
LPWSTR __cdecl NTDLL_wcspbrk( LPCWSTR str, LPCWSTR accept )
|
|
|
|
{
|
|
|
|
LPCWSTR p;
|
|
|
|
while (*str)
|
|
|
|
{
|
|
|
|
for (p = accept; *p; p++) if (*p == *str) return (LPWSTR)str;
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* wcsrchr (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
LPWSTR __cdecl NTDLL_wcsrchr( LPWSTR str, WCHAR ch )
|
|
|
|
{
|
|
|
|
LPWSTR last = NULL;
|
|
|
|
while (*str)
|
|
|
|
{
|
|
|
|
if (*str == ch) last = str;
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
return last;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* wcsspn (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
INT __cdecl NTDLL_wcsspn( LPCWSTR str, LPCWSTR accept )
|
|
|
|
{
|
|
|
|
LPCWSTR start = str;
|
|
|
|
while (*str)
|
|
|
|
{
|
|
|
|
LPCWSTR p = accept;
|
|
|
|
while (*p && (*p != *str)) p++;
|
|
|
|
if (!*p) break;
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
return str - start;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* wcsstr (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
LPWSTR __cdecl NTDLL_wcsstr( LPCWSTR str, LPCWSTR sub )
|
|
|
|
{
|
|
|
|
return strstrW( str, sub );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* wcstok (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
LPWSTR __cdecl NTDLL_wcstok( LPWSTR str, LPCWSTR delim )
|
|
|
|
{
|
|
|
|
static LPWSTR next = NULL;
|
|
|
|
LPWSTR ret;
|
|
|
|
|
|
|
|
if (!str)
|
|
|
|
if (!(str = next)) return NULL;
|
|
|
|
|
|
|
|
while (*str && NTDLL_wcschr( delim, *str )) str++;
|
|
|
|
if (!*str) return NULL;
|
|
|
|
ret = str++;
|
|
|
|
while (*str && !NTDLL_wcschr( delim, *str )) str++;
|
|
|
|
if (*str) *str++ = 0;
|
|
|
|
next = str;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* wcstombs (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
INT __cdecl NTDLL_wcstombs( LPSTR dst, LPCWSTR src, INT n )
|
|
|
|
{
|
2001-12-05 22:14:57 +00:00
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
if (!dst)
|
|
|
|
{
|
|
|
|
RtlUnicodeToMultiByteSize( &len, src, strlenW(src)*sizeof(WCHAR) );
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (n <= 0) return 0;
|
|
|
|
RtlUnicodeToMultiByteN( dst, n, &len, src, strlenW(src)*sizeof(WCHAR) );
|
|
|
|
if (len < n) dst[len] = 0;
|
|
|
|
}
|
|
|
|
return len;
|
2000-06-23 16:16:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* mbstowcs (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
INT __cdecl NTDLL_mbstowcs( LPWSTR dst, LPCSTR src, INT n )
|
|
|
|
{
|
2001-12-05 22:14:57 +00:00
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
if (!dst)
|
|
|
|
{
|
|
|
|
RtlMultiByteToUnicodeSize( &len, src, strlen(src) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (n <= 0) return 0;
|
|
|
|
RtlMultiByteToUnicodeN( dst, n*sizeof(WCHAR), &len, src, strlen(src) );
|
|
|
|
if (len / sizeof(WCHAR) < n) dst[len / sizeof(WCHAR)] = 0;
|
|
|
|
}
|
|
|
|
return len / sizeof(WCHAR);
|
2000-06-23 16:16:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* wcstol (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
2002-05-16 18:58:47 +00:00
|
|
|
long __cdecl NTDLL_wcstol(LPCWSTR s,LPWSTR *end,INT base)
|
2000-06-23 16:16:30 +00:00
|
|
|
{
|
2002-05-16 18:58:47 +00:00
|
|
|
return strtolW( s, end, base );
|
2000-06-23 16:16:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-22 18:58:21 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* wcstoul (NTDLL.@)
|
|
|
|
*/
|
2002-05-16 18:58:47 +00:00
|
|
|
unsigned long __cdecl NTDLL_wcstoul(LPCWSTR s,LPWSTR *end,INT base)
|
2001-10-22 18:58:21 +00:00
|
|
|
{
|
2002-05-16 18:58:47 +00:00
|
|
|
return strtoulW( s, end, base );
|
2001-10-22 18:58:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-23 16:16:30 +00:00
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* iswctype (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
INT __cdecl NTDLL_iswctype( WCHAR wc, WCHAR wct )
|
|
|
|
{
|
2000-08-11 20:53:40 +00:00
|
|
|
return (get_char_typeW(wc) & 0xfff) & wct;
|
2000-06-23 16:16:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* iswalpha (NTDLL.@)
|
2000-06-23 16:16:30 +00:00
|
|
|
*/
|
|
|
|
INT __cdecl NTDLL_iswalpha( WCHAR wc )
|
|
|
|
{
|
2000-08-11 20:53:40 +00:00
|
|
|
return get_char_typeW(wc) & C1_ALPHA;
|
2000-06-23 16:16:30 +00:00
|
|
|
}
|
2000-12-13 21:28:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* _ultow (NTDLL.@)
|
2000-12-13 21:28:15 +00:00
|
|
|
* Like _ultoa, but for wide character strings.
|
|
|
|
*/
|
|
|
|
LPWSTR __cdecl _ultow(ULONG value, LPWSTR string, INT radix)
|
|
|
|
{
|
|
|
|
WCHAR tmp[33];
|
|
|
|
LPWSTR tp = tmp;
|
|
|
|
LPWSTR sp;
|
|
|
|
LONG i;
|
|
|
|
ULONG v = value;
|
|
|
|
|
|
|
|
if (radix > 36 || radix <= 1)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
while (v || tp == tmp)
|
|
|
|
{
|
|
|
|
i = v % radix;
|
|
|
|
v = v / radix;
|
|
|
|
if (i < 10)
|
|
|
|
*tp++ = i + '0';
|
|
|
|
else
|
|
|
|
*tp++ = i + 'a' - 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
sp = string;
|
|
|
|
while (tp > tmp)
|
|
|
|
*sp++ = *--tp;
|
|
|
|
*sp = 0;
|
|
|
|
return string;
|
|
|
|
}
|
2001-01-22 02:17:29 +00:00
|
|
|
|
2001-04-16 20:24:47 +00:00
|
|
|
/*********************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* _wtol (NTDLL.@)
|
2001-04-16 20:24:47 +00:00
|
|
|
* Like atol, but for wide character strings.
|
|
|
|
*/
|
2002-05-16 18:58:47 +00:00
|
|
|
LONG __cdecl NTDLL__wtol(LPWSTR string)
|
2001-04-16 20:24:47 +00:00
|
|
|
{
|
2002-05-16 18:58:47 +00:00
|
|
|
return strtolW( string, NULL, 10 );
|
2001-04-16 20:24:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* _wtoi (NTDLL.@)
|
2001-04-16 20:24:47 +00:00
|
|
|
*/
|
2002-05-16 18:58:47 +00:00
|
|
|
INT __cdecl NTDLL__wtoi(LPWSTR string)
|
2001-04-16 20:24:47 +00:00
|
|
|
{
|
2002-05-16 18:58:47 +00:00
|
|
|
return NTDLL__wtol(string);
|
2001-04-16 20:24:47 +00:00
|
|
|
}
|
2001-01-22 02:17:29 +00:00
|
|
|
|
|
|
|
/* INTERNAL: Wide char snprintf
|
|
|
|
* If you fix a bug in this function, fix it in msvcrt/wcs.c also!
|
|
|
|
*/
|
|
|
|
static int __cdecl NTDLL_vsnwprintf(WCHAR *str, unsigned int len,
|
|
|
|
const WCHAR *format, va_list valist)
|
|
|
|
{
|
|
|
|
unsigned int written = 0;
|
|
|
|
const WCHAR *iter = format;
|
|
|
|
char bufa[256], fmtbufa[64], *fmta;
|
|
|
|
|
|
|
|
TRACE("(%d,%s)\n",len,debugstr_w(format));
|
|
|
|
|
|
|
|
while (*iter)
|
|
|
|
{
|
|
|
|
while (*iter && *iter != (WCHAR)L'%')
|
|
|
|
{
|
|
|
|
if (written++ >= len)
|
|
|
|
return -1;
|
|
|
|
*str++ = *iter++;
|
|
|
|
}
|
|
|
|
if (*iter == (WCHAR)L'%')
|
|
|
|
{
|
|
|
|
fmta = fmtbufa;
|
|
|
|
*fmta++ = *iter++;
|
|
|
|
while (*iter == (WCHAR)L'0' ||
|
|
|
|
*iter == (WCHAR)L'+' ||
|
|
|
|
*iter == (WCHAR)L'-' ||
|
|
|
|
*iter == (WCHAR)L' ' ||
|
|
|
|
*iter == (WCHAR)L'0' ||
|
|
|
|
*iter == (WCHAR)L'*' ||
|
|
|
|
*iter == (WCHAR)L'#')
|
|
|
|
{
|
|
|
|
if (*iter == (WCHAR)L'*')
|
|
|
|
{
|
|
|
|
char *buffiter = bufa;
|
|
|
|
int fieldlen = va_arg(valist, int);
|
|
|
|
sprintf(buffiter, "%d", fieldlen);
|
|
|
|
while (*buffiter)
|
|
|
|
*fmta++ = *buffiter++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*fmta++ = *iter;
|
|
|
|
iter++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (isdigit(*iter))
|
|
|
|
*fmta++ = *iter++;
|
|
|
|
|
|
|
|
if (*iter == (WCHAR)L'.')
|
|
|
|
{
|
|
|
|
*fmta++ = *iter++;
|
|
|
|
if (*iter == (WCHAR)L'*')
|
|
|
|
{
|
|
|
|
char *buffiter = bufa;
|
|
|
|
int fieldlen = va_arg(valist, int);
|
|
|
|
sprintf(buffiter, "%d", fieldlen);
|
|
|
|
while (*buffiter)
|
|
|
|
*fmta++ = *buffiter++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
while (isdigit(*iter))
|
|
|
|
*fmta++ = *iter++;
|
|
|
|
}
|
|
|
|
if (*iter == (WCHAR)L'h' ||
|
|
|
|
*iter == (WCHAR)L'l')
|
|
|
|
*fmta++ = *iter++;
|
|
|
|
|
|
|
|
switch (*iter)
|
|
|
|
{
|
|
|
|
case (WCHAR)L's':
|
|
|
|
{
|
|
|
|
static const WCHAR none[] = { '(', 'n', 'u', 'l', 'l', ')', 0 };
|
|
|
|
const WCHAR *wstr = va_arg(valist, const WCHAR *);
|
|
|
|
const WCHAR *striter = wstr ? wstr : none;
|
|
|
|
while (*striter)
|
|
|
|
{
|
|
|
|
if (written++ >= len)
|
|
|
|
return -1;
|
|
|
|
*str++ = *striter++;
|
|
|
|
}
|
|
|
|
iter++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case (WCHAR)L'c':
|
|
|
|
if (written++ >= len)
|
|
|
|
return -1;
|
2001-01-22 19:26:42 +00:00
|
|
|
*str++ = (WCHAR)va_arg(valist, int);
|
2001-01-22 02:17:29 +00:00
|
|
|
iter++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
/* For non wc types, use system sprintf and append to wide char output */
|
|
|
|
/* FIXME: for unrecognised types, should ignore % when printing */
|
|
|
|
char *bufaiter = bufa;
|
|
|
|
if (*iter == (WCHAR)L'p')
|
|
|
|
sprintf(bufaiter, "%08lX", va_arg(valist, long));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*fmta++ = *iter;
|
|
|
|
*fmta = '\0';
|
2001-04-16 19:00:42 +00:00
|
|
|
if (*iter == (WCHAR)L'f')
|
|
|
|
sprintf(bufaiter, fmtbufa, va_arg(valist, double));
|
|
|
|
else
|
|
|
|
sprintf(bufaiter, fmtbufa, va_arg(valist, void *));
|
2001-01-22 02:17:29 +00:00
|
|
|
}
|
|
|
|
while (*bufaiter)
|
|
|
|
{
|
|
|
|
if (written++ >= len)
|
|
|
|
return -1;
|
|
|
|
*str++ = *bufaiter++;
|
|
|
|
}
|
|
|
|
iter++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (written >= len)
|
|
|
|
return -1;
|
|
|
|
*str++ = (WCHAR)L'\0';
|
|
|
|
return (int)written;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* _snwprintf (NTDLL.@)
|
2001-01-22 02:17:29 +00:00
|
|
|
*/
|
|
|
|
int __cdecl _snwprintf(WCHAR *str, unsigned int len, const WCHAR *format, ...)
|
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
va_list valist;
|
|
|
|
va_start(valist, format);
|
|
|
|
retval = NTDLL_vsnwprintf(str, len, format, valist);
|
|
|
|
va_end(valist);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* swprintf (NTDLL.@)
|
2001-01-22 02:17:29 +00:00
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_swprintf(WCHAR *str, const WCHAR *format, ...)
|
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
va_list valist;
|
|
|
|
va_start(valist, format);
|
|
|
|
retval = NTDLL_vsnwprintf(str, INT_MAX, format, valist);
|
|
|
|
va_end(valist);
|
|
|
|
return retval;
|
|
|
|
}
|