d51dcf99af7e55c71b255de9565bb35c93c83d18
[reactos.git] / reactos / lib / crt / stdio / vsprintf.c
1 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
2 #include <stdio.h>
3 #include <stdarg.h>
4 #include <limits.h>
5 #include <internal/file.h>
6 #include <tchar.h>
7
8 int
9 crt_vsprintf(_TCHAR *str, const _TCHAR *fmt, va_list ap)
10 {
11 FILE f = {0};
12 int len;
13
14 f._flag = _IOWRT|_IOSTRG|_IOBINARY;
15 f._ptr = (char*)str;
16 f._cnt = INT_MAX;
17 f._file = -1;
18 len = _vftprintf(&f,fmt, ap);
19 *(_TCHAR*)f._ptr = 0;
20 return len;
21 }
22
23
24 int
25 crt__vsnprintf(_TCHAR *str, size_t maxlen, const _TCHAR *fmt, va_list ap)
26 {
27 FILE f = {0};
28 int len;
29
30 f._flag = _IOWRT|_IOSTRG|_IOBINARY;
31 f._ptr = (char*)str;
32 f._cnt = maxlen;
33 f._file = -1;
34 len = _vftprintf(&f,fmt, ap);
35 // what if the buffer is full ??
36 *(_TCHAR *)f._ptr = 0;
37 return len;
38 }