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 many systems, we should use waitpid() instead of waitN()
66 #if !defined( USE_WAITPID ) && ( defined( SYSV ) || defined( sunos4 ) || defined( ultrix ) || defined( aix ))
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 )
101 * some systems don't have the BSD re_comp and re_exec routines
103 #ifndef NEED_BSDREGEX
104 #if defined( SYSV ) || defined( VMS ) || defined( netbsd ) || defined( freebsd ) || defined( linux )
105 #define NEED_BSDREGEX
110 * many systems do not have the setpwfile() library routine... we just
111 * enable use for those systems we know have it.
113 #ifndef HAVE_SETPWFILE
114 #if defined( sunos4 ) || defined( ultrix ) || defined( __osf__ )
115 #define HAVE_SETPWFILE
120 * Are sys_errlist and sys_nerr declared in stdio.h?
122 #ifndef SYSERRLIST_IN_STDIO
123 #if defined( freebsd )
124 #define SYSERRLIST_IN_STDIO
131 #if !defined(FD_SET) && !defined(WINSOCK)
133 #define FD_SETSIZE 32
134 #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
135 #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
136 #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
137 #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
140 #if defined( hpux ) && defined( __STDC__ )
142 * Under HP/UX, select seems to want (int *) instead of fd_set. Non-ANSI
143 * compilers don't like recursive macros, so ignore the problem if __STDC__
146 #define select(a,b,c,d,e) select(a, (int *)b, (int *)c, (int *)d, e)
147 #endif /* hpux && __STDC__ */
151 * for signal() -- what do signal handling functions return?
155 # define SIG_FN void /* signal-catching functions return void */
158 # if (BSD >= 199006) || defined(NeXT) || defined(__osf__) || defined(sun) || defined(ultrix) || defined(apollo) || defined(POSIX_SIGNALS)
159 # define SIG_FN void /* signal-catching functions return void */
161 # define SIG_FN int /* signal-catching functions return int */
164 # define SIG_FN void /* signal-catching functions return void */
170 * call signal or sigset (signal does not block the signal while
171 * in the handler on sys v and sigset does not exist on bsd)
174 #define SIGNAL sigset
176 #define SIGNAL signal
180 * toupper and tolower macros are different under bsd and sys v
182 #if defined( SYSV ) && !defined( hpux )
183 #define TOUPPER(c) (isascii(c) && islower(c) ? _toupper(c) : c)
184 #define TOLOWER(c) (isascii(c) && isupper(c) ? _tolower(c) : c)
186 #define TOUPPER(c) (isascii(c) && islower(c) ? toupper(c) : c)
187 #define TOLOWER(c) (isascii(c) && isupper(c) ? tolower(c) : c)
191 * put a cover on the tty-related ioctl calls we need to use
193 #if defined( NeXT ) || (defined(SunOS) && SunOS < 40)
194 #define TERMIO_TYPE struct sgttyb
195 #define TERMFLAG_TYPE int
196 #define GETATTR( fd, tiop ) ioctl((fd), TIOCGETP, (caddr_t)(tiop))
197 #define SETATTR( fd, tiop ) ioctl((fd), TIOCSETP, (caddr_t)(tiop))
198 #define GETFLAGS( tio ) (tio).sg_flags
199 #define SETFLAGS( tio, flags ) (tio).sg_flags = (flags)
202 #define TERMIO_TYPE struct termios
203 #define TERMFLAG_TYPE tcflag_t
204 #define GETATTR( fd, tiop ) tcgetattr((fd), (tiop))
205 #define SETATTR( fd, tiop ) tcsetattr((fd), TCSANOW /* 0 */, (tiop))
206 #define GETFLAGS( tio ) (tio).c_lflag
207 #define SETFLAGS( tio, flags ) (tio).c_lflag = (flags)
211 #if defined( ultrix ) || defined( nextstep )
212 extern char *strdup();
213 #endif /* ultrix || nextstep */
215 #endif /* _PORTABLE_H */