ReactOS  0.4.12-dev-18-gf469aca
serviceentry.c
Go to the documentation of this file.
1 /*
2  * Copyright 2007 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #include <stdarg.h>
20 #include <windef.h>
21 #include <winbase.h>
22 #include <winsvc.h>
23 #include <wine/debug.h>
24 
25 int kickoff_telnetd(void);
26 
28 
29 static WCHAR telnetdW[] = {'t','e','l','n','e','t','d',0};
30 
33 
34 static DWORD WINAPI service_handler( DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context )
35 {
37 
40  status.dwWin32ExitCode = 0;
41  status.dwServiceSpecificExitCode = 0;
42  status.dwCheckPoint = 0;
43  status.dwWaitHint = 0;
44 
45  switch(ctrl)
46  {
49  WINE_TRACE( "shutting down\n" );
51  status.dwControlsAccepted = 0;
52  SetServiceStatus( service_handle, &status );
53  SetEvent( stop_event );
54  return NO_ERROR;
55  default:
56  WINE_FIXME( "got service ctrl %x\n", ctrl );
58  SetServiceStatus( service_handle, &status );
59  return NO_ERROR;
60  }
61 }
62 
64 {
66 
67  WINE_TRACE( "starting service\n" );
68 
69  stop_event = CreateEventW( NULL, TRUE, FALSE, NULL );
70 
72  if (!service_handle)
73  return;
74 
78  status.dwWin32ExitCode = 0;
79  status.dwServiceSpecificExitCode = 0;
80  status.dwCheckPoint = 0;
81  status.dwWaitHint = 10000;
82  SetServiceStatus( service_handle, &status );
83 
84  /* Argument Ignored for now */
86 
87  WaitForSingleObject( stop_event, INFINITE );
88 
90  status.dwControlsAccepted = 0;
91  SetServiceStatus( service_handle, &status );
92  WINE_TRACE( "service stopped\n" );
93 }
94 
95 int main(int argc, char **argv)
96 {
97  static const SERVICE_TABLE_ENTRYW servtbl[] = {
99  {NULL, NULL}
100  };
101 
102  WINE_TRACE("(%d %p)\n", argc, argv);
103 
105  return 0;
106 }
107 /* EOF */
108 
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
DWORD dwCurrentState
Definition: winsvc.h:100
static DWORD WINAPI service_handler(DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context)
Definition: serviceentry.c:34
Definition: http.c:6587
__wchar_t WCHAR
Definition: xmlstorage.h:180
static HANDLE stop_event
Definition: serviceentry.c:32
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
#define WINE_TRACE
Definition: debug.h:358
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
DWORD dwServiceSpecificExitCode
Definition: winsvc.h:103
#define NO_ERROR
Definition: dderror.h:5
BOOL WINAPI StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW *lpServiceStartTable)
Definition: sctrl.c:1094
static char ** argv
Definition: ServiceArgs.c:11
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:597
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:957
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
DWORD dwCheckPoint
Definition: winsvc.h:104
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_RUNNING
Definition: winsvc.h:24
smooth NULL
Definition: ftsmooth.c:416
#define ctrl
Definition: input.c:1669
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
#define SERVICE_ACCEPT_SHUTDOWN
Definition: winsvc.h:30
int kickoff_telnetd(void)
Definition: telnetd.c:48
DWORD dwWaitHint
Definition: winsvc.h:105
DWORD dwWin32ExitCode
Definition: winsvc.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwServiceType
Definition: winsvc.h:99
static void WINAPI serv_main(DWORD argc, LPWSTR *argv)
Definition: serviceentry.c:63
int main(int argc, char **argv)
Definition: serviceentry.c:95
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:773
#define WINAPI
Definition: msvc.h:20
static SERVICE_STATUS_HANDLE service_handle
Definition: serviceentry.c:31
DWORD dwControlsAccepted
Definition: winsvc.h:101
#define SERVICE_WIN32
Definition: cmtypes.h:962
WINE_DEFAULT_DEBUG_CHANNEL(telnetd)
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define INFINITE
Definition: serial.h:102
static SERVICE_STATUS status
Definition: service.c:31
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
static WCHAR telnetdW[]
Definition: serviceentry.c:29
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:40
#define WINE_FIXME
Definition: debug.h:370