For a namespace clean function, implement
_isatty
, otherwise implement
isatty
. The detailed implementation will
depend on the file handling functionality available.
This specifically checks whether a stream is a terminal. The minimal implementation only has the single output stream, which is to the console, so always returns 1.
int _isatty (int file) { return 1; } /* _isatty () */
Caution | |
---|---|
Contrary to the standard |
The OpenRISC 1000 version gives a little more detail, setting
errno
if the stream is not standard output,
standard error or (for the UART version of the BSP) standard
input.
#include <errno.h> #include <unistd.h> #undef ERRNO extern int errno; int _isatty (int file) { if ((file == STDOUT_FILENO) || (file == STDERR_FILENO)) { return 1; } else { errno = EBADF; return -1; } } /* _isatty () */
The UART version is almost identical, but also succeeds for standard input.