VBox.cpp revision 1c94c0a63ba68be1a7b2c640e70d7a06464e4fca
/** @file
*
* VBox - Main Program.
*
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <signal.h>
#include <stdio.h>
#ifdef _MSC_VER
# include <stdlib.h>
#else
# include <unistd.h>
#endif
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
static void SignalInterrupt(int iSignalNo);
{
int rc = -1;
/* todo: decide whether or not we're gonna have one executable
* which contains both GUI and VM backend or separate executables.
*
* In any case we're expecting this code to be rewritten as this is mostly
* a sketch of what we currently think is going to happen when a VM is started.
*/
/*
* Init runtime.
*/
if (!VBOX_SUCCESS(rc))
{
return 1;
}
/*
* Parse arguments.
*/
char *pszVMConfig = NULL;
{
{
{
case '?':
case 'h':
case 'H':
return 1;
default:
return 1;
}
}
else
{
if (pszVMConfig)
{
printf("syntax error: Multiple VM configuration files specified!\n");
return 1;
}
}
}
/*
* Create the VM from the given config file.
*/
if (VBOX_SUCCESS(rc))
{
/*
* Run the VM.
*/
if (VBOX_SUCCESS(rc))
{
/*
* Wait for user to press Control-C,
* (or Control-Break if signal is available).
*/
#ifdef SIGBREAK
#endif
#ifdef _MSC_VER
_sleep(~0);
#else
pause();
#endif
rc = 0;
}
else
{
rc = 1;
}
/*
* Destroy the VM.
*/
if (!VBOX_SUCCESS(rc2))
{
rc = 1;
}
}
else
{
rc = 1;
}
return rc;
}
/**
* Signal handler.
* @param iSignalNo Signal number.
*/
void SignalInterrupt(int iSignalNo)
{
#ifdef SIGBREAK
printf("SIGBREAK!\n");
else
printf("SIGINT!\n");
#else
printf("SIGINT!\n");
#endif
/*
* assuming BSD style signals here, meaning that execution
* continues upon return....
* I've no clue how that works on Win32 and linux though.
*/
#ifdef SIG_ACK
#endif
}