diff options
author | marha <marha@users.sourceforge.net> | 2015-06-28 12:56:53 +0200 |
---|---|---|
committer | Mike DePaulo <mikedep333@gmail.com> | 2015-06-30 22:55:16 -0400 |
commit | 6fe71499cd506c11a378c339d1117630c85ab96c (patch) | |
tree | 2776f56e02244f5e0d79dd961327ebedd4f9887f /xorg-server | |
parent | 1aeb164a14fee3ee35f5f0bbfdb8f9c03a123a3a (diff) | |
download | vcxsrv-6fe71499cd506c11a378c339d1117630c85ab96c.tar.gz vcxsrv-6fe71499cd506c11a378c339d1117630c85ab96c.tar.bz2 vcxsrv-6fe71499cd506c11a378c339d1117630c85ab96c.zip |
Show all text received by plink to show to the user (and not only the first part)
Diffstat (limited to 'xorg-server')
-rw-r--r-- | xorg-server/hw/xwin/xlaunch/main.cc | 62 | ||||
-rw-r--r-- | xorg-server/hw/xwin/xlaunch/resources/dialog.rc | 2 |
2 files changed, 48 insertions, 16 deletions
diff --git a/xorg-server/hw/xwin/xlaunch/main.cc b/xorg-server/hw/xwin/xlaunch/main.cc index e6b04d6b3..372420b1b 100644 --- a/xorg-server/hw/xwin/xlaunch/main.cc +++ b/xorg-server/hw/xwin/xlaunch/main.cc @@ -54,14 +54,17 @@ static bool ContainPrintableChars(const char *Buf, unsigned Nbr) return false; } +HANDLE g_hChildStdoutRd; +int g_hStdOut; + /* * Process messages for the prompt dialog. */ static INT_PTR CALLBACK DisplayPromptDlgProc (HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam) { - static LPARAM Param; static UINT PasswordChar; + static char *buf_p; switch (message) { case WM_INITDIALOG: @@ -86,18 +89,39 @@ static INT_PTR CALLBACK DisplayPromptDlgProc (HWND hwndDialog, UINT message, WPA 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED); - Param=lParam; - SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, WM_SETTEXT, 0, lParam); + buf_p=(char*)lParam; + SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, WM_SETTEXT, 0, (LPARAM)buf_p); + SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, EM_LINESCROLL, 0, 1000); + SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, EM_SETSEL, -1, -1); + SetTimer(hwndDialog,1,20,NULL); return TRUE; } break; + case WM_TIMER: + { + DWORD nbrAvail=0; + PeekNamedPipe(g_hChildStdoutRd, NULL, NULL, NULL, &nbrAvail, NULL); + if (nbrAvail) + { + int curLen=strlen(buf_p); + buf_p=(char*)realloc(buf_p, curLen+nbrAvail+1); + size_t Nbr = _read(g_hStdOut, buf_p+curLen, nbrAvail); + buf_p[curLen+nbrAvail]=0; + SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, WM_SETTEXT, 0, (LPARAM)buf_p); + SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, EM_LINESCROLL, 0, 1000); + SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, EM_SETSEL, -1, -1); + } + break; + } + case WM_COMMAND: switch (LOWORD (wParam)) { case IDOK: - SendDlgItemMessage(hwndDialog, IDC_INPUT, WM_GETTEXT, 128, Param); - EndDialog(hwndDialog, Param); + buf_p=(char*)realloc(buf_p, 128); + SendDlgItemMessage(hwndDialog, IDC_INPUT, WM_GETTEXT, 128, (LPARAM)buf_p); + EndDialog(hwndDialog, (LPARAM)buf_p); return TRUE; case IDCANCEL: EndDialog(hwndDialog, NULL); @@ -114,6 +138,11 @@ static INT_PTR CALLBACK DisplayPromptDlgProc (HWND hwndDialog, UINT message, WPA } InvalidateRect(hDlg, NULL, TRUE); } + return TRUE; + case IDC_PROMPT_DESC: + if (HIWORD(wParam)==EN_SETFOCUS) + SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, EM_SETSEL, -1, -1); + return TRUE; } break; @@ -128,23 +157,26 @@ static INT_PTR CALLBACK DisplayPromptDlgProc (HWND hwndDialog, UINT message, WPA static bool CheckOutput(HANDLE hChildStdoutRd, int hStdOut, int hStdIn) { + g_hChildStdoutRd = hChildStdoutRd; + g_hStdOut = hStdOut; DWORD NbrAvail=0; PeekNamedPipe(hChildStdoutRd, NULL, NULL, NULL, &NbrAvail, NULL); if (NbrAvail) { - char Buf[128]; - size_t Nbr = _read(hStdOut, Buf, sizeof(Buf)-1); - if (ContainPrintableChars(Buf,Nbr)) + char *buf_p=(char*)malloc(NbrAvail+1); + size_t Nbr = _read(hStdOut, buf_p, NbrAvail); + if (ContainPrintableChars(buf_p,Nbr)) { - Buf[Nbr]=0; - INT_PTR Ret = DialogBoxParam (GetModuleHandle(NULL), "IDD_PROMPT", NULL, DisplayPromptDlgProc, (LPARAM)Buf); + buf_p[Nbr]=0; + INT_PTR Ret = DialogBoxParam (GetModuleHandle(NULL), "IDD_PROMPT", NULL, DisplayPromptDlgProc, (LPARAM)buf_p); if (Ret) { char *Data=(char*)Ret; // Write it to the client _write(hStdIn, Data, strlen(Data)); - _write(hStdIn, "\x0d\x0a", 2); + _write(hStdIn, "\x0a", 1); + //_write(hStdIn, "\x0d\x0a", 2); } return true; @@ -839,15 +871,15 @@ class CMyWizard : public CWizard if (!CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0)) throw win32_error("CreatePipe failed", GetLastError()); - // Ensure the write handle to the pipe for STDIN is not inherited.
- if ( ! SetHandleInformation(hChildStdinWr, HANDLE_FLAG_INHERIT, 0) )
+ // Ensure the write handle to the pipe for STDIN is not inherited. + if ( ! SetHandleInformation(hChildStdinWr, HANDLE_FLAG_INHERIT, 0) ) throw win32_error("SetHandleInformation failed", GetLastError()); if (!CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0)) throw win32_error("CreatePipe failed", GetLastError()); - // Ensure the read handle to the pipe for STDOUT is not inherited.
- if ( ! SetHandleInformation(hChildStdoutRd, HANDLE_FLAG_INHERIT, 0) )
+ // Ensure the read handle to the pipe for STDOUT is not inherited. + if ( ! SetHandleInformation(hChildStdoutRd, HANDLE_FLAG_INHERIT, 0) ) throw win32_error("SetHandleInformation failed", GetLastError()); sic.dwFlags = STARTF_USESTDHANDLES; diff --git a/xorg-server/hw/xwin/xlaunch/resources/dialog.rc b/xorg-server/hw/xwin/xlaunch/resources/dialog.rc index 3435329b2..9827f9112 100644 --- a/xorg-server/hw/xwin/xlaunch/resources/dialog.rc +++ b/xorg-server/hw/xwin/xlaunch/resources/dialog.rc @@ -144,8 +144,8 @@ EXSTYLE WS_EX_NOPARENTNOTIFY CAPTION "Input requested?" FONT 8, "MS Shell Dlg 2", 0, 0, 0x1 BEGIN - LTEXT "",IDC_PROMPT_DESC,7,7,245,50, WS_BORDER EDITTEXT IDC_INPUT,7,67,245,12, WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL | ES_PASSWORD + EDITTEXT IDC_PROMPT_DESC,7,7,245,50, WS_BORDER | WS_TABSTOP | WS_VSCROLL | ES_READONLY | ES_MULTILINE AUTOCHECKBOX "Show Characters", IDC_PASSWORD, 7,77,245,12, WS_TABSTOP DEFPUSHBUTTON "OK",IDOK,61,95,50,15, WS_TABSTOP PUSHBUTTON "Cancel",IDCANCEL,147,95,50,14, WS_TABSTOP |