105 lines
3.0 KiB
C++

//----------------------------------------------------------------------------
//
// Copyright (C) Intel Corporation, 2006 - 2007.
//
// File: MPSService.cpp
//
// Contents: Runs the MPS as a service.
//
// Notes:
//----------------------------------------------------------------------------
#include "global.h"
#include "MPSService.h"
#ifndef WAIT_INFINITE
#define WAIT_INFINITE 0xffffffff
#endif
// Prototypes of MPS functions that can be run
int closeMPS();
int run_main (int argc, char *argv[]);
//int mps_init (int argc, char *argv[]);
//*****************************************************************************
// Name : ServiceBase
// Description : Constructor - initializes a new instance of the
// UserNotificationService class.
//*****************************************************************************
MPSService::MPSService(LPCTSTR pszServiceName):
BaseService(pszServiceName),_argc(), _argv()
{
}
//*****************************************************************************
// Name : ServiceBase
// Description : Destructor - finish soap.
//*****************************************************************************
MPSService::~MPSService(void)
{
}
//*****************************************************************************
// Name : _ServiceCtrlHandler
// Description : Take care of calling the callback function
// specified for each control operations.
//*****************************************************************************
DWORD WINAPI MPSService::_ServiceCtrlHandler(
DWORD dwControl,
DWORD dwEventType,
LPVOID lpEventData,
LPVOID lpContext)
{
switch (dwControl)
{
case SERVICE_CONTROL_SHUTDOWN:
case SERVICE_CONTROL_STOP:
UpdateService(SERVICE_STOP_PENDING); // Notify SCM to stop pending.
#if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_SERVICES) && defined (_SERVICE)
closeMPS();
#endif /* ACE_WIN32 && !(ACE_LACKS_WIN32_SERVICES) && (_SERVICE)*/
// Stop the service
UpdateService(SERVICE_STOPPED);
break;
}
return NO_ERROR;
}
//*****************************************************************************
// Name : ServiceInitialization
// Description : This is a service initialization function that gets called
// when the service gets created
//*****************************************************************************
DWORD MPSService::ServiceInitialization(DWORD argc,
LPTSTR *argv,
DWORD *specificError)
{
_argc = argc;
_argv = argv;
//int ret = mps_init(_argc, _argv);
//return ret;
return 0;
}
//*****************************************************************************
// Name : ServiceMainLoop
// Description : Listen of the master socket, if a data is received from the
// TCP network process the data: Invoke soap_serve(&soap):
// The soap_serve() function will invoke the __emc__SoapAlert.
//
//*****************************************************************************
DWORD MPSService::ServiceMainLoop()
{
int ret;
try {
ret = run_main (_argc, _argv);
}
catch (...)
{
}
return ret;
}