Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenspoolsv.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS kernel 00004 * FILE: services/spoolsv/spoolsv.c 00005 * PURPOSE: Printer spooler 00006 * PROGRAMMER: Eric Kohl 00007 */ 00008 00009 /* INCLUDES *****************************************************************/ 00010 00011 #define WIN32_NO_STATUS 00012 #include <windows.h> 00013 00014 #include "wine/debug.h" 00015 00016 WINE_DEFAULT_DEBUG_CHANNEL(spoolsv); 00017 00018 00019 /* GLOBALS ******************************************************************/ 00020 00021 static VOID CALLBACK ServiceMain(DWORD argc, LPWSTR *argv); 00022 static WCHAR ServiceName[] = L"Spooler"; 00023 static SERVICE_TABLE_ENTRYW ServiceTable[] = 00024 { 00025 {ServiceName, ServiceMain}, 00026 {NULL, NULL} 00027 }; 00028 00029 SERVICE_STATUS_HANDLE ServiceStatusHandle; 00030 SERVICE_STATUS ServiceStatus; 00031 00032 00033 /* FUNCTIONS *****************************************************************/ 00034 00035 static VOID 00036 UpdateServiceStatus(DWORD dwState) 00037 { 00038 ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; 00039 ServiceStatus.dwCurrentState = dwState; 00040 00041 if (dwState == SERVICE_RUNNING) 00042 ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE | SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; 00043 else if (dwState == SERVICE_PAUSED) 00044 ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE; 00045 else 00046 ServiceStatus.dwControlsAccepted = 0; 00047 00048 ServiceStatus.dwWin32ExitCode = 0; 00049 ServiceStatus.dwServiceSpecificExitCode = 0; 00050 ServiceStatus.dwCheckPoint = 0; 00051 00052 if (dwState == SERVICE_START_PENDING || 00053 dwState == SERVICE_STOP_PENDING || 00054 dwState == SERVICE_PAUSE_PENDING || 00055 dwState == SERVICE_CONTINUE_PENDING) 00056 ServiceStatus.dwWaitHint = 10000; 00057 else 00058 ServiceStatus.dwWaitHint = 0; 00059 00060 SetServiceStatus(ServiceStatusHandle, 00061 &ServiceStatus); 00062 } 00063 00064 00065 static DWORD WINAPI 00066 ServiceControlHandler(DWORD dwControl, 00067 DWORD dwEventType, 00068 LPVOID lpEventData, 00069 LPVOID lpContext) 00070 { 00071 TRACE("ServiceControlHandler() called\n"); 00072 00073 switch (dwControl) 00074 { 00075 case SERVICE_CONTROL_STOP: 00076 TRACE(" SERVICE_CONTROL_STOP received\n"); 00077 UpdateServiceStatus(SERVICE_STOPPED); 00078 return ERROR_SUCCESS; 00079 00080 case SERVICE_CONTROL_PAUSE: 00081 TRACE(" SERVICE_CONTROL_PAUSE received\n"); 00082 UpdateServiceStatus(SERVICE_PAUSED); 00083 return ERROR_SUCCESS; 00084 00085 case SERVICE_CONTROL_CONTINUE: 00086 TRACE(" SERVICE_CONTROL_CONTINUE received\n"); 00087 UpdateServiceStatus(SERVICE_RUNNING); 00088 return ERROR_SUCCESS; 00089 00090 case SERVICE_CONTROL_INTERROGATE: 00091 TRACE(" SERVICE_CONTROL_INTERROGATE received\n"); 00092 SetServiceStatus(ServiceStatusHandle, 00093 &ServiceStatus); 00094 return ERROR_SUCCESS; 00095 00096 case SERVICE_CONTROL_SHUTDOWN: 00097 TRACE(" SERVICE_CONTROL_SHUTDOWN received\n"); 00098 UpdateServiceStatus(SERVICE_STOPPED); 00099 return ERROR_SUCCESS; 00100 00101 default : 00102 TRACE(" Control %lu received\n"); 00103 return ERROR_CALL_NOT_IMPLEMENTED; 00104 } 00105 } 00106 00107 00108 static VOID CALLBACK 00109 ServiceMain(DWORD argc, LPWSTR *argv) 00110 { 00111 UNREFERENCED_PARAMETER(argc); 00112 UNREFERENCED_PARAMETER(argv); 00113 00114 TRACE("ServiceMain() called\n"); 00115 00116 ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName, 00117 ServiceControlHandler, 00118 NULL); 00119 00120 TRACE("Calling SetServiceStatus()\n"); 00121 UpdateServiceStatus(SERVICE_RUNNING); 00122 TRACE("SetServiceStatus() called\n"); 00123 00124 00125 TRACE("ServiceMain() done\n"); 00126 } 00127 00128 00129 int 00130 wmain(int argc, WCHAR *argv[]) 00131 { 00132 UNREFERENCED_PARAMETER(argc); 00133 UNREFERENCED_PARAMETER(argv); 00134 00135 TRACE("Spoolsv: main() started\n"); 00136 00137 StartServiceCtrlDispatcher(ServiceTable); 00138 00139 TRACE("Spoolsv: main() done\n"); 00140 00141 return 0; 00142 } 00143 00144 /* EOF */ Generated on Sun May 27 2012 04:17:54 for ReactOS by
1.7.6.1
|