wined3d: Pass a wined3d_device_context to wined3d_cs_emit_blt_sub_resource().
[wine/zf.git] / dlls / ntdll / printf.c
blob9f14633a2ca56b40eb833b92505f65f155e83229
1 /*
2 * ntdll printf functions
4 * Copyright 1999, 2009 Alexandre Julliard
5 * Copyright 2000 Jon Griffiths
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <assert.h>
23 #include <ctype.h>
24 #include <stdarg.h>
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <string.h>
29 #include "windef.h"
30 #include "winternl.h"
31 #include "ntdll_misc.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
36 static const SIZE_T size_max = ~(SIZE_T)0 >> 1;
38 typedef struct pf_flags_t
40 enum { LEN_DEFAULT, LEN_SHORT, LEN_LONG } IntegerLength;
41 BOOLEAN IntegerDouble, IntegerNative, LeftAlign, Alternate, PadZero, WideString;
42 int FieldLength, Precision;
43 char Sign, Format;
44 } pf_flags;
47 #include "printf.h"
48 #define PRINTF_WIDE
49 #include "printf.h"
50 #undef PRINTF_WIDE
52 /*********************************************************************
53 * _vsnprintf (NTDLL.@)
55 int CDECL _vsnprintf( char *str, size_t len, const char *format, __ms_va_list args )
57 pf_output_a out = { str, len };
58 int r = pf_vsnprintf_a( &out, format, args );
60 if (out.used < len) str[out.used] = 0;
61 return r;
65 /***********************************************************************
66 * _vsnwprintf (NTDLL.@)
68 int CDECL _vsnwprintf( WCHAR *str, size_t len, const WCHAR *format, __ms_va_list args )
70 pf_output_w out = { str, len };
71 int r = pf_vsnprintf_w( &out, format, args );
73 if (out.used < len) str[out.used] = 0;
74 return r;
78 /*********************************************************************
79 * _snprintf (NTDLL.@)
81 int WINAPIV NTDLL__snprintf( char *str, size_t len, const char *format, ... )
83 int ret;
84 __ms_va_list valist;
86 __ms_va_start( valist, format );
87 ret = _vsnprintf( str, len, format, valist );
88 __ms_va_end( valist );
89 return ret;
93 /***********************************************************************
94 * _snwprintf (NTDLL.@)
96 int WINAPIV _snwprintf( WCHAR *str, size_t len, const WCHAR *format, ... )
98 int ret;
99 __ms_va_list valist;
101 __ms_va_start(valist, format);
102 ret = _vsnwprintf( str, len, format, valist );
103 __ms_va_end(valist);
104 return ret;
108 /*********************************************************************
109 * _vsnprintf_s (NTDLL.@)
111 int CDECL _vsnprintf_s( char *str, size_t size, size_t len, const char *format, __ms_va_list args )
113 pf_output_a out = { str, min( size, len ) };
114 int r = pf_vsnprintf_a( &out, format, args );
116 if (out.used < size) str[out.used] = 0;
117 else str[0] = 0;
118 if (r == size) r = -1;
119 return r;
123 /***********************************************************************
124 * _vsnwprintf_s (NTDLL.@)
126 int CDECL _vsnwprintf_s( WCHAR *str, size_t size, size_t len, const WCHAR *format, __ms_va_list args )
128 pf_output_w out = { str, min( size, len ) };
129 int r = pf_vsnprintf_w( &out, format, args );
131 if (out.used < size) str[out.used] = 0;
132 else str[0] = 0;
133 if (r == size) r = -1;
134 return r;
138 /*********************************************************************
139 * _snprintf_s (NTDLL.@)
141 int WINAPIV _snprintf_s( char *str, size_t size, size_t len, const char *format, ... )
143 int ret;
144 __ms_va_list valist;
146 __ms_va_start( valist, format );
147 ret = _vsnprintf_s( str, size, len, format, valist );
148 __ms_va_end( valist );
149 return ret;
153 /*********************************************************************
154 * _snwprintf_s (NTDLL.@)
156 int WINAPIV _snwprintf_s( WCHAR *str, size_t size, size_t len, const WCHAR *format, ... )
158 int ret;
159 __ms_va_list valist;
161 __ms_va_start( valist, format );
162 ret = _vsnwprintf_s( str, size, len, format, valist );
163 __ms_va_end( valist );
164 return ret;
168 /*********************************************************************
169 * vsprintf (NTDLL.@)
171 int CDECL vsprintf( char *str, const char *format, __ms_va_list args )
173 return _vsnprintf( str, size_max, format, args );
177 /*********************************************************************
178 * vsprintf_s (NTDLL.@)
180 int CDECL vsprintf_s( char *str, size_t size, const char *format, __ms_va_list args )
182 return _vsnprintf_s( str, size, size, format, args );
186 /*********************************************************************
187 * _vswprintf (NTDLL.@)
189 int CDECL _vswprintf( WCHAR *str, const WCHAR *format, __ms_va_list args )
191 return _vsnwprintf( str, size_max, format, args );
195 /*********************************************************************
196 * vswprintf_s (NTDLL.@)
198 int CDECL vswprintf_s( WCHAR *str, size_t size, const WCHAR *format, __ms_va_list args )
200 return _vsnwprintf_s( str, size, size, format, args );
204 /*********************************************************************
205 * sprintf (NTDLL.@)
207 int WINAPIV NTDLL_sprintf( char *str, const char *format, ... )
209 int ret;
210 __ms_va_list valist;
212 __ms_va_start( valist, format );
213 ret = _vsnprintf( str, size_max, format, valist );
214 __ms_va_end( valist );
215 return ret;
219 /*********************************************************************
220 * sprintf_s (NTDLL.@)
222 int WINAPIV sprintf_s( char *str, size_t size, const char *format, ... )
224 int ret;
225 __ms_va_list valist;
227 __ms_va_start( valist, format );
228 ret = vsprintf_s( str, size, format, valist );
229 __ms_va_end( valist );
230 return ret;
234 /***********************************************************************
235 * swprintf (NTDLL.@)
237 int WINAPIV NTDLL_swprintf( WCHAR *str, const WCHAR *format, ... )
239 int ret;
240 __ms_va_list valist;
242 __ms_va_start(valist, format);
243 ret = _vsnwprintf( str, size_max, format, valist );
244 __ms_va_end(valist);
245 return ret;
249 /***********************************************************************
250 * swprintf_s (NTDLL.@)
252 int WINAPIV swprintf_s( WCHAR *str, size_t size, const WCHAR *format, ... )
254 int ret;
255 __ms_va_list valist;
257 __ms_va_start(valist, format);
258 ret = vswprintf_s( str, size, format, valist );
259 __ms_va_end(valist);
260 return ret;