17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * Copyright (c) 2001 by Sun Microsystems, Inc. 37c478bd9Sstevel@tonic-gate * All rights reserved. 47c478bd9Sstevel@tonic-gate */ 57c478bd9Sstevel@tonic-gate 67c478bd9Sstevel@tonic-gate /* 77c478bd9Sstevel@tonic-gate * The contents of this file are subject to the Netscape Public 87c478bd9Sstevel@tonic-gate * License Version 1.1 (the "License"); you may not use this file 97c478bd9Sstevel@tonic-gate * except in compliance with the License. You may obtain a copy of 107c478bd9Sstevel@tonic-gate * the License at http://www.mozilla.org/NPL/ 117c478bd9Sstevel@tonic-gate * 127c478bd9Sstevel@tonic-gate * Software distributed under the License is distributed on an "AS 137c478bd9Sstevel@tonic-gate * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 147c478bd9Sstevel@tonic-gate * implied. See the License for the specific language governing 157c478bd9Sstevel@tonic-gate * rights and limitations under the License. 167c478bd9Sstevel@tonic-gate * 177c478bd9Sstevel@tonic-gate * The Original Code is Mozilla Communicator client code, released 187c478bd9Sstevel@tonic-gate * March 31, 1998. 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * The Initial Developer of the Original Code is Netscape 217c478bd9Sstevel@tonic-gate * Communications Corporation. Portions created by Netscape are 227c478bd9Sstevel@tonic-gate * Copyright (C) 1998-1999 Netscape Communications Corporation. All 237c478bd9Sstevel@tonic-gate * Rights Reserved. 247c478bd9Sstevel@tonic-gate * 257c478bd9Sstevel@tonic-gate * Contributor(s): 267c478bd9Sstevel@tonic-gate */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate /* 297c478bd9Sstevel@tonic-gate * Copyright (c) 1994 Regents of the University of Michigan. 307c478bd9Sstevel@tonic-gate * All rights reserved. 317c478bd9Sstevel@tonic-gate * 327c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms are permitted 337c478bd9Sstevel@tonic-gate * provided that this notice is preserved and that due credit is given 347c478bd9Sstevel@tonic-gate * to the University of Michigan at Ann Arbor. The name of the University 357c478bd9Sstevel@tonic-gate * may not be used to endorse or promote products derived from this 367c478bd9Sstevel@tonic-gate * software without specific prior written permission. This software 377c478bd9Sstevel@tonic-gate * is provided ``as is'' without express or implied warranty. 387c478bd9Sstevel@tonic-gate */ 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifndef _PORTABLE_H 417c478bd9Sstevel@tonic-gate #define _PORTABLE_H 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* 447c478bd9Sstevel@tonic-gate * portable.h for LDAP -- this is where we define common stuff to make 457c478bd9Sstevel@tonic-gate * life easier on various Unix systems. 467c478bd9Sstevel@tonic-gate * 477c478bd9Sstevel@tonic-gate * Unless you are porting LDAP to a new platform, you should not need to 487c478bd9Sstevel@tonic-gate * edit this file. 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate #ifndef SYSV 527c478bd9Sstevel@tonic-gate #if defined( hpux ) || defined( sunos5 ) || defined ( sgi ) || defined( SVR4 ) 537c478bd9Sstevel@tonic-gate #define SYSV 547c478bd9Sstevel@tonic-gate #endif 557c478bd9Sstevel@tonic-gate #endif 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate /* 587c478bd9Sstevel@tonic-gate * under System V, use sysconf() instead of getdtablesize 597c478bd9Sstevel@tonic-gate */ 607c478bd9Sstevel@tonic-gate #if !defined( USE_SYSCONF ) && defined( SYSV ) 617c478bd9Sstevel@tonic-gate #define USE_SYSCONF 627c478bd9Sstevel@tonic-gate #endif 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * under System V, daemons should use setsid() instead of detaching from their 667c478bd9Sstevel@tonic-gate * tty themselves 677c478bd9Sstevel@tonic-gate */ 687c478bd9Sstevel@tonic-gate #if !defined( USE_SETSID ) && defined( SYSV ) 697c478bd9Sstevel@tonic-gate #define USE_SETSID 707c478bd9Sstevel@tonic-gate #endif 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * System V has socket options in filio.h 747c478bd9Sstevel@tonic-gate */ 757c478bd9Sstevel@tonic-gate #if !defined( NEED_FILIO ) && defined( SYSV ) && !defined( hpux ) && !defined( AIX ) 767c478bd9Sstevel@tonic-gate #define NEED_FILIO 777c478bd9Sstevel@tonic-gate #endif 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate /* 807c478bd9Sstevel@tonic-gate * use lockf() under System V 817c478bd9Sstevel@tonic-gate */ 827c478bd9Sstevel@tonic-gate #if !defined( USE_LOCKF ) && ( defined( SYSV ) || defined( aix )) 837c478bd9Sstevel@tonic-gate #define USE_LOCKF 847c478bd9Sstevel@tonic-gate #endif 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate /* 877c478bd9Sstevel@tonic-gate * on many systems, we should use waitpid() instead of waitN() 887c478bd9Sstevel@tonic-gate */ 897c478bd9Sstevel@tonic-gate #if !defined( USE_WAITPID ) && ( defined( SYSV ) || defined( sunos4 ) || defined( ultrix ) || defined( aix )) 907c478bd9Sstevel@tonic-gate #define USE_WAITPID 917c478bd9Sstevel@tonic-gate #endif 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate * define the wait status argument type 957c478bd9Sstevel@tonic-gate */ 967c478bd9Sstevel@tonic-gate #if ( defined( SunOS ) && SunOS < 40 ) || defined( nextstep ) 977c478bd9Sstevel@tonic-gate #define WAITSTATUSTYPE union wait 987c478bd9Sstevel@tonic-gate #else 997c478bd9Sstevel@tonic-gate #define WAITSTATUSTYPE int 1007c478bd9Sstevel@tonic-gate #endif 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate /* 1037c478bd9Sstevel@tonic-gate * define the flags for wait 1047c478bd9Sstevel@tonic-gate */ 1057c478bd9Sstevel@tonic-gate #ifdef sunos5 1067c478bd9Sstevel@tonic-gate #define WAIT_FLAGS ( WNOHANG | WUNTRACED | WCONTINUED ) 1077c478bd9Sstevel@tonic-gate #else 1087c478bd9Sstevel@tonic-gate #define WAIT_FLAGS ( WNOHANG | WUNTRACED ) 1097c478bd9Sstevel@tonic-gate #endif 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate /* 1127c478bd9Sstevel@tonic-gate * defined the options for openlog (syslog) 1137c478bd9Sstevel@tonic-gate */ 1147c478bd9Sstevel@tonic-gate #ifdef ultrix 1157c478bd9Sstevel@tonic-gate #define OPENLOG_OPTIONS LOG_PID 1167c478bd9Sstevel@tonic-gate #else 1177c478bd9Sstevel@tonic-gate #define OPENLOG_OPTIONS ( LOG_PID | LOG_NOWAIT ) 1187c478bd9Sstevel@tonic-gate #endif 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate /* 1217c478bd9Sstevel@tonic-gate * some systems don't have the BSD re_comp and re_exec routines 1227c478bd9Sstevel@tonic-gate */ 1237c478bd9Sstevel@tonic-gate #ifndef NEED_BSDREGEX 1247c478bd9Sstevel@tonic-gate #if ( defined( SYSV ) || defined( VMS ) || defined( netbsd ) || defined( freebsd ) || defined( linux )) && !defined(sgi) 1257c478bd9Sstevel@tonic-gate #define NEED_BSDREGEX 1267c478bd9Sstevel@tonic-gate #endif 1277c478bd9Sstevel@tonic-gate #endif 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate /* 1307c478bd9Sstevel@tonic-gate * many systems do not have the setpwfile() library routine... we just 1317c478bd9Sstevel@tonic-gate * enable use for those systems we know have it. 1327c478bd9Sstevel@tonic-gate */ 1337c478bd9Sstevel@tonic-gate #ifndef HAVE_SETPWFILE 1347c478bd9Sstevel@tonic-gate #if defined( sunos4 ) || defined( ultrix ) || defined( OSF1 ) 1357c478bd9Sstevel@tonic-gate #define HAVE_SETPWFILE 1367c478bd9Sstevel@tonic-gate #endif 1377c478bd9Sstevel@tonic-gate #endif 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate /* 1407c478bd9Sstevel@tonic-gate * Are sys_errlist and sys_nerr declared in stdio.h? 1417c478bd9Sstevel@tonic-gate */ 1427c478bd9Sstevel@tonic-gate #ifndef SYSERRLIST_IN_STDIO 143*1da57d55SToomas Soome #if defined( freebsd ) 1447c478bd9Sstevel@tonic-gate #define SYSERRLIST_IN_STDIO 1457c478bd9Sstevel@tonic-gate #endif 1467c478bd9Sstevel@tonic-gate #endif 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate /* 1507c478bd9Sstevel@tonic-gate * Is snprintf() part of the standard C runtime library? 1517c478bd9Sstevel@tonic-gate */ 1527c478bd9Sstevel@tonic-gate #if !defined(HAVE_SNPRINTF) 1537c478bd9Sstevel@tonic-gate #if defined(SOLARIS) || defined(LINUX) || defined(HPUX) 1547c478bd9Sstevel@tonic-gate #define HAVE_SNPRINTF 1557c478bd9Sstevel@tonic-gate #endif 1567c478bd9Sstevel@tonic-gate #endif 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate /* 160*1da57d55SToomas Soome * Async IO. Use a non blocking implementation of connect() and 1617c478bd9Sstevel@tonic-gate * dns functions 1627c478bd9Sstevel@tonic-gate */ 1637c478bd9Sstevel@tonic-gate #if !defined(LDAP_ASYNC_IO) 1647c478bd9Sstevel@tonic-gate #if !defined(_WINDOWS) && !defined(macintosh) 1657c478bd9Sstevel@tonic-gate #define LDAP_ASYNC_IO 1667c478bd9Sstevel@tonic-gate #endif /* _WINDOWS */ 1677c478bd9Sstevel@tonic-gate #endif 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate /* 1707c478bd9Sstevel@tonic-gate * for select() 1717c478bd9Sstevel@tonic-gate */ 1727c478bd9Sstevel@tonic-gate #if !defined(WINSOCK) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2) 1737c478bd9Sstevel@tonic-gate #if defined(hpux) || defined(LINUX) || defined(SUNOS4) 1747c478bd9Sstevel@tonic-gate #include <sys/time.h> 1757c478bd9Sstevel@tonic-gate #else 1767c478bd9Sstevel@tonic-gate #include <sys/select.h> 1777c478bd9Sstevel@tonic-gate #endif 1787c478bd9Sstevel@tonic-gate #if !defined(FD_SET) 1797c478bd9Sstevel@tonic-gate #define NFDBITS 32 1807c478bd9Sstevel@tonic-gate #define FD_SETSIZE 32 1817c478bd9Sstevel@tonic-gate #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) 1827c478bd9Sstevel@tonic-gate #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) 1837c478bd9Sstevel@tonic-gate #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) 1847c478bd9Sstevel@tonic-gate #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) 1857c478bd9Sstevel@tonic-gate #endif /* !FD_SET */ 1867c478bd9Sstevel@tonic-gate #endif /* !WINSOCK && !_WINDOWS && !macintosh */ 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate 1897c478bd9Sstevel@tonic-gate /* 1907c478bd9Sstevel@tonic-gate * for connect() -- must we block signals when calling connect()? This 1917c478bd9Sstevel@tonic-gate * is necessary on some buggy UNIXes. 1927c478bd9Sstevel@tonic-gate */ 1937c478bd9Sstevel@tonic-gate #if !defined(LDAP_CONNECT_MUST_NOT_BE_INTERRUPTED) && \ 1947c478bd9Sstevel@tonic-gate ( defined(AIX) || defined(IRIX) || defined(HPUX) || defined(SUNOS4) \ 195*1da57d55SToomas Soome || defined(SOLARIS) || defined(OSF1) ||defined(freebsd)) 1967c478bd9Sstevel@tonic-gate #define LDAP_CONNECT_MUST_NOT_BE_INTERRUPTED 1977c478bd9Sstevel@tonic-gate #endif 1987c478bd9Sstevel@tonic-gate 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate /* 2017c478bd9Sstevel@tonic-gate * for signal() -- what do signal handling functions return? 2027c478bd9Sstevel@tonic-gate */ 2037c478bd9Sstevel@tonic-gate #ifndef SIG_FN 2047c478bd9Sstevel@tonic-gate #ifdef sunos5 2057c478bd9Sstevel@tonic-gate # define SIG_FN void /* signal-catching functions return void */ 2067c478bd9Sstevel@tonic-gate #else /* sunos5 */ 2077c478bd9Sstevel@tonic-gate # ifdef BSD 2087c478bd9Sstevel@tonic-gate # if (BSD >= 199006) || defined(NeXT) || defined(OSF1) || defined(sun) || defined(ultrix) || defined(apollo) || defined(POSIX_SIGNALS) 2097c478bd9Sstevel@tonic-gate # define SIG_FN void /* signal-catching functions return void */ 2107c478bd9Sstevel@tonic-gate # else 2117c478bd9Sstevel@tonic-gate # define SIG_FN int /* signal-catching functions return int */ 2127c478bd9Sstevel@tonic-gate # endif 2137c478bd9Sstevel@tonic-gate # else /* BSD */ 2147c478bd9Sstevel@tonic-gate # define SIG_FN void /* signal-catching functions return void */ 2157c478bd9Sstevel@tonic-gate # endif /* BSD */ 2167c478bd9Sstevel@tonic-gate #endif /* sunos5 */ 2177c478bd9Sstevel@tonic-gate #endif /* SIG_FN */ 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate /* 2207c478bd9Sstevel@tonic-gate * toupper and tolower macros are different under bsd and sys v 2217c478bd9Sstevel@tonic-gate */ 2227c478bd9Sstevel@tonic-gate #if defined( SYSV ) && !defined( hpux ) 2237c478bd9Sstevel@tonic-gate #define TOUPPER(c) (isascii(c) && islower(c) ? _toupper(c) : c) 2247c478bd9Sstevel@tonic-gate #define TOLOWER(c) (isascii(c) && isupper(c) ? _tolower(c) : c) 2257c478bd9Sstevel@tonic-gate #else 2267c478bd9Sstevel@tonic-gate #define TOUPPER(c) (isascii(c) && islower(c) ? toupper(c) : c) 2277c478bd9Sstevel@tonic-gate #define TOLOWER(c) (isascii(c) && isupper(c) ? tolower(c) : c) 2287c478bd9Sstevel@tonic-gate #endif 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate /* 2317c478bd9Sstevel@tonic-gate * put a cover on the tty-related ioctl calls we need to use 2327c478bd9Sstevel@tonic-gate */ 2337c478bd9Sstevel@tonic-gate #if defined( NeXT ) || (defined(SunOS) && SunOS < 40) 2347c478bd9Sstevel@tonic-gate #define TERMIO_TYPE struct sgttyb 2357c478bd9Sstevel@tonic-gate #define TERMFLAG_TYPE int 2367c478bd9Sstevel@tonic-gate #define GETATTR( fd, tiop ) ioctl((fd), TIOCGETP, (caddr_t)(tiop)) 2377c478bd9Sstevel@tonic-gate #define SETATTR( fd, tiop ) ioctl((fd), TIOCSETP, (caddr_t)(tiop)) 2387c478bd9Sstevel@tonic-gate #define GETFLAGS( tio ) (tio).sg_flags 2397c478bd9Sstevel@tonic-gate #define SETFLAGS( tio, flags ) (tio).sg_flags = (flags) 2407c478bd9Sstevel@tonic-gate #else 2417c478bd9Sstevel@tonic-gate #define USE_TERMIOS 2427c478bd9Sstevel@tonic-gate #define TERMIO_TYPE struct termios 2437c478bd9Sstevel@tonic-gate #define TERMFLAG_TYPE tcflag_t 2447c478bd9Sstevel@tonic-gate #define GETATTR( fd, tiop ) tcgetattr((fd), (tiop)) 2457c478bd9Sstevel@tonic-gate #define SETATTR( fd, tiop ) tcsetattr((fd), TCSANOW /* 0 */, (tiop)) 2467c478bd9Sstevel@tonic-gate #define GETFLAGS( tio ) (tio).c_lflag 2477c478bd9Sstevel@tonic-gate #define SETFLAGS( tio, flags ) (tio).c_lflag = (flags) 2487c478bd9Sstevel@tonic-gate #endif 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate #if ( !defined( HPUX9 )) && ( !defined( sunos4 )) && ( !defined( SNI )) && \ 2517c478bd9Sstevel@tonic-gate ( !defined( HAVE_TIME_R )) 2527c478bd9Sstevel@tonic-gate #define HAVE_TIME_R 2537c478bd9Sstevel@tonic-gate #endif 2547c478bd9Sstevel@tonic-gate 2557c478bd9Sstevel@tonic-gate #if defined( sunos5 ) || defined( aix ) 2567c478bd9Sstevel@tonic-gate #define HAVE_GETPWNAM_R 2577c478bd9Sstevel@tonic-gate #define HAVE_GETGRNAM_R 2587c478bd9Sstevel@tonic-gate #endif 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate #if defined(SNI) || defined(LINUX1_2) 2617c478bd9Sstevel@tonic-gate int strcasecmp(const char *, const char *); 2627c478bd9Sstevel@tonic-gate #ifdef SNI 2637c478bd9Sstevel@tonic-gate int strncasecmp(const char *, const char *, int); 2647c478bd9Sstevel@tonic-gate #endif /* SNI */ 2657c478bd9Sstevel@tonic-gate #ifdef LINUX1_2 2667c478bd9Sstevel@tonic-gate int strncasecmp(const char *, const char *, size_t); 2677c478bd9Sstevel@tonic-gate #endif /* LINUX1_2 */ 2687c478bd9Sstevel@tonic-gate #endif /* SNI || LINUX1_2 */ 2697c478bd9Sstevel@tonic-gate 2707c478bd9Sstevel@tonic-gate #if defined(_WINDOWS) || defined(macintosh) || defined(XP_OS2) 2717c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n ) 2727c478bd9Sstevel@tonic-gate #define NSLDAPI_CTIME( c, b, l ) ctime( c ) 2737c478bd9Sstevel@tonic-gate #define STRTOK( s1, s2, l ) strtok( s1, s2 ) 2747c478bd9Sstevel@tonic-gate #else /* UNIX */ 2757c478bd9Sstevel@tonic-gate #if defined(sgi) || defined(HPUX9) || defined(LINUX1_2) || defined(SCOOS) || \ 2767c478bd9Sstevel@tonic-gate defined(UNIXWARE) || defined(SUNOS4) || defined(SNI) || defined(BSDI) || \ 2777c478bd9Sstevel@tonic-gate defined(NCR) || defined(OSF1) || defined(NEC) || \ 2787c478bd9Sstevel@tonic-gate ( defined(HPUX10) && !defined(_REENTRANT)) || defined(HPUX11) || \ 2797c478bd9Sstevel@tonic-gate defined(UnixWare) || defined(LINUX) || (defined(AIX) && !defined(USE_REENTRANT_LIBC)) 2807c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n ) 2817c478bd9Sstevel@tonic-gate #elif defined(AIX) 2827c478bd9Sstevel@tonic-gate /* Maybe this is for another version of AIX? 2837c478bd9Sstevel@tonic-gate Commenting out for AIX 4.1 for Nova 2847c478bd9Sstevel@tonic-gate Replaced with following to lines, stolen from the #else below 2857c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME_BUF_T struct hostent_data 2867c478bd9Sstevel@tonic-gate */ 2877c478bd9Sstevel@tonic-gate typedef char GETHOSTBYNAME_buf_t [BUFSIZ /* XXX might be too small */]; 2887c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t 2897c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME( n, r, b, l, e ) \ 2907c478bd9Sstevel@tonic-gate (memset (&b, 0, l), gethostbyname_r (n, r, &b) ? NULL : r) 2917c478bd9Sstevel@tonic-gate #elif defined(HPUX10) 2927c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME_BUF_T struct hostent_data 2937c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME( n, r, b, l, e ) nsldapi_compat_gethostbyname_r( n, r, (char *)&b, l, e ) 2947c478bd9Sstevel@tonic-gate #else 2957c478bd9Sstevel@tonic-gate #include <stdio.h> /* BUFSIZ */ 2967c478bd9Sstevel@tonic-gate typedef char GETHOSTBYNAME_buf_t [BUFSIZ /* XXX might be too small */]; 2977c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t 2987c478bd9Sstevel@tonic-gate #define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname_r( n, r, b, l, e ) 2997c478bd9Sstevel@tonic-gate #endif 3007c478bd9Sstevel@tonic-gate #if defined(HPUX9) || defined(LINUX1_2) || defined(LINUX2_0) || \ 3017c478bd9Sstevel@tonic-gate defined(LINUX2_1) || defined(SUNOS4) || defined(SNI) || \ 3027c478bd9Sstevel@tonic-gate defined(SCOOS) || defined(BSDI) || defined(NCR) || \ 3037c478bd9Sstevel@tonic-gate defined(NEC) || ( defined(HPUX10) && !defined(_REENTRANT)) || \ 3047c478bd9Sstevel@tonic-gate (defined(AIX) && !defined(USE_REENTRANT_LIBC)) 3057c478bd9Sstevel@tonic-gate #define NSLDAPI_CTIME( c, b, l ) ctime( c ) 3067c478bd9Sstevel@tonic-gate #elif defined(HPUX10) && defined(_REENTRANT) && !defined(HPUX11) 3077c478bd9Sstevel@tonic-gate #define NSLDAPI_CTIME( c, b, l ) nsldapi_compat_ctime_r( c, b, l ) 3087c478bd9Sstevel@tonic-gate #elif defined( IRIX6_2 ) || defined( IRIX6_3 ) || defined(UNIXWARE) \ 3097c478bd9Sstevel@tonic-gate || defined(OSF1V4) || defined(AIX) || defined(UnixWare) || defined(hpux) || defined(HPUX11) 3107c478bd9Sstevel@tonic-gate #define NSLDAPI_CTIME( c, b, l ) ctime_r( c, b ) 3117c478bd9Sstevel@tonic-gate #elif defined( OSF1V3 ) 3127c478bd9Sstevel@tonic-gate #define NSLDAPI_CTIME( c, b, l ) (ctime_r( c, b, l ) ? NULL : b) 3137c478bd9Sstevel@tonic-gate #else 3147c478bd9Sstevel@tonic-gate #define NSLDAPI_CTIME( c, b, l ) ctime_r( c, b, l ) 3157c478bd9Sstevel@tonic-gate #endif 3167c478bd9Sstevel@tonic-gate #if defined(hpux9) || defined(LINUX1_2) || defined(SUNOS4) || defined(SNI) || \ 3177c478bd9Sstevel@tonic-gate defined(SCOOS) || defined(BSDI) || defined(NCR) || \ 3187c478bd9Sstevel@tonic-gate defined(NEC) || defined(LINUX) || (defined(AIX) && !defined(USE_REENTRANT_LIBC)) 3197c478bd9Sstevel@tonic-gate #define STRTOK( s1, s2, l ) strtok( s1, s2 ) 3207c478bd9Sstevel@tonic-gate #else 3217c478bd9Sstevel@tonic-gate #define HAVE_STRTOK_R 3227c478bd9Sstevel@tonic-gate char *strtok_r(char *, const char *, char **); 3237c478bd9Sstevel@tonic-gate #define STRTOK( s1, s2, l ) (char *)strtok_r( s1, s2, l ) 3247c478bd9Sstevel@tonic-gate #endif /* STRTOK */ 3257c478bd9Sstevel@tonic-gate #endif /* UNIX */ 3267c478bd9Sstevel@tonic-gate 3277c478bd9Sstevel@tonic-gate #if defined( ultrix ) || defined( nextstep ) 3287c478bd9Sstevel@tonic-gate extern char *strdup(); 3297c478bd9Sstevel@tonic-gate #endif /* ultrix || nextstep */ 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate #if defined( sunos4 ) || defined( OSF1 ) 3327c478bd9Sstevel@tonic-gate #define BSD_TIME 1 /* for servers/slapd/log.h */ 3337c478bd9Sstevel@tonic-gate #endif /* sunos4 || osf */ 3347c478bd9Sstevel@tonic-gate 3357c478bd9Sstevel@tonic-gate #if !defined(_WINDOWS) && !defined(macintosh) 3367c478bd9Sstevel@tonic-gate #include <netinet/in.h> 3377c478bd9Sstevel@tonic-gate #include <arpa/inet.h> /* for inet_addr() */ 3387c478bd9Sstevel@tonic-gate #endif 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate /* 3417c478bd9Sstevel@tonic-gate * Define a portable type for IPv4 style Internet addresses (32 bits): 3427c478bd9Sstevel@tonic-gate */ 3437c478bd9Sstevel@tonic-gate #if ( defined(sunos5) && defined(_IN_ADDR_T)) || \ 3447c478bd9Sstevel@tonic-gate defined(aix) || defined(HPUX11) || defined(OSF1) || defined(SOLARIS) 3457c478bd9Sstevel@tonic-gate typedef in_addr_t nsldapi_in_addr_t; 3467c478bd9Sstevel@tonic-gate #else 3477c478bd9Sstevel@tonic-gate typedef unsigned long nsldapi_in_addr_t; 3487c478bd9Sstevel@tonic-gate #endif 3497c478bd9Sstevel@tonic-gate 3507c478bd9Sstevel@tonic-gate #ifdef SUNOS4 3517c478bd9Sstevel@tonic-gate #include <pcfs/pc_dir.h> /* for toupper() */ 3527c478bd9Sstevel@tonic-gate int fprintf(FILE *, char *, ...); 3537c478bd9Sstevel@tonic-gate int fseek(FILE *, long, int); 3547c478bd9Sstevel@tonic-gate int fread(char *, int, int, FILE *); 3557c478bd9Sstevel@tonic-gate int fclose(FILE *); 3567c478bd9Sstevel@tonic-gate int fflush(FILE *); 3577c478bd9Sstevel@tonic-gate int rewind(FILE *); 3587c478bd9Sstevel@tonic-gate void *memmove(void *, const void *, size_t); 3597c478bd9Sstevel@tonic-gate int strcasecmp(char *, char *); 3607c478bd9Sstevel@tonic-gate int strncasecmp(char *, char *, int); 3617c478bd9Sstevel@tonic-gate time_t time(time_t *); 3627c478bd9Sstevel@tonic-gate void perror(char *); 3637c478bd9Sstevel@tonic-gate int fputc(char, FILE *); 3647c478bd9Sstevel@tonic-gate int fputs(char *, FILE *); 3657c478bd9Sstevel@tonic-gate int re_exec(char *); 3667c478bd9Sstevel@tonic-gate int socket(int, int, int); 3677c478bd9Sstevel@tonic-gate void bzero(char *, int); 3687c478bd9Sstevel@tonic-gate unsigned long inet_addr(char *); 3697c478bd9Sstevel@tonic-gate char * inet_ntoa(struct in_addr); 3707c478bd9Sstevel@tonic-gate int getdtablesize(); 3717c478bd9Sstevel@tonic-gate int connect(int, struct sockaddr *, int); 3727c478bd9Sstevel@tonic-gate #endif /* SUNOS4 */ 3737c478bd9Sstevel@tonic-gate 3747c478bd9Sstevel@tonic-gate /* #if defined(SUNOS4) || defined(SNI) */ 3757c478bd9Sstevel@tonic-gate #if defined(SUNOS4) 3767c478bd9Sstevel@tonic-gate int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); 3777c478bd9Sstevel@tonic-gate #endif /* SUNOS4 || SNI */ 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate /* 3807c478bd9Sstevel@tonic-gate * SAFEMEMCPY is an overlap-safe copy from s to d of n bytes 3817c478bd9Sstevel@tonic-gate * This is moved to lber.h in Solaris 3827c478bd9Sstevel@tonic-gate */ 3837c478bd9Sstevel@tonic-gate #ifndef _SOLARIS_SDK 3847c478bd9Sstevel@tonic-gate #ifdef macintosh 3857c478bd9Sstevel@tonic-gate #define SAFEMEMCPY( d, s, n ) BlockMoveData( (Ptr)s, (Ptr)d, n ) 3867c478bd9Sstevel@tonic-gate #else /* macintosh */ 3877c478bd9Sstevel@tonic-gate #ifdef sunos4 3887c478bd9Sstevel@tonic-gate #define SAFEMEMCPY( d, s, n ) bcopy( s, d, n ) 3897c478bd9Sstevel@tonic-gate #else /* sunos4 */ 3907c478bd9Sstevel@tonic-gate #define SAFEMEMCPY( d, s, n ) memmove( d, s, n ) 3917c478bd9Sstevel@tonic-gate #endif /* sunos4 */ 3927c478bd9Sstevel@tonic-gate #endif /* macintosh */ 3937c478bd9Sstevel@tonic-gate #endif /* ifndef _SOLARIS_SDK */ 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate #ifdef _WINDOWS 3967c478bd9Sstevel@tonic-gate 3977c478bd9Sstevel@tonic-gate #define strcasecmp strcmpi 3987c478bd9Sstevel@tonic-gate #define strncasecmp _strnicmp 3997c478bd9Sstevel@tonic-gate #define bzero(a, b) memset( a, 0, b ) 4007c478bd9Sstevel@tonic-gate #define getpid _getpid 4017c478bd9Sstevel@tonic-gate #define ioctl ioctlsocket 4027c478bd9Sstevel@tonic-gate #define sleep(a) Sleep( a*1000 ) 4037c478bd9Sstevel@tonic-gate 4047c478bd9Sstevel@tonic-gate #define EMSGSIZE WSAEMSGSIZE 4057c478bd9Sstevel@tonic-gate #define EWOULDBLOCK WSAEWOULDBLOCK 4067c478bd9Sstevel@tonic-gate #define EHOSTUNREACH WSAEHOSTUNREACH 4077c478bd9Sstevel@tonic-gate 4087c478bd9Sstevel@tonic-gate #ifndef MAXPATHLEN 4097c478bd9Sstevel@tonic-gate #define MAXPATHLEN _MAX_PATH 4107c478bd9Sstevel@tonic-gate #endif 4117c478bd9Sstevel@tonic-gate 4127c478bd9Sstevel@tonic-gate /* We'd like this number to be prime for the hash 4137c478bd9Sstevel@tonic-gate * into the Connection table */ 4147c478bd9Sstevel@tonic-gate #define DS_MAX_NT_SOCKET_CONNECTIONS 2003 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate #elif defined(XP_OS2) 4177c478bd9Sstevel@tonic-gate 4187c478bd9Sstevel@tonic-gate #define strcasecmp strcmpi 4197c478bd9Sstevel@tonic-gate #define strncasecmp strnicmp 4207c478bd9Sstevel@tonic-gate #define bzero(a, b) memset( a, 0, b ) 4217c478bd9Sstevel@tonic-gate #include "dirent.h" 4227c478bd9Sstevel@tonic-gate #include <string.h> /*for strcmpi()*/ 4237c478bd9Sstevel@tonic-gate #include <time.h> /*for ctime()*/ 4247c478bd9Sstevel@tonic-gate 4257c478bd9Sstevel@tonic-gate #endif /* XP_OS2 */ 4267c478bd9Sstevel@tonic-gate 4277c478bd9Sstevel@tonic-gate 4287c478bd9Sstevel@tonic-gate #endif /* _PORTABLE_H */ 429