ReactOS 0.4.16-dev-927-g467dec4
output.cpp File Reference
Include dependency graph for output.cpp:

Go to the source code of this file.

Functions

template<template< typename, typename > class Base, typename Character >
static int __cdecl common_vfprintf (unsigned __int64 const options, FILE *const stream, Character const *const format, __crt_cached_ptd_host &ptd, va_list const arglist) throw ()
 
int __cdecl __stdio_common_vfprintf (unsigned __int64 const options, FILE *const stream, char const *const format, _locale_t const locale, va_list const arglist)
 
int __cdecl __stdio_common_vfwprintf (unsigned __int64 const options, FILE *const stream, wchar_t const *const format, _locale_t const locale, va_list const arglist)
 
int __cdecl __stdio_common_vfprintf_s (unsigned __int64 const options, FILE *const stream, char const *const format, _locale_t const locale, va_list const arglist)
 
int __cdecl __stdio_common_vfwprintf_s (unsigned __int64 const options, FILE *const stream, wchar_t const *const format, _locale_t const locale, va_list const arglist)
 
int __cdecl __stdio_common_vfprintf_p (unsigned __int64 const options, FILE *const stream, char const *const format, _locale_t const locale, va_list const arglist)
 
int __cdecl __stdio_common_vfwprintf_p (unsigned __int64 const options, FILE *const stream, wchar_t const *const format, _locale_t const locale, va_list const arglist)
 
template<template< typename, typename > class Base, typename Character >
 _Success_ (return >=0) static int __cdecl common_vsprintf(unsigned __int64 const options
 
 _Out_writes_z_ (buffer_count) Character *const buffer
 
size_t const Character const *const __crt_cached_ptd_host va_list const arglist throw ()
 
int __cdecl __stdio_common_vsprintf (unsigned __int64 const options, char *const buffer, size_t const buffer_count, char const *const format, _locale_t const locale, va_list const arglist)
 
int __cdecl __stdio_common_vswprintf (unsigned __int64 const options, wchar_t *const buffer, size_t const buffer_count, wchar_t const *const format, _locale_t const locale, va_list const arglist)
 
template<typename Character >
 _Success_ (return >=0) static int __cdecl common_vsprintf_s(unsigned __int64 const options
 
int __cdecl __stdio_common_vsprintf_s (unsigned __int64 const options, char *const buffer, size_t const buffer_count, char const *const format, _locale_t const locale, va_list const arglist)
 
int __cdecl __stdio_common_vswprintf_s (unsigned __int64 const options, wchar_t *const buffer, size_t const buffer_count, wchar_t const *const format, _locale_t const locale, va_list const arglist)
 
int __cdecl __stdio_common_vsnprintf_s (unsigned __int64 const options, char *const buffer, size_t const buffer_count, size_t const max_count, char const *const format, _locale_t const locale, va_list const arglist)
 
int __cdecl __stdio_common_vsnwprintf_s (unsigned __int64 const options, wchar_t *const buffer, size_t const buffer_count, size_t const max_count, wchar_t const *const format, _locale_t const locale, va_list const arglist)
 
int __cdecl __stdio_common_vsprintf_p (unsigned __int64 const options, char *const buffer, size_t const buffer_count, char const *const format, _locale_t const locale, va_list const arglist)
 
int __cdecl __stdio_common_vswprintf_p (unsigned __int64 const options, wchar_t *const buffer, size_t const buffer_count, wchar_t const *const format, _locale_t const locale, va_list const arglist)
 

Variables

size_t const buffer_count
 
size_t const Character const *const format
 
size_t const Character const *const __crt_cached_ptd_host & ptd
 
size_t const size_t const max_count
 

Function Documentation

◆ __stdio_common_vfprintf()

int __cdecl __stdio_common_vfprintf ( unsigned __int64 const  options,
FILE *const  stream,
char const *const  format,
_locale_t const  locale,
va_list const  arglist 
)

Definition at line 52 of file output.cpp.

59{
60 __crt_cached_ptd_host ptd(locale);
61 return common_vfprintf<standard_base>(options, stream, format, ptd, arglist);
62}
Definition: _locale.h:75
size_t const Character const *const __crt_cached_ptd_host & ptd
Definition: output.cpp:134
va_lists_t arglist[FMT_ARGMAX+1]
Definition: format.c:284
Definition: format.c:58
Definition: parse.h:23

Referenced by vfprintf_wrapper().

◆ __stdio_common_vfprintf_p()

int __cdecl __stdio_common_vfprintf_p ( unsigned __int64 const  options,
FILE *const  stream,
char const *const  format,
_locale_t const  locale,
va_list const  arglist 
)

Definition at line 100 of file output.cpp.

107{
108 __crt_cached_ptd_host ptd(locale);
109 return common_vfprintf<positional_parameter_base>(options, stream, format, ptd, arglist);
110}

◆ __stdio_common_vfprintf_s()

int __cdecl __stdio_common_vfprintf_s ( unsigned __int64 const  options,
FILE *const  stream,
char const *const  format,
_locale_t const  locale,
va_list const  arglist 
)

Definition at line 76 of file output.cpp.

83{
84 __crt_cached_ptd_host ptd(locale);
85 return common_vfprintf<format_validation_base>(options, stream, format, ptd, arglist);
86}

◆ __stdio_common_vfwprintf()

int __cdecl __stdio_common_vfwprintf ( unsigned __int64 const  options,
FILE *const  stream,
wchar_t const *const  format,
_locale_t const  locale,
va_list const  arglist 
)

Definition at line 64 of file output.cpp.

71{
72 __crt_cached_ptd_host ptd(locale);
73 return common_vfprintf<standard_base>(options, stream, format, ptd, arglist);
74}

Referenced by vfwprintf_wrapper().

◆ __stdio_common_vfwprintf_p()

int __cdecl __stdio_common_vfwprintf_p ( unsigned __int64 const  options,
FILE *const  stream,
wchar_t const *const  format,
_locale_t const  locale,
va_list const  arglist 
)

Definition at line 112 of file output.cpp.

119{
120 __crt_cached_ptd_host ptd(locale);
121 return common_vfprintf<positional_parameter_base>(options, stream, format, ptd, arglist);
122}

◆ __stdio_common_vfwprintf_s()

int __cdecl __stdio_common_vfwprintf_s ( unsigned __int64 const  options,
FILE *const  stream,
wchar_t const *const  format,
_locale_t const  locale,
va_list const  arglist 
)

Definition at line 88 of file output.cpp.

95{
96 __crt_cached_ptd_host ptd(locale);
97 return common_vfprintf<format_validation_base>(options, stream, format, ptd, arglist);
98}

◆ __stdio_common_vsnprintf_s()

int __cdecl __stdio_common_vsnprintf_s ( unsigned __int64 const  options,
char *const  buffer,
size_t const  buffer_count,
size_t const  max_count,
char const *const  format,
_locale_t const  locale,
va_list const  arglist 
)

Definition at line 393 of file output.cpp.

402{
403 __crt_cached_ptd_host ptd(locale);
404 return common_vsnprintf_s(options, buffer, buffer_count, max_count, format, ptd, arglist);
405}
GLuint buffer
Definition: glext.h:5915
size_t const size_t const max_count
Definition: output.cpp:324
size_t const buffer_count
Definition: output.cpp:132

Referenced by _vsnprintf_s_wrapper().

◆ __stdio_common_vsnwprintf_s()

int __cdecl __stdio_common_vsnwprintf_s ( unsigned __int64 const  options,
wchar_t *const  buffer,
size_t const  buffer_count,
size_t const  max_count,
wchar_t const *const  format,
_locale_t const  locale,
va_list const  arglist 
)

Definition at line 407 of file output.cpp.

416{
417 __crt_cached_ptd_host ptd(locale);
418 return common_vsnprintf_s(options, buffer, buffer_count, max_count, format, ptd, arglist);
419}

Referenced by _VCrtDbgReportW(), and _vsnwprintf_s_wrapper().

◆ __stdio_common_vsprintf()

int __cdecl __stdio_common_vsprintf ( unsigned __int64 const  options,
char *const  buffer,
size_t const  buffer_count,
char const *const  format,
_locale_t const  locale,
va_list const  arglist 
)

Definition at line 233 of file output.cpp.

241{
242 __crt_cached_ptd_host ptd(locale);
243 return common_vsprintf<standard_base>(options, buffer, buffer_count, format, ptd, arglist);
244}

Referenced by vsprintf_wrapper().

◆ __stdio_common_vsprintf_p()

int __cdecl __stdio_common_vsprintf_p ( unsigned __int64 const  options,
char *const  buffer,
size_t const  buffer_count,
char const *const  format,
_locale_t const  locale,
va_list const  arglist 
)

Definition at line 421 of file output.cpp.

429{
430 __crt_cached_ptd_host ptd(locale);
431 return common_vsprintf<positional_parameter_base>(options, buffer, buffer_count, format, ptd, arglist);
432}

◆ __stdio_common_vsprintf_s()

int __cdecl __stdio_common_vsprintf_s ( unsigned __int64 const  options,
char *const  buffer,
size_t const  buffer_count,
char const *const  format,
_locale_t const  locale,
va_list const  arglist 
)

Definition at line 292 of file output.cpp.

300{
301 __crt_cached_ptd_host ptd(locale);
302 return common_vsprintf_s(options, buffer, buffer_count, format, ptd, arglist);
303}

◆ __stdio_common_vswprintf()

int __cdecl __stdio_common_vswprintf ( unsigned __int64 const  options,
wchar_t *const  buffer,
size_t const  buffer_count,
wchar_t const *const  format,
_locale_t const  locale,
va_list const  arglist 
)

Definition at line 246 of file output.cpp.

254{
255 __crt_cached_ptd_host ptd(locale);
256 return common_vsprintf<standard_base>(options, buffer, buffer_count, format, ptd, arglist);
257}

Referenced by vswprintf_wrapper().

◆ __stdio_common_vswprintf_p()

int __cdecl __stdio_common_vswprintf_p ( unsigned __int64 const  options,
wchar_t *const  buffer,
size_t const  buffer_count,
wchar_t const *const  format,
_locale_t const  locale,
va_list const  arglist 
)

Definition at line 434 of file output.cpp.

442{
443 __crt_cached_ptd_host ptd(locale);
444 return common_vsprintf<positional_parameter_base>(options, buffer, buffer_count, format, ptd, arglist);
445}

◆ __stdio_common_vswprintf_s()

int __cdecl __stdio_common_vswprintf_s ( unsigned __int64 const  options,
wchar_t *const  buffer,
size_t const  buffer_count,
wchar_t const *const  format,
_locale_t const  locale,
va_list const  arglist 
)

Definition at line 305 of file output.cpp.

313{
314 __crt_cached_ptd_host ptd(locale);
315 return common_vsprintf_s(options, buffer, buffer_count, format, ptd, arglist);
316}

◆ _Out_writes_z_()

_Out_writes_z_ ( buffer_count  ) const

◆ _Success_() [1/2]

template<template< typename, typename > class Base, typename Character >
_Success_ ( return >=  0) const

◆ _Success_() [2/2]

template<typename Character >
_Success_ ( return >=  0) const

◆ common_vfprintf()

template<template< typename, typename > class Base, typename Character >
static int __cdecl common_vfprintf ( unsigned __int64 const  options,
FILE *const  stream,
Character const *const  format,
__crt_cached_ptd_host &  ptd,
va_list const  arglist 
)
throw (
)
static

Definition at line 20 of file output.cpp.

27{
28 typedef output_processor<
29 Character,
31 Base<Character, stream_output_adapter<Character>>
32 > processor_type;
33
34 _UCRT_VALIDATE_RETURN(ptd, stream != nullptr, EINVAL, -1);
35 _UCRT_VALIDATE_RETURN(ptd, format != nullptr, EINVAL, -1);
36
37 return __acrt_lock_stream_and_call(stream, [&]() -> int
38 {
39 __acrt_stdio_temporary_buffering_guard const buffering(stream, ptd);
40
41 processor_type processor(
43 options,
44 format,
45 ptd,
46 arglist);
47
48 return processor.process();
49 });
50}
#define EINVAL
Definition: acclib.h:90
#define _UCRT_VALIDATE_RETURN(ptd, expr, errorcode, retexpr)
auto __acrt_lock_stream_and_call(FILE *const stream, Action &&action) -> decltype(action())

◆ throw()

size_t const Character const *const __crt_cached_ptd_host va_list const arglist throw ( )

Definition at line 136 of file output.cpp.

137{
139
140 typedef output_processor<
141 Character,
143 Base<Character, string_output_adapter<Character>>
144 > processor_type;
145
146 _UCRT_VALIDATE_RETURN(ptd, format != nullptr, EINVAL, -1);
147 _UCRT_VALIDATE_RETURN(ptd, buffer_count == 0 || buffer != nullptr, EINVAL, -1);
148
150 context._buffer = buffer;
151 context._buffer_count = buffer_count;
152 context._buffer_used = 0;
153
154 // For the C Standard snprintf functions, we continue formatting even after
155 // the buffer is full so that we can return the number of characters that
156 // are required to complete the format operation. For all other sprintf
157 // functions that have a buffer count, if no buffer was provided then we
158 // do the same.
159 context._continue_count =
161 buffer == nullptr;
162
163 processor_type processor(
165 options,
166 format,
167 ptd,
168 arglist);
169
170 int const result = processor.process();
171
172 if (buffer == nullptr)
173 {
174 return result;
175 }
176
177 // Otherwise, we formatted data into the buffer and need to terminate it:
179 {
180 if (buffer_count == 0 && result != 0)
181 {
182 return -1;
183 }
184 else if (context._buffer_used != buffer_count)
185 {
186 buffer[context._buffer_used] = '\0';
187 }
188 else if (result >= 0 && static_cast<size_t>(result) > buffer_count)
189 {
190 return -1;
191 }
192 }
194 {
195 if (buffer_count == 0)
196 {
197 // No-op
198 }
199 else if (result < 0)
200 {
201 buffer[0] = '\0';
202 }
203 else if (context._buffer_used == buffer_count)
204 {
205 buffer[buffer_count - 1] = '\0';
206 }
207 else
208 {
209 buffer[context._buffer_used] = '\0';
210 }
211 }
212 else
213 {
214 if (buffer_count == 0)
215 {
216 return -1;
217 }
218 else if (context._buffer_used == buffer_count)
219 {
220 buffer[buffer_count - 1] = '\0';
221 return -2;
222 }
223 else
224 {
225 buffer[context._buffer_used] = '\0';
226 }
227 }
228
229#pragma warning(suppress:__WARNING_POSTCONDITION_NULLTERMINATION_VIOLATION) // 26036 needs work
230 return result;
231}
#define _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION
#define _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR
GLuint64EXT * result
Definition: glext.h:11304
Definition: http.c:7252

Variable Documentation

◆ buffer_count

◆ format

Definition at line 133 of file output.cpp.

◆ max_count

size_t const size_t const max_count

Definition at line 324 of file output.cpp.

Referenced by __stdio_common_vsnprintf_s(), and __stdio_common_vsnwprintf_s().

◆ ptd