Changeset 70431 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Jan 2, 2018 3:14:30 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 120036
- Location:
- trunk/src/VBox/Additions/common/VBoxControl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxControl/Makefile.kmk
r70344 r70431 43 43 VBoxControl_DEFS.win += \ 44 44 $(if $(VBOX_WITH_DPC_LATENCY_CHECKER),VBOX_WITH_DPC_LATENCY_CHECKER,) 45 VBoxControl_SDKS = VBOX_ZLIB_STATIC 45 46 VBoxControl_SOURCES = \ 46 47 VBoxControl.cpp -
trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp
r70211 r70431 30 30 #include <iprt/string.h> 31 31 #include <iprt/stream.h> 32 #include <iprt/zip.h> 32 33 #include <VBox/log.h> 33 34 #include <VBox/version.h> … … 1847 1848 } 1848 1849 1850 /** 1851 * @callback_method_impl{FNVBOXCTRLCMDHANDLER, Command: ls} 1852 */ 1853 static 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 */ 1861 static 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 */ 1869 static 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 */ 1877 static DECLCALLBACK(RTEXITCODE) handleUnzip(int argc, char *argv[]) 1878 { 1879 return RTZipUnzipCmd(argc + 1, argv - 1); 1880 } 1881 1849 1882 1850 1883 /** command handler type */ … … 1855 1888 struct COMMANDHANDLER 1856 1889 { 1857 const char *pszCommand; 1858 PFNVBOXCTRLCMDHANDLER pfnHandler; 1890 const char *pszCommand; 1891 PFNVBOXCTRLCMDHANDLER pfnHandler; 1892 bool fNeedDevice; 1859 1893 } g_aCommandHandlers[] = 1860 1894 { 1861 1895 #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 }, 1869 1903 #endif 1870 1904 #ifdef VBOX_WITH_GUEST_PROPS 1871 { "guestproperty", handleGuestProperty },1905 { "guestproperty", handleGuestProperty, true }, 1872 1906 #endif 1873 1907 #ifdef VBOX_WITH_SHARED_FOLDERS 1874 { "sharedfolder", handleSharedFolder },1908 { "sharedfolder", handleSharedFolder, true }, 1875 1909 #endif 1876 1910 #if !defined(VBOX_CONTROL_TEST) 1877 { "writecoredump", handleWriteCoreDump },1911 { "writecoredump", handleWriteCoreDump, true }, 1878 1912 #endif 1879 1913 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER 1880 { "dpc", handleDpc },1914 { "dpc", handleDpc, true }, 1881 1915 #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 }, 1892 1931 }; 1893 1932 … … 1963 2002 1964 2003 /* 1965 * Do global initialisation for the programme if we will be handling a command1966 */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 /*1980 2004 * Now look for an actual command in the argument list and handle it. 1981 2005 */ 1982 1983 2006 if (!fOnlyInfo && rcExit == RTEXITCODE_SUCCESS) 1984 2007 { … … 1992 2015 if (!strcmp(argv[iArg], g_aCommandHandlers[i].pszCommand)) 1993 2016 { 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); 1995 2030 break; 1996 2031 } 1997 2032 if (i >= RT_ELEMENTS(g_aCommandHandlers)) 1998 2033 { 1999 rcExit = RTEXITCODE_FAILURE;2000 2034 usage(); 2035 rcExit = RTEXITCODE_SYNTAX; 2001 2036 } 2002 2037 } … … 2004 2039 { 2005 2040 /* The user didn't specify a command. */ 2006 rcExit = RTEXITCODE_FAILURE;2007 2041 usage(); 2042 rcExit = RTEXITCODE_SYNTAX; 2008 2043 } 2009 2044 }
Note:
See TracChangeset
for help on using the changeset viewer.