ReactOS 0.4.16-dev-981-g80eb313
fputws.cpp
Go to the documentation of this file.
1//
2// fputws.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// Defines fputws(), which writes a wide character string to a stream.
7//
10
11
12
13// Writes the given wide character string to the given stream. Does not write
14// the string's null terminator, and does not append a '\n' to the file. Returns
15// a nonnegative value on success; EOF on failure. (Note well that we return EOF
16// and not WEOF on failure. This is intentional, and is the correct behavior per
17// the C Language Standard).
18static int __cdecl _fputws_internal(wchar_t const* const string, FILE* const stream, __crt_cached_ptd_host& ptd)
19{
20 _UCRT_VALIDATE_RETURN(ptd, string != nullptr, EINVAL, EOF);
22
23 return __acrt_lock_stream_and_call(stream, [&]() -> int
24 {
25 __acrt_stdio_temporary_buffering_guard const buffering(stream, ptd);
26
27 for (wchar_t const* it = string; *it != L'\0'; ++it)
28 {
30 {
31 return EOF;
32 }
33 }
34
35 return 0;
36 });
37}
38
39extern "C" int __cdecl fputws(wchar_t const* const string, FILE* const stream)
40{
41 __crt_cached_ptd_host ptd;
42 return _fputws_internal(string, stream, ptd);
43}
#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
int __cdecl fputws(wchar_t const *const string, FILE *const stream)
Definition: fputws.cpp:39
static int __cdecl _fputws_internal(wchar_t const *const string, FILE *const stream, __crt_cached_ptd_host &ptd)
Definition: fputws.cpp:18
#define EOF
Definition: stdio.h:24
#define L(x)
Definition: ntvdm.h:50
#define WEOF
Definition: conio.h:185
Definition: parse.h:23