squid.h
上传用户:liugui
上传日期:2007-01-04
资源大小:822k
文件大小:8k
- /*
- * $Id: squid.h,v 1.185 1999/01/19 17:41:04 wessels Exp $
- *
- * AUTHOR: Duane Wessels
- *
- * SQUID Internet Object Cache http://squid.nlanr.net/Squid/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from the
- * Internet community. Development is led by Duane Wessels of the
- * National Laboratory for Applied Network Research and funded by the
- * National Science Foundation. Squid is Copyrighted (C) 1998 by
- * Duane Wessels and the University of California San Diego. Please
- * see the COPYRIGHT file for full details. Squid incorporates
- * software developed and/or copyrighted by other sources. Please see
- * the CREDITS file for full details.
- *
- * 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; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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, USA.
- *
- */
- #ifndef SQUID_H
- #define SQUID_H
- #include "config.h"
- /*
- * On some systems, FD_SETSIZE is set to something lower than the
- * actual number of files which can be opened. IRIX is one case,
- * NetBSD is another. So here we increase FD_SETSIZE to our
- * configure-discovered maximum *before* any system includes.
- */
- #define CHANGE_FD_SETSIZE 1
- /* Cannot increase FD_SETSIZE on Linux */
- #if defined(_SQUID_LINUX_)
- #undef CHANGE_FD_SETSIZE
- #define CHANGE_FD_SETSIZE 0
- #endif
- /* Cannot increase FD_SETSIZE on FreeBSD before 2.2.0, causes select(2)
- * to return EINVAL. */
- /* Marian Durkovic <marian@svf.stuba.sk> */
- /* Peter Wemm <peter@spinner.DIALix.COM> */
- #if defined(_SQUID_FREEBSD_)
- #include <osreldate.h>
- #if __FreeBSD_version < 220000
- #undef CHANGE_FD_SETSIZE
- #define CHANGE_FD_SETSIZE 0
- #endif
- #endif
- /* Increase FD_SETSIZE if SQUID_MAXFD is bigger */
- #if CHANGE_FD_SETSIZE && SQUID_MAXFD > DEFAULT_FD_SETSIZE
- #define FD_SETSIZE SQUID_MAXFD
- #endif
- #if PURIFY
- #define assert(EX) ((void)0)
- #elif STDC_HEADERS
- #define assert(EX) ((EX)?((void)0):xassert( # EX , __FILE__, __LINE__))
- #else
- #define assert(EX) ((EX)?((void)0):xassert("EX", __FILE__, __LINE__))
- #endif
- #if HAVE_UNISTD_H
- #include <unistd.h>
- #endif
- #if HAVE_STDLIB_H
- #include <stdlib.h>
- #endif
- #if HAVE_STDIO_H
- #include <stdio.h>
- #endif
- #if HAVE_SYS_TYPES_H
- #include <sys/types.h>
- #endif
- #if HAVE_CTYPE_H
- #include <ctype.h>
- #endif
- #if HAVE_ERRNO_H
- #include <errno.h>
- #endif
- #if HAVE_FCNTL_H
- #include <fcntl.h>
- #endif
- #if HAVE_GRP_H
- #include <grp.h>
- #endif
- #if HAVE_GNUMALLOC_H
- #include <gnumalloc.h>
- #elif HAVE_MALLOC_H && !defined(_SQUID_FREEBSD_) && !defined(_SQUID_NEXT_)
- #include <malloc.h>
- #endif
- #if HAVE_MEMORY_H
- #include <memory.h>
- #endif
- #if HAVE_NETDB_H && !defined(_SQUID_NETDB_H_) /* protect NEXTSTEP */
- #define _SQUID_NETDB_H_
- #ifdef _SQUID_NEXT_
- #include <netinet/in_systm.h>
- #endif
- #include <netdb.h>
- #endif
- #if HAVE_PWD_H
- #include <pwd.h>
- #endif
- #if HAVE_SIGNAL_H
- #include <signal.h>
- #endif
- #if HAVE_TIME_H
- #include <time.h>
- #endif
- #if HAVE_SYS_PARAM_H
- #include <sys/param.h>
- #endif
- #if HAVE_SYS_TIME_H
- #include <sys/time.h>
- #endif
- #if HAVE_SYS_RESOURCE_H
- #include <sys/resource.h> /* needs sys/time.h above it */
- #endif
- #if HAVE_SYS_SOCKET_H
- #include <sys/socket.h>
- #endif
- #if HAVE_NETINET_IN_H
- #include <netinet/in.h>
- #endif
- #if HAVE_ARPA_INET_H
- #include <arpa/inet.h>
- #endif
- #if HAVE_SYS_STAT_H
- #include <sys/stat.h>
- #endif
- #if HAVE_SYS_UN_H
- #include <sys/un.h>
- #endif
- #if HAVE_SYS_WAIT_H
- #include <sys/wait.h>
- #endif
- #if HAVE_LIBC_H
- #include <libc.h>
- #endif
- #ifdef HAVE_SYS_SYSCALL_H
- #include <sys/syscall.h>
- #endif
- #ifdef HAVE_STRING_H
- #include <string.h>
- #endif
- #ifdef HAVE_STRINGS_H
- #include <strings.h>
- #endif
- #if HAVE_BSTRING_H
- #include <bstring.h>
- #endif
- #ifdef HAVE_CRYPT_H
- #include <crypt.h>
- #endif
- #if HAVE_SYS_SELECT_H
- #include <sys/select.h>
- #endif
- #if HAVE_GETOPT_H
- #include <getopt.h>
- #endif
- #if HAVE_DIRENT_H
- #include <dirent.h>
- #define NAMLEN(dirent) strlen((dirent)->d_name)
- #else /* HAVE_DIRENT_H */
- #define dirent direct
- #define NAMLEN(dirent) (dirent)->d_namlen
- #if HAVE_SYS_NDIR_H
- #include <sys/ndir.h>
- #endif /* HAVE_SYS_NDIR_H */
- #if HAVE_SYS_DIR_H
- #include <sys/dir.h>
- #endif /* HAVE_SYS_DIR_H */
- #if HAVE_NDIR_H
- #include <ndir.h>
- #endif /* HAVE_NDIR_H */
- #endif /* HAVE_DIRENT_H */
- #if defined(__QNX__)
- #include <unix.h>
- #endif
- /*
- * We require poll.h before using poll(). If the symbols used
- * by poll() are defined elsewhere, we will need to make this
- * a more sophisticated test.
- * -- Oskar Pearson <oskar@is.co.za>
- * -- Stewart Forster <slf@connect.com.au>
- */
- #if HAVE_POLL
- #if HAVE_POLL_H
- #include <poll.h>
- #else /* HAVE_POLL_H */
- #undef HAVE_POLL
- #endif /* HAVE_POLL_H */
- #endif /* HAVE_POLL */
- #if STDC_HEADERS
- #include <stdarg.h>
- #else
- #include <varargs.h>
- #endif
- /* Make sure syslog goes after stdarg/varargs */
- #ifdef HAVE_SYSLOG_H
- #ifdef _SQUID_AIX_
- #define _XOPEN_EXTENDED_SOURCE
- #endif
- #include <syslog.h>
- #endif
- #if HAVE_MATH_H
- #include <math.h>
- #endif
- #if !defined(MAXHOSTNAMELEN) || (MAXHOSTNAMELEN < 128)
- #define SQUIDHOSTNAMELEN 128
- #else
- #define SQUIDHOSTNAMELEN MAXHOSTNAMELEN
- #endif
- #define SQUID_MAXPATHLEN 256
- #ifndef MAXPATHLEN
- #define MAXPATHLEN SQUID_MAXPATHLEN
- #endif
- #if !HAVE_GETRUSAGE
- #if defined(_SQUID_HPUX_)
- #define HAVE_GETRUSAGE 1
- #define getrusage(a, b) syscall(SYS_GETRUSAGE, a, b)
- #endif
- #endif
- #if !HAVE_STRUCT_RUSAGE
- /*
- * If we don't have getrusage() then we create a fake structure
- * with only the fields Squid cares about. This just makes the
- * source code cleaner, so we don't need lots of #ifdefs in other
- * places
- */
- struct rusage {
- struct timeval ru_stime;
- struct timeval ru_utime;
- int ru_maxrss;
- int ru_majflt;
- };
- #endif
- #if !defined(HAVE_GETPAGESIZE) && defined(_SQUID_HPUX_)
- #define HAVE_GETPAGESIZE
- #define getpagesize( ) sysconf(_SC_PAGE_SIZE)
- #endif
- #ifndef BUFSIZ
- #define BUFSIZ 4096 /* make reasonable guess */
- #endif
- #ifndef SA_RESTART
- #define SA_RESTART 0
- #endif
- #ifndef SA_NODEFER
- #define SA_NODEFER 0
- #endif
- #ifndef SA_RESETHAND
- #define SA_RESETHAND 0
- #endif
- #if SA_RESETHAND == 0 && defined(SA_ONESHOT)
- #undef SA_RESETHAND
- #define SA_RESETHAND SA_ONESHOT
- #endif
- #if PURIFY
- #define LOCAL_ARRAY(type,name,size)
- static type *local_##name=NULL;
- type *name = local_##name ? local_##name :
- ( local_##name = (type *)xcalloc(size, sizeof(type)) )
- #else
- #define LOCAL_ARRAY(type,name,size) static type name[size]
- #endif
- #if CBDATA_DEBUG
- #define cbdataAdd(a,b,c) cbdataAddDbg(a,b,c,__FILE__,__LINE__)
- #endif
- #if USE_LEAKFINDER
- #define leakAdd(p) leakAddFL(p,__FILE__,__LINE__)
- #define leakTouch(p) leakTouchFL(p,__FILE__,__LINE__)
- #else
- #define leakAdd(p) p
- #define leakTouch(p) p
- #define leakFree(p) p
- #endif
- #if defined(_SQUID_NEXT_) && !defined(S_ISDIR)
- #define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR))
- #endif
- #ifdef USE_GNUREGEX
- #include "GNUregex.h"
- #elif HAVE_REGEX_H
- #include <regex.h>
- #endif
- #if USE_ASYNC_IO
- #undef USE_UNLINKD
- #else
- #define USE_UNLINKD 1
- #endif
- #include "md5.h"
- #include "Stack.h"
- /* Needed for poll() on Linux at least */
- #if HAVE_POLL
- #ifndef POLLRDNORM
- #define POLLRDNORM POLLIN
- #endif
- #ifndef POLLWRNORM
- #define POLLWRNORM POLLOUT
- #endif
- #endif
- #ifdef SQUID_SNMP
- #include "cache_snmp.h"
- #endif
- #include "hash.h"
- #include "defines.h"
- #include "enums.h"
- #include "typedefs.h"
- #include "structs.h"
- #include "protos.h"
- #include "globals.h"
- #include "util.h"
- #include "radix.h"
- #if !HAVE_TEMPNAM
- #include "tempnam.h"
- #endif
- #if !HAVE_SNPRINTF
- #include "snprintf.h"
- #endif
- #define XMIN(x,y) ((x)<(y)? (x) : (y))
- #define XMAX(a,b) ((a)>(b)? (a) : (b))
- /*
- * Squid source files should not call these functions directly
- */
- #define malloc +
- #define free +
- #define calloc +
- #define sprintf +
- #define strdup +
- #if SQUID_SNMP
- extern struct snmp_mib_tree *Mib;
- #endif
- #endif /* SQUID_H */