1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * Copyright (c) 2001 by Sun Microsystems, Inc. 3*7c478bd9Sstevel@tonic-gate * All rights reserved. 4*7c478bd9Sstevel@tonic-gate */ 5*7c478bd9Sstevel@tonic-gate 6*7c478bd9Sstevel@tonic-gate /* 7*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the Netscape Public 8*7c478bd9Sstevel@tonic-gate * License Version 1.1 (the "License"); you may not use this file 9*7c478bd9Sstevel@tonic-gate * except in compliance with the License. You may obtain a copy of 10*7c478bd9Sstevel@tonic-gate * the License at http://www.mozilla.org/NPL/ 11*7c478bd9Sstevel@tonic-gate * 12*7c478bd9Sstevel@tonic-gate * Software distributed under the License is distributed on an "AS 13*7c478bd9Sstevel@tonic-gate * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 14*7c478bd9Sstevel@tonic-gate * implied. See the License for the specific language governing 15*7c478bd9Sstevel@tonic-gate * rights and limitations under the License. 16*7c478bd9Sstevel@tonic-gate * 17*7c478bd9Sstevel@tonic-gate * The Original Code is Mozilla Communicator client code, released 18*7c478bd9Sstevel@tonic-gate * March 31, 1998. 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * The Initial Developer of the Original Code is Netscape 21*7c478bd9Sstevel@tonic-gate * Communications Corporation. Portions created by Netscape are 22*7c478bd9Sstevel@tonic-gate * Copyright (C) 1998-1999 Netscape Communications Corporation. All 23*7c478bd9Sstevel@tonic-gate * Rights Reserved. 24*7c478bd9Sstevel@tonic-gate * 25*7c478bd9Sstevel@tonic-gate * Contributor(s): 26*7c478bd9Sstevel@tonic-gate */ 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate /* 29*7c478bd9Sstevel@tonic-gate * Copyright (c) 1994 Regents of the University of Michigan. 30*7c478bd9Sstevel@tonic-gate * All rights reserved. 31*7c478bd9Sstevel@tonic-gate * 32*7c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms are permitted 33*7c478bd9Sstevel@tonic-gate * provided that this notice is preserved and that due credit is given 34*7c478bd9Sstevel@tonic-gate * to the University of Michigan at Ann Arbor. The name of the University 35*7c478bd9Sstevel@tonic-gate * may not be used to endorse or promote products derived from this 36*7c478bd9Sstevel@tonic-gate * software without specific prior written permission. This software 37*7c478bd9Sstevel@tonic-gate * is provided ``as is'' without express or implied warranty. 38*7c478bd9Sstevel@tonic-gate */ 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #ifndef _PORTABLE_H 41*7c478bd9Sstevel@tonic-gate #define _PORTABLE_H 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate /* 44*7c478bd9Sstevel@tonic-gate * portable.h for LDAP -- this is where we define common stuff to make 45*7c478bd9Sstevel@tonic-gate * life easier on various Unix systems. 46*7c478bd9Sstevel@tonic-gate * 47*7c478bd9Sstevel@tonic-gate * Unless you are porting LDAP to a new platform, you should not need to 48*7c478bd9Sstevel@tonic-gate * edit this file. 49*7c478bd9Sstevel@tonic-gate */ 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate #ifndef SYSV 52*7c478bd9Sstevel@tonic-gate #if defined( hpux ) || defined( sunos5 ) || defined ( sgi ) || defined( SVR4 ) 53*7c478bd9Sstevel@tonic-gate #define SYSV 54*7c478bd9Sstevel@tonic-gate #endif 55*7c478bd9Sstevel@tonic-gate #endif 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate /* 58*7c478bd9Sstevel@tonic-gate * under System V, use sysconf() instead of getdtablesize 59*7c478bd9Sstevel@tonic-gate */ 60*7c478bd9Sstevel@tonic-gate #if !defined( USE_SYSCONF ) && defined( SYSV ) 61*7c478bd9Sstevel@tonic-gate #define USE_SYSCONF 62*7c478bd9Sstevel@tonic-gate #endif 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate /* 65*7c478bd9Sstevel@tonic-gate * under System V, daemons should use setsid() instead of detaching from their 66*7c478bd9Sstevel@tonic-gate * tty themselves 67*7c478bd9Sstevel@tonic-gate */ 68*7c478bd9Sstevel@tonic-gate #if !defined( USE_SETSID ) && defined( SYSV ) 69*7c478bd9Sstevel@tonic-gate #define USE_SETSID 70*7c478bd9Sstevel@tonic-gate #endif 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate /* 73*7c478bd9Sstevel@tonic-gate * System V has socket options in filio.h 74*7c478bd9Sstevel@tonic-gate */ 75*7c478bd9Sstevel@tonic-gate #if !defined( NEED_FILIO ) && defined( SYSV ) && !defined( hpux ) && !defined( AIX ) 76*7c478bd9Sstevel@tonic-gate #define NEED_FILIO 77*7c478bd9Sstevel@tonic-gate #endif 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate /* 80*7c478bd9Sstevel@tonic-gate * use lockf() under System V 81*7c478bd9Sstevel@tonic-gate */ 82*7c478bd9Sstevel@tonic-gate #if !defined( USE_LOCKF ) && ( defined( SYSV ) || defined( aix )) 83*7c478bd9Sstevel@tonic-gate #define USE_LOCKF 84*7c478bd9Sstevel@tonic-gate #endif 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate /* 87*7c478bd9Sstevel@tonic-gate * on many systems, we should use waitpid() instead of waitN() 88*7c478bd9Sstevel@tonic-gate */ 89*7c478bd9Sstevel@tonic-gate #if !defined( USE_WAITPID ) && ( defined( SYSV ) || defined( sunos4 ) || defined( ultrix ) || defined( aix )) 90*7c478bd9Sstevel@tonic-gate #define USE_WAITPID 91*7c478bd9Sstevel@tonic-gate #endif 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate /* 94*7c478bd9Sstevel@tonic-gate * define the wait status argument type 95*7c478bd9Sstevel@tonic-gate */ 96*7c478bd9Sstevel@tonic-gate #if ( defined( SunOS ) && SunOS < 40 ) || defined( nextstep ) 97*7c478bd9Sstevel@tonic-gate #define WAITSTATUSTYPE union wait 98*7c478bd9Sstevel@tonic-gate #else 99*7c478bd9Sstevel@tonic-gate #define WAITSTATUSTYPE int 100*7c478bd9Sstevel@tonic-gate #endif 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate /* 103*7c478bd9Sstevel@tonic-gate * define the flags for wait 104*7c478bd9Sstevel@tonic-gate */ 105*7c478bd9Sstevel@tonic-gate #ifdef sunos5 106*7c478bd9Sstevel@tonic-gate #define WAIT_FLAGS ( WNOHANG | WUNTRACED | WCONTINUED ) 107*7c478bd9Sstevel@tonic-gate #else 108*7c478bd9Sstevel@tonic-gate #define WAIT_FLAGS ( WNOHANG | WUNTRACED ) 109*7c478bd9Sstevel@tonic-gate #endif 110*7c478bd9Sstevel@tonic-gate 111*7c478bd9Sstevel@tonic-gate /* 112*7c478bd9Sstevel@tonic-gate * defined the options for openlog (syslog) 113*7c478bd9Sstevel@tonic-gate */ 114*7c478bd9Sstevel@tonic-gate #ifdef ultrix 115*7c478bd9Sstevel@tonic-gate #define OPENLOG_OPTIONS LOG_PID 116*7c478bd9Sstevel@tonic-gate #else 117*7c478bd9Sstevel@tonic-gate #define OPENLOG_OPTIONS ( LOG_PID | LOG_NOWAIT ) 118*7c478bd9Sstevel@tonic-gate #endif 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate /* 121*7c478bd9Sstevel@tonic-gate * some systems don't have the BSD re_comp and re_exec routines 122*7c478bd9Sstevel@tonic-gate */ 123*7c478bd9Sstevel@tonic-gate #ifndef NEED_BSDREGEX 124*7c478bd9Sstevel@tonic-gate #if ( defined( SYSV ) || defined( VMS ) || defined( netbsd ) || defined( freebsd ) || defined( linux )) && !defined(sgi) 125*7c478bd9Sstevel@tonic-gate #define NEED_BSDREGEX 126*7c478bd9Sstevel@tonic-gate #endif 127*7c478bd9Sstevel@tonic-gate #endif 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate /* 130*7c478bd9Sstevel@tonic-gate * many systems do not have the setpwfile() library routine... we just 131*7c478bd9Sstevel@tonic-gate * enable use for those systems we know have it. 132*7c478bd9Sstevel@tonic-gate */ 133*7c478bd9Sstevel@tonic-gate #ifndef HAVE_SETPWFILE 134*7c478bd9Sstevel@tonic-gate #if defined( sunos4 ) || defined( ultrix ) || defined( OSF1 ) 135*7c478bd9Sstevel@tonic-gate #define HAVE_SETPWFILE 136*7c478bd9Sstevel@tonic-gate #endif 137*7c478bd9Sstevel@tonic-gate #endif 138*7c478bd9Sstevel@tonic-gate 139*7c478bd9Sstevel@tonic-gate /* 140*7c478bd9Sstevel@tonic-gate * Are sys_errlist and sys_nerr declared in stdio.h? 141*7c478bd9Sstevel@tonic-gate */ 142*7c478bd9Sstevel@tonic-gate #ifndef SYSERRLIST_IN_STDIO 143*7c478bd9Sstevel@tonic-gate #if defined( freebsd ) 144*7c478bd9Sstevel@tonic-gate #define SYSERRLIST_IN_STDIO 145*7c478bd9Sstevel@tonic-gate #endif 146*7c478bd9Sstevel@tonic-gate #endif 147*7c478bd9Sstevel@tonic-gate 148*7c478bd9Sstevel@tonic-gate 149*7c478bd9Sstevel@tonic-gate /* 150*7c478bd9Sstevel@tonic-gate * Is snprintf() part of the standard C runtime library? 151*7c478bd9Sstevel@tonic-gate */ 152*7c478bd9Sstevel@tonic-gate #if !defined(HAVE_SNPRINTF) 153*7c478bd9Sstevel@tonic-gate #if defined(SOLARIS) || defined(LINUX) || defined(HPUX) 154*7c478bd9Sstevel@tonic-gate #define HAVE_SNPRINTF 155*7c478bd9Sstevel@tonic-gate #endif 156*7c478bd9Sstevel@tonic-gate #endif 157*7c478bd9Sstevel@tonic-gate 158*7c478bd9Sstevel@tonic-gate 159*7c478bd9Sstevel@tonic-gate /* 160*7c478bd9Sstevel@tonic-gate * Async IO. Use a non blocking implementation of connect() and 161*7c478bd9Sstevel@tonic-gate * dns functions 162*7c478bd9Sstevel@tonic-gate */ 163*7c478bd9Sstevel@tonic-gate #if !defined(LDAP_ASYNC_IO) 164*7c478bd9Sstevel@tonic-gate #if !defined(_WINDOWS) && !defined(macintosh) 165*7c478bd9Sstevel@tonic-gate #define LDAP_ASYNC_IO 166*7c478bd9Sstevel@tonic-gate #endif /* _WINDOWS */ 167*7c478bd9Sstevel@tonic-gate #endif 168*7c478bd9Sstevel@tonic-gate 169*7c478bd9Sstevel@tonic-gate /* 170*7c478bd9Sstevel@tonic-gate * for select() 171*7c478bd9Sstevel@tonic-gate */ 172*7c478bd9Sstevel@tonic-gate #if !defined(WINSOCK) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2) 173*7c478bd9Sstevel@tonic-gate #if defined(hpux) || defined(LINUX) || defined(SUNOS4) 174*7c478bd9Sstevel@tonic-gate #include <sys/time.h> 175*7c478bd9Sstevel@tonic-gate #else 176*7c478bd9Sstevel@tonic-gate #include <sys/select.h> 177*7c478bd9Sstevel@tonic-gate #endif 178*7c478bd9Sstevel@tonic-gate #if !defined(FD_SET) 179*7c478bd9Sstevel@tonic-gate #define NFDBITS 32 180*7c478bd9Sstevel@tonic-gate #define FD_SETSIZE 32 181*7c478bd9Sstevel@tonic-gate #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) 182*7c478bd9Sstevel@tonic-gate #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) 183*7c478bd9Sstevel@tonic-gate #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) 184*7c478bd9Sstevel@tonic-gate #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) 185*7c478bd9Sstevel@tonic-gate #endif /* !FD_SET */ 186*7c478bd9Sstevel@tonic-gate #endif /* !WINSOCK && !_WINDOWS && !macintosh */ 187*7c478bd9Sstevel@tonic-gate 188*7c478bd9Sstevel@tonic-gate 189*7c478bd9Sstevel@tonic-gate /* 190*7c478bd9Sstevel@tonic-gate * for connect() -- must we block signals when calling connect()? This 191*7c478bd9Sstevel@tonic-gate * is necessary on some buggy UNIXes. 192*7c478bd9Sstevel@tonic-gate */ 193*7c478bd9Sstevel@tonic-gate #if !defined(LDAP_CONNECT_MUST_NOT_BE_INTERRUPTED) && \ 194*7c478bd9Sstevel@tonic-gate ( defined(AIX) || defined(IRIX) || defined(HPUX) || defined(SUNOS4) \ 195*7c478bd9Sstevel@tonic-gate || defined(SOLARIS) || defined(OSF1) ||defined(freebsd)) 196*7c478bd9Sstevel@tonic-gate #define LDAP_CONNECT_MUST_NOT_BE_INTERRUPTED 197*7c478bd9Sstevel@tonic-gate #endif 198*7c478bd9Sstevel@tonic-gate 199*7c478bd9Sstevel@tonic-gate 200*7c478bd9Sstevel@tonic-gate /* 201*7c478bd9Sstevel@tonic-gate * for signal() -- what do signal handling functions return? 202*7c478bd9Sstevel@tonic-gate */ 203*7c478bd9Sstevel@tonic-gate #ifndef SIG_FN 204*7c478bd9Sstevel@tonic-gate #ifdef sunos5 205*7c478bd9Sstevel@tonic-gate # define SIG_FN void /* signal-catching functions return void */ 206*7c478bd9Sstevel@tonic-gate #else /* sunos5 */ 207*7c478bd9Sstevel@tonic-gate # ifdef BSD 208*7c478bd9Sstevel@tonic-gate # if (BSD >= 199006) || defined(NeXT) || defined(OSF1) || defined(sun) || defined(ultrix) || defined(apollo) || defined(POSIX_SIGNALS) 209*7c478bd9Sstevel@tonic-gate # define SIG_FN void /* signal-catching functions return void */ 210*7c478bd9Sstevel@tonic-gate # else 211*7c478bd9Sstevel@tonic-gate # define SIG_FN int /* signal-catching functions return int */ 212*7c478bd9Sstevel@tonic-gate # endif 213*7c478bd9Sstevel@tonic-gate # else /* BSD */ 214*7c478bd9Sstevel@tonic-gate # define SIG_FN void /* signal-catching functions return void */ 215*7c478bd9Sstevel@tonic-gate # endif /* BSD */ 216*7c478bd9Sstevel@tonic-gate #endif /* sunos5 */ 217*7c478bd9Sstevel@tonic-gate #endif /* SIG_FN */ 218*7c478bd9Sstevel@tonic-gate 219*7c478bd9Sstevel@tonic-gate /* 220*7c478bd9Sstevel@tonic-gate * toupper and tolower macros are different under bsd and sys v 221*7c478bd9Sstevel@tonic-gate */ 222*7c478bd9Sstevel@tonic-gate #if defined( SYSV ) && !defined( hpux ) 223*7c478bd9Sstevel@tonic-gate #define TOUPPER(c) (isascii(c) && islower(c) ? _toupper(c) : c) 224*7c478bd9Sstevel@tonic-gate #define TOLOWER(c) (isascii(c) && isupper(c) ? _tolower(c) : c) 225*7c478bd9Sstevel@tonic-gate #else 226*7c478bd9Sstevel@tonic-gate #define TOUPPER(c) (isascii(c) && islower(c) ? toupper(c) : c) 227*7c478bd9Sstevel@tonic-gate #define TOLOWER(c) (isascii(c) && isupper(c) ? tolower(c) : c) 228*7c478bd9Sstevel@tonic-gate #endif 229*7c478bd9Sstevel@tonic-gate 230*7c478bd9Sstevel@tonic-gate /* 231*7c478bd9Sstevel@tonic-gate * put a cover on the tty-related ioctl calls we need to use 232*7c478bd9Sstevel@tonic-gate */ 233*7c478bd9Sstevel@tonic-gate #if defined( NeXT ) || (defined(SunOS) && SunOS < 40) 234*7c478bd9Sstevel@tonic-gate #define TERMIO_TYPE struct sgttyb 235*7c478bd9Sstevel@tonic-gate #define TERMFLAG_TYPE int 236*7c478bd9Sstevel@tonic-gate #define GETATTR( fd, tiop ) ioctl((fd), TIOCGETP, (caddr_t)(tiop)) 237*7c478bd9Sstevel@tonic-gate #define SETATTR( fd, tiop ) ioctl((fd), TIOCSETP, (caddr_t)(tiop)) 238*7c478bd9Sstevel@tonic-gate #define GETFLAGS( tio ) (tio).sg_flags 239*7c478bd9Sstevel@tonic-gate #define SETFLAGS( tio, flags ) (tio).sg_flags = (flags) 240*7c478bd9Sstevel@tonic-gate #else 241*7c478bd9Sstevel@tonic-gate #define USE_TERMIOS 242*7c478bd9Sstevel@tonic-gate #define TERMIO_TYPE struct termios 243*7c478bd9Sstevel@tonic-gate #define TERMFLAG_TYPE tcflag_t 244*7c478bd9Sstevel@tonic-gate #define GETATTR( fd, tiop ) tcgetattr((fd), (tiop)) 245*7c478bd9Sstevel@tonic-gate #define SETATTR( fd, tiop ) tcsetattr((fd), TCSANOW /* 0 */, (tiop)) 246*7c478bd9Sstevel@tonic-gate #define GETFLAGS( tio ) (tio).c_lflag 247*7c478bd9Sstevel@tonic-gate #define SETFLAGS( tio, flags ) (tio).c_lflag = (flags) 248*7c478bd9Sstevel@tonic-gate #endif 249*7c478bd9Sstevel@tonic-gate 250*7c478bd9Sstevel@tonic-gate #if ( !defined( HPUX9 )) && ( !defined( sunos4 )) && ( !defined( SNI )) && \ 251*7c478bd9Sstevel@tonic-gate ( !defined( HAVE_TIME_R )) 252*7c478bd9Sstevel@tonic-gate #define HAVE_TIME_R 253*7c478bd9Sstevel@tonic-gate #endif 254*7c478bd9Sstevel@tonic-gate 255*7c478bd9Sstevel@tonic-gate #if defined( sunos5 ) || defined( aix ) 256*7c478bd9Sstevel@tonic-gate #define HAVE_GETPWNAM_R 257*7c478bd9Sstevel@tonic-gate #define HAVE_GETGRNAM_R 258*7c478bd9Sstevel@tonic-gate #endif 259*7c478bd9Sstevel@tonic-gate 260*7c478bd9Sstevel@tonic-gate #if defined(SNI) || defined(LINUX1_2) 261*7c478bd9Sstevel@tonic-gate int strcasecmp(const char *, const char *); 262*7c478bd9Sstevel@tonic-gate #ifdef SNI 263*7c478bd9Sstevel@tonic-gate int strncasecmp(const char *, const char *, int); 264*7c478bd9Sstevel@tonic-gate #endif /* SNI */ 265*7c478bd9Sstevel@tonic-gate #ifdef LINUX1_2 266*7c478bd9Sstevel@tonic-gate int strncasecmp(const char *, const char *, size_t); 267*7c478bd9Sstevel@tonic-gate #endif /* LINUX1_2 */ 268*7c478bd9Sstevel@tonic-gate #endif /* SNI || LINUX1_2 */ 269*7c478bd9Sstevel@tonic-gate 270*7c478bd9Sstevel@tonic-gate #if defined(_WINDOWS) || defined(macintosh) || defined(XP_OS2) 271*7c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n ) 272*7c478bd9Sstevel@tonic-gate #define NSLDAPI_CTIME( c, b, l ) ctime( c ) 273*7c478bd9Sstevel@tonic-gate #define STRTOK( s1, s2, l ) strtok( s1, s2 ) 274*7c478bd9Sstevel@tonic-gate #else /* UNIX */ 275*7c478bd9Sstevel@tonic-gate #if defined(sgi) || defined(HPUX9) || defined(LINUX1_2) || defined(SCOOS) || \ 276*7c478bd9Sstevel@tonic-gate defined(UNIXWARE) || defined(SUNOS4) || defined(SNI) || defined(BSDI) || \ 277*7c478bd9Sstevel@tonic-gate defined(NCR) || defined(OSF1) || defined(NEC) || \ 278*7c478bd9Sstevel@tonic-gate ( defined(HPUX10) && !defined(_REENTRANT)) || defined(HPUX11) || \ 279*7c478bd9Sstevel@tonic-gate defined(UnixWare) || defined(LINUX) || (defined(AIX) && !defined(USE_REENTRANT_LIBC)) 280*7c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n ) 281*7c478bd9Sstevel@tonic-gate #elif defined(AIX) 282*7c478bd9Sstevel@tonic-gate /* Maybe this is for another version of AIX? 283*7c478bd9Sstevel@tonic-gate Commenting out for AIX 4.1 for Nova 284*7c478bd9Sstevel@tonic-gate Replaced with following to lines, stolen from the #else below 285*7c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME_BUF_T struct hostent_data 286*7c478bd9Sstevel@tonic-gate */ 287*7c478bd9Sstevel@tonic-gate typedef char GETHOSTBYNAME_buf_t [BUFSIZ /* XXX might be too small */]; 288*7c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t 289*7c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME( n, r, b, l, e ) \ 290*7c478bd9Sstevel@tonic-gate (memset (&b, 0, l), gethostbyname_r (n, r, &b) ? NULL : r) 291*7c478bd9Sstevel@tonic-gate #elif defined(HPUX10) 292*7c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME_BUF_T struct hostent_data 293*7c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME( n, r, b, l, e ) nsldapi_compat_gethostbyname_r( n, r, (char *)&b, l, e ) 294*7c478bd9Sstevel@tonic-gate #else 295*7c478bd9Sstevel@tonic-gate #include <stdio.h> /* BUFSIZ */ 296*7c478bd9Sstevel@tonic-gate typedef char GETHOSTBYNAME_buf_t [BUFSIZ /* XXX might be too small */]; 297*7c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t 298*7c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname_r( n, r, b, l, e ) 299*7c478bd9Sstevel@tonic-gate #endif 300*7c478bd9Sstevel@tonic-gate #if defined(HPUX9) || defined(LINUX1_2) || defined(LINUX2_0) || \ 301*7c478bd9Sstevel@tonic-gate defined(LINUX2_1) || defined(SUNOS4) || defined(SNI) || \ 302*7c478bd9Sstevel@tonic-gate defined(SCOOS) || defined(BSDI) || defined(NCR) || \ 303*7c478bd9Sstevel@tonic-gate defined(NEC) || ( defined(HPUX10) && !defined(_REENTRANT)) || \ 304*7c478bd9Sstevel@tonic-gate (defined(AIX) && !defined(USE_REENTRANT_LIBC)) 305*7c478bd9Sstevel@tonic-gate #define NSLDAPI_CTIME( c, b, l ) ctime( c ) 306*7c478bd9Sstevel@tonic-gate #elif defined(HPUX10) && defined(_REENTRANT) && !defined(HPUX11) 307*7c478bd9Sstevel@tonic-gate #define NSLDAPI_CTIME( c, b, l ) nsldapi_compat_ctime_r( c, b, l ) 308*7c478bd9Sstevel@tonic-gate #elif defined( IRIX6_2 ) || defined( IRIX6_3 ) || defined(UNIXWARE) \ 309*7c478bd9Sstevel@tonic-gate || defined(OSF1V4) || defined(AIX) || defined(UnixWare) || defined(hpux) || defined(HPUX11) 310*7c478bd9Sstevel@tonic-gate #define NSLDAPI_CTIME( c, b, l ) ctime_r( c, b ) 311*7c478bd9Sstevel@tonic-gate #elif defined( OSF1V3 ) 312*7c478bd9Sstevel@tonic-gate #define NSLDAPI_CTIME( c, b, l ) (ctime_r( c, b, l ) ? NULL : b) 313*7c478bd9Sstevel@tonic-gate #else 314*7c478bd9Sstevel@tonic-gate #define NSLDAPI_CTIME( c, b, l ) ctime_r( c, b, l ) 315*7c478bd9Sstevel@tonic-gate #endif 316*7c478bd9Sstevel@tonic-gate #if defined(hpux9) || defined(LINUX1_2) || defined(SUNOS4) || defined(SNI) || \ 317*7c478bd9Sstevel@tonic-gate defined(SCOOS) || defined(BSDI) || defined(NCR) || \ 318*7c478bd9Sstevel@tonic-gate defined(NEC) || defined(LINUX) || (defined(AIX) && !defined(USE_REENTRANT_LIBC)) 319*7c478bd9Sstevel@tonic-gate #define STRTOK( s1, s2, l ) strtok( s1, s2 ) 320*7c478bd9Sstevel@tonic-gate #else 321*7c478bd9Sstevel@tonic-gate #define HAVE_STRTOK_R 322*7c478bd9Sstevel@tonic-gate char *strtok_r(char *, const char *, char **); 323*7c478bd9Sstevel@tonic-gate #define STRTOK( s1, s2, l ) (char *)strtok_r( s1, s2, l ) 324*7c478bd9Sstevel@tonic-gate #endif /* STRTOK */ 325*7c478bd9Sstevel@tonic-gate #endif /* UNIX */ 326*7c478bd9Sstevel@tonic-gate 327*7c478bd9Sstevel@tonic-gate #if defined( ultrix ) || defined( nextstep ) 328*7c478bd9Sstevel@tonic-gate extern char *strdup(); 329*7c478bd9Sstevel@tonic-gate #endif /* ultrix || nextstep */ 330*7c478bd9Sstevel@tonic-gate 331*7c478bd9Sstevel@tonic-gate #if defined( sunos4 ) || defined( OSF1 ) 332*7c478bd9Sstevel@tonic-gate #define BSD_TIME 1 /* for servers/slapd/log.h */ 333*7c478bd9Sstevel@tonic-gate #endif /* sunos4 || osf */ 334*7c478bd9Sstevel@tonic-gate 335*7c478bd9Sstevel@tonic-gate #if !defined(_WINDOWS) && !defined(macintosh) 336*7c478bd9Sstevel@tonic-gate #include <netinet/in.h> 337*7c478bd9Sstevel@tonic-gate #include <arpa/inet.h> /* for inet_addr() */ 338*7c478bd9Sstevel@tonic-gate #endif 339*7c478bd9Sstevel@tonic-gate 340*7c478bd9Sstevel@tonic-gate /* 341*7c478bd9Sstevel@tonic-gate * Define a portable type for IPv4 style Internet addresses (32 bits): 342*7c478bd9Sstevel@tonic-gate */ 343*7c478bd9Sstevel@tonic-gate #if ( defined(sunos5) && defined(_IN_ADDR_T)) || \ 344*7c478bd9Sstevel@tonic-gate defined(aix) || defined(HPUX11) || defined(OSF1) || defined(SOLARIS) 345*7c478bd9Sstevel@tonic-gate typedef in_addr_t nsldapi_in_addr_t; 346*7c478bd9Sstevel@tonic-gate #else 347*7c478bd9Sstevel@tonic-gate typedef unsigned long nsldapi_in_addr_t; 348*7c478bd9Sstevel@tonic-gate #endif 349*7c478bd9Sstevel@tonic-gate 350*7c478bd9Sstevel@tonic-gate #ifdef SUNOS4 351*7c478bd9Sstevel@tonic-gate #include <pcfs/pc_dir.h> /* for toupper() */ 352*7c478bd9Sstevel@tonic-gate int fprintf(FILE *, char *, ...); 353*7c478bd9Sstevel@tonic-gate int fseek(FILE *, long, int); 354*7c478bd9Sstevel@tonic-gate int fread(char *, int, int, FILE *); 355*7c478bd9Sstevel@tonic-gate int fclose(FILE *); 356*7c478bd9Sstevel@tonic-gate int fflush(FILE *); 357*7c478bd9Sstevel@tonic-gate int rewind(FILE *); 358*7c478bd9Sstevel@tonic-gate void *memmove(void *, const void *, size_t); 359*7c478bd9Sstevel@tonic-gate int strcasecmp(char *, char *); 360*7c478bd9Sstevel@tonic-gate int strncasecmp(char *, char *, int); 361*7c478bd9Sstevel@tonic-gate time_t time(time_t *); 362*7c478bd9Sstevel@tonic-gate void perror(char *); 363*7c478bd9Sstevel@tonic-gate int fputc(char, FILE *); 364*7c478bd9Sstevel@tonic-gate int fputs(char *, FILE *); 365*7c478bd9Sstevel@tonic-gate int re_exec(char *); 366*7c478bd9Sstevel@tonic-gate int socket(int, int, int); 367*7c478bd9Sstevel@tonic-gate void bzero(char *, int); 368*7c478bd9Sstevel@tonic-gate unsigned long inet_addr(char *); 369*7c478bd9Sstevel@tonic-gate char * inet_ntoa(struct in_addr); 370*7c478bd9Sstevel@tonic-gate int getdtablesize(); 371*7c478bd9Sstevel@tonic-gate int connect(int, struct sockaddr *, int); 372*7c478bd9Sstevel@tonic-gate #endif /* SUNOS4 */ 373*7c478bd9Sstevel@tonic-gate 374*7c478bd9Sstevel@tonic-gate /* #if defined(SUNOS4) || defined(SNI) */ 375*7c478bd9Sstevel@tonic-gate #if defined(SUNOS4) 376*7c478bd9Sstevel@tonic-gate int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); 377*7c478bd9Sstevel@tonic-gate #endif /* SUNOS4 || SNI */ 378*7c478bd9Sstevel@tonic-gate 379*7c478bd9Sstevel@tonic-gate /* 380*7c478bd9Sstevel@tonic-gate * SAFEMEMCPY is an overlap-safe copy from s to d of n bytes 381*7c478bd9Sstevel@tonic-gate * This is moved to lber.h in Solaris 382*7c478bd9Sstevel@tonic-gate */ 383*7c478bd9Sstevel@tonic-gate #ifndef _SOLARIS_SDK 384*7c478bd9Sstevel@tonic-gate #ifdef macintosh 385*7c478bd9Sstevel@tonic-gate #define SAFEMEMCPY( d, s, n ) BlockMoveData( (Ptr)s, (Ptr)d, n ) 386*7c478bd9Sstevel@tonic-gate #else /* macintosh */ 387*7c478bd9Sstevel@tonic-gate #ifdef sunos4 388*7c478bd9Sstevel@tonic-gate #define SAFEMEMCPY( d, s, n ) bcopy( s, d, n ) 389*7c478bd9Sstevel@tonic-gate #else /* sunos4 */ 390*7c478bd9Sstevel@tonic-gate #define SAFEMEMCPY( d, s, n ) memmove( d, s, n ) 391*7c478bd9Sstevel@tonic-gate #endif /* sunos4 */ 392*7c478bd9Sstevel@tonic-gate #endif /* macintosh */ 393*7c478bd9Sstevel@tonic-gate #endif /* ifndef _SOLARIS_SDK */ 394*7c478bd9Sstevel@tonic-gate 395*7c478bd9Sstevel@tonic-gate #ifdef _WINDOWS 396*7c478bd9Sstevel@tonic-gate 397*7c478bd9Sstevel@tonic-gate #define strcasecmp strcmpi 398*7c478bd9Sstevel@tonic-gate #define strncasecmp _strnicmp 399*7c478bd9Sstevel@tonic-gate #define bzero(a, b) memset( a, 0, b ) 400*7c478bd9Sstevel@tonic-gate #define getpid _getpid 401*7c478bd9Sstevel@tonic-gate #define ioctl ioctlsocket 402*7c478bd9Sstevel@tonic-gate #define sleep(a) Sleep( a*1000 ) 403*7c478bd9Sstevel@tonic-gate 404*7c478bd9Sstevel@tonic-gate #define EMSGSIZE WSAEMSGSIZE 405*7c478bd9Sstevel@tonic-gate #define EWOULDBLOCK WSAEWOULDBLOCK 406*7c478bd9Sstevel@tonic-gate #define EHOSTUNREACH WSAEHOSTUNREACH 407*7c478bd9Sstevel@tonic-gate 408*7c478bd9Sstevel@tonic-gate #ifndef MAXPATHLEN 409*7c478bd9Sstevel@tonic-gate #define MAXPATHLEN _MAX_PATH 410*7c478bd9Sstevel@tonic-gate #endif 411*7c478bd9Sstevel@tonic-gate 412*7c478bd9Sstevel@tonic-gate /* We'd like this number to be prime for the hash 413*7c478bd9Sstevel@tonic-gate * into the Connection table */ 414*7c478bd9Sstevel@tonic-gate #define DS_MAX_NT_SOCKET_CONNECTIONS 2003 415*7c478bd9Sstevel@tonic-gate 416*7c478bd9Sstevel@tonic-gate #elif defined(XP_OS2) 417*7c478bd9Sstevel@tonic-gate 418*7c478bd9Sstevel@tonic-gate #define strcasecmp strcmpi 419*7c478bd9Sstevel@tonic-gate #define strncasecmp strnicmp 420*7c478bd9Sstevel@tonic-gate #define bzero(a, b) memset( a, 0, b ) 421*7c478bd9Sstevel@tonic-gate #include "dirent.h" 422*7c478bd9Sstevel@tonic-gate #include <string.h> /*for strcmpi()*/ 423*7c478bd9Sstevel@tonic-gate #include <time.h> /*for ctime()*/ 424*7c478bd9Sstevel@tonic-gate 425*7c478bd9Sstevel@tonic-gate #endif /* XP_OS2 */ 426*7c478bd9Sstevel@tonic-gate 427*7c478bd9Sstevel@tonic-gate 428*7c478bd9Sstevel@tonic-gate #endif /* _PORTABLE_H */ 429