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