#include <stdio.h>
#ifdef sun
#ifdef _IOSTRG
#define sunos
#else
#define solaris
#endif
#endif
#include <ar.h>
#ifdef AIAMAG
#define aix
#endif
#ifdef _HIUX_SOURCE
#define hpux
#endif
/*
* Select system dependent system calls about:
* synchronous I/O multiplexing: {HAS_SELECT, HAS_POLL}
* terminal control: {USE_SGTTY, USE_TERMIO, USE_TERMIOS}
*/
#if defined(sunos) \
|| defined(pureBSD43) \
|| defined(ultrix) \
|| defined(sony_news) \
|| defined(MACH) \
|| defined(NeXT) \
|| defined(bsdi) \
|| defined(__FreeBSD__)
#define USE_SGTTY
#define HAS_SELECT
#endif
#if defined(solaris) \
|| defined(sgi) \
|| defined(nec_ews) \
|| defined(_nec_ews_svr4)
#define USE_TERMIO
#define HAS_POLL
#endif
#if defined(hpux) \
|| defined(aix) \
|| defined(__linux__) \
|| defined(__osf__) && defined(__alpha) \
|| defined(H3050R)
#define USE_TERMIOS
#define HAS_SELECT
#endif
#if defined (AUX3) || defined (macII) || (_AUX_SOURCE)
# undef AUX3
# define AUX3
# define USE_TERMIO
# define HAS_SELECT
#endif
/*
* Get the count of bufferd characters.
*/
#ifdef __linux__
#ifdef _IO_STDIO_H
#define READYCC(fp) (fp->_IO_read_end - fp->_IO_read_ptr)
#else
#define READYCC(fp) (fp->_egptr - fp->_gptr)
#endif
#else
#if defined(bsdi) || defined(__FreeBSD__)
#define READYCC(fp) (fp->_r)
#else
#define READYCC(fp) (fp->_cnt)
#endif
#endif
syntax highlighted by Code2HTML, v. 0.9.1