WIN32_ALL_SOURCE = \
win32.cc \
+ WinSvc.h \
WinSvc.cc
if ENABLE_WIN32SPECIFIC
WIN32_SOURCE = win32.cc
-
/*
- * $Id$
- *
* Windows support
* AUTHOR: Guido Serassio <serassio@squid-cache.org>
* inspired by previous work by Romeo Anghelache & Eric Stern.
*/
#include "squid.h"
+#include "protos.h"
#include "squid_windows.h"
#if _SQUID_MSWIN_
#endif
#endif
+/* forward declarations */
+static void WIN32_Exit(void);
+static void WIN32_Abort(int);
+
static unsigned int GetOSVersion();
void WIN32_svcstatusupdate(DWORD, DWORD);
void WINAPI WIN32_svcHandler(DWORD);
#endif
extern "C" void WINAPI SquidWinSvcMain(DWORD, char **);
-#if _SQUID_MSWIN_
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
void Squid_Win32InvalidParameterHandler(const wchar_t*, const wchar_t*, const wchar_t*, unsigned int, uintptr_t);
#endif
void WIN32_ExceptionHandlerCleanup(void);
static int s_iInitCount = 0;
static HANDLE NotifyAddrChange_thread = INVALID_HANDLE_VALUE;
-#endif /* _SQUID_MSWIN_ */
static int Squid_Aborting = 0;
WIN32_Exit();
}
-#if _SQUID_MSWIN_
void
WIN32_IpAddrChangeMonitorExit()
{
CloseHandle(NotifyAddrChange_thread);
}
}
-#endif
void
WIN32_Exit()
{
-#if _SQUID_MSWIN_
Win32SockCleanup();
-#endif
#if USE_WIN32_SERVICE
if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) {
}
#endif
-#if _SQUID_MSWIN_
if (dbg_mutex)
DeleteCriticalSection(dbg_mutex);
WIN32_ExceptionHandlerCleanup();
WIN32_IpAddrChangeMonitorExit();
-
-#endif
-
_exit(0);
}
-#if _SQUID_MSWIN_
static DWORD WINAPI
WIN32_IpAddrChangeMonitor(LPVOID lpParam)
{
}
return status;
}
-#endif /* _SQUID_MSWIN_ */
int WIN32_Subsystem_Init(int * argc, char *** argv)
{
svcStatus.dwCheckPoint = 0;
svcStatus.dwWaitHint = 10000;
SetServiceStatus(svcHandle, &svcStatus);
-#if _SQUID_MSWIN_
_setmaxstdio(Squid_MaxFD);
-#endif
}
#endif /* USE_WIN32_SERVICE */
-#if _SQUID_MSWIN_
if (Win32SockInit() < 0)
return 1;
-#endif
-
return 0;
}
}
} else {
WIN32_run_mode = _WIN_SQUID_RUN_MODE_INTERACTIVE;
-#if _SQUID_MSWIN_
-
opt_no_daemon = 1;
-#endif
-
return SquidMain(argc, argv);
}
#endif /* USE_WIN32_SERVICE */
-#if _SQUID_MSWIN_
static int Win32SockInit(void)
{
int iVersionRequested;
{
return;
}
-
-#endif /* SQUID_MSWIN_ */
--- /dev/null
+#ifndef WINSVC_H_
+#define WINSVC_H_
+/*
+ * DEBUG: none
+ * AUTHOR: Guido Serassio <serassio@squid-cache.org>
+ *
+ * SQUID Web Proxy Cache http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ * 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.
+ *
+ */
+
+#if _SQUID_WINDOWS_
+extern int WIN32_Subsystem_Init(int *, char ***);
+extern void WIN32_sendSignal(int);
+extern void WIN32_SetServiceCommandLine(void);
+extern void WIN32_InstallService(void);
+extern void WIN32_RemoveService(void);
+extern int SquidMain(int, char **);
+#else /* _SQUID_WINDOWS_ */
+inline int WIN32_Subsystem_Init(int *foo, char ***bar) {return 0; } /* NOP */
+inline void WIN32_sendSignal(int foo) { return; } /* NOP */
+inline void WIN32_SetServiceCommandLine(void) {} /* NOP */
+inline void WIN32_InstallService(void) {} /* NOP */
+inline void WIN32_RemoveService(void) {} /* NOP */
+#endif /* _SQUID_WINDOWS_ */
+
+
+
+
+#endif /* WINSVC_H_ */
#include "URL.h"
#include "wccp.h"
#include "wccp2.h"
+#include "WinSvc.h"
#if USE_ADAPTATION
#include "adaptation/Config.h"
{
ConfigureCurrentKid(argv[0]);
-#if _SQUID_WINDOWS_
- int WIN32_init_err;
-#endif
-
#if HAVE_SBRK
-
sbrk_start = sbrk(0);
#endif
#endif
-#if _SQUID_WINDOWS_
+ /* NOP under non-windows */
+ int WIN32_init_err=0;
if ((WIN32_init_err = WIN32_Subsystem_Init(&argc, &argv)))
return WIN32_init_err;
-#endif
/* call mallopt() before anything else */
#if HAVE_MALLOPT
if (pid > 1) {
#if USE_WIN32_SERVICE
-
if (opt_signal_service) {
WIN32_sendSignal(opt_send_signal);
exit(0);
- } else
-#if _SQUID_MSWIN_
- {
+ } else {
fprintf(stderr, "%s: ERROR: Could not send ", APP_SHORTNAME);
fprintf(stderr, "signal to Squid Service:\n");
fprintf(stderr, "missing -n command line switch.\n");
exit(1);
}
-
/* NOTREACHED */
-#endif
-
#endif
if (kill(pid, opt_send_signal) &&
extern void rotate_logs(int);
extern void reconfigure(int);
- /* CygWin & Windows NT Port */
- /* win32.c */
-#if _SQUID_WINDOWS_
- SQUIDCEXTERN int WIN32_Subsystem_Init(int *, char ***);
- 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);
- SQUIDCEXTERN int SquidMain(int, char **);
-#endif /* _SQUID_WINDOWS_ */
#if _SQUID_MSWIN_
SQUIDCEXTERN int WIN32_pipe(int[2]);