ReactOS 0.4.16-dev-2104-gb84fa49
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 _VALIDATE_STREAM_ANSI_RETURN(stream, errorcode, retexpr)
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
void CDECL _lock_file(FILE *file)
Definition: file.c:1487
void CDECL _unlock_file(FILE *file)
Definition: file.c:1499
#define __cdecl
Definition: corecrt.h:121
#define stdin
#define EINVAL
Definition: errno.h:44
#define EOF
Definition: stdio.h:33
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 __try
Definition: pseh2_64.h:188
#define __endtry
Definition: pseh2_64.h:191
#define __finally
Definition: pseh2_64.h:190
#define _fgetc_nolock(_stream)
Definition: stdio.h:1142
#define _getc_nolock(_stream)
Definition: stdio.h:1144
Definition: parse.h:23