git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@847 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-08-31 13:27:36 +00:00
parent ce50f46809
commit 53b82a6199
3 changed files with 48 additions and 71 deletions

View file

@ -245,7 +245,6 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
}
DWORD WINAPI MakeNSISProc(LPVOID p) {
char buf[1024];
STARTUPINFO si={sizeof(si),};
SECURITY_ATTRIBUTES sa={sizeof(sa),};
SECURITY_DESCRIPTOR sd={0,};
@ -280,29 +279,27 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
PostMessage(g_hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
return 1;
}
unsigned long exit=0,read,avail;
my_memset(buf,0,sizeof(buf));
while(1) {
PeekNamedPipe(read_stdout,buf,sizeof(buf)-1,&read,&avail,NULL);
if (read != 0) {
my_memset(buf,0,sizeof(buf));
if (avail > sizeof(buf)-1) {
while (read >= sizeof(buf)-1) {
ReadFile(read_stdout,buf,sizeof(buf)-1,&read,NULL);
LogMessage(g_hwnd,buf);
my_memset(buf,0,sizeof(buf));
char szBuf[1024];
DWORD dwRead = 1;
DWORD dwExit = !STILL_ACTIVE;
while (dwExit == STILL_ACTIVE || dwRead) {
PeekNamedPipe(read_stdout, 0, 0, 0, &dwRead, NULL);
if (dwRead) {
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
szBuf[dwRead] = 0;
LogMessage(g_hwnd, szBuf);
}
else Sleep(TIMEOUT);
GetExitCodeProcess(pi.hProcess, &dwExit);
// Make sure we have no data before killing getting out of the loop
if (dwExit != STILL_ACTIVE) {
PeekNamedPipe(read_stdout, 0, 0, 0, &dwRead, NULL);
}
}
else {
ReadFile(read_stdout,buf,sizeof(buf),&read,NULL);
LogMessage(g_hwnd,buf);
}
}
GetExitCodeProcess(pi.hProcess,&exit);
if (exit != STILL_ACTIVE) break;
Sleep(TIMEOUT);
}
g_retcode = exit;
g_retcode = dwExit;
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
CloseHandle(newstdout);

View file

@ -38,7 +38,7 @@
#define REGKEY "Software\\NSIS"
#define REGLOC "MakeNSISWPlacement"
#define MAX_STRING 256
#define TIMEOUT 800
#define TIMEOUT 150
#define MINWIDTH 350
#define MINHEIGHT 180

View file

@ -55,40 +55,12 @@ void ClearLog(HWND hwnd) {
char g_output_exe[1024];
char g_input_script[1024];
BOOL g_input_found;
extern BOOL g_warnings;
void LogMessage(HWND hwnd,const char *str) {
if (!str || !*str) return;
int len=SendDlgItemMessage(hwnd,IDC_LOGWIN,WM_GETTEXTLENGTH,0,0);
char *existing_text=(char*)GlobalAlloc(GPTR,len+lstrlen(str)+3);//3=\r\n\0
if (!existing_text) return;
existing_text[0]=0;
GETTEXTEX gt={0};
gt.cb = len;
gt.codepage = CP_ACP;
gt.flags = GT_DEFAULT;
SendDlgItemMessage(hwnd,IDC_LOGWIN,EM_GETTEXTEX,(WPARAM)&gt,(LPARAM)existing_text);
lstrcat(existing_text,str);
if (!g_input_found) {
char *p1=my_strstr(existing_text,"\r\nProcessing script file: \"");
if (p1) {
while (*p1++ != '"');
char *p2=my_strstr(p1,"\r\n");
lstrcpyn(g_input_script,p1,p2-p1);
g_input_found=TRUE;
}
}
if (my_strstr(existing_text," warning:")||my_strstr(existing_text," warnings:")) {
g_warnings = TRUE;
}
SetDlgItemText(hwnd, IDC_LOGWIN, existing_text);
SendDlgItemMessage(hwnd, IDC_LOGWIN,EM_SETSEL,lstrlen(existing_text),lstrlen(existing_text));
SendDlgItemMessage(hwnd, IDC_LOGWIN,EM_SCROLLCARET,0,0);
GlobalFree(existing_text);
SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_REPLACESEL, 0, (WPARAM)str);
}
void ErrorMessage(HWND hwnd,const char *str) {
if (!str) return;
char buf[1028];
@ -99,7 +71,6 @@ void ErrorMessage(HWND hwnd,const char *str) {
void DisableItems(HWND hwnd) {
g_output_exe[0]=0;
g_input_script[0]=0;
g_input_found=FALSE;
EnableWindow(GetDlgItem(hwnd,IDC_CLOSE),0);
EnableWindow(GetDlgItem(hwnd,IDC_TEST),0);
HMENU m = GetMenu(hwnd);
@ -129,6 +100,15 @@ void EnableItems(HWND hwnd) {
lstrcpy(g_output_exe,p2);
}
}
p=my_strstr(existing_text,"\r\nProcessing script file: \"");
if (p) {
while (*p++ != '"');
char *p2=my_strstr(p,"\r\n");
lstrcpyn(g_input_script,p,p2-p);
}
if (my_strstr(existing_text, " warning:") || my_strstr(existing_text, " warnings:")) {
g_warnings = TRUE;
}
HMENU m = GetMenu(hwnd);
if (g_output_exe[0]) {