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