---------------------
PatchSet 4095 
Date: 2002/04/30 17:21:47
Author: serassio
Branch: nt-2_3
Tag: (none) 
Log:
Commit of 11/04/2002 build sources with new socket code

Members: 
	include/autoconf.h:1.1.2.9->1.1.2.10 
	include/snmp_impl.h:1.1.1.1.44.2->1.1.1.1.44.3 
	include/squid-mswin.h:1.1.2.6->1.1.2.7 
	lib/rfc1035.c:1.1.1.1.4.3.2.2->1.1.1.1.4.3.2.3 
	lib/util.c:1.1.1.3.4.2.2.3->1.1.1.3.4.2.2.4 
	lib/win32lib.c:1.1.2.9->1.1.2.10 
	snmplib/snmp_vars.c:1.1.1.2.56.1->1.1.1.2.56.2 
	src/acl.c:1.1.1.3.4.3.2.6->1.1.1.3.4.3.2.7 
	src/cache_manager.c:1.1.1.2.4.1.2.4->1.1.1.2.4.1.2.5 
	src/cf.data.pre:1.1.1.3.4.3.2.4->1.1.1.3.4.3.2.5 
	src/client_side.c:1.1.1.3.4.6.2.8->1.1.1.3.4.6.2.9 
	src/comm.c:1.1.1.3.4.1.2.10->1.1.1.3.4.1.2.11 
	src/comm_select.c:1.1.1.3.4.2.2.4->1.1.1.3.4.2.2.5 
	src/defines.h:1.1.1.3.4.2.2.6->1.1.1.3.4.2.2.7 
	src/delay_pools.c:1.1.1.3.4.2.2.3->1.1.1.3.4.2.2.4 
	src/disk.c:1.1.1.3.4.1.2.7->1.1.1.3.4.1.2.8 
	src/dns_internal.c:1.1.1.1.4.6.2.9->1.1.1.1.4.6.2.10 
	src/errorpage.c:1.1.1.3.4.3.2.3->1.1.1.3.4.3.2.4 
	src/fd.c:1.1.1.3.4.1.2.6->1.1.1.3.4.1.2.7 
	src/forward.c:1.1.1.3.4.1.2.6->1.1.1.3.4.1.2.7 
	src/fqdncache.c:1.1.1.3.4.1.2.2->1.1.1.3.4.1.2.3 
	src/ftp.c:1.1.1.3.4.3.2.9->1.1.1.3.4.3.2.10 
	src/globals.h:1.1.1.3.4.2.2.6->1.1.1.3.4.2.2.7 
	src/gopher.c:1.1.1.3.4.2.2.2->1.1.1.3.4.2.2.3 
	src/helper.c:1.1.1.3.24.1->1.1.1.3.24.2 
	src/http.c:1.1.1.3.4.3.2.4->1.1.1.3.4.3.2.5 
	src/ident.c:1.1.1.3.4.1.2.4->1.1.1.3.4.1.2.5 
	src/ipcache.c:1.1.1.3.4.1.2.2->1.1.1.3.4.1.2.3 
	src/main.c:1.1.1.3.4.2.2.14->1.1.1.3.4.2.2.15 
	src/pconn.c:1.1.1.2.4.1.2.1->1.1.1.2.4.1.2.2 
	src/protos.h:1.1.1.3.4.1.2.12->1.1.1.3.4.1.2.13 
	src/pump.c:1.1.1.3.4.1.2.1->1.1.1.3.4.1.2.2 
	src/refresh.c:1.1.1.3.4.1.2.3->1.1.1.3.4.1.2.4 
	src/ssl.c:1.1.1.3.4.1.2.4->1.1.1.3.4.1.2.5 
	src/stat.c:1.1.1.3.4.1.2.7->1.1.1.3.4.1.2.8 
	src/structs.h:1.1.1.3.4.2.2.7->1.1.1.3.4.2.2.8 
	src/tools.c:1.1.1.3.4.1.2.16->1.1.1.3.4.1.2.17 
	src/typedefs.h:1.1.1.3.4.1.2.3->1.1.1.3.4.1.2.4 
	src/wais.c:1.1.1.2.4.1.2.1->1.1.1.2.4.1.2.2 
	src/win32.c:1.1.2.15->1.1.2.16 
	win/cf_gen/cf_gen.dsp:1.1.2.3->1.1.2.4 
	win/squidnt/squidnt.dsp:1.1.2.9->1.1.2.10 

Index: squid/include/autoconf.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/include/Attic/autoconf.h,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- squid/include/autoconf.h	1 Nov 2001 17:31:07 -0000	1.1.2.9
+++ squid/include/autoconf.h	30 Apr 2002 17:21:47 -0000	1.1.2.10
@@ -26,7 +26,7 @@
 
 /* Define to `int' if <sys/types.h> doesn't define.  */
 #undef pid_t
-#define pid_t int
+#define pid_t long
 
 /* Define to `unsigned' if <sys/types.h> doesn't define.  */
 #undef size_t
@@ -93,7 +93,7 @@
  * Traffic management via "delay pools".
  */
 #undef DELAY_POOLS
-#define DELAY_POOLS 1
+// #define DELAY_POOLS 1
 
 /*
  * If you want to log User-Agent request header values, define this.
@@ -165,31 +165,31 @@
 
 /* Default FD_SETSIZE value */
 #undef DEFAULT_FD_SETSIZE
-#define DEFAULT_FD_SETSIZE 64
+#define DEFAULT_FD_SETSIZE 256
 
 /* Maximum number of open filedescriptors */
 #undef SQUID_MAXFD
-#define SQUID_MAXFD 8192
+#define SQUID_MAXFD 2048
 
 /* UDP send buffer size */
 #undef SQUID_UDP_SO_SNDBUF
-#define SQUID_UDP_SO_SNDBUF 512
+#define SQUID_UDP_SO_SNDBUF 16384
 
 /* UDP receive buffer size */
 #undef SQUID_UDP_SO_RCVBUF
-#define SQUID_UDP_SO_RCVBUF 512
+#define SQUID_UDP_SO_RCVBUF 16384
 
 /* TCP send buffer size */
 #undef SQUID_TCP_SO_SNDBUF
-#define SQUID_TCP_SO_SNDBUF 512
+#define SQUID_TCP_SO_SNDBUF 16384
 
 /* TCP receive buffer size */
 #undef SQUID_TCP_SO_RCVBUF
-#define SQUID_TCP_SO_RCVBUF 512
+#define SQUID_TCP_SO_RCVBUF 16384
 
 /* Host type from configure */
 #undef CONFIG_HOST_TYPE
-#define CONFIG_HOST_TYPE "WIN32"
+#define CONFIG_HOST_TYPE "i386-pc-winnt"
 
 /* If we need to declare sys_errlist[] as external */
 #undef NEED_SYS_ERRLIST
@@ -233,7 +233,7 @@
  * should be defined to int.
  */
 #undef socklen_t
-#define socklen_t long  
+#define socklen_t int  
 /*
  * By default (for now anyway) Squid includes options which allows
  * the cache administrator to violate the HTTP protocol specification
@@ -258,7 +258,7 @@
  * type of fd_set array
  */
 #undef fd_mask
-#define fd_mask long 
+#define fd_mask int 
 /*
  * If _res structure has nsaddr_list member
  */
@@ -284,7 +284,8 @@
  * the dnsserver processes instead.
  */
 #undef USE_DNSSERVERS
-// #define USE_DNSSERVERS 1
+#define USE_DNSSERVERS 1
+
 /*
  * we check for the existance of struct mallinfo
  */
Index: squid/include/snmp_impl.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/include/snmp_impl.h,v
retrieving revision 1.1.1.1.44.2
retrieving revision 1.1.1.1.44.3
diff -u -r1.1.1.1.44.2 -r1.1.1.1.44.3
--- squid/include/snmp_impl.h	16 Feb 2002 18:20:32 -0000	1.1.1.1.44.2
+++ squid/include/snmp_impl.h	30 Apr 2002 17:21:47 -0000	1.1.1.1.44.3
@@ -1,5 +1,5 @@
 /*
- * $Id: snmp_impl.h,v 1.1.1.1.44.2 2002/02/16 18:20:32 serassio Exp $
+ * $Id: snmp_impl.h,v 1.1.1.1.44.3 2002/04/30 17:21:47 serassio Exp $
  */
 
 #ifndef _SNMP_IMPL_H_
@@ -44,15 +44,6 @@
 #endif
 #endif
 
-/*
- * Error codes:
- */
-/*
- * These must not clash with SNMP error codes (all positive).
- */
-#define PARSE_ERROR	-1
-#define BUILD_ERROR	-2
-
 #define SID_MAX_LEN	64
 
 #ifndef NULL
Index: squid/include/squid-mswin.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/include/Attic/squid-mswin.h,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- squid/include/squid-mswin.h	10 Feb 2002 17:55:55 -0000	1.1.2.6
+++ squid/include/squid-mswin.h	30 Apr 2002 17:21:47 -0000	1.1.2.7
@@ -1,5 +1,5 @@
 /*
- * $Id: squid-mswin.h,v 1.1.2.6 2002/02/10 17:55:55 serassio Exp $
+ * $Id: squid-mswin.h,v 1.1.2.7 2002/04/30 17:21:47 serassio Exp $
  *
  * AUTHOR: Guido Serassio & Andrey Shorin
  *
@@ -35,11 +35,12 @@
 
 #define __STDC__ 1
 
+#undef HAVE_SYS_TIME_H
+
 #pragma include_alias(<dirent.h>, <direct.h>)
 
 #define alloca _alloca
 #define chdir _chdir
-#define close _close
 #define dup _dup
 #define dup2 _dup2
 #define fdopen _fdopen
@@ -69,10 +70,6 @@
 #define unlink _unlink
 #define vsnprintf _vsnprintf
 
-// temp
-#define read       _read
-#define write      _write
-
 #define O_RDONLY _O_RDONLY
 #define O_BINARY _O_BINARY
 #define O_WRONLY _O_WRONLY
@@ -124,9 +121,14 @@
 
 #include <stddef.h>
 #include <process.h>
+/* Hack to suppress compiler warnings on FD_SET() & FD_CLR() */
+#pragma warning (push)
+#pragma warning (disable:4142)
+typedef int SOCKET;
 /* prevent inclusion of wingdi.h */
 #define NOGDI
 #include <ws2spi.h>
+#pragma warning (pop)
 #include "readdir.h"
 
 typedef char *caddr_t;
@@ -143,45 +145,185 @@
 #define ECONNRESET WSAECONNRESET
 #define ERESTART WSATRY_AGAIN
 
-#if defined (COMM_C) || defined (COMM_SELECT_C)
-#define recv(x,y,z) recv(x,y,z,0)
-#define send(x,y,z) send(x,y,z,0)
-#define fd_bytes(x,y,z) sd_bytes(x,y,z)
-#define fd_note(x,y) sd_note(x,y)
-#define fd_open(x,y,z) sd_open(x,y,z)
-#define fd_close(x) sd_close(x)
-#define ignoreErrno(x) WSAignoreErrno(x)
-#endif
-
-#if defined (ICP_V2_C)
-#define fd_note(x,y) sd_note(x,y)
-#define ignoreErrno(x) WSAignoreErrno(x)
-#define commSetSelect(x,y,z,u,v) commSetSelectS(x,y,z,u,v)
-#endif
-
-#if defined (SNMP_CORE_C)
-#define fd_note(x,y) sd_note(x,y)
-#define commSetSelect(x,y,z,u,v) commSetSelectS(x,y,z,u,v)
+/* internal to CRTLIB */
+#define FPIPE           0x08    /* file handle refers to a pipe */
+typedef struct {
+        long osfhnd;    /* underlying OS file HANDLE */
+        char osfile;    /* attributes of file (e.g., open in text mode?) */
+        char pipech;    /* one char buffer for handles opened on pipes */
+#ifdef _MT
+        int lockinitflag;
+        CRITICAL_SECTION lock;
+#endif  /* _MT */
+    }   ioinfo;
+extern _CRTIMP ioinfo * __pioinfo[];
+#define IOINFO_L2E          5
+#define IOINFO_ARRAY_ELTS   (1 << IOINFO_L2E)
+#define _pioinfo(i) ( __pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)) )
+#define _osfile(i)  ( _pioinfo(i)->osfile )
+int __cdecl _free_osfhnd(int);
+
+#undef h_errno
+#define h_errno errno /* we'll set it ourselves */
+
+#undef FD_CLR
+#define FD_CLR(fd, set) do { \
+    u_int __i; \
+    SOCKET __sock = _get_osfhandle(fd); \
+    for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count ; __i++) { \
+        if (((fd_set FAR *)(set))->fd_array[__i] == __sock) { \
+            while (__i < ((fd_set FAR *)(set))->fd_count-1) { \
+                ((fd_set FAR *)(set))->fd_array[__i] = \
+                    ((fd_set FAR *)(set))->fd_array[__i+1]; \
+                __i++; \
+            } \
+            ((fd_set FAR *)(set))->fd_count--; \
+            break; \
+        } \
+    } \
+} while(0)
+
+#undef FD_SET
+#define FD_SET(fd, set) do { \
+    u_int __i; \
+    SOCKET __sock = _get_osfhandle(fd); \
+    for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count; __i++) { \
+        if (((fd_set FAR *)(set))->fd_array[__i] == (__sock)) { \
+            break; \
+        } \
+    } \
+    if (__i == ((fd_set FAR *)(set))->fd_count) { \
+        if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) { \
+            ((fd_set FAR *)(set))->fd_array[__i] = (__sock); \
+            ((fd_set FAR *)(set))->fd_count++; \
+        } \
+    } \
+} while(0)
+
+#undef FD_ISSET
+#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(_get_osfhandle(fd)), (fd_set FAR *)(set))
+
+extern __declspec(thread) int ws32_result;
+
+#if !defined(_etext) /* util.c actually */
+#define strerror(e) xbstrerror(e)
+#else
+#define NOT_NEEDED 1
 #endif
 
-#if defined(WHOIS_C) || defined(WAIS_C) 
-#define send(x,y,z) send(x,y,z,0)
-#define recv(x,y,z) recv(x,y,z,0)
-#define fd_bytes(x,y,z) sd_bytes(x,y,z)
-#define ignoreErrno(x) WSAignoreErrno(x)
-#define commSetSelect(x,y,z,u,v) commSetSelectS(x,y,z,u,v)
+/* internal to CRTLIB */
+/* used also in win32lib.c */
+extern void __cdecl _dosmaperr(unsigned long oserrno);
+
+#define socket(f,t,p) \
+	(INVALID_SOCKET == ((SOCKET)ws32_result = socket(f,t,p)) ? \
+	((WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1), -1) : \
+	(SOCKET)_open_osfhandle(ws32_result,0))
+#define accept(s,a,l) \
+	(INVALID_SOCKET == ((SOCKET)ws32_result = accept(_get_osfhandle(s),a,l)) ? \
+	((WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1), -1) : \
+	(SOCKET)_open_osfhandle(ws32_result,0))
+#define bind(s,n,l) \
+	(SOCKET_ERROR == bind(_get_osfhandle(s),n,l) ? \
+	(errno = WSAGetLastError()), -1 : 0)
+#define connect(s,n,l) \
+	(SOCKET_ERROR == connect(_get_osfhandle(s),n,l) ? \
+	(WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1, -1) : 0)
+#define listen(s,b) \
+	(SOCKET_ERROR == listen(_get_osfhandle(s),b) ? \
+	(WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1, -1) : 0)
+#define shutdown(s,h) \
+	(SOCKET_ERROR == shutdown(_get_osfhandle(s),h) ? \
+	(errno = WSAGetLastError()), -1 : 0)
+#define closesocket(s) \
+	{ \
+	(SOCKET_ERROR == closesocket(_get_osfhandle(s)) ? \
+	(errno = WSAGetLastError()), -1 : 0); \
+	_free_osfhnd(s); \
+	_osfile(s) = 0; \
+	} 
+#define select(n,r,w,e,t) \
+	(SOCKET_ERROR == (ws32_result = select(n,r,w,e,t)) ? \
+	(errno = WSAGetLastError()), -1 : ws32_result)
+#define recv(s,b,l,f) \
+	(SOCKET_ERROR == (ws32_result = recv(_get_osfhandle(s),b,l,f)) ? \
+	(errno = WSAGetLastError()), -1 : ws32_result)
+#define recvfrom(s,b,l,f,fr,frl) \
+	(SOCKET_ERROR == (ws32_result = recvfrom(_get_osfhandle(s),b,l,f,fr,frl)) ? \
+	(errno = WSAGetLastError()), -1 : ws32_result)
+#define send(s,b,l,f) \
+	(SOCKET_ERROR == (ws32_result = send(_get_osfhandle(s),b,l,f)) ? \
+	(errno = WSAGetLastError()), -1 : ws32_result)
+#define sendto(s,b,l,f,t,tl) \
+	(SOCKET_ERROR == (ws32_result = sendto(_get_osfhandle(s),b,l,f,t,tl)) ? \
+	(errno = WSAGetLastError()), -1 : ws32_result)
+#define getsockname(s,n,l) \
+	(SOCKET_ERROR == getsockname(_get_osfhandle(s),n,l) ? \
+	(errno = WSAGetLastError()), -1 : 0)
+#define getsockopt(s,l,o,v,n) \
+	(Sleep(1), SOCKET_ERROR == getsockopt(_get_osfhandle(s),l,o,(char*)v,n) ? \
+	(errno = WSAGetLastError()), -1 : 0)
+#define setsockopt(s,l,o,v,n) \
+	(SOCKET_ERROR == setsockopt(_get_osfhandle(s),l,o,v,n) ? \
+	(errno = WSAGetLastError()), -1 : 0)
+#define ioctlsocket(s,c,a) \
+	(SOCKET_ERROR == ioctlsocket(_get_osfhandle(s),c,a) ? \
+	(errno = WSAGetLastError()), -1 : 0)
+#define gethostname(n,l) \
+	(SOCKET_ERROR == gethostname(n,l) ? \
+	(errno = WSAGetLastError()), -1 : 0)
+#define gethostbyname(n) \
+	(NULL == ((HOSTENT FAR*)ws32_result = gethostbyname(n)) ? \
+	(errno = WSAGetLastError()), NULL : (HOSTENT FAR*)ws32_result)
+#define getservbyname(n,p) \
+	(NULL == ((SERVENT FAR*)ws32_result = getservbyname(n,p)) ? \
+	(errno = WSAGetLastError()), NULL : (SERVENT FAR*)ws32_result)
+#define gethostbyaddr(a,l,t) \
+	(NULL == ((HOSTENT FAR*)ws32_result = gethostbyaddr(a,l,t)) ? \
+	(errno = WSAGetLastError()), NULL : (HOSTENT FAR*)ws32_result)
+#undef WSASocket
+#ifdef UNICODE
+#define WSASocket(a,t,p,i,g,f) \
+	(INVALID_SOCKET == ((SOCKET)ws32_result = WSASocketW(a,t,p,i,g,f)) ? \
+	((WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1), -1) : \
+	(SOCKET)_open_osfhandle(ws32_result,0))
+#else
+#define WSASocket(a,t,p,i,g,f) \
+	(INVALID_SOCKET == ((SOCKET)ws32_result = WSASocketA(a,t,p,i,g,f)) ? \
+	((WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1), -1) : \
+	(SOCKET)_open_osfhandle(ws32_result,0))
+#endif /* !UNICODE */
+#undef WSADuplicateSocket
+#ifdef UNICODE
+#define WSADuplicateSocket(s,n,l) \
+	(SOCKET_ERROR == WSADuplicateSocketW(_get_osfhandle(s),n,l) ? \
+	(errno = WSAGetLastError()), -1 : 0)
+#else
+#define WSADuplicateSocket(s,n,l) \
+	(SOCKET_ERROR == WSADuplicateSocketA(_get_osfhandle(s),n,l) ? \
+	(errno = WSAGetLastError()), -1 : 0)
+#endif /* !UNICODE */
+
+#if defined(STORE_IO_C) || defined(STORE_DIR_C) || defined(TOOLS_C)
+#define read  _read
+#define write _write
+#else
+extern __declspec(thread) int _so_err;
+extern __declspec(thread) int _so_err_siz;
+#define read(fd,buf,siz) \
+	(_so_err_siz = sizeof(_so_err), \
+	getsockopt((fd),SOL_SOCKET,SO_ERROR,&_so_err,&_so_err_siz) \
+	== 0 ? recv((fd),(buf),(siz),0) : _read((fd),(buf),(siz)))
+#define write(fd,buf,siz) \
+	(_so_err_siz = sizeof(_so_err), \
+	getsockopt((fd),SOL_SOCKET,SO_ERROR,&_so_err,&_so_err_siz) \
+	== 0 ? send((fd),(buf),(siz),0) : _write((fd),(buf),(siz)))
 #endif
 
-#if defined (SSL_C) || defined (PCONN_C) || defined (PUMP_C) ||  \
-	defined (HTTP_C) || defined (HTCP_C) || defined (HELPER_C) || defined (CLIENT_SIDE_C) \
-	|| defined (FTP_C) || defined (GOPHER_C) || defined(IDENT_C) || \
-	defined (ICMP_C) || defined (FORWARD_C) || defined (DNS_INTERNAL_C)
-#define recv(x,y,z) recv(x,y,z,0)
-#define send(x,y,z) send(x,y,z,0)
-#define fd_bytes(x,y,z) sd_bytes(x,y,z)
-#define fd_note(x,y) sd_note(x,y)
-#define ignoreErrno(x) WSAignoreErrno(x)
-#define commSetSelect(x,y,z,u,v) commSetSelectS(x,y,z,u,v)
+#if defined(COMM_C) || defined(TOOLS_C)
+#define close closesocket
+#else
+#define close _close
 #endif
 
 #define	RUSAGE_SELF	0		/* calling process */
Index: squid/lib/rfc1035.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/lib/rfc1035.c,v
retrieving revision 1.1.1.1.4.3.2.2
retrieving revision 1.1.1.1.4.3.2.3
diff -u -r1.1.1.1.4.3.2.2 -r1.1.1.1.4.3.2.3
--- squid/lib/rfc1035.c	6 Jan 2002 13:53:29 -0000	1.1.1.1.4.3.2.2
+++ squid/lib/rfc1035.c	30 Apr 2002 17:21:47 -0000	1.1.1.1.4.3.2.3
@@ -1,32 +1,32 @@
 
 /*
- * $Id: rfc1035.c,v 1.1.1.1.4.3.2.2 2002/01/06 13:53:29 serassio Exp $
+ * $Id: rfc1035.c,v 1.1.1.1.4.3.2.3 2002/04/30 17:21:47 serassio Exp $
  *
  * Low level DNS protocol routines
  * AUTHOR: Duane Wessels
  *
- * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
+ * SQUID Web Proxy Cache          http://www.squid-cache.org/
  * ----------------------------------------------------------
  *
- *  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
- *  the Regents of the University of California.  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.
+ *  Squid is the result of efforts by numerous individuals from
+ *  the Internet community; see the CONTRIBUTORS file for full
+ *  details.   Many organizations have provided support for Squid's
+ *  development; see the SPONSORS file for full details.  Squid is
+ *  Copyrighted (C) 2001 by the Regents of the University of
+ *  California; see the COPYRIGHT file for full details.  Squid
+ *  incorporates software developed and/or copyrighted by other
+ *  sources; 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.
@@ -73,6 +73,14 @@
 #include "snprintf.h"
 
 #define RFC1035_MAXLABELSZ 63
+#define rfc1035_unpack_error 15
+
+#if 0
+#define RFC1035_UNPACK_DEBUG  fprintf(stderr, "unpack error at %s:%d\n", __FILE__,__LINE__)
+#else
+#define RFC1035_UNPACK_DEBUG  (void)0
+#endif
+
 
 typedef struct _rfc1035_header rfc1035_header;
 
@@ -93,6 +101,12 @@
     unsigned short arcount;
 };
 
+static const char *Alphanum =
+"abcdefghijklmnopqrstuvwxyz"
+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+"0123456789";
+
+
 /*
  * rfc1035HeaderPack()
  * 
@@ -169,12 +183,15 @@
  * Note message compression is not supported here.
  * Returns number of octets packed.
  */
-off_t
+static off_t
 rfc1035NamePack(char *buf, size_t sz, const char *name)
 {
     off_t off = 0;
     char *copy = strdup(name);
     char *t;
+    /*
+     * NOTE: use of strtok here makes names like foo....com valid.
+     */
     for (t = strtok(copy, "."); t; t = strtok(NULL, "."))
 	off += rfc1035LabelPack(buf + off, sz - off, t);
     free(copy);
@@ -214,21 +231,29 @@
  * 
  * Unpacks a RFC1035 message header buffer into a rfc1035_header
  * structure.
- * Returns the new buffer offset, which is the same as number of
+ *
+ * Updates the buffer offset, which is the same as number of
  * octects unpacked since the header starts at offset 0.
+ *
+ * Returns 0 (success) or 1 (error)
  */
-static off_t
-rfc1035HeaderUnpack(const char *buf, size_t sz, rfc1035_header * h)
+static int
+rfc1035HeaderUnpack(const char *buf, size_t sz, off_t * off, rfc1035_header * h)
 {
     unsigned short s;
     unsigned short t;
-    off_t off = 0;
-    assert(sz >= 12);
-    memcpy(&s, buf + off, sizeof(s));
-    off += sizeof(s);
+    assert(*off == 0);
+    /*
+     * The header is 12 octets.  This is a bogus message if the size
+     * is less than that.
+     */
+    if (sz < 12)
+	return 1;
+    memcpy(&s, buf + (*off), sizeof(s));
+    (*off) += sizeof(s);
     h->id = ntohs(s);
-    memcpy(&s, buf + off, sizeof(s));
-    off += sizeof(s);
+    memcpy(&s, buf + (*off), sizeof(s));
+    (*off) += sizeof(s);
     t = ntohs(s);
     h->qr = (t >> 15) & 0x01;
     h->opcode = (t >> 11) & 0x0F;
@@ -236,21 +261,26 @@
     h->tc = (t >> 9) & 0x01;
     h->rd = (t >> 8) & 0x01;
     h->ra = (t >> 7) & 0x01;
+    /*
+     * We might want to check that the reserved 'Z' bits (6-4) are
+     * all zero as per RFC 1035.  If not the message should be
+     * rejected.
+     */
     h->rcode = t & 0x0F;
-    memcpy(&s, buf + off, sizeof(s));
-    off += sizeof(s);
+    memcpy(&s, buf + (*off), sizeof(s));
+    (*off) += sizeof(s);
     h->qdcount = ntohs(s);
-    memcpy(&s, buf + off, sizeof(s));
-    off += sizeof(s);
+    memcpy(&s, buf + (*off), sizeof(s));
+    (*off) += sizeof(s);
     h->ancount = ntohs(s);
-    memcpy(&s, buf + off, sizeof(s));
-    off += sizeof(s);
+    memcpy(&s, buf + (*off), sizeof(s));
+    (*off) += sizeof(s);
     h->nscount = ntohs(s);
-    memcpy(&s, buf + off, sizeof(s));
-    off += sizeof(s);
+    memcpy(&s, buf + (*off), sizeof(s));
+    (*off) += sizeof(s);
     h->arcount = ntohs(s);
-    assert(off == 12);
-    return off;
+    assert((*off) == 12);
+    return 0;
 }
 
 /*
@@ -264,43 +294,61 @@
  *
  * Supports the RFC1035 message compression through recursion.
  *
- * Returns the new buffer offset.
+ * Updates the new buffer offset.
+ *
+ * Returns 0 (success) or 1 (error)
  */
-static off_t
-rfc1035NameUnpack(const char *buf, size_t sz, off_t off, char *name, size_t ns)
+static int
+rfc1035NameUnpack(const char *buf, size_t sz, off_t * off, char *name, size_t ns, int rdepth)
 {
     off_t no = 0;
     unsigned char c;
     size_t len;
     assert(ns > 0);
     do {
-	c = *(buf + off);
-	if (c > RFC1035_MAXLABELSZ) {
-	    /* fucking compression */
+	assert((*off) < sz);
+	c = *(buf + (*off));
+	if (c > 191) {
+	    /* blasted compression */
 	    unsigned short s;
 	    off_t ptr;
-	    memcpy(&s, buf + off, sizeof(s));
+	    if (rdepth > 64)		/* infinite pointer loop */
+		return 1;
+	    memcpy(&s, buf + (*off), sizeof(s));
 	    s = ntohs(s);
-	    off += sizeof(s);
+	    (*off) += sizeof(s);
+	    /* Sanity check */
+	    if ((*off) >= sz)
+		return 1;
 	    ptr = s & 0x3FFF;
-	    (void) rfc1035NameUnpack(buf, sz, ptr, name + no, ns - no);
-	    return off;
+	    /* Make sure the pointer is inside this message */
+	    if (ptr >= sz)
+		return 1;
+	    return rfc1035NameUnpack(buf, sz, &ptr, name + no, ns - no, rdepth + 1);
+	} else if (c > RFC1035_MAXLABELSZ) {
+	    /*
+	     * "(The 10 and 01 combinations are reserved for future use.)"
+	     */
+	    return 1;
 	} else {
-	    off++;
+	    (*off)++;
 	    len = (size_t) c;
 	    if (len == 0)
 		break;
-	    if (len > (ns - 1))
-		len = ns - 1;
-	    memcpy(name + no, buf + off, len);
-	    off += len;
+	    if (len > (ns - no - 1))	/* label won't fit */
+		return 1;
+	    if ((*off) + len > sz)	/* message is too short */
+		return 1;
+	    memcpy(name + no, buf + (*off), len);
+	    (*off) += len;
 	    no += len;
 	    *(name + (no++)) = '.';
 	}
-    } while (c > 0);
+    } while (c > 0 && no < ns);
     *(name + no - 1) = '\0';
+    /* make sure we didn't allow someone to overflow the name buffer */
     assert(no <= ns);
-    return off;
+    return 0;
 }
 
 /*
@@ -308,49 +356,78 @@
  * 
  * Unpacks a RFC1035 Resource Record into 'RR' from a message buffer.
  * The caller must free RR->rdata!
- * Returns the new message buffer offset.
+ *
+ * Updates the new message buffer offset.
+ *
+ * Returns 0 (success) or 1 (error)
  */
-static off_t
-rfc1035RRUnpack(const char *buf, size_t sz, off_t off, rfc1035_rr * RR)
+static int
+rfc1035RRUnpack(const char *buf, size_t sz, off_t * off, rfc1035_rr * RR)
 {
     unsigned short s;
     unsigned int i;
-    off = rfc1035NameUnpack(buf, sz, off, RR->name, RFC1035_MAXHOSTNAMESZ);
-    memcpy(&s, buf + off, sizeof(s));
-    off += sizeof(s);
+    off_t rdata_off;
+    if (rfc1035NameUnpack(buf, sz, off, RR->name, RFC1035_MAXHOSTNAMESZ, 0)) {
+	RFC1035_UNPACK_DEBUG;
+	memset(RR, '\0', sizeof(*RR));
+	return 1;
+    }
+    /*
+     * Make sure the remaining message has enough octets for the
+     * rest of the RR fields.
+     */
+    if ((*off) + 10 > sz) {
+	RFC1035_UNPACK_DEBUG;
+	memset(RR, '\0', sizeof(*RR));
+	return 1;
+    }
+    memcpy(&s, buf + (*off), sizeof(s));
+    (*off) += sizeof(s);
     RR->type = ntohs(s);
-    memcpy(&s, buf + off, sizeof(s));
-    off += sizeof(s);
+    memcpy(&s, buf + (*off), sizeof(s));
+    (*off) += sizeof(s);
     RR->class = ntohs(s);
-    memcpy(&i, buf + off, sizeof(i));
-    off += sizeof(i);
+    memcpy(&i, buf + (*off), sizeof(i));
+    (*off) += sizeof(i);
     RR->ttl = ntohl(i);
-    memcpy(&s, buf + off, sizeof(s));
-    off += sizeof(s);
-    if (off + ntohs(s) > sz) {
+    memcpy(&s, buf + (*off), sizeof(s));
+    (*off) += sizeof(s);
+    if ((*off) + ntohs(s) > sz) {
 	/*
 	 * We got a truncated packet.  'dnscache' truncates UDP
-	 * replies at 512 octets, as per RFC 1035.  Returning sz+1
-	 * should cause no further processing for this reply.
+	 * replies at 512 octets, as per RFC 1035.
 	 */
-	return sz + 1;
+	RFC1035_UNPACK_DEBUG;
+	memset(RR, '\0', sizeof(*RR));
+	return 1;
     }
+    RR->rdlength = ntohs(s);
     switch (RR->type) {
     case RFC1035_TYPE_PTR:
 	RR->rdata = malloc(RFC1035_MAXHOSTNAMESZ);
-	rfc1035NameUnpack(buf, sz, off, RR->rdata, RFC1035_MAXHOSTNAMESZ);
-	RR->rdlength = strlen(RR->rdata);
+	rdata_off = *off;
+	if (rfc1035NameUnpack(buf, sz, &rdata_off, RR->rdata, RFC1035_MAXHOSTNAMESZ, 0))
+	    return 1;
+	if (rdata_off != ((*off) + RR->rdlength)) {
+	    /*
+	     * This probably doesn't happen for valid packets, but
+	     * I want to make sure that NameUnpack doesn't go beyond
+	     * the RDATA area.
+	     */
+	    RFC1035_UNPACK_DEBUG;
+	    memset(RR, '\0', sizeof(*RR));
+	    return 1;
+	}
 	break;
     case RFC1035_TYPE_A:
     default:
-	RR->rdlength = ntohs(s);
 	RR->rdata = malloc(RR->rdlength);
-	memcpy(RR->rdata, buf + off, RR->rdlength);
+	memcpy(RR->rdata, buf + (*off), RR->rdlength);
 	break;
     }
-    off += ntohs(s);
-    assert(off <= sz);
-    return off;
+    (*off) += RR->rdlength;
+    assert((*off) <= sz);
+    return 0;
 }
 
 static unsigned short
@@ -362,6 +439,43 @@
     return qid;
 }
 
+static void
+rfc1035SetErrno(int n)
+{
+    switch (rfc1035_errno = n) {
+    case 0:
+	rfc1035_error_message = "No error condition";
+	break;
+    case 1:
+	rfc1035_error_message = "Format Error: The name server was "
+	    "unable to interpret the query.";
+	break;
+    case 2:
+	rfc1035_error_message = "Server Failure: The name server was "
+	    "unable to process this query.";
+	break;
+    case 3:
+	rfc1035_error_message = "Name Error: The domain name does "
+	    "not exist.";
+	break;
+    case 4:
+	rfc1035_error_message = "Not Implemented: The name server does "
+	    "not support the requested kind of query.";
+	break;
+    case 5:
+	rfc1035_error_message = "Refused: The name server refuses to "
+	    "perform the specified operation.";
+	break;
+    case rfc1035_unpack_error:
+	rfc1035_error_message = "The DNS reply message is corrupt or could "
+	    "not be safely parsed.";
+	break;
+    default:
+	rfc1035_error_message = "Unknown Error";
+	break;
+    }
+}
+
 void
 rfc1035RRDestroy(rfc1035_rr * rr, int n)
 {
@@ -375,6 +489,17 @@
     free(rr);
 }
 
+/*
+ * rfc1035AnswersUnpack()
+ *
+ * Takes the contents of a DNS reply and fills in an array
+ * of resource record structures.  The records array is allocated
+ * here, and should be freed by calling rfc1035RRDestroy().
+ *
+ * Returns number of records unpacked, zero if DNS reply indicates
+ * zero answers, or an error number < 0.
+ */
+
 int
 rfc1035AnswersUnpack(const char *buf,
     size_t sz,
@@ -388,40 +513,17 @@
     rfc1035_header hdr;
     rfc1035_rr *recs;
     memset(&hdr, '\0', sizeof(hdr));
-    off = rfc1035HeaderUnpack(buf + off, sz - off, &hdr);
+    if (rfc1035HeaderUnpack(buf + off, sz - off, &off, &hdr)) {
+	RFC1035_UNPACK_DEBUG;
+	rfc1035SetErrno(rfc1035_unpack_error);
+	return -rfc1035_unpack_error;
+    }
     *id = hdr.id;
     rfc1035_errno = 0;
     rfc1035_error_message = NULL;
     if (hdr.rcode) {
-	rfc1035_errno = (int) hdr.rcode;
-	switch (rfc1035_errno) {
-	case 0:
-	    rfc1035_error_message = "No error condition";
-	    break;
-	case 1:
-	    rfc1035_error_message = "Format Error: The name server was "
-		"unable to interpret the query.";
-	    break;
-	case 2:
-	    rfc1035_error_message = "Server Failure: The name server was "
-		"unable to process this query.";
-	    break;
-	case 3:
-	    rfc1035_error_message = "Name Error: The domain name does "
-		"not exist.";
-	    break;
-	case 4:
-	    rfc1035_error_message = "Not Implemented: The name server does "
-		"not support the requested kind of query.";
-	    break;
-	case 5:
-	    rfc1035_error_message = "Refused: The name server refuses to "
-		"perform the specified operation.";
-	    break;
-	default:
-	    rfc1035_error_message = "Unknown Error";
-	    break;
-	}
+	RFC1035_UNPACK_DEBUG;
+	rfc1035SetErrno((int) hdr.rcode);
 	return -rfc1035_errno;
     }
     i = (int) hdr.qdcount;
@@ -430,30 +532,50 @@
 	do {
 	    l = (int) (unsigned char) *(buf + off);
 	    off++;
-	    if (l > RFC1035_MAXLABELSZ) {	/* compression */
+	    if (l > 191) {	/* compression */
 		off++;
 		break;
+	    } else if (l > RFC1035_MAXLABELSZ) {
+		/* illegal combination of compression bits */
+		RFC1035_UNPACK_DEBUG;
+		rfc1035SetErrno(rfc1035_unpack_error);
+		return -rfc1035_unpack_error;
 	    } else {
 		off += l;
 	    }
 	} while (l > 0);	/* a zero-length label terminates */
 	off += 4;		/* qtype, qclass */
-	assert(off <= sz);
+	if (off > sz) {
+	    RFC1035_UNPACK_DEBUG;
+	    rfc1035SetErrno(rfc1035_unpack_error);
+	    return -rfc1035_unpack_error;
+	}
     }
     i = (int) hdr.ancount;
     if (i == 0)
 	return 0;
     recs = calloc(i, sizeof(*recs));
     while (i--) {
-	off = rfc1035RRUnpack(buf, sz, off, &recs[i]);
-	if (off > sz)		/* truncated packet */
+	if (off >= sz) {	/* corrupt packet */
+	    RFC1035_UNPACK_DEBUG;
 	    break;
+	}
+	if (rfc1035RRUnpack(buf, sz, &off, &recs[i])) {		/* corrupt RR */
+	    RFC1035_UNPACK_DEBUG;
+	    break;
+	}
 	nr++;
     }
-    if (nr > 0)
-	*records = recs;
-    else
+    if (nr == 0) {
+	/*
+	 * we expected to unpack some answers (ancount != 0), but
+	 * didn't actually get any.
+	 */
 	free(recs);
+	rfc1035SetErrno(rfc1035_unpack_error);
+	return -rfc1035_unpack_error;
+    }
+    *records = recs;
     return nr;
 }
 
@@ -471,9 +593,14 @@
 rfc1035BuildAQuery(const char *hostname, char *buf, size_t * szp)
 {
     static rfc1035_header h;
-    off_t offset = 0;
+    size_t offset = 0;
     size_t sz = *szp;
     memset(&h, '\0', sizeof(h));
+    /* the first char of hostname must be alphanmeric */
+    if (NULL == strchr(Alphanum, *hostname)) {
+	rfc1035SetErrno(3);
+	return 0;
+    }
     h.id = rfc1035Qid();
     h.qr = 0;
     h.rd = 1;
@@ -504,7 +631,7 @@
 rfc1035BuildPTRQuery(const struct in_addr addr, char *buf, size_t * szp)
 {
     static rfc1035_header h;
-    off_t offset = 0;
+    size_t offset = 0;
     size_t sz = *szp;
     static char rev[32];
     unsigned int i;
@@ -527,7 +654,7 @@
 	RFC1035_TYPE_PTR,
 	RFC1035_CLASS_IN);
     assert(offset <= sz);
-    *szp = (size_t) offset;
+    *szp = offset;
     return h.id;
 }
 
@@ -559,6 +686,10 @@
     int s;
     int rl;
     struct sockaddr_in S;
+    if (3 != argc) {
+	fprintf(stderr, "usage: %s ip port\n", argv[0]);
+	return 1;
+    }
     setbuf(stdout, NULL);
     setbuf(stderr, NULL);
     s = socket(PF_INET, SOCK_DGRAM, 0);
@@ -566,6 +697,10 @@
 	perror("socket");
 	return 1;
     }
+    memset(&S, '\0', sizeof(S));
+    S.sin_family = AF_INET;
+    S.sin_port = htons(atoi(argv[2]));
+    S.sin_addr.s_addr = inet_addr(argv[1]);
     while (fgets(input, 512, stdin)) {
 	struct in_addr junk;
 	strtok(input, "\r\n");
@@ -576,10 +711,6 @@
 	} else {
 	    sid = rfc1035BuildAQuery(input, buf, &sz);
 	}
-	memset(&S, '\0', sizeof(S));
-	S.sin_family = AF_INET;
-	S.sin_port = htons(53);
-	S.sin_addr.s_addr = inet_addr("128.117.28.219");
 	sendto(s, buf, sz, 0, (struct sockaddr *) &S, sizeof(S));
 	do {
 	    fd_set R;
@@ -597,7 +728,7 @@
 	memset(rbuf, '\0', 512);
 	rl = recv(s, rbuf, 512, 0);
 	{
-	    unsigned short rid;
+	    unsigned short rid = 0;
 	    int i;
 	    int n;
 	    rfc1035_rr *answers = NULL;
@@ -605,10 +736,10 @@
 		rl,
 		&answers,
 		&rid);
-	    if (rid != sid) {
-		printf("ERROR, ID mismatch (%#hx, %#hx)\n", sid, rid);
-	    } else if (n < 0) {
+	    if (n < 0) {
 		printf("ERROR %d\n", rfc1035_errno);
+	    } else if (rid != sid) {
+		printf("ERROR, ID mismatch (%#hx, %#hx)\n", sid, rid);
 	    } else {
 		printf("%d answers\n", n);
 		for (i = 0; i < n; i++) {
Index: squid/lib/util.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/lib/util.c,v
retrieving revision 1.1.1.3.4.2.2.3
retrieving revision 1.1.1.3.4.2.2.4
diff -u -r1.1.1.3.4.2.2.3 -r1.1.1.3.4.2.2.4
--- squid/lib/util.c	27 Jan 2002 19:37:44 -0000	1.1.1.3.4.2.2.3
+++ squid/lib/util.c	30 Apr 2002 17:21:47 -0000	1.1.1.3.4.2.2.4
@@ -1,6 +1,6 @@
 
 /*
- * $Id: util.c,v 1.1.1.3.4.2.2.3 2002/01/27 19:37:44 serassio Exp $
+ * $Id: util.c,v 1.1.1.3.4.2.2.4 2002/04/30 17:21:47 serassio Exp $
  *
  * DEBUG: 
  * AUTHOR: Harvest Derived
@@ -607,7 +607,11 @@
 {
     static char xstrerror_buf[BUFSIZ];
     if (errno < 0 || errno >= sys_nerr)
+#ifdef _SQUID_MSWIN_
+	strncpy(xstrerror_buf, wsastrerror(errno), BUFSIZ);
+#else
 	snprintf(xstrerror_buf, BUFSIZ, "(%d) Unknown", errno);
+#endif
     else
 	snprintf(xstrerror_buf, BUFSIZ, "(%d) %s", errno, strerror(errno));
     return xstrerror_buf;
@@ -622,7 +626,11 @@
 {
     static char xbstrerror_buf[BUFSIZ];
     if (err < 0 || err >= sys_nerr)
+#ifdef _SQUID_MSWIN_
+	strncpy(xbstrerror_buf, wsastrerror(err), BUFSIZ);
+#else
 	snprintf(xbstrerror_buf, BUFSIZ, "(%d) Unknown", err);
+#endif
     else
 	snprintf(xbstrerror_buf, BUFSIZ, "(%d) %s", err, strerror(err));
     return xbstrerror_buf;
Index: squid/lib/win32lib.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/lib/win32lib.c,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- squid/lib/win32lib.c	3 Feb 2002 15:16:28 -0000	1.1.2.9
+++ squid/lib/win32lib.c	30 Apr 2002 17:21:47 -0000	1.1.2.10
@@ -1,5 +1,5 @@
 /*
- * $Id: win32lib.c,v 1.1.2.9 2002/02/03 15:16:28 serassio Exp $
+ * $Id: win32lib.c,v 1.1.2.10 2002/04/30 17:21:47 serassio Exp $
  *
  * * * * * * * * Legal stuff * * * * * * *
  *
@@ -37,6 +37,10 @@
 #define OPTERRNF (2)
 #define OPTERRARG (3)
 
+__declspec(thread) int ws32_result;
+__declspec(thread) int _so_err;
+__declspec(thread) int _so_err_siz;
+
 char *optarg;
 int optreset = 0;
 int optind = 1;
@@ -45,35 +49,35 @@
 
 int chroot (const char *dirname)
 {
-    if (SetCurrentDirectory(dirname))
-	return 0;
-    else
-	return GetLastError();
+	if (SetCurrentDirectory(dirname))
+		return 0;
+	else
+		return GetLastError();
 }
 
 int kill(pid_t pid, int sig)
 {
-    HANDLE hProcess;
+   	HANDLE hProcess;
 
-    if (sig == 0) {
-	if ((hProcess = OpenProcess(PROCESS_QUERY_INFORMATION |
-	    PROCESS_VM_READ,
-	    FALSE, pid)) == NULL)
-	    return -1;
-	else {
-	    CloseHandle(hProcess);
-	    return 0;
+	if (sig == 0) {
+		if ((hProcess = OpenProcess(PROCESS_QUERY_INFORMATION |
+		    PROCESS_VM_READ,
+		    FALSE, pid)) == NULL)
+				return -1;
+		else {
+        	CloseHandle(hProcess);
+			return 0;
+		}
 	}
-    }
-    else return 0;
+	else return 0;
 }
 
 int gettimeofday( struct timeval * pcur_time,void * tz){
-    struct _timeb current;
-    _ftime(&current);
-    pcur_time->tv_sec=current.time;
-    pcur_time->tv_usec=current.millitm * 1000;
-    return 0;
+	struct _timeb current;
+	_ftime(&current);
+	pcur_time->tv_sec=current.time;
+	pcur_time->tv_usec=current.millitm * 1000;
+	return 0;
 }
 
 int statfs(const char *path, struct statfs *sfs)
@@ -84,22 +88,22 @@
 
     if (!sfs)
     {
-	errno=EINVAL;
-	return -1;
+		errno=EINVAL;
+		return -1;
     }
 
     strncpy(drive,path,2);
-    drive[2]='\0';
-    strcat(drive,"\\");
+	drive[2]='\0';
+	strcat(drive,"\\");
 
     if (!GetDiskFreeSpace(drive, &spc, &bps, &freec, &totalc)) {
-	errno = ENOENT;
-	return -1;
+      errno=ENOENT;
+      return -1;
     }
     if (!GetVolumeInformation(drive, NULL, 0, &vsn, &maxlen, &flags, NULL, 0))
     {
-	errno = ENOENT;
-	return -1;
+      errno=ENOENT;
+      return -1;
     }
     sfs->f_type = flags;
     sfs->f_bsize = spc*bps;
@@ -138,6 +142,7 @@
     optopt = argv[oint][optchr];
     return('?');
 }
+    
 
 int
 getopt(int argc, char* const *argv, const char *optstr)
@@ -149,11 +154,11 @@
 
     if (optreset)
         optreset = optchr = dash = 0;
-    if(optind >= argc)
+    if (optind >= argc)
         return(EOF);
-    if(!dash && (argv[optind][0] !=  '-'))
+    if (!dash && (argv[optind][0] !=  '-'))
         return(EOF);
-    if(!dash && (argv[optind][0] ==  '-') && !argv[optind][1])
+    if (!dash && (argv[optind][0] == '-') && !argv[optind][1])
     {
         /*
          * use to specify stdin. Need to let pgm process this and
@@ -161,13 +166,13 @@
          */
         return(EOF);
     }
-    if((argv[optind][0] == '-') && (argv[optind][1] == '-'))
+    if ((argv[optind][0] == '-') && (argv[optind][1] == '-'))
     {
         /* -- indicates end of args */
         optind++;
         return(EOF);
     }
-    if(!dash)
+    if (!dash)
     {
         assert((argv[optind][0] == '-') && argv[optind][1]);
         dash = 1;
@@ -283,21 +288,22 @@
 	break;
     }
     if (errind == -1)
-	return ("Unknown");
-    assert(err == _wsaerrtext[errind].err);
-    snprintf(xwsaerror_buf, BUFSIZ, "(%d) %s, %s", err, _wsaerrtext[errind].errconst, _wsaerrtext[errind].errdesc);
+	snprintf(xwsaerror_buf, BUFSIZ, "(%d) Unknown", err);
+    else
+	snprintf(xwsaerror_buf, BUFSIZ, "(%d) %s, %s", err, _wsaerrtext[errind].errconst, _wsaerrtext[errind].errdesc);
     return xwsaerror_buf;
 }
 
 struct passwd *getpwnam(char * unused)
 {
-    static struct passwd pwd = {100};
-    return &pwd;
+	static struct passwd pwd = {100};
+	return &pwd;
 }
 
 struct group *getgrnam(char * unused)
 {
-    static struct group grp = {100};
-    return &grp;
+	static struct group grp = {100};
+	return &grp;
 }
+
 #endif
Index: squid/snmplib/snmp_vars.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/snmplib/snmp_vars.c,v
retrieving revision 1.1.1.2.56.1
retrieving revision 1.1.1.2.56.2
diff -u -r1.1.1.2.56.1 -r1.1.1.2.56.2
--- squid/snmplib/snmp_vars.c	16 Feb 2002 18:20:32 -0000	1.1.1.2.56.1
+++ squid/snmplib/snmp_vars.c	30 Apr 2002 17:21:47 -0000	1.1.1.2.56.2
@@ -402,9 +402,6 @@
     printf("VARS: All Variable length %d\n", AllVarLen);
 #endif
 
-#if defined PARSE_ERROR
-#undef PARSE_ERROR
-#endif
 #define PARSE_ERROR { snmp_var_free(Var); return(NULL); }
 
     /* We know how long the variable list is.  Parse it. */
Index: squid/src/acl.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/acl.c,v
retrieving revision 1.1.1.3.4.3.2.6
retrieving revision 1.1.1.3.4.3.2.7
diff -u -r1.1.1.3.4.3.2.6 -r1.1.1.3.4.3.2.7
--- squid/src/acl.c	29 Sep 2001 07:58:59 -0000	1.1.1.3.4.3.2.6
+++ squid/src/acl.c	30 Apr 2002 17:21:48 -0000	1.1.1.3.4.3.2.7
@@ -1,6 +1,6 @@
 
 /*
- * $Id: acl.c,v 1.1.1.3.4.3.2.6 2001/09/29 07:58:59 serassio Exp $
+ * $Id: acl.c,v 1.1.1.3.4.3.2.7 2002/04/30 17:21:48 serassio Exp $
  *
  * DEBUG: section 28    Access Control
  * AUTHOR: Duane Wessels
@@ -110,7 +110,9 @@
   strtok_again:
     if (!aclFromFile) {
 	t = (strtok(NULL, w_space));
-	if (t && (*t == '\"' || *t == '\'')) {
+	if (!t || *t == '#') {
+	    return NULL;
+	} else if (*t == '\"' || *t == '\'') {
 	    /* quote found, start reading from file */
 	    fn = ++t;
 	    while (*t && *t != '\"' && *t != '\'')
Index: squid/src/cache_manager.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/cache_manager.c,v
retrieving revision 1.1.1.2.4.1.2.4
retrieving revision 1.1.1.2.4.1.2.5
diff -u -r1.1.1.2.4.1.2.4 -r1.1.1.2.4.1.2.5
--- squid/src/cache_manager.c	6 Apr 2002 17:37:34 -0000	1.1.1.2.4.1.2.4
+++ squid/src/cache_manager.c	30 Apr 2002 17:21:48 -0000	1.1.1.2.4.1.2.5
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_manager.c,v 1.1.1.2.4.1.2.4 2002/04/06 17:37:34 serassio Exp $
+ * $Id: cache_manager.c,v 1.1.1.2.4.1.2.5 2002/04/30 17:21:48 serassio Exp $
  *
  * DEBUG: section 16    Cache Manager Objects
  * AUTHOR: Duane Wessels
@@ -306,21 +306,11 @@
 static void
 cachemgrOfflineToggle(StoreEntry * sentry)
 {
-    switch(Config.offline)
-    {
-	case 0:
-	    Config.offline=2;
-	    break;
-	case 1:
-	    break;
-	case 2:
-	    Config.offline=0;
-	    break;
-    }
+    Config.onoff.offline = !Config.onoff.offline;
     debug(16, 0) ("offline_mode now %s.\n",
-	Config.offline ? (Config.offline==1?"MAYBE":"ON") : "OFF");
+	Config.onoff.offline ? "ON" : "OFF");
     storeAppendPrintf(sentry, "offline_mode is now %s\n",
-	Config.offline ? (Config.offline==1?"MAYBE":"ON") : "OFF");
+	Config.onoff.offline ? "ON" : "OFF");
 }
 static const char *
 cachemgrActionProtection(const action_table * at)
Index: squid/src/cf.data.pre
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/cf.data.pre,v
retrieving revision 1.1.1.3.4.3.2.4
retrieving revision 1.1.1.3.4.3.2.5
diff -u -r1.1.1.3.4.3.2.4 -r1.1.1.3.4.3.2.5
--- squid/src/cf.data.pre	10 Feb 2002 17:55:55 -0000	1.1.1.3.4.3.2.4
+++ squid/src/cf.data.pre	30 Apr 2002 17:21:48 -0000	1.1.1.3.4.3.2.5
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.1.1.3.4.3.2.4 2002/02/10 17:55:55 serassio Exp $
+# $Id: cf.data.pre,v 1.1.1.3.4.3.2.5 2002/04/30 17:21:48 serassio Exp $
 #
 #
 # SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -2995,25 +2995,12 @@
 DOC_NONE
 
 NAME: offline_mode
-TYPE: int
-LOC: Config.offline
-DEFAULT: 0
-DOC_START
-	If set to 2, Squid will never try to validate cached objects.
-	If set to 1, Squid will not try to cache objects if network_interface
-	is down
-	If set to 0, Squid will operate normally.
-DOC_END
-
-NAME: network_interface
-TYPE: eol
-LOC: Config.network_interface
-DEFAULT: none
+TYPE: onoff
+LOC: Config.onoff.offline
+DEFAULT: off
 DOC_START
-	Used in conjunction with the new offline code. If offline_mode is 1,
-	then the status of this interface (up or down) tells us if
-	we should be operating in offline mode. If it's down, we pretend
-	we're in offline mode. If it's up, we behave normally.
+	Enable this option and Squid will never try to validate cached
+	objects.
 DOC_END
 
 NAME: uri_whitespace
Index: squid/src/client_side.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v
retrieving revision 1.1.1.3.4.6.2.8
retrieving revision 1.1.1.3.4.6.2.9
diff -u -r1.1.1.3.4.6.2.8 -r1.1.1.3.4.6.2.9
--- squid/src/client_side.c	10 Feb 2002 17:55:55 -0000	1.1.1.3.4.6.2.8
+++ squid/src/client_side.c	30 Apr 2002 17:21:48 -0000	1.1.1.3.4.6.2.9
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.c,v 1.1.1.3.4.6.2.8 2002/02/10 17:55:55 serassio Exp $
+ * $Id: client_side.c,v 1.1.1.3.4.6.2.9 2002/04/30 17:21:48 serassio Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -112,10 +112,6 @@
 static int clientReplyBodyTooLarge(int clen);
 static int clientRequestBodyTooLarge(int clen);
 
-#ifdef _SQUID_MSWIN_
-#define xstrerror() wsastrerror(errno)
-#endif
-
 static int
 checkAccelOnly(clientHttpRequest * http)
 {
@@ -1432,7 +1428,7 @@
 	 */
 	if (e->mem_status == IN_MEMORY)
 	    http->log_type = LOG_TCP_MEM_HIT;
-	else if (check_offline())
+	else if (Config.onoff.offline)
 	    http->log_type = LOG_TCP_OFFLINE_HIT;
 	clientSendMoreData(data, buf, size);
     }
@@ -1782,7 +1778,7 @@
 	 * This hack may hit performance a little, but it's better than 
 	 * blocking!.
 	 */
-#if defined (_SQUID_CYGWIN_) || defined (_SQUID_MSWIN_)
+#ifdef _SQUID_CYGWIN_
 	commSetSelect(conn->fd, COMM_SELECT_READ, clientReadRequest, conn, 0);
 #else
 	clientReadRequest(conn->fd, conn);	/* Read next request */
@@ -1915,7 +1911,7 @@
 	debug(33, 3) ("clientProcessRequest2: storeGet() MISS\n");
 	return LOG_TCP_MISS;
     }
-    if (check_offline()) {
+    if (Config.onoff.offline) {
 	debug(33, 3) ("clientProcessRequest2: offline HIT\n");
 	http->entry = e;
 	return LOG_TCP_HIT;
@@ -2365,19 +2361,11 @@
     clientHttpRequest **H = NULL;
     char *prefix = NULL;
     ErrorState *err = NULL;
-#ifdef _SQUID_MSWIN_
-    sde *F = &sd_table[fd];
-#else
     fde *F = &fd_table[fd];
-#endif
     int len = conn->in.size - conn->in.offset - 1;
     debug(33, 4) ("clientReadRequest: FD %d: reading request...\n", fd);
     Counter.syscalls.sock.reads++;
-#ifdef _SQUID_MSWIN_
-    size = recv(fd, conn->in.buf + conn->in.offset, len);
-#else
     size = read(fd, conn->in.buf + conn->in.offset, len);
-#endif
     if (size > 0) {
 	fd_bytes(fd, size, FD_READ);
 	kb_incr(&Counter.client_http.kbytes_in, size);
@@ -2407,11 +2395,7 @@
 	conn->defer.n++;
 	fd_note(fd, "half-closed");
 	return;
-#ifdef _SQUID_MSWIN_
-    } else if (size ==SOCKET_ERROR) {
-#else
     } else if (size < 0) {
-#endif
 	if (!ignoreErrno(errno)) {
 	    debug(50, 2) ("clientReadRequest: FD %d: %s\n", fd, xstrerror());
 	    comm_close(fd);
@@ -2689,11 +2673,7 @@
     while (max-- && !httpAcceptDefer(sock, NULL)) {
 	memset(&peer, '\0', sizeof(struct sockaddr_in));
 	memset(&me, '\0', sizeof(struct sockaddr_in));
-#ifdef _SQUID_MSWIN_
-	if ((fd = comm_accept(sock, &peer, &me)) ==INVALID_SOCKET ) {
-#else
 	if ((fd = comm_accept(sock, &peer, &me)) < 0) {
-#endif
 	    if (!ignoreErrno(errno))
 		debug(50, 1) ("httpAccept: FD %d: accept failure: %s\n",
 		    sock, xstrerror());
Index: squid/src/comm.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/comm.c,v
retrieving revision 1.1.1.3.4.1.2.10
retrieving revision 1.1.1.3.4.1.2.11
diff -u -r1.1.1.3.4.1.2.10 -r1.1.1.3.4.1.2.11
--- squid/src/comm.c	6 Apr 2002 17:37:38 -0000	1.1.1.3.4.1.2.10
+++ squid/src/comm.c	30 Apr 2002 17:21:49 -0000	1.1.1.3.4.1.2.11
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.c,v 1.1.1.3.4.1.2.10 2002/04/06 17:37:38 serassio Exp $
+ * $Id: comm.c,v 1.1.1.3.4.1.2.11 2002/04/30 17:21:49 serassio Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -71,44 +71,13 @@
 static int commResetFD(ConnectStateData * cs);
 static int commRetryConnect(ConnectStateData * cs);
 
-#ifdef _SQUID_MSWIN_
-void
-commSetSelectS(int sd, unsigned int type, PF * handler, void *client_data, time_t timeout)
-{
-    sde *F = &sd_table[sd];
-    assert(sd >= 0);
-    assert(F->flags.open);
-    debug(5, 5) ("commSetSelect: SD %d type %d\n", sd, type);
-    if (type & COMM_SELECT_READ) {
-	F->read_handler = handler;
-	F->read_data = client_data;
-	commUpdateReadBitsS(sd, handler);
-    }
-    if (type & COMM_SELECT_WRITE) {
-	F->write_handler = handler;
-	F->write_data = client_data;
-	commUpdateWriteBitsS(sd, handler);
-    }
-    if (timeout)
-	F->timeout = squid_curtime + timeout;
-}
-#endif
-
 static void
 CommWriteStateCallbackAndFree(int fd, int code)
 {
-#ifdef _SQUID_MSWIN_
-    CommWriteStateData *CommWriteState = sd_table[fd].rwstate;
-#else
     CommWriteStateData *CommWriteState = fd_table[fd].rwstate;
-#endif
     CWCB *callback = NULL;
     void *data;
-#ifdef _SQUID_MSWIN_
-    sd_table[fd].rwstate = NULL;
-#else
     fd_table[fd].rwstate = NULL;
-#endif
     if (CommWriteState == NULL)
 	return;
     if (CommWriteState->free_func) {
@@ -130,11 +99,7 @@
 {
     struct sockaddr_in addr;
     socklen_t addr_len = 0;
-#ifdef _SQUID_MSWIN_
-    sde *F = &sd_table[fd];
-#else
     fde *F = &fd_table[fd];
-#endif
 
     /* If the fd is closed already, just return */
     if (!F->flags.open) {
@@ -184,24 +149,10 @@
     const char *note)
 {
     int new_socket;
-#ifdef _SQUID_MSWIN_
-    sde *F = NULL;
-    int err;
-#else
     fde *F = NULL;
-#endif
 
     /* Create socket for accepting new connections. */
     Counter.syscalls.sock.sockets++;
-#ifdef _SQUID_MSWIN_
-    if ((new_socket = (int) socket(AF_INET, sock_type, proto)) == INVALID_SOCKET) {
-	/* Increase the number of reserved fd's if calls to socket()
-	 * are failing because the open file table is full.  This
-	 * limits the number of simultaneous clients */
-	err=WSAGetLastError();
-	switch (err) {
-	case WSAEMFILE:
-#else
     if ((new_socket = socket(AF_INET, sock_type, proto)) < 0) {
 	/* Increase the number of reserved fd's if calls to socket()
 	 * are failing because the open file table is full.  This
@@ -209,7 +160,6 @@
 	switch (errno) {
 	case ENFILE:
 	case EMFILE:
-#endif
 	    debug(50, 1) ("comm_open: socket failure: %s\n", xstrerror());
 	    fdAdjustReserved();
 	    break;
@@ -221,18 +171,14 @@
     /* update fdstat */
     debug(5, 5) ("comm_open: FD %d is a new socket\n", new_socket);
     fd_open(new_socket, FD_SOCKET, note);
-#ifdef _SQUID_MSWIN_
-    F = &sd_table[new_socket];
-#else
     F = &fd_table[new_socket];
-#endif
     if (!(flags & COMM_NOCLOEXEC))
 	commSetCloseOnExec(new_socket);
     if ((flags & COMM_REUSEADDR))
 	commSetReuseAddr(new_socket);
     if (port > (u_short) 0) {
 #ifdef _SQUID_MSWIN_
-	if ( sock_type != SOCK_DGRAM && proto != IPPROTO_UDP )
+	if (sock_type != SOCK_DGRAM)
 #endif
 	commSetNoLinger(new_socket);
 	if (opt_reuseaddr)
@@ -352,54 +298,26 @@
 static int
 commResetFD(ConnectStateData * cs)
 {
-#ifdef _SQUID_MSWIN_
-    int err;
-#endif
     int fd2;
     if (!cbdataValid(cs->data))
 	return 0;
-#ifdef _SQUID_MSWIN_
-    closesocket(cs->fd);
-    return 0;
-#endif
-    Counter.syscalls.sock.sockets++;
-#ifdef _SQUID_MSWIN_
-    fd2 = (int) socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
     Counter.syscalls.sock.sockets++;
-    if (fd2 == INVALID_SOCKET) {
-	err=WSAGetLastError();
-	debug(5, 0) ("commResetFD: socket: %s\n", xstrerror());
-	if (WSAEMFILE == h_errno)
-#else    
     fd2 = socket(AF_INET, SOCK_STREAM, 0);
     Counter.syscalls.sock.sockets++;
     if (fd2 < 0) {
 	debug(5, 0) ("commResetFD: socket: %s\n", xstrerror());
 	if (ENFILE == errno || EMFILE == errno)
-#endif
 	    fdAdjustReserved();
 	return 0;
     }
     if (dup2(fd2, cs->fd) < 0) {
-#ifdef _SQUID_MSWIN_
-	err=WSAGetLastError();
-#endif
 	debug(5, 0) ("commResetFD: dup2: %s\n", xstrerror());
-#ifdef _SQUID_MSWIN_
-	if (WSAEMFILE == err)
-#else
 	if (ENFILE == errno || EMFILE == errno)
-#endif
 	    fdAdjustReserved();
 	return 0;
     }
-#ifdef _SQUID_MSWIN_
-    closesocket(fd2);
-    sd_table[cs->fd].flags.called_connect = 0;
-#else
     close(fd2);
     fd_table[cs->fd].flags.called_connect = 0;
-#endif
     /*
      * yuck, this has assumptions about comm_open() arguments for
      * the original socket
@@ -450,11 +368,7 @@
     switch (comm_connect_addr(fd, &cs->S)) {
     case COMM_INPROGRESS:
 	debug(5, 5) ("commConnectHandle: FD %d: COMM_INPROGRESS\n", fd);
-#ifdef _SQUID_MSWIN_
-	commSetSelectS(fd, COMM_SELECT_WRITE, commConnectHandle, cs, 0);
-#else
 	commSetSelect(fd, COMM_SELECT_WRITE, commConnectHandle, cs, 0);
-#endif
 	break;
     case COMM_OK:
 	ipcacheMarkGoodAddr(cs->host, cs->S.sin_addr);
@@ -478,19 +392,11 @@
 int
 commSetTimeout(int fd, int timeout, PF * handler, void *data)
 {
-#ifdef _SQUID_MSWIN_
-    sde *F;
-#else
     fde *F;
-#endif
     debug(5, 3) ("commSetTimeout: FD %d timeout %d\n", fd, timeout);
     assert(fd >= 0);
     assert(fd < Squid_MaxFD);
-#ifdef _SQUID_MSWIN_
-	F = &sd_table[fd];
-#else
 	F = &fd_table[fd];
-#endif
     assert(F->flags.open);
     if (timeout < 0) {
 	F->timeout_handler = NULL;
@@ -509,11 +415,7 @@
 comm_connect_addr(int sock, const struct sockaddr_in *address)
 {
     int status = COMM_OK;
-#ifdef _SQUID_MSWIN_
-    sde *F = &sd_table[sock];
-#else
     fde *F = &fd_table[sock];
-#endif
     int x;
     int err = 0;
     socklen_t errlen;
@@ -525,14 +427,7 @@
 	Counter.syscalls.sock.connects++;
 	x = connect(sock, (struct sockaddr *) address, sizeof(*address));
 	if (x < 0)
-#ifdef _SQUID_MSWIN_
-	{
-	    err=WSAGetLastError();
-	    debug(5, 9) ("connect FD %d: %s\n", sock, wsastrerror(err));
-	}
-#else
 	    debug(5, 9) ("connect FD %d: %s\n", sock, xstrerror());
-#endif
     } else {
 #if defined(_SQUID_NEWSOS6_)
 	/* Makoto MATSUSHITA <matusita@ics.es.osaka-u.ac.jp> */
@@ -545,11 +440,7 @@
 	}
 #else
 	errlen = sizeof(err);
-#ifdef _SQUID_MSWIN_
-	x = getsockopt(sock, SOL_SOCKET, SO_ERROR, (char*)&err,(int*) &errlen);
-#else
 	x = getsockopt(sock, SOL_SOCKET, SO_ERROR, &err, &errlen);
-#endif
 	if (x == 0)
 	    errno = err;
 #if defined(_SQUID_SOLARIS_)
@@ -564,15 +455,9 @@
 #endif
 #endif
     }
-#ifdef _SQUID_MSWIN_
-    if (err == 0 || err == WSAEISCONN)
-	status = COMM_OK;
-    else if (WSASetLastError(err), ignoreErrno(err))
-#else
     if (errno == 0 || errno == EISCONN)
 	status = COMM_OK;
     else if (ignoreErrno(errno))
-#endif
 	status = COMM_INPROGRESS;
     else
 	return COMM_ERROR;
@@ -596,27 +481,14 @@
     struct sockaddr_in P;
     struct sockaddr_in M;
     socklen_t Slen;
-#ifdef _SQUID_MSWIN_
-    sde *F = NULL;
-#else
     fde *F = NULL;
-#endif
     Slen = sizeof(P);
     Counter.syscalls.sock.accepts++;
-#ifdef _SQUID_MSWIN_
-    if ((sock = WSAAccept(fd, (struct sockaddr *) &P,(int*) &Slen,NULL,0)) ==INVALID_SOCKET ) {
-	if (ignoreErrno(h_errno)) {
-#else
     if ((sock = accept(fd, (struct sockaddr *) &P, &Slen)) < 0) {
 	if (ignoreErrno(errno)) {
-#endif
 	    debug(50, 5) ("comm_accept: FD %d: %s\n", fd, xstrerror());
 	    return COMM_NOMESSAGE;
-#ifdef _SQUID_MSWIN_
-	} else if (WSAEMFILE == WSAGetLastError()) {
-#else
 	} else if (ENFILE == errno || EMFILE == errno) {
-#endif
 	    debug(50, 3) ("comm_accept: FD %d: %s\n", fd, xstrerror());
 	    return COMM_ERROR;
 	} else {
@@ -634,11 +506,7 @@
     commSetCloseOnExec(sock);
     /* fdstat update */
     fd_open(sock, FD_SOCKET, "HTTP Request");
-#ifdef _SQUID_MSWIN_
-    F = &sd_table[sock];
-#else
-    F = &fd_table[sock];
-#endif
+	F = &fd_table[sock];
     xstrncpy(F->ipaddr, inet_ntoa(P.sin_addr), 16);
     F->remote_port = htons(P.sin_port);
     F->local_port = htons(M.sin_port);
@@ -649,11 +517,7 @@
 void
 commCallCloseHandlers(int fd)
 {
-#ifdef _SQUID_MSWIN_
-    sde *F = &sd_table[fd];
-#else
     fde *F = &fd_table[fd];
-#endif
     close_handler *ch;
     debug(5, 5) ("commCallCloseHandlers: FD %d\n", fd);
     while ((ch = F->close_handler) != NULL) {
@@ -672,11 +536,7 @@
 {
     LOCAL_ARRAY(char, buf, 1024);
     int n;
-#ifdef _SQUID_MSWIN_
-    n = recv(fd, buf, 1024);
-#else
     n = read(fd, buf, 1024);
-#endif
     if (n < 0)
 	debug(5, 3) ("commLingerClose: FD %d read: %s\n", fd, xstrerror());
     comm_close(fd);
@@ -701,30 +561,18 @@
     }
     fd_note(fd, "lingering close");
     commSetTimeout(fd, 10, commLingerTimeout, NULL);
-#ifdef _SQUID_MSWIN_
-    commSetSelectS(fd, COMM_SELECT_READ, commLingerClose, NULL, 0);
-#else
     commSetSelect(fd, COMM_SELECT_READ, commLingerClose, NULL, 0);
-#endif
 }
 #endif
 
 void
 comm_close(int fd)
 {
-#ifdef _SQUID_MSWIN_
-    sde *F = NULL;
-#else
     fde *F = NULL;
-#endif
     debug(5, 5) ("comm_close: FD %d\n", fd);
     assert(fd >= 0);
     assert(fd < Squid_MaxFD);
-#ifdef _SQUID_MSWIN_
-    F = &sd_table[fd];
-#else
     F = &fd_table[fd];
-#endif
     if (F->flags.closing)
 	return;
     if (shutting_down && (!F->flags.open || F->type == FD_FILE))
@@ -737,11 +585,7 @@
     if (F->uses)		/* assume persistent connect count */
 	pconnHistCount(1, F->uses);
     fd_close(fd);		/* update fdstat */
-#ifdef _SQUID_MSWIN_
-    closesocket(fd);
-#else
     close(fd);
-#endif
     Counter.syscalls.sock.closes++;
 }
 
@@ -760,18 +604,11 @@
 #ifdef _SQUID_LINUX_
 	if (ECONNREFUSED != errno)
 #endif
-#ifdef _SQUID_MSWIN_
-	errno = WSAGetLastError();
-#endif
 	    debug(50, 1) ("comm_udp_sendto: FD %d, %s, port %d: %s\n",
 		fd,
 		inet_ntoa(to_addr->sin_addr),
 		(int) htons(to_addr->sin_port),
-#ifdef _SQUID_MSWIN_
-		wsastrerror(errno));
-#else
 		xstrerror());
-#endif
 	return COMM_ERROR;
     }
     return x;
@@ -780,11 +617,7 @@
 void
 commSetDefer(int fd, DEFER * func, void *data)
 {
-#ifdef _SQUID_MSWIN_
-    sde *F = &sd_table[fd];
-#else
     fde *F = &fd_table[fd];
-#endif
     F->defer_check = func;
     F->defer_data = data;
 }
@@ -817,21 +650,12 @@
     close_handler *c;
     debug(5, 5) ("comm_add_close_handler: FD %d, handler=%p, data=%p\n",
 	fd, handler, data);
-#ifdef _SQUID_MSWIN_
-	for (c = sd_table[fd].close_handler; c; c = c->next)
-	assert(c->handler != handler || c->data != data);
-    new->handler = handler;
-    new->data = data;
-    new->next = sd_table[fd].close_handler;
-    sd_table[fd].close_handler = new;
-#else
     for (c = fd_table[fd].close_handler; c; c = c->next)
 	assert(c->handler != handler || c->data != data);
     new->handler = handler;
     new->data = data;
     new->next = fd_table[fd].close_handler;
     fd_table[fd].close_handler = new;
-#endif
     cbdataLock(data);
 }
 
@@ -843,11 +667,7 @@
     /* Find handler in list */
     debug(5, 5) ("comm_remove_close_handler: FD %d, handler=%p, data=%p\n",
 	fd, handler, data);
-#ifdef _SQUID_MSWIN_
-	for (p = sd_table[fd].close_handler; p != NULL; last = p, p = p->next)
-#else
 	for (p = fd_table[fd].close_handler; p != NULL; last = p, p = p->next)
-#endif
 	if (p->handler == handler && p->data == data)
 	    break;		/* This is our handler */
     assert(p != NULL);
@@ -855,11 +675,7 @@
     if (last)
 	last->next = p->next;
     else
-#ifdef _SQUID_MSWIN_
-	sd_table[fd].close_handler = p->next;
-#else
 	fd_table[fd].close_handler = p->next;
-#endif
     cbdataUnlock(p->data);
     safe_free(p);
 }
@@ -871,13 +687,8 @@
     L.l_onoff = 0;		/* off */
     L.l_linger = 0;
     if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (char *) &L, sizeof(L)) < 0)
-#ifdef _SQUID_MSWIN_
-	debug(50, 0) ("commSetNoLinger: FD %d: %s\n", fd, wsastrerror(WSAGetLastError()));
-    sd_table[fd].flags.nolinger = 1;
-#else
 	debug(50, 0) ("commSetNoLinger: FD %d: %s\n", fd, xstrerror());
     fd_table[fd].flags.nolinger = 1;
-#endif
 }
 
 static void
@@ -901,12 +712,8 @@
 {
     int dummy = 0;
 #ifdef _SQUID_MSWIN_
-    int nonblocking = TRUE;
-    if (ioctlsocket(fd, FIONBIO, (unsigned long*)&nonblocking) ==SOCKET_ERROR) {
-	debug(50, 0) ("commSetNonBlocking: FD %d: %s\n", fd, wsastrerror(WSAGetLastError()));
-	return COMM_ERROR;
-    }
-    sd_table[fd].flags.nonblocking = 1;
+    int nonblocking = 1;
+    if (ioctlsocket(fd, FIONBIO, (unsigned long *) &nonblocking) < 0) {
 #else
     int flags;
     if ((flags = fcntl(fd, F_GETFL, dummy)) < 0) {
@@ -914,11 +721,11 @@
 	return COMM_ERROR;
     }
     if (fcntl(fd, F_SETFL, flags | SQUID_NONBLOCK) < 0) {
+#endif
 	debug(50, 0) ("commSetNonBlocking: FD %d: %s\n", fd, xstrerror());
 	return COMM_ERROR;
     }
     fd_table[fd].flags.nonblocking = 1;
-#endif
     return 0;
 }
 
@@ -927,12 +734,8 @@
 {
     int dummy = 0;
 #ifdef _SQUID_MSWIN_
-    int nonblocking=0;
-    if (ioctlsocket(fd, FIONBIO, (unsigned long*)&nonblocking) ==SOCKET_ERROR) {
-	debug(50, 0) ("commSetNonBlocking: FD %d: %s\n", fd, wsastrerror(WSAGetLastError()));
-	return COMM_ERROR;
-    }
-    sd_table[fd].flags.nonblocking = 0;
+    int nonblocking = 0;
+    if (ioctlsocket(fd, FIONBIO, (unsigned long *) &nonblocking) < 0) {
 #else
     int flags;
     if ((flags = fcntl(fd, F_GETFL, dummy)) < 0) {
@@ -940,11 +743,11 @@
 	return COMM_ERROR;
     }
     if (fcntl(fd, F_SETFL, flags & (~SQUID_NONBLOCK)) < 0) {
+#endif
 	debug(50, 0) ("commUnsetNonBlocking: FD %d: %s\n", fd, xstrerror());
 	return COMM_ERROR;
     }
     fd_table[fd].flags.nonblocking = 0;
-#endif
     return 0;
 }
 
@@ -977,9 +780,6 @@
 void
 comm_init(void)
 {
-#ifdef _SQUID_MSWIN_
-    sd_table =(sde*) xcalloc(Squid_MaxFD, sizeof(sde));
-#endif
     fd_table = xcalloc(Squid_MaxFD, sizeof(fde));
     /* XXX account fd_table */
     /* Keep a few file descriptors free so that we don't run out of FD's
@@ -1000,11 +800,7 @@
 	fd, (int) state->offset, state->size);
 
     nleft = state->size - state->offset;
-#ifdef _SQUID_MSWIN_
-    len = send(fd, state->buf + state->offset, nleft);
-#else
     len = write(fd, state->buf + state->offset, nleft);
-#endif
     debug(5, 5) ("commHandleWrite: write() returns %d\n", len);
     fd_bytes(fd, len, FD_WRITE);
     Counter.syscalls.sock.writes++;
@@ -1017,27 +813,10 @@
 	CommWriteStateCallbackAndFree(fd, nleft ? COMM_ERROR : COMM_OK);
     } else if (len < 0) {
 	/* An error */
-#ifdef _SQUID_MSWIN_
-	    if (sd_table[fd].flags.socket_eof) {
-	    debug(50, 2) ("commHandleWrite: FD %d: write failure: %s.\n",
-		fd, wsastrerror(WSAGetLastError()));
-#else
 	    if (fd_table[fd].flags.socket_eof) {
 	    debug(50, 2) ("commHandleWrite: FD %d: write failure: %s.\n",
 		fd, xstrerror());
-#endif
-	    CommWriteStateCallbackAndFree(fd, COMM_ERROR);
-#ifdef _SQUID_MSWIN_
-	} else if (ignoreErrno(errno)) {
-	    debug(50, 2) ("commHandleWrite: FD %d: write failure: %s.\n",
-		fd, wsastrerror(WSAGetLastError()));
-		commSetSelectS(fd,COMM_SELECT_WRITE, commHandleWrite,state, 0);
-	} else {
-	    debug(50, 2) ("commHandleWrite: FD %d: write failure: %s.\n",
-		fd, wsastrerror(WSAGetLastError()));
 	    CommWriteStateCallbackAndFree(fd, COMM_ERROR);
-	}
-#else
 	} else if (ignoreErrno(errno)) {
 	    debug(50, 10) ("commHandleWrite: FD %d: write failure: %s.\n",
 		fd, xstrerror());
@@ -1051,21 +830,16 @@
 		fd, xstrerror());
 	    CommWriteStateCallbackAndFree(fd, COMM_ERROR);
 	}
-#endif
     } else {
 	/* A successful write, continue */
 	state->offset += len;
-	if (state->offset < state->size) {
+	if ((unsigned) state->offset < state->size) {
 	    /* Not done, reinstall the write handler and write some more */
-#ifdef _SQUID_MSWIN_
-	    commSetSelectS(fd,COMM_SELECT_WRITE, commHandleWrite,state,0);
-#else
 	    commSetSelect(fd,
 		COMM_SELECT_WRITE,
 		commHandleWrite,
 		state,
 		0);
-#endif
 	} else {
 	    CommWriteStateCallbackAndFree(fd, COMM_OK);
 	}
@@ -1079,28 +853,16 @@
 void
 comm_write(int fd, char *buf, int size, CWCB * handler, void *handler_data, FREE * free_func)
 {
-#ifdef _SQUID_MSWIN_
-	CommWriteStateData *state = sd_table[fd].rwstate;
-#else
-	CommWriteStateData *state = fd_table[fd].rwstate;
-#endif
+    CommWriteStateData *state = fd_table[fd].rwstate;
     debug(5, 5) ("comm_write: FD %d: sz %d: hndl %p: data %p.\n",
 	fd, size, handler, handler_data);
     if (NULL != state) {
 	debug(5, 1) ("comm_write: fd_table[%d].rwstate != NULL\n", fd);
 	safe_free(state);
-#ifdef _SQUID_MSWIN_
-	sd_table[fd].rwstate = NULL;
-#else
 	fd_table[fd].rwstate = NULL;
-#endif
     }
     assert(state == NULL);
-#ifdef _SQUID_MSWIN_
-	sd_table[fd].rwstate = state = (CommWriteStateData*)xcalloc(1, sizeof(CommWriteStateData));
-#else
-	fd_table[fd].rwstate = state = xcalloc(1, sizeof(CommWriteStateData));
-#endif
+    fd_table[fd].rwstate = state = xcalloc(1, sizeof(CommWriteStateData));
     state->buf = buf;
     state->size = size;
     state->offset = 0;
@@ -1108,11 +870,7 @@
     state->handler_data = handler_data;
     state->free_func = free_func;
     cbdataLock(handler_data);
-#ifdef _SQUID_MSWIN_
-    commSetSelectS(fd, COMM_SELECT_WRITE, commHandleWrite, state, 0);
-#else
     commSetSelect(fd, COMM_SELECT_WRITE, commHandleWrite, state, 0);
-#endif
 }
 
 /* a wrapper around comm_write to allow for MemBuf to be comm_written in a snap */
@@ -1126,26 +884,6 @@
  * hm, this might be too general-purpose for all the places we'd
  * like to use it.
  */
-#ifdef _SQUID_MSWIN_
-int
-WSAignoreErrno(int err)
-{
-    err=WSAGetLastError();
-    errno = err;
-    switch (err) {
-    case WSAEINPROGRESS:
-    case WSAEWOULDBLOCK:
-    case WSAEALREADY:
-	case WSATRY_AGAIN:
-	return 1;
-    default:
-	return 0;
-    }
-    /* NOTREACHED */
-}
-
-#else
-
 int
 ignoreErrno(int ierrno)
 {
@@ -1166,24 +904,15 @@
     }
     /* NOTREACHED */
 }
-#endif
 
 void
 commCloseAllSockets(void)
 {
     int fd;
-#ifdef _SQUID_MSWIN_
-    sde *F = NULL;
-#else
     fde *F = NULL;
-#endif
     PF *callback;
     for (fd = 0; fd <= Biggest_FD; fd++) {
-#ifdef _SQUID_MSWIN_
-	F = &sd_table[fd];
-#else
 	F = &fd_table[fd];
-#endif
 	if (!F->flags.open)
 	    continue;
 	if (F->type != FD_SOCKET)
Index: squid/src/comm_select.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/comm_select.c,v
retrieving revision 1.1.1.3.4.2.2.4
retrieving revision 1.1.1.3.4.2.2.5
diff -u -r1.1.1.3.4.2.2.4 -r1.1.1.3.4.2.2.5
--- squid/src/comm_select.c	3 Feb 2002 15:15:35 -0000	1.1.1.3.4.2.2.4
+++ squid/src/comm_select.c	30 Apr 2002 17:21:49 -0000	1.1.1.3.4.2.2.5
@@ -1,6 +1,5 @@
-
 /*
- * $Id: comm_select.c,v 1.1.1.3.4.2.2.4 2002/02/03 15:15:35 serassio Exp $
+ * $Id: comm_select.c,v 1.1.1.3.4.2.2.5 2002/04/30 17:21:49 serassio Exp $
  *
  * DEBUG: section 5     Socket Functions
  *
@@ -70,15 +69,6 @@
 
 
 static struct timeval zero_tv;
-#ifdef _SQUID_MSWIN_
-static fd_set global_readsds;
-static fd_set global_writesds;
-static fd_set readsds;
-static fd_set writesds;
-static fd_set errsds;
-static int nreadsds;
-static int nwritesds;
-#endif
 static fd_set global_readfds;
 static fd_set global_writefds;
 static int nreadfds;
@@ -148,11 +138,7 @@
 static int
 commDeferRead(int fd)
 {
-#ifdef _SQUID_MSWIN_
-    sde *F = &sd_table[fd];
-#else
     fde *F = &fd_table[fd];
-#endif
     if (F->defer_check == NULL)
 	return 0;
     return F->defer_check(fd, F->defer_data);
@@ -544,27 +530,21 @@
     PF *hdl = NULL;
     fd_set read_mask;
     fd_set write_mask;
+#ifdef _SQUID_MSWIN_
+    fd_set errfds;
+    FD_ZERO(&errfds);
+#endif
     FD_ZERO(&read_mask);
     FD_ZERO(&write_mask);
     for (i = 0; i < nfds; i++) {
 	fd = fds[i];
-#ifdef _SQUID_MSWIN_
-	if (sd_table[fd].read_handler) {
-	    FD_SET((SOCKET) fd, &read_mask);
-#else
 	if (fd_table[fd].read_handler) {
 	    FD_SET(fd, &read_mask);
-#endif
 	    if (fd > maxfd)
 		maxfd = fd;
 	}
-#ifdef _SQUID_MSWIN_
-	if (sd_table[fd].write_handler) {
-	    FD_SET((SOCKET) fd, &write_mask);
-#else
 	if (fd_table[fd].write_handler) {
 	    FD_SET(fd, &write_mask);
-#endif
 	    if (fd > maxfd)
 		maxfd = fd;
 	}
@@ -575,20 +555,18 @@
     getCurrentTime();
 #endif
     Counter.syscalls.selects++;
+#ifdef _SQUID_MSWIN_
+    if (select(maxfd, &read_mask, &write_mask, &errfds, &zero_tv) < 1)
+#else
     if (select(maxfd, &read_mask, &write_mask, NULL, &zero_tv) < 1)
+#endif
 	return incame;
     for (i = 0; i < nfds; i++) {
 	fd = fds[i];
 	if (FD_ISSET(fd, &read_mask)) {
-#ifdef _SQUID_MSWIN_
-	    if ((hdl = sd_table[fd].read_handler) != NULL) {
-		sd_table[fd].read_handler = NULL;
-		commUpdateReadBitsS(fd, NULL);
-#else
 	    if ((hdl = fd_table[fd].read_handler) != NULL) {
 		fd_table[fd].read_handler = NULL;
 		commUpdateReadBits(fd, NULL);
-#endif
 		hdl(fd, &incame);
 	    } else {
 		debug(5, 1) ("comm_select_incoming: FD %d NULL read handler\n",
@@ -596,15 +574,9 @@
 	    }
 	}
 	if (FD_ISSET(fd, &write_mask)) {
-#ifdef _SQUID_MSWIN_
-	    if ((hdl = sd_table[fd].write_handler) != NULL) {
-		sd_table[fd].write_handler = NULL;
-		commUpdateWriteBitsS(fd, NULL);
-#else
 	    if ((hdl = fd_table[fd].write_handler) != NULL) {
 		fd_table[fd].write_handler = NULL;
 		commUpdateWriteBits(fd, NULL);
-#endif
 		hdl(fd, &incame);
 	    } else {
 		debug(5, 1) ("comm_select_incoming: FD %d NULL write handler\n",
@@ -687,12 +659,14 @@
     static time_t last_timeout = 0;
     struct timeval poll_time;
     double timeout = current_dtime + (msec / 1000.0);
-#ifdef _SQUID_MSWIN_
-    sde *F;
-#else
     fde *F;
     fd_set readfds;
     fd_set writefds;
+#ifdef _SQUID_MSWIN_
+    int no_bits;
+    fd_set errfds;
+    FD_ZERO(&errfds);
+#else
     int k;
     fd_mask *fdsp;
     fd_mask tmask;
@@ -717,23 +691,29 @@
 	callicp = calldns = callhttp = 0;
 	maxfd = Biggest_FD + 1;
 #ifdef _SQUID_MSWIN_
-	FD_ZERO(&readsds);
-	FD_ZERO(&writesds);
-	FD_ZERO(&errsds);
-	xmemcpy(&readsds, &global_readsds,sizeof(global_readsds));
-	xmemcpy(&writesds, &global_writesds,sizeof(global_writesds));
-	xmemcpy(&errsds, &global_writesds,sizeof(global_writesds));
-	for (j = 0; j < (int) readsds.fd_count; j++) {
-	    fd=readsds.fd_array[j];
+	xmemcpy(&readfds, &global_readfds, sizeof(global_readfds));
+	xmemcpy(&writefds, &global_writefds, sizeof(global_writefds));
+	for (j = 0; j < (int) readfds.fd_count; j++) {
+	    no_bits = 1;
+	    for ( fd = Biggest_FD; fd; fd-- ) {
+		if (_get_osfhandle(fd) == readfds.fd_array[j]) {
+		    if (fd_table[fd].flags.open) { 
+			no_bits = 0;
+			break;
+		    }
+		}
+	    }
+	    if (no_bits)
+	        continue;
 	    switch (commDeferRead(fd)) {
 	    case 0:
 		break;
 	    case 1:
-		FD_CLR((SOCKET) fd, &readsds);
+		FD_CLR(fd, &readfds);
 		break;
 #if DELAY_POOLS
 	    case -1:
-		FD_SET((SOCKET) fd, &slowfds);
+		FD_SET(fd, &slowfds);
 		break;
 #endif
 	    default:
@@ -788,17 +768,13 @@
 	    }
 	}
 #endif
-#ifdef _SQUID_MSWIN_
-	if (nreadsds + nwritesds == 0) {
-#else
 	if (nreadfds + nwritefds == 0) {
-#endif
 	    assert(shutting_down);
 	    return COMM_SHUTDOWN;
 	}
 	if (msec > MAX_POLL_TIME)
 	    msec = MAX_POLL_TIME;
-#if defined(_SQUID_OS2_) || defined(_SQUID_MSWIN_)
+#if defined(_SQUID_OS2_)
 	if (msec < 0)
 	    msec = MAX_POLL_TIME;
 #endif
@@ -807,22 +783,18 @@
 	    poll_time.tv_usec = (msec % 1000) * 1000;
 	    Counter.syscalls.selects++;
 #ifdef _SQUID_MSWIN_
-	    num = select(maxfd, &readsds, &writesds, &errsds, &poll_time);
+	    num = select(maxfd, &readfds, &writefds, &errfds, &poll_time);
 #else
 	    num = select(maxfd, &readfds, &writefds, NULL, &poll_time);
 #endif
-		Counter.select_loops++;
+	    Counter.select_loops++;
 	    if (num >= 0)
 		break;
 	    if (ignoreErrno(errno))
 		break;
 	    debug(50, 0) ("comm_select: select failure: %s\n",
 		xstrerror());
-#ifdef _SQUID_MSWIN_
-	    examine_select(&readsds, &writesds);
-#else
 	    examine_select(&readfds, &writefds);
-#endif
 	    return COMM_ERROR;
 	    /* NOTREACHED */
 	}
@@ -841,8 +813,19 @@
 	    continue;
 	/* Scan return fd masks for ready descriptors */
 #ifdef _SQUID_MSWIN_
-	for (j = 0; j < (int) readsds.fd_count; j++) {
-		fd=readsds.fd_array[j];
+	assert(readfds.fd_count <= (unsigned int) Biggest_FD);
+	for (j = 0; j < (int) readfds.fd_count; j++) {
+	    no_bits = 1;
+	    for ( fd = Biggest_FD; fd; fd-- ) {
+		if ( _get_osfhandle(fd) == readfds.fd_array[j] ) {
+		    if (fd_table[fd].flags.open) { 
+			no_bits = 0;
+			break;
+		    }
+		}
+	    }
+	    if (no_bits)
+	        continue;
 #else
 	fdsp = (fd_mask *) & readfds;
 	maxindex = howmany(maxfd, FD_MASK_BITS);
@@ -874,11 +857,7 @@
 		    callhttp = 1;
 		    continue;
 		}
-#ifdef _SQUID_MSWIN_
-		F = &sd_table[fd];
-#else
 		F = &fd_table[fd];
-#endif
 		debug(5, 6) ("comm_select: FD %d ready for reading\n", fd);
 		if (NULL == (hdl = F->read_handler))
 		    (void) 0;
@@ -888,11 +867,7 @@
 #endif
 		else {
 		    F->read_handler = NULL;
-#ifdef _SQUID_MSWIN_
-		    commUpdateReadBitsS(fd, NULL);
-#else
 		    commUpdateReadBits(fd, NULL);
-#endif
 		    hdl(fd, F->read_data);
 		    Counter.select_fds++;
 		    if (commCheckICPIncoming)
@@ -902,20 +877,39 @@
 		    if (commCheckHTTPIncoming)
 			comm_select_http_incoming();
 		}
-	}
+	    }
 #ifdef _SQUID_MSWIN_
-	for (j = 0; j < (int) errsds.fd_count; j++) {
-		fd=errsds.fd_array[j];
-		F = &sd_table[fd];
-		if ((hdl = F->write_handler)) {
+#if 1
+	    assert(errfds.fd_count <= (unsigned int) Biggest_FD);
+	    for (j = 0; j < (int) errfds.fd_count; j++) {
+		for ( fd = Biggest_FD; fd; fd-- ) {
+		    if ( _get_osfhandle(fd) == errfds.fd_array[j] )
+			break;
+		}
+		if (fd_table[fd].flags.open) { 
+		    F = &fd_table[fd];
+		    if ((hdl = F->write_handler)) {
 			F->write_handler = NULL;
-			commUpdateWriteBitsS(fd, NULL);
+			commUpdateWriteBits(fd, NULL);
 			hdl(fd, F->write_data);
 			Counter.select_fds++;
+		    }
 		}
-	}
-	for (j = 0; j < (int) writesds.fd_count; j++) {
-		fd=writesds.fd_array[j];
+	    }
+#endif
+	    assert(writefds.fd_count <= (unsigned int) Biggest_FD);
+	    for (j = 0; j < (int) writefds.fd_count; j++) {
+		no_bits = 1;
+		for ( fd = Biggest_FD; fd; fd-- ) {
+		    if ( _get_osfhandle(fd) == writefds.fd_array[j] ) {
+			if (fd_table[fd].flags.open) { 
+			    no_bits = 0;
+			    break;
+			}
+		    }
+		}
+		if (no_bits)
+		    continue;
 #else
 	}
 	fdsp = (fd_mask *) & writefds;
@@ -947,19 +941,11 @@
 		    callhttp = 1;
 		    continue;
 		}
-#ifdef _SQUID_MSWIN_
-		F = &sd_table[fd];
-#else
 		F = &fd_table[fd];
-#endif
 		debug(5, 5) ("comm_select: FD %d ready for writing\n", fd);
 		if ((hdl = F->write_handler)) {
 		    F->write_handler = NULL;
-#ifdef _SQUID_MSWIN_
-		    commUpdateWriteBitsS(fd, NULL);
-#else
 		    commUpdateWriteBits(fd, NULL);
-#endif
 		    hdl(fd, F->write_data);
 		    Counter.select_fds++;
 		    if (commCheckICPIncoming)
@@ -969,9 +955,9 @@
 		    if (commCheckHTTPIncoming)
 			comm_select_http_incoming();
 #ifndef _SQUID_MSWIN_
-	    }
-#endif
 		}
+#endif
+	    }
 	}
 	if (callicp)
 	    comm_select_icp_incoming();
@@ -981,11 +967,7 @@
 	    comm_select_http_incoming();
 #if DELAY_POOLS
 	while ((fd = commGetSlowFd()) != -1) {
-#ifdef _SQUID_MSWIN_
-		F = &sd_table[fd];
-#else
-		F = &fd_table[fd];
-#endif
+	    F = &fd_table[fd];
 	    debug(5, 6) ("comm_select: slow FD %d selected for reading\n", fd);
 	    if ((hdl = F->read_handler)) {
 		F->read_handler = NULL;
@@ -1080,9 +1062,9 @@
 	FD_ZERO(&write_x);
 	tv.tv_sec = tv.tv_usec = 0;
 	if (FD_ISSET(fd, readfds))
-	    FD_SET((SOCKET) fd, &read_x);
+	    FD_SET(fd, &read_x);
 	else if (FD_ISSET(fd, writefds))
-	    FD_SET((SOCKET) fd, &write_x);
+	    FD_SET(fd, &write_x);
 	else
 	    continue;
 	Counter.syscalls.selects++;
@@ -1114,8 +1096,8 @@
 	F->timeout_handler = NULL;
 	F->read_handler = NULL;
 	F->write_handler = NULL;
-	FD_CLR((SOCKET) fd, readfds);
-	FD_CLR((SOCKET) fd, writefds);
+	FD_CLR(fd, readfds);
+	FD_CLR(fd, writefds);
     }
     return 0;
 }
@@ -1125,42 +1107,10 @@
 checkTimeouts(void)
 {
     int fd;
-#ifdef _SQUID_MSWIN_
-    sde *F = NULL;
-    int	j;
-#else
     fde *F = NULL;
-#endif
     PF *callback;
-#ifdef _SQUID_MSWIN_
-    for (j = 0; j < (int) readsds.fd_count; j++) {
-	fd=readsds.fd_array[j];
-	F = &sd_table[fd];
-#else
     for (fd = 0; fd <= Biggest_FD; fd++) {
 	F = &fd_table[fd];
-#endif
-	if (!F->flags.open)
-	    continue;
-	if (F->timeout == 0)
-	    continue;
-	if (F->timeout > squid_curtime)
-	    continue;
-	debug(5, 5) ("checkTimeouts: FD %d Expired\n", fd);
-	if (F->timeout_handler) {
-	    debug(5, 5) ("checkTimeouts: FD %d: Call timeout handler\n", fd);
-	    callback = F->timeout_handler;
-	    F->timeout_handler = NULL;
-	    callback(fd, F->timeout_data);
-	} else {
-	    debug(5, 5) ("checkTimeouts: FD %d: Forcing comm_close()\n", fd);
-	    comm_close(fd);
-	}
-    }
-#ifdef _SQUID_MSWIN_
-    for (j = 0; j < (int) writesds.fd_count; j++) {
-	fd=writesds.fd_array[j];
-	F = &sd_table[fd];
 	if (!F->flags.open)
 	    continue;
 	if (F->timeout == 0)
@@ -1178,7 +1128,6 @@
 	    comm_close(fd);
 	}
     }
-#endif
 }
 
 static void
@@ -1213,40 +1162,15 @@
     statHistDump(&f->comm_http_incoming, sentry, statHistIntDumper);
 }
 
-#ifdef _SQUID_MSWIN_
-void
-commUpdateReadBitsS(int sd, PF * handler)
-{
-    if (handler && !FD_ISSET(sd, &global_readsds)) {
-	FD_SET((SOCKET) sd, &global_readsds);
-	nreadsds++;
-    } else if (!handler && FD_ISSET(sd, &global_readsds)) {
-	FD_CLR((SOCKET) sd, &global_readsds);
-	nreadsds--;
-    }
-}
-
-void
-commUpdateWriteBitsS(int sd, PF * handler)
-{
-    if (handler && !FD_ISSET(sd, &global_writesds)) {
-	FD_SET((SOCKET) sd, &global_writesds);
-	nwritesds++;
-    } else if (!handler && FD_ISSET(sd, &global_writesds)) {
-	FD_CLR((SOCKET) sd, &global_writesds);
-	nwritesds--;
-    }
-}
-#endif
 
 void
 commUpdateReadBits(int fd, PF * handler)
 {
     if (handler && !FD_ISSET(fd, &global_readfds)) {
-	FD_SET((SOCKET) fd, &global_readfds);
+	FD_SET(fd, &global_readfds);
 	nreadfds++;
     } else if (!handler && FD_ISSET(fd, &global_readfds)) {
-	FD_CLR((SOCKET) fd, &global_readfds);
+	FD_CLR(fd, &global_readfds);
 	nreadfds--;
     }
 }
@@ -1255,11 +1179,11 @@
 commUpdateWriteBits(int fd, PF * handler)
 {
     if (handler && !FD_ISSET(fd, &global_writefds)) {
-	FD_SET((SOCKET) fd, &global_writefds);
+	FD_SET(fd, &global_writefds);
 	nwritefds++;
     } else if (!handler && FD_ISSET(fd, &global_writefds)) {
-	FD_CLR((SOCKET) fd, &global_writefds);
+	FD_CLR(fd, &global_writefds);
 	nwritefds--;
     }
 }
-#endif COMM_SELECT_C
+#endif /* COMM_SELECT_C */
Index: squid/src/defines.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/defines.h,v
retrieving revision 1.1.1.3.4.2.2.6
retrieving revision 1.1.1.3.4.2.2.7
diff -u -r1.1.1.3.4.2.2.6 -r1.1.1.3.4.2.2.7
--- squid/src/defines.h	1 Nov 2001 17:31:07 -0000	1.1.1.3.4.2.2.6
+++ squid/src/defines.h	30 Apr 2002 17:21:49 -0000	1.1.1.3.4.2.2.7
@@ -1,6 +1,6 @@
 
 /*
- * $Id: defines.h,v 1.1.1.3.4.2.2.6 2001/11/01 17:31:07 serassio Exp $
+ * $Id: defines.h,v 1.1.1.3.4.2.2.7 2002/04/30 17:21:49 serassio Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -240,28 +240,16 @@
 /*
  * Max number of ICP messages to receive per call to icpHandleUdp
  */
-#ifdef _SQUID_MSWIN_
-#define INCOMING_ICP_MAX 1
-#else
 #define INCOMING_ICP_MAX 15
-#endif
 /*
  * Max number of DNS messages to receive per call to DNS read handler
  */
-#ifdef _SQUID_MSWIN_
-#define INCOMING_DNS_MAX 1
-#else
 #define INCOMING_DNS_MAX 15
-#endif
 /*
  * Max number of HTTP connections to accept per call to httpAccept
  * and PER HTTP PORT
  */
-#ifdef _SQUID_MSWIN_
-#define INCOMING_HTTP_MAX 1
-#else
 #define INCOMING_HTTP_MAX 10
-#endif
 #define INCOMING_TOTAL_MAX (INCOMING_ICP_MAX+INCOMING_HTTP_MAX)
 
 /*
Index: squid/src/delay_pools.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/delay_pools.c,v
retrieving revision 1.1.1.3.4.2.2.3
retrieving revision 1.1.1.3.4.2.2.4
diff -u -r1.1.1.3.4.2.2.3 -r1.1.1.3.4.2.2.4
--- squid/src/delay_pools.c	3 Feb 2002 15:15:35 -0000	1.1.1.3.4.2.2.3
+++ squid/src/delay_pools.c	30 Apr 2002 17:21:49 -0000	1.1.1.3.4.2.2.4
@@ -1,6 +1,6 @@
 
 /*
- * $Id: delay_pools.c,v 1.1.1.3.4.2.2.3 2002/02/03 15:15:35 serassio Exp $
+ * $Id: delay_pools.c,v 1.1.1.3.4.2.2.4 2002/04/30 17:21:49 serassio Exp $
  *
  * DEBUG: section 77    Delay Pools
  * AUTHOR: David Luyer <luyer@ucs.uwa.edu.au>
@@ -283,13 +283,13 @@
 void
 delaySetNoDelay(int fd)
 {
-    FD_SET((SOCKET) fd, &delay_no_delay);
+    FD_SET(fd, &delay_no_delay);
 }
 
 void
 delayClearNoDelay(int fd)
 {
-    FD_CLR((SOCKET) fd, &delay_no_delay);
+    FD_CLR(fd, &delay_no_delay);
 }
 
 int
Index: squid/src/disk.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/disk.c,v
retrieving revision 1.1.1.3.4.1.2.7
retrieving revision 1.1.1.3.4.1.2.8
diff -u -r1.1.1.3.4.1.2.7 -r1.1.1.3.4.1.2.8
--- squid/src/disk.c	8 Sep 2001 09:36:19 -0000	1.1.1.3.4.1.2.7
+++ squid/src/disk.c	30 Apr 2002 17:21:49 -0000	1.1.1.3.4.1.2.8
@@ -1,6 +1,6 @@
 
 /*
- * $Id: disk.c,v 1.1.1.3.4.1.2.7 2001/09/08 09:36:19 serassio Exp $
+ * $Id: disk.c,v 1.1.1.3.4.1.2.8 2002/04/30 17:21:49 serassio Exp $
  *
  * DEBUG: section 6     Disk I/O Routines
  * AUTHOR: Harvest Derived
@@ -61,8 +61,8 @@
 {
     int fd;
 #ifdef _SQUID_MSWIN_ 
-	char fmode[4]="";
-	FILE * fbuf;
+    char fmode[4]="";
+    FILE * fbuf;
 #endif
 
     if (mode & O_WRONLY)
@@ -78,7 +78,7 @@
 	}
 	else
 	    strcpy(fmode,"rb");
-	fbuf=fopen(path,fmode);
+    fbuf = fopen(path,fmode);
     fd = (fbuf != NULL) ? fileno(fbuf) : -1;
 #else
     mode |= SQUID_NONBLOCK;
@@ -436,26 +436,3 @@
     cbdataLock(client_data);
     diskHandleRead(fd, ctrl_dat);
 }
-
-#ifdef _SQUID_MSWIN_
-int
-ignoreErrno(int ierrno)
-{
-    switch (ierrno) {
-    case EINPROGRESS:
-    case EWOULDBLOCK:
-#if EAGAIN != EWOULDBLOCK
-    case EAGAIN:
-#endif
-    case EALREADY:
-    case EINTR:
-#ifdef ERESTART
-    case ERESTART:
-#endif
-	return 1;
-    default:
-	return 0;
-    }
-    /* NOTREACHED */
-}
-#endif
Index: squid/src/dns_internal.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/dns_internal.c,v
retrieving revision 1.1.1.1.4.6.2.9
retrieving revision 1.1.1.1.4.6.2.10
diff -u -r1.1.1.1.4.6.2.9 -r1.1.1.1.4.6.2.10
--- squid/src/dns_internal.c	27 Jan 2002 18:38:40 -0000	1.1.1.1.4.6.2.9
+++ squid/src/dns_internal.c	30 Apr 2002 17:21:49 -0000	1.1.1.1.4.6.2.10
@@ -1,6 +1,6 @@
 
 /*
- * $Id: dns_internal.c,v 1.1.1.1.4.6.2.9 2002/01/27 18:38:40 serassio Exp $
+ * $Id: dns_internal.c,v 1.1.1.1.4.6.2.10 2002/04/30 17:21:49 serassio Exp $
  *
  * DEBUG: section 78    DNS lookups; interacts with lib/rfc1035.c
  * AUTHOR: Duane Wessels
@@ -390,11 +390,7 @@
 	q->sz);
     if (x < 0) {
 	debug(50, 1) ("idnsSendQuery: FD %d: sendto: %s\n",
-#ifdef _SQUID_MSWIN_
-	    DnsSocket, wsastrerror(errno));
-#else
 	    DnsSocket, xstrerror());
-#endif
     } else {
 	fd_bytes(DnsSocket, x, FD_WRITE);
 	commSetSelect(DnsSocket, COMM_SELECT_READ, idnsRead, NULL, 0);
@@ -510,11 +506,7 @@
 	    if (errno != ECONNREFUSED && errno != EHOSTUNREACH)
 #endif
 		debug(50, 1) ("idnsRead: FD %d recvfrom: %s\n",
-#ifdef _SQUID_MSWIN_
-		    fd, wsastrerror(WSAGetLastError()));
-#else
 		    fd, xstrerror());
-#endif
 	    break;
 	}
 	fd_bytes(DnsSocket, len, FD_READ);
Index: squid/src/errorpage.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/errorpage.c,v
retrieving revision 1.1.1.3.4.3.2.3
retrieving revision 1.1.1.3.4.3.2.4
diff -u -r1.1.1.3.4.3.2.3 -r1.1.1.3.4.3.2.4
--- squid/src/errorpage.c	6 Jan 2002 13:48:40 -0000	1.1.1.3.4.3.2.3
+++ squid/src/errorpage.c	30 Apr 2002 17:21:49 -0000	1.1.1.3.4.3.2.4
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.c,v 1.1.1.3.4.3.2.3 2002/01/06 13:48:40 serassio Exp $
+ * $Id: errorpage.c,v 1.1.1.3.4.3.2.4 2002/04/30 17:21:49 serassio Exp $
  *
  * DEBUG: section 4     Error Generation
  * AUTHOR: Duane Wessels
@@ -440,11 +440,7 @@
 	break;
     case 'E':
 	if (err->xerrno)
-#ifdef _SQUID_MSWIN_
-	    memBufPrintf(&mb, "%s", wsastrerror(err->xerrno));
-#else
 	    memBufPrintf(&mb, "(%d) %s", err->xerrno, strerror(err->xerrno));
-#endif
 	else
 	    memBufPrintf(&mb, "[No Error]");
 	break;
Index: squid/src/fd.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/fd.c,v
retrieving revision 1.1.1.3.4.1.2.6
retrieving revision 1.1.1.3.4.1.2.7
diff -u -r1.1.1.3.4.1.2.6 -r1.1.1.3.4.1.2.7
--- squid/src/fd.c	23 Feb 2002 21:41:03 -0000	1.1.1.3.4.1.2.6
+++ squid/src/fd.c	30 Apr 2002 17:21:49 -0000	1.1.1.3.4.1.2.7
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fd.c,v 1.1.1.3.4.1.2.6 2002/02/23 21:41:03 serassio Exp $
+ * $Id: fd.c,v 1.1.1.3.4.1.2.7 2002/04/30 17:21:49 serassio Exp $
  *
  * DEBUG: section 51    Filedescriptor Functions
  * AUTHOR: Duane Wessels
@@ -45,99 +45,6 @@
     "Unknown"
 };
 
-#ifdef _SQUID_MSWIN_
-static void
-sdUpdateBiggest(int fd,  int opening)
-{
-    if (fd < Biggest_SD)
-	return;
-    assert(fd < Squid_MaxFD);
-    if (fd > Biggest_SD) {
-	/*
-	 * assert that we are not closing a FD bigger than
-	 * our known biggest FD
-	 */
-	assert(opening);
-	Biggest_SD = fd;
-	return;
-    }
-    /* if we are here, then fd == Biggest_FD */
-    /*
-     * assert that we are closing the biggest FD; we can't be
-     * re-opening it
-     */
-    assert(!opening);
-    while (!sd_table[Biggest_SD].flags.open && Biggest_SD)
-	Biggest_SD--;
-    debug(51, 2) ("sdUpdateBiggest: %d\n",Biggest_SD);
-}
-
-void
-sd_close(int fd)
-{
-    sde *F = &sd_table[fd];
-    if (F->type == FD_FILE) {
-	assert(F->read_handler == NULL);
-	assert(F->write_handler == NULL);
-    }
-    debug(51, 3) ("sd_close FD %d %s\n", fd, F->desc);
-    F->flags.open = 0;
-    sdUpdateBiggest(fd, 0);
-    Number_SD--;
-    commUpdateReadBitsS(fd, NULL);
-    commUpdateWriteBitsS(fd, NULL);
-    memset(F, '\0', sizeof(sde));
-    F->timeout = 0;
-}
-
-void
-sd_open(int fd, unsigned int type, const char *desc)
-{
-    sde *F;
-    assert(fd >= 0);
-    F = &sd_table[fd];
-#if USE_ASYNC_IO
-    if (F->flags.closing) {
-	/* Reuse of a closed FD before we have noticed it is closed */
-	sd_close(fd);
-    }
-#endif
-    if (F->flags.open) {
-	debug(51, 1) ("WARNING: Closing open SD %4d\n", fd);
-	sd_close(fd);
-    }
-    assert(!F->flags.open);
-    debug(51, 3) ("sd_open SD %d %s\n", fd, desc);
-    F->type = type;
-    F->flags.open = 1;
-    sdUpdateBiggest(fd, 1);
-    if (desc)
-	xstrncpy(F->desc, desc, FD_DESC_SZ);
-    Number_SD++;
-}
-
-void
-sd_note(int fd, const char *s)
-{
-    sde *F = &sd_table[fd];
-    xstrncpy(F->desc, s, FD_DESC_SZ);
-}
-
-void
-sd_bytes(int fd, int len, unsigned int type)
-{
-    sde *F = &sd_table[fd];
-    if (len < 0)
-	return;
-    assert(type == FD_READ || type == FD_WRITE);
-    if (type == FD_READ)
-	F->bytes_read += len;
-    else
-	F->bytes_written += len;
-}
-
-#endif
-
 static void fdUpdateBiggest(int fd, int);
 
 static void
@@ -161,11 +68,7 @@
      * re-opening it
      */
     assert(!opening);
-#ifdef _SQUID_MSWIN_
-    while (!fd_table[Biggest_FD].flags.open && Biggest_FD)
-#else
     while (!fd_table[Biggest_FD].flags.open)
-#endif
 	Biggest_FD--;
 }
 
@@ -237,9 +140,6 @@
 fdFreeMemory(void)
 {
     safe_free(fd_table);
-#ifdef _SQUID_MSWIN_
-    safe_free(sd_table);
-#endif
 }
 
 void
Index: squid/src/forward.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/forward.c,v
retrieving revision 1.1.1.3.4.1.2.6
retrieving revision 1.1.1.3.4.1.2.7
diff -u -r1.1.1.3.4.1.2.6 -r1.1.1.3.4.1.2.7
--- squid/src/forward.c	10 Feb 2002 17:55:56 -0000	1.1.1.3.4.1.2.6
+++ squid/src/forward.c	30 Apr 2002 17:21:49 -0000	1.1.1.3.4.1.2.7
@@ -1,6 +1,6 @@
 
 /*
- * $Id: forward.c,v 1.1.1.3.4.1.2.6 2002/02/10 17:55:56 serassio Exp $
+ * $Id: forward.c,v 1.1.1.3.4.1.2.7 2002/04/30 17:21:49 serassio Exp $
  *
  * DEBUG: section 17    Request Forwarding
  * AUTHOR: Duane Wessels
@@ -439,16 +439,6 @@
 	    return;
 	}
     }
-    if (check_offline()) {
-	/*
-	 * Check if we're in offline mode
-	 */
-	err = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE);
-	err->request = requestLink(r);
-	err->src_addr = r->client_addr;
-	errorAppendEntry(e, err);
-	return;
-    }
     debug(17, 3) ("fwdStart: '%s'\n", storeUrl(e));
     e->mem_obj->request = requestLink(r);
     e->mem_obj->fd = fd;
Index: squid/src/fqdncache.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/fqdncache.c,v
retrieving revision 1.1.1.3.4.1.2.2
retrieving revision 1.1.1.3.4.1.2.3
diff -u -r1.1.1.3.4.1.2.2 -r1.1.1.3.4.1.2.3
--- squid/src/fqdncache.c	10 Feb 2002 17:55:57 -0000	1.1.1.3.4.1.2.2
+++ squid/src/fqdncache.c	30 Apr 2002 17:21:49 -0000	1.1.1.3.4.1.2.3
@@ -1,7 +1,7 @@
 
 
 /*
- * $Id: fqdncache.c,v 1.1.1.3.4.1.2.2 2002/02/10 17:55:57 serassio Exp $
+ * $Id: fqdncache.c,v 1.1.1.3.4.1.2.3 2002/04/30 17:21:49 serassio Exp $
  *
  * DEBUG: section 35    FQDN Cache
  * AUTHOR: Harvest Derived
@@ -123,8 +123,6 @@
 static int
 fqdncacheExpiredEntry(const fqdncache_entry * f)
 {
-    if(check_offline())
-	return 0; /* In offline mode, don't expire cached entries */
     if (f->status == FQDN_PENDING)
 	return 0;
     if (f->status == FQDN_DISPATCHED)
@@ -199,10 +197,7 @@
     if (hp)
 	fqdncacheAddHostent(f, hp);
     f->status = status;
-    if(check_offline())
-	f->lastref = 0;	/* Expires instantly when we go online */
-    else
-	f->lastref = squid_curtime;
+    f->lastref = squid_curtime;
     return f;
 }
 
@@ -391,15 +386,6 @@
     }
     if (f == NULL) {
 	/* MISS: No entry, create the new one */
-	if(check_offline())
-	{
-	    struct hostent he={ (char *)name,NULL,0,0,NULL};
-	    /* Fake it */
-	    f = fqdncacheAddNew(name,&he,FQDN_CACHED);
-	    fqdncacheAddPending(f, handler, handlerData);
-	    fqdncache_call_pending(f);
-	    return;
-	}
 	debug(35, 5) ("fqdncache_nbgethostbyaddr: MISS for '%s'\n", name);
 	FqdncacheStats.misses++;
 	f = fqdncacheAddNew(name, NULL, FQDN_PENDING);
Index: squid/src/ftp.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/ftp.c,v
retrieving revision 1.1.1.3.4.3.2.9
retrieving revision 1.1.1.3.4.3.2.10
diff -u -r1.1.1.3.4.3.2.9 -r1.1.1.3.4.3.2.10
--- squid/src/ftp.c	3 Mar 2002 10:39:43 -0000	1.1.1.3.4.3.2.9
+++ squid/src/ftp.c	30 Apr 2002 17:21:49 -0000	1.1.1.3.4.3.2.10
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.c,v 1.1.1.3.4.3.2.9 2002/03/03 10:39:43 serassio Exp $
+ * $Id: ftp.c,v 1.1.1.3.4.3.2.10 2002/04/30 17:21:49 serassio Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -880,11 +880,7 @@
 #endif
     memset(ftpState->data.buf + ftpState->data.offset, '\0', read_sz);
     Counter.syscalls.sock.reads++;
-#ifdef _SQUID_MSWIN_
-    len = recv(fd, ftpState->data.buf + ftpState->data.offset, read_sz);
-#else
     len = read(fd, ftpState->data.buf + ftpState->data.offset, read_sz);
-#endif
     if (len > 0) {
 	fd_bytes(fd, len, FD_READ);
 #if DELAY_POOLS
@@ -1248,15 +1244,9 @@
     }
     assert(ftpState->ctrl.offset < ftpState->ctrl.size);
     Counter.syscalls.sock.reads++;
-#ifdef _SQUID_MSWIN_
-    len = recv(fd,
-	ftpState->ctrl.buf + ftpState->ctrl.offset,
-	ftpState->ctrl.size - ftpState->ctrl.offset);
-#else
     len = read(fd,
 	ftpState->ctrl.buf + ftpState->ctrl.offset,
 	ftpState->ctrl.size - ftpState->ctrl.offset);
-#endif
     if (len > 0) {
 	fd_bytes(fd, len, FD_READ);
 	kb_incr(&Counter.server.all.kbytes_in, len);
Index: squid/src/globals.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/globals.h,v
retrieving revision 1.1.1.3.4.2.2.6
retrieving revision 1.1.1.3.4.2.2.7
diff -u -r1.1.1.3.4.2.2.6 -r1.1.1.3.4.2.2.7
--- squid/src/globals.h	6 Jan 2002 11:00:05 -0000	1.1.1.3.4.2.2.6
+++ squid/src/globals.h	30 Apr 2002 17:21:50 -0000	1.1.1.3.4.2.2.7
@@ -1,6 +1,6 @@
 
 /*
- * $Id: globals.h,v 1.1.1.3.4.2.2.6 2002/01/06 11:00:05 serassio Exp $
+ * $Id: globals.h,v 1.1.1.3.4.2.2.7 2002/04/30 17:21:50 serassio Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -63,11 +63,6 @@
 extern const char *storeStatusStr[];
 extern const char *swapStatusStr[];
 extern dnsStatData DnsStats;
-#ifdef _SQUID_MSWIN_
-extern sde *sd_table;		/* NULL */
-extern int Biggest_SD;		/* 0 */
-extern int Number_SD;		/* 0 */
-#endif
 extern fde *fd_table;		/* NULL */
 extern int Biggest_FD;		/* -1 */
 extern int Number_FD;		/* 0 */
Index: squid/src/gopher.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/gopher.c,v
retrieving revision 1.1.1.3.4.2.2.2
retrieving revision 1.1.1.3.4.2.2.3
diff -u -r1.1.1.3.4.2.2.2 -r1.1.1.3.4.2.2.3
--- squid/src/gopher.c	10 Sep 2001 20:25:56 -0000	1.1.1.3.4.2.2.2
+++ squid/src/gopher.c	30 Apr 2002 17:21:50 -0000	1.1.1.3.4.2.2.3
@@ -1,7 +1,7 @@
 
 
 /*
- * $Id: gopher.c,v 1.1.1.3.4.2.2.2 2001/09/10 20:25:56 serassio Exp $
+ * $Id: gopher.c,v 1.1.1.3.4.2.2.3 2002/04/30 17:21:50 serassio Exp $
  *
  * DEBUG: section 10    Gopher
  * AUTHOR: Harvest Derived
@@ -614,11 +614,7 @@
 #endif
     /* leave one space for \0 in gopherToHTML */
     Counter.syscalls.sock.reads++;
-#ifdef _SQUID_MSWIN_
-    len = recv(fd, buf, read_sz);
-#else
     len = read(fd, buf, read_sz);
-#endif
     if (len > 0) {
 	fd_bytes(fd, len, FD_READ);
 #if DELAY_POOLS
Index: squid/src/helper.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/helper.c,v
retrieving revision 1.1.1.3.24.1
retrieving revision 1.1.1.3.24.2
diff -u -r1.1.1.3.24.1 -r1.1.1.3.24.2
--- squid/src/helper.c	6 Jan 2001 12:40:14 -0000	1.1.1.3.24.1
+++ squid/src/helper.c	30 Apr 2002 17:21:50 -0000	1.1.1.3.24.2
@@ -253,11 +253,7 @@
     assert(fd == srv->rfd);
     assert(cbdataValid(data));
     Counter.syscalls.sock.reads++;
-#ifdef _SQUID_MSWIN_
-    len = recv(fd, srv->buf + srv->offset, srv->buf_sz - srv->offset);
-#else
     len = read(fd, srv->buf + srv->offset, srv->buf_sz - srv->offset);
-#endif
     fd_bytes(fd, len, FD_READ);
     debug(29, 5) ("helperHandleRead: %d bytes from %s #%d.\n",
 	len, hlp->id_name, srv->index + 1);
Index: squid/src/http.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/http.c,v
retrieving revision 1.1.1.3.4.3.2.4
retrieving revision 1.1.1.3.4.3.2.5
diff -u -r1.1.1.3.4.3.2.4 -r1.1.1.3.4.3.2.5
--- squid/src/http.c	10 Sep 2001 20:25:56 -0000	1.1.1.3.4.3.2.4
+++ squid/src/http.c	30 Apr 2002 17:21:50 -0000	1.1.1.3.4.3.2.5
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.c,v 1.1.1.3.4.3.2.4 2001/09/10 20:25:56 serassio Exp $
+ * $Id: http.c,v 1.1.1.3.4.3.2.5 2002/04/30 17:21:50 serassio Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -479,12 +479,7 @@
     read_sz = delayBytesWanted(delay_id, 1, read_sz);
 #endif
     Counter.syscalls.sock.reads++;
-#ifdef _SQUID_MSWIN_
-    len = recv(fd, buf, read_sz);
-    errno = WSAGetLastError();
-#else
     len = read(fd, buf, read_sz);
-#endif
     debug(11, 5) ("httpReadReply: FD %d: len %d.\n", fd, len);
     if (len > 0) {
 	fd_bytes(fd, len, FD_READ);
@@ -511,11 +506,7 @@
     }
     if (len < 0) {
 	debug(50, 2) ("httpReadReply: FD %d: read failure: %s.\n",
-#ifdef _SQUID_MSWIN_
 	    fd, xstrerror());
-#else
-	    fd, wsastrerror(errno));
-#endif
 	if (ignoreErrno(errno)) {
 	    commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0);
 	} else if (entry->mem_obj->inmem_hi == 0) {
@@ -859,11 +850,7 @@
 	cfd = -1;
     else
 	cfd = entry->mem_obj->fd;
-#ifdef _SQUID_MSWIN_
-    assert(-1 == cfd || FD_SOCKET == sd_table[cfd].type);
-#else
     assert(-1 == cfd || FD_SOCKET == fd_table[cfd].type);
-#endif
     if (p != NULL)
 	httpState->flags.proxying = 1;
     /*
Index: squid/src/ident.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/ident.c,v
retrieving revision 1.1.1.3.4.1.2.4
retrieving revision 1.1.1.3.4.1.2.5
diff -u -r1.1.1.3.4.1.2.4 -r1.1.1.3.4.1.2.5
--- squid/src/ident.c	27 Jan 2002 18:38:41 -0000	1.1.1.3.4.1.2.4
+++ squid/src/ident.c	30 Apr 2002 17:21:50 -0000	1.1.1.3.4.1.2.5
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ident.c,v 1.1.1.3.4.1.2.4 2002/01/27 18:38:41 serassio Exp $
+ * $Id: ident.c,v 1.1.1.3.4.1.2.5 2002/04/30 17:21:50 serassio Exp $
  *
  * DEBUG: section 30    Ident (RFC 931)
  * AUTHOR: Duane Wessels
@@ -140,11 +140,7 @@
     int len = -1;
     buf[0] = '\0';
     Counter.syscalls.sock.reads++;
-#ifdef _SQUID_MSWIN_
-    len = recv(fd, buf, BUFSIZ - 1);
-#else
     len = read(fd, buf, BUFSIZ - 1);
-#endif
     fd_bytes(fd, len, FD_READ);
     if (len <= 0) {
 	comm_close(fd);
Index: squid/src/ipcache.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/ipcache.c,v
retrieving revision 1.1.1.3.4.1.2.2
retrieving revision 1.1.1.3.4.1.2.3
diff -u -r1.1.1.3.4.1.2.2 -r1.1.1.3.4.1.2.3
--- squid/src/ipcache.c	10 Feb 2002 17:55:57 -0000	1.1.1.3.4.1.2.2
+++ squid/src/ipcache.c	30 Apr 2002 17:21:50 -0000	1.1.1.3.4.1.2.3
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ipcache.c,v 1.1.1.3.4.1.2.2 2002/02/10 17:55:57 serassio Exp $
+ * $Id: ipcache.c,v 1.1.1.3.4.1.2.3 2002/04/30 17:21:50 serassio Exp $
  *
  * DEBUG: section 14    IP Cache
  * AUTHOR: Harvest Derived
@@ -148,8 +148,6 @@
 static int
 ipcacheExpiredEntry(ipcache_entry * i)
 {
-    if(check_offline())
-	return 0; /* In offline mode, don't expire cached entries */
     if (i->status == IP_PENDING)
 	return 0;
     if (i->status == IP_DISPATCHED)
@@ -209,9 +207,8 @@
     int k;
     safe_free(i->addrs.in_addrs);
     safe_free(i->addrs.bad_mask);
-    if(hp->h_addr_list)
-	while ((addr_count < 255) && *(hp->h_addr_list + addr_count))
-	    ++addr_count;
+    while ((addr_count < 255) && *(hp->h_addr_list + addr_count))
+	++addr_count;
     i->addrs.count = (unsigned char) addr_count;
     i->addrs.in_addrs = xcalloc(addr_count, sizeof(struct in_addr));
     i->addrs.bad_mask = xcalloc(addr_count, sizeof(unsigned char));
@@ -235,10 +232,7 @@
     if (hp)
 	ipcacheAddHostent(i, hp);
     i->status = status;
-    if(check_offline())
-	i->lastref = 0; /* Expires instantly when we go online */
-    else
-	i->lastref = squid_curtime;
+    i->lastref = squid_curtime;
     return i;
 }
 
@@ -466,17 +460,6 @@
     }
     if (i == NULL) {
 	/* MISS: No entry, create the new one */
-	if(check_offline())
-	{
-	    struct hostent he={ (char *)name,NULL,0,0,NULL};
-	    /* Not permitted to look it up in offline mode */
-	    debug(14, 5) ("ipcache_nbgethostbyname: OFFLINE! Will not look it up\n");
-	    /* Fake it */
-	    i = ipcacheAddNew(name, &he, IP_CACHED);
-	    ipcacheAddPending(i, handler, handlerData);
-	    ipcache_call_pending(i);
-	    return;
-	}
 	debug(14, 5) ("ipcache_nbgethostbyname: MISS for '%s'\n", name);
 	IpcacheStats.misses++;
 	i = ipcacheAddNew(name, NULL, IP_PENDING);
Index: squid/src/main.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/main.c,v
retrieving revision 1.1.1.3.4.2.2.14
retrieving revision 1.1.1.3.4.2.2.15
diff -u -r1.1.1.3.4.2.2.14 -r1.1.1.3.4.2.2.15
--- squid/src/main.c	6 Apr 2002 17:37:39 -0000	1.1.1.3.4.2.2.14
+++ squid/src/main.c	30 Apr 2002 17:21:50 -0000	1.1.1.3.4.2.2.15
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.c,v 1.1.1.3.4.2.2.14 2002/04/06 17:37:39 serassio Exp $
+ * $Id: main.c,v 1.1.1.3.4.2.2.15 2002/04/30 17:21:50 serassio Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -804,11 +804,7 @@
     comm_init();
     comm_select_init();
 
-#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
-    if ((WIN32_run_mode == _WIN_SQUID_RUN_MODE_INTERACTIVE) && (opt_no_daemon)) {
-#else
     if (opt_no_daemon) {
-#endif
 	/* we have to init fdstat here. */
 	fd_open(0, FD_LOG, "stdin");
 	fd_open(1, FD_LOG, "stdout");
@@ -1076,11 +1072,7 @@
     errorClean();
 #endif
 #if !XMALLOC_TRACE
-#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
-    if ((WIN32_run_mode == _WIN_SQUID_RUN_MODE_INTERACTIVE) && (opt_no_daemon)) {
-#else
     if (opt_no_daemon) {
-#endif
 	file_close(0);
 	file_close(1);
 	file_close(2);
Index: squid/src/pconn.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/pconn.c,v
retrieving revision 1.1.1.2.4.1.2.1
retrieving revision 1.1.1.2.4.1.2.2
diff -u -r1.1.1.2.4.1.2.1 -r1.1.1.2.4.1.2.2
--- squid/src/pconn.c	6 Jan 2001 12:40:15 -0000	1.1.1.2.4.1.2.1
+++ squid/src/pconn.c	30 Apr 2002 17:21:50 -0000	1.1.1.2.4.1.2.2
@@ -1,6 +1,6 @@
 
 /*
- * $Id: pconn.c,v 1.1.1.2.4.1.2.1 2001/01/06 12:40:15 hno Exp $
+ * $Id: pconn.c,v 1.1.1.2.4.1.2.2 2002/04/30 17:21:50 serassio Exp $
  *
  * DEBUG: section 48    Persistent Connections
  * AUTHOR: Duane Wessels
@@ -120,11 +120,7 @@
     int n;
     assert(table != NULL);
     Counter.syscalls.sock.reads++;
-#ifdef _SQUID_MSWIN_
-    n = recv(fd, buf, 256);
-#else
     n = read(fd, buf, 256);
-#endif
     debug(48, 3) ("pconnRead: %d bytes from FD %d, %s\n", n, fd, p->key);
     pconnRemoveFD(p, fd);
     comm_close(fd);
Index: squid/src/protos.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/protos.h,v
retrieving revision 1.1.1.3.4.1.2.12
retrieving revision 1.1.1.3.4.1.2.13
diff -u -r1.1.1.3.4.1.2.12 -r1.1.1.3.4.1.2.13
--- squid/src/protos.h	23 Feb 2002 21:41:03 -0000	1.1.1.3.4.1.2.12
+++ squid/src/protos.h	30 Apr 2002 17:21:50 -0000	1.1.1.3.4.1.2.13
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.1.1.3.4.1.2.12 2002/02/23 21:41:03 serassio Exp $
+ * $Id: protos.h,v 1.1.1.3.4.1.2.13 2002/04/30 17:21:50 serassio Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -167,9 +167,6 @@
 extern void commCallCloseHandlers(int fd);
 extern int commSetTimeout(int fd, int, PF *, void *);
 extern void commSetDefer(int fd, DEFER * func, void *);
-#ifdef _SQUID_MSWIN_
-extern int WSAignoreErrno(int);
-#endif
 extern int ignoreErrno(int);
 extern void commCloseAllSockets(void);
 
@@ -183,10 +180,6 @@
 #else
 extern int comm_select(int);
 #endif
-#ifdef _SQUID_MSWIN_
-extern void commUpdateReadBitsS(int, PF *);
-extern void commUpdateWriteBitsS(int, PF *);
-#endif
 extern void commUpdateReadBits(int, PF *);
 extern void commUpdateWriteBits(int, PF *);
 
@@ -1112,8 +1105,6 @@
 extern int stringHasCntl(const char *);
 extern void linklistPush(link_list **, void *);
 extern void *linklistShift(link_list **);
-extern int check_offline(void);
-
 #if USE_HTCP
 extern void htcpInit(void);
 extern void htcpQuery(StoreEntry * e, request_t * req, peer * p);
Index: squid/src/pump.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/Attic/pump.c,v
retrieving revision 1.1.1.3.4.1.2.1
retrieving revision 1.1.1.3.4.1.2.2
diff -u -r1.1.1.3.4.1.2.1 -r1.1.1.3.4.1.2.2
--- squid/src/pump.c	6 Jan 2001 12:40:15 -0000	1.1.1.3.4.1.2.1
+++ squid/src/pump.c	30 Apr 2002 17:21:50 -0000	1.1.1.3.4.1.2.2
@@ -1,5 +1,5 @@
 /*
- * $Id: pump.c,v 1.1.1.3.4.1.2.1 2001/01/06 12:40:15 hno Exp $
+ * $Id: pump.c,v 1.1.1.3.4.1.2.2 2002/04/30 17:21:50 serassio Exp $
  *
  * DEBUG: section 61    PUMP handler
  * AUTHOR: Kostas Anagnostakis
@@ -241,11 +241,7 @@
     int len = 0;
     errno = 0;
     Counter.syscalls.sock.reads++;
-#ifdef _SQUID_MSWIN_
-    len = recv(fd, buf, bytes_to_read);
-#else
     len = read(fd, buf, bytes_to_read);
-#endif
     fd_bytes(fd, len, FD_READ);
     debug(61, 5) ("pumpReadFromClient: FD %d: len %d.\n", fd, len);
     if (len > 0) {
Index: squid/src/refresh.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/refresh.c,v
retrieving revision 1.1.1.3.4.1.2.3
retrieving revision 1.1.1.3.4.1.2.4
diff -u -r1.1.1.3.4.1.2.3 -r1.1.1.3.4.1.2.4
--- squid/src/refresh.c	10 Feb 2002 17:55:57 -0000	1.1.1.3.4.1.2.3
+++ squid/src/refresh.c	30 Apr 2002 17:21:50 -0000	1.1.1.3.4.1.2.4
@@ -1,7 +1,7 @@
 
 
 /*
- * $Id: refresh.c,v 1.1.1.3.4.1.2.3 2002/02/10 17:55:57 serassio Exp $
+ * $Id: refresh.c,v 1.1.1.3.4.1.2.4 2002/04/30 17:21:50 serassio Exp $
  *
  * DEBUG: section 22    Refresh Calculation
  * AUTHOR: Harvest Derived
@@ -289,8 +289,6 @@
 int
 refreshCheckHTTP(const StoreEntry * entry, request_t * request)
 {
-    if(check_offline())
-	return 0;	/* If we're offline, we're always fresh */
     return refreshCheck(entry, request, 0, &refreshCounts[rcHTTP]);
 }
 
Index: squid/src/ssl.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/ssl.c,v
retrieving revision 1.1.1.3.4.1.2.4
retrieving revision 1.1.1.3.4.1.2.5
diff -u -r1.1.1.3.4.1.2.4 -r1.1.1.3.4.1.2.5
--- squid/src/ssl.c	27 Jan 2002 18:38:41 -0000	1.1.1.3.4.1.2.4
+++ squid/src/ssl.c	30 Apr 2002 17:21:50 -0000	1.1.1.3.4.1.2.5
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ssl.c,v 1.1.1.3.4.1.2.4 2002/01/27 18:38:41 serassio Exp $
+ * $Id: ssl.c,v 1.1.1.3.4.1.2.5 2002/04/30 17:21:50 serassio Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -199,11 +199,7 @@
     read_sz = delayBytesWanted(sslState->delay_id, 1, read_sz);
 #endif
     Counter.syscalls.sock.reads++;
-#ifdef _SQUID_MSWIN_
-    len = recv(fd, sslState->server.buf + sslState->server.len, read_sz);
-#else
     len = read(fd, sslState->server.buf + sslState->server.len, read_sz);
-#endif
     debug(26, 3) ("sslReadServer: FD %d, read   %d bytes\n", fd, len);
     if (len > 0) {
 	fd_bytes(fd, len, FD_READ);
@@ -239,13 +235,9 @@
 	fd, SQUID_TCP_SO_RCVBUF - sslState->client.len,
 	sslState->client.len);
     Counter.syscalls.sock.reads++;
-#ifdef _SQUID_MSWIN_
-    len = recv(fd, sslState->client.buf + sslState->client.len, SQUID_TCP_SO_RCVBUF - sslState->client.len);
-#else
     len = read(fd,
 	sslState->client.buf + sslState->client.len,
 	SQUID_TCP_SO_RCVBUF - sslState->client.len);
-#endif
     debug(26, 3) ("sslReadClient: FD %d, read   %d bytes\n", fd, len);
     if (len > 0) {
 	fd_bytes(fd, len, FD_READ);
@@ -254,13 +246,8 @@
     }
     cbdataLock(sslState);
     if (len < 0) {
-#ifdef _SQUID_MSWIN_
-	debug(50, WSAECONNRESET == WSAGetLastError() ? 3 : 1) ("sslReadClient: FD %d: read failure: %s\n",
-	    fd, xstrerror());
-#else
 	debug(50, ECONNRESET == errno ? 3 : 1) ("sslReadClient: FD %d: read failure: %s\n",
 	    fd, xstrerror());
-#endif
 	if (!ignoreErrno(errno))
 	    comm_close(fd);
     } else if (len == 0) {
@@ -281,13 +268,9 @@
     debug(26, 3) ("sslWriteServer: FD %d, %d bytes to write\n",
 	fd, sslState->client.len);
     Counter.syscalls.sock.writes++;
-#ifdef _SQUID_MSWIN_
-    len = send(fd,sslState->client.buf,sslState->client.len);
-#else
     len = write(fd,
 	sslState->client.buf,
 	sslState->client.len);
-#endif
     debug(26, 3) ("sslWriteServer: FD %d, %d bytes written\n", fd, len);
     if (len > 0) {
 	fd_bytes(fd, len, FD_WRITE);
@@ -324,13 +307,9 @@
     debug(26, 3) ("sslWriteClient: FD %d, %d bytes to write\n",
 	fd, sslState->server.len);
     Counter.syscalls.sock.writes++;
-#ifdef _SQUID_MSWIN_
-    len = send(fd, sslState->server.buf, sslState->server.len);
-#else
     len = write(fd, 
 	sslState->server.buf,
 	sslState->server.len);
-#endif
     debug(26, 3) ("sslWriteClient: FD %d, %d bytes written\n", fd, len);
     if (len > 0) {
 	fd_bytes(fd, len, FD_WRITE);
Index: squid/src/stat.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/stat.c,v
retrieving revision 1.1.1.3.4.1.2.7
retrieving revision 1.1.1.3.4.1.2.8
diff -u -r1.1.1.3.4.1.2.7 -r1.1.1.3.4.1.2.8
--- squid/src/stat.c	17 Feb 2002 08:57:57 -0000	1.1.1.3.4.1.2.7
+++ squid/src/stat.c	30 Apr 2002 17:21:51 -0000	1.1.1.3.4.1.2.8
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.c,v 1.1.1.3.4.1.2.7 2002/02/17 08:57:57 serassio Exp $
+ * $Id: stat.c,v 1.1.1.3.4.1.2.8 2002/04/30 17:21:51 serassio Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -391,18 +391,6 @@
 }
 #endif
 
-#ifdef _SQUID_MSWIN_
-static const char *
-sdRemoteAddr(const sde * f)
-{
-    LOCAL_ARRAY(char, buf, 32);
-    if (f->type != FD_SOCKET)
-	return null_string;
-    snprintf(buf, 32, "%s.%d", f->ipaddr, (int) f->remote_port);
-    return buf;
-}
-#endif
-
 static const char *
 fdRemoteAddr(const fde * f)
 {
@@ -418,9 +406,6 @@
 {
     int i;
     fde *f;
-#ifdef _SQUID_MSWIN_
-    sde *s;
-#endif
     storeAppendPrintf(sentry, "Active file descriptors:\n");
     storeAppendPrintf(sentry, "%-4s %-6s %-4s %-7s* %-7s* %-21s %s\n",
 	"File",
@@ -446,23 +431,6 @@
 	    fdRemoteAddr(f),
 	    f->desc);
     }
-#ifdef _SQUID_MSWIN_
-    for (i = 0; i < Squid_MaxFD; i++) {
-	s = &sd_table[i];
-	if (!s->flags.open)
-	    continue;
-	storeAppendPrintf(sentry, "%4d %-6.6s %4d %7d%c %7d%c %-21s %s\n",
-	    i,
-	    fdTypeStr[s->type],
-	    s->timeout_handler ? (int) (s->timeout - squid_curtime) / 60 : 0,
-	    s->bytes_read,
-	    s->read_handler ? '*' : ' ',
-	    s->bytes_written,
-	    s->write_handler ? '*' : ' ',
-	    sdRemoteAddr(s),
-	    s->desc);
-    }
-#endif
 }
 
 static void
@@ -643,15 +611,6 @@
 	RESERVED_FD);
     storeAppendPrintf(sentry, "\tStore Disk files open:                %4d\n",
 	store_open_disk_fd);
-#ifdef _SQUID_MSWIN_
-    storeAppendPrintf(sentry, "Socket descriptor usage for %s:\n", appname);
-    storeAppendPrintf(sentry, "\tMaximum number of socket descriptors:   %4d\n",
-	Squid_MaxFD);
-    storeAppendPrintf(sentry, "\tLargest socket desc currently in use:   %4d\n",
-	Biggest_SD);
-    storeAppendPrintf(sentry, "\tNumber of socket desc currently in use: %4d\n",
-	Number_SD);
-#endif
     storeAppendPrintf(sentry, "Internal Data Structures:\n");
     storeAppendPrintf(sentry, "\t%6d StoreEntries\n",
 	memInUse(MEM_STOREENTRY));
Index: squid/src/structs.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/structs.h,v
retrieving revision 1.1.1.3.4.2.2.7
retrieving revision 1.1.1.3.4.2.2.8
diff -u -r1.1.1.3.4.2.2.7 -r1.1.1.3.4.2.2.8
--- squid/src/structs.h	10 Feb 2002 17:55:57 -0000	1.1.1.3.4.2.2.7
+++ squid/src/structs.h	30 Apr 2002 17:21:51 -0000	1.1.1.3.4.2.2.8
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.1.1.3.4.2.2.7 2002/02/10 17:55:57 serassio Exp $
+ * $Id: structs.h,v 1.1.1.3.4.2.2.8 2002/04/30 17:21:51 serassio Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -406,6 +406,7 @@
 #if HTTP_VIOLATIONS
 	int reload_into_ims;
 #endif
+	int offline;
 	int redir_rewrites_host;
 	int prefer_direct;
 	int strip_query_terms;
@@ -419,8 +420,6 @@
 	int log_redirected_url;
 	int ie_refresh;
     } onoff;
-    int offline;
-    char *network_interface;
     acl *aclList;
     struct {
 	acl_access *http;
@@ -565,52 +564,13 @@
     const char *str;		/* quoted-string */
     int weak;			/* true if it is a weak validator */
 };
-#ifdef _SQUID_MSWIN_
-struct _sde {
-    unsigned int type;
-    u_short local_port;
-    u_short remote_port;
-    char ipaddr[16];		/* dotted decimal address of peer */
-    char desc[FD_DESC_SZ];
-    struct {
-	unsigned int open:1;
-	unsigned int close_request:1;
-	unsigned int write_daemon:1;
-	unsigned int closing:1;
-	unsigned int socket_eof:1;
-	unsigned int nolinger:1;
-	unsigned int nonblocking:1;
-	unsigned int ipc:1;
-	unsigned int called_connect:1;
-#ifdef OPTIMISTIC_IO
-	unsigned int calling_io_handler:1;
-#endif
-    } flags;
-    int bytes_read;
-    int bytes_written;
-    int uses;			/* ie # req's over persistent conn */
-    PF *read_handler;
-    void *read_data;
-    PF *write_handler;
-    void *write_data;
-    PF *timeout_handler;
-    time_t timeout;
-    void *timeout_data;
-    void *lifetime_data;
-    close_handler *close_handler;	/* linked list */
-    DEFER *defer_check;		/* check if we should defer read */
-    void *defer_data;
-    CommWriteStateData *rwstate;	/* State data for comm_write */
-};
-#endif
-
 
 struct _fde {
     unsigned int type;
     u_short local_port;
     u_short remote_port;
 #ifdef _SQUID_MSWIN_
-	FILE * fbuf;
+    FILE * fbuf;
 #endif
     char ipaddr[16];		/* dotted decimal address of peer */
     char desc[FD_DESC_SZ];
Index: squid/src/tools.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/tools.c,v
retrieving revision 1.1.1.3.4.1.2.16
retrieving revision 1.1.1.3.4.1.2.17
diff -u -r1.1.1.3.4.1.2.16 -r1.1.1.3.4.1.2.17
--- squid/src/tools.c	23 Feb 2002 21:41:03 -0000	1.1.1.3.4.1.2.16
+++ squid/src/tools.c	30 Apr 2002 17:21:51 -0000	1.1.1.3.4.1.2.17
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.c,v 1.1.1.3.4.1.2.16 2002/02/23 21:41:03 serassio Exp $
+ * $Id: tools.c,v 1.1.1.3.4.1.2.17 2002/04/30 17:21:51 serassio Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -63,24 +63,12 @@
     /* Release the main ports as early as possible */
     for (i = 0; i < NHttpSockets; i++) {
 	if (HttpSockets[i] >= 0)
-#ifdef _SQUID_MSWIN_
-	    closesocket(HttpSockets[i]);
-#else
 	    close(HttpSockets[i]);
-#endif
     }
     if (theInIcpConnection >= 0)
-#ifdef _SQUID_MSWIN_
-	closesocket(theInIcpConnection);
-#else
 	close(theInIcpConnection);
-#endif
     if (theOutIcpConnection >= 0 && theOutIcpConnection != theInIcpConnection)
-#ifdef _SQUID_MSWIN_
-	closesocket(theOutIcpConnection);
-#else
 	close(theOutIcpConnection);
-#endif
 }
 
 static char *
@@ -913,68 +901,3 @@
     }
     return 0;
 }
-
-#ifndef _SQUID_MSWIN_ 
-#include <net/if.h>
-#include <sys/ioctl.h>
-
-/* int is_interface_down(const char *interface_name)
- *
- * returns 0 if the interface exists and is UP
- * returns 1 if the interface is down, does not exist or there is an
- *     error trying to create a datagram socket to query interface status
- */
-int
-is_interface_down(const char *interface_name)
-{
-    int r,sockfd;
-    struct ifreq ifr;
-
-    sockfd = socket(AF_INET, SOCK_DGRAM, 0);
-    if (sockfd < 0)
-    {
-	return 1; /* Cannot create a socket.
-	             I guess we can assume that the network is
-                     nil operandum */
-    }
-    strncpy(ifr.ifr_name, interface_name, IFNAMSIZ);
-    ifr.ifr_name[IFNAMSIZ-1] = '\0';
-    if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) == -1)
-    {
-	close(sockfd);
-	return 1;       /* Interface probably doesn't exist */
-    }
-    if ((ifr.ifr_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
-	r=1; /* Down */
-    else
-	r=0; /* UP */
-
-    close(sockfd);
-    return r;
-}
-#endif
-
-/*
- * int check_offline(void)
- * Returns 0 if offline_mode is 0.
- * Returns 0 if offline_mode is 1 and the network_interface is up.
- * Returns 1 if offline_mode is 1 and the network_interface is down.
- * Returns 1 if offline_mode is 2.
- */
-int
-check_offline(void)
-{
-    static time_t last_checked=0;
-    static int    last_status=0;
-    time_t now;
-
-    /* Only check once per 5 second or so. */
-    time(&now);
-    if(now<=last_checked)
-	return last_status;
-    last_checked=now+5;
-    if(Config.offline!=1)
-	return Config.offline;
-    last_status=is_interface_down(Config.network_interface);
-    return last_status;
-}
Index: squid/src/typedefs.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v
retrieving revision 1.1.1.3.4.1.2.3
retrieving revision 1.1.1.3.4.1.2.4
diff -u -r1.1.1.3.4.1.2.3 -r1.1.1.3.4.1.2.4
--- squid/src/typedefs.h	14 Jun 2001 20:36:16 -0000	1.1.1.3.4.1.2.3
+++ squid/src/typedefs.h	30 Apr 2002 17:21:51 -0000	1.1.1.3.4.1.2.4
@@ -1,6 +1,6 @@
 
 /*
- * $Id: typedefs.h,v 1.1.1.3.4.1.2.3 2001/06/14 20:36:16 serassio Exp $
+ * $Id: typedefs.h,v 1.1.1.3.4.1.2.4 2002/04/30 17:21:51 serassio Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -81,9 +81,6 @@
 typedef struct _dwrite_q dwrite_q;
 typedef struct _ETag ETag;
 typedef struct _fde fde;
-#ifdef _SQUID_MSWIN_
-typedef struct _sde sde;
-#endif
 typedef struct _fileMap fileMap;
 typedef struct _fqdncache_entry fqdncache_entry;
 typedef struct _fqdn_pending fqdn_pending;
Index: squid/src/wais.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/wais.c,v
retrieving revision 1.1.1.2.4.1.2.1
retrieving revision 1.1.1.2.4.1.2.2
diff -u -r1.1.1.2.4.1.2.1 -r1.1.1.2.4.1.2.2
--- squid/src/wais.c	6 Jan 2001 12:40:17 -0000	1.1.1.2.4.1.2.1
+++ squid/src/wais.c	30 Apr 2002 17:21:51 -0000	1.1.1.2.4.1.2.2
@@ -1,6 +1,6 @@
 
 /*
- * $Id: wais.c,v 1.1.1.2.4.1.2.1 2001/01/06 12:40:17 hno Exp $
+ * $Id: wais.c,v 1.1.1.2.4.1.2.2 2002/04/30 17:21:51 serassio Exp $
  *
  * DEBUG: section 24    WAIS Relay
  * AUTHOR: Harvest Derived
@@ -103,11 +103,7 @@
     read_sz = delayBytesWanted(delay_id, 1, read_sz);
 #endif
     Counter.syscalls.sock.reads++;
-#ifdef _SQUID_MSWIN_
-    len = recv(fd, buf, read_sz);
-#else
     len = read(fd, buf, read_sz);
-#endif
     if (len > 0) {
 	fd_bytes(fd, len, FD_READ);
 #if DELAY_POOLS
Index: squid/src/win32.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/win32.c,v
retrieving revision 1.1.2.15
retrieving revision 1.1.2.16
diff -u -r1.1.2.15 -r1.1.2.16
--- squid/src/win32.c	6 Apr 2002 17:37:39 -0000	1.1.2.15
+++ squid/src/win32.c	30 Apr 2002 17:21:51 -0000	1.1.2.16
@@ -374,7 +374,7 @@
 	WIN32_build_argv(WIN32_Service_Command_Line);
 	*argc = WIN32_argc;
 	*argv = WIN32_argv;
-	/* Set Service Staus to SERVICE_START_PENDING */
+	/* Set Service Status to SERVICE_START_PENDING */
 	svcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
 	svcStatus.dwCurrentState = SERVICE_START_PENDING;
 	svcStatus.dwControlsAccepted =
Index: squid/win/cf_gen/cf_gen.dsp
===================================================================
RCS file: /cvsroot/squid-sf//squid/win/cf_gen/Attic/cf_gen.dsp,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- squid/win/cf_gen/cf_gen.dsp	3 Feb 2002 15:28:51 -0000	1.1.2.3
+++ squid/win/cf_gen/cf_gen.dsp	30 Apr 2002 17:21:51 -0000	1.1.2.4
@@ -94,6 +94,10 @@
 # Begin Group "Header Files"
 
 # PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\include\config.h
+# End Source File
 # End Group
 # Begin Group "Resource Files"
 
Index: squid/win/squidnt/squidnt.dsp
===================================================================
RCS file: /cvsroot/squid-sf//squid/win/squidnt/Attic/squidnt.dsp,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- squid/win/squidnt/squidnt.dsp	16 Feb 2002 18:20:32 -0000	1.1.2.9
+++ squid/win/squidnt/squidnt.dsp	30 Apr 2002 17:21:51 -0000	1.1.2.10
@@ -51,7 +51,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 ws2_32.lib advapi32.lib psapi.lib Iphlpapi.lib /nologo /subsystem:console /machine:I386 /out:"Release/squid.exe"
+# ADD LINK32 ws2_32.lib advapi32.lib psapi.lib /nologo /subsystem:console /machine:I386 /out:"Release/squid.exe"
 # SUBTRACT LINK32 /profile
 # Begin Special Build Tool
 SOURCE="$(InputPath)"
@@ -82,7 +82,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 winwrap.lib kernel32.lib ws2_32.lib advapi32.lib psapi.lib Iphlpapi.lib /nologo /subsystem:console /debug /machine:I386 /out:"Debug/squid.exe" /pdbtype:sept
+# ADD LINK32 winwrap.lib kernel32.lib ws2_32.lib advapi32.lib psapi.lib /nologo /subsystem:console /debug /machine:I386 /out:"Debug/squid.exe" /pdbtype:sept
 # SUBTRACT LINK32 /profile
 # Begin Special Build Tool
 SOURCE="$(InputPath)"
