mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 13:26:17 +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
48
sdk/lib/ucrt/stdio/getw.cpp
Normal file
48
sdk/lib/ucrt/stdio/getw.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// getw.cpp
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Defines _getw(), which reads a binary integer to a stream.
|
||||
//
|
||||
#include <corecrt_internal_stdio.h>
|
||||
|
||||
|
||||
|
||||
// Reads a binary int value from the stream, byte-by-byte. On success, returns
|
||||
// the value written; on failure (error or eof), returns EOF. Note, however,
|
||||
// that the value may be EOF--that is, after all, a valid integer--so be sure to
|
||||
// test ferror() and feof() to check for error conditions.
|
||||
extern "C" int __cdecl _getw(FILE* const stream)
|
||||
{
|
||||
_VALIDATE_RETURN(stream != nullptr, EINVAL, EOF);
|
||||
|
||||
int return_value = EOF;
|
||||
|
||||
_lock_file(stream);
|
||||
__try
|
||||
{
|
||||
int value = 0;
|
||||
char* const first = reinterpret_cast<char*>(&value);
|
||||
char* const last = first + sizeof(value);
|
||||
|
||||
for (char* it = first; it != last; ++it)
|
||||
{
|
||||
*it = static_cast<char>(_getc_nolock(stream));
|
||||
}
|
||||
|
||||
if (feof(stream))
|
||||
__leave;
|
||||
|
||||
if (ferror(stream))
|
||||
__leave;
|
||||
|
||||
return_value = value;
|
||||
}
|
||||
__finally
|
||||
{
|
||||
_unlock_file(stream);
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue