diff -urw /cygdrive/c/Programme/NSIS/Source/build.cpp ./build.cpp --- /cygdrive/c/Programme/NSIS/Source/build.cpp Wed Nov 14 21:15:44 2001 +++ ./build.cpp Mon Nov 19 08:48:12 2001 @@ -237,6 +237,7 @@ "SYSDIR\0" // 21 "HWNDPARENT\0" // 22 "CMDLINE\0" // 23 + "SECTIONS\0" // 24 ; const char *p=in; @@ -1094,6 +1095,7 @@ if (resolve_function("install callback",ns_func.find(".onInstFailed",0),build_header.code_onInstFailed)) return PS_ERROR; if (resolve_function("install callback",ns_func.find(".onUserAbort",0),build_header.code_onUserAbort)) return PS_ERROR; if (resolve_function("install callback",ns_func.find(".onVerifyInstDir",0),build_header.code_onVerifyInstDir)) return PS_ERROR; + if (resolve_function("install callback",ns_func.find(".onDlgPage",0),build_header.code_onDlgPage)) return PS_ERROR; #endif//NSIS_SUPPORT_CODECALLBACKS if (resolve_functions("install")) return PS_ERROR; diff -urw /cygdrive/c/Programme/NSIS/Source/exehead/Ui.c ./exehead/Ui.c --- /cygdrive/c/Programme/NSIS/Source/exehead/Ui.c Fri Nov 16 21:02:26 2001 +++ ./exehead/Ui.c Mon Nov 19 09:55:24 2001 @@ -228,8 +228,9 @@ dealWithIcon(hwndDlg,uMsg); if (uMsg == WM_INITDIALOG || uMsg == WM_NOTIFY_OUTER_NEXT) { - int backenabled=0,iscp=0,islp=0,isdp=0; + int backenabled=0,iscp=0,islp=0,isdp=0, callondlg=1; int delta=(uMsg == WM_NOTIFY_OUTER_NEXT)?wParam:0; + int old_mpage = m_page; static struct { char *id; @@ -253,7 +254,9 @@ SetDlgItemText(hwndDlg,IDC_VERSTR,GetStringFromStringTab(g_inst_header->branding_ptr)); SetDlgItemText(hwndDlg,IDC_BACK,GetStringFromStringTab(g_inst_header->backbutton_ptr)); SetDlgItemText(hwndDlg,IDCANCEL,GetStringFromStringTab(g_inst_header->cancelbutton_ptr)); + old_mpage = -1; } +recalcpage: #ifdef NSIS_CONFIG_LICENSEPAGE if (g_inst_header->licensedata_ptr>=0) islp++; #endif @@ -279,7 +282,70 @@ if (m_page==2&&(islp||iscp)) backenabled++; #ifdef NSIS_SUPPORT_CODECALLBACKS - if (m_page>3) ExecuteCodeSegment(g_inst_entry,g_inst_header->code_onInstSuccess,NULL); + if (m_page>3) + ExecuteCodeSegment(g_inst_entry,g_inst_header->code_onInstSuccess,NULL); +#ifdef NSIS_SUPPORT_STACK + else if (callondlg) { + if (g_inst_header->code_onDlgPage[1] > g_inst_header->code_onDlgPage[0]) { + stack_t *s = (stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)*2); + + if ((m_page >= 0) && (m_page <= 3) && (m_page < old_mpage)) { + // If going back, set button-captions _before_ running callback. + int ptr=g_inst_header->nextbutton_ptr; +#ifdef NSIS_CONFIG_LICENSEPAGE + if (m_page == 0) ptr=g_inst_header->licensebutton_ptr; +#endif + if (m_page == 2 || (m_page == 1 && !isdp)) ptr=g_inst_header->installbutton_ptr; + if (m_page == 3) ptr=g_inst_header->closebutton_ptr; + SetDlgItemText(hwndDlg,IDOK,GetStringFromStringTab(ptr)); + } + if (m_curwnd && (old_mpage == 1)) { + // if about to leave component-page, update section-states + // cause the onDlg function probably uses $SECTIONS + int x, a = 0; + for (x = 0; x < g_inst_header->num_sections; x ++) { + if (g_inst_section[x].name_ptr<0 || + SendDlgItemMessage(m_curwnd,IDC_LIST1,LB_GETSEL,a++,0) || !x) + g_inst_section[x].default_state|=0x80000000; + else + g_inst_section[x].default_state&=~0x80000000; + } + } + + wsprintf(s[0].text, "%d", old_mpage); + s[0].next = &s[1]; + wsprintf(s[1].text, "%d", m_page); + s[1].next = g_st; + g_st = s; + if (!ExecuteCodeSegment(g_inst_entry,g_inst_header->code_onDlgPage,NULL)) { + if (s = g_st) { + int retval = myatoi(s->text); + callondlg = 0; + g_st = s->next; + GlobalFree((HGLOBAL)s); + switch (retval) { + case IDCANCEL: + uMsg = WM_COMMAND; + wParam = IDCANCEL; + break; + case IDOK: + delta = 1; + if (old_mpage < m_page) + m_page = old_mpage; + goto recalcpage; + break; + case IDC_BACK: + delta = -1; + if (old_mpage > m_page) + m_page = old_mpage; + goto recalcpage; + break; + } + } + } + } + } +#endif//NSIS_SUPPORT_STACK #endif//NSIS_SUPPORT_CODECALLBACKS if (m_curwnd) DestroyWindow(m_curwnd); diff -urw /cygdrive/c/Programme/NSIS/Source/exehead/exec.c ./exehead/exec.c --- /cygdrive/c/Programme/NSIS/Source/exehead/exec.c Sat Nov 17 01:19:38 2001 +++ ./exehead/exec.c Mon Nov 19 06:47:14 2001 @@ -6,6 +6,7 @@ #include "ui.h" #include "libc.h" #include "exec.h" +#include "resource.h" #ifndef FOF_NOERRORUI #define FOF_NOERRORUI 0x0400 @@ -22,12 +23,7 @@ // or 0 is advance by 1. #ifdef NSIS_SUPPORT_STACK -typedef struct _stack_t { - struct _stack_t *next; - char text[NSIS_MAX_STRLEN]; -} stack_t; - -static stack_t *g_st; +stack_t *g_st; #endif static int exec_errorflag; @@ -659,6 +647,52 @@ } } return 0; + case EW_EXECDLL: + { + HANDLE h; + exec_errorflag++; + process_string_fromtab(buf,parms[0]); + process_string_fromtab(buf2,parms[1]); + process_string_fromtab(buf3,parms[2]); + + h=LoadLibrary(buf); + if (h) + { + typedef struct { + HWND hMainWindow; + HWND HelpText; + int CancelId; + int BackId; + int NextId; + } tDLLparams; + typedef int (*tDLLfunc)(tDLLparams *, LPCSTR); + + tDLLfunc funke = (tDLLfunc)GetProcAddress(h, buf2); + if (funke) + { + stack_t *s = (stack_t*)GlobalAlloc(GPTR, sizeof(stack_t)); + tDLLparams dllParams; + + exec_errorflag--; + + dllParams.CancelId = IDCANCEL; + dllParams.BackId = IDC_BACK; + dllParams.NextId = IDOK; + dllParams.hMainWindow = g_hwnd; + dllParams.HelpText = NULL; + wsprintf(s->text, "%d", funke(&dllParams, buf3)); + s->next = g_st; + g_st = s; + } + else + { + update_status_text("Could not find symbol: ",buf2); + log_printf4("%s%s not found in %s",g_errdll,buf2,buf); + } + // No FreeLibrary called here, since this dll could be called several times; + } + } + return 0; #endif//NSIS_SUPPORT_SHELLEXECUTE #ifdef NSIS_SUPPORT_EXECUTE case EW_EXECUTE: diff -urw /cygdrive/c/Programme/NSIS/Source/exehead/exec.h ./exehead/exec.h --- /cygdrive/c/Programme/NSIS/Source/exehead/exec.h Tue Oct 30 18:46:56 2001 +++ ./exehead/exec.h Sat Nov 17 17:18:48 2001 @@ -1,6 +1,15 @@ #ifndef _EXEC_H_ #define _EXEC_H_ +#ifdef NSIS_SUPPORT_STACK +typedef struct _stack_t { + struct _stack_t *next; + char text[NSIS_MAX_STRLEN]; +} stack_t; + +extern stack_t *g_st; +#endif + #define EXEC_ERROR 0x10000000 int ExecuteEntry(entry *entries, int pos); // returns advance on advance, EXEC_ERROR on err. diff -urw /cygdrive/c/Programme/NSIS/Source/exehead/fileform.h ./exehead/fileform.h --- /cygdrive/c/Programme/NSIS/Source/exehead/fileform.h Sat Nov 17 01:22:52 2001 +++ ./exehead/fileform.h Sun Nov 18 06:27:10 2001 @@ -72,6 +72,8 @@ EW_EXECUTE, // Execute program: 3,[complete command line,waitflag,>=0?output errorcode] + EW_EXECDLL, // Execute DLL function: 3,[DllName, functionname, paramstr] + EW_GETFILETIME, // GetFileTime; 3 [file highout lowout] EW_GETDLLVERSION, // GetDLLVersion: 3 [file highout lowout] @@ -183,6 +185,7 @@ int code_onInstFailed[2]; int code_onUserAbort[2]; int code_onVerifyInstDir[2]; + int code_onDlgPage[2]; #endif//NSIS_SUPPORT_CODECALLBACKS // additional flags diff -urw /cygdrive/c/Programme/NSIS/Source/exehead/util.c ./exehead/util.c --- /cygdrive/c/Programme/NSIS/Source/exehead/util.c Mon Nov 12 20:59:48 2001 +++ ./exehead/util.c Mon Nov 19 09:26:38 2001 @@ -6,6 +6,7 @@ #include "config.h" #include "fileform.h" +#include "ui.h" #ifdef NSIS_CONFIG_LOG char g_log_file[1024]; @@ -378,8 +379,25 @@ case VAR_CODES_START + 23 : // CMDLINE lstrcpyn(out,GetCommandLine(),1024); while (*out) out++; // don't remove trailing slash + + case VAR_CODES_START + 24 : // SECTIONS + { + int i; + int j = 0; + int snum = 0; + for (i=0; inum_sections; i++) { + char c=GetStringFromStringTab(g_inst_section[i].name_ptr)[0]; + if (!i || (g_inst_section[i].default_state&0x80000000) || + (g_inst_section[i].name_ptr<0)) + out[j++]=snum+'1'; + if ((!i) || (c && (c != '-'))) + snum++; + } + out[j] = 0; + } + break; break; - #if VAR_CODES_START + 23 >= 255 + #if VAR_CODES_START + 24 >= 255 #error "Too many variables! Extend VAR_CODES_START!" #endif } // switch diff -urw /cygdrive/c/Programme/NSIS/Source/script.cpp ./script.cpp --- /cygdrive/c/Programme/NSIS/Source/script.cpp Wed Nov 21 02:05:00 2001 +++ ./script.cpp Sun Nov 18 07:05:32 2001 @@ -57,27 +57,25 @@ int np,op; int tkid=get_commandtoken(line.gettoken_str(0),&np,&op); - if (tkid == -1) { - if (ignore) - return PS_OK; - else + if (tkid == -1) { char *p=line.gettoken_str(0); - if (p[0] && p[strlen(p)-1]==':') { + if (!ignore) + { int a=add_label(line.gettoken_str(0)); if (a) return PS_ERROR; + } line.eattoken(); goto parse_again; } printf("Invalid command: %s\n",line.gettoken_str(0)); return PS_ERROR; } - } + int v=line.getnumtokens()-(np+1); - if (((!ignore) || (tkid == TOK_P_ELSE) || (tkid == TOK_P_ENDIF)) && - (v < 0 || (op >= 0 && v > op))) // opt_parms is -1 for unlimited + if (v < 0 || (op >= 0 && v > op)) // opt_parms is -1 for unlimited { printf("%s expects %d",line.gettoken_str(0),np); if (op < 0) printf("+"); @@ -1126,6 +1124,18 @@ printf("Error: %s specified, NSIS_SUPPORT_SHELLEXECUTE not defined.\n", line.gettoken_str(0)); return PS_ERROR; #endif//!NSIS_SUPPORT_SHELLEXECUTE + case TOK_EXECDLL: +#ifdef NSIS_SUPPORT_EXECUTE + ent.which=EW_EXECDLL; + ent.offsets[0]=add_string(line.gettoken_str(1)); + ent.offsets[1]=add_string(line.gettoken_str(2)); + ent.offsets[2]=add_string(line.gettoken_str(3)); + printf("ExecDLL \"%s\" \"%s\" \"%s\"\n", line.gettoken_str(1), line.gettoken_str(2), line.gettoken_str(3)); + return add_entry(&ent); +#else//!NSIS_SUPPORT_EXECUTE + printf("Error: %s specified, NSIS_SUPPORT_EXECUTE not defined.\n", line.gettoken_str(0)); + return PS_ERROR; +#endif//!NSIS_SUPPORT_EXECUTE case TOK_REGDLL: case TOK_UNREGDLL: #ifndef NSIS_SUPPORT_ACTIVEXREG diff -urw /cygdrive/c/Programme/NSIS/Source/tokens.cpp ./tokens.cpp --- /cygdrive/c/Programme/NSIS/Source/tokens.cpp Mon Nov 12 21:49:02 2001 +++ ./tokens.cpp Sun Nov 18 06:45:16 2001 @@ -50,6 +50,7 @@ {TOK_ENUMREGVAL,"EnumRegValue",4,0,"$(0-9|INSTDIR|OUTDIR) rootkey subkey index\n root_key=(HKCR|HKLM|HKCU|HKU|HKCC|HKDD|HKPD)"}, {TOK_EXCH,"Exch",0,1,"[$(0-9|INSTDIR|OUTDIR)] | [stack_item_index]"}, {TOK_EXEC,"Exec",1,0,"command_line"}, +{TOK_EXECDLL,"ExecDLL",2,2,"DllName FunctionName [parameter_string]"}, {TOK_EXECWAIT,"ExecWait",1,1,"command_line [$(0-9)]"}, {TOK_EXECSHELL,"ExecShell",2,2,"(open|print|etc) command_line [parameters [showmode]]\n showmode=(SW_SHOWNORMAL|SW_SHOWMAXIMIZED|SW_SHOWMINIMIZED)"}, {TOK_EXPANDENVSTRS,"ExpandEnvStrings",2,0,"$(0-9|INSTDIR|OUTDIR) string"}, diff -urw /cygdrive/c/Programme/NSIS/Source/tokens.h ./tokens.h --- /cygdrive/c/Programme/NSIS/Source/tokens.h Thu Nov 8 20:04:56 2001 +++ ./tokens.h Sun Nov 18 06:09:34 2001 @@ -81,6 +81,7 @@ TOK_EXEC, TOK_EXECWAIT, TOK_EXECSHELL, + TOK_EXECDLL, TOK_REGDLL, TOK_UNREGDLL, TOK_RENAME,