]> git.sur5r.net Git - openldap/blob - include/bridge.h
Minor fixes for Linux
[openldap] / include / bridge.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 /* This file SHOULD go away !!! */
14
15 #ifndef _LDAP_BRIDGE_H
16 #define _LDAP_BRIDGE_H
17
18 /*
19  * portable.h for LDAP -- this is where we define common stuff to make
20  * life easier on various Unix systems.
21  *
22  * Unless you are porting LDAP to a new platform, you should not need to
23  * edit this file.
24  */
25
26 #ifndef LDAP_LIBUI
27 #ifndef NO_USERINTERFACE
28 #define NO_USERINTERFACE
29 #endif
30 #endif
31
32 #ifndef SYSV
33 #if defined( hpux ) || defined( sunos5 ) || defined ( sgi ) || defined( SVR4 )
34 #       define SYSV
35 #endif
36 #endif
37
38
39 /*
40  * under System V, use sysconf() instead of getdtablesize
41  */
42 #if defined( HAVE_SYSCONF ) && !defined( HAVE_GETDTABLESIZE )
43 #define USE_SYSCONF
44 #endif
45
46
47 /*
48  * under System V, daemons should use setsid() instead of detaching from their
49  * tty themselves
50  */
51 #if defined( HAVE_SETSID )
52 #define USE_SETSID
53 #endif
54
55
56 /*
57  * System V has socket options in filio.h
58  */
59 #if defined( HAVE_FILIO_H )
60 #define NEED_FILIO
61 #endif
62
63 /*
64  * use lockf() under System V
65  */
66 #if !defined( HAVE_LOCKF ) && !defined( HAVE_FLOCK )
67 #define USE_LOCKF
68 #endif
69
70 /*
71  * on most systems, we should use waitpid() instead of waitN()
72  */
73 #if defined( HAVE_WAITPID ) && !defined( nextstep )
74 #define USE_WAITPID
75 #endif
76
77
78 /*
79  * define the wait status argument type
80  */
81 #if !defined( WAITSTATUSTYPE )
82 #if !defined( HAVE_SYS_WAIT_H )
83 #define WAITSTATUSTYPE  union wait
84 #else
85 #define WAITSTATUSTYPE  int
86 #endif
87 #endif
88
89 /*
90  * define the flags for wait
91  */
92 #if !defined( WAIT_FLAGS )
93 #ifdef sunos5
94 #define WAIT_FLAGS      ( WNOHANG | WUNTRACED | WCONTINUED )
95 #else
96 #define WAIT_FLAGS      ( WNOHANG | WUNTRACED )
97 #endif
98 #endif
99
100
101 /*
102  * defined the options for openlog (syslog)
103  */
104 #if !defined( OPENLOG_OPTIONS )
105 #ifdef ultrix
106 #define OPENLOG_OPTIONS         LOG_PID
107 #else
108 #define OPENLOG_OPTIONS         ( LOG_PID | LOG_NOWAIT )
109 #endif
110 #endif
111
112
113 /*
114  * many systems do not have the setpwfile() library routine... we just
115  * enable use for those systems we know have it.
116  */
117 #ifdef NOTDEF
118 #ifndef HAVE_SETPWFILE
119 #if defined( sunos4 ) || defined( ultrix ) || defined( __osf__ )
120 #define HAVE_SETPWFILE
121 #endif
122 #endif
123 #endif NOTDEF
124
125 #ifndef DISABLE_BRIDGE 
126 /*
127  * Are sys_errlist and sys_nerr declared in stdio.h?
128  */
129 #ifndef SYSERRLIST_IN_STDIO
130 #if !defined( DECL_SYS_ERRLIST ) 
131 #define SYSERRLIST_IN_STDIO
132 #endif
133 #endif
134
135 /*
136  * for select()
137  */
138 #if !defined(FD_SET) && !defined(WINSOCK)
139 #define NFDBITS         32
140 #define FD_SETSIZE      32
141 #define FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
142 #define FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
143 #define FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
144 #define FD_ZERO(p)      bzero((char *)(p), sizeof(*(p)))
145 #endif /* FD_SET */
146 #endif
147
148 #if defined( hpux ) && defined( __STDC__ )
149 /*
150  * Under HP/UX, select seems to want (int *) instead of fd_set.  Non-ANSI
151  * compilers don't like recursive macros, so ignore the problem if __STDC__
152  * is not defined.
153  */
154 #define select(a,b,c,d,e) select(a, (int *)b, (int *)c, (int *)d, e)
155 #endif /* hpux && __STDC__ */
156
157
158 /*
159  * for signal() -- what do signal handling functions return?
160  */
161 #ifdef RETSIGTYPE
162 #define SIG_FN RETSIGTYPE
163 #endif
164
165
166 /*
167  * call signal or sigset (signal does not block the signal while
168  * in the handler on sys v and sigset does not exist on bsd)
169  */
170 #ifndef SIGNAL
171 #ifdef HAVE_SIGSET
172 #define SIGNAL sigset
173 #else
174 #define SIGNAL signal
175 #endif
176 #endif
177
178 /*
179  * toupper and tolower macros are different under bsd and sys v
180  */
181 #if defined( SYSV ) && !defined( hpux )
182 #define TOUPPER(c)      (isascii(c) && islower(c) ? _toupper(c) : c)
183 #define TOLOWER(c)      (isascii(c) && isupper(c) ? _tolower(c) : c)
184 #else
185 #define TOUPPER(c)      (isascii(c) && islower(c) ? toupper(c) : c)
186 #define TOLOWER(c)      (isascii(c) && isupper(c) ? tolower(c) : c)
187 #endif
188
189 /*
190  * put a cover on the tty-related ioctl calls we need to use
191  */
192 #if !defined( HAVE_TERMIOS_H )
193 #define TERMIO_TYPE struct sgttyb
194 #define TERMFLAG_TYPE int
195 #define GETATTR( fd, tiop )     ioctl((fd), TIOCGETP, (caddr_t)(tiop))
196 #define SETATTR( fd, tiop )     ioctl((fd), TIOCSETP, (caddr_t)(tiop))
197 #define GETFLAGS( tio )         (tio).sg_flags
198 #define SETFLAGS( tio, flags )  (tio).sg_flags = (flags)
199 #else
200 #define USE_TERMIOS
201 #define TERMIO_TYPE struct termios
202 #define TERMFLAG_TYPE tcflag_t
203 #define GETATTR( fd, tiop )     tcgetattr((fd), (tiop))
204 #define SETATTR( fd, tiop )     tcsetattr((fd), TCSANOW /* 0 */, (tiop))
205 #define GETFLAGS( tio )         (tio).c_lflag
206 #define SETFLAGS( tio, flags )  (tio).c_lflag = (flags)
207 #endif
208
209
210 #if defined( ultrix ) || defined( nextstep )
211 extern char *strdup();
212 #endif /* ultrix || nextstep */
213
214 #endif /* _LDAP_BRIDGE_H */