Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenserviceentry.c
Go to the documentation of this file.
00001 /* 00002 * Copyright 2007 Jacek Caban for CodeWeavers 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00017 */ 00018 00019 #define WIN32_LEAN_AND_MEAN 00020 00021 #include <windows.h> 00022 #include "wine/debug.h" 00023 00024 int kickoff_telnetd(void); 00025 00026 WINE_DEFAULT_DEBUG_CHANNEL(telnetd); 00027 00028 static WCHAR telnetdW[] = {'t','e','l','n','e','t','d',0}; 00029 00030 static SERVICE_STATUS_HANDLE service_handle; 00031 static HANDLE stop_event; 00032 00033 static DWORD WINAPI service_handler( DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context ) 00034 { 00035 SERVICE_STATUS status; 00036 00037 status.dwServiceType = SERVICE_WIN32; 00038 status.dwControlsAccepted = SERVICE_ACCEPT_STOP; 00039 status.dwWin32ExitCode = 0; 00040 status.dwServiceSpecificExitCode = 0; 00041 status.dwCheckPoint = 0; 00042 status.dwWaitHint = 0; 00043 00044 switch(ctrl) 00045 { 00046 case SERVICE_CONTROL_STOP: 00047 case SERVICE_CONTROL_SHUTDOWN: 00048 WINE_TRACE( "shutting down\n" ); 00049 status.dwCurrentState = SERVICE_STOP_PENDING; 00050 status.dwControlsAccepted = 0; 00051 SetServiceStatus( service_handle, &status ); 00052 SetEvent( stop_event ); 00053 return NO_ERROR; 00054 default: 00055 WINE_FIXME( "got service ctrl %x\n", ctrl ); 00056 status.dwCurrentState = SERVICE_RUNNING; 00057 SetServiceStatus( service_handle, &status ); 00058 return NO_ERROR; 00059 } 00060 } 00061 00062 static void WINAPI serv_main(DWORD argc, LPWSTR *argv) 00063 { 00064 SERVICE_STATUS status; 00065 00066 WINE_TRACE( "starting service\n" ); 00067 00068 stop_event = CreateEventW( NULL, TRUE, FALSE, NULL ); 00069 00070 service_handle = RegisterServiceCtrlHandlerExW( telnetdW, service_handler, NULL ); 00071 if (!service_handle) 00072 return; 00073 00074 status.dwServiceType = SERVICE_WIN32; 00075 status.dwCurrentState = SERVICE_RUNNING; 00076 status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; 00077 status.dwWin32ExitCode = 0; 00078 status.dwServiceSpecificExitCode = 0; 00079 status.dwCheckPoint = 0; 00080 status.dwWaitHint = 10000; 00081 SetServiceStatus( service_handle, &status ); 00082 00083 /* Argument Ignored for now */ 00084 kickoff_telnetd(); 00085 00086 WaitForSingleObject( stop_event, INFINITE ); 00087 00088 status.dwCurrentState = SERVICE_STOPPED; 00089 status.dwControlsAccepted = 0; 00090 SetServiceStatus( service_handle, &status ); 00091 WINE_TRACE( "service stopped\n" ); 00092 } 00093 00094 int main(int argc, char **argv) 00095 { 00096 static const SERVICE_TABLE_ENTRYW servtbl[] = { 00097 {telnetdW, serv_main}, 00098 {NULL, NULL} 00099 }; 00100 00101 WINE_TRACE("(%d %p)\n", argc, argv); 00102 00103 StartServiceCtrlDispatcherW(servtbl); 00104 return 0; 00105 } 00106 /* EOF */ 00107 Generated on Sat May 26 2012 04:16:38 for ReactOS by
1.7.6.1
|