ReactOS  0.4.13-dev-257-gfabbd7c
serviceentry.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winsvc.h>
#include <wine/debug.h>
Include dependency graph for serviceentry.c:

Go to the source code of this file.

Functions

int kickoff_telnetd (void)
 
 WINE_DEFAULT_DEBUG_CHANNEL (telnetd)
 
static DWORD WINAPI service_handler (DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context)
 
static void WINAPI serv_main (DWORD argc, LPWSTR *argv)
 
int main (int argc, char **argv)
 

Variables

static WCHAR telnetdW [] = {'t','e','l','n','e','t','d',0}
 
static SERVICE_STATUS_HANDLE service_handle
 
static HANDLE stop_event
 

Function Documentation

◆ kickoff_telnetd()

int kickoff_telnetd ( void  )

Definition at line 48 of file telnetd.c.

49 {
50  printf("Attempting to start Simple TelnetD\n");
51 
52 // DetectPlatform();
54 
55  if (!StartSocketInterface())
56  ErrorExit("Unable to start socket interface\n");
57 
58  CreateSocket();
59 
60  while(!bShutdown) {
62  }
63 
64  WSACleanup();
65  return 0;
66 }
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
static BOOLEAN StartSocketInterface(void)
Definition: telnetd.c:79
static BOOL WINAPI Cleanup(DWORD dwControlType)
Definition: telnetd.c:69
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine, BOOL Add)
Definition: console.c:2111
static BOOLEAN bShutdown
Definition: telnetd.c:36
static void CreateSocket(void)
Definition: telnetd.c:102
static VOID ErrorExit(LPTSTR lpszMessage)
Definition: telnetd.c:647
static void WaitForConnect(void)
Definition: telnetd.c:120
#define printf
Definition: config.h:203

Referenced by serv_main().

◆ main()

int main ( int argc  ,
char **  argv 
)

Definition at line 95 of file serviceentry.c.

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 }
static int argc
Definition: ServiceArgs.c:12
#define WINE_TRACE
Definition: debug.h:353
#define argv
Definition: mplay32.c:18
BOOL WINAPI StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW *lpServiceStartTable)
Definition: sctrl.c:1123
smooth NULL
Definition: ftsmooth.c:416
static void WINAPI serv_main(DWORD argc, LPWSTR *argv)
Definition: serviceentry.c:63
static WCHAR telnetdW[]
Definition: serviceentry.c:29

◆ serv_main()

static void WINAPI serv_main ( DWORD  argc,
LPWSTR argv 
)
static

Definition at line 63 of file serviceentry.c.

64 {
66 
67  WINE_TRACE( "starting service\n" );
68 
70 
72  if (!service_handle)
73  return;
74 
75  status.dwServiceType = SERVICE_WIN32;
76  status.dwCurrentState = SERVICE_RUNNING;
77  status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
78  status.dwWin32ExitCode = 0;
79  status.dwServiceSpecificExitCode = 0;
80  status.dwCheckPoint = 0;
81  status.dwWaitHint = 10000;
83 
84  /* Argument Ignored for now */
86 
88 
89  status.dwCurrentState = SERVICE_STOPPED;
90  status.dwControlsAccepted = 0;
92  WINE_TRACE( "service stopped\n" );
93 }
#define TRUE
Definition: types.h:120
static DWORD WINAPI service_handler(DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context)
Definition: serviceentry.c:34
static HANDLE stop_event
Definition: serviceentry.c:32
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
#define WINE_TRACE
Definition: debug.h:353
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:986
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_RUNNING
Definition: winsvc.h:24
smooth NULL
Definition: ftsmooth.c:416
#define SERVICE_ACCEPT_SHUTDOWN
Definition: winsvc.h:30
int kickoff_telnetd(void)
Definition: telnetd.c:48
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:802
static SERVICE_STATUS_HANDLE service_handle
Definition: serviceentry.c:31
#define SERVICE_WIN32
Definition: cmtypes.h:962
#define INFINITE
Definition: serial.h:102
static SERVICE_STATUS status
Definition: service.c:31
static WCHAR telnetdW[]
Definition: serviceentry.c:29
Definition: ps.c:97

Referenced by main().

◆ service_handler()

static DWORD WINAPI service_handler ( DWORD  ctrl,
DWORD  event_type,
LPVOID  event_data,
LPVOID  context 
)
static

Definition at line 34 of file serviceentry.c.

35 {
37 
38  status.dwServiceType = SERVICE_WIN32;
39  status.dwControlsAccepted = SERVICE_ACCEPT_STOP;
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" );
50  status.dwCurrentState = SERVICE_STOP_PENDING;
51  status.dwControlsAccepted = 0;
54  return NO_ERROR;
55  default:
56  WINE_FIXME( "got service ctrl %x\n", ctrl );
57  status.dwCurrentState = SERVICE_RUNNING;
59  return NO_ERROR;
60  }
61 }
static HANDLE stop_event
Definition: serviceentry.c:32
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
#define WINE_TRACE
Definition: debug.h:353
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
#define NO_ERROR
Definition: dderror.h:5
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:986
#define SERVICE_RUNNING
Definition: winsvc.h:24
#define ctrl
Definition: input.c:1669
static SERVICE_STATUS_HANDLE service_handle
Definition: serviceentry.c:31
#define SERVICE_WIN32
Definition: cmtypes.h:962
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
static SERVICE_STATUS status
Definition: service.c:31
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:40
#define WINE_FIXME
Definition: debug.h:365
Definition: ps.c:97

Referenced by serv_main().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( telnetd  )

Variable Documentation

◆ service_handle

SERVICE_STATUS_HANDLE service_handle
static

Definition at line 31 of file serviceentry.c.

Referenced by serv_main(), and service_handler().

◆ stop_event

HANDLE stop_event
static

Definition at line 32 of file serviceentry.c.

Referenced by serv_main(), and service_handler().

◆ telnetdW

WCHAR telnetdW[] = {'t','e','l','n','e','t','d',0}
static

Definition at line 29 of file serviceentry.c.

Referenced by main(), and serv_main().