Index: src/client_side_reply.cc =================================================================== RCS file: /cvsroot/squid/squid3/src/client_side_reply.cc,v retrieving revision 1.29 diff -u -p -r1.29 client_side_reply.cc --- src/client_side_reply.cc 16 Mar 2003 03:14:01 -0000 1.29 +++ src/client_side_reply.cc 6 Apr 2003 12:46:18 -0000 @@ -139,7 +139,8 @@ clientReplyContext::operator new (size_t void clientReplyContext::operator delete (void *address) { - cbdataFree (address); + clientReplyContext * tmp = (clientReplyContext *)address; + cbdataFree (tmp); } void Index: src/comm.cc =================================================================== RCS file: /cvsroot/squid/squid3/src/comm.cc,v retrieving revision 1.24 diff -u -p -r1.24 comm.cc --- src/comm.cc 11 Mar 2003 03:16:28 -0000 1.24 +++ src/comm.cc 6 Apr 2003 12:46:19 -0000 @@ -1186,7 +1186,12 @@ comm_openex(int sock_type, if (port > (u_short) 0) { - commSetNoLinger(new_socket); +#ifdef _SQUID_MSWIN_ + + if (sock_type != SOCK_DGRAM) +#endif + + commSetNoLinger(new_socket); if (opt_reuseaddr) commSetReuseAddr(new_socket); @@ -1952,19 +1957,22 @@ commSetTcpRcvbuf(int fd, int size) int commSetNonBlocking(int fd) { +#ifndef _SQUID_MSWIN_ int flags; int dummy = 0; -#ifdef _SQUID_CYGWIN_ +#endif +#if defined (_SQUID_CYGWIN_) || defined (_SQUID_MSWIN_) int nonblocking = TRUE; if (fd_table[fd].type != FD_PIPE) { if (ioctl(fd, FIONBIO, &nonblocking) < 0) { - debug(50, 0) ("commSetNonBlocking: FD %d: %s %D\n", fd, xstrerror(), fd_table[fd].type); + debug(50, 0) ("commSetNonBlocking: FD %d: %s %d\n", fd, xstrerror(), fd_table[fd].type); return COMM_ERROR; } } else { #endif +#ifndef _SQUID_MSWIN_ if ((flags = fcntl(fd, F_GETFL, dummy)) < 0) { debug(50, 0) ("FD %d: fcntl F_GETFL: %s\n", fd, xstrerror()); @@ -1976,7 +1984,8 @@ commSetNonBlocking(int fd) return COMM_ERROR; } -#ifdef _SQUID_CYGWIN_ +#endif +#if defined (_SQUID_CYGWIN_) || defined (_SQUID_MSWIN_) } @@ -1989,6 +1998,11 @@ commSetNonBlocking(int fd) int commUnsetNonBlocking(int fd) { +#ifdef _SQUID_MSWIN_ + int nonblocking = FALSE; + + if (ioctlsocket(fd, FIONBIO, (unsigned long *) &nonblocking) < 0) { +#else int flags; int dummy = 0; @@ -1998,6 +2012,7 @@ commUnsetNonBlocking(int fd) } if (fcntl(fd, F_SETFL, flags & (~SQUID_NONBLOCK)) < 0) { +#endif debug(50, 0) ("commUnsetNonBlocking: FD %d: %s\n", fd, xstrerror()); return COMM_ERROR; } Index: src/defines.h =================================================================== RCS file: /cvsroot/squid/squid3/src/defines.h,v retrieving revision 1.6 diff -u -p -r1.6 defines.h --- src/defines.h 23 Jan 2003 03:14:42 -0000 1.6 +++ src/defines.h 6 Apr 2003 12:46:19 -0000 @@ -310,4 +310,20 @@ #endif #define HTTP_REQBUF_SZ 4096 + +/* CygWin & Windows NT Port */ +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) +#define _WIN_SQUID_SERVICE_CONTROL_STOP SERVICE_CONTROL_STOP +#define _WIN_SQUID_SERVICE_CONTROL_SHUTDOWN SERVICE_CONTROL_SHUTDOWN +#define _WIN_SQUID_SERVICE_CONTROL_INTERROGATE SERVICE_CONTROL_INTERROGATE +#define _WIN_SQUID_SERVICE_CONTROL_ROTATE 128 +#define _WIN_SQUID_SERVICE_CONTROL_RECONFIGURE 129 +#define _WIN_SQUID_SERVICE_CONTROL_DEBUG 130 +#define _WIN_SQUID_SERVICE_CONTROL_INTERRUPT 131 +#define _WIN_SQUID_DEFAULT_SERVICE_NAME "SquidNT" +#define _WIN_SQUID_SERVICE_OPTION "--ntservice" +#define _WIN_SQUID_RUN_MODE_INTERACTIVE 0 +#define _WIN_SQUID_RUN_MODE_SERVICE 1 +#endif + #endif /* SQUID_DEFINES_H */ Index: src/globals.h =================================================================== RCS file: /cvsroot/squid/squid3/src/globals.h,v retrieving revision 1.10 diff -u -p -r1.10 globals.h --- src/globals.h 26 Feb 2003 03:15:46 -0000 1.10 +++ src/globals.h 6 Apr 2003 12:46:20 -0000 @@ -157,9 +157,19 @@ extern ssize_t store_maxobjsize; /* -1 * extern RemovalPolicy *mem_policy; extern hash_table *proxy_auth_username_cache; /* NULL */ extern int incoming_sockets_accepted; +#ifdef _SQUID_MSWIN_ +extern unsigned int WIN32_Socks_initialized; /* 0 */ +#endif #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) extern unsigned int WIN32_OS_version; /* 0 */ -extern char *WIN32_OS_string; /* NULL */ +extern char *WIN32_OS_string; /* NULL */ +extern char *WIN32_Service_name; /* NULL */ +extern char *WIN32_Command_Line; /* NULL */ +extern char *WIN32_Service_Command_Line; /* NULL */ +extern unsigned int WIN32_run_mode; /* _WIN_SQUID_RUN_MODE_INTERACTIVE */ +#if defined(_SQUID_MSWIN_) && defined(_DEBUG) +extern int do_debug; /* 0 */ +#endif #endif #if HAVE_SBRK extern void *sbrk_start; /* 0 */ Index: src/main.cc =================================================================== RCS file: /cvsroot/squid/squid3/src/main.cc,v retrieving revision 1.16 diff -u -p -r1.16 main.cc --- src/main.cc 26 Feb 2003 03:15:47 -0000 1.16 +++ src/main.cc 6 Apr 2003 12:46:22 -0000 @@ -306,10 +306,12 @@ static void rotate_logs(int sig) { do_rotate = 1; +#ifndef _SQUID_MSWIN_ #if !HAVE_SIGACTION signal(sig, rotate_logs); #endif +#endif } /* ARGSUSED */ @@ -317,16 +319,19 @@ static void reconfigure(int sig) { do_reconfigure = 1; +#ifndef _SQUID_MSWIN_ #if !HAVE_SIGACTION signal(sig, reconfigure); #endif +#endif } void shut_down(int sig) { do_shutdown = sig == SIGINT ? -1 : 1; +#ifndef _SQUID_MSWIN_ #ifdef KILL_PARENT_OPT if (getppid() > 1) { @@ -343,6 +348,7 @@ shut_down(int sig) signal(SIGINT, SIG_DFL); #endif +#endif } static void @@ -1001,6 +1007,7 @@ sendSignal(void) exit(0); } +#ifndef _SQUID_MSWIN_ /* * This function is run when Squid is in daemon mode, just * before the parent forks and starts up the child process. @@ -1043,6 +1050,8 @@ mainStartScript(const char *prog) } } +#endif /* _SQUID_MSWIN_ */ + static int checkRunningPid(void) { @@ -1064,6 +1073,7 @@ checkRunningPid(void) static void watch_child(char *argv[]) { +#ifndef _SQUID_MSWIN_ char *prog; int failcount = 0; time_t start; @@ -1200,6 +1210,7 @@ watch_child(char *argv[]) } /* NOTREACHED */ +#endif /* _SQUID_MSWIN_ */ } static void Index: src/net_db.cc =================================================================== RCS file: /cvsroot/squid/squid3/src/net_db.cc,v retrieving revision 1.8 diff -u -p -r1.8 net_db.cc --- src/net_db.cc 7 Mar 2003 03:13:28 -0000 1.8 +++ src/net_db.cc 6 Apr 2003 12:46:22 -0000 @@ -528,7 +528,13 @@ netdbReloadState(void) * Solaris bugs, its a bad idea. fopen can fail if more than * 256 FDs are open. */ +#ifdef _SQUID_MSWIN_ + + fd = file_open(path, O_RDONLY | O_BINARY); +#else + fd = file_open(path, O_RDONLY | O_TEXT); +#endif if (fd < 0) return; Index: src/protos.h =================================================================== RCS file: /cvsroot/squid/squid3/src/protos.h,v retrieving revision 1.25 diff -u -p -r1.25 protos.h --- src/protos.h 16 Mar 2003 03:14:04 -0000 1.25 +++ src/protos.h 6 Apr 2003 12:46:26 -0000 @@ -1068,8 +1068,20 @@ SQUIDCEXTERN int varyEvaluateMatch(Store /* CygWin & Windows NT Port */ /* win32.c */ #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) +#ifdef USE_WIN32_SERVICE +SQUIDCEXTERN int WIN32_Subsystem_Init(int *, char ***); +#else SQUIDCEXTERN int WIN32_Subsystem_Init(void); +#endif +SQUIDCEXTERN void WIN32_sendSignal(int); +SQUIDCEXTERN void WIN32_Abort(int); SQUIDCEXTERN void WIN32_Exit(void); +SQUIDCEXTERN void WIN32_SetServiceCommandLine(void); +SQUIDCEXTERN void WIN32_InstallService(void); +SQUIDCEXTERN void WIN32_RemoveService(void); +#endif +#ifdef _SQUID_MSWIN_ +SQUIDCEXTERN int WIN32_getrusage(int, struct rusage *); #endif /* external_acl.c */ Index: src/squid.h =================================================================== RCS file: /cvsroot/squid/squid3/src/squid.h,v retrieving revision 1.8 diff -u -p -r1.8 squid.h --- src/squid.h 11 Mar 2003 03:16:30 -0000 1.8 +++ src/squid.h 6 Apr 2003 12:46:26 -0000 @@ -368,6 +368,7 @@ extern "C" template inline A const & +#ifndef min min(A const & lhs, A const & rhs) { if (rhs < lhs) @@ -375,8 +376,10 @@ min(A const & lhs, A const & rhs) return lhs; } +#endif #define XMIN(x,y) (min (x,y)) +#ifndef max template inline A const & max(A const & lhs, A const & rhs) @@ -386,6 +389,7 @@ max(A const & lhs, A const & rhs) return lhs; } +#endif #define XMAX(a,b) (max (a,b)) Index: src/tools.cc =================================================================== RCS file: /cvsroot/squid/squid3/src/tools.cc,v retrieving revision 1.8 diff -u -p -r1.8 tools.cc --- src/tools.cc 22 Feb 2003 03:14:36 -0000 1.8 +++ src/tools.cc 6 Apr 2003 12:46:26 -0000 @@ -375,6 +375,11 @@ death(int sig) void sigusr2_handle(int sig) { +#if defined(_SQUID_MSWIN_) && defined(_DEBUG) + do_debug = 1; +#endif +#if (defined(_SQUID_MSWIN_) && !defined(_DEBUG)) || !defined(_SQUID_MSWIN_) + static int state = 0; /* no debug() here; bad things happen if the signal is delivered during _db_print() */ @@ -398,6 +403,7 @@ sigusr2_handle(int sig) state = 0; } +#endif #if !HAVE_SIGACTION signal(sig, sigusr2_handle); /* reinstall */ @@ -502,6 +508,7 @@ debug_trap(const char *message) { void sig_child(int sig) { +#ifndef _SQUID_MSWIN_ #ifdef _SQUID_NEXT_ union wait status; #else @@ -532,6 +539,7 @@ sig_child(int sig) { ; signal(sig, sig_child); +#endif #endif }