VBoxServiceToolBox.cpp revision 4c83fd46d254a6e1cad9f1df4395408cd9ff7833
/* $Id$ */
/** @file
* VBoxServiceToolBox - Internal (BusyBox-like) toolbox.
*/
/*
* Copyright (C) 2010 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 <VBox/VBoxGuestLib.h>
#include "VBoxServiceInternal.h"
#include "VBoxServiceUtils.h"
/**
* Displays a help text to stdout.
*/
void VBoxServiceToolboxShowUsage(void)
{
RTPrintf("Toolbox Usage:\n"
"cat [FILE] - Concatenate FILE(s), or standard input, to standard output\n"
"\n");
}
/**
*
*
* @return int
*
* @param pszFormat
*/
int VBoxServiceToolboxErrorSyntax(const char *pszFormat, ...)
{
RTPrintf("\n"
return VERR_INVALID_PARAMETER;
}
{
int rc = VINF_SUCCESS;
bool usageOK = true;
{
}
if (!usageOK)
return rc;
}
/**
* Main routine for toolbox command line handling.
*
* @return int
*
* @param argc
* @param argv
*/
{
int rc = VERR_NOT_FOUND;
bool fUsageOK = true;
{
{
/** @todo Move this block into an own "cat main" routine! */
bool fHaveFile = false;
/* Do we have a file as second argument? */
if (argc == 2)
{
/* Use stdin as standard input stream. */
rc = VINF_SUCCESS;
}
else if (argc == 3)
{
"rb", /* Read binary */
&pStream);
if (RT_SUCCESS(rc))
fHaveFile = true;
}
else
fUsageOK = false;
if (RT_SUCCESS(rc))
{
do
{
if (RT_SUCCESS(rc))
/* Close opened file handle. */
if (fHaveFile)
}
}
}
/* Ignore usage errors when using an unknown command - this might
* be a regular VBoxService startup command (--whatever)! */
if (!fUsageOK)
if (rc != VERR_NOT_FOUND)
return rc;
}