Changeset 33759 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Nov 4, 2010 10:54:04 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp
r33556 r33759 61 61 return "Unknown"; 62 62 } 63 #endif 63 #endif /* VBOX_WITH_HOSTNETIF_API */ 64 64 65 65 static const char*getDeviceTypeText(DeviceType_T enmType) … … 186 186 } 187 187 188 enum enOptionCodes 188 /** 189 * The type of lists we can produce. 190 */ 191 enum enmListType 189 192 { 190 LISTVMS = 1000, 191 LISTRUNNINGVMS, 192 LISTOSTYPES, 193 LISTHOSTDVDS, 194 LISTHOSTFLOPPIES, 195 LISTBRIDGEDIFS, 193 kListNotSpecified = 1000, 194 kListVMs, 195 kListRunningVMs, 196 kListOsTypes, 197 kListHostDvds, 198 kListHostFloppies, 199 kListBridgedInterfaces, 196 200 #if defined(VBOX_WITH_NETFLT) 197 LISTHOSTONLYIFS,201 kListHostOnlyInterfaces, 198 202 #endif 199 LISTHOSTCPUIDS,200 LISTHOSTINFO,201 LISTHDDBACKENDS,202 LISTHDDS,203 LISTDVDS,204 LISTFLOPPIES,205 LISTUSBHOST,206 LISTUSBFILTERS,207 LISTSYSTEMPROPERTIES,208 LISTDHCPSERVERS,209 LISTVRDELIBRARIES203 kListHostCpuIDs, 204 kListHostInfo, 205 kListHddBackends, 206 kListHdds, 207 kListDvds, 208 kListFloppies, 209 kListUsbHost, 210 kListUsbFilters, 211 kListSystemProperties, 212 kListDhcpServers, 213 kListVrdeLibraries 210 214 }; 211 215 212 static const RTGETOPTDEF g_aListOptions[] 213 = { 214 { "--long", 'l', RTGETOPT_REQ_NOTHING }, 215 { "vms", LISTVMS, RTGETOPT_REQ_NOTHING }, 216 { "runningvms", LISTRUNNINGVMS, RTGETOPT_REQ_NOTHING }, 217 { "ostypes", LISTOSTYPES, RTGETOPT_REQ_NOTHING }, 218 { "hostdvds", LISTHOSTDVDS, RTGETOPT_REQ_NOTHING }, 219 { "hostfloppies", LISTHOSTFLOPPIES, RTGETOPT_REQ_NOTHING }, 220 { "hostifs", LISTBRIDGEDIFS, RTGETOPT_REQ_NOTHING }, /* backward compatibility */ 221 { "bridgedifs", LISTBRIDGEDIFS, RTGETOPT_REQ_NOTHING }, 222 #if defined(VBOX_WITH_NETFLT) 223 { "hostonlyifs", LISTHOSTONLYIFS, RTGETOPT_REQ_NOTHING }, 224 #endif 225 { "hostinfo", LISTHOSTINFO, RTGETOPT_REQ_NOTHING }, 226 { "hostcpuids", LISTHOSTCPUIDS, RTGETOPT_REQ_NOTHING }, 227 { "hddbackends", LISTHDDBACKENDS, RTGETOPT_REQ_NOTHING }, 228 { "hdds", LISTHDDS, RTGETOPT_REQ_NOTHING }, 229 { "dvds", LISTDVDS, RTGETOPT_REQ_NOTHING }, 230 { "floppies", LISTFLOPPIES, RTGETOPT_REQ_NOTHING }, 231 { "usbhost", LISTUSBHOST, RTGETOPT_REQ_NOTHING }, 232 { "usbfilters", LISTUSBFILTERS, RTGETOPT_REQ_NOTHING }, 233 { "systemproperties", LISTSYSTEMPROPERTIES, RTGETOPT_REQ_NOTHING }, 234 { "dhcpservers", LISTDHCPSERVERS, RTGETOPT_REQ_NOTHING }, 235 { "vrdelibraries", LISTVRDELIBRARIES, RTGETOPT_REQ_NOTHING }, 236 }; 237 238 int handleList(HandlerArg *a) 216 217 /** 218 * Produces the specified listing. 219 * 220 * @returns S_OK or some COM error code that has been reported in full. 221 * @param enmList The list to produce. 222 * @param fOptLong Long (@c true) or short list format. 223 * @param rptrVirtualBox Reference to the IVirtualBox smart pointer. 224 */ 225 static HRESULT produceList(enum enmListType enmCommand, bool fOptLong, const ComPtr<IVirtualBox> &rptrVirtualBox) 239 226 { 240 227 HRESULT rc = S_OK; 241 242 bool fOptLong = false; 243 244 int command = 0; 245 int c; 246 247 RTGETOPTUNION ValueUnion; 248 RTGETOPTSTATE GetState; 249 RTGetOptInit(&GetState, a->argc, a->argv, g_aListOptions, RT_ELEMENTS(g_aListOptions), 250 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 251 while ((c = RTGetOpt(&GetState, &ValueUnion))) 228 switch (enmCommand) 252 229 { 253 switch (c) 254 { 255 case 'l': // --long 256 fOptLong = true; 257 break; 258 259 case LISTVMS: 260 case LISTRUNNINGVMS: 261 case LISTOSTYPES: 262 case LISTHOSTDVDS: 263 case LISTHOSTFLOPPIES: 264 case LISTBRIDGEDIFS: 265 #if defined(VBOX_WITH_NETFLT) 266 case LISTHOSTONLYIFS: 267 #endif 268 case LISTHOSTINFO: 269 case LISTHOSTCPUIDS: 270 case LISTHDDBACKENDS: 271 case LISTHDDS: 272 case LISTDVDS: 273 case LISTFLOPPIES: 274 case LISTUSBHOST: 275 case LISTUSBFILTERS: 276 case LISTSYSTEMPROPERTIES: 277 case LISTDHCPSERVERS: 278 case LISTVRDELIBRARIES: 279 if (command) 280 return errorSyntax(USAGE_LIST, "Too many subcommands for \"list\" command.\n"); 281 282 command = c; 283 break; 284 285 case VINF_GETOPT_NOT_OPTION: 286 return errorSyntax(USAGE_LIST, "Unknown subcommand \"%s\".", ValueUnion.psz); 287 break; 288 289 default: 290 if (c > 0) 291 { 292 if (RT_C_IS_GRAPH(c)) 293 return errorSyntax(USAGE_LIST, "unhandled option: -%c", c); 294 else 295 return errorSyntax(USAGE_LIST, "unhandled option: %i", c); 296 } 297 else if (c == VERR_GETOPT_UNKNOWN_OPTION) 298 return errorSyntax(USAGE_LIST, "unknown option: %s", ValueUnion.psz); 299 else if (ValueUnion.pDef) 300 return errorSyntax(USAGE_LIST, "%s: %Rrs", ValueUnion.pDef->pszLong, c); 301 else 302 return errorSyntax(USAGE_LIST, "%Rrs", c); 303 } 304 } 305 306 if (!command) 307 return errorSyntax(USAGE_LIST, "Missing subcommand for \"list\" command.\n"); 308 309 /* which object? */ 310 switch (command) 311 { 312 case LISTVMS: 230 case kListNotSpecified: 231 AssertFailed(); 232 return E_FAIL; 233 234 case kListVMs: 313 235 { 314 236 /* 315 237 * Get the list of all registered VMs 316 238 */ 317 com::SafeIfaceArray 318 rc = a->virtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));239 com::SafeIfaceArray<IMachine> machines; 240 rc = rptrVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines)); 319 241 if (SUCCEEDED(rc)) 320 242 { … … 325 247 { 326 248 if (machines[i]) 327 rc = showVMInfo(a->virtualBox, 328 machines[i], 329 (fOptLong) ? VMINFO_STANDARD : VMINFO_COMPACT); 330 } 331 } 332 } 333 break; 334 335 case LISTRUNNINGVMS: 249 rc = showVMInfo(rptrVirtualBox, machines[i], fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT); 250 } 251 } 252 break; 253 } 254 255 case kListRunningVMs: 336 256 { 337 257 /* 338 258 * Get the list of all _running_ VMs 339 259 */ 340 com::SafeIfaceArray 341 rc = a->virtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));260 com::SafeIfaceArray<IMachine> machines; 261 rc = rptrVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines)); 342 262 if (SUCCEEDED(rc)) 343 263 { … … 360 280 case MachineState_Paused: 361 281 case MachineState_TeleportingPausedVM: 362 rc = showVMInfo(a->virtualBox, 363 machines[i], 364 (fOptLong) ? VMINFO_STANDARD : VMINFO_COMPACT); 282 rc = showVMInfo(rptrVirtualBox, machines[i], fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT); 283 break; 365 284 } 366 285 } … … 368 287 } 369 288 } 370 }371 break;372 373 case LISTOSTYPES:374 { 375 com::SafeIfaceArray 376 rc = a->virtualBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(coll));289 break; 290 } 291 292 case kListOsTypes: 293 { 294 com::SafeIfaceArray<IGuestOSType> coll; 295 rc = rptrVirtualBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(coll)); 377 296 if (SUCCEEDED(rc)) 378 297 { … … 392 311 } 393 312 } 394 }395 break;396 397 case LISTHOSTDVDS:313 break; 314 } 315 316 case kListHostDvds: 398 317 { 399 318 ComPtr<IHost> host; 400 CHECK_ERROR( a->virtualBox, COMGETTER(Host)(host.asOutParam()));401 com::SafeIfaceArray 319 CHECK_ERROR(rptrVirtualBox, COMGETTER(Host)(host.asOutParam())); 320 com::SafeIfaceArray<IMedium> coll; 402 321 CHECK_ERROR(host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll))); 403 322 if (SUCCEEDED(rc)) … … 414 333 } 415 334 } 416 }417 break;418 419 case LISTHOSTFLOPPIES:335 break; 336 } 337 338 case kListHostFloppies: 420 339 { 421 340 ComPtr<IHost> host; 422 CHECK_ERROR( a->virtualBox, COMGETTER(Host)(host.asOutParam()));423 com::SafeIfaceArray 341 CHECK_ERROR(rptrVirtualBox, COMGETTER(Host)(host.asOutParam())); 342 com::SafeIfaceArray<IMedium> coll; 424 343 CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(coll))); 425 344 if (SUCCEEDED(rc)) … … 436 355 } 437 356 } 438 } 439 break; 440 441 case LISTBRIDGEDIFS: 357 break; 358 } 359 360 /** @todo function. */ 361 case kListBridgedInterfaces: 442 362 #if defined(VBOX_WITH_NETFLT) 443 case LISTHOSTONLYIFS:363 case kListHostOnlyInterfaces: 444 364 #endif 445 365 { 446 366 ComPtr<IHost> host; 447 CHECK_ERROR( a->virtualBox, COMGETTER(Host)(host.asOutParam()));448 com::SafeIfaceArray 367 CHECK_ERROR(rptrVirtualBox, COMGETTER(Host)(host.asOutParam())); 368 com::SafeIfaceArray<IHostNetworkInterface> hostNetworkInterfaces; 449 369 #if defined(VBOX_WITH_NETFLT) 450 if ( command == LISTBRIDGEDIFS)370 if (enmCommand == kListBridgedInterfaces) 451 371 CHECK_ERROR(host, FindHostNetworkInterfacesOfType(HostNetworkInterfaceType_Bridged, 452 372 ComSafeArrayAsOutParam(hostNetworkInterfaces))); … … 502 422 networkInterface->COMGETTER(NetworkName)(netName.asOutParam()); 503 423 RTPrintf("VBoxNetworkName: %lS\n\n", netName.raw()); 504 505 424 #endif 506 425 } 507 } 508 break; 509 510 case LISTHOSTINFO: 426 break; 427 } 428 429 /** @todo function. */ 430 case kListHostInfo: 511 431 { 512 432 ComPtr<IHost> Host; 513 CHECK_ERROR( a->virtualBox, COMGETTER(Host)(Host.asOutParam()));433 CHECK_ERROR(rptrVirtualBox, COMGETTER(Host)(Host.asOutParam())); 514 434 515 435 RTPrintf("Host Information:\n\n"); 516 436 517 LONG64 uTCTime = 0; 518 CHECK_ERROR(Host, COMGETTER(UTCTime)(&uTCTime)); 519 RTTIMESPEC timeSpec; 520 RTTimeSpecSetMilli(&timeSpec, uTCTime); 521 char szTime[32] = {0}; 522 RTTimeSpecToString(&timeSpec, szTime, sizeof(szTime)); 523 RTPrintf("Host time: %s\n", szTime); 437 LONG64 u64UtcTime = 0; 438 CHECK_ERROR(Host, COMGETTER(UTCTime)(&u64UtcTime)); 439 RTTIMESPEC timeSpec; 440 char szTime[32]; 441 RTPrintf("Host time: %s\n", RTTimeSpecToString(RTTimeSpecSetMilli(&timeSpec, u64UtcTime), szTime, sizeof(szTime))); 524 442 525 443 ULONG processorOnlineCount = 0; … … 557 475 CHECK_ERROR(Host, COMGETTER(OSVersion)(oSVersion.asOutParam())); 558 476 RTPrintf("Operating system version: %lS\n", oSVersion.raw()); 559 }560 break;561 562 case LISTHOSTCPUIDS:477 break; 478 } 479 480 case kListHostCpuIDs: 563 481 { 564 482 ComPtr<IHost> Host; 565 CHECK_ERROR( a->virtualBox, COMGETTER(Host)(Host.asOutParam()));483 CHECK_ERROR(rptrVirtualBox, COMGETTER(Host)(Host.asOutParam())); 566 484 567 485 RTPrintf("Host CPUIDs:\n\nLeaf no. EAX EBX ECX EDX\n"); … … 586 504 } 587 505 } 588 } 589 break; 590 591 case LISTHDDBACKENDS: 592 { 593 ComPtr<ISystemProperties> systemProperties; 594 CHECK_ERROR(a->virtualBox, 595 COMGETTER(SystemProperties)(systemProperties.asOutParam())); 596 com::SafeIfaceArray <IMediumFormat> mediumFormats; 597 CHECK_ERROR(systemProperties, 598 COMGETTER(MediumFormats)(ComSafeArrayAsOutParam(mediumFormats))); 506 break; 507 } 508 509 /** @todo function. */ 510 case kListHddBackends: 511 { 512 ComPtr<ISystemProperties> systemProperties; 513 CHECK_ERROR(rptrVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam())); 514 com::SafeIfaceArray<IMediumFormat> mediumFormats; 515 CHECK_ERROR(systemProperties, COMGETTER(MediumFormats)(ComSafeArrayAsOutParam(mediumFormats))); 599 516 600 517 RTPrintf("Supported hard disk backends:\n\n"); … … 663 580 RTPrintf(")\n"); 664 581 } 665 }666 break;667 668 case LISTHDDS:582 break; 583 } 584 585 case kListHdds: 669 586 { 670 587 com::SafeIfaceArray<IMedium> hdds; 671 CHECK_ERROR( a->virtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hdds)));672 listMedia( a->virtualBox, hdds, "base");673 }674 break;675 676 case LISTDVDS:588 CHECK_ERROR(rptrVirtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hdds))); 589 listMedia(rptrVirtualBox, hdds, "base"); 590 break; 591 } 592 593 case kListDvds: 677 594 { 678 595 com::SafeIfaceArray<IMedium> dvds; 679 CHECK_ERROR( a->virtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds)));680 listMedia( a->virtualBox, dvds, NULL);681 }682 break;683 684 case LISTFLOPPIES:596 CHECK_ERROR(rptrVirtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds))); 597 listMedia(rptrVirtualBox, dvds, NULL); 598 break; 599 } 600 601 case kListFloppies: 685 602 { 686 603 com::SafeIfaceArray<IMedium> floppies; 687 CHECK_ERROR(a->virtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies))); 688 listMedia(a->virtualBox, floppies, NULL); 689 } 690 break; 691 692 case LISTUSBHOST: 604 CHECK_ERROR(rptrVirtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies))); 605 listMedia(rptrVirtualBox, floppies, NULL); 606 break; 607 } 608 609 /** @todo function. */ 610 case kListUsbHost: 693 611 { 694 612 ComPtr<IHost> Host; 695 CHECK_ERROR_RET( a->virtualBox, COMGETTER(Host)(Host.asOutParam()), 1);613 CHECK_ERROR_RET(rptrVirtualBox, COMGETTER(Host)(Host.asOutParam()), 1); 696 614 697 615 SafeIfaceArray <IHostUSBDevice> CollPtr; … … 751 669 { 752 670 case USBDeviceState_NotSupported: 753 pszState = "Not supported"; break; 671 pszState = "Not supported"; 672 break; 754 673 case USBDeviceState_Unavailable: 755 pszState = "Unavailable"; break; 674 pszState = "Unavailable"; 675 break; 756 676 case USBDeviceState_Busy: 757 pszState = "Busy"; break; 677 pszState = "Busy"; 678 break; 758 679 case USBDeviceState_Available: 759 pszState = "Available"; break; 680 pszState = "Available"; 681 break; 760 682 case USBDeviceState_Held: 761 pszState = "Held"; break; 683 pszState = "Held"; 684 break; 762 685 case USBDeviceState_Captured: 763 pszState = "Captured"; break; 686 pszState = "Captured"; 687 break; 764 688 default: 765 689 ASSERT(false); … … 769 693 } 770 694 } 771 } 772 break; 773 774 case LISTUSBFILTERS: 695 break; 696 } 697 698 /** @todo function. */ 699 case kListUsbFilters: 775 700 { 776 701 RTPrintf("Global USB Device Filters:\n\n"); 777 702 778 ComPtr 779 CHECK_ERROR_RET( a->virtualBox, COMGETTER(Host)(host.asOutParam()), 1);780 781 SafeIfaceArray 703 ComPtr<IHost> host; 704 CHECK_ERROR_RET(rptrVirtualBox, COMGETTER(Host)(host.asOutParam()), 1); 705 706 SafeIfaceArray<IHostUSBDeviceFilter> coll; 782 707 CHECK_ERROR_RET(host, COMGETTER(USBDeviceFilters)(ComSafeArrayAsOutParam(coll)), 1); 783 708 … … 833 758 } 834 759 } 835 } 836 break; 837 838 case LISTSYSTEMPROPERTIES: 760 break; 761 } 762 763 /** @todo function. */ 764 case kListSystemProperties: 839 765 { 840 766 ComPtr<ISystemProperties> systemProperties; 841 a->virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());767 rptrVirtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam()); 842 768 843 769 Bstr str; … … 907 833 systemProperties->COMGETTER(LogHistoryCount)(&ulValue); 908 834 RTPrintf("Log history count: %u\n", ulValue); 909 910 } 911 break; 912 case LISTDHCPSERVERS:835 break; 836 } 837 838 case kListDhcpServers: 913 839 { 914 840 com::SafeIfaceArray<IDHCPServer> svrs; 915 CHECK_ERROR( a->virtualBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(svrs)));841 CHECK_ERROR(rptrVirtualBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(svrs))); 916 842 for (size_t i = 0; i < svrs.size(); ++i) 917 843 { … … 932 858 svr->COMGETTER(UpperIP)(upperIp.asOutParam()); 933 859 RTPrintf("upperIPAddress: %lS\n", upperIp.raw()); 934 BOOL bEnabled;935 svr->COMGETTER(Enabled)(& bEnabled);936 RTPrintf("Enabled: %s\n", bEnabled ? "Yes" : "No");860 BOOL fEnabled; 861 svr->COMGETTER(Enabled)(&fEnabled); 862 RTPrintf("Enabled: %s\n", fEnabled ? "Yes" : "No"); 937 863 RTPrintf("\n"); 938 864 } 939 } 940 break; 941 case LISTVRDELIBRARIES: 865 break; 866 } 867 868 case kListVrdeLibraries: 942 869 { 943 870 SafeArray<BSTR> libs; 944 CHECK_ERROR( a->virtualBox, VRDEListLibraries(ComSafeArrayAsOutParam(libs)));871 CHECK_ERROR(rptrVirtualBox, VRDEListLibraries(ComSafeArrayAsOutParam(libs))); 945 872 for (size_t i = 0; i < libs.size(); ++i) 946 873 { … … 948 875 RTPrintf("%lS\n", bstrName.raw()); 949 876 } 950 } 951 break; 952 } // end switch 953 954 return SUCCEEDED(rc) ? 0 : 1; 877 break; 878 } 879 880 /* No default here, want gcc warnings. */ 881 882 } /* end switch */ 883 884 return rc; 885 } 886 887 /** 888 * Handles the 'list' command. 889 * 890 * @returns Appropriate exit code. 891 * @param a Handler argument. 892 */ 893 int handleList(HandlerArg *a) 894 { 895 bool fOptLong = false; 896 bool fOptMultiple = false; 897 enum enmListType enmOptCommand = kListNotSpecified; 898 899 static const RTGETOPTDEF s_aListOptions[] = 900 { 901 { "--long", 'l', RTGETOPT_REQ_NOTHING }, 902 { "--multiple", 'm', RTGETOPT_REQ_NOTHING }, /* not offical yet */ 903 { "vms", kListVMs, RTGETOPT_REQ_NOTHING }, 904 { "runningvms", kListRunningVMs, RTGETOPT_REQ_NOTHING }, 905 { "ostypes", kListOsTypes, RTGETOPT_REQ_NOTHING }, 906 { "hostdvds", kListHostDvds, RTGETOPT_REQ_NOTHING }, 907 { "hostfloppies", kListHostFloppies, RTGETOPT_REQ_NOTHING }, 908 { "hostifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING }, /* backward compatibility */ 909 { "bridgedifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING }, 910 #if defined(VBOX_WITH_NETFLT) 911 { "hostonlyifs", kListHostOnlyInterfaces, RTGETOPT_REQ_NOTHING }, 912 #endif 913 { "hostinfo", kListHostInfo, RTGETOPT_REQ_NOTHING }, 914 { "hostcpuids", kListHostCpuIDs, RTGETOPT_REQ_NOTHING }, 915 { "hddbackends", kListHddBackends, RTGETOPT_REQ_NOTHING }, 916 { "hdds", kListHdds, RTGETOPT_REQ_NOTHING }, 917 { "dvds", kListDvds, RTGETOPT_REQ_NOTHING }, 918 { "floppies", kListFloppies, RTGETOPT_REQ_NOTHING }, 919 { "usbhost", kListUsbHost, RTGETOPT_REQ_NOTHING }, 920 { "usbfilters", kListUsbFilters, RTGETOPT_REQ_NOTHING }, 921 { "systemproperties", kListSystemProperties, RTGETOPT_REQ_NOTHING }, 922 { "dhcpservers", kListDhcpServers, RTGETOPT_REQ_NOTHING }, 923 { "vrdelibraries", kListVrdeLibraries, RTGETOPT_REQ_NOTHING }, 924 }; 925 926 int ch; 927 RTGETOPTUNION ValueUnion; 928 RTGETOPTSTATE GetState; 929 RTGetOptInit(&GetState, a->argc, a->argv, s_aListOptions, RT_ELEMENTS(s_aListOptions), 930 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 931 while ((ch = RTGetOpt(&GetState, &ValueUnion))) 932 { 933 switch (ch) 934 { 935 case 'l': /* --long */ 936 fOptLong = true; 937 break; 938 939 case 'm': 940 fOptMultiple = true; 941 if (enmOptCommand == kListNotSpecified) 942 break; 943 ch = enmOptCommand; 944 /* fall thru */ 945 946 case kListVMs: 947 case kListRunningVMs: 948 case kListOsTypes: 949 case kListHostDvds: 950 case kListHostFloppies: 951 case kListBridgedInterfaces: 952 #if defined(VBOX_WITH_NETFLT) 953 case kListHostOnlyInterfaces: 954 #endif 955 case kListHostInfo: 956 case kListHostCpuIDs: 957 case kListHddBackends: 958 case kListHdds: 959 case kListDvds: 960 case kListFloppies: 961 case kListUsbHost: 962 case kListUsbFilters: 963 case kListSystemProperties: 964 case kListDhcpServers: 965 case kListVrdeLibraries: 966 enmOptCommand = (enum enmListType)ch; 967 if (fOptMultiple) 968 { 969 HRESULT hrc = produceList((enum enmListType)ch, fOptLong, a->virtualBox); 970 if (FAILED(hrc)) 971 return 1; 972 } 973 break; 974 975 case VINF_GETOPT_NOT_OPTION: 976 return errorSyntax(USAGE_LIST, "Unknown subcommand \"%s\".", ValueUnion.psz); 977 978 default: 979 return errorGetOpt(USAGE_LIST, ch, &ValueUnion); 980 } 981 } 982 983 /* 984 * If not in multiple list mode, we have to produce the list now. 985 */ 986 if (enmOptCommand == kListNotSpecified) 987 return errorSyntax(USAGE_LIST, "Missing subcommand for \"list\" command.\n"); 988 if (!fOptMultiple) 989 { 990 HRESULT hrc = produceList(enmOptCommand, fOptLong, a->virtualBox); 991 if (FAILED(hrc)) 992 return 1; 993 } 994 995 return 0; 955 996 } 956 997
Note:
See TracChangeset
for help on using the changeset viewer.