]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Moved Win32-service specific prototypes to own header
authorFrancesco Chemolli <kinkie@squid-cache.org>
Sat, 1 Sep 2012 10:40:00 +0000 (12:40 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Sat, 1 Sep 2012 10:40:00 +0000 (12:40 +0200)
src/Makefile.am
src/WinSvc.cc
src/WinSvc.h [new file with mode: 0644]
src/main.cc
src/protos.h

index e1633b0a2111f2c189fc76b980c1098749a36664..3ba1d71eba2d85cd96bc1aae72bff1cefc46bf94 100644 (file)
@@ -147,6 +147,7 @@ endif
 
 WIN32_ALL_SOURCE = \
        win32.cc \
+       WinSvc.h \
        WinSvc.cc
 if ENABLE_WIN32SPECIFIC
 WIN32_SOURCE = win32.cc
index 6d8303853a46d6be96d83bd1d6145fc7af30ba72..9f8ba5a56e1a16b09e4ab9cf65d8c46e3570a7ac 100644 (file)
@@ -1,7 +1,4 @@
-
 /*
- * $Id$
- *
  * Windows support
  * AUTHOR: Guido Serassio <serassio@squid-cache.org>
  * inspired by previous work by Romeo Anghelache & Eric Stern.
@@ -35,6 +32,7 @@
  */
 
 #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);
@@ -57,7 +59,6 @@ static void WIN32_build_argv (char *);
 #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
@@ -67,7 +68,6 @@ SQUIDCEXTERN LPCRITICAL_SECTION dbg_mutex;
 void WIN32_ExceptionHandlerCleanup(void);
 static int s_iInitCount = 0;
 static HANDLE NotifyAddrChange_thread = INVALID_HANDLE_VALUE;
-#endif /* _SQUID_MSWIN_ */
 
 static int Squid_Aborting = 0;
 
@@ -401,7 +401,6 @@ WIN32_Abort(int sig)
     WIN32_Exit();
 }
 
-#if _SQUID_MSWIN_
 void
 WIN32_IpAddrChangeMonitorExit()
 {
@@ -412,14 +411,11 @@ 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) {
@@ -430,19 +426,14 @@ WIN32_Exit()
     }
 
 #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)
 {
@@ -484,7 +475,6 @@ WIN32_IpAddrChangeMonitorInit()
     }
     return status;
 }
-#endif /* _SQUID_MSWIN_ */
 
 int WIN32_Subsystem_Init(int * argc, char *** argv)
 {
@@ -580,20 +570,15 @@ 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;
 }
 
@@ -964,12 +949,8 @@ int main(int argc, char **argv)
         }
     } else {
         WIN32_run_mode = _WIN_SQUID_RUN_MODE_INTERACTIVE;
-#if _SQUID_MSWIN_
-
         opt_no_daemon = 1;
 
-#endif
-
         return SquidMain(argc, argv);
     }
 
@@ -978,7 +959,6 @@ int main(int argc, char **argv)
 
 #endif /* USE_WIN32_SERVICE */
 
-#if _SQUID_MSWIN_
 static int Win32SockInit(void)
 {
     int iVersionRequested;
@@ -1042,5 +1022,3 @@ void Squid_Win32InvalidParameterHandler(const wchar_t* expression, const wchar_t
 {
     return;
 }
-
-#endif /* SQUID_MSWIN_ */
diff --git a/src/WinSvc.h b/src/WinSvc.h
new file mode 100644 (file)
index 0000000..0ebd69e
--- /dev/null
@@ -0,0 +1,53 @@
+#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_ */
index 76f8357f157ad4dc9f2c9c5818712caa8730ec96..f07205049b6c71aca1108f86341271b809a5685f 100644 (file)
@@ -94,6 +94,7 @@
 #include "URL.h"
 #include "wccp.h"
 #include "wccp2.h"
+#include "WinSvc.h"
 
 #if USE_ADAPTATION
 #include "adaptation/Config.h"
@@ -1279,12 +1280,7 @@ SquidMain(int argc, char **argv)
 {
     ConfigureCurrentKid(argv[0]);
 
-#if _SQUID_WINDOWS_
-    int WIN32_init_err;
-#endif
-
 #if HAVE_SBRK
-
     sbrk_start = sbrk(0);
 #endif
 
@@ -1298,10 +1294,10 @@ SquidMain(int argc, char **argv)
 
 #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
@@ -1545,22 +1541,16 @@ sendSignal(void)
 
     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) &&
index 798ddcefe02376d11ac6979dbe7e4a4bce97fdef..c5bc195e7c8563f54dc6511fa50d1dd222bcf968 100644 (file)
@@ -43,18 +43,6 @@ extern void shut_down(int);
 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]);