diff options
Diffstat (limited to 'linden/indra/llplugin/llpluginprocesschild.cpp')
-rwxr-xr-x | linden/indra/llplugin/llpluginprocesschild.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/linden/indra/llplugin/llpluginprocesschild.cpp b/linden/indra/llplugin/llpluginprocesschild.cpp index 0d95cac..168236e 100755 --- a/linden/indra/llplugin/llpluginprocesschild.cpp +++ b/linden/indra/llplugin/llpluginprocesschild.cpp | |||
@@ -42,6 +42,14 @@ | |||
42 | #include "llpluginmessagepipe.h" | 42 | #include "llpluginmessagepipe.h" |
43 | #include "llpluginmessageclasses.h" | 43 | #include "llpluginmessageclasses.h" |
44 | 44 | ||
45 | #if LL_WINDOWS | ||
46 | #include <windows.h> | ||
47 | #include <fcntl.h> | ||
48 | #include <io.h> | ||
49 | #include <iostream> | ||
50 | #include <fstream> | ||
51 | #endif | ||
52 | |||
45 | static const F32 HEARTBEAT_SECONDS = 1.0f; | 53 | static const F32 HEARTBEAT_SECONDS = 1.0f; |
46 | static const F32 PLUGIN_IDLE_SECONDS = 1.0f / 100.0f; // Each call to idle will give the plugin this much time. | 54 | static const F32 PLUGIN_IDLE_SECONDS = 1.0f / 100.0f; // Each call to idle will give the plugin this much time. |
47 | 55 | ||
@@ -420,6 +428,12 @@ void LLPluginProcessChild::receiveMessageRaw(const std::string &message) | |||
420 | { | 428 | { |
421 | mSleepTime = parsed.getValueReal("time"); | 429 | mSleepTime = parsed.getValueReal("time"); |
422 | } | 430 | } |
431 | #if LL_WINDOWS | ||
432 | else if(message_name == "show_console") | ||
433 | { | ||
434 | createConsole(); | ||
435 | } | ||
436 | #endif | ||
423 | else if(message_name == "crash") | 437 | else if(message_name == "crash") |
424 | { | 438 | { |
425 | // Crash the plugin | 439 | // Crash the plugin |
@@ -569,3 +583,46 @@ void LLPluginProcessChild::deliverQueuedMessages() | |||
569 | } | 583 | } |
570 | } | 584 | } |
571 | } | 585 | } |
586 | |||
587 | #if LL_WINDOWS | ||
588 | void LLPluginProcessChild::createConsole() | ||
589 | { | ||
590 | const S32 MAX_CONSOLE_LINES = 500; | ||
591 | |||
592 | int h_con_handle; | ||
593 | long l_std_handle; | ||
594 | |||
595 | CONSOLE_SCREEN_BUFFER_INFO coninfo; | ||
596 | FILE *fp; | ||
597 | |||
598 | // allocate a console for this app | ||
599 | AllocConsole(); | ||
600 | |||
601 | // set the screen buffer to be big enough to let us scroll text | ||
602 | GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo); | ||
603 | coninfo.dwSize.Y = MAX_CONSOLE_LINES; | ||
604 | SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize); | ||
605 | |||
606 | // redirect unbuffered STDOUT to the console | ||
607 | l_std_handle = (long)GetStdHandle(STD_OUTPUT_HANDLE); | ||
608 | h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT); | ||
609 | fp = _fdopen( h_con_handle, "w" ); | ||
610 | *stdout = *fp; | ||
611 | setvbuf( stdout, NULL, _IONBF, 0 ); | ||
612 | |||
613 | // redirect unbuffered STDIN to the console | ||
614 | l_std_handle = (long)GetStdHandle(STD_INPUT_HANDLE); | ||
615 | h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT); | ||
616 | fp = _fdopen( h_con_handle, "r" ); | ||
617 | *stdin = *fp; | ||
618 | setvbuf( stdin, NULL, _IONBF, 0 ); | ||
619 | |||
620 | // redirect unbuffered STDERR to the console | ||
621 | l_std_handle = (long)GetStdHandle(STD_ERROR_HANDLE); | ||
622 | h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT); | ||
623 | fp = _fdopen( h_con_handle, "w" ); | ||
624 | *stderr = *fp; | ||
625 | setvbuf( stderr, NULL, _IOFBF, 1024 ); //Assigning a buffer improves speed a LOT, esp on vista/win7 | ||
626 | //_IOLBF is borked. | ||
627 | } | ||
628 | #endif \ No newline at end of file | ||