From: wessels <> Date: Wed, 27 Mar 1996 08:45:54 +0000 (+0000) Subject: MAJOR #include REWRITE; ack! X-Git-Tag: SQUID_3_0_PRE1~6378 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44a47c6e26f4aff5bc67c04dbddac360027a9e1d;p=thirdparty%2Fsquid.git MAJOR #include REWRITE; ack! --- diff --git a/include/util.h b/include/util.h index c8d0802dce..12368c54a2 100644 --- a/include/util.h +++ b/include/util.h @@ -1,7 +1,7 @@ /* * Darren Hardy, hardy@cs.colorado.edu, April 1994 * - * $Id: util.h,v 1.3 1996/03/19 01:28:48 wessels Exp $ + * $Id: util.h,v 1.4 1996/03/27 01:46:40 wessels Exp $ * * ---------------------------------------------------------------------- * Copyright (c) 1994, 1995. All rights reserved. @@ -180,6 +180,7 @@ void dump_host_cache _PARAMS((int, int)); char *mkhttpdlogtime _PARAMS((time_t *)); extern char *mkrfc850 _PARAMS((time_t *)); +extern time_t parse_rfc850 _PARAMS((char *str)); extern void init_log3 _PARAMS((char *pn, FILE *a, FILE *b)); extern void debug_init(); extern void log_errno2 _PARAMS((char *, int, char *)); diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 0624fff928..e736ff257a 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,25 +1,7 @@ -/* $Id: cache_cf.cc,v 1.4 1996/03/26 21:58:41 wessels Exp $ */ - -#include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "debug.h" -#include "comm.h" -#include "cache_cf.h" -#include "proto.h" -#include "store.h" -#include "ttl.h" -#include "util.h" +/* $Id: cache_cf.cc,v 1.5 1996/03/27 01:45:54 wessels Exp $ */ + +#include "squid.h" + static struct { struct { diff --git a/src/cachemgr.cc b/src/cachemgr.cc index ce823af0ea..78c3140d7a 100644 --- a/src/cachemgr.cc +++ b/src/cachemgr.cc @@ -1,19 +1,6 @@ -/* $Id: cachemgr.cc,v 1.3 1996/02/29 07:23:06 wessels Exp $ */ - -#include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "util.h" +/* $Id: cachemgr.cc,v 1.4 1996/03/27 01:45:56 wessels Exp $ */ + +#include "squid.h" static int client_comm_connect(); diff --git a/src/client.cc b/src/client.cc index 92a3285efa..7b81eecd82 100644 --- a/src/client.cc +++ b/src/client.cc @@ -1,17 +1,7 @@ -/* $Id: client.cc,v 1.3 1996/03/22 17:48:14 wessels Exp $ */ +/* $Id: client.cc,v 1.4 1996/03/27 01:45:56 wessels Exp $ */ -#include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "squid.h" #ifndef BUFSIZ #define BUFSIZ 8192 diff --git a/src/comm.cc b/src/comm.cc index dcc378272a..e7c0e94b54 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,32 +1,8 @@ -/* $Id: comm.cc,v 1.7 1996/03/26 05:16:20 wessels Exp $ */ - -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if HAVE_SYS_SELECT_H -#include -#endif +/* $Id: comm.cc,v 1.8 1996/03/27 01:45:57 wessels Exp $ */ -#if HAVE_BSTRING_H -#include -#endif +#include "squid.h" -#include "debug.h" -#include "comm.h" -#include "ipcache.h" -#include "cache_cf.h" -#include "fdstat.h" -#include "util.h" /* Block processing new client requests (accepts on ascii port) when we start * running shy of free file descriptors. For example, under SunOS, we'll keep @@ -61,10 +37,8 @@ extern int getMaxFD(); extern int theAsciiConnection; extern int theUdpConnection; extern int getConnectTimeout(); -extern int fdstat_are_n_free_fd _PARAMS((int)); -extern void fatal_dump _PARAMS((char *)); + extern int fd_of_first_client _PARAMS((StoreEntry *)); -char *fd_note(); void comm_handler() { @@ -73,45 +47,6 @@ void comm_handler() app_handler(); } -char *comm_hostname() -{ - static char host[SQUIDHOSTNAMELEN + 1]; - static int present = 0; - struct hostent *h = NULL; - - /* Get the host name and store it in host to return */ - if (!present) { - host[0] = '\0'; - if (gethostname(host, SQUIDHOSTNAMELEN) == -1) { - debug(1, "comm_hostname: gethostname failed: %s\n", - xstrerror()); - return NULL; - } else { - if ((h = ipcache_gethostbyname(host)) != NULL) { - /* DNS lookup successful */ - /* use the official name from DNS lookup */ - strcpy(host, h->h_name); - } - present = 1; - } - } - return host; -} - -char *comm_hostname_direct() -{ - static char temp_host[SQUIDHOSTNAMELEN + 1]; - - temp_host[0] = '\0'; - if (gethostname(temp_host, SQUIDHOSTNAMELEN) == -1) { - debug(1, "comm_hostname_direct: gethostname failed: %s\n", - xstrerror()); - return NULL; - } else { - return temp_host; - } -} - /* Return the local port associated with fd. */ int comm_port(fd) int fd; diff --git a/src/debug.cc b/src/debug.cc index 69f17570d5..504c2a44e2 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -1,28 +1,14 @@ -/* $Id: debug.cc,v 1.2 1996/02/29 07:23:08 wessels Exp $ */ +/* $Id: debug.cc,v 1.3 1996/03/27 01:45:58 wessels Exp $ */ -#include "config.h" -#include -#include -#include -#include -#if defined(__STRICT_ANSI__) -#include -#else -#include -#endif -#include -#include /* For MAXPATHLEN. */ +#include "squid.h" -#include "debug.h" -#include "util.h" -#include "cache_cf.h" +extern int getLogfileRotateNumber _PARAMS((void)); static char *_db_modules = 0; /* colon separated list of modules to debug. */ int _db_level = 0; char *_db_file = __FILE__; int _db_line = 0; -extern time_t cached_curtime; extern char *mkrfc850(); extern int unbuffered_logs; /* main.c */ diff --git a/src/disk.cc b/src/disk.cc index c917ff7c15..720ab5bb60 100644 --- a/src/disk.cc +++ b/src/disk.cc @@ -1,25 +1,6 @@ -/* $Id: disk.cc,v 1.3 1996/03/23 00:01:51 wessels Exp $ */ - -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ansihelp.h" -#include "comm.h" -#include "disk.h" -#include "fdstat.h" -#include "cache_cf.h" -#include "util.h" -#include "debug.h" +/* $Id: disk.cc,v 1.4 1996/03/27 01:45:59 wessels Exp $ */ + +#include "squid.h" #define DISK_LINE_LEN 1024 #define MAX_FILE_NAME_LEN 256 diff --git a/src/dnsserver.cc b/src/dnsserver.cc index 881800a368..9a46346183 100644 --- a/src/dnsserver.cc +++ b/src/dnsserver.cc @@ -1,22 +1,6 @@ -/* $Id: dnsserver.cc,v 1.3 1996/02/29 07:23:09 wessels Exp $ */ - -#include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "util.h" +/* $Id: dnsserver.cc,v 1.4 1996/03/27 01:46:00 wessels Exp $ */ + +#include "squid.h" extern int h_errno; diff --git a/src/errorpage.cc b/src/errorpage.cc index 8c023ff590..d70a7d074a 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -1,15 +1,8 @@ -/* $Id: errorpage.cc,v 1.2 1996/03/26 21:58:42 wessels Exp $ */ +/* $Id: errorpage.cc,v 1.3 1996/03/27 01:45:55 wessels Exp $ */ -#include "config.h" -#include +#include "squid.h" -#include "ansihelp.h" -#include "comm.h" -#include "store.h" -#include "stat.h" -#include "cached_error.h" - #define CACHED_ERROR_MSG_P1 "\ ERROR: The requested URL could not be retrieved\n\ @@ -99,7 +92,10 @@ error_data ErrorData[] = ""} }; -static char tmp_error_buf[BUFSIZ]; +/* GLOBAL */ +char tmp_error_buf[BUFSIZ]; + +/* LOCAL */ static char tbuf[BUFSIZ]; int log_errors = 1; @@ -124,7 +120,7 @@ void cached_error_entry(entry, type, msg) sprintf(tbuf, CACHED_ERROR_MSG_P3, ErrorData[type].lng, SQUID_VERSION, - comm_hostname()); + getMyHostname()); strcat(tmp_error_buf, tbuf); storeAbort(entry, tmp_error_buf); if (!log_errors) @@ -160,7 +156,7 @@ char *cached_error_url(url, type, msg) sprintf(tbuf, CACHED_ERROR_MSG_P3, ErrorData[type].lng, SQUID_VERSION, - comm_hostname()); + getMyHostname()); if (!log_errors) return tmp_error_buf; CacheInfo->log_append(CacheInfo, diff --git a/src/filemap.cc b/src/filemap.cc index 012d1cd081..8321a24da3 100644 --- a/src/filemap.cc +++ b/src/filemap.cc @@ -1,12 +1,6 @@ -/* $Id: filemap.cc,v 1.4 1996/03/22 17:48:16 wessels Exp $ */ +/* $Id: filemap.cc,v 1.5 1996/03/27 01:46:03 wessels Exp $ */ -#include "config.h" -#include - -#include "ansihelp.h" -#include "filemap.h" -#include "util.h" -#include "debug.h" +#include "squid.h" /* Number of bits in a long */ #if SIZEOF_LONG == 8 diff --git a/src/ftp.cc b/src/ftp.cc index 97937238ce..84edf0e765 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,28 +1,6 @@ -/* $Id: ftp.cc,v 1.11 1996/03/26 05:17:20 wessels Exp $ */ - -#include "config.h" -#include -#include -#include -#include -#include -#include -#include /* for WNOHANG */ -#include -#include - -#include "ansihelp.h" -#include "comm.h" -#include "store.h" -#include "stat.h" -#include "url.h" -#include "mime.h" -#include "fdstat.h" -#include "cache_cf.h" -#include "ttl.h" -#include "util.h" -#include "icp.h" -#include "cached_error.h" +/* $Id: ftp.cc,v 1.12 1996/03/27 01:46:04 wessels Exp $ */ + +#include "squid.h" #define FTP_DELETE_GAP (64*1024) #define READBUFSIZ 4096 @@ -51,9 +29,6 @@ typedef struct _Ftpdata { int got_marker; /* denotes end of successful request */ } FtpData; -extern char *tmp_error_buf; -extern time_t cached_curtime; - /* XXX: this does not support FTP on a different port! */ int ftp_url_parser(url, data) char *url; @@ -370,7 +345,7 @@ void ftpSendRequest(fd, data) strcat(buf, data->password); strcat(buf, space); debug(5, "ftpSendRequest: FD %d: buf '%s'\n", fd, buf); - data->icp_rwd_ptr = icpWrite(fd, buf, strlen(buf), 30, ftpSendComplete, data); + data->icp_rwd_ptr = icpWrite(fd, buf, strlen(buf), 30, ftpSendComplete, (caddr_t) data); } void ftpConnInProgress(fd, data) diff --git a/src/gopher.cc b/src/gopher.cc index 3e59ea065e..3b6d4c0018 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -1,29 +1,8 @@ -/* $Id: gopher.cc,v 1.7 1996/03/26 05:17:21 wessels Exp $ */ - -#include "config.h" -#include -#include -#include -#include -#include - -#include "ansihelp.h" -#include "comm.h" -#include "store.h" -#include "stat.h" -#include "url.h" -#include "mime.h" -#include "cache_cf.h" -#include "ttl.h" -#include "util.h" -#include "stmem.h" -#include "ipcache.h" -#include "icp.h" -#include "cached_error.h" +/* $Id: gopher.cc,v 1.8 1996/03/27 01:46:06 wessels Exp $ */ + +#include "squid.h" extern char *dns_error_message; -extern time_t cached_curtime; -extern char *tmp_error_buf; /* gopher type code from rfc. Anawat. */ #define GOPHER_FILE '0' @@ -736,7 +715,7 @@ int gopherReadReply(fd, data) /* This will be called when request write is complete. Schedule read of * reply. */ -int gopherSendComplete(fd, buf, size, errflag, data) +void gopherSendComplete(fd, buf, size, errflag, data) int fd; char *buf; int size; @@ -753,7 +732,7 @@ int gopherSendComplete(fd, buf, size, errflag, data) freeGopherData(data); if (buf) put_free_4k_page(buf); /* Allocated by gopherSendRequest. */ - return 0; + return; } /* * OK. We successfully reach remote site. Start MIME typing @@ -808,7 +787,6 @@ int gopherSendComplete(fd, buf, size, errflag, data) put_free_4k_page(buf); /* Allocated by gopherSendRequest. */ data->icp_page_ptr = NULL; data->icp_rwd_ptr = NULL; - return 0; } /* This will be called when connect completes. Write request. */ @@ -841,7 +819,12 @@ int gopherSendRequest(fd, data) } debug(5, "gopherSendRequest - fd: %d\n", fd); - data->icp_rwd_ptr = icpWrite(fd, buf, len, 30, gopherSendComplete, data); + data->icp_rwd_ptr = icpWrite(fd, + buf, + len, + 30, + gopherSendComplete, + (caddr_t) data); return 0; } diff --git a/src/http.cc b/src/http.cc index 2c95740ff0..25ad126cd2 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,22 +1,6 @@ -/* $Id: http.cc,v 1.9 1996/03/26 05:17:21 wessels Exp $ */ - -#include "config.h" -#include -#include -#include -#include - -#include "ansihelp.h" -#include "comm.h" -#include "store.h" -#include "stat.h" -#include "url.h" -#include "ipcache.h" -#include "cache_cf.h" -#include "ttl.h" -#include "icp.h" -#include "util.h" -#include "cached_error.h" +/* $Id: http.cc,v 1.10 1996/03/27 01:46:08 wessels Exp $ */ + +#include "squid.h" #define HTTP_PORT 80 #define HTTP_DELETE_GAP (64*1024) @@ -24,7 +8,6 @@ extern int errno; extern char *dns_error_message; -extern time_t cached_curtime; typedef struct _httpdata { StoreEntry *entry; @@ -42,8 +25,6 @@ typedef struct _httpdata { * icpReadWriteData */ } HttpData; -extern char *tmp_error_buf; - char *HTTP_OPS[] = {"GET", "POST", "HEAD", ""}; @@ -366,7 +347,7 @@ void httpSendRequest(fd, data) xfree(post_buf); } debug(6, "httpSendRequest: FD %d: buf '%s'\n", fd, buf); - data->icp_rwd_ptr = icpWrite(fd, buf, len, 30, httpSendComplete, data); + data->icp_rwd_ptr = icpWrite(fd, buf, len, 30, httpSendComplete, (caddr_t) data); } void httpConnInProgress(fd, data) diff --git a/src/ipcache.cc b/src/ipcache.cc index e1d58951f9..3a1e1440da 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,37 +1,7 @@ -/* $Id: ipcache.cc,v 1.7 1996/03/22 20:58:11 wessels Exp $ */ - -#include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "ansihelp.h" /* goes first */ -#include "debug.h" -#include "comm.h" -#include "fdstat.h" -#include "icp.h" -#include "cache_cf.h" -#include "ipcache.h" -#include "autoconf.h" -#include "stat.h" -#include "hash.h" -#include "disk.h" -#include "util.h" - -struct hostent *gethostbyname(); -int urlcmp _PARAMS((char *s1, char *s2)); +/* $Id: ipcache.cc,v 1.8 1996/03/27 01:46:11 wessels Exp $ */ + +#include "squid.h" + #define MAX_LINELEN (4096) char ipcache_status_char _PARAMS((ipcache_entry *)); @@ -104,7 +74,6 @@ char *dns_error_message = NULL; /* possible error message */ HashID ip_table = 0; extern int do_dns_test; -extern time_t cached_curtime; extern int getMaxFD(); extern int getDnsChildren(); extern void fatal_dump _PARAMS((char *)); diff --git a/src/main.cc b/src/main.cc index 7129ac853b..fa3b364791 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,38 +1,15 @@ -/* $Id: main.cc,v 1.6 1996/03/22 21:13:16 wessels Exp $ */ - -#include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ansihelp.h" -#include "cache_cf.h" -#include "debug.h" -#include "comm.h" -#include "icp.h" -#include "stat.h" -#include "stack.h" -#include "fdstat.h" -#include "ipcache.h" -#include "util.h" +/* $Id: main.cc,v 1.7 1996/03/27 01:46:12 wessels Exp $ */ + +#include "squid.h" + /* WRITE_PID_FILE - tries to write a cached.pid file on startup */ #ifndef WRITE_PID_FILE #define WRITE_PID_FILE #endif -time_t cached_starttime = (time_t) 0; -time_t next_cleaning = (time_t) 0; +time_t cached_starttime = 0; +time_t next_cleaning = 0; int theAsciiConnection = -1; int theBinaryConnection = -1; int theUdpConnection = -1; @@ -40,14 +17,11 @@ int do_reuse = 1; int debug_level = 0; int catch_signals = 1; int do_dns_test = 1; -char *tmp_error_buf = NULL; char *config_file = NULL; int vhost_mode = 0; int unbuffered_logs = 0; /* debug and hierarhcy buffered by default */ -extern time_t cached_curtime; extern void (*failure_notify) (); /* for error reporting from xmalloc */ -extern int do_mallinfo; extern void hash_init _PARAMS((int)); extern int disk_init(); extern void stmemInit(); @@ -130,9 +104,7 @@ int main(argc, argv) mallopt(M_NLBLKS, 100); #endif - /* allocate storage for error messages */ - tmp_error_buf = (char *) xcalloc(1, 8192); -/*init comm module */ + /*init comm module */ comm_init(); #ifdef DAEMON diff --git a/src/mime.cc b/src/mime.cc index 084a1beb54..8641cb4d3d 100644 --- a/src/mime.cc +++ b/src/mime.cc @@ -1,18 +1,9 @@ -/* $Id: mime.cc,v 1.3 1996/03/22 17:48:18 wessels Exp $ */ +/* $Id: mime.cc,v 1.4 1996/03/27 01:46:13 wessels Exp $ */ -#include "config.h" -#include -#include -#include - -#include "ansihelp.h" /* goes first */ -#include "debug.h" -#include "mime.h" +#include "squid.h" #include "mime_table.h" -extern time_t cached_curtime; - int mime_refresh_request(mime) char *mime; { diff --git a/src/neighbors.cc b/src/neighbors.cc index 04eefec711..5ab3b75ce0 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,37 +1,8 @@ -/* $Id: neighbors.cc,v 1.3 1996/02/29 07:23:17 wessels Exp $ */ - -#include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ansihelp.h" -#include "comm.h" -#include "store.h" -#include "icp.h" -#include "proto.h" -#include "neighbors.h" -#include "ipcache.h" -#include "cache_cf.h" -#include "util.h" -#include "disk.h" +/* $Id: neighbors.cc,v 1.4 1996/03/27 01:46:14 wessels Exp $ */ -static neighbors *friends = NULL; +#include "squid.h" -extern time_t cached_curtime; -extern int unbuffered_logs; /* main.c */ -extern char *tmp_error_buf; /* main.c */ -extern int icpUdpSend _PARAMS((int, char *, icp_common_t *, struct sockaddr_in *, icp_opcode)); -extern int getFromOrgSource _PARAMS((int fd, StoreEntry * entry)); -extern int getFromCache _PARAMS((int fd, StoreEntry * entry, edge * e)); -extern int getFromDefaultSource _PARAMS((int fd, StoreEntry * entry)); -extern void fatal_dump _PARAMS((char *)); -extern void fatal _PARAMS((char *)); +static neighbors *friends = NULL; static struct neighbor_cf *Neighbor_cf = NULL; @@ -709,7 +680,7 @@ void neighbors_init() for (t = Neighbor_cf; t; t = next) { next = t->next; - if (strncmp(t->host, comm_hostname(), SQUIDHOSTNAMELEN) || + if (strncmp(t->host, getMyHostname(), SQUIDHOSTNAMELEN) || t->ascii_port != getAsciiPortNum()) { neighbors_install(t->host, t->type, t->ascii_port, t->udp_port, t->proxy_only, diff --git a/src/send-announce.cc b/src/send-announce.cc index 9f40deffd0..fce028b2b0 100644 --- a/src/send-announce.cc +++ b/src/send-announce.cc @@ -1,4 +1,4 @@ -/* $Id: send-announce.cc,v 1.3 1996/02/29 07:23:20 wessels Exp $ */ +/* $Id: send-announce.cc,v 1.4 1996/03/27 01:46:18 wessels Exp $ */ #include "config.h" @@ -14,6 +14,7 @@ #include "util.h" + char *databuf = NULL; int quiet = 0; int debug = 0; diff --git a/src/squid.h b/src/squid.h new file mode 100644 index 0000000000..036c4e573a --- /dev/null +++ b/src/squid.h @@ -0,0 +1,112 @@ + +/* $Id: squid.h,v 1.1 1996/03/27 01:46:18 wessels Exp $ */ + +#include "config.h" +#include "autoconf.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if HAVE_SYS_SELECT_H +#include +#endif + +#if HAVE_BSTRING_H +#include +#endif + +#ifdef HAVE_CRYPT_H +#include +#endif + +#if defined(__STRICT_ANSI__) +#include +#else +#include +#endif + +#if !defined(MAXHOSTNAMELEN) || (MAXHOSTNAMELEN < 128) +#define SQUIDHOSTNAMELEN 128 +#else +#define SQUIDHOSTNAMELEN MAXHOSTNAMELEN +#endif + +typedef struct sentry StoreEntry; +typedef struct mem_hdr *mem_ptr; +typedef struct _edge edge; +typedef struct icp_common_s icp_common_t; +typedef struct _cacheinfo cacheinfo; + +/* 32 bit integer compatability hack */ +#if SIZEOF_LONG == 4 +typedef long num32; +typedef unsigned long u_num32; +#elif SIZEOF_INT == 4 +typedef int num32; +typedef unsigned int u_num32; +#else +typedef long num32; /* assume that long's are 32bit */ +typedef unsigned long u_num32; +#endif +#define NUM32LEN sizeof(num32) /* this should always be 4 */ + +#include "GNUregex.h" +#include "ansihelp.h" +#include "blocklist.h" +#include "cache_cf.h" +#include "cached_error.h" +#include "comm.h" +#include "debug.h" +#include "disk.h" +#include "dynamic_array.h" +#include "fdstat.h" +#include "filemap.h" +#include "hash.h" +#include "proto.h" +#include "icp.h" +#include "icp_lib.h" +#include "ipcache.h" +#include "mime.h" +#include "neighbors.h" +#include "stack.h" +#include "stat.h" +#include "stmem.h" +#include "store.h" +#include "tools.h" +#include "ttl.h" +#include "url.h" +#include "storetoString.h" +#include "util.h" + +extern time_t cached_starttime; /* main.c */ +extern time_t next_cleaning; /* main.c */ +extern int debug_level; /* main.c */ +extern int catch_signals; /* main.c */ diff --git a/src/stat.cc b/src/stat.cc index c7c57fd844..f8bb874793 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,16 +1,6 @@ -/* $Id: stat.cc,v 1.6 1996/02/29 08:08:05 wessels Exp $ */ - -#include "config.h" -#include -#include -#include -#include /* for lseek. should be removed later. */ -#include -#include -#include -#include -#include -#include +/* $Id: stat.cc,v 1.7 1996/03/27 01:46:20 wessels Exp $ */ + +#include "squid.h" #ifdef _SQUID_HPUX_ #include @@ -18,17 +8,6 @@ #define getpagesize( ) sysconf(_SC_PAGE_SIZE) #endif /* _SQUID_HPUX_ */ -#include "comm.h" -#include "store.h" -#include "stat.h" -#include "disk.h" -#include "ipcache.h" -#include "cache_cf.h" -#include "hash.h" -#include "util.h" -#include "neighbors.h" -#include "fdstat.h" - extern int emulate_httpd_log; #define MIN_BUFSIZE (4096) @@ -48,22 +27,6 @@ typedef struct _cached_read_data_t { Meta_data meta_data; unsigned long nconn = 0; -extern int getMaxFD(), fdstat_biggest_fd(); -extern int RESERVED_FD; -extern char *mkrfc850(); -extern time_t cached_curtime; -extern time_t cached_starttime; -extern time_t next_cleaning; -extern int httpd_accel_mode; -extern int debug_level; -extern int hash_links_allocated; -extern void stat_ipcache_get _PARAMS((StoreEntry * e, cacheinfo * obj)); -extern int fdstat_are_n_free_fd _PARAMS((int)); -extern int comm_get_fd_timeout _PARAMS((int)); -extern int file_write_lock _PARAMS((int)); -extern void fatal _PARAMS((char *)); -extern void fatal_dump _PARAMS((char *)); - char *stat_describe(); char *mem_describe(); char *ttl_describe(); diff --git a/src/stmem.cc b/src/stmem.cc index 010be15c60..fe8e09ace4 100644 --- a/src/stmem.cc +++ b/src/stmem.cc @@ -1,12 +1,7 @@ -/* $Id: stmem.cc,v 1.2 1996/02/29 07:23:22 wessels Exp $ */ +/* $Id: stmem.cc,v 1.3 1996/03/27 01:46:22 wessels Exp $ */ -#include "config.h" -#include -#include -#include +#include "squid.h" -#include "stmem.h" -#include "util.h" #define min(x,y) ((x)<(y)? (x) : (y)) @@ -14,13 +9,6 @@ #define USE_MEMALIGN 0 #endif -extern int getCacheMemMax(); -extern int empty_stack _PARAMS((Stack * stack)); -extern int full_stack _PARAMS((Stack * stack)); -extern void push _PARAMS((Stack * stack, generic_ptr data)); -extern void init_stack _PARAMS((Stack * stack, int size)); -extern void fatal_dump _PARAMS((char *)); - void memFree(mem) mem_ptr mem; { @@ -328,8 +316,7 @@ void put_free_4k_page(page) push(&sm_stats.free_page_stack, page); } -char * - get_free_8k_page() +char *get_free_8k_page() { char *page = NULL; diff --git a/src/store.cc b/src/store.cc index 36d53a148e..19dd19184c 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,5 +1,5 @@ -/* $Id: store.cc,v 1.9 1996/03/26 05:19:10 wessels Exp $ */ +/* $Id: store.cc,v 1.10 1996/03/27 01:46:23 wessels Exp $ */ /* * Here is a summary of the routines which change mem_status and swap_status: @@ -26,44 +26,7 @@ * */ -#include "config.h" /* goes first */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ansihelp.h" /* goes secound */ -#include "comm.h" -#include "proto.h" -#include "url.h" -#include "stat.h" -#include "disk.h" -#include "store.h" -#include "cache_cf.h" -#include "hash.h" -#include "debug.h" -#include "dynamic_array.h" -#include "util.h" -#include "filemap.h" -#include "stmem.h" -#include "mime.h" -#include "cached_error.h" - -extern time_t cached_curtime; -extern char *storeToString _PARAMS((StoreEntry * e)); -extern int proto_url_to_id _PARAMS((char *url)); -extern int file_write_lock _PARAMS((int)); -extern void fatal_dump _PARAMS((char *)); -extern void fatal _PARAMS((char *)); -extern void death(); -char *tmp_error_buf; +#include "squid.h" /* goes first */ #define REBUILD_TIMESTAMP_DELTA_MAX 2 #define MAX_SWAP_FILE (1<<21) @@ -80,12 +43,6 @@ char *tmp_error_buf; #define STORE_BUCKETS (7921) #define STORE_IN_MEM_BUCKETS (143) -int urlcmp _PARAMS((char *s1, char *s2)); -int safeunlink _PARAMS((char *, int)); -int swapInError _PARAMS((int fd_unused, StoreEntry * entry)); -int storeSwapInStart _PARAMS((StoreEntry * e)); -int storeCopy _PARAMS((StoreEntry * e, int stateoffset, int maxSize, char *buf, int *size)); - /* Now, this table is inaccessible to outsider. They have to use a method * to access a value in internal storage data structure. */ HashID table = 0; @@ -2453,18 +2410,6 @@ int storeMaintainSwapSpace() return rm_obj; } -int safeunlink(s, quiet) - char *s; - int quiet; -{ - int err; - - if ((err = unlink(s)) < 0) - if (!quiet) - debug(1, "safeunlink: Couldn't delete %s. %s\n", s, xstrerror()); - return (err); -} - /* * storeWriteCleanLog diff --git a/src/tools.cc b/src/tools.cc index 6c225dc13e..336c404c19 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,67 +1,13 @@ -/* $Id: tools.cc,v 1.5 1996/03/25 21:25:18 wessels Exp $ */ - -#include "config.h" -#include -#include -#include -#include -#include /* for sysconf() stuff */ -#include -#include -#include -#include -#include -#include /* has NOFILE */ -#include - -#include "debug.h" -#include "cache_cf.h" -#include "autoconf.h" - -void death(), deathb(), neighbors_rotate_log(), stat_rotate_log(); -void mail_warranty(), print_warranty(), _db_rotate_log(); + +/* $Id: tools.cc,v 1.6 1996/03/27 01:46:26 wessels Exp $ */ + +#include "squid.h" + int do_mallinfo = 0; /* don't do mallinfo() unless this gets set */ -int PrintRusage _PARAMS((void (*)(), FILE *)); - -extern int catch_signals; /* main.c */ -extern int storeWriteCleanLog _PARAMS((void)); - -/*------------------------------------------------------------------------- --- --- death, deathb --- --- Function: These functions catch and report fatal system violations. --- --- Inputs: None. --- --- Output: None. --- --- Comments: None. --- ---------------------------------------------------------------------------*/ -void death() -{ - fprintf(stderr, "FATAL: Received Segment Violation...dying.\n"); - signal(SIGSEGV, SIG_DFL); - signal(SIGBUS, SIG_DFL); - storeWriteCleanLog(); - PrintRusage(NULL, stderr); - print_warranty(); - abort(); -} +static int PrintRusage _PARAMS((void (*)(), FILE *)); -void deathb() -{ - fprintf(stderr, "FATAL: Received bus error...dying.\n"); - signal(SIGSEGV, SIG_DFL); - signal(SIGBUS, SIG_DFL); - signal(SIGBUS, SIG_DFL); - storeWriteCleanLog(); - PrintRusage(NULL, stderr); - print_warranty(); - abort(); -} +extern int gethostname _PARAMS((char *name, int namelen)); #define DEAD_MSG "\ The Harvest Cache (version %s) died.\n\ @@ -109,6 +55,30 @@ void print_warranty() puts(dead_msg()); } +void death() +{ + fprintf(stderr, "FATAL: Received Segment Violation...dying.\n"); + signal(SIGSEGV, SIG_DFL); + signal(SIGBUS, SIG_DFL); + storeWriteCleanLog(); + PrintRusage(NULL, stderr); + print_warranty(); + abort(); +} + + +void deathb() +{ + fprintf(stderr, "FATAL: Received bus error...dying.\n"); + signal(SIGSEGV, SIG_DFL); + signal(SIGBUS, SIG_DFL); + signal(SIGBUS, SIG_DFL); + storeWriteCleanLog(); + PrintRusage(NULL, stderr); + print_warranty(); + abort(); +} + void rotate_logs(sig) int sig; { @@ -299,3 +269,39 @@ int getMaxFD() } return (i); } + +char *getMyHostname() +{ + static char host[SQUIDHOSTNAMELEN + 1]; + static int present = 0; + struct hostent *h = NULL; + + /* Get the host name and store it in host to return */ + if (!present) { + host[0] = '\0'; + if (gethostname(host, SQUIDHOSTNAMELEN) == -1) { + debug(1, "comm_hostname: gethostname failed: %s\n", + xstrerror()); + return NULL; + } else { + if ((h = ipcache_gethostbyname(host)) != NULL) { + /* DNS lookup successful */ + /* use the official name from DNS lookup */ + strcpy(host, h->h_name); + } + present = 1; + } + } + return host; +} + +int safeunlink(s, quiet) + char *s; + int quiet; +{ + int err; + if ((err = unlink(s)) < 0) + if (!quiet) + debug(1, "safeunlink: Couldn't delete %s. %s\n", s, xstrerror()); + return (err); +} diff --git a/src/url.cc b/src/url.cc index a583b02480..9c833c26ce 100644 --- a/src/url.cc +++ b/src/url.cc @@ -1,16 +1,6 @@ -/* $Id: url.cc,v 1.2 1996/02/29 07:23:25 wessels Exp $ */ - -#include "config.h" -#include -#include -#include - -#include "debug.h" -#include "comm.h" -#include "proto.h" -#include "store.h" /* for the_url() */ -#include "url.h" -#include "util.h" +/* $Id: url.cc,v 1.3 1996/03/27 01:46:28 wessels Exp $ */ + +#include "squid.h" int url_acceptable[256]; diff --git a/src/wais.cc b/src/wais.cc index 5bbb8078b2..9f80465ee9 100644 --- a/src/wais.cc +++ b/src/wais.cc @@ -1,21 +1,8 @@ -/* $Id: wais.cc,v 1.8 1996/03/26 05:17:22 wessels Exp $ */ +/* $Id: wais.cc,v 1.9 1996/03/27 01:46:29 wessels Exp $ */ + +#include "squid.h" -#include "config.h" #if USE_WAIS_RELAY -#include -#include -#include - -#include "ansihelp.h" -#include "comm.h" -#include "store.h" -#include "stat.h" -#include "neighbors.h" -#include "url.h" -#include "ipcache.h" -#include "cache_cf.h" -#include "util.h" -#include "cached_error.h" #define WAIS_DELETE_GAP (64*1024) @@ -29,9 +16,7 @@ typedef struct _waisdata { char request[MAX_URL]; } WAISData; -extern char *tmp_error_buf; extern char *dns_error_message; -extern time_t cached_curtime; int wais_url_parser(url, host, port, request) char *url; @@ -290,4 +275,14 @@ int waisStart(unusedfd, url, type, mime_hdr, entry) (PF) waisSendRequest, (caddr_t) data); return COMM_OK; } +#else +int waisStart(unusedfd, url, type, mime_hdr, entry) + int unusedfd; + char *url; + char *type; + char *mime_hdr; + StoreEntry *entry; +{ + return 1; +} #endif