Reactos
1//
2// isatty.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// Defines _isatty(), which tests whether a file refers to a character device.
7//
8#include <corecrt_internal_lowio.h>
9
10
11
12// Tests if the given file refers to a character device (e.g. terminal, console,
13// printer, serial port, etc.). Returns nonzero if so; zero if not.
14extern "C" int __cdecl _isatty(int const fh)
15{
16 _CHECK_FH_RETURN(fh, EBADF, 0);
17 _VALIDATE_RETURN((fh >= 0 && (unsigned)fh < (unsigned)_nhandle), EBADF, 0);
18
19 return static_cast<int>(_osfile(fh) & FDEV);
20}