Changeset 65827 in vbox for trunk/src/VBox
- Timestamp:
- Feb 21, 2017 8:49:45 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHostonly.cpp
r63300 r65827 44 44 using namespace com; 45 45 46 static const RTGETOPTDEF g_aHostOnlyCreateOptions[] = 47 { 48 { "--machinereadable", 'M', RTGETOPT_REQ_NOTHING }, 49 }; 50 46 51 #if defined(VBOX_WITH_NETFLT) && !defined(RT_OS_SOLARIS) 47 52 static RTEXITCODE handleCreate(HandlerArg *a) … … 50 55 * Parse input. 51 56 */ 57 bool fMachineReadable = false; 52 58 RTGETOPTUNION ValueUnion; 53 59 RTGETOPTSTATE GetState; 54 RTGetOptInit(&GetState, a->argc, a->argv, NULL, 0, 1, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 55 int ch = RTGetOpt(&GetState, &ValueUnion); 56 if (ch != 0) 57 return errorGetOpt(USAGE_HOSTONLYIFS, ch, &ValueUnion); 60 RTGetOptInit(&GetState, a->argc, a->argv, g_aHostOnlyCreateOptions, 61 RT_ELEMENTS(g_aHostOnlyCreateOptions), 1, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 62 int c; 63 while ((c = RTGetOpt(&GetState, &ValueUnion)) != 0) 64 { 65 switch (c) 66 { 67 case 'M': // --machinereadable 68 fMachineReadable = true; 69 break; 70 71 default: 72 return errorGetOpt(USAGE_HOSTONLYIFS, c, &ValueUnion); 73 } 74 } 58 75 59 76 /* … … 68 85 CHECK_ERROR2I_RET(host, CreateHostOnlyNetworkInterface(hif.asOutParam(), progress.asOutParam()), RTEXITCODE_FAILURE); 69 86 70 /*HRESULT hrc =*/ showProgress(progress); 71 CHECK_PROGRESS_ERROR_RET(progress, ("Failed to create the host-only adapter"), RTEXITCODE_FAILURE); 87 if (fMachineReadable) 88 { 89 CHECK_PROGRESS_ERROR_RET(progress, (""), RTEXITCODE_FAILURE); 90 } 91 else 92 { 93 /*HRESULT hrc =*/ showProgress(progress); 94 CHECK_PROGRESS_ERROR_RET(progress, ("Failed to create the host-only adapter"), RTEXITCODE_FAILURE); 95 } 72 96 73 97 Bstr bstrName; 74 98 CHECK_ERROR2I(hif, COMGETTER(Name)(bstrName.asOutParam())); 75 99 76 RTPrintf("Interface '%ls' was successfully created\n", bstrName.raw()); 77 100 if (fMachineReadable) 101 RTPrintf("%ls", bstrName.raw()); 102 else 103 RTPrintf("Interface '%ls' was successfully created\n", bstrName.raw()); 78 104 return RTEXITCODE_SUCCESS; 79 105 }
Note:
See TracChangeset
for help on using the changeset viewer.