VirtualBox

Changeset 70431 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Jan 2, 2018 3:14:30 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
120036
Message:

VBoxControl: Added gzip, ls, tar and unzip commands.

Location:
trunk/src/VBox/Additions/common/VBoxControl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxControl/Makefile.kmk

    r70344 r70431  
    4343VBoxControl_DEFS.win += \
    4444        $(if $(VBOX_WITH_DPC_LATENCY_CHECKER),VBOX_WITH_DPC_LATENCY_CHECKER,)
     45VBoxControl_SDKS = VBOX_ZLIB_STATIC
    4546VBoxControl_SOURCES = \
    4647        VBoxControl.cpp
  • trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp

    r70211 r70431  
    3030#include <iprt/string.h>
    3131#include <iprt/stream.h>
     32#include <iprt/zip.h>
    3233#include <VBox/log.h>
    3334#include <VBox/version.h>
     
    18471848}
    18481849
     1850/**
     1851 * @callback_method_impl{FNVBOXCTRLCMDHANDLER, Command: ls}
     1852 */
     1853static DECLCALLBACK(RTEXITCODE) handleLs(int argc, char *argv[])
     1854{
     1855    return RTFsCmdLs(argc + 1, argv - 1);
     1856}
     1857
     1858/**
     1859 * @callback_method_impl{FNVBOXCTRLCMDHANDLER, Command: tar}
     1860 */
     1861static DECLCALLBACK(RTEXITCODE) handleTar(int argc, char *argv[])
     1862{
     1863    return RTZipTarCmd(argc + 1, argv - 1);
     1864}
     1865
     1866/**
     1867 * @callback_method_impl{FNVBOXCTRLCMDHANDLER, Command: tar}
     1868 */
     1869static DECLCALLBACK(RTEXITCODE) handleGzip(int argc, char *argv[])
     1870{
     1871    return RTZipGzipCmd(argc + 1, argv - 1);
     1872}
     1873
     1874/**
     1875 * @callback_method_impl{FNVBOXCTRLCMDHANDLER, Command: unzip}
     1876 */
     1877static DECLCALLBACK(RTEXITCODE) handleUnzip(int argc, char *argv[])
     1878{
     1879    return RTZipUnzipCmd(argc + 1, argv - 1);
     1880}
     1881
    18491882
    18501883/** command handler type */
     
    18551888struct COMMANDHANDLER
    18561889{
    1857     const char *pszCommand;
    1858     PFNVBOXCTRLCMDHANDLER pfnHandler;
     1890    const char             *pszCommand;
     1891    PFNVBOXCTRLCMDHANDLER   pfnHandler;
     1892    bool                    fNeedDevice;
    18591893} g_aCommandHandlers[] =
    18601894{
    18611895#if defined(RT_OS_WINDOWS) && !defined(VBOX_CONTROL_TEST)
    1862     { "getvideoacceleration",   handleGetVideoAcceleration },
    1863     { "setvideoacceleration",   handleSetVideoAcceleration },
    1864     { "videoflags",             handleVideoFlags },
    1865     { "listcustommodes",        handleListCustomModes },
    1866     { "addcustommode",          handleAddCustomMode },
    1867     { "removecustommode",       handleRemoveCustomMode },
    1868     { "setvideomode",           handleSetVideoMode },
     1896    { "getvideoacceleration",   handleGetVideoAcceleration, true },
     1897    { "setvideoacceleration",   handleSetVideoAcceleration, true },
     1898    { "videoflags",             handleVideoFlags,           true },
     1899    { "listcustommodes",        handleListCustomModes,      true },
     1900    { "addcustommode",          handleAddCustomMode,        true },
     1901    { "removecustommode",       handleRemoveCustomMode,     true },
     1902    { "setvideomode",           handleSetVideoMode,         true },
    18691903#endif
    18701904#ifdef VBOX_WITH_GUEST_PROPS
    1871     { "guestproperty",          handleGuestProperty },
     1905    { "guestproperty",          handleGuestProperty,        true },
    18721906#endif
    18731907#ifdef VBOX_WITH_SHARED_FOLDERS
    1874     { "sharedfolder",           handleSharedFolder },
     1908    { "sharedfolder",           handleSharedFolder,         true },
    18751909#endif
    18761910#if !defined(VBOX_CONTROL_TEST)
    1877     { "writecoredump",          handleWriteCoreDump },
     1911    { "writecoredump",          handleWriteCoreDump,        true },
    18781912#endif
    18791913#ifdef VBOX_WITH_DPC_LATENCY_CHECKER
    1880     { "dpc",                    handleDpc },
     1914    { "dpc",                    handleDpc,                  true },
    18811915#endif
    1882     { "writelog",               handleWriteLog },
    1883     { "takesnapshot",           handleTakeSnapshot },
    1884     { "savestate",              handleSaveState },
    1885     { "suspend",                handleSuspend },
    1886     { "pause",                  handleSuspend },
    1887     { "poweroff",               handlePowerOff },
    1888     { "powerdown",              handlePowerOff },
    1889     { "getversion",             handleVersion },
    1890     { "version",                handleVersion },
    1891     { "help",                   handleHelp }
     1916    { "writelog",               handleWriteLog,             true  },
     1917    { "takesnapshot",           handleTakeSnapshot,         true  },
     1918    { "savestate",              handleSaveState,            true  },
     1919    { "suspend",                handleSuspend,              true  },
     1920    { "pause",                  handleSuspend,              true  },
     1921    { "poweroff",               handlePowerOff,             true  },
     1922    { "powerdown",              handlePowerOff,             true  },
     1923    { "getversion",             handleVersion,              false },
     1924    { "version",                handleVersion,              false },
     1925    { "help",                   handleHelp,                 false },
     1926    /* Hany tricks that doesn't cost much space: */
     1927    { "gzip",                   handleGzip,                 false },
     1928    { "ls",                     handleLs,                   false },
     1929    { "tar",                    handleTar,                  false },
     1930    { "unzip",                  handleUnzip,                false },
    18921931};
    18931932
     
    19632002
    19642003    /*
    1965      * Do global initialisation for the programme if we will be handling a command
    1966      */
    1967     if (!fOnlyInfo)
    1968     {
    1969         rrc = VbglR3Init();
    1970         if (RT_FAILURE(rrc))
    1971         {
    1972             VBoxControlError("Could not contact the host system.  Make sure that you are running this\n"
    1973                              "application inside a VirtualBox guest system, and that you have sufficient\n"
    1974                              "user permissions.\n");
    1975             rcExit = RTEXITCODE_FAILURE;
    1976         }
    1977     }
    1978 
    1979     /*
    19802004     * Now look for an actual command in the argument list and handle it.
    19812005     */
    1982 
    19832006    if (!fOnlyInfo && rcExit == RTEXITCODE_SUCCESS)
    19842007    {
     
    19922015                if (!strcmp(argv[iArg], g_aCommandHandlers[i].pszCommand))
    19932016                {
    1994                     rcExit = g_aCommandHandlers[i].pfnHandler(argc - iArg - 1, argv + iArg + 1);
     2017                    if (g_aCommandHandlers[i].fNeedDevice)
     2018                    {
     2019                        rrc = VbglR3Init();
     2020                        if (RT_FAILURE(rrc))
     2021                        {
     2022                            VBoxControlError("Could not contact the host system.  Make sure that you are running this\n"
     2023                                             "application inside a VirtualBox guest system, and that you have sufficient\n"
     2024                                             "user permissions.\n");
     2025                            rcExit = RTEXITCODE_FAILURE;
     2026                        }
     2027                    }
     2028                    if (rcExit == RTEXITCODE_SUCCESS)
     2029                        rcExit = g_aCommandHandlers[i].pfnHandler(argc - iArg - 1, argv + iArg + 1);
    19952030                    break;
    19962031                }
    19972032            if (i >= RT_ELEMENTS(g_aCommandHandlers))
    19982033            {
    1999                 rcExit = RTEXITCODE_FAILURE;
    20002034                usage();
     2035                rcExit = RTEXITCODE_SYNTAX;
    20012036            }
    20022037        }
     
    20042039        {
    20052040            /* The user didn't specify a command. */
    2006             rcExit = RTEXITCODE_FAILURE;
    20072041            usage();
     2042            rcExit = RTEXITCODE_SYNTAX;
    20082043        }
    20092044    }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette