1 /**	$MirOS: src/usr.sbin/httpd/src/include/ap_config.h,v 1.5 2006/09/20 23:45:04 tg Exp $ */
2 /*	$OpenBSD: ap_config.h,v 1.21 2006/04/04 11:39:28 henning Exp $ */
3 
4 /* ====================================================================
5  * The Apache Software License, Version 1.1
6  *
7  * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
8  * reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  *
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in
19  *    the documentation and/or other materials provided with the
20  *    distribution.
21  *
22  * 3. The end-user documentation included with the redistribution,
23  *    if any, must include the following acknowledgment:
24  *       "This product includes software developed by the
25  *        Apache Software Foundation (http://www.apache.org/)."
26  *    Alternately, this acknowledgment may appear in the software itself,
27  *    if and wherever such third-party acknowledgments normally appear.
28  *
29  * 4. The names "Apache" and "Apache Software Foundation" must
30  *    not be used to endorse or promote products derived from this
31  *    software without prior written permission. For written
32  *    permission, please contact apache@apache.org.
33  *
34  * 5. Products derived from this software may not be called "Apache",
35  *    nor may "Apache" appear in their name, without prior written
36  *    permission of the Apache Software Foundation.
37  *
38  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
39  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
42  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
48  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49  * SUCH DAMAGE.
50  * ====================================================================
51  *
52  * This software consists of voluntary contributions made by many
53  * individuals on behalf of the Apache Software Foundation.  For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  *
57  * Portions of this software are based upon public domain software
58  * originally written at the National Center for Supercomputing Applications,
59  * University of Illinois, Urbana-Champaign.
60  */
61 
62 #ifndef AP_CONFIG_H
63 #define AP_CONFIG_H
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 /*
70  * ap_config.h: system-dependant #defines and includes...
71  * See PORTING for a listing of what they mean
72  */
73 
74 #include "ap_mmn.h"		/* MODULE_MAGIC_NUMBER_ */
75 
76 /*
77  * Support for platform dependent autogenerated defines
78  */
79 #include "ap_config_auto.h"
80 
81 #include <sys/types.h>
82 #include <sys/stat.h>
83 
84 
85 /* So that we can use inline on some critical functions, and use
86  * GNUC attributes (such as to get -Wall warnings for printf-like
87  * functions).  Only do this in gcc 2.7 or later ... it may work
88  * on earlier stuff, but why chance it.
89  */
90 #define ap_inline __inline__
91 #define USE_GNU_INLINE
92 #define ENUM_BITFIELD(e,n,w)  e n : w
93 
94 #include "os.h"
95 
96 /* Define these according to OpenBSD system. */
97 #define HAVE_GMTOFF 1
98 #undef NO_KILLPG
99 #undef NO_SETSID
100 #define HAVE_SYSLOG 1
101 #ifndef DEFAULT_USER
102 #define DEFAULT_USER "nobody"
103 #endif
104 #ifndef DEFAULT_GROUP
105 #define DEFAULT_GROUP "nogroup"
106 #endif
107 #define HAVE_SHMGET 1
108 #define HAVE_MMAP 1
109 #define USE_MMAP_SCOREBOARD
110 #define USE_MMAP_FILES
111 #define HAVE_FLOCK_SERIALIZED_ACCEPT
112 #define HAVE_SYSVSEM_SERIALIZED_ACCEPT
113 #define USE_SYSVSEM_SERIALIZED_ACCEPT
114 #include <sys/param.h>
115 #if (OpenBSD >= 199912)
116 #define NET_SIZE_T socklen_t
117 #endif
118 #define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
119 
120 #include <sys/param.h>
121 
122 /* stuff marked API_EXPORT is part of the API, and intended for use
123  * by modules
124  */
125 #ifndef API_EXPORT
126 #define API_EXPORT(type)    type
127 #endif
128 
129 /* Stuff marked API_EXPORT_NONSTD is part of the API, and intended for
130  * use by modules.  The difference between API_EXPORT and
131  * API_EXPORT_NONSTD is that the latter is required for any functions
132  * which use varargs or are used via indirect function call.  This
133  * is to accomodate the two calling conventions in windows dlls.
134  */
135 #ifndef API_EXPORT_NONSTD
136 #define API_EXPORT_NONSTD(type)    type
137 #endif
138 
139 #ifndef MODULE_VAR_EXPORT
140 #define MODULE_VAR_EXPORT
141 #endif
142 #ifndef API_VAR_EXPORT
143 #define API_VAR_EXPORT
144 #endif
145 
146 /* modules should not used functions marked CORE_EXPORT
147  * or CORE_EXPORT_NONSTD */
148 #ifndef CORE_EXPORT
149 #define CORE_EXPORT	API_EXPORT
150 #endif
151 #ifndef CORE_EXPORT_NONSTD
152 #define CORE_EXPORT_NONSTD	API_EXPORT_NONSTD
153 #endif
154 
155 #define ap_private_extern
156 
157 /*
158  * The particular directory style your system supports. If you have dirent.h
159  * in /usr/include (POSIX) or /usr/include/sys (SYSV), #include
160  * that file and define DIR_TYPE to be dirent. Otherwise, if you have
161  * /usr/include/sys/dir.h, define DIR_TYPE to be direct and include that
162  * file. If you have neither, I'm confused.
163  */
164 
165 #include <sys/types.h>
166 #include <stdarg.h>
167 
168 #include <dirent.h>
169 #define DIR_TYPE dirent
170 
171 #include <stdio.h>
172 #include <stdlib.h>
173 #include <string.h>
174 #include "ap_ctype.h"
175 #include <sys/file.h>
176 #include <sys/socket.h>
177 #include <sys/select.h>
178 #include <netinet/in.h>
179 #include <netdb.h>
180 #include <sys/ioctl.h>
181 #include <arpa/inet.h>		/* for inet_ntoa */
182 #include <sys/wait.h>
183 #include <pwd.h>
184 #include <grp.h>
185 #include <fcntl.h>
186 #define closesocket(s) close(s)
187 #ifndef O_BINARY
188 #define O_BINARY (0)
189 #endif
190 
191 #include <limits.h>
192 #include <time.h>		/* for ctime */
193 #include <signal.h>
194 #include <errno.h>
195 #include <memory.h>
196 
197 #include <regex.h>
198 
199 #include <sys/resource.h>
200 #include <sys/mman.h>
201 
202 /* A USE_FOO_SERIALIZED_ACCEPT implies a HAVE_FOO_SERIALIZED_ACCEPT */
203 #if defined(USE_SYSVSEM_SERIALIZED_ACCEPT) && !defined(HAVE_SYSVSEM_SERIALIZED_ACCEPT)
204 #define HAVE_SYSVSEM_SERIALIZED_ACCEPT
205 #endif
206 #if defined(USE_FLOCK_SERIALIZED_ACCEPT) && !defined(HAVE_FLOCK_SERIALIZED_ACCEPT)
207 #define HAVE_FLOCK_SERIALIZED_ACCEPT
208 #endif
209 
210 #ifndef LOGNAME_MAX
211 #define LOGNAME_MAX 25
212 #endif
213 
214 #include <unistd.h>
215 
216 #ifndef S_ISLNK
217 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
218 #endif
219 
220 #ifndef INADDR_NONE
221 #define INADDR_NONE ((unsigned long) -1)
222 #endif
223 
224 /*
225  * Replace signal function with sigaction equivalent
226  */
227 typedef void Sigfunc(int);
228 
229 #if defined(SIG_IGN) && !defined(SIG_ERR)
230 #define SIG_ERR ((Sigfunc *)-1)
231 #endif
232 
233 /*
234  * For some strange reason, QNX defines signal to signal. Eliminate it.
235  */
236 #ifdef signal
237 #undef signal
238 #endif
239 #define signal(s,f)	ap_signal(s,f)
240 Sigfunc *signal(int signo, Sigfunc * func);
241 
242 #include <setjmp.h>
243 
244 #if defined(USE_LONGJMP)
245 #define ap_longjmp(x, y)        longjmp((x), (y))
246 #define ap_setjmp(x)            setjmp(x)
247 #ifndef JMP_BUF
248 #define JMP_BUF jmp_buf
249 #endif
250 #else
251 #define ap_longjmp(x, y)        siglongjmp((x), (y))
252 #define ap_setjmp(x)            sigsetjmp((x), 1)
253 #ifndef JMP_BUF
254 #define JMP_BUF sigjmp_buf
255 #endif
256 #endif
257 
258 /* Majority of os's want to verify FD_SETSIZE */
259 #define CHECK_FD_SETSIZE
260 
261 #if defined(SELECT_NEEDS_CAST)
262 #define ap_select(_a, _b, _c, _d, _e)   \
263     select((_a), (int *)(_b), (int *)(_c), (int *)(_d), (_e))
264 #else
265 #define ap_select(_a, _b, _c, _d, _e)   \
266 	select(_a, _b, _c, _d, _e)
267 #endif
268 
269 #define ap_accept(_fd, _sa, _ln)	accept(_fd, _sa, _ln)
270 
271 #define ap_check_signals()
272 
273 #define ap_fdopen(d,m) fdopen((d), (m))
274 
275 #ifndef ap_inet_addr
276 #define ap_inet_addr inet_addr
277 #endif
278 
279 /* Finding offsets of elements within structures.
280  * Taken from the X code... they've sweated portability of this stuff
281  * so we don't have to.  Sigh...
282  */
283 
284 #if defined(__arm)
285 #ifdef __STDC__
286 #define XtOffset(p_type,field) _Offsetof(p_type,field)
287 #else
288 #define XtOffset(p_type,field) ((unsigned int)&(((p_type)NULL)->field))
289 #endif /* __STDC__ */
290 #else /* ! (__arm) */
291 
292 #define XtOffset(p_type,field) \
293 	((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
294 
295 #endif /* __arm */
296 
297 #ifdef offsetof
298 #define XtOffsetOf(s_type,field) offsetof(s_type,field)
299 #else
300 #define XtOffsetOf(s_type,field) XtOffset(s_type*,field)
301 #endif
302 
303 /*
304  * NET_SIZE_T exists because of shortsightedness on the POSIX committee.  BSD
305  * systems used "int *" as the parameter to accept(), getsockname(),
306  * getpeername() et al.  Consequently many unixes took an int * for that
307  * parameter.  The POSIX committee decided that "int" was just too generic and
308  * had to be replaced with size_t almost everywhere.  There's no problem with
309  * that when you're passing by value.  But when you're passing by reference
310  * this creates a gross source incompatibility with existing programs.  On
311  * 32-bit architectures it creates only a warning.  On 64-bit architectures it
312  * creates broken code -- because "int *" is a pointer to a 64-bit quantity and
313  * "size_t *" is frequently a pointer to a 32-bit quantity.
314  *
315  * Some Unixes adopted "size_t *" for the sake of POSIX compliance.  Others
316  * ignored it because it was such a broken interface.  Chaos ensued.  POSIX
317  * finally woke up and decided that it was wrong and created a new type
318  * socklen_t.  The only useful value for socklen_t is int, and that's how
319  * everyone who has a clue implements it.  It is almost always the case that
320  * NET_SIZE_T should be defined to be an int, unless the system being compiled
321  * for was created in the window of POSIX madness.
322  */
323 #ifndef NET_SIZE_T
324 #define NET_SIZE_T int
325 #endif
326 
327 /* The assumption is that when the functions are missing,
328  * then there's no matching prototype available either.
329  * Declare what is needed exactly as the replacement routines implement it.
330  */
331 
332 #ifndef ap_wait_t
333 #define ap_wait_t int
334 #endif
335 
336 #ifndef INET6
337 #define sockaddr_storage	sockaddr
338 #define ss_family		sa_family
339 #define ss_len			sa_len
340 #else
341 #include "sockaddr_storage.h"	/* sshida@st.rim.or.jp */
342 #endif
343 
344 #ifndef INET6_ADDRSTRLEN
345 #define INET6_ADDRSTRLEN	46
346 #endif
347 #ifndef INET_ADDRSTRLEN
348 #define INET_ADDRSTRLEN		16
349 #endif
350 #ifndef NI_MAXHOST
351 #define NI_MAXHOST		1025
352 #endif
353 #ifndef NI_MAXSERV
354 #define	NI_MAXSERV		32
355 #endif
356 
357 #if defined(NEED_GETADDRINFO) || defined(NEED_GETNAMEINFO)
358 /*
359  * minimal definitions for fake getaddrinfo()/getnameinfo().
360  */
361 #ifndef EAI_NODATA
362 #define EAI_NODATA	1
363 #define EAI_MEMORY	2
364 #endif
365 
366 #ifndef AI_PASSIVE
367 #define AI_PASSIVE	1
368 #define AI_CANONNAME	2
369 #define AI_NUMERICHOST	4
370 #define NI_NUMERICHOST	8
371 #define NI_NAMEREQD	16
372 #define NI_NUMERICSERV	32
373 #endif
374 #endif
375 
376 #ifdef NEED_GETADDRINFO
377 #ifdef NEED_ADDRINFO
378 struct addrinfo {
379 	int	ai_flags;	/* AI_PASSIVE, AI_CANONNAME */
380 	int	ai_family;	/* PF_xxx */
381 	int	ai_socktype;	/* SOCK_xxx */
382 	int	ai_protocol;	/* 0 or IPPROTO_xxx for IPv4 and IPv6 */
383 	size_t	ai_addrlen;	/* length of ai_addr */
384 	char	*ai_canonname;	/* canonical name for hostname */
385 	struct sockaddr *ai_addr;	/* binary address */
386 	struct addrinfo *ai_next;	/* next structure in linked list */
387 };
388 #endif
389 extern char *gai_strerror(int ecode);
390 extern void freeaddrinfo(struct addrinfo *ai);
391 extern int getaddrinfo(const char *hostname, const char *servname,
392 	const struct addrinfo *hints, struct addrinfo **res);
393 #endif
394 #ifdef NEED_GETNAMEINFO
395 extern int getnameinfo(const struct sockaddr *sa, size_t salen,
396 	char *host, size_t hostlen, char *serv, size_t servlen,
397 	int flag);
398 #endif
399 
400 #ifdef __cplusplus
401 }
402 #endif
403 
404 #endif /* !AP_CONFIG_H */
405