:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / lib / crtdll / stdio / vsprintf.c
1 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
2 #include <crtdll/stdio.h>
3 #include <stdarg.h>
4 #include <limits.h>
5 #include <crtdll/internal/file.h>
6
7 int
8 vsprintf(char *str, const char *fmt, va_list ap)
9 {
10   FILE f;
11   int len;
12
13   f._flag = _IOWRT|_IOSTRG;
14   f._ptr = str;
15   f._cnt = INT_MAX;
16   f._file = -1;
17   len = vfprintf(&f,fmt, ap);
18   *f._ptr = 0;
19   return len;
20 }
21
22 int
23 vswprintf(wchar_t *str, const wchar_t *fmt, va_list ap)
24 {
25   FILE f;
26   int len;
27
28   f._flag = _IOWRT|_IOSTRG;
29   f._ptr = (char*)str;
30   f._cnt = INT_MAX;
31   f._file = -1;
32   len = vfwprintf(&f,fmt, ap);
33   *f._ptr = 0;
34   return len;
35 }
36
37
38 int
39 _vsnprintf(char *str, size_t maxlen, const char *fmt, va_list ap)
40 {
41   FILE f;
42   int len;
43   f._flag = _IOWRT|_IOSTRG;
44   f._ptr = str;
45   f._cnt = maxlen;
46   f._file = -1;
47   len = vfprintf(&f,fmt, ap);
48   // what if the buffer is full ??
49   *f._ptr = 0;
50   return len;
51 }
52
53 int
54 _vsnwprintf(wchar_t *str, size_t maxlen, const wchar_t *fmt, va_list ap)
55 {
56   FILE f;
57   int len;
58   f._flag = _IOWRT|_IOSTRG;
59   f._ptr = (char*)str;
60   f._cnt = maxlen;
61   f._file = -1;
62   len = vfwprintf(&f,fmt, ap);
63   // what if the buffer is full ??
64   *f._ptr = 0;
65   return len;
66 }
67
68