Changeset 35947 in vbox for trunk/src/VBox
- Timestamp:
- Feb 11, 2011 6:09:45 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r35937 r35947 97 97 { 98 98 RTGETOPTDEF_EXEC_IGNOREORPHANEDPROCESSES = 1000, 99 RTGETOPTDEF_EXEC_OUTPUTFORMAT, 100 RTGETOPTDEF_EXEC_OUTPUTTYPE, 99 101 RTGETOPTDEF_EXEC_WAITFOREXIT, 100 102 RTGETOPTDEF_EXEC_WAITFORSTDOUT, … … 113 115 " [--environment \"<NAME>=<VALUE> [<NAME>=<VALUE>]\"]\n" 114 116 " [--timeout <msec>] [--verbose]\n" 115 " [--wait-exit] [--wait-stdout] [--wait-stdout]\n" 117 " [--wait-exit] [--wait-stdout] [--wait-stdout]" 118 //" [--output-format=<dos>|<unix>]\n" 119 " [--output-type=<binary>|<text>]\n" 116 120 " [-- [<argument1>] ... [<argumentN>]\n" 117 121 /** @todo Add a "--" parameter (has to be last parameter) to directly execute … … 364 368 { "--ignore-operhaned-processes", RTGETOPTDEF_EXEC_IGNOREORPHANEDPROCESSES, RTGETOPT_REQ_NOTHING }, 365 369 { "--image", 'i', RTGETOPT_REQ_STRING }, 370 //{ "--output-format", RTGETOPTDEF_EXEC_OUTPUTFORMAT, RTGETOPT_REQ_STRING }, 371 { "--output-type", RTGETOPTDEF_EXEC_OUTPUTTYPE, RTGETOPT_REQ_STRING }, 366 372 { "--password", 'p', RTGETOPT_REQ_STRING }, 367 373 { "--timeout", 't', RTGETOPT_REQ_UINT32 }, … … 386 392 Utf8Str Utf8Password; 387 393 uint32_t u32TimeoutMS = 0; 394 bool fOutputBinary = false; 388 395 bool fWaitForExit = false; 389 396 bool fWaitForStdOut = false; … … 392 399 393 400 int vrc = VINF_SUCCESS; 394 bool fUsageOK = true;395 401 while ( (ch = RTGetOpt(&GetState, &ValueUnion)) 396 402 && RT_SUCCESS(vrc)) … … 417 423 } 418 424 425 case RTGETOPTDEF_EXEC_IGNOREORPHANEDPROCESSES: 426 fFlags |= ExecuteProcessFlag_IgnoreOrphanedProcesses; 427 break; 428 419 429 case 'i': 420 430 Utf8Cmd = ValueUnion.psz; 421 431 break; 422 432 423 case RTGETOPTDEF_EXEC_IGNOREORPHANEDPROCESSES: 424 fFlags |= ExecuteProcessFlag_IgnoreOrphanedProcesses; 433 /*case RTGETOPTDEF_EXEC_OUTPUTFORMAT: 434 /** todo Add DOS2UNIX and vice versa handling! 435 break;*/ 436 437 case RTGETOPTDEF_EXEC_OUTPUTTYPE: 438 if (!RTStrICmp(ValueUnion.psz, "binary")) 439 fOutputBinary = true; 440 else if (!RTStrICmp(ValueUnion.psz, "text")) 441 fOutputBinary = false; 442 else 443 { 444 AssertPtr(GetState.pDef->pszLong); 445 return errorSyntax(USAGE_GUESTCONTROL, "Unknown value for '%s' specified! Use either 'binary' or 'text'", 446 GetState.pDef->pszLong); 447 } 425 448 break; 426 449 … … 602 625 if (cbOutputData > 0) 603 626 { 604 /** @todo r=bird: cat'ing binary data from the guest is not going to work 605 * reliably if we do conversions like this. Should probably just 606 * write the output as it is by default, but bypassing RTStrWrite and 607 * it's automatic translation. Adding exec options to convert unix2dos 608 * and dos2unix. Use a VFS I/O stream filter for doing this, it's a 609 * generic problem and the new VFS APIs will handle it more 610 * transparently. (requires writing dos2unix/unix2dos filters ofc) */ 611 /* aOutputData has a platform dependent line ending, standardize on 612 * Unix style, as RTStrmWrite does the LF -> CR/LF replacement on 613 * Windows. Otherwise we end up with CR/CR/LF on Windows. */ 614 ULONG cbOutputDataPrint = cbOutputData; 615 for (BYTE *s = aOutputData.raw(), *d = s; 616 s - aOutputData.raw() < (ssize_t)cbOutputData; 617 s++, d++) 627 /** @todo r=bird: Adding exec options to convert unix2dos 628 * and dos2unix. Use a VFS I/O stream filter for doing this, it's a 629 * generic problem and the new VFS APIs will handle it more 630 * transparently. (requires writing dos2unix/unix2dos filters ofc) */ 631 if (!fOutputBinary) 618 632 { 619 if (*s == '\r') 633 /* 634 * If aOutputData is text data from the guest process' stdout or stderr, 635 * it has a platform dependent line ending. So standardize on 636 * Unix style, as RTStrmWrite does the LF -> CR/LF replacement on 637 * Windows. Otherwise we end up with CR/CR/LF on Windows. 638 */ 639 ULONG cbOutputDataPrint = cbOutputData; 640 for (BYTE *s = aOutputData.raw(), *d = s; 641 s - aOutputData.raw() < (ssize_t)cbOutputData; 642 s++, d++) 620 643 { 621 /* skip over CR, adjust destination */ 622 d--; 623 cbOutputDataPrint--; 644 if (*s == '\r') 645 { 646 /* skip over CR, adjust destination */ 647 d--; 648 cbOutputDataPrint--; 649 } 650 else if (s != d) 651 *d = *s; 624 652 } 625 else if (s != d) 626 *d = *s; 653 RTStrmWrite(g_pStdOut, aOutputData.raw(), cbOutputDataPrint); 627 654 } 628 RTStrmWrite(g_pStdOut, aOutputData.raw(), cbOutputDataPrint); 655 else /* Just dump all data as we got it ... */ 656 RTStrmWrite(g_pStdOut, aOutputData.raw(), cbOutputData); 629 657 } 630 658 }
Note:
See TracChangeset
for help on using the changeset viewer.