| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 |
- /** BEGIN COPYRIGHT BLOCK
- * This Program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; version 2 of the License.
- *
- * This Program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * In addition, as a special exception, Red Hat, Inc. gives You the additional
- * right to link the code of this Program with code not covered under the GNU
- * General Public License ("Non-GPL Code") and to distribute linked combinations
- * including the two, subject to the limitations in this paragraph. Non-GPL Code
- * permitted under this exception must only link to the code of this Program
- * through those well defined interfaces identified in the file named EXCEPTION
- * found in the source code files (the "Approved Interfaces"). The files of
- * Non-GPL Code may instantiate templates or use macros or inline functions from
- * the Approved Interfaces without causing the resulting work to be covered by
- * the GNU General Public License. Only Red Hat, Inc. may make changes or
- * additions to the list of Approved Interfaces. You must obey the GNU General
- * Public License in all respects for all of the Program code and other code used
- * in conjunction with the Program except the Non-GPL Code covered by this
- * exception. If you modify this file, you may extend this exception to your
- * version of the file, but you are not obligated to do so. If you do not wish to
- * provide this exception without modification, you must delete this exception
- * statement from your version and license this file solely under the GPL without
- * exception.
- *
- *
- * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
- * All rights reserved.
- * END COPYRIGHT BLOCK **/
- #ifdef HAVE_CONFIG_H
- # include <config.h>
- #endif
- /*
- * Copyright (c) 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
- #ifndef _PORTABLE_H
- #define _PORTABLE_H
- /*
- * portable.h for LDAP -- this is where we define common stuff to make
- * life easier on various Unix systems.
- *
- * Unless you are porting LDAP to a new platform, you should not need to
- * edit this file.
- */
- #ifndef SYSV
- #if defined( hpux ) || defined( sunos5 ) || defined ( sgi ) || defined( SVR4 )
- #define SYSV
- #endif
- #endif
- /*
- * under System V, use sysconf() instead of getdtablesize
- */
- #if !defined( USE_SYSCONF ) && defined( SYSV )
- #define USE_SYSCONF
- #endif
- /*
- * under System V, daemons should use setsid() instead of detaching from their
- * tty themselves
- */
- #if !defined( USE_SETSID ) && defined( SYSV )
- #define USE_SETSID
- #endif
- /*
- * System V has socket options in filio.h
- */
- #if !defined( NEED_FILIO ) && defined( SYSV ) && !defined( hpux ) && !defined( AIX )
- #define NEED_FILIO
- #endif
- /*
- * use lockf() under System V
- */
- #if !defined( USE_LOCKF ) && ( defined( SYSV ) || defined( aix ))
- #define USE_LOCKF
- #endif
- /*
- * on many systems, we should use waitpid() instead of waitN()
- */
- #if !defined( USE_WAITPID ) && ( defined( SYSV ) || defined( sunos4 ) || defined( ultrix ) || defined( aix ))
- #define USE_WAITPID
- #endif
- /*
- * define the wait status argument type
- */
- #if ( defined( SunOS ) && SunOS < 40 ) || defined( nextstep )
- #define WAITSTATUSTYPE union wait
- #else
- #define WAITSTATUSTYPE int
- #endif
- /*
- * define the flags for wait
- */
- #ifdef sunos5
- #define WAIT_FLAGS ( WNOHANG | WUNTRACED | WCONTINUED )
- #else
- #define WAIT_FLAGS ( WNOHANG | WUNTRACED )
- #endif
- /*
- * defined the options for openlog (syslog)
- */
- #ifdef ultrix
- #define OPENLOG_OPTIONS LOG_PID
- #else
- #define OPENLOG_OPTIONS ( LOG_PID | LOG_NOWAIT )
- #endif
- /*
- * We use the internal regex on all systems now.
- */
- #ifndef NEED_BSDREGEX
- #define NEED_BSDREGEX
- #endif
- /*
- * many systems do not have the setpwfile() library routine... we just
- * enable use for those systems we know have it.
- */
- #ifndef HAVE_SETPWFILE
- #if defined( sunos4 ) || defined( ultrix ) || defined( OSF1 )
- #define HAVE_SETPWFILE
- #endif
- #endif
- /*
- * Are sys_errlist and sys_nerr declared in stdio.h?
- */
- #ifndef SYSERRLIST_IN_STDIO
- #if defined( freebsd ) || defined(Linux)
- #define SYSERRLIST_IN_STDIO
- #endif
- #endif
- /*
- * for select()
- */
- #if !defined(WINSOCK) && !defined(_WINDOWS) && !defined(macintosh)
- #if defined(hpux) || defined(LINUX2_0)
- #include <sys/time.h>
- #else
- #include <sys/select.h>
- #endif
- #if !defined(FD_SET)
- #define NFDBITS 32
- #define FD_SETSIZE 32
- #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
- #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
- #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
- #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
- #endif /* !FD_SET */
- #endif /* !WINSOCK && !_WINDOWS && !macintosh */
- /*
- * for connect() -- must we block signals when calling connect()? This
- * is necessary on some buggy UNIXes.
- */
- #if !defined(LDAP_CONNECT_MUST_NOT_BE_INTERRUPTED) && \
- ( defined(AIX) || defined(IRIX) || defined(HPUX) || defined(SUNOS4))
- #define LDAP_CONNECT_MUST_NOT_BE_INTERRUPTED
- #endif
- /*
- * Some DNS resolver implementations, such as the one built into
- * Solaris <= 8, need to use one or more low numbered file
- * descriptors internally (probably because they use a deficient
- * implementation of stdio).
- */
- #if defined(SOLARIS) || defined(IRIX)
- #define RESOLVER_NEEDS_LOW_FILE_DESCRIPTORS
- #endif
- /*
- * for signal() -- what do signal handling functions return?
- */
- #ifndef SIG_FN
- #ifdef sunos5
- # define SIG_FN void /* signal-catching functions return void */
- #else /* sunos5 */
- # ifdef BSD
- # if (BSD >= 199006) || defined(NeXT) || defined(OSF1) || defined(sun) || defined(ultrix) || defined(apollo) || defined(POSIX_SIGNALS)
- # define SIG_FN void /* signal-catching functions return void */
- # else
- # define SIG_FN int /* signal-catching functions return int */
- # endif
- # else /* BSD */
- # define SIG_FN void /* signal-catching functions return void */
- # endif /* BSD */
- #endif /* sunos5 */
- #endif /* SIG_FN */
- /*
- * toupper and tolower macros are different under bsd and sys v
- */
- #if defined( SYSV ) && !defined( hpux )
- #define TOUPPER(c) (isascii(c) && islower(c) ? _toupper(c) : c)
- #define TOLOWER(c) (isascii(c) && isupper(c) ? _tolower(c) : c)
- #else
- #define TOUPPER(c) (isascii(c) && islower(c) ? toupper(c) : c)
- #define TOLOWER(c) (isascii(c) && isupper(c) ? tolower(c) : c)
- #endif
- /*
- * put a cover on the tty-related ioctl calls we need to use
- */
- #if defined( NeXT ) || (defined(SunOS) && SunOS < 40)
- #define TERMIO_TYPE struct sgttyb
- #define TERMFLAG_TYPE int
- #define GETATTR( fd, tiop ) ioctl((fd), TIOCGETP, (caddr_t)(tiop))
- #define SETATTR( fd, tiop ) ioctl((fd), TIOCSETP, (caddr_t)(tiop))
- #define GETFLAGS( tio ) (tio).sg_flags
- #define SETFLAGS( tio, flags ) (tio).sg_flags = (flags)
- #else
- #define USE_TERMIOS
- #define TERMIO_TYPE struct termios
- #define TERMFLAG_TYPE tcflag_t
- #define GETATTR( fd, tiop ) tcgetattr((fd), (tiop))
- #define SETATTR( fd, tiop ) tcsetattr((fd), TCSANOW /* 0 */, (tiop))
- #define GETFLAGS( tio ) (tio).c_lflag
- #define SETFLAGS( tio, flags ) (tio).c_lflag = (flags)
- #endif
- #if ( !defined( HPUX9 )) && ( !defined( sunos4 )) && ( !defined( SNI )) && \
- ( !defined( HAVE_TIME_R ) )
- #define HAVE_TIME_R
- #endif
- #if defined( sunos5 ) || defined( aix )
- #define HAVE_GETPWNAM_R
- #define HAVE_GETGRNAM_R
- #endif
- #if defined(SNI) || defined(LINUX1_2)
- int strcasecmp(const char *, const char *);
- #ifdef SNI
- int strncasecmp(const char *, const char *, int);
- #endif /* SNI */
- #ifdef LINUX1_2
- int strncasecmp(const char *, const char *, size_t);
- #endif /* LINUX1_2 */
- #endif /* SNI || LINUX1_2 */
- #if defined(_WINDOWS) || defined(macintosh)
- #define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n )
- #define CTIME( c, b, l ) ctime( c )
- #define STRTOK( s1, s2, l ) strtok( s1, s2 )
- #else /* UNIX */
- #if defined(sgi) || defined(HPUX9) || defined(LINUX1_2) || defined(SCOOS) || \
- defined(UNIXWARE) || defined(SUNOS4) || defined(SNI) || defined(BSDI) || \
- defined(NCR) || defined(OSF1) || defined(NEC) || \
- ( defined(HPUX10) && !defined(_REENTRANT)) || defined(HPUX11) || \
- defined(UnixWare) || defined(LINUX2_0)
- #define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n )
- #elif defined(AIX)
- #define GETHOSTBYNAME_BUF_T struct hostent_data
- #define GETHOSTBYNAME( n, r, b, l, e ) \
- (memset (&b, 0, l), gethostbyname_r (n, r, &b) ? NULL : r)
- #elif defined(HPUX10)
- #define GETHOSTBYNAME_BUF_T struct hostent_data
- #define GETHOSTBYNAME( n, r, b, l, e ) nsldapi_compat_gethostbyname_r( n, r, (char *)&b, l, e )
- #else
- #include <stdio.h> /* BUFSIZ */
- typedef char GETHOSTBYNAME_buf_t [BUFSIZ /* XXX might be too small */];
- #define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t
- #define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname_r( n, r, b, l, e )
- #endif
- /*
- * XXXmcs: GETHOSTBYADDR() is only defined for IRIX/SGI and Solaris for now.
- */
- #if defined(sgi)
- #define GETHOSTBYADDR( a, al, t, h, b, bl, e ) \
- gethostbyaddr( a, al, t )
- #elif defined(SOLARIS)
- #include <stdio.h> /* BUFSIZ */
- typedef char GETHOSTBYADDR_buf_t [BUFSIZ];
- #define GETHOSTBYADDR_BUF_T GETHOSTBYADDR_buf_t
- #define GETHOSTBYADDR( a, al, t, h, b, bl, e ) \
- gethostbyaddr_r( a, al, t, h, b, bl, e )
- #endif
- #if defined(HPUX9) || defined(LINUX1_2) || defined(SUNOS4) || defined(SNI) || \
- defined(SCOOS) || defined(BSDI) || defined(NCR) || \
- defined(NEC) || ( defined(HPUX10) && !defined(_REENTRANT))
- #define CTIME( c, b, l ) ctime( c )
- #elif defined( hpux10 )
- #define CTIME( c, b, l ) nsldapi_compat_ctime_r( c, b, l )
- #elif defined( IRIX ) || defined(UNIXWARE) || defined(LINUX) \
- || defined(OSF1V4) || defined(AIX) || defined(UnixWare) || defined (HPUX11)
- #define CTIME( c, b, l ) ctime_r( c, b )
- #elif defined( OSF1V3 )
- #define CTIME( c, b, l ) (ctime_r( c, b, l ) ? NULL : b)
- #else
- #define CTIME( c, b, l ) ctime_r( c, b, l )
- #endif
- #if defined(hpux9) || defined(LINUX1_2) || defined(SUNOS4) || defined(SNI) || \
- defined(SCOOS) || defined(BSDI) || defined(NCR) || \
- defined(NEC) || defined(LINUX2_0)
- /* strtok() is not MT safe, but it is okay to call here because used in mmt_protocol.xs which
- has been moved in the tetframewrok */
- #define STRTOK( s1, s2, l ) strtok( s1, s2 )
- #else
- #define HAVE_STRTOK_R
- char *strtok_r(char *, const char *, char **);
- #define STRTOK( s1, s2, l ) (char *)strtok_r( s1, s2, l )
- #endif /* STRTOK */
- #endif /* UNIX */
- #if defined( ultrix ) || defined( nextstep )
- extern char *strdup();
- #endif /* ultrix || nextstep */
- #if defined( sunos4 ) || defined( OSF1 )
- #define BSD_TIME 1 /* for servers/slapd/log.h */
- #endif /* sunos4 || osf */
- #ifdef SOLARIS
- #include <netinet/in.h>
- #include <arpa/inet.h> /* for inet_addr() */
- #endif /* SOLARIS */
- #ifdef SUNOS4
- #include <pcfs/pc_dir.h> /* for toupper() */
- int fprintf(FILE *, char *, ...);
- int fseek(FILE *, long, int);
- int fread(char *, int, int, FILE *);
- int fclose(FILE *);
- int fflush(FILE *);
- int rewind(FILE *);
- void *memmove(void *, const void *, size_t);
- int strcasecmp(char *, char *);
- int strncasecmp(char *, char *, int);
- time_t time(time_t *);
- void perror(char *);
- int fputc(char, FILE *);
- int fputs(char *, FILE *);
- int LDAP_CALL re_exec(char *);
- int socket(int, int, int);
- void bzero(char *, int);
- unsigned long inet_addr(char *);
- char * inet_ntoa(struct in_addr);
- int getdtablesize();
- int connect(int, struct sockaddr *, int);
- #endif /* SUNOS4 */
- /* #if defined(SUNOS4) || defined(SNI) */
- #if defined(SUNOS4)
- int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
- #endif /* SUNOS4 || SNI */
- /*
- * SAFEMEMCPY is an overlap-safe copy from s to d of n bytes
- */
- #ifdef macintosh
- #define SAFEMEMCPY( d, s, n ) BlockMoveData( (Ptr)s, (Ptr)d, n )
- #else /* macintosh */
- #ifdef sunos4
- #define SAFEMEMCPY( d, s, n ) bcopy( s, d, n )
- #else /* sunos4 */
- #define SAFEMEMCPY( d, s, n ) memmove( d, s, n )
- #endif /* sunos4 */
- #endif /* macintosh */
- #ifdef _WINDOWS
- #undef strcasecmp
- #define strcasecmp strcmpi
- #undef strncasecmp
- #define strncasecmp _strnicmp
- #define bzero(a, b) memset( a, 0, b )
- #define getpid _getpid
- #define ioctl ioctlsocket
- #undef sleep
- #define sleep(a) Sleep( a*1000 )
- #define EMSGSIZE WSAEMSGSIZE
- #define EWOULDBLOCK WSAEWOULDBLOCK
- #define EHOSTUNREACH WSAEHOSTUNREACH
- #if !defined(MAXPATHLEN)
- #define MAXPATHLEN _MAX_PATH
- #endif
- #endif
- #endif /* _PORTABLE_H */
|