summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server.cpp1
-rw-r--r--win/configure.cpp1
-rw-r--r--win/inspircdVC80.vcproj2
-rw-r--r--win/inspircd_win32wrapper.h2
-rw-r--r--win/win32service.cpp11
-rw-r--r--win/win32service.h3
6 files changed, 13 insertions, 7 deletions
diff --git a/src/server.cpp b/src/server.cpp
index a87612449..d8ab76425 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -36,6 +36,7 @@ void InspIRCd::Exit(int status)
#ifdef WINDOWS
if (WindowsIPC)
delete WindowsIPC;
+ SetServiceStopped(status);
#endif
if (this)
{
diff --git a/win/configure.cpp b/win/configure.cpp
index 91c68a227..1bc6aba13 100644
--- a/win/configure.cpp
+++ b/win/configure.cpp
@@ -13,6 +13,7 @@
#define _CRT_SECURE_NO_DEPRECATE
+#define CONFIGURE_BUILD
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
diff --git a/win/inspircdVC80.vcproj b/win/inspircdVC80.vcproj
index aee4dcbde..bfa8a16fc 100644
--- a/win/inspircdVC80.vcproj
+++ b/win/inspircdVC80.vcproj
@@ -730,7 +730,7 @@
>
</File>
<File
- RelativePath="..\include\win32service.h"
+ RelativePath=".\win32service.h"
>
</File>
<File
diff --git a/win/inspircd_win32wrapper.h b/win/inspircd_win32wrapper.h
index 89309fbc9..2935ba5c9 100644
--- a/win/inspircd_win32wrapper.h
+++ b/win/inspircd_win32wrapper.h
@@ -18,7 +18,9 @@
#ifndef INSPIRCD_WIN32WRAPPER_H
#define INSPIRCD_WIN32WRAPPER_H
+#ifndef CONFIGURE_BUILD
#include "win32service.h"
+#endif
/* Define the WINDOWS macro. This means we're building on windows to the rest of the server.
I think this is more reasonable than using WIN32, especially if we're gonna be doing 64-bit compiles */
diff --git a/win/win32service.cpp b/win/win32service.cpp
index 5923c1458..42eaa998b 100644
--- a/win/win32service.cpp
+++ b/win/win32service.cpp
@@ -27,6 +27,9 @@ static int serviceCurrentStatus;
*/
typedef BOOL (CALLBACK* SETSERVDESC)(SC_HANDLE,DWORD,LPVOID);
+BOOL UpdateSCMStatus (DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwServiceSpecificExitCode, DWORD dwCheckPoint, DWORD dwWaitHint);
+void terminateService (int code, int wincode);
+
/* A commandline parameter handler for service specific commandline parameters */
typedef void (*CommandlineParameterHandler)(void);
@@ -40,7 +43,7 @@ struct Commandline
/* A function pointer for dynamic linking tricks */
SETSERVDESC ChangeServiceConf;
-bool IsAService();
+bool IsAService()
{
USEROBJECTFLAGS uoflags;
HWINSTA winstation = GetProcessWindowStation();
@@ -78,7 +81,7 @@ void SetServiceRunning()
return;
serviceCurrentStatus = SERVICE_RUNNING;
- success = UpdateSCMStatus(SERVICE_RUNNING, NO_ERROR, 0, 0, 0);
+ BOOL success = UpdateSCMStatus(SERVICE_RUNNING, NO_ERROR, 0, 0, 0);
if (!success)
{
terminateService(6, GetLastError());
@@ -141,7 +144,7 @@ void terminateService (int code, int wincode)
}
/* In windows we hook this to exit() */
-void newexit(int status)
+void SetServiceStopped(int status)
{
if (!IsAService())
exit(status);
@@ -355,7 +358,7 @@ int main(int argc, char** argv)
* as a service so if this is true, we just run the non-service inspircd.
*/
if (!IsAService())
- return smain(argv, argc);
+ return smain(argc, argv);
/* If we get here, we know the service is installed so we can start it */
diff --git a/win/win32service.h b/win/win32service.h
index 93c9c8e09..162a7d66d 100644
--- a/win/win32service.h
+++ b/win/win32service.h
@@ -2,8 +2,7 @@
#define _WIN32SERVICE_H_
/* Hook for win32service.cpp to exit properly with the service specific error code */
-#define exit(a) newexit(a)
-void newexit(int status);
+void SetServiceStopped(int status);
/* Marks the service as running, not called until the config is parsed */
void SetServiceRunning();