ReactOS 0.4.16-dev-927-g467dec4
fgetc.cpp
Go to the documentation of this file.
1//
2// fgetc.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// Functions that read the next character from a stream and return it. If the
7// read causes the stream to reach EOF, EOF is returned and the EOF bit is set
8// on the stream.
9//
11
12
13
14extern "C" int __cdecl _fgetc_nolock(FILE* const public_stream)
15{
16 __crt_stdio_stream const stream(public_stream);
17
19
20 --stream->_cnt;
21
22 if (stream->_cnt < 0)
24
25 char const c = *stream->_ptr;
26 ++stream->_ptr;
27 return c & 0xff;
28}
29
30
31
32extern "C" int __cdecl _getc_nolock(FILE* const stream)
33{
34 return _fgetc_nolock(stream);
35}
36
37
38
39extern "C" int __cdecl fgetc(FILE* const public_stream)
40{
41 __crt_stdio_stream const stream(public_stream);
42
44
45 int return_value = 0;
46
47 _lock_file(stream.public_stream());
48 __try
49 {
51
52 return_value = _fgetc_nolock(stream.public_stream());
53 }
55 {
56 _unlock_file(stream.public_stream());
57 }
59
60 return return_value;
61}
62
63
64
65extern "C" int __cdecl getc(FILE* const stream)
66{
67 return fgetc(stream);
68}
69
70
71
72extern "C" int __cdecl _fgetchar()
73{
74 return fgetc(stdin);
75}
76
77
78
79extern "C" int __cdecl getchar()
80{
81 return _fgetchar();
82}
int __cdecl __acrt_stdio_refill_and_read_narrow_nolock(FILE *const stream)
Definition: _filbuf.cpp:178
#define EINVAL
Definition: acclib.h:90
#define __cdecl
Definition: accygwin.h:79
#define _VALIDATE_STREAM_ANSI_RETURN(stream, errorcode, retexpr)
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
int __cdecl fgetc(FILE *const public_stream)
Definition: fgetc.cpp:39
int __cdecl getchar()
Definition: fgetc.cpp:79
int __cdecl getc(FILE *const stream)
Definition: fgetc.cpp:65
int __cdecl _fgetchar()
Definition: fgetc.cpp:72
const GLubyte * c
Definition: glext.h:8905
#define _fgetc_nolock(_stream)
Definition: stdio.h:1142
#define EOF
Definition: stdio.h:24
#define _getc_nolock(_stream)
Definition: stdio.h:1144
_CRTIMP void __cdecl _unlock_file(_Inout_ FILE *_File)
#define stdin
Definition: stdio.h:98
_CRTIMP void __cdecl _lock_file(_Inout_ FILE *_File)
#define __try
Definition: pseh2_64.h:188
#define __endtry
Definition: pseh2_64.h:191
#define __finally
Definition: pseh2_64.h:190
Definition: parse.h:23