]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/squid.h
3 * $Id: squid.h,v 1.215 2001/04/14 00:03:23 hno Exp $
5 * AUTHOR: Duane Wessels
7 * SQUID Web Proxy Cache http://www.squid-cache.org/
8 * ----------------------------------------------------------
10 * Squid is the result of efforts by numerous individuals from
11 * the Internet community; see the CONTRIBUTORS file for full
12 * details. Many organizations have provided support for Squid's
13 * development; see the SPONSORS file for full details. Squid is
14 * Copyrighted (C) 2001 by the Regents of the University of
15 * California; see the COPYRIGHT file for full details. Squid
16 * incorporates software developed and/or copyrighted by other
17 * sources; see the CREDITS file for full details.
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
41 * On some systems, FD_SETSIZE is set to something lower than the
42 * actual number of files which can be opened. IRIX is one case,
43 * NetBSD is another. So here we increase FD_SETSIZE to our
44 * configure-discovered maximum *before* any system includes.
46 #define CHANGE_FD_SETSIZE 1
48 /* Cannot increase FD_SETSIZE on Linux */
49 #if defined(_SQUID_LINUX_)
50 #undef CHANGE_FD_SETSIZE
51 #define CHANGE_FD_SETSIZE 0
55 * Cannot increase FD_SETSIZE on FreeBSD before 2.2.0, causes select(2)
57 * --Marian Durkovic <marian@svf.stuba.sk>
58 * --Peter Wemm <peter@spinner.DIALix.COM>
60 #if defined(_SQUID_FREEBSD_)
61 #include <osreldate.h>
62 #if __FreeBSD_version < 220000
63 #undef CHANGE_FD_SETSIZE
64 #define CHANGE_FD_SETSIZE 0
69 * Trying to redefine CHANGE_FD_SETSIZE causes a slew of warnings
72 #if defined(_SQUID_APPLE_)
73 #undef CHANGE_FD_SETSIZE
74 #define CHANGE_FD_SETSIZE 0
77 /* Increase FD_SETSIZE if SQUID_MAXFD is bigger */
78 #if CHANGE_FD_SETSIZE && SQUID_MAXFD > DEFAULT_FD_SETSIZE
79 #define FD_SETSIZE SQUID_MAXFD
83 #define assert(EX) ((void)0)
84 #elif defined(NODEBUG)
85 #define assert(EX) ((void)0)
87 #define assert(EX) ((EX)?((void)0):xassert( # EX , __FILE__, __LINE__))
89 #define assert(EX) ((EX)?((void)0):xassert("EX", __FILE__, __LINE__))
93 /* 32 bit integer compatability */
94 #include "squid_types.h"
96 #define u_num32 u_int32_t
108 #include <sys/types.h>
123 #include <gnumalloc.h>
124 #elif HAVE_MALLOC_H && !defined(_SQUID_FREEBSD_) && !defined(_SQUID_NEXT_)
130 #if HAVE_NETDB_H && !defined(_SQUID_NETDB_H_) /* protect NEXTSTEP */
131 #define _SQUID_NETDB_H_
133 #include <netinet/in_systm.h>
147 #include <sys/param.h>
150 #include <sys/time.h>
152 #if HAVE_SYS_RESOURCE_H
153 #include <sys/resource.h> /* needs sys/time.h above it */
155 #if HAVE_SYS_SOCKET_H
156 #include <sys/socket.h>
158 #if HAVE_NETINET_IN_H
159 #include <netinet/in.h>
162 #include <arpa/inet.h>
165 #include <sys/stat.h>
171 #include <sys/wait.h>
176 #ifdef HAVE_SYS_SYSCALL_H
177 #include <sys/syscall.h>
182 #ifdef HAVE_STRINGS_H
191 #if HAVE_SYS_SELECT_H
192 #include <sys/select.h>
200 #if defined(_SQUID_CYGWIN_)
206 #define NAMLEN(dirent) strlen((dirent)->d_name)
207 #else /* HAVE_DIRENT_H */
208 #define dirent direct
209 #define NAMLEN(dirent) (dirent)->d_namlen
211 #include <sys/ndir.h>
212 #endif /* HAVE_SYS_NDIR_H */
215 #endif /* HAVE_SYS_DIR_H */
218 #endif /* HAVE_NDIR_H */
219 #endif /* HAVE_DIRENT_H */
226 #include <sys/mount.h>
230 * We require poll.h before using poll(). If the symbols used
231 * by poll() are defined elsewhere, we will need to make this
232 * a more sophisticated test.
233 * -- Oskar Pearson <oskar@is.co.za>
234 * -- Stewart Forster <slf@connect.com.au>
239 #else /* HAVE_POLL_H */
241 #endif /* HAVE_POLL_H */
242 #endif /* HAVE_POLL */
244 #if defined(HAVE_STDARG_H)
246 #define HAVE_STDARGS /* let's hope that works everywhere (mj) */
247 #define VA_LOCAL_DECL va_list ap;
248 #define VA_START(f) va_start(ap, f)
249 #define VA_SHIFT(v,t) ; /* no-op for ANSI */
250 #define VA_END va_end(ap)
252 #if defined(HAVE_VARARGS_H)
255 #define VA_LOCAL_DECL va_list ap;
256 #define VA_START(f) va_start(ap) /* f is ignored! */
257 #define VA_SHIFT(v,t) v = va_arg(ap,t)
258 #define VA_END va_end(ap)
260 #error XX **NO VARARGS ** XX
264 /* Make sure syslog goes after stdarg/varargs */
267 #define _XOPEN_EXTENDED_SOURCE
268 #define _XOPEN_SOURCE_EXTENDED 1
277 #if !defined(MAXHOSTNAMELEN) || (MAXHOSTNAMELEN < 128)
278 #define SQUIDHOSTNAMELEN 128
280 #define SQUIDHOSTNAMELEN MAXHOSTNAMELEN
283 #define SQUID_MAXPATHLEN 256
285 #define MAXPATHLEN SQUID_MAXPATHLEN
289 #if defined(_SQUID_HPUX_)
290 #define HAVE_GETRUSAGE 1
291 #define getrusage(a, b) syscall(SYS_GETRUSAGE, a, b)
295 #if !HAVE_STRUCT_RUSAGE
297 * If we don't have getrusage() then we create a fake structure
298 * with only the fields Squid cares about. This just makes the
299 * source code cleaner, so we don't need lots of #ifdefs in other
303 struct timeval ru_stime
;
304 struct timeval ru_utime
;
311 #if !defined(HAVE_GETPAGESIZE) && defined(_SQUID_HPUX_)
312 #define HAVE_GETPAGESIZE
313 #define getpagesize( ) sysconf(_SC_PAGE_SIZE)
317 #define BUFSIZ 4096 /* make reasonable guess */
328 #define SA_RESETHAND 0
330 #if SA_RESETHAND == 0 && defined(SA_ONESHOT)
332 #define SA_RESETHAND SA_ONESHOT
336 #define LOCAL_ARRAY(type,name,size) \
337 static type *local_##name=NULL; \
338 type *name = local_##name ? local_##name : \
339 ( local_##name = (type *)xcalloc(size, sizeof(type)) )
341 #define LOCAL_ARRAY(type,name,size) static type name[size]
345 #define cbdataAlloc(a,b) cbdataAllocDbg(a,b,__FILE__,__LINE__)
346 #define cbdataLock(a) cbdataLockDbg(a,__FILE__,__LINE__)
347 #define cbdataUnlock(a) cbdataUnlockDbg(a,__FILE__,__LINE__)
351 #define leakAdd(p) leakAddFL(p,__FILE__,__LINE__)
352 #define leakTouch(p) leakTouchFL(p,__FILE__,__LINE__)
353 #define leakFree(p) leakFreeFL(p,__FILE__,__LINE__)
356 #define leakTouch(p) p
357 #define leakFree(p) p
360 #if defined(_SQUID_NEXT_) && !defined(S_ISDIR)
361 #define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR))
365 #include "GNUregex.h"
373 #include "ssl_support.h"
374 /* This is an ugly hack, but necessary.
376 * Squid's md5 conflicts with OpenSSL's md5, but they're more or less
378 * Free is defined in include/radix.h and also in OpenSSL, but we don't need
379 * OpenSSL's, so it can be undef'd and then appear from radix.h later.
380 * It's dangerous and ugly, but I can't see any other way to get around it.
387 /* Needed for poll() on Linux at least */
390 #define POLLRDNORM POLLIN
393 #define POLLWRNORM POLLOUT
398 #include "cache_snmp.h"
406 #include "typedefs.h"
414 * Mac OS X Server already has radix.h as a standard header, so
415 * this causes conflicts.
417 #ifndef _SQUID_APPLE_
426 #include "snprintf.h"
429 #define XMIN(x,y) ((x)<(y)? (x) : (y))
430 #define XMAX(a,b) ((a)>(b)? (a) : (b))
433 * Squid source files should not call these functions directly.
434 * Use xmalloc, xfree, xcalloc, snprintf, and xstrdup instead.
435 * Also use xmemcpy, xisspace, ...
454 * Hey dummy, don't be tempted to move this to lib/config.h.in
455 * again. O_NONBLOCK will not be defined there because you didn't
456 * #include <fcntl.h> yet.
458 #if defined(_SQUID_SUNOS_)
460 * We assume O_NONBLOCK is broken, or does not exist, on SunOS.
462 #define SQUID_NONBLOCK O_NDELAY
463 #elif defined(O_NONBLOCK)
465 * We used to assume O_NONBLOCK was broken on Solaris, but evidence
466 * now indicates that its fine on Solaris 8, and in fact required for
467 * properly detecting EOF on FIFOs. So now we assume that if
468 * its defined, it works correctly on all operating systems.
470 #define SQUID_NONBLOCK O_NONBLOCK
472 * O_NDELAY is our fallback.
475 #define SQUID_NONBLOCK O_NDELAY
479 * I'm sick of having to keep doing this ..
481 #define INDEXSD(i) (&Config.cacheSwap.swapDirs[(i)])
483 #define FD_READ_METHOD(fd, buf, len) (*fd_table[fd].read_method)(fd, buf, len)
484 #define FD_WRITE_METHOD(fd, buf, len) (*fd_table[fd].write_method)(fd, buf, len)