#ifndef _PORTABLE_H
#define _PORTABLE_H
#ifndef SYSV
#if defined( hpux ) || defined( sunos5 ) || defined ( sgi ) || defined( SVR4 )
#define SYSV
#endif
#endif
#if !defined( USE_SYSCONF ) && defined( SYSV )
#define USE_SYSCONF
#endif
#if !defined( USE_SETSID ) && defined( SYSV )
#define USE_SETSID
#endif
#if !defined( NEED_FILIO ) && defined( SYSV ) && !defined( hpux )
#define NEED_FILIO
#endif
#if !defined( USE_LOCKF ) && ( defined( SYSV ) || defined( aix ))
#define USE_LOCKF
#endif
#if !defined( USE_WAITPID ) && !defined( nextstep )
#define USE_WAITPID
#endif
#if ( defined( SunOS ) && SunOS < 40 ) || defined( nextstep )
#define WAITSTATUSTYPE union wait
#else
#define WAITSTATUSTYPE int
#endif
#ifdef sunos5
#define WAIT_FLAGS ( WNOHANG | WUNTRACED | WCONTINUED )
#else
#define WAIT_FLAGS ( WNOHANG | WUNTRACED )
#endif
#ifdef ultrix
#define OPENLOG_OPTIONS LOG_PID
#else
#define OPENLOG_OPTIONS ( LOG_PID | LOG_NOWAIT )
#endif
#ifndef NEED_BSDREGEX
#if defined( SYSV ) || defined( VMS ) || defined( netbsd ) || defined( freebsd ) || defined( linux )
#define NEED_BSDREGEX
#endif
#endif
#ifndef HAVE_SETPWFILE
#if defined( sunos4 ) || defined( ultrix ) || defined( __osf__ )
#define HAVE_SETPWFILE
#endif
#endif
#ifndef SYSERRLIST_IN_STDIO
#if defined( freebsd ) || defined( __NeXT__ ) || defined(__APPLE__)
#define SYSERRLIST_IN_STDIO
#endif
#endif
#if !defined(FD_SET) && !defined(WINSOCK)
#define NFDBITS 32
#define FD_SETSIZE 32
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
#endif
#if defined( hpux ) && defined( __STDC__ )
#define select(a,b,c,d,e) select(a, (int *)b, (int *)c, (int *)d, e)
#endif
#ifndef SIG_FN
#ifdef sunos5
# define SIG_FN void
#else
# ifdef BSD
# if (BSD >= 199006) || defined(NeXT) || defined (__APPLE__) || defined(__osf__) || defined(sun) || defined(ultrix) || defined(apollo) || defined(POSIX_SIGNALS)
# define SIG_FN void
# else
# define SIG_FN int
# endif
# else
# define SIG_FN void
# endif
#endif
#endif
#ifdef SYSV
#define SIGNAL sigset
#else
#define SIGNAL signal
#endif
#if defined( SYSV ) && !defined( hpux )
#define TOUPPER(c) (isascii(c) && islower(c) ? _toupper(c) : c)
#define TOLOWER(c) (isascii(c) && isupper(c) ? _tolower(c) : c)
#else
#define TOUPPER(c) (isascii(c) && islower(c) ? toupper(c) : c)
#define TOLOWER(c) (isascii(c) && isupper(c) ? tolower(c) : c)
#endif
#if defined( nextstep ) || (defined(SunOS) && SunOS < 40)
#define TERMIO_TYPE struct sgttyb
#define TERMFLAG_TYPE int
#define GETATTR( fd, tiop ) ioctl((fd), TIOCGETP, (caddr_t)(tiop))
#define SETATTR( fd, tiop ) ioctl((fd), TIOCSETP, (caddr_t)(tiop))
#define GETFLAGS( tio ) (tio).sg_flags
#define SETFLAGS( tio, flags ) (tio).sg_flags = (flags)
#else
#define USE_TERMIOS
#define TERMIO_TYPE struct termios
#define TERMFLAG_TYPE tcflag_t
#define GETATTR( fd, tiop ) tcgetattr((fd), (tiop))
#define SETATTR( fd, tiop ) tcsetattr((fd), TCSANOW , (tiop))
#define GETFLAGS( tio ) (tio).c_lflag
#define SETFLAGS( tio, flags ) (tio).c_lflag = (flags)
#endif
#if defined( ultrix ) || defined( nextstep )
extern char *strdup();
#endif
#endif