xref: /reactos/sdk/lib/ucrt/stdio/feoferr.cpp (revision 04e0dc4a)
1*04e0dc4aSTimo Kreuzer //
2*04e0dc4aSTimo Kreuzer // feoferr.cpp
3*04e0dc4aSTimo Kreuzer //
4*04e0dc4aSTimo Kreuzer //      Copyright (c) Microsoft Corporation.  All rights reserved.
5*04e0dc4aSTimo Kreuzer //
6*04e0dc4aSTimo Kreuzer // Defines feof() and ferror(), which test the end-of-file and error states of a
7*04e0dc4aSTimo Kreuzer // stream, respectively.
8*04e0dc4aSTimo Kreuzer //
9*04e0dc4aSTimo Kreuzer #include <corecrt_internal_stdio.h>
10*04e0dc4aSTimo Kreuzer 
11*04e0dc4aSTimo Kreuzer 
12*04e0dc4aSTimo Kreuzer 
13*04e0dc4aSTimo Kreuzer // Tests the stream for the end-of-file condition.  Returns nonzero if and only
14*04e0dc4aSTimo Kreuzer // if the stream is at end-of-file.
feof(FILE * const public_stream)15*04e0dc4aSTimo Kreuzer extern "C" int __cdecl feof(FILE* const public_stream)
16*04e0dc4aSTimo Kreuzer {
17*04e0dc4aSTimo Kreuzer     _VALIDATE_RETURN(public_stream != nullptr, EINVAL, 0);
18*04e0dc4aSTimo Kreuzer     return __crt_stdio_stream(public_stream).eof();
19*04e0dc4aSTimo Kreuzer }
20*04e0dc4aSTimo Kreuzer 
21*04e0dc4aSTimo Kreuzer 
22*04e0dc4aSTimo Kreuzer 
23*04e0dc4aSTimo Kreuzer // Tests the stream error indicator.  Returns nonzero if and only if the error
24*04e0dc4aSTimo Kreuzer // indicator for the stream is set.
ferror(FILE * const public_stream)25*04e0dc4aSTimo Kreuzer extern "C" int __cdecl ferror(FILE* const public_stream)
26*04e0dc4aSTimo Kreuzer {
27*04e0dc4aSTimo Kreuzer     _VALIDATE_RETURN(public_stream != nullptr, EINVAL, 0);
28*04e0dc4aSTimo Kreuzer     return __crt_stdio_stream(public_stream).error();
29*04e0dc4aSTimo Kreuzer }
30