642d70ae754e0f2b64343aae0e3cc501db1ffb7a
[reactos.git] / reactos / base / services / spoolsv / spoolsv.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: services/spoolsv/spoolsv.c
5 * PURPOSE: Printer spooler
6 * PROGRAMMER: Eric Kohl
7 */
8
9 /* INCLUDES *****************************************************************/
10
11 #define WIN32_NO_STATUS
12 #include <windows.h>
13
14 #define NDEBUG
15 #include <debug.h>
16
17 /* GLOBALS ******************************************************************/
18
19 #define SERVICE_NAME TEXT("Spooler")
20
21 SERVICE_STATUS_HANDLE ServiceStatusHandle;
22 SERVICE_STATUS ServiceStatus;
23
24
25 /* FUNCTIONS *****************************************************************/
26
27
28 static DWORD WINAPI
29 ServiceControlHandler(DWORD dwControl,
30 DWORD dwEventType,
31 LPVOID lpEventData,
32 LPVOID lpContext)
33 {
34 switch (dwControl)
35 {
36 case SERVICE_CONTROL_STOP:
37 case SERVICE_CONTROL_SHUTDOWN:
38 return ERROR_SUCCESS;
39
40 default :
41 return ERROR_CALL_NOT_IMPLEMENTED;
42 }
43 }
44
45
46
47 static VOID CALLBACK
48 ServiceMain(DWORD argc, LPTSTR *argv)
49 {
50 UNREFERENCED_PARAMETER(argc);
51 UNREFERENCED_PARAMETER(argv);
52
53 DPRINT("ServiceMain() called\n");
54
55 ServiceStatusHandle = RegisterServiceCtrlHandlerExW(SERVICE_NAME,
56 ServiceControlHandler,
57 NULL);
58
59 /* Service is now running */
60 ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
61 ServiceStatus.dwServiceSpecificExitCode = 0;
62 ServiceStatus.dwWin32ExitCode = NO_ERROR;
63 ServiceStatus.dwWaitHint = 0;
64 ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
65 ServiceStatus.dwCheckPoint = 0;
66 ServiceStatus.dwCurrentState = SERVICE_RUNNING;
67 SetServiceStatus(ServiceStatusHandle, &ServiceStatus);
68
69 DPRINT("ServiceMain() done\n");
70 }
71
72
73 int
74 wmain(int argc, WCHAR *argv[])
75 {
76 SERVICE_TABLE_ENTRY ServiceTable[2] =
77 {
78 {SERVICE_NAME, ServiceMain},
79 {NULL, NULL}
80 };
81
82 UNREFERENCED_PARAMETER(argc);
83 UNREFERENCED_PARAMETER(argv);
84
85 DPRINT("Spoolsv: main() started\n");
86
87 StartServiceCtrlDispatcher(ServiceTable);
88
89 DPRINT("Spoolsv: main() done\n");
90
91 ExitThread(0);
92
93 return 0;
94 }
95
96 /* EOF */