VBoxClient.cpp revision 1a84601801d5bd045712787a3ef59313795389a1
/** $Id$ */
/** @file
* VBoxClient - User specific services, Darwin.
*/
/*
* Copyright (C) 2007-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include <VBox/VBoxGuestLib.h>
#include <iprt/initterm.h>
#include "VBoxClientInternal.h"
/*******************************************************************************
* Glogal Variables *
*******************************************************************************/
static int g_cVerbosity = 0;
static VBOXCLIENTSERVICE g_aServices[] =
{
{ g_ClipboardService },
};
/**
* Create default logger in order to print output to the specified file.
*
* @return IPRT status code.
*/
static int vbclInitLogger(char *szLogFileName)
{
int rc;
static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES;
fFlags, /* Logger instance flags, a combination of the RTLOGFLAGS_* values */
"all", /* The initial group settings */
"VBOXCLIENT_RELEASE_LOG", /* Base name for the environment variables for this instance */
s_apszGroups, /* Pointer to array of groups. This must stick around for the life of the logger instance */
fDestFlags, /* The destination flags */
NULL, /* Callback function for starting logging and for ending or starting a new file for log history rotation */
szLogFileName ? RT_SEC_1DAY : 0, /* Maximum time interval per log file when performing history rotation */
0, /* A buffer which is filled with an error message if something fails */
0, /* The size of the error message buffer */
szLogFileName /* Log filename format string */
);
/* Register this logger as the release logger */
/* Explicitly flush the log in case of VBOXCLIENT_RELEASE_LOG=buffered. */
return rc;
}
/**
* Destroy logger.
*/
static void vbclTermLogger(char *szLogFileName)
{
// Why SIGBUS here?
if (szLogFileName)
}
/**
* Displays a verbose message.
*
* @param iLevel Minimum log level required to display this message.
* @param pszFormat The message text.
* @param ... Format arguments.
*/
{
if (iLevel > g_cVerbosity)
return;
}
/**
* Wait for signals in order to safely terminate process.
*/
static void vbclWait(void)
{
int iSignal;
/* Register signals that we are waiting for */
/* Ignoring return status */
}
/**
* Start registered services.
*
* @return IPRT status code.
*/
static int vbclStartServices(void)
{
int rc;
unsigned int iServiceId = 0;
{
if (RT_FAILURE(rc))
{
/* Stop running services */
do
{
if (RT_FAILURE(rcStop))
VBoxClientVerbose(1, "unable to stop service: %s (%Rrc)\n", g_aServices[iServiceId].pszName, rcStop);
} while (--iServiceId != 0);
break;
}
}
if (RT_SUCCESS(rc))
return rc;
}
/**
* Stop registered services.
*
* @return IPRT status code.
*/
static void vbclStopServices(void)
{
unsigned int iServiceId = 0;
{
if (RT_FAILURE(rc))
}
}
{
exit(1);
}
{
int rc;
int c;
bool fDemonize = true;
static char *szLogFileName = NULL;
/* Parse command line */
{
switch(c)
{
case 'f':
fDemonize = false;
break;
case 'v':
g_cVerbosity++;
break;
case 'l':
break;
}
}
/* No more arguments allowed */
if (fDemonize)
{
if (RT_FAILURE(rc))
{
RTPrintf("failed to run into background\n");
return 1;
}
}
if (RT_FAILURE(rc))
{
return RTMsgInitFailure(rc);
}
rc = VbglR3Init();
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
rc = vbclStartServices();
if (RT_SUCCESS(rc))
{
vbclWait();
}
else
{
}
}
else
{
}
VbglR3Term();
}
else
{
}
return 0;
}