ntservice.h #1

  • //
  • guest/
  • perforce_software/
  • p4/
  • 2014-1/
  • sys/
  • ntservice.h
  • View
  • Commits
  • Open Download .zip Download (2 KB)
/*
 * Copyright 1995, 2000 Perforce Software.  All rights reserved.
 *
 * This file is part of Perforce - the FAST SCM System.
 */

/*
 * NtService - Class allows Perforce server to run as a service on NT.
 *
 * Public methods:
 *
 *	NtService::NtService()
 *	    Constructor requires a name, and a pointer to the entry point for
 *	    the program which can not be main because main calls 
 *	    StartServiceControlDispatcher() and never returns.
 *
 *	NtService::Start()
 *	    This calls StartServiceControlDispatcher to connect the service to 
 *	    the SCM. This should be called as soon as possible after the 
 *	    program starts because the SCM will only wait 30 seconds for this
 *	    call.
 *
 *	NtService::SetStatus()
 *	    Informx SCM of changes in the services status. Required to tell 
 *	    SCM when service has successfully started.
 *
 */

#ifndef NTSERVICE_H__
#define NTSERVICE_H__

class Error;

class NtService
{
    public:
	enum states 
	{  
	    stopped,
	    running,
	    start_pending,
	    stop_pending,
	    paused,
	    pause_pending,
	    continue_pending,
	    no_change 
	};

		    NtService();
    	virtual	    ~NtService();

	// Our caller's interface

    	virtual void Start(
			int (*entryPt)( DWORD, char ** ),
			char *svc,
			Error *e);

    	virtual void SetStatus(   
			states state = no_change, 
			DWORD win32_exitcode = 0,
			DWORD specific_code = 0,
			DWORD wait_hint	= 0 );

    private:

	// SCM callbacks with Win32 interfaces.
	// Do not call them directly.
	// Because they are static, we have to remember
	// the (one) NtService in use.

	static NtService *global_this; 
	static void WINAPI ControlHandler( DWORD opcode );
	static void StaticRun( DWORD argc, char **argv );

	// Called by ControlHanlder

	virtual void    Run( DWORD argc, char **argv );
	virtual void    Stop();

	SERVICE_STATUS		status;
	SERVICE_STATUS_HANDLE	statusHandle;

	int ( *entry_point )( DWORD, char ** );

	char	svcName[32];
};

#endif // NTSERVICE_H__
# Change User Description Committed
#1 15902 Matt Attaway A second renaming that I will not obliterate as a badge of shame
//guest/perforce_software/p4/2014_1/sys/ntservice.h
#1 15901 Matt Attaway Clean up code to fit modern Workshop naming standards
//guest/perforce_software/p4/2014.1/sys/ntservice.h
#1 12188 Matt Attaway Move 'main' p4 into a release specific directory in prep for new releases
//guest/perforce_software/p4/sys/ntservice.h
#1 9129 Matt Attaway Initial commit of the 2014.1 p4/p4api source code