mmdevapi: Indicate data flow direction in IMMDevice::GetId result.
[wine.git] / dlls / msvcrt / wcs.c
blobb6786cef421abd0852dc88cfadc0af273164a095
1 /*
2 * msvcrt.dll wide-char functions
4 * Copyright 1999 Alexandre Julliard
5 * Copyright 2000 Jon Griffiths
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <limits.h>
25 #include <stdio.h>
26 #include <math.h>
27 #include <assert.h>
28 #include "msvcrt.h"
29 #include "winnls.h"
30 #include "wtypes.h"
31 #include "wine/unicode.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
36 static BOOL n_format_enabled = TRUE;
38 #include "printf.h"
39 #define PRINTF_WIDE
40 #include "printf.h"
41 #undef PRINTF_WIDE
43 /* _get_printf_count_output - not exported in native msvcrt */
44 int CDECL MSVCRT__get_printf_count_output( void )
46 return n_format_enabled ? 1 : 0;
49 /* _set_printf_count_output - not exported in native msvcrt */
50 int CDECL MSVCRT__set_printf_count_output( int enable )
52 BOOL old = n_format_enabled;
53 n_format_enabled = (enable ? TRUE : FALSE);
54 return old ? 1 : 0;
57 /*********************************************************************
58 * _wcsdup (MSVCRT.@)
60 MSVCRT_wchar_t* CDECL MSVCRT__wcsdup( const MSVCRT_wchar_t* str )
62 MSVCRT_wchar_t* ret = NULL;
63 if (str)
65 int size = (strlenW(str) + 1) * sizeof(MSVCRT_wchar_t);
66 ret = MSVCRT_malloc( size );
67 if (ret) memcpy( ret, str, size );
69 return ret;
72 /*********************************************************************
73 * _wcsicoll (MSVCRT.@)
75 INT CDECL MSVCRT__wcsicoll( const MSVCRT_wchar_t* str1, const MSVCRT_wchar_t* str2 )
77 /* FIXME: handle collates */
78 return strcmpiW( str1, str2 );
81 /*********************************************************************
82 * _wcsnicoll (MSVCRT.@)
84 INT CDECL MSVCRT__wcsnicoll( const MSVCRT_wchar_t* str1, const MSVCRT_wchar_t* str2, MSVCRT_size_t count )
86 /* FIXME: handle collates */
87 return strncmpiW( str1, str2, count );
90 /*********************************************************************
91 * _wcsnset (MSVCRT.@)
93 MSVCRT_wchar_t* CDECL MSVCRT__wcsnset( MSVCRT_wchar_t* str, MSVCRT_wchar_t c, MSVCRT_size_t n )
95 MSVCRT_wchar_t* ret = str;
96 while ((n-- > 0) && *str) *str++ = c;
97 return ret;
100 /*********************************************************************
101 * _wcsrev (MSVCRT.@)
103 MSVCRT_wchar_t* CDECL MSVCRT__wcsrev( MSVCRT_wchar_t* str )
105 MSVCRT_wchar_t* ret = str;
106 MSVCRT_wchar_t* end = str + strlenW(str) - 1;
107 while (end > str)
109 MSVCRT_wchar_t t = *end;
110 *end-- = *str;
111 *str++ = t;
113 return ret;
116 /*********************************************************************
117 * _wcsset (MSVCRT.@)
119 MSVCRT_wchar_t* CDECL MSVCRT__wcsset( MSVCRT_wchar_t* str, MSVCRT_wchar_t c )
121 MSVCRT_wchar_t* ret = str;
122 while (*str) *str++ = c;
123 return ret;
126 /******************************************************************
127 * _wcsupr_s_l (MSVCRT.@)
129 int CDECL MSVCRT__wcsupr_s_l( MSVCRT_wchar_t* str, MSVCRT_size_t n,
130 MSVCRT__locale_t locale )
132 MSVCRT_wchar_t* ptr = str;
134 if (!str || !n)
136 if (str) *str = '\0';
137 *MSVCRT__errno() = MSVCRT_EINVAL;
138 return MSVCRT_EINVAL;
141 while (n--)
143 if (!*ptr) return 0;
144 /* FIXME: add locale support */
145 *ptr = toupperW(*ptr);
146 ptr++;
149 /* MSDN claims that the function should return and set errno to
150 * ERANGE, which doesn't seem to be true based on the tests. */
151 *str = '\0';
152 *MSVCRT__errno() = MSVCRT_EINVAL;
153 return MSVCRT_EINVAL;
156 /******************************************************************
157 * _wcsupr_s (MSVCRT.@)
160 INT CDECL MSVCRT__wcsupr_s( MSVCRT_wchar_t* str, MSVCRT_size_t n )
162 return MSVCRT__wcsupr_s_l( str, n, NULL );
165 /******************************************************************
166 * _wcslwr_s (MSVCRT.@)
168 int CDECL MSVCRT__wcslwr_s( MSVCRT_wchar_t* str, MSVCRT_size_t n )
170 MSVCRT_wchar_t* ptr = str;
172 if (!str || !n)
174 if (str) *str = '\0';
175 *MSVCRT__errno() = MSVCRT_EINVAL;
176 return MSVCRT_EINVAL;
179 while (n--)
181 if (!*ptr) return 0;
182 *ptr = tolowerW(*ptr);
183 ptr++;
186 /* MSDN claims that the function should return and set errno to
187 * ERANGE, which doesn't seem to be true based on the tests. */
188 *str = '\0';
189 *MSVCRT__errno() = MSVCRT_EINVAL;
190 return MSVCRT_EINVAL;
193 /*********************************************************************
194 * _wcstod_l - not exported in native msvcrt
196 double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
197 MSVCRT__locale_t locale)
199 MSVCRT_pthreadlocinfo locinfo;
200 unsigned __int64 d=0, hlp;
201 unsigned fpcontrol;
202 int exp=0, sign=1;
203 const MSVCRT_wchar_t *p;
204 double ret;
205 BOOL found_digit = FALSE;
207 if (!MSVCRT_CHECK_PMT(str != NULL)) {
208 *MSVCRT__errno() = MSVCRT_EINVAL;
209 return 0;
212 if(!locale)
213 locinfo = get_locinfo();
214 else
215 locinfo = locale->locinfo;
217 p = str;
218 while(isspaceW(*p))
219 p++;
221 if(*p == '-') {
222 sign = -1;
223 p++;
224 } else if(*p == '+')
225 p++;
227 while(isdigitW(*p)) {
228 found_digit = TRUE;
229 hlp = d*10+*(p++)-'0';
230 if(d>MSVCRT_UI64_MAX/10 || hlp<d) {
231 exp++;
232 break;
233 } else
234 d = hlp;
236 while(isdigitW(*p)) {
237 exp++;
238 p++;
240 if(*p == *locinfo->lconv->decimal_point)
241 p++;
243 while(isdigitW(*p)) {
244 found_digit = TRUE;
245 hlp = d*10+*(p++)-'0';
246 if(d>MSVCRT_UI64_MAX/10 || hlp<d)
247 break;
249 d = hlp;
250 exp--;
252 while(isdigitW(*p))
253 p++;
255 if(!found_digit) {
256 if(end)
257 *end = (MSVCRT_wchar_t*)str;
258 return 0.0;
261 if(*p=='e' || *p=='E' || *p=='d' || *p=='D') {
262 int e=0, s=1;
264 p++;
265 if(*p == '-') {
266 s = -1;
267 p++;
268 } else if(*p == '+')
269 p++;
271 if(isdigitW(*p)) {
272 while(isdigitW(*p)) {
273 if(e>INT_MAX/10 || (e=e*10+*p-'0')<0)
274 e = INT_MAX;
275 p++;
277 e *= s;
279 if(exp<0 && e<0 && exp+e>=0) exp = INT_MIN;
280 else if(exp>0 && e>0 && exp+e<0) exp = INT_MAX;
281 else exp += e;
282 } else {
283 if(*p=='-' || *p=='+')
284 p--;
285 p--;
289 fpcontrol = _control87(0, 0);
290 _control87(MSVCRT__EM_DENORMAL|MSVCRT__EM_INVALID|MSVCRT__EM_ZERODIVIDE
291 |MSVCRT__EM_OVERFLOW|MSVCRT__EM_UNDERFLOW|MSVCRT__EM_INEXACT, 0xffffffff);
293 if(exp>0)
294 ret = (double)sign*d*pow(10, exp);
295 else
296 ret = (double)sign*d/pow(10, -exp);
298 _control87(fpcontrol, 0xffffffff);
300 if((d && ret==0.0) || isinf(ret))
301 *MSVCRT__errno() = MSVCRT_ERANGE;
303 if(end)
304 *end = (MSVCRT_wchar_t*)p;
306 return ret;
309 /*********************************************************************
310 * wcsrtombs_l (INTERNAL)
312 static MSVCRT_size_t CDECL MSVCRT_wcsrtombs_l(char *mbstr, const MSVCRT_wchar_t **wcstr,
313 MSVCRT_size_t count, MSVCRT__locale_t locale)
315 MSVCRT_pthreadlocinfo locinfo;
316 MSVCRT_size_t tmp = 0;
317 BOOL used_default;
319 if(!locale)
320 locinfo = get_locinfo();
321 else
322 locinfo = locale->locinfo;
324 if(!mbstr) {
325 tmp = WideCharToMultiByte(locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
326 *wcstr, -1, NULL, 0, NULL, &used_default)-1;
327 if(used_default)
328 return -1;
329 return tmp;
332 while(**wcstr) {
333 char buf[3];
334 MSVCRT_size_t i, size;
336 size = WideCharToMultiByte(locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
337 *wcstr, 1, buf, 3, NULL, &used_default);
338 if(used_default)
339 return -1;
340 if(tmp+size > count)
341 return tmp;
343 for(i=0; i<size; i++)
344 mbstr[tmp++] = buf[i];
345 (*wcstr)++;
348 if(tmp < count) {
349 mbstr[tmp] = '\0';
350 *wcstr = NULL;
352 return tmp;
355 /*********************************************************************
356 * _wcstombs_l (MSVCRT.@)
358 MSVCRT_size_t CDECL MSVCRT__wcstombs_l(char *mbstr, const MSVCRT_wchar_t *wcstr,
359 MSVCRT_size_t count, MSVCRT__locale_t locale)
361 return MSVCRT_wcsrtombs_l(mbstr, &wcstr, count, locale);
364 /*********************************************************************
365 * wcstombs (MSVCRT.@)
367 MSVCRT_size_t CDECL MSVCRT_wcstombs(char *mbstr, const MSVCRT_wchar_t *wcstr,
368 MSVCRT_size_t count)
370 return MSVCRT_wcsrtombs_l(mbstr, &wcstr, count, NULL);
373 /*********************************************************************
374 * wcsrtombs (MSVCRT.@)
376 MSVCRT_size_t CDECL MSVCRT_wcsrtombs(char *mbstr, const MSVCRT_wchar_t **wcstr,
377 MSVCRT_size_t count, MSVCRT_mbstate_t *mbstate)
379 if(mbstate)
380 *mbstate = 0;
382 return MSVCRT_wcsrtombs_l(mbstr, wcstr, count, NULL);
385 /*********************************************************************
386 * MSVCRT_wcsrtombs_s_l (INTERNAL)
388 static int MSVCRT_wcsrtombs_s_l(MSVCRT_size_t *ret, char *mbstr,
389 MSVCRT_size_t size, const MSVCRT_wchar_t **wcstr,
390 MSVCRT_size_t count, MSVCRT__locale_t locale)
392 MSVCRT_size_t conv;
394 if(!mbstr && !size && wcstr) {
395 conv = MSVCRT_wcsrtombs_l(NULL, wcstr, 0, locale);
396 if(ret)
397 *ret = conv+1;
398 return 0;
401 if (!MSVCRT_CHECK_PMT(wcstr != NULL) || !MSVCRT_CHECK_PMT(*wcstr != NULL)
402 || !MSVCRT_CHECK_PMT(mbstr != NULL)) {
403 if(mbstr && size)
404 mbstr[0] = '\0';
405 *MSVCRT__errno() = MSVCRT_EINVAL;
406 return MSVCRT_EINVAL;
409 if(count==MSVCRT__TRUNCATE || size<count)
410 conv = size;
411 else
412 conv = count;
414 conv = MSVCRT_wcsrtombs_l(mbstr, wcstr, conv, locale);
415 if(conv<size)
416 mbstr[conv++] = '\0';
417 else if(conv==size && (count==MSVCRT__TRUNCATE || mbstr[conv-1]=='\0'))
418 mbstr[conv-1] = '\0';
419 else {
420 MSVCRT_INVALID_PMT("mbstr[size] is too small");
421 if(size)
422 mbstr[0] = '\0';
423 *MSVCRT__errno() = MSVCRT_ERANGE;
424 return MSVCRT_ERANGE;
427 if(ret)
428 *ret = conv;
429 return 0;
432 /*********************************************************************
433 * _wcstombs_s_l (MSVCRT.@)
435 int CDECL MSVCRT__wcstombs_s_l(MSVCRT_size_t *ret, char *mbstr,
436 MSVCRT_size_t size, const MSVCRT_wchar_t *wcstr,
437 MSVCRT_size_t count, MSVCRT__locale_t locale)
439 return MSVCRT_wcsrtombs_s_l(ret, mbstr, size, &wcstr,count, locale);
442 /*********************************************************************
443 * wcstombs_s (MSVCRT.@)
445 int CDECL MSVCRT_wcstombs_s(MSVCRT_size_t *ret, char *mbstr,
446 MSVCRT_size_t size, const MSVCRT_wchar_t *wcstr, MSVCRT_size_t count)
448 return MSVCRT_wcsrtombs_s_l(ret, mbstr, size, &wcstr, count, NULL);
451 /*********************************************************************
452 * wcsrtombs_s (MSVCRT.@)
454 int CDECL MSVCRT_wcsrtombs_s(MSVCRT_size_t *ret, char *mbstr, MSVCRT_size_t size,
455 const MSVCRT_wchar_t **wcstr, MSVCRT_size_t count, MSVCRT_mbstate_t *mbstate)
457 if(mbstate)
458 *mbstate = 0;
460 return MSVCRT_wcsrtombs_s_l(ret, mbstr, size, wcstr, count, NULL);
463 /*********************************************************************
464 * wcstod (MSVCRT.@)
466 double CDECL MSVCRT_wcstod(const MSVCRT_wchar_t* lpszStr, MSVCRT_wchar_t** end)
468 return MSVCRT__wcstod_l(lpszStr, end, NULL);
471 /*********************************************************************
472 * _wtof (MSVCRT.@)
474 double CDECL MSVCRT__wtof(const MSVCRT_wchar_t *str)
476 return MSVCRT__wcstod_l(str, NULL, NULL);
479 /*********************************************************************
480 * _wtof_l (MSVCRT.@)
482 double CDECL MSVCRT__wtof_l(const MSVCRT_wchar_t *str, MSVCRT__locale_t locale)
484 return MSVCRT__wcstod_l(str, NULL, locale);
487 /*********************************************************************
488 * arg_clbk_valist (INTERNAL)
490 printf_arg arg_clbk_valist(void *ctx, int arg_pos, int type, __ms_va_list *valist)
492 printf_arg ret;
494 if(type == VT_I8)
495 ret.get_longlong = va_arg(*valist, LONGLONG);
496 else if(type == VT_INT)
497 ret.get_int = va_arg(*valist, int);
498 else if(type == VT_R8)
499 ret.get_double = va_arg(*valist, double);
500 else if(type == VT_PTR)
501 ret.get_ptr = va_arg(*valist, void*);
502 else {
503 ERR("Incorrect type\n");
504 ret.get_int = 0;
507 return ret;
510 /*********************************************************************
511 * arg_clbk_positional (INTERNAL)
513 static printf_arg arg_clbk_positional(void *ctx, int pos, int type, __ms_va_list *valist)
515 printf_arg *args = ctx;
516 return args[pos];
519 /*********************************************************************
520 * _vsnprintf (MSVCRT.@)
522 int CDECL MSVCRT_vsnprintf( char *str, MSVCRT_size_t len,
523 const char *format, __ms_va_list valist )
525 static const char nullbyte = '\0';
526 struct _str_ctx_a ctx = {len, str};
527 int ret;
529 ret = pf_printf_a(puts_clbk_str_a, &ctx, format, NULL, FALSE, FALSE,
530 arg_clbk_valist, NULL, &valist);
531 puts_clbk_str_a(&ctx, 1, &nullbyte);
532 return ret;
535 /*********************************************************************
536 * _vsnprintf_l (MSVCRT.@)
538 int CDECL MSVCRT_vsnprintf_l( char *str, MSVCRT_size_t len, const char *format,
539 MSVCRT__locale_t locale, __ms_va_list valist )
541 static const char nullbyte = '\0';
542 struct _str_ctx_a ctx = {len, str};
543 int ret;
545 ret = pf_printf_a(puts_clbk_str_a, &ctx, format, locale, FALSE, FALSE,
546 arg_clbk_valist, NULL, &valist);
547 puts_clbk_str_a(&ctx, 1, &nullbyte);
548 return ret;
551 /*********************************************************************
552 * _vsnprintf_s_l (MSVCRT.@)
554 int CDECL MSVCRT_vsnprintf_s_l( char *str, MSVCRT_size_t sizeOfBuffer,
555 MSVCRT_size_t count, const char *format,
556 MSVCRT__locale_t locale, __ms_va_list valist )
558 static const char nullbyte = '\0';
559 struct _str_ctx_a ctx;
560 int len, ret;
562 if(sizeOfBuffer<count+1 || count==-1)
563 len = sizeOfBuffer;
564 else
565 len = count+1;
567 ctx.len = len;
568 ctx.buf = str;
569 ret = pf_printf_a(puts_clbk_str_a, &ctx, format, locale, FALSE, TRUE,
570 arg_clbk_valist, NULL, &valist);
571 puts_clbk_str_a(&ctx, 1, &nullbyte);
573 if(ret<0 || ret==len) {
574 if(count!=MSVCRT__TRUNCATE && count>sizeOfBuffer) {
575 MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small");
576 *MSVCRT__errno() = MSVCRT_ERANGE;
577 memset(str, 0, sizeOfBuffer);
578 } else
579 str[len-1] = '\0';
581 return -1;
584 return ret;
587 /*********************************************************************
588 * _vsnprintf_s (MSVCRT.@)
590 int CDECL MSVCRT_vsnprintf_s( char *str, MSVCRT_size_t sizeOfBuffer,
591 MSVCRT_size_t count, const char *format, __ms_va_list valist )
593 return MSVCRT_vsnprintf_s_l(str,sizeOfBuffer, count, format, NULL, valist);
596 /*********************************************************************
597 * vsprintf (MSVCRT.@)
599 int CDECL MSVCRT_vsprintf( char *str, const char *format, __ms_va_list valist)
601 return MSVCRT_vsnprintf(str, INT_MAX, format, valist);
604 /*********************************************************************
605 * vsprintf_s (MSVCRT.@)
607 int CDECL MSVCRT_vsprintf_s( char *str, MSVCRT_size_t num, const char *format, __ms_va_list valist)
609 return MSVCRT_vsnprintf(str, num, format, valist);
612 /*********************************************************************
613 * _vscprintf (MSVCRT.@)
615 int CDECL MSVCRT__vscprintf( const char *format, __ms_va_list valist )
617 return MSVCRT_vsnprintf( NULL, INT_MAX, format, valist );
620 /*********************************************************************
621 * _snprintf (MSVCRT.@)
623 int CDECL MSVCRT__snprintf(char *str, unsigned int len, const char *format, ...)
625 int retval;
626 __ms_va_list valist;
627 __ms_va_start(valist, format);
628 retval = MSVCRT_vsnprintf(str, len, format, valist);
629 __ms_va_end(valist);
630 return retval;
633 /*********************************************************************
634 * _snprintf_s (MSVCRT.@)
636 int CDECL MSVCRT__snprintf_s(char *str, unsigned int len, unsigned int count,
637 const char *format, ...)
639 int retval;
640 __ms_va_list valist;
641 __ms_va_start(valist, format);
642 retval = MSVCRT_vsnprintf_s_l(str, len, count, format, NULL, valist);
643 __ms_va_end(valist);
644 return retval;
647 /*********************************************************************
648 * _scprintf (MSVCRT.@)
650 int CDECL MSVCRT__scprintf(const char *format, ...)
652 int retval;
653 __ms_va_list valist;
654 __ms_va_start(valist, format);
655 retval = MSVCRT__vscprintf(format, valist);
656 __ms_va_end(valist);
657 return retval;
660 /*********************************************************************
661 * _vsnwprintf (MSVCRT.@)
663 int CDECL MSVCRT_vsnwprintf(MSVCRT_wchar_t *str, MSVCRT_size_t len,
664 const MSVCRT_wchar_t *format, __ms_va_list valist)
666 static const MSVCRT_wchar_t nullbyte = '\0';
667 struct _str_ctx_w ctx = {len, str};
668 int ret;
670 ret = pf_printf_w(puts_clbk_str_w, &ctx, format, NULL, FALSE, FALSE,
671 arg_clbk_valist, NULL, &valist);
672 puts_clbk_str_w(&ctx, 1, &nullbyte);
673 return ret;
676 /*********************************************************************
677 * _vsnwprintf_l (MSVCRT.@)
679 int CDECL MSVCRT_vsnwprintf_l(MSVCRT_wchar_t *str, MSVCRT_size_t len,
680 const MSVCRT_wchar_t *format, MSVCRT__locale_t locale,
681 __ms_va_list valist)
683 static const MSVCRT_wchar_t nullbyte = '\0';
684 struct _str_ctx_w ctx = {len, str};
685 int ret;
687 ret = pf_printf_w(puts_clbk_str_w, &ctx, format, locale, FALSE, FALSE,
688 arg_clbk_valist, NULL, &valist);
689 puts_clbk_str_w(&ctx, 1, &nullbyte);
690 return ret;
693 /*********************************************************************
694 * _vswprintf_p_l (MSVCRT.@)
696 int CDECL MSVCRT_vswprintf_p_l(MSVCRT_wchar_t *buffer, MSVCRT_size_t length,
697 const MSVCRT_wchar_t *format, MSVCRT__locale_t locale, __ms_va_list args)
699 static const MSVCRT_wchar_t nullbyte = '\0';
700 printf_arg args_ctx[MSVCRT__ARGMAX+1];
701 struct _str_ctx_w puts_ctx = {length, buffer};
702 int ret;
704 memset(args_ctx, 0, sizeof(args_ctx));
706 ret = create_positional_ctx_w(args_ctx, format, args);
707 if(ret < 0) {
708 MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
709 *MSVCRT__errno() = MSVCRT_EINVAL;
710 return ret;
711 } else if(ret == 0)
712 ret = pf_printf_w(puts_clbk_str_w, &puts_ctx, format, locale, FALSE, TRUE,
713 arg_clbk_valist, NULL, &args);
714 else
715 ret = pf_printf_w(puts_clbk_str_w, &puts_ctx, format, locale, TRUE, TRUE,
716 arg_clbk_positional, args_ctx, NULL);
718 puts_clbk_str_w(&puts_ctx, 1, &nullbyte);
719 return ret;
722 /*********************************************************************
723 * _vsnwprintf_s_l (MSVCRT.@)
725 int CDECL MSVCRT_vsnwprintf_s_l( MSVCRT_wchar_t *str, MSVCRT_size_t sizeOfBuffer,
726 MSVCRT_size_t count, const MSVCRT_wchar_t *format,
727 MSVCRT__locale_t locale, __ms_va_list valist)
729 static const MSVCRT_wchar_t nullbyte = '\0';
730 struct _str_ctx_w ctx;
731 int len, ret;
733 len = sizeOfBuffer;
734 if(count!=-1 && len>count+1)
735 len = count+1;
737 ctx.len = len;
738 ctx.buf = str;
739 ret = pf_printf_w(puts_clbk_str_w, &ctx, format, locale, FALSE, TRUE,
740 arg_clbk_valist, NULL, &valist);
741 puts_clbk_str_w(&ctx, 1, &nullbyte);
743 if(ret<0 || ret==len) {
744 if(count!=MSVCRT__TRUNCATE && count>sizeOfBuffer) {
745 MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small");
746 *MSVCRT__errno() = MSVCRT_ERANGE;
747 memset(str, 0, sizeOfBuffer*sizeof(MSVCRT_wchar_t));
748 } else
749 str[len-1] = '\0';
751 return -1;
754 return ret;
757 /*********************************************************************
758 * _vsnwprintf_s (MSVCRT.@)
760 int CDECL MSVCRT_vsnwprintf_s(MSVCRT_wchar_t *str, MSVCRT_size_t sizeOfBuffer,
761 MSVCRT_size_t count, const MSVCRT_wchar_t *format, __ms_va_list valist)
763 return MSVCRT_vsnwprintf_s_l(str, sizeOfBuffer, count,
764 format, NULL, valist);
767 /*********************************************************************
768 * _snwprintf (MSVCRT.@)
770 int CDECL MSVCRT__snwprintf( MSVCRT_wchar_t *str, unsigned int len, const MSVCRT_wchar_t *format, ...)
772 int retval;
773 __ms_va_list valist;
774 __ms_va_start(valist, format);
775 retval = MSVCRT_vsnwprintf(str, len, format, valist);
776 __ms_va_end(valist);
777 return retval;
780 /*********************************************************************
781 * _snwprintf_l (MSVCRT.@)
783 int CDECL MSVCRT__snwprintf_l( MSVCRT_wchar_t *str, unsigned int len, const MSVCRT_wchar_t *format,
784 MSVCRT__locale_t locale, ...)
786 int retval;
787 __ms_va_list valist;
788 __ms_va_start(valist, locale);
789 retval = MSVCRT_vsnwprintf_l(str, len, format, locale, valist);
790 __ms_va_end(valist);
791 return retval;
794 /*********************************************************************
795 * _snwprintf_s (MSVCRT.@)
797 int CDECL MSVCRT__snwprintf_s( MSVCRT_wchar_t *str, unsigned int len, unsigned int count,
798 const MSVCRT_wchar_t *format, ...)
800 int retval;
801 __ms_va_list valist;
802 __ms_va_start(valist, format);
803 retval = MSVCRT_vsnwprintf_s_l(str, len, count, format, NULL, valist);
804 __ms_va_end(valist);
805 return retval;
808 /*********************************************************************
809 * sprintf (MSVCRT.@)
811 int CDECL MSVCRT_sprintf( char *str, const char *format, ... )
813 __ms_va_list ap;
814 int r;
816 __ms_va_start( ap, format );
817 r = MSVCRT_vsnprintf( str, INT_MAX, format, ap );
818 __ms_va_end( ap );
819 return r;
822 /*********************************************************************
823 * sprintf_s (MSVCRT.@)
825 int CDECL MSVCRT_sprintf_s( char *str, MSVCRT_size_t num, const char *format, ... )
827 __ms_va_list ap;
828 int r;
830 __ms_va_start( ap, format );
831 r = MSVCRT_vsnprintf( str, num, format, ap );
832 __ms_va_end( ap );
833 return r;
836 /*********************************************************************
837 * _scwprintf (MSVCRT.@)
839 int CDECL MSVCRT__scwprintf( const MSVCRT_wchar_t *format, ... )
841 __ms_va_list ap;
842 int r;
844 __ms_va_start( ap, format );
845 r = MSVCRT_vsnwprintf( NULL, INT_MAX, format, ap );
846 __ms_va_end( ap );
847 return r;
850 /*********************************************************************
851 * swprintf (MSVCRT.@)
853 int CDECL MSVCRT_swprintf( MSVCRT_wchar_t *str, const MSVCRT_wchar_t *format, ... )
855 __ms_va_list ap;
856 int r;
858 __ms_va_start( ap, format );
859 r = MSVCRT_vsnwprintf( str, INT_MAX, format, ap );
860 __ms_va_end( ap );
861 return r;
864 /*********************************************************************
865 * swprintf_s (MSVCRT.@)
867 int CDECL MSVCRT_swprintf_s(MSVCRT_wchar_t *str, MSVCRT_size_t numberOfElements,
868 const MSVCRT_wchar_t *format, ... )
870 __ms_va_list ap;
871 int r;
873 __ms_va_start(ap, format);
874 r = MSVCRT_vsnwprintf_s(str, numberOfElements, INT_MAX, format, ap);
875 __ms_va_end(ap);
877 return r;
880 /*********************************************************************
881 * _vswprintf (MSVCRT.@)
883 int CDECL MSVCRT_vswprintf( MSVCRT_wchar_t* str, const MSVCRT_wchar_t* format, __ms_va_list args )
885 return MSVCRT_vsnwprintf( str, INT_MAX, format, args );
888 /*********************************************************************
889 * _vswprintf (MSVCRT.@)
891 int CDECL MSVCRT_vswprintf_l( MSVCRT_wchar_t* str, const MSVCRT_wchar_t* format,
892 MSVCRT__locale_t locale, __ms_va_list args )
894 return MSVCRT_vsnwprintf_l( str, INT_MAX, format, locale, args );
897 /*********************************************************************
898 * _vscwprintf (MSVCRT.@)
900 int CDECL MSVCRT__vscwprintf( const MSVCRT_wchar_t *format, __ms_va_list args )
902 return MSVCRT_vsnwprintf( NULL, INT_MAX, format, args );
905 /*********************************************************************
906 * _vscwprintf_l (MSVCRT.@)
908 int CDECL MSVCRT__vscwprintf_l( const MSVCRT_wchar_t *format, MSVCRT__locale_t locale, __ms_va_list args )
910 return MSVCRT_vsnwprintf_l( NULL, INT_MAX, format, locale, args );
913 /*********************************************************************
914 * _vscwprintf_p_l (MSVCRT.@)
916 int CDECL MSVCRT__vscwprintf_p_l( const MSVCRT_wchar_t *format, MSVCRT__locale_t locale, __ms_va_list args )
918 return MSVCRT_vswprintf_p_l( NULL, INT_MAX, format, locale, args );
921 /*********************************************************************
922 * vswprintf_s (MSVCRT.@)
924 int CDECL MSVCRT_vswprintf_s(MSVCRT_wchar_t* str, MSVCRT_size_t numberOfElements,
925 const MSVCRT_wchar_t* format, __ms_va_list args)
927 return MSVCRT_vsnwprintf_s(str, numberOfElements, INT_MAX, format, args );
930 /*********************************************************************
931 * _vswprintf_s_l (MSVCRT.@)
933 int CDECL MSVCRT_vswprintf_s_l(MSVCRT_wchar_t* str, MSVCRT_size_t numberOfElements,
934 const MSVCRT_wchar_t* format, MSVCRT__locale_t locale, __ms_va_list args)
936 return MSVCRT_vsnwprintf_s_l(str, numberOfElements, INT_MAX,
937 format, locale, args );
940 /*********************************************************************
941 * _vsprintf_p_l (MSVCRT.@)
943 int CDECL MSVCRT_vsprintf_p_l(char *buffer, MSVCRT_size_t length, const char *format,
944 MSVCRT__locale_t locale, __ms_va_list args)
946 static const char nullbyte = '\0';
947 printf_arg args_ctx[MSVCRT__ARGMAX+1];
948 struct _str_ctx_a puts_ctx = {length, buffer};
949 int ret;
951 memset(args_ctx, 0, sizeof(args_ctx));
953 ret = create_positional_ctx_a(args_ctx, format, args);
954 if(ret < 0) {
955 MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
956 *MSVCRT__errno() = MSVCRT_EINVAL;
957 return ret;
958 } else if(ret == 0)
959 ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale, FALSE, TRUE,
960 arg_clbk_valist, NULL, &args);
961 else
962 ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale, TRUE, TRUE,
963 arg_clbk_positional, args_ctx, NULL);
965 puts_clbk_str_a(&puts_ctx, 1, &nullbyte);
966 return ret;
969 /*********************************************************************
970 * _vsprintf_p (MSVCRT.@)
972 int CDECL MSVCRT_vsprintf_p(char *buffer, MSVCRT_size_t length,
973 const char *format, __ms_va_list args)
975 return MSVCRT_vsprintf_p_l(buffer, length, format, NULL, args);
978 /*********************************************************************
979 * _sprintf_p_l (MSVCRT.@)
981 int CDECL MSVCRT_sprintf_p_l(char *buffer, MSVCRT_size_t length,
982 const char *format, MSVCRT__locale_t locale, ...)
984 __ms_va_list valist;
985 int r;
987 __ms_va_start(valist, locale);
988 r = MSVCRT_vsprintf_p_l(buffer, length, format, locale, valist);
989 __ms_va_end(valist);
991 return r;
994 /*********************************************************************
995 * _swprintf_p_l (MSVCRT.@)
997 int CDECL MSVCRT_swprintf_p_l(MSVCRT_wchar_t *buffer, MSVCRT_size_t length,
998 const MSVCRT_wchar_t *format, MSVCRT__locale_t locale, ...)
1000 __ms_va_list valist;
1001 int r;
1003 __ms_va_start(valist, locale);
1004 r = MSVCRT_vswprintf_p_l(buffer, length, format, locale, valist);
1005 __ms_va_end(valist);
1007 return r;
1010 /*********************************************************************
1011 * wcscoll (MSVCRT.@)
1013 int CDECL MSVCRT_wcscoll( const MSVCRT_wchar_t* str1, const MSVCRT_wchar_t* str2 )
1015 /* FIXME: handle collates */
1016 return strcmpW( str1, str2 );
1019 /*********************************************************************
1020 * wcspbrk (MSVCRT.@)
1022 MSVCRT_wchar_t* CDECL MSVCRT_wcspbrk( const MSVCRT_wchar_t* str, const MSVCRT_wchar_t* accept )
1024 const MSVCRT_wchar_t* p;
1025 while (*str)
1027 for (p = accept; *p; p++) if (*p == *str) return (MSVCRT_wchar_t*)str;
1028 str++;
1030 return NULL;
1033 /*********************************************************************
1034 * wcstok_s (MSVCRT.@)
1036 MSVCRT_wchar_t * CDECL wcstok_s( MSVCRT_wchar_t *str, const MSVCRT_wchar_t *delim,
1037 MSVCRT_wchar_t **next_token )
1039 MSVCRT_wchar_t *ret;
1041 if (!MSVCRT_CHECK_PMT(delim != NULL) || !MSVCRT_CHECK_PMT(next_token != NULL) ||
1042 !MSVCRT_CHECK_PMT(str != NULL || *next_token != NULL))
1044 *MSVCRT__errno() = MSVCRT_EINVAL;
1045 return NULL;
1047 if (!str) str = *next_token;
1049 while (*str && strchrW( delim, *str )) str++;
1050 if (!*str) return NULL;
1051 ret = str++;
1052 while (*str && !strchrW( delim, *str )) str++;
1053 if (*str) *str++ = 0;
1054 *next_token = str;
1055 return ret;
1058 /*********************************************************************
1059 * wcstok (MSVCRT.@)
1061 MSVCRT_wchar_t * CDECL MSVCRT_wcstok( MSVCRT_wchar_t *str, const MSVCRT_wchar_t *delim )
1063 return wcstok_s(str, delim, &msvcrt_get_thread_data()->wcstok_next);
1066 /*********************************************************************
1067 * wctob (MSVCRT.@)
1069 INT CDECL MSVCRT_wctob( MSVCRT_wint_t wchar )
1071 char out;
1072 BOOL error;
1073 UINT codepage = get_locinfo()->lc_codepage;
1075 if(!codepage) {
1076 if (wchar < 0xff)
1077 return (signed char)wchar;
1078 else
1079 return MSVCRT_EOF;
1080 } else if(WideCharToMultiByte( codepage, 0, &wchar, 1, &out, 1, NULL, &error ) && !error)
1081 return (INT)out;
1082 return MSVCRT_EOF;
1085 /*********************************************************************
1086 * wctomb (MSVCRT.@)
1088 INT CDECL MSVCRT_wctomb( char *dst, MSVCRT_wchar_t ch )
1090 return WideCharToMultiByte( get_locinfo()->lc_codepage, 0, &ch, 1, dst, 6, NULL, NULL );
1093 /*********************************************************************
1094 * iswalnum (MSVCRT.@)
1096 INT CDECL MSVCRT_iswalnum( MSVCRT_wchar_t wc )
1098 return isalnumW( wc );
1101 /*********************************************************************
1102 * iswalpha (MSVCRT.@)
1104 INT CDECL MSVCRT_iswalpha( MSVCRT_wchar_t wc )
1106 return isalphaW( wc );
1109 /*********************************************************************
1110 * iswalpha_l (MSVCRT.@)
1112 INT CDECL MSVCRT__iswalpha_l( MSVCRT_wchar_t wc, MSVCRT__locale_t locale )
1114 return isalphaW( wc );
1117 /*********************************************************************
1118 * iswcntrl (MSVCRT.@)
1120 INT CDECL MSVCRT_iswcntrl( MSVCRT_wchar_t wc )
1122 return iscntrlW( wc );
1125 /*********************************************************************
1126 * iswdigit (MSVCRT.@)
1128 INT CDECL MSVCRT_iswdigit( MSVCRT_wchar_t wc )
1130 return isdigitW( wc );
1133 /*********************************************************************
1134 * _iswdigit_l (MSVCRT.@)
1136 INT CDECL MSVCRT__iswdigit_l( MSVCRT_wchar_t wc, MSVCRT__locale_t locale )
1138 return isdigitW( wc );
1141 /*********************************************************************
1142 * iswgraph (MSVCRT.@)
1144 INT CDECL MSVCRT_iswgraph( MSVCRT_wchar_t wc )
1146 return isgraphW( wc );
1149 /*********************************************************************
1150 * iswlower (MSVCRT.@)
1152 INT CDECL MSVCRT_iswlower( MSVCRT_wchar_t wc )
1154 return islowerW( wc );
1157 /*********************************************************************
1158 * iswprint (MSVCRT.@)
1160 INT CDECL MSVCRT_iswprint( MSVCRT_wchar_t wc )
1162 return isprintW( wc );
1165 /*********************************************************************
1166 * iswpunct (MSVCRT.@)
1168 INT CDECL MSVCRT_iswpunct( MSVCRT_wchar_t wc )
1170 return ispunctW( wc );
1173 /*********************************************************************
1174 * iswspace (MSVCRT.@)
1176 INT CDECL MSVCRT_iswspace( MSVCRT_wchar_t wc )
1178 return isspaceW( wc );
1181 /*********************************************************************
1182 * iswupper (MSVCRT.@)
1184 INT CDECL MSVCRT_iswupper( MSVCRT_wchar_t wc )
1186 return isupperW( wc );
1189 /*********************************************************************
1190 * iswxdigit (MSVCRT.@)
1192 INT CDECL MSVCRT_iswxdigit( MSVCRT_wchar_t wc )
1194 return isxdigitW( wc );
1197 /*********************************************************************
1198 * wcscpy_s (MSVCRT.@)
1200 INT CDECL MSVCRT_wcscpy_s( MSVCRT_wchar_t* wcDest, MSVCRT_size_t numElement, const MSVCRT_wchar_t *wcSrc)
1202 MSVCRT_size_t size = 0;
1204 if(!wcDest || !numElement)
1205 return MSVCRT_EINVAL;
1207 wcDest[0] = 0;
1209 if(!wcSrc)
1211 return MSVCRT_EINVAL;
1214 size = strlenW(wcSrc) + 1;
1216 if(size > numElement)
1218 return MSVCRT_ERANGE;
1221 memcpy( wcDest, wcSrc, size*sizeof(WCHAR) );
1223 return 0;
1226 /******************************************************************
1227 * wcsncpy_s (MSVCRT.@)
1229 INT CDECL MSVCRT_wcsncpy_s( MSVCRT_wchar_t* wcDest, MSVCRT_size_t numElement, const MSVCRT_wchar_t *wcSrc,
1230 MSVCRT_size_t count )
1232 MSVCRT_size_t size = 0;
1234 if (!wcDest || !numElement)
1235 return MSVCRT_EINVAL;
1237 wcDest[0] = 0;
1239 if (!wcSrc)
1241 return count ? MSVCRT_EINVAL : 0;
1244 size = min(strlenW(wcSrc), count);
1246 if (size >= numElement)
1248 return MSVCRT_ERANGE;
1251 memcpy( wcDest, wcSrc, size*sizeof(WCHAR) );
1252 wcDest[size] = '\0';
1254 return 0;
1257 /******************************************************************
1258 * wcscat_s (MSVCRT.@)
1261 INT CDECL MSVCRT_wcscat_s(MSVCRT_wchar_t* dst, MSVCRT_size_t elem, const MSVCRT_wchar_t* src)
1263 MSVCRT_wchar_t* ptr = dst;
1265 if (!dst || elem == 0) return MSVCRT_EINVAL;
1266 if (!src)
1268 dst[0] = '\0';
1269 return MSVCRT_EINVAL;
1272 /* seek to end of dst string (or elem if no end of string is found */
1273 while (ptr < dst + elem && *ptr != '\0') ptr++;
1274 while (ptr < dst + elem)
1276 if ((*ptr++ = *src++) == '\0') return 0;
1278 /* not enough space */
1279 dst[0] = '\0';
1280 return MSVCRT_ERANGE;
1283 /*********************************************************************
1284 * wcsncat_s (MSVCRT.@)
1287 INT CDECL MSVCRT_wcsncat_s(MSVCRT_wchar_t *dst, MSVCRT_size_t elem,
1288 const MSVCRT_wchar_t *src, MSVCRT_size_t count)
1290 MSVCRT_size_t srclen;
1291 MSVCRT_wchar_t dststart;
1292 INT ret = 0;
1294 if (!MSVCRT_CHECK_PMT(dst != NULL) || !MSVCRT_CHECK_PMT(elem > 0))
1296 *MSVCRT__errno() = MSVCRT_EINVAL;
1297 return MSVCRT_EINVAL;
1299 if (!MSVCRT_CHECK_PMT(src != NULL || count == 0))
1300 return MSVCRT_EINVAL;
1301 if (count == 0)
1302 return 0;
1304 for (dststart = 0; dststart < elem; dststart++)
1306 if (dst[dststart] == '\0')
1307 break;
1309 if (dststart == elem)
1311 MSVCRT_INVALID_PMT("dst[elem] is not NULL terminated\n");
1312 return MSVCRT_EINVAL;
1315 if (count == MSVCRT__TRUNCATE)
1317 srclen = strlenW(src);
1318 if (srclen >= (elem - dststart))
1320 srclen = elem - dststart - 1;
1321 ret = MSVCRT_STRUNCATE;
1324 else
1325 srclen = min(strlenW(src), count);
1326 if (srclen < (elem - dststart))
1328 memcpy(&dst[dststart], src, srclen*sizeof(MSVCRT_wchar_t));
1329 dst[dststart+srclen] = '\0';
1330 return ret;
1332 MSVCRT_INVALID_PMT("dst[elem] is too small");
1333 dst[0] = '\0';
1334 return MSVCRT_ERANGE;
1337 /*********************************************************************
1338 * _wcstoi64_l (MSVCRT.@)
1340 * FIXME: locale parameter is ignored
1342 __int64 CDECL MSVCRT__wcstoi64_l(const MSVCRT_wchar_t *nptr,
1343 MSVCRT_wchar_t **endptr, int base, MSVCRT__locale_t locale)
1345 BOOL negative = FALSE;
1346 __int64 ret = 0;
1348 TRACE("(%s %p %d %p)\n", debugstr_w(nptr), endptr, base, locale);
1350 if (!MSVCRT_CHECK_PMT(nptr != NULL) || !MSVCRT_CHECK_PMT(base == 0 || base >= 2) ||
1351 !MSVCRT_CHECK_PMT(base <= 36)) {
1352 *MSVCRT__errno() = MSVCRT_EINVAL;
1353 return 0;
1356 while(isspaceW(*nptr)) nptr++;
1358 if(*nptr == '-') {
1359 negative = TRUE;
1360 nptr++;
1361 } else if(*nptr == '+')
1362 nptr++;
1364 if((base==0 || base==16) && *nptr=='0' && tolowerW(*(nptr+1))=='x') {
1365 base = 16;
1366 nptr += 2;
1369 if(base == 0) {
1370 if(*nptr=='0')
1371 base = 8;
1372 else
1373 base = 10;
1376 while(*nptr) {
1377 char cur = tolowerW(*nptr);
1378 int v;
1380 if(isdigitW(cur)) {
1381 if(cur >= '0'+base)
1382 break;
1383 v = cur-'0';
1384 } else {
1385 if(cur<'a' || cur>='a'+base-10)
1386 break;
1387 v = cur-'a'+10;
1390 if(negative)
1391 v = -v;
1393 nptr++;
1395 if(!negative && (ret>MSVCRT_I64_MAX/base || ret*base>MSVCRT_I64_MAX-v)) {
1396 ret = MSVCRT_I64_MAX;
1397 *MSVCRT__errno() = MSVCRT_ERANGE;
1398 } else if(negative && (ret<MSVCRT_I64_MIN/base || ret*base<MSVCRT_I64_MIN-v)) {
1399 ret = MSVCRT_I64_MIN;
1400 *MSVCRT__errno() = MSVCRT_ERANGE;
1401 } else
1402 ret = ret*base + v;
1405 if(endptr)
1406 *endptr = (MSVCRT_wchar_t*)nptr;
1408 return ret;
1411 /*********************************************************************
1412 * _wcstoi64 (MSVCRT.@)
1414 __int64 CDECL MSVCRT__wcstoi64(const MSVCRT_wchar_t *nptr,
1415 MSVCRT_wchar_t **endptr, int base)
1417 return MSVCRT__wcstoi64_l(nptr, endptr, base, NULL);
1420 /*********************************************************************
1421 * _wcstoui64_l (MSVCRT.@)
1423 * FIXME: locale parameter is ignored
1425 unsigned __int64 CDECL MSVCRT__wcstoui64_l(const MSVCRT_wchar_t *nptr,
1426 MSVCRT_wchar_t **endptr, int base, MSVCRT__locale_t locale)
1428 BOOL negative = FALSE;
1429 unsigned __int64 ret = 0;
1431 TRACE("(%s %p %d %p)\n", debugstr_w(nptr), endptr, base, locale);
1433 if (!MSVCRT_CHECK_PMT(nptr != NULL) || !MSVCRT_CHECK_PMT(base == 0 || base >= 2) ||
1434 !MSVCRT_CHECK_PMT(base <= 36)) {
1435 *MSVCRT__errno() = MSVCRT_EINVAL;
1436 return 0;
1439 while(isspaceW(*nptr)) nptr++;
1441 if(*nptr == '-') {
1442 negative = TRUE;
1443 nptr++;
1444 } else if(*nptr == '+')
1445 nptr++;
1447 if((base==0 || base==16) && *nptr=='0' && tolowerW(*(nptr+1))=='x') {
1448 base = 16;
1449 nptr += 2;
1452 if(base == 0) {
1453 if(*nptr=='0')
1454 base = 8;
1455 else
1456 base = 10;
1459 while(*nptr) {
1460 char cur = tolowerW(*nptr);
1461 int v;
1463 if(isdigit(cur)) {
1464 if(cur >= '0'+base)
1465 break;
1466 v = *nptr-'0';
1467 } else {
1468 if(cur<'a' || cur>='a'+base-10)
1469 break;
1470 v = cur-'a'+10;
1473 nptr++;
1475 if(ret>MSVCRT_UI64_MAX/base || ret*base>MSVCRT_UI64_MAX-v) {
1476 ret = MSVCRT_UI64_MAX;
1477 *MSVCRT__errno() = MSVCRT_ERANGE;
1478 } else
1479 ret = ret*base + v;
1482 if(endptr)
1483 *endptr = (MSVCRT_wchar_t*)nptr;
1485 return negative ? -ret : ret;
1488 /*********************************************************************
1489 * _wcstoui64 (MSVCRT.@)
1491 unsigned __int64 CDECL MSVCRT__wcstoui64(const MSVCRT_wchar_t *nptr,
1492 MSVCRT_wchar_t **endptr, int base)
1494 return MSVCRT__wcstoui64_l(nptr, endptr, base, NULL);
1497 /******************************************************************
1498 * wcsnlen (MSVCRT.@)
1500 MSVCRT_size_t CDECL MSVCRT_wcsnlen(const MSVCRT_wchar_t *s, MSVCRT_size_t maxlen)
1502 MSVCRT_size_t i;
1504 for (i = 0; i < maxlen; i++)
1505 if (!s[i]) break;
1506 return i;
1509 /*********************************************************************
1510 * _towupper_l (MSVCRT.@)
1512 int CDECL MSVCRT__towupper_l(MSVCRT_wint_t c, MSVCRT__locale_t locale)
1514 return toupperW(c);
1517 /*********************************************************************
1518 * _towlower_l (MSVCRT.@)
1520 int CDECL MSVCRT__towlower_l(MSVCRT_wint_t c, MSVCRT__locale_t locale)
1522 return tolowerW(c);