[CRT]
[reactos.git] / reactos / lib / sdk / crt / printf / _vsnwprintf.c
1 /*
2 * COPYRIGHT: GNU GPL, see COPYING in the top level directory
3 * PROJECT: ReactOS crt library
4 * FILE: lib/sdk/crt/printf/_vsnwprintf.c
5 * PURPOSE: Implementation of _vsnwprintf
6 * PROGRAMMER: Timo Kreuzer
7 */
8
9 #include <stdio.h>
10 #include <stdarg.h>
11
12 int _cdecl wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
13
14 int
15 __cdecl
16 _vsnwprintf(
17 wchar_t *buffer,
18 size_t count,
19 const wchar_t *format,
20 va_list argptr)
21 {
22 int result;
23 FILE stream;
24
25 stream._base = (char*)buffer;
26 stream._ptr = stream._base;
27 stream._bufsiz = count * sizeof(wchar_t);
28 stream._cnt = stream._bufsiz;
29 stream._flag = _IOSTRG | _IOWRT;
30 stream._tmpfname = 0;
31 stream._charbuf = 0;
32
33 result = wstreamout(&stream, format, argptr);
34 *(wchar_t*)stream._ptr = L'\0';
35
36 return result;
37 }