Author: ekohl
Date: Tue Jan 5 21:32:02 2010
New Revision: 44960
URL:
http://svn.reactos.org/svn/reactos?rev=44960&view=rev
Log:
[spoolsv]
- Switch to wine debug macros. Add new debug channel spoolsv.
- Update service status when the service receives a control message.
Modified:
trunk/reactos/base/services/spoolsv/spoolsv.c
trunk/reactos/base/services/spoolsv/spoolsv.rbuild
Modified: trunk/reactos/base/services/spoolsv/spoolsv.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/spoolsv/spoo…
==============================================================================
--- trunk/reactos/base/services/spoolsv/spoolsv.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/spoolsv/spoolsv.c [iso-8859-1] Tue Jan 5 21:32:02 2010
@@ -11,8 +11,10 @@
#define WIN32_NO_STATUS
#include <windows.h>
-#define NDEBUG
-#include <debug.h>
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(spoolsv);
+
/* GLOBALS ******************************************************************/
@@ -24,6 +26,35 @@
/* FUNCTIONS *****************************************************************/
+static VOID
+UpdateServiceStatus(DWORD dwState)
+{
+ ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+ ServiceStatus.dwCurrentState = dwState;
+
+ if (dwState == SERVICE_RUNNING)
+ ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE |
SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
+ else if (dwState == SERVICE_PAUSED)
+ ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE;
+ else
+ ServiceStatus.dwControlsAccepted = 0;
+
+ ServiceStatus.dwWin32ExitCode = 0;
+ ServiceStatus.dwServiceSpecificExitCode = 0;
+ ServiceStatus.dwCheckPoint = 0;
+
+ if (dwState == SERVICE_START_PENDING ||
+ dwState == SERVICE_STOP_PENDING ||
+ dwState == SERVICE_PAUSE_PENDING ||
+ dwState == SERVICE_CONTINUE_PENDING)
+ ServiceStatus.dwWaitHint = 10000;
+ else
+ ServiceStatus.dwWaitHint = 0;
+
+ SetServiceStatus(ServiceStatusHandle,
+ &ServiceStatus);
+}
+
static DWORD WINAPI
ServiceControlHandler(DWORD dwControl,
@@ -31,17 +62,41 @@
LPVOID lpEventData,
LPVOID lpContext)
{
+ TRACE("ServiceControlHandler() called\n");
+
switch (dwControl)
{
case SERVICE_CONTROL_STOP:
+ TRACE(" SERVICE_CONTROL_STOP received\n");
+ UpdateServiceStatus(SERVICE_STOPPED);
+ return ERROR_SUCCESS;
+
+ case SERVICE_CONTROL_PAUSE:
+ TRACE(" SERVICE_CONTROL_PAUSE received\n");
+ UpdateServiceStatus(SERVICE_PAUSED);
+ return ERROR_SUCCESS;
+
+ case SERVICE_CONTROL_CONTINUE:
+ TRACE(" SERVICE_CONTROL_CONTINUE received\n");
+ UpdateServiceStatus(SERVICE_RUNNING);
+ return ERROR_SUCCESS;
+
+ case SERVICE_CONTROL_INTERROGATE:
+ TRACE(" SERVICE_CONTROL_INTERROGATE received\n");
+ SetServiceStatus(ServiceStatusHandle,
+ &ServiceStatus);
+ return ERROR_SUCCESS;
+
case SERVICE_CONTROL_SHUTDOWN:
+ TRACE(" SERVICE_CONTROL_SHUTDOWN received\n");
+ UpdateServiceStatus(SERVICE_STOPPED);
return ERROR_SUCCESS;
default :
+ TRACE(" Control %lu received\n");
return ERROR_CALL_NOT_IMPLEMENTED;
}
}
-
static VOID CALLBACK
@@ -50,23 +105,18 @@
UNREFERENCED_PARAMETER(argc);
UNREFERENCED_PARAMETER(argv);
- DPRINT("ServiceMain() called\n");
+ TRACE("ServiceMain() called\n");
ServiceStatusHandle = RegisterServiceCtrlHandlerExW(SERVICE_NAME,
ServiceControlHandler,
NULL);
- /* Service is now running */
- ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
- ServiceStatus.dwServiceSpecificExitCode = 0;
- ServiceStatus.dwWin32ExitCode = NO_ERROR;
- ServiceStatus.dwWaitHint = 0;
- ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
- ServiceStatus.dwCheckPoint = 0;
- ServiceStatus.dwCurrentState = SERVICE_RUNNING;
- SetServiceStatus(ServiceStatusHandle, &ServiceStatus);
-
- DPRINT("ServiceMain() done\n");
+ TRACE("Calling SetServiceStatus()\n");
+ UpdateServiceStatus(SERVICE_RUNNING);
+ TRACE("SetServiceStatus() called\n");
+
+
+ TRACE("ServiceMain() done\n");
}
@@ -82,11 +132,11 @@
UNREFERENCED_PARAMETER(argc);
UNREFERENCED_PARAMETER(argv);
- DPRINT("Spoolsv: main() started\n");
+ TRACE("Spoolsv: main() started\n");
StartServiceCtrlDispatcher(ServiceTable);
- DPRINT("Spoolsv: main() done\n");
+ TRACE("Spoolsv: main() done\n");
ExitThread(0);
Modified: trunk/reactos/base/services/spoolsv/spoolsv.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/spoolsv/spoo…
==============================================================================
--- trunk/reactos/base/services/spoolsv/spoolsv.rbuild [iso-8859-1] (original)
+++ trunk/reactos/base/services/spoolsv/spoolsv.rbuild [iso-8859-1] Tue Jan 5 21:32:02
2010
@@ -2,6 +2,7 @@
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<module name="spoolsv" type="win32cui"
installbase="system32" installname="spoolsv.exe"
unicode="yes">
<include base="spoolsv">.</include>
+ <library>wine</library>
<library>ntdll</library>
<library>advapi32</library>
<file>spoolsv.c</file>