SUPSvc.cpp revision e64031e20c39650a7bc902a3e1aba613b9415dee
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * VirtualBox Support Service - Common Code.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * Copyright (C) 2008 Oracle Corporation
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * available from http://www.virtualbox.org. This file is free software;
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * you can redistribute it and/or modify it under the terms of the GNU
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * General Public License (GPL) as published by the Free Software
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * The contents of this file may alternatively be used under the terms
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * of the Common Development and Distribution License Version 1.0
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * VirtualBox OSE distribution, in which case the provisions of the
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * CDDL are applicable instead of those of the GPL.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * You may elect to license modified versions of this file under the
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * terms and conditions of either the GPL or the CDDL or both.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync/*******************************************************************************
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync* Header Files *
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync*******************************************************************************/
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync/*******************************************************************************
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync* Structures and Typedefs *
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync*******************************************************************************/
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * Service state.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * Service descriptor.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync /** The service name. */
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync const char *pszName;
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync /** The service state. */
8d82d07fc2f7234b1e5a3ba544e1086a5a7a7c5fvboxsync /** The instance handle returned by pfnCreate. */
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * Create the service (don't start it).
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * @returns VBox status code, log entry is written on failure.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * @param ppvInstance Where to store the instance handle.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync DECLCALLBACKMEMBER(int, pfnCreate)(void **ppvInstance);
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * Start the service.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * @returns VBox status code, log entry is written on failure.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * @param pvInstance The instance handle.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync DECLCALLBACKMEMBER(void, pfnStart)(void *pvInstance);
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * Attempt to stop a running service.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * This should fail if there are active clients. A stopped service
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * can be restarted by calling pfnStart.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * @returns VBox status code, log entry is written on failure.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * @param pvInstance The instance handle.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync DECLCALLBACKMEMBER(int, pfnTryStop)(void *pvInstance);
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * Destroy the service, stopping first it if necessary.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * @param pvInstance The instance handle.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync * @param fRunning Whether the service is running or not.
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync DECLCALLBACKMEMBER(void, pfnStopAndDestroy)(void *pvInstance, bool fRunning);
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync/** Pointer to a service descriptor. */
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync/** Pointer to a const service descriptor. */
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync/*******************************************************************************
73045e3d71f04f3d399e70e89fbd6395c4402821vboxsync* Global Variables *
8d82d07fc2f7234b1e5a3ba544e1086a5a7a7c5fvboxsync*******************************************************************************/
int supSvcCreateAndStartServices(void)
return VERR_WRONG_ORDER;
return rc;
int supSvcTryStopServices(void)
unsigned cRunning = 0;
cRunning++;
return VERR_WRONG_ORDER;
if (!cRunning)
return rc;
void supSvcStopAndDestroyServices(void)
if (*pszFormat)
int supSvcLogGetOptError(const char *pszAction, int rc, int argc, char **argv, int iArg, PCRTOPTIONUNION pValue)
int supSvcDisplayGetOptError(const char *pszAction, int rc, int argc, char **argv, int iArg, PCRTOPTIONUNION pValue)