2 * Copyright (c) 1994 Regents of the University of Michigan.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of Michigan at Ann Arbor. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
17 * portable.h for LDAP -- this is where we define common stuff to make
18 * life easier on various Unix systems.
20 * Unless you are porting LDAP to a new platform, you should not need to
26 #if defined( hpux ) || defined( sunos5 ) || defined ( sgi ) || defined( SVR4 )
33 * under System V, use sysconf() instead of getdtablesize
35 #if !defined( USE_SYSCONF ) && defined( SYSV )
41 * under System V, daemons should use setsid() instead of detaching from their
44 #if !defined( USE_SETSID ) && defined( SYSV )
50 * System V has socket options in filio.h
52 #if !defined( NEED_FILIO ) && defined( SYSV ) && !defined( hpux )
57 * use lockf() under System V
59 #if !defined( USE_LOCKF ) && ( defined( SYSV ) || defined( aix ))
64 * on most systems, we should use waitpid() instead of waitN()
66 #if !defined( USE_WAITPID ) && !defined( nextstep )
72 * define the wait status argument type
74 #if ( defined( SunOS ) && SunOS < 40 ) || defined( nextstep )
75 #define WAITSTATUSTYPE union wait
77 #define WAITSTATUSTYPE int
81 * define the flags for wait
84 #define WAIT_FLAGS ( WNOHANG | WUNTRACED | WCONTINUED )
86 #define WAIT_FLAGS ( WNOHANG | WUNTRACED )
91 * defined the options for openlog (syslog)
94 #define OPENLOG_OPTIONS LOG_PID
96 #define OPENLOG_OPTIONS ( LOG_PID | LOG_NOWAIT )
100 * many systems do not have the setpwfile() library routine... we just
101 * enable use for those systems we know have it.
103 #ifndef HAVE_SETPWFILE
104 #if defined( sunos4 ) || defined( ultrix ) || defined( __osf__ )
105 #define HAVE_SETPWFILE
110 * Are sys_errlist and sys_nerr declared in stdio.h?
112 #ifndef SYSERRLIST_IN_STDIO
113 #if defined( freebsd ) || defined( netbsd ) || \
114 defined( __GLIBC__ ) && ( __GLIBC__ > 1 )
115 #define SYSERRLIST_IN_STDIO
122 #if !defined(FD_SET) && !defined(WINSOCK)
124 #define FD_SETSIZE 32
125 #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
126 #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
127 #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
128 #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
131 #if defined( hpux ) && defined( __STDC__ )
133 * Under HP/UX, select seems to want (int *) instead of fd_set. Non-ANSI
134 * compilers don't like recursive macros, so ignore the problem if __STDC__
137 #define select(a,b,c,d,e) select(a, (int *)b, (int *)c, (int *)d, e)
138 #endif /* hpux && __STDC__ */
142 * for signal() -- what do signal handling functions return?
146 # define SIG_FN void /* signal-catching functions return void */
149 # if (BSD >= 199006) || defined(NeXT) || defined(__osf__) || defined(sun) || defined(ultrix) || defined(apollo) || defined(POSIX_SIGNALS)
150 # define SIG_FN void /* signal-catching functions return void */
152 # define SIG_FN int /* signal-catching functions return int */
155 # define SIG_FN void /* signal-catching functions return void */
161 * call signal or sigset (signal does not block the signal while
162 * in the handler on sys v and sigset does not exist on bsd)
164 #if defined(SYSV) && !defined(linux)
165 #define SIGNAL sigset
167 #define SIGNAL signal
171 * toupper and tolower macros are different under bsd and sys v
173 #if defined( SYSV ) && !defined( hpux )
174 #define TOUPPER(c) (isascii(c) && islower(c) ? _toupper(c) : c)
175 #define TOLOWER(c) (isascii(c) && isupper(c) ? _tolower(c) : c)
177 #define TOUPPER(c) (isascii(c) && islower(c) ? toupper(c) : c)
178 #define TOLOWER(c) (isascii(c) && isupper(c) ? tolower(c) : c)
182 * put a cover on the tty-related ioctl calls we need to use
184 #if defined( NeXT ) || (defined(SunOS) && SunOS < 40)
185 #define TERMIO_TYPE struct sgttyb
186 #define TERMFLAG_TYPE int
187 #define GETATTR( fd, tiop ) ioctl((fd), TIOCGETP, (caddr_t)(tiop))
188 #define SETATTR( fd, tiop ) ioctl((fd), TIOCSETP, (caddr_t)(tiop))
189 #define GETFLAGS( tio ) (tio).sg_flags
190 #define SETFLAGS( tio, flags ) (tio).sg_flags = (flags)
193 #define TERMIO_TYPE struct termios
194 #define TERMFLAG_TYPE tcflag_t
195 #define GETATTR( fd, tiop ) tcgetattr((fd), (tiop))
196 #define SETATTR( fd, tiop ) tcsetattr((fd), TCSANOW /* 0 */, (tiop))
197 #define GETFLAGS( tio ) (tio).c_lflag
198 #define SETFLAGS( tio, flags ) (tio).c_lflag = (flags)
202 #if defined( ultrix ) || defined( nextstep )
203 extern char *strdup();
204 #endif /* ultrix || nextstep */
206 #endif /* _PORTABLE_H */