ReactOS  0.4.12-dev-18-gf469aca
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.

Referenced by serv_main().

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

◆ 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:358
BOOL WINAPI StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW *lpServiceStartTable)
Definition: sctrl.c:1094
static char ** argv
Definition: ServiceArgs.c:11
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.

Referenced by main().

64 {
66 
67  WINE_TRACE( "starting service\n" );
68 
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 
88 
90  status.dwControlsAccepted = 0;
91  SetServiceStatus( service_handle, &status );
92  WINE_TRACE( "service stopped\n" );
93 }
#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
static HANDLE stop_event
Definition: serviceentry.c:32
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
#define WINE_TRACE
Definition: debug.h:358
DWORD dwServiceSpecificExitCode
Definition: winsvc.h:103
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 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
DWORD dwServiceType
Definition: winsvc.h:99
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:773
static SERVICE_STATUS_HANDLE service_handle
Definition: serviceentry.c:31
DWORD dwControlsAccepted
Definition: winsvc.h:101
#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

◆ 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.

Referenced by serv_main().

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 );
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 }
DWORD dwCurrentState
Definition: winsvc.h:100
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 SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:957
DWORD dwCheckPoint
Definition: winsvc.h:104
#define SERVICE_RUNNING
Definition: winsvc.h:24
#define ctrl
Definition: input.c:1669
DWORD dwWaitHint
Definition: winsvc.h:105
DWORD dwWin32ExitCode
Definition: winsvc.h:102
DWORD dwServiceType
Definition: winsvc.h:99
static SERVICE_STATUS_HANDLE service_handle
Definition: serviceentry.c:31
DWORD dwControlsAccepted
Definition: winsvc.h:101
#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:370

◆ 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.

◆ 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().