mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 12:52:58 +00:00
[UCRT] Import Microsoft.Windows.SDK.CRTSource version 10.0.22621.3
Imported from https://www.nuget.org/packages/Microsoft.Windows.SDK.CRTSource/10.0.22621.3 License: MIT
This commit is contained in:
parent
f1b60c66f0
commit
04e0dc4a7a
568 changed files with 115483 additions and 0 deletions
81
sdk/lib/ucrt/stdio/fgetc.cpp
Normal file
81
sdk/lib/ucrt/stdio/fgetc.cpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
//
|
||||
// fgetc.cpp
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Functions that read the next character from a stream and return it. If the
|
||||
// read causes the stream to reach EOF, EOF is returned and the EOF bit is set
|
||||
// on the stream.
|
||||
//
|
||||
#include <corecrt_internal_stdio.h>
|
||||
|
||||
|
||||
|
||||
extern "C" int __cdecl _fgetc_nolock(FILE* const public_stream)
|
||||
{
|
||||
__crt_stdio_stream const stream(public_stream);
|
||||
|
||||
_VALIDATE_RETURN(stream.valid(), EINVAL, EOF);
|
||||
|
||||
--stream->_cnt;
|
||||
|
||||
if (stream->_cnt < 0)
|
||||
return __acrt_stdio_refill_and_read_narrow_nolock(stream.public_stream());
|
||||
|
||||
char const c = *stream->_ptr;
|
||||
++stream->_ptr;
|
||||
return c & 0xff;
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern "C" int __cdecl _getc_nolock(FILE* const stream)
|
||||
{
|
||||
return _fgetc_nolock(stream);
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern "C" int __cdecl fgetc(FILE* const public_stream)
|
||||
{
|
||||
__crt_stdio_stream const stream(public_stream);
|
||||
|
||||
_VALIDATE_RETURN(stream.valid(), EINVAL, EOF);
|
||||
|
||||
int return_value = 0;
|
||||
|
||||
_lock_file(stream.public_stream());
|
||||
__try
|
||||
{
|
||||
_VALIDATE_STREAM_ANSI_RETURN(stream, EINVAL, EOF);
|
||||
|
||||
return_value = _fgetc_nolock(stream.public_stream());
|
||||
}
|
||||
__finally
|
||||
{
|
||||
_unlock_file(stream.public_stream());
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern "C" int __cdecl getc(FILE* const stream)
|
||||
{
|
||||
return fgetc(stream);
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern "C" int __cdecl _fgetchar()
|
||||
{
|
||||
return fgetc(stdin);
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern "C" int __cdecl getchar()
|
||||
{
|
||||
return _fgetchar();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue