1 /* 2 * 3 * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved. 4 * Use is subject to license terms. 5 * 6 */ 7 8 #pragma ident "%Z%%M% %I% %E% SMI" 9 10 /* 11 * Copyright (c) 1994 Regents of the University of Michigan. 12 * All rights reserved. 13 * 14 * Redistribution and use in source and binary forms are permitted 15 * provided that this notice is preserved and that due credit is given 16 * to the University of Michigan at Ann Arbor. The name of the University 17 * may not be used to endorse or promote products derived from this 18 * software without specific prior written permission. This software 19 * is provided ``as is'' without express or implied warranty. 20 */ 21 22 #ifndef _PORTABLE_H 23 #define _PORTABLE_H 24 25 /* 26 * portable.h for LDAP -- this is where we define common stuff to make 27 * life easier on various Unix systems. 28 * 29 * Unless you are porting LDAP to a new platform, you should not need to 30 * edit this file. 31 */ 32 33 34 #ifndef SYSV 35 #if defined( hpux ) || defined( sunos5 ) || defined ( sgi ) || defined( SVR4 ) 36 #define SYSV 37 #endif 38 #endif 39 40 41 /* 42 * under System V, use sysconf() instead of getdtablesize 43 */ 44 #if !defined( USE_SYSCONF ) && defined( SYSV ) 45 #define USE_SYSCONF 46 #endif 47 48 49 /* 50 * under System V, daemons should use setsid() instead of detaching from their 51 * tty themselves 52 */ 53 #if !defined( USE_SETSID ) && defined( SYSV ) 54 #define USE_SETSID 55 #endif 56 57 58 /* 59 * System V has socket options in filio.h 60 */ 61 #if !defined( NEED_FILIO ) && defined( SYSV ) && !defined( hpux ) 62 #define NEED_FILIO 63 #endif 64 65 /* 66 * use lockf() under System V 67 */ 68 #if !defined( USE_LOCKF ) && ( defined( SYSV ) || defined( aix )) 69 #define USE_LOCKF 70 #endif 71 72 /* 73 * on many systems, we should use waitpid() instead of waitN() 74 */ 75 #if !defined( USE_WAITPID ) && ( defined( SYSV ) || defined( sunos4 ) || defined( ultrix ) || defined( aix )) 76 #define USE_WAITPID 77 #endif 78 79 80 /* 81 * define the wait status argument type 82 */ 83 #if ( defined( SunOS ) && SunOS < 40 ) || defined( nextstep ) 84 #define WAITSTATUSTYPE union wait 85 #else 86 #define WAITSTATUSTYPE int 87 #endif 88 89 /* 90 * define the flags for wait 91 */ 92 #ifdef sunos5 93 #define WAIT_FLAGS ( WNOHANG | WUNTRACED | WCONTINUED ) 94 #else 95 #define WAIT_FLAGS ( WNOHANG | WUNTRACED ) 96 #endif 97 98 99 /* 100 * defined the options for openlog (syslog) 101 */ 102 #ifdef ultrix 103 #define OPENLOG_OPTIONS LOG_PID 104 #else 105 #define OPENLOG_OPTIONS ( LOG_PID | LOG_NOWAIT ) 106 #endif 107 108 109 /* 110 * some systems don't have the BSD re_comp and re_exec routines 111 */ 112 #ifndef NEED_BSDREGEX 113 #if defined( SYSV ) || defined( VMS ) || defined( netbsd ) || defined( freebsd ) || defined( linux ) 114 #define NEED_BSDREGEX 115 #endif 116 #endif 117 118 /* 119 * many systems do not have the setpwfile() library routine... we just 120 * enable use for those systems we know have it. 121 */ 122 #ifndef HAVE_SETPWFILE 123 #if defined( sunos4 ) || defined( ultrix ) || defined( __osf__ ) 124 #define HAVE_SETPWFILE 125 #endif 126 #endif 127 128 /* 129 * Are sys_errlist and sys_nerr declared in stdio.h? 130 */ 131 #ifndef SYSERRLIST_IN_STDIO 132 #if defined( freebsd ) 133 #define SYSERRLIST_IN_STDIO 134 #endif 135 #endif 136 137 /* 138 * for select() 139 */ 140 #if !defined(FD_SET) && !defined(WINSOCK) 141 #define NFDBITS 32 142 #define FD_SETSIZE 32 143 #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) 144 #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) 145 #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) 146 #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) 147 #endif /* FD_SET */ 148 149 #if defined( hpux ) && defined( __STDC__ ) 150 /* 151 * Under HP/UX, select seems to want (int *) instead of fd_set. Non-ANSI 152 * compilers don't like recursive macros, so ignore the problem if __STDC__ 153 * is not defined. 154 */ 155 #define select(a,b,c,d,e) select(a, (int *)b, (int *)c, (int *)d, e) 156 #endif /* hpux && __STDC__ */ 157 158 159 /* 160 * for signal() -- what do signal handling functions return? 161 */ 162 #ifndef SIG_FN 163 #ifdef sunos5 164 # define SIG_FN void /* signal-catching functions return void */ 165 #else /* sunos5 */ 166 # ifdef BSD 167 # if (BSD >= 199006) || defined(NeXT) || defined(__osf__) || defined(sun) || defined(ultrix) || defined(apollo) || defined(POSIX_SIGNALS) 168 # define SIG_FN void /* signal-catching functions return void */ 169 # else 170 # define SIG_FN int /* signal-catching functions return int */ 171 # endif 172 # else /* BSD */ 173 # define SIG_FN void /* signal-catching functions return void */ 174 # endif /* BSD */ 175 #endif /* sunos5 */ 176 #endif /* SIG_FN */ 177 178 /* 179 * call signal or sigset (signal does not block the signal while 180 * in the handler on sys v and sigset does not exist on bsd) 181 */ 182 #ifdef SYSV 183 #define SIGNAL sigset 184 #else 185 #define SIGNAL signal 186 #endif 187 188 /* 189 * toupper and tolower macros are different under bsd and sys v 190 */ 191 #if defined( SYSV ) && !defined( hpux ) 192 #define TOUPPER(c) (isascii(c) && islower(c) ? _toupper(c) : c) 193 #define TOLOWER(c) (isascii(c) && isupper(c) ? _tolower(c) : c) 194 #else 195 #define TOUPPER(c) (isascii(c) && islower(c) ? toupper(c) : c) 196 #define TOLOWER(c) (isascii(c) && isupper(c) ? tolower(c) : c) 197 #endif 198 199 /* 200 * put a cover on the tty-related ioctl calls we need to use 201 */ 202 #if defined( NeXT ) || (defined(SunOS) && SunOS < 40) 203 #define TERMIO_TYPE struct sgttyb 204 #define TERMFLAG_TYPE int 205 #define GETATTR( fd, tiop ) ioctl((fd), TIOCGETP, (caddr_t)(tiop)) 206 #define SETATTR( fd, tiop ) ioctl((fd), TIOCSETP, (caddr_t)(tiop)) 207 #define GETFLAGS( tio ) (tio).sg_flags 208 #define SETFLAGS( tio, flags ) (tio).sg_flags = (flags) 209 #else 210 #define USE_TERMIOS 211 #define TERMIO_TYPE struct termios 212 #define TERMFLAG_TYPE tcflag_t 213 #define GETATTR( fd, tiop ) tcgetattr((fd), (tiop)) 214 #define SETATTR( fd, tiop ) tcsetattr((fd), TCSANOW /* 0 */, (tiop)) 215 #define GETFLAGS( tio ) (tio).c_lflag 216 #define SETFLAGS( tio, flags ) (tio).c_lflag = (flags) 217 #endif 218 219 220 #if defined( ultrix ) || defined( nextstep ) 221 extern char *strdup(); 222 #endif /* ultrix || nextstep */ 223 224 #endif /* _PORTABLE_H */ 225