VBoxServiceToolBox.cpp revision e3a5468cbde9a6f09d91ada9e117bf458d8ea578
/* $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;
}
/**
*
*
* @return int
*
* @param argc
* @param argv
*/
{
int rc = VINF_SUCCESS;
bool usageOK = true;
{
}
if (!usageOK)
return rc;
}
/**
*
*
* @return int
*
* @param hInput
* @param hOutput
*/
{
int rc = VINF_SUCCESS;
if (hInput == NIL_RTFILE)
{
if (RT_FAILURE(rc))
}
if (hOutput == NIL_RTFILE)
{
if (RT_FAILURE(rc))
}
if (RT_SUCCESS(rc))
{
for (;;)
{
{
cbRead = 0;
}
else
{
if ( cbRead == 0
&& rc == VERR_BROKEN_PIPE)
{
rc = VINF_SUCCESS;
}
break;
}
}
}
return rc;
}
/**
*
*
* @return int
*
* @param argc
* @param argv
*/
{
static const RTGETOPTDEF s_aOptions[] =
{
};
int ch;
int rc = VINF_SUCCESS;
//bool fSeenInput = false;
&& RT_SUCCESS(rc))
{
/* For options that require an argument, ValueUnion has received the value. */
switch (ch)
{
case 'o':
if (RT_FAILURE(rc))
VBoxServiceError("Cat: Could not create output file \"%s\"! rc=%Rrc\n",
break;
case 'i':
case VINF_GETOPT_NOT_OPTION:
{
/*rc = VBoxServiceToolboxCatInput(ValueUnion.psz, hOutput);
if (RT_SUCCESS(rc))
fSeenInput = true;*/
if (RT_FAILURE(rc))
VBoxServiceError("Cat: Could not open input file \"%s\"! rc=%Rrc\n",
break;
}
default:
}
}
if (hInput != NIL_RTFILE)
if (hOutput != NIL_RTFILE)
return rc;
}
/**
* Main routine for toolbox command line handling.
*
* @return int
*
* @param argc
* @param argv
*/
{
int rc = VERR_NOT_FOUND;
{
}
if (rc != VERR_NOT_FOUND)
return rc;
}