]> git.sur5r.net Git - openldap/blob - include/portable.h
LDAPworld P1: DEC and other portability issues
[openldap] / include / portable.h
1 /*
2  * Copyright (c) 1994 Regents of the University of Michigan.
3  * All rights reserved.
4  *
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.
11  */
12
13 #ifndef _PORTABLE_H
14 #define _PORTABLE_H
15
16 /*
17  * portable.h for LDAP -- this is where we define common stuff to make
18  * life easier on various Unix systems.
19  *
20  * Unless you are porting LDAP to a new platform, you should not need to
21  * edit this file.
22  */
23
24
25 #ifndef SYSV
26 #if defined( hpux ) || defined( sunos5 ) || defined ( sgi ) || defined( SVR4 )
27 #define SYSV
28 #endif
29 #endif
30
31
32 /*
33  * under System V, use sysconf() instead of getdtablesize
34  */
35 #if !defined( USE_SYSCONF ) && defined( SYSV )
36 #define USE_SYSCONF
37 #endif
38
39
40 /*
41  * under System V, daemons should use setsid() instead of detaching from their
42  * tty themselves
43  */
44 #if !defined( USE_SETSID ) && defined( SYSV )
45 #define USE_SETSID
46 #endif
47
48
49 /*
50  * System V has socket options in filio.h
51  */
52 #if !defined( NEED_FILIO ) && defined( SYSV ) && !defined( hpux )
53 #define NEED_FILIO
54 #endif
55
56 /*
57  * use lockf() under System V
58  */
59 #if !defined( USE_LOCKF ) && ( defined( SYSV ) || defined( aix ))
60 #define USE_LOCKF
61 #endif
62
63 /*
64  * on most systems, we should use waitpid() instead of waitN()
65  */
66 #if !defined( USE_WAITPID ) && !defined( nextstep )
67 #define USE_WAITPID
68 #endif
69
70
71 /*
72  * define the wait status argument type
73  */
74 #if ( defined( SunOS ) && SunOS < 40 ) || defined( nextstep )
75 #define WAITSTATUSTYPE  union wait
76 #else
77 #define WAITSTATUSTYPE  int
78 #endif
79
80 /*
81  * define the flags for wait
82  */
83 #ifdef sunos5
84 #define WAIT_FLAGS      ( WNOHANG | WUNTRACED | WCONTINUED )
85 #else
86 #define WAIT_FLAGS      ( WNOHANG | WUNTRACED )
87 #endif
88
89
90 /*
91  * defined the options for openlog (syslog)
92  */
93 #ifdef ultrix
94 #define OPENLOG_OPTIONS         LOG_PID
95 #else
96 #define OPENLOG_OPTIONS         ( LOG_PID | LOG_NOWAIT )
97 #endif
98
99
100 /*
101  * some systems don't have the BSD re_comp and re_exec routines
102  */
103 #ifndef NEED_BSDREGEX
104 #if defined( SYSV ) || defined( VMS ) || defined( netbsd ) || defined( freebsd ) || defined( linux )
105 #define NEED_BSDREGEX
106 #endif
107 #endif
108
109 /*
110  * many systems do not have the setpwfile() library routine... we just
111  * enable use for those systems we know have it.
112  */
113 #ifndef HAVE_SETPWFILE
114 #if defined( sunos4 ) || defined( ultrix ) || defined( __osf__ )
115 #define HAVE_SETPWFILE
116 #endif
117 #endif
118
119 /*
120  * Are sys_errlist and sys_nerr declared in stdio.h?
121  */
122 #ifndef SYSERRLIST_IN_STDIO
123 #if defined( freebsd ) 
124 #define SYSERRLIST_IN_STDIO
125 #endif
126 #endif
127
128 /*
129  * for select()
130  */
131 #if !defined(FD_SET) && !defined(WINSOCK)
132 #define NFDBITS         32
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)))
138 #endif /* FD_SET */
139
140 #if defined( hpux ) && defined( __STDC__ )
141 /*
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__
144  * is not defined.
145  */
146 #define select(a,b,c,d,e) select(a, (int *)b, (int *)c, (int *)d, e)
147 #endif /* hpux && __STDC__ */
148
149
150 /*
151  * for signal() -- what do signal handling functions return?
152  */
153 #ifndef SIG_FN
154 #ifdef sunos5
155 #   define SIG_FN void          /* signal-catching functions return void */
156 #else /* sunos5 */
157 # ifdef BSD
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 */
160 #  else
161 #   define SIG_FN int           /* signal-catching functions return int */
162 #  endif
163 # else /* BSD */
164 #  define SIG_FN void           /* signal-catching functions return void */
165 # endif /* BSD */
166 #endif /* sunos5 */
167 #endif /* SIG_FN */
168
169 /*
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)
172  */
173 #ifdef SYSV
174 #define SIGNAL sigset
175 #else
176 #define SIGNAL signal
177 #endif
178
179 /*
180  * toupper and tolower macros are different under bsd and sys v
181  */
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)
185 #else
186 #define TOUPPER(c)      (isascii(c) && islower(c) ? toupper(c) : c)
187 #define TOLOWER(c)      (isascii(c) && isupper(c) ? tolower(c) : c)
188 #endif
189
190 /*
191  * put a cover on the tty-related ioctl calls we need to use
192  */
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)
200 #else
201 #define USE_TERMIOS
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)
208 #endif
209
210
211 #if defined( ultrix ) || defined( nextstep )
212 extern char *strdup();
213 #endif /* ultrix || nextstep */
214
215 #endif /* _PORTABLE_H */