Changeset 3077 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jun 7, 2007 1:09:42 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r2980 r3077 210 210 // funcs 211 211 /////////////////////////////////////////////////////////////////////////////// 212 213 static void showLogo(void) 214 { 215 static bool fShown; /* show only once */ 216 217 if (!fShown) 218 { 219 RTPrintf("VirtualBox Command Line Management Interface Version %s\n" 220 "(C) 2005-2007 innotek GmbH\n" 221 "All rights reserved.\n" 222 "\n", 223 VBOX_VERSION_STRING); 224 fShown = true; 225 } 226 } 212 227 213 228 static void printUsage(USAGECATEGORY u64Cmd) … … 244 259 RTPrintf("Usage:\n" 245 260 "\n"); 261 262 if (u64Cmd == USAGE_ALL) 263 { 264 RTPrintf("VBoxManage -nologo ... suppress the logo\n" 265 "\n"); 266 } 246 267 247 268 if (u64Cmd & USAGE_LIST) … … 567 588 { 568 589 va_list args; 590 showLogo(); // show logo even if suppressed 569 591 if (fInternalMode) 570 592 printUsageInternal(u64Cmd); … … 6105 6127 RTR3Init(false); 6106 6128 6107 RTPrintf("VirtualBox Command Line Management Interface Version %s\n" 6108 "(C) 2005-2007 innotek GmbH\n" 6109 "All rights reserved.\n" 6110 "\n", 6111 VBOX_VERSION_STRING); 6112 6113 /* shortcut for no parameters or help */ 6114 if ( (argc < 2) 6115 || (strcmp(argv[1], "help") == 0) 6116 || (strcmp(argv[1], "-?") == 0) 6117 || (strcmp(argv[1], "-h") == 0) 6118 || (strcmp(argv[1], "-help") == 0) 6119 || (strcmp(argv[1], "--help") == 0)) 6120 { 6121 printUsage(USAGE_ALL); 6122 return 0; 6123 } 6124 6125 /* Special option to dump really all commands, even the ones not 6126 * understood on this platform. */ 6127 if (argc == 2 && strcmp(argv[1], "-dumpopts") == 0) 6128 { 6129 printUsage(USAGE_DUMPOPTS); 6130 return 0; 6131 } 6129 bool fShowLogo = true; 6130 int iCmd = 1; 6131 int iCmdArg; 6132 6133 for (int i = 1; i < argc || argc <= iCmd; i++) 6134 { 6135 if ( argc <= iCmd 6136 || (strcmp(argv[i], "help") == 0) 6137 || (strcmp(argv[i], "-?") == 0) 6138 || (strcmp(argv[i], "-h") == 0) 6139 || (strcmp(argv[i], "-help") == 0) 6140 || (strcmp(argv[i], "--help") == 0)) 6141 { 6142 showLogo(); 6143 printUsage(USAGE_ALL); 6144 return 0; 6145 } 6146 else if (strcmp(argv[i], "-nologo") == 0) 6147 { 6148 /* suppress the logo */ 6149 fShowLogo = false; 6150 iCmd++; 6151 } 6152 else if (strcmp(argv[i], "-dumpopts") == 0) 6153 { 6154 /* Special option to dump really all commands, 6155 * even the ones not understood on this platform. */ 6156 printUsage(USAGE_DUMPOPTS); 6157 return 0; 6158 } 6159 else 6160 { 6161 break; 6162 } 6163 } 6164 6165 iCmdArg = iCmd + 1; 6166 6167 if (fShowLogo) 6168 showLogo(); 6132 6169 6133 6170 HRESULT rc; … … 6140 6177 * For simplicity, just convert the argv[] array here. 6141 6178 */ 6142 for (int i = 2; i < argc; i++)6179 for (int i = iCmdArg; i < argc; i++) 6143 6180 { 6144 6181 char *converted; … … 6153 6190 6154 6191 /* update settings command (no VirtualBox instantiation!) */ 6155 if (argc >= 2 && (strcmp(argv[1], "updatesettings") == 0))6156 { 6157 rc = handleUpdateSettings(argc - 2, argv + 2);6192 if (argc >= iCmdArg && (strcmp(argv[iCmd], "updatesettings") == 0)) 6193 { 6194 rc = handleUpdateSettings(argc - iCmdArg, argv + iCmdArg); 6158 6195 break; 6159 6196 } 6160 6197 6161 6198 /* convertdd: does not need a VirtualBox instantiation) */ 6162 if (argc >= 2 && (strcmp(argv[1], "convertdd") == 0))6163 { 6164 rc = handleConvertDDImage(argc - 2, argv + 2);6199 if (argc >= iCmdArg && (strcmp(argv[iCmd], "convertdd") == 0)) 6200 { 6201 rc = handleConvertDDImage(argc - iCmdArg, argv + iCmdArg); 6165 6202 break; 6166 6203 } … … 6189 6226 * (here it is necessary only to process remaining XPCOM/IPC events 6190 6227 * after the session is closed) */ 6228 6191 6229 EventQueue eventQ; 6192 6230 … … 6233 6271 for (commandIndex = 0; commandHandlers[commandIndex].command != NULL; commandIndex++) 6234 6272 { 6235 if (strcmp(commandHandlers[commandIndex].command, argv[ 1]) == 0)6236 { 6237 rc = commandHandlers[commandIndex].handler(argc - 2, &argv[2], virtualBox, session);6273 if (strcmp(commandHandlers[commandIndex].command, argv[iCmd]) == 0) 6274 { 6275 rc = commandHandlers[commandIndex].handler(argc - iCmdArg, &argv[iCmdArg], virtualBox, session); 6238 6276 break; 6239 6277 } … … 6241 6279 if (!commandHandlers[commandIndex].command) 6242 6280 { 6243 rc = errorSyntax(USAGE_ALL, "Invalid command '%s'", Utf8Str(argv[ 1]).raw());6281 rc = errorSyntax(USAGE_ALL, "Invalid command '%s'", Utf8Str(argv[iCmd]).raw()); 6244 6282 } 6245 6283 … … 6255 6293 * Free converted argument vector 6256 6294 */ 6257 for (int i = 2; i < argc; i++) 6258 { 6295 for (int i = iCmdArg; i < argc; i++) 6259 6296 RTStrFree(argv[i]); 6260 }6261 6297 6262 6298 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.