Reactos
1//
2// clearerr.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// Defines clearerr(), which clears error and EOF flags from a stream.
7//
8#include <corecrt_internal_stdio.h>
9
10
11
12extern "C" errno_t __cdecl clearerr_s(FILE* const public_stream)
13{
14 __crt_stdio_stream const stream(public_stream);
15
16 _VALIDATE_RETURN_ERRCODE(stream.valid(), EINVAL);
17
18 _lock_file(stream.public_stream());
19 __try
20 {
21 stream.unset_flags(_IOERROR | _IOEOF); // Clear stdio flags
22 _osfile_safe(_fileno(stream.public_stream())) &= ~(FEOFLAG); // Clear lowio flags
23 }
24 __finally
25 {
26 _unlock_file(stream.public_stream());
27 }
28 __endtry
29
30 return 0;
31}
32
33
34
35extern "C" void __cdecl clearerr(FILE* const stream)
36{
37 clearerr_s(stream);
38}