ReactOS 0.4.16-dev-2110-ge3521eb
putw.cpp
Go to the documentation of this file.
1//
2// putw.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// Defines _putw(), which writes a binary integer to a stream.
7//
9
10
11
12// Writes the binary int value to the stream, byte-by-byte. On success, returns
13// the value written; on failure, returns EOF. Note, however, that the value may
14// be EOF--that is, after all, a valid integer--so be sure to test ferror() and
15// feof() to check for error conditions.
16extern "C" int __cdecl _putw(int const value, FILE* const stream)
17{
18 _VALIDATE_RETURN(stream != nullptr, EINVAL, EOF);
19
20 int return_value = EOF;
21
23 __try
24 {
25 char const* const first = reinterpret_cast<char const*>(&value);
26 char const* const last = first + sizeof(value);
27 for (char const* it = first; it != last; ++it)
28 {
30 }
31
32 if (ferror(stream))
33 __leave;
34
35 return_value = value;
36 }
38 {
40 }
42
43 return return_value;
44}
#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
int CDECL ferror(FILE *file)
Definition: file.c:3811
#define __cdecl
Definition: corecrt.h:121
#define EINVAL
Definition: errno.h:44
#define EOF
Definition: stdio.h:33
const GLint * first
Definition: glext.h:5794
static UINT UINT last
Definition: font.c:45
#define __try
Definition: pseh2_64.h:188
#define __leave
Definition: pseh2_64.h:192
#define __endtry
Definition: pseh2_64.h:191
#define __finally
Definition: pseh2_64.h:190
int __cdecl _putw(int const value, FILE *const stream)
Definition: putw.cpp:16
#define _fputc_nolock(_c, _stream)
Definition: stdio.h:1143
Definition: parse.h:23
Definition: pdh_main.c:96
#define const
Definition: zconf.h:233