ReactOS 0.4.16-dev-852-gcfcc8d8
putws.cpp
Go to the documentation of this file.
1//
2// putws.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// Defines _putws(), which writes a wide character string to stdout.
7//
10
11
12
13// Writes a wide character string to stdout. Does not write the string's null
14// terminator, but _does_ append a newline to the output. Returns 0 on success;
15// returns WEOF on failure.
16static int __cdecl _putws_internal(wchar_t const* const string, __crt_cached_ptd_host& ptd)
17{
18 _UCRT_VALIDATE_RETURN(ptd, string != nullptr, EINVAL, WEOF);
19
20 FILE* const stream = stdout;
21
22 return __acrt_lock_stream_and_call(stream, [&]() -> int
23 {
24 __acrt_stdio_temporary_buffering_guard const buffering(stream, ptd);
25
26 // Write the string, character-by-character:
27 for (wchar_t const* it = string; *it; ++it)
28 {
30 {
31 return WEOF;
32 }
33 }
34
36 {
37 return WEOF;
38 }
39
40 return 0;
41 });
42}
43
44extern "C" int __cdecl _putws(wchar_t const* const string)
45{
46 __crt_cached_ptd_host ptd;
47 return _putws_internal(string, ptd);
48}
#define EINVAL
Definition: acclib.h:90
#define __cdecl
Definition: accygwin.h:79
#define _UCRT_VALIDATE_RETURN(ptd, expr, errorcode, retexpr)
_Check_return_opt_ wint_t __cdecl _fputwc_nolock_internal(_In_ wchar_t _Character, _Inout_ FILE *_Stream, _Inout_ __crt_cached_ptd_host &_Ptd)
auto __acrt_lock_stream_and_call(FILE *const stream, Action &&action) -> decltype(action())
_In_ size_t const _In_ int _In_ bool const _In_ unsigned const _In_ __acrt_rounding_mode const _Inout_ __crt_cached_ptd_host & ptd
Definition: cvt.cpp:355
#define stdout
Definition: stdio.h:99
#define L(x)
Definition: ntvdm.h:50
static int __cdecl _putws_internal(wchar_t const *const string, __crt_cached_ptd_host &ptd)
Definition: putws.cpp:16
int __cdecl _putws(wchar_t const *const string)
Definition: putws.cpp:44
#define WEOF
Definition: conio.h:185
Definition: parse.h:23