ReactOS 0.4.16-dev-822-gbcedb53
fputc.cpp
Go to the documentation of this file.
1//
2// fputc.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// Defines the fputc() family of functions, which write a character to a stream.
7//
10
11
12extern "C" int __cdecl _fputc_nolock_internal(int const c, FILE* const public_stream, __crt_cached_ptd_host& ptd)
13{
14 __crt_stdio_stream const stream(public_stream);
15
16 --stream->_cnt;
17
18 // If there is no room for the character in the buffer, flush the buffer and
19 // write the character:
20 if (stream->_cnt < 0)
21 {
23 }
24
25 // Otherwise, there is sufficient room, so we can write directly to the buffer:
26 char const char_value = static_cast<char>(c);
27 *stream->_ptr++ = char_value;
28 return char_value & 0xff;
29}
30
31extern "C" int __cdecl _fputc_nolock(int const c, FILE* const public_stream)
32{
33 __crt_cached_ptd_host ptd;
34 return _fputc_nolock_internal(c, public_stream, ptd);
35}
36
37extern "C" int __cdecl _putc_nolock(int const c, FILE* const stream)
38{
39 return _fputc_nolock(c, stream);
40}
41
42
43
44// Writes a character to a stream. Returns the character on success; returns
45// EOF on failure.
46static int __cdecl _fputc_internal(int const c, FILE* const stream, __crt_cached_ptd_host& ptd)
47{
49
50 int return_value = 0;
51
53 __try
54 {
56
57 return_value = _fputc_nolock_internal(c, stream, ptd);
58 }
60 {
62 }
64
65 return return_value;
66}
67
68// Writes a character to a stream. Returns the character on success; returns
69// EOF on failure.
70extern "C" int __cdecl fputc(int const c, FILE* const stream)
71{
72 __crt_cached_ptd_host ptd;
73 return _fputc_internal(c, stream, ptd);
74}
75
76
77
78// Writes a character to a stream. See fputc() for details.
79extern "C" int __cdecl putc(int const c, FILE* const stream)
80{
81 return fputc(c, stream);
82}
83
84
85
86// Writes a character to stdout. See fputc() for details.
87extern "C" int __cdecl _fputchar(int const c)
88{
89 return fputc(c, stdout);
90}
91
92
93
94// Writes a character to stdout. See fputc() for details.
95extern "C" int __cdecl putchar(int const c)
96{
97 return _fputchar(c);
98}
int __cdecl __acrt_stdio_flush_and_write_narrow_nolock(int const c, FILE *const stream, __crt_cached_ptd_host &ptd)
Definition: _flsbuf.cpp:195
#define EINVAL
Definition: acclib.h:90
#define __cdecl
Definition: accygwin.h:79
#define _UCRT_VALIDATE_STREAM_ANSI_RETURN(ptd, stream, errorcode, retexpr)
#define _UCRT_VALIDATE_RETURN(ptd, expr, errorcode, retexpr)
_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 _fputc_nolock_internal(int const c, FILE *const public_stream, __crt_cached_ptd_host &ptd)
Definition: fputc.cpp:12
static int __cdecl _fputc_internal(int const c, FILE *const stream, __crt_cached_ptd_host &ptd)
Definition: fputc.cpp:46
int __cdecl putc(int const c, FILE *const stream)
Definition: fputc.cpp:79
int __cdecl fputc(int const c, FILE *const stream)
Definition: fputc.cpp:70
int __cdecl _fputchar(int const c)
Definition: fputc.cpp:87
int __cdecl putchar(int const c)
Definition: fputc.cpp:95
const GLubyte * c
Definition: glext.h:8905
#define stdout
Definition: stdio.h:99
#define EOF
Definition: stdio.h:24
_CRTIMP void __cdecl _unlock_file(_Inout_ FILE *_File)
#define _putc_nolock(_c, _stream)
Definition: stdio.h:1145
#define _fputc_nolock(_c, _stream)
Definition: stdio.h:1143
_CRTIMP void __cdecl _lock_file(_Inout_ FILE *_File)
#define c
Definition: ke_i.h:80
#define __try
Definition: pseh2_64.h:172
#define __endtry
Definition: pseh2_64.h:175
#define __finally
Definition: pseh2_64.h:174
Definition: parse.h:23