2008-09-03 20:57:51 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* FILE: services/spoolsv/spoolsv.c
|
|
|
|
* PURPOSE: Printer spooler
|
|
|
|
* PROGRAMMER: Eric Kohl
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include <windows.h>
|
|
|
|
|
2010-01-05 20:32:02 +00:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(spoolsv);
|
|
|
|
|
2008-09-03 20:57:51 +00:00
|
|
|
|
|
|
|
/* GLOBALS ******************************************************************/
|
|
|
|
|
2010-02-20 12:59:53 +00:00
|
|
|
static VOID CALLBACK ServiceMain(DWORD argc, LPWSTR *argv);
|
|
|
|
static WCHAR ServiceName[] = L"Spooler";
|
|
|
|
static SERVICE_TABLE_ENTRYW ServiceTable[] =
|
|
|
|
{
|
|
|
|
{ServiceName, ServiceMain},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
2008-09-03 20:57:51 +00:00
|
|
|
|
|
|
|
SERVICE_STATUS_HANDLE ServiceStatusHandle;
|
2009-11-07 11:43:06 +00:00
|
|
|
SERVICE_STATUS ServiceStatus;
|
2008-09-03 20:57:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2010-01-05 20:32:02 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2008-09-03 20:57:51 +00:00
|
|
|
|
|
|
|
static DWORD WINAPI
|
|
|
|
ServiceControlHandler(DWORD dwControl,
|
|
|
|
DWORD dwEventType,
|
|
|
|
LPVOID lpEventData,
|
|
|
|
LPVOID lpContext)
|
|
|
|
{
|
2010-01-05 20:32:02 +00:00
|
|
|
TRACE("ServiceControlHandler() called\n");
|
|
|
|
|
2008-09-03 20:57:51 +00:00
|
|
|
switch (dwControl)
|
|
|
|
{
|
|
|
|
case SERVICE_CONTROL_STOP:
|
2010-01-05 20:32:02 +00:00
|
|
|
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;
|
|
|
|
|
2008-09-03 20:57:51 +00:00
|
|
|
case SERVICE_CONTROL_SHUTDOWN:
|
2010-01-05 20:32:02 +00:00
|
|
|
TRACE(" SERVICE_CONTROL_SHUTDOWN received\n");
|
|
|
|
UpdateServiceStatus(SERVICE_STOPPED);
|
2008-09-03 20:57:51 +00:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
default :
|
2010-01-05 20:32:02 +00:00
|
|
|
TRACE(" Control %lu received\n");
|
2008-09-03 20:57:51 +00:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static VOID CALLBACK
|
2010-02-20 12:59:53 +00:00
|
|
|
ServiceMain(DWORD argc, LPWSTR *argv)
|
2008-09-03 20:57:51 +00:00
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(argc);
|
|
|
|
UNREFERENCED_PARAMETER(argv);
|
|
|
|
|
2010-01-05 20:32:02 +00:00
|
|
|
TRACE("ServiceMain() called\n");
|
2008-09-03 20:57:51 +00:00
|
|
|
|
2010-02-20 12:59:53 +00:00
|
|
|
ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
|
2008-09-03 20:57:51 +00:00
|
|
|
ServiceControlHandler,
|
|
|
|
NULL);
|
|
|
|
|
2010-01-05 20:32:02 +00:00
|
|
|
TRACE("Calling SetServiceStatus()\n");
|
|
|
|
UpdateServiceStatus(SERVICE_RUNNING);
|
|
|
|
TRACE("SetServiceStatus() called\n");
|
|
|
|
|
|
|
|
|
|
|
|
TRACE("ServiceMain() done\n");
|
2008-09-03 20:57:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
wmain(int argc, WCHAR *argv[])
|
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(argc);
|
|
|
|
UNREFERENCED_PARAMETER(argv);
|
|
|
|
|
2010-01-05 20:32:02 +00:00
|
|
|
TRACE("Spoolsv: main() started\n");
|
2008-09-03 20:57:51 +00:00
|
|
|
|
|
|
|
StartServiceCtrlDispatcher(ServiceTable);
|
|
|
|
|
2010-01-05 20:32:02 +00:00
|
|
|
TRACE("Spoolsv: main() done\n");
|
2008-09-03 20:57:51 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|