diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index 5499dbcd..2b9bd6fd 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -14,7 +14,7 @@ * you wrote the original software. If you use this software in a product, an * acknowledgment in the product documentation would be appreciated but is not required. * -* 2. Altered source versions must be plainly marked as such, and must not be +* 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source distribution. @@ -39,14 +39,10 @@ #define LB_ICONHEIGHT 20 // Added by Amir Szekely 3rd August 2002 -installer_strings *install_strings_tables; -installer_strings *cur_install_strings_table; common_strings *common_strings_tables; common_strings *cur_common_strings_table; -#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT -uninstall_strings *uninstall_strings_tables; -uninstall_strings *cur_uninstall_strings_table; -#endif +char *install_strings_tables; // installer_strings/uninstall_strings depending on installer type +char *cur_install_strings_table; int g_quit_flag; // set when Quit has been called (meaning bail out ASAP) @@ -108,12 +104,12 @@ HWND m_curwnd; static int m_whichcfg; #ifdef NSIS_CONFIG_VISIBLE_SUPPORT -BOOL my_SetDlgItemText(HWND dlg, WORD id, int strtab) { - return SetDlgItemText(dlg,id,STR(strtab)); +BOOL SetDlgItemTextFromLang(HWND dlg, WORD id, langid_t lid) { + return SetDlgItemText(dlg,id,STR(GetLangString(lid))); } -BOOL SetUIText(HWND defhw, WORD def, WORD custom, int strtab) { - return my_SetDlgItemText(custom?g_hwnd:defhw,custom?custom:def,strtab); +BOOL SetUITextFromLang(HWND defhw, WORD def, WORD custom, langid_t lid) { + return SetDlgItemTextFromLang(custom?g_hwnd:defhw,custom?custom:def,lid); } // no tab @@ -147,7 +143,7 @@ static void SetChildrenStates(HWND hWnd, TV_ITEM *pItem, int iState) { pItem->mask|=TVIF_PARAM; TreeView_GetItem(hWnd, pItem); - if (pItem->state >> 12 == 0) + if (pItem->state >> 12 == 0) return; if (iState < 3 && (g_inst_section[pItem->lParam].default_state & DFS_RO)) l=3; @@ -185,8 +181,8 @@ static void SetParentState(HWND hWnd, TV_ITEM *pItem) { pItem->hItem = hItem; pItem->mask|=TVIF_PARAM; TreeView_GetItem(hWnd, pItem); - iState = pItem->state >> 12; - if (iState && !(g_inst_section[pItem->lParam].default_state & DFS_RO)) + iState = pItem->state >> 12; + if (iState && !(g_inst_section[pItem->lParam].default_state & DFS_RO)) { if (iState==5) iState=2; else if (iState==4) iState=1; @@ -215,7 +211,7 @@ static void CheckTreeItem(HWND hWnd, TV_ITEM *pItem, int checked) { pItem->mask = TVIF_STATE|TVIF_PARAM; TreeView_GetItem(hWnd, pItem); - if (pItem->state >> 12 == 0) + if (pItem->state >> 12 == 0) return; if (g_inst_section[pItem->lParam].default_state & DFS_RO) l=3; @@ -301,45 +297,41 @@ int ui_doinstall(void) // Added by Amir Szekely 3rd August 2002 // Multilingual support char pa=0; - int num=g_inst_header->str_tables_num; - LANGID user_lang=GetUserDefaultLangID(); + int num=g_inst_header->common.str_tables_num; + LANGID user_lang=GetUserDefaultLangID(), lang_mask=~(LANGID)0; int size=num*sizeof(common_strings); cur_common_strings_table=common_strings_tables=(common_strings*)GlobalAlloc(GPTR,size); GetCompressedDataFromDataBlockToMemory(g_inst_header->common.str_tables,(char*)common_strings_tables,size); #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT - if (g_is_uninstaller) { + if (g_is_uninstaller) size=num*sizeof(uninstall_strings); - cur_uninstall_strings_table=uninstall_strings_tables=(uninstall_strings*)GlobalAlloc(GPTR,size); - GetCompressedDataFromDataBlockToMemory(g_inst_uninstheader->str_tables,(char*)uninstall_strings_tables,size); - } else #endif - { size=num*sizeof(installer_strings); - cur_install_strings_table=install_strings_tables=(installer_strings*)GlobalAlloc(GPTR,size); - GetCompressedDataFromDataBlockToMemory(g_inst_header->str_tables,(char*)install_strings_tables,size); - } + cur_install_strings_table=install_strings_tables=(char *)GlobalAlloc(GPTR,size); + GetCompressedDataFromDataBlockToMemory(g_inst_header->common.inst_str_tables,install_strings_tables,size); lang_again: for (size=0; size < num; size++) { - if (user_lang == common_strings_tables[size].lang_id) { - cur_install_strings_table+=size; + if (!((user_lang ^ common_strings_tables[size].lang_id) & lang_mask)) { cur_common_strings_table+=size; #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT - cur_uninstall_strings_table+=size; + if (g_is_uninstaller) + (uninstall_strings *)cur_install_strings_table+=size; + else #endif + (installer_strings *)cur_install_strings_table+=size; pa++; break; } - common_strings_tables[size].lang_id&=0x3ff; // primary lang } if (!pa) { - user_lang&=0x3ff; // primary lang + lang_mask=0x3ff; // primary lang pa++; goto lang_again; } } - process_string_fromtab(g_caption,COMMON_STR(caption)); + process_string_from_lang(g_caption,LANGID_CAPTION); #ifdef NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_CONFIG_SILENT_SUPPORT @@ -435,33 +427,33 @@ static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l if (uMsg == WM_INITDIALOG) { g_hwnd=hwndDlg; - my_SetDlgItemText(hwndDlg,IDC_VERSTR,LANG_BRANDING); + SetDlgItemTextFromLang(hwndDlg,IDC_VERSTR,LANGID_BRANDING); hIcon=LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_ICON2)); SetClassLong(hwndDlg,GCL_HICON,(long)hIcon); - my_SetDlgItemText(hwndDlg,IDCANCEL,LANG_BTN_CANCEL); + SetDlgItemTextFromLang(hwndDlg,IDCANCEL,LANGID_BTN_CANCEL); #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT if (!g_is_uninstaller) #endif - my_SetDlgItemText(hwndDlg,IDC_BACK,LANG_BTN_BACK); + SetDlgItemTextFromLang(hwndDlg,IDC_BACK,LANGID_BTN_BACK); ShowWindow(hwndDlg,SW_SHOW); } #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT if (g_is_uninstaller) { - islp=UNINSTALL_STR(uninstalltext)>=0; + islp=LANG_UNINST_TEXT>=0; iscp++; } else #endif//NSIS_CONFIG_UNINSTALL_SUPPORT { #ifdef NSIS_CONFIG_LICENSEPAGE - if (INSTALL_STR(licensedata)>=0) islp++; + if (LANG_LICENSE_DATA>=0) islp++; #endif//NSIS_CONFIG_LICENSEPAGE #ifdef NSIS_CONFIG_COMPONENTPAGE - if (INSTALL_STR(componenttext)>=0) iscp++; + if (LANG_COMP_TEXT>=0) iscp++; #endif//NSIS_CONFIG_COMPONENTPAGE - if (INSTALL_STR(text)>=0) ispotentiallydp++; + if (LANG_DIR_TEXT>=0) ispotentiallydp++; if (ispotentiallydp && !((g_inst_cmnheader->misc_flags&2) && is_valid_instpath(state_install_directory) @@ -509,19 +501,19 @@ static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l else if (!m_curwnd) { HWND hwndtmp; - my_SetDlgItemText(hwndDlg,IDOK, - (m_page == g_max_page) ? LANG_BTN_CLOSE : + SetDlgItemTextFromLang(hwndDlg,IDOK, + (m_page == g_max_page) ? LANGID_BTN_CLOSE : #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT - g_is_uninstaller ? LANG_BTN_UNINST : + g_is_uninstaller ? LANGID_BTN_UNINST : #endif #ifdef NSIS_CONFIG_LICENSEPAGE - (m_page == 0) ? LANG_BTN_LICENSE : + (m_page == 0) ? LANGID_BTN_LICENSE : #endif - (m_page == 2 || (m_page == 1 && !isdp)) ? LANG_BTN_INSTALL : - LANG_BTN_NEXT + (m_page == 2 || (m_page == 1 && !isdp)) ? LANGID_BTN_INSTALL : + LANGID_BTN_NEXT ); lstrcpy(g_tmp,g_caption); - process_string_fromtab(g_tmp+lstrlen(g_tmp),LANG_SUBCAPTION(m_page)); + process_string_from_lang(g_tmp+lstrlen(g_tmp),LANGID_SUBCAPTION(m_page)); SetWindowText(hwndDlg,g_tmp); @@ -608,7 +600,7 @@ static BOOL CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM SendMessage(hwLicense,EM_SETBKGNDCOLOR,0,g_inst_header->license_bg); SendMessage(hwLicense,EM_SETEVENTMASK,0,ENM_LINK); SetWindowText(hwLicense,STR(LANG_LICENSE_DATA)); - SetUIText(hwndDlg,IDC_INTROTEXT,g_inst_header->common.intro_text_id,LANG_LICENSE_TEXT); + SetUITextFromLang(hwndDlg,IDC_INTROTEXT,g_inst_header->common.intro_text_id,LANGID_LICENSE_TEXT); } else if (uMsg == WM_NOTIFY) { ENLINK *enlink=(ENLINK *)lParam; @@ -644,8 +636,8 @@ static BOOL CALLBACK UninstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l { if (uMsg == WM_INITDIALOG) { - SetUIText(hwndDlg,IDC_INTROTEXT,g_inst_header->common.intro_text_id,LANG_UNINST_TEXT); - SetUIText(hwndDlg,IDC_UNINSTFROM,g_inst_uninstheader->uninst_subtext_id,LANG_UNINST_SUBTEXT); + SetUITextFromLang(hwndDlg,IDC_INTROTEXT,g_inst_header->common.intro_text_id,LANGID_UNINST_TEXT); + SetUITextFromLang(hwndDlg,IDC_UNINSTFROM,g_inst_uninstheader->uninst_subtext_id,LANGID_UNINST_SUBTEXT); SetDlgItemText(hwndDlg,IDC_EDIT1,state_install_directory); } return 0; @@ -682,9 +674,9 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar } #endif SetDlgItemText(hwndDlg,IDC_DIR,state_install_directory); - SetUIText(hwndDlg,IDC_INTROTEXT,g_inst_header->common.intro_text_id,LANG_DIR_TEXT); - my_SetDlgItemText(hwndDlg,IDC_BROWSE,LANG_BTN_BROWSE); - SetUIText(hwndDlg,IDC_SELDIRTEXT,g_inst_header->dir_subtext_id,LANG_DIR_SUBTEXT); + SetUITextFromLang(hwndDlg,IDC_INTROTEXT,g_inst_header->common.intro_text_id,LANGID_DIR_TEXT); + SetDlgItemTextFromLang(hwndDlg,IDC_BROWSE,LANGID_BTN_BROWSE); + SetUITextFromLang(hwndDlg,IDC_SELDIRTEXT,g_inst_header->dir_subtext_id,LANGID_DIR_SUBTEXT); SendMessage(hwndDlg,WM_IN_UPDATEMSG,0,0); } if (uMsg == WM_COMMAND) @@ -780,7 +772,7 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar // Added by Amir Szekely 24th July 2002 // Allows 'SpaceTexts none' - if (INSTALL_STR(spacerequired) >= 0) { + if (LANG_SPACE_REQ >= 0) { lstrcpy(s,STR(LANG_SPACE_REQ)); inttosizestr(total,s); SetUITextNT(hwndDlg,IDC_SPACEREQUIRED,g_inst_header->space_req_id,s); @@ -835,9 +827,9 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar hTreeItems=(HTREEITEM*)GlobalAlloc(GPTR,sizeof(HTREEITEM)*g_inst_header->num_sections); hBMcheck1=LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BITMAP1)); - SetUIText(hwndDlg,IDC_INTROTEXT,g_inst_header->common.intro_text_id,LANG_COMP_TEXT); - SetUIText(hwndDlg,IDC_TEXT1,g_inst_header->com_subtext1_id,LANG_COMP_SUBTEXT(0)); - SetUIText(hwndDlg,IDC_TEXT2,g_inst_header->com_subtext2_id,LANG_COMP_SUBTEXT(1)); + SetUITextFromLang(hwndDlg,IDC_INTROTEXT,g_inst_header->common.intro_text_id,LANGID_COMP_TEXT); + SetUITextFromLang(hwndDlg,IDC_TEXT1,g_inst_header->com_subtext1_id,LANGID_COMP_SUBTEXT(0)); + SetUITextFromLang(hwndDlg,IDC_TEXT2,g_inst_header->com_subtext2_id,LANGID_COMP_SUBTEXT(1)); oldTreeWndProc=GetWindowLong(hwndTree1,GWL_WNDPROC); SetWindowLong(hwndTree1,GWL_WNDPROC,(DWORD)newTreeWndProc); @@ -845,7 +837,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar if (hImageList) ImageList_Destroy(hImageList); hImageList = ImageList_Create(16,16, ILC_COLOR32, 4, 4); ImageList_SetBkColor(hImageList, GetSysColor(COLOR_WINDOW)); - + ImageList_Add(hImageList,hBMcheck1,NULL); TreeView_SetImageList(hwndTree1, hImageList, TVSIL_STATE); @@ -858,7 +850,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar } else { - for (m_num_insttypes = 0; m_num_insttypes < NSIS_MAX_INST_TYPES && + for (m_num_insttypes = 0; m_num_insttypes < NSIS_MAX_INST_TYPES && g_inst_header->install_types_ptr[m_num_insttypes]>=0; m_num_insttypes ++) { SendMessage(hwndCombo1,CB_ADDSTRING,0,(LPARAM)GetStringFromStringTab(g_inst_header->install_types_ptr[m_num_insttypes])); @@ -973,20 +965,20 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar } if (uMsg == WM_NOTIFY || uMsg == WM_TREEVIEW_KEYHACK) { - LPNMHDR lpnmh = (LPNMHDR) lParam; + LPNMHDR lpnmh = (LPNMHDR) lParam; if (uMsg == WM_TREEVIEW_KEYHACK || lpnmh->idFrom == IDC_TREE1) { - if (uMsg == WM_TREEVIEW_KEYHACK || lpnmh->code == NM_CLICK) + if (uMsg == WM_TREEVIEW_KEYHACK || lpnmh->code == NM_CLICK) { TVHITTESTINFO ht = {0}; if (uMsg != WM_TREEVIEW_KEYHACK) { DWORD dwpos = GetMessagePos(); - + ht.pt.x = GET_X_LPARAM(dwpos); ht.pt.y = GET_Y_LPARAM(dwpos); MapWindowPoints(HWND_DESKTOP, hwndTree1, &ht.pt, 1); - + TreeView_HitTest(hwndTree1, &ht); } else @@ -994,13 +986,13 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar ht.hItem=TreeView_GetSelection(hwndTree1); if (ht.hItem) ht.flags=TVHT_ONITEMSTATEICON; } - - if ((TVHT_ONITEMSTATEICON|TVHT_ONITEMLABEL|TVHT_ONITEMRIGHT|TVHT_ONITEM) & ht.flags) + + if ((TVHT_ONITEMSTATEICON|TVHT_ONITEMLABEL|TVHT_ONITEMRIGHT|TVHT_ONITEM) & ht.flags) { TVITEM hItem; int image,wh; hItem.hItem = ht.hItem; - + hItem.mask = TVIF_STATE|TVIF_PARAM; TreeView_GetItem(hwndTree1, &hItem); @@ -1124,7 +1116,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar ShowWindow(GetUIItem(hwndDlg,IDC_TEXT2,g_inst_header->com_subtext2_id),c); } - if (INSTALL_STR(spacerequired) >= 0) { + if (LANG_SPACE_REQ >= 0) { int x,total; char s[128]; for (total=x=0; x < g_inst_header->num_sections; x ++) @@ -1145,9 +1137,9 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar int ui_st_updateflag=0x3; -void update_status_text_from_tab(int texttab, const char *text2) +void update_status_text_from_lang(langid_t id, const char *text2) { - update_status_text(STR(texttab), text2); + update_status_text(STR(GetLangString(id)), text2); } void update_status_text(const char *text1, const char *text2) @@ -1290,8 +1282,8 @@ static BOOL CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { ShowWindow(g_hwnd,SW_SHOWNA); lstrcpy(g_tmp,g_caption); - process_string_fromtab(g_tmp+lstrlen(g_caption),COMMON_STR(subcaptions[g_max_page+1])); - update_status_text_from_tab(LANG_COMPLETED,""); + process_string_from_lang(g_tmp+lstrlen(g_caption),LANGID_SUBCAPTION(g_max_page+1)); + update_status_text_from_lang(LANGID_COMPLETED,""); SetWindowText(g_hwnd,g_tmp); SetFocus(h); } diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index c84ab6e4..628c1e8d 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -35,7 +35,6 @@ HBITMAP g_hBrandingBitmap = 0; #ifdef NSIS_CONFIG_PLUGIN_SUPPORT char plugins_temp_dir[NSIS_MAX_STRLEN]=""; -char plugin[NSIS_MAX_STRLEN]=""; #endif extern HWND m_curwnd; @@ -45,7 +44,7 @@ static WIN32_FIND_DATA *file_exists(char *buf) HANDLE h; static WIN32_FIND_DATA fd; h = FindFirstFile(buf,&fd); - if (h != INVALID_HANDLE_VALUE) + if (h != INVALID_HANDLE_VALUE) { FindClose(h); return &fd; @@ -66,7 +65,7 @@ static LONG myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey, int onlyifempty) char buffer[MAX_PATH+1]; while (RegEnumKey(key,0,buffer,MAX_PATH+1)==ERROR_SUCCESS) { - if (onlyifempty) + if (onlyifempty) { RegCloseKey(key); return !ERROR_SUCCESS; @@ -84,13 +83,13 @@ extern char g_all_user_var_flag; static int ExecuteEntry(entry *entries, int pos); -static int resolveaddr(int v) -{ - if (v<0) return myatoi(g_usrvars[-(v+1)]); // if <0, that means we - return v; +static int resolveaddr(int v) +{ + if (v<0) return myatoi(g_usrvars[-(v+1)]); // if <0, that means we + return v; } -int ExecuteCodeSegment(entry *entries, int pos, HWND hwndProgress) +int ExecuteCodeSegment(entry *entries, int pos, HWND hwndProgress) { while (pos >= 0) { @@ -100,7 +99,7 @@ int ExecuteCodeSegment(entry *entries, int pos, HWND hwndProgress) if (rv == EXEC_ERROR) return EXEC_ERROR; rv=resolveaddr(rv); - + if (!rv) { rv++; pos++; } else { @@ -109,8 +108,8 @@ int ExecuteCodeSegment(entry *entries, int pos, HWND hwndProgress) pos=rv; // set new position rv-=t; // set rv to delta for progress adjustment } - - if (hwndProgress) + + if (hwndProgress) { extern int progress_bar_pos, progress_bar_len; progress_bar_pos+=rv; @@ -131,8 +130,8 @@ static int ExecuteEntry(entry *entries, int pos) int which=entries[pos].which; switch (which) { - case EW_NOP: - log_printf2("Jump: %d",parms[0]); + case EW_NOP: + log_printf2("Jump: %d",parms[0]); return parms[0]; case EW_ABORT: { @@ -148,7 +147,7 @@ static int ExecuteEntry(entry *entries, int pos) case EW_CALL: { int v=resolveaddr(parms[0])-1; // address is -1, since we encode it as +1 - log_printf2("Call: %d",v); + log_printf2("Call: %d",v); return ExecuteCodeSegment(entries,v,NULL); } case EW_UPDATETEXT: @@ -185,7 +184,7 @@ static int ExecuteEntry(entry *entries, int pos) return 0; case EW_CHDETAILSVIEW: if (insthwndbutton) ShowWindow(insthwndbutton,parms[1]); - if (insthwnd) ShowWindow(insthwnd,parms[0]); + if (insthwnd) ShowWindow(insthwnd,parms[0]); return 0; case EW_SETFILEATTRIBUTES: process_string_fromtab(buf,parms[0]); @@ -199,17 +198,17 @@ static int ExecuteEntry(entry *entries, int pos) case EW_CREATEDIR: process_string_fromtab(buf2,parms[0]); log_printf3("CreateDirectory: \"%s\" (%d)",buf2,parms[1]); - if (parms[1]) + if (parms[1]) { - update_status_text_from_tab(LANG_OUTPUTDIR,buf2); + update_status_text_from_lang(LANGID_OUTPUTDIR,buf2); lstrcpy(state_output_directory,buf2); } - else update_status_text_from_tab(LANG_CREATEDIR,buf2); + else update_status_text_from_lang(LANGID_CREATEDIR,buf2); recursive_create_directory(buf2); return 0; case EW_IFFILEEXISTS: process_string_fromtab(buf,parms[0]); - if (file_exists(buf)) + if (file_exists(buf)) { log_printf3("IfFileExists: file \"%s\" exists, jumping %d",buf,parms[1]); return parms[1]; @@ -240,7 +239,7 @@ static int ExecuteEntry(entry *entries, int pos) log_printf2("Rename: %s",buf4); if (MoveFile(buf,buf2)) { - update_status_text_from_tab(LANG_RENAME,buf4); + update_status_text_from_lang(LANGID_RENAME,buf4); } else { @@ -251,7 +250,7 @@ static int ExecuteEntry(entry *entries, int pos) exec_rebootflag++; #endif MoveFileOnReboot(buf,buf2); - update_status_text_from_tab(LANG_RENAMEONREBOOT,buf4); + update_status_text_from_lang(LANGID_RENAMEONREBOOT,buf4); log_printf2("Rename on reboot: %s",buf4); } else @@ -270,7 +269,7 @@ static int ExecuteEntry(entry *entries, int pos) char *p=g_usrvars[parms[0]]; char *fp; process_string_fromtab(buf,parms[1]); - if (!GetFullPathName(buf,NSIS_MAX_STRLEN,p,&fp)) + if (!GetFullPathName(buf,NSIS_MAX_STRLEN,p,&fp)) { exec_errorflag++; *p=0; @@ -295,7 +294,7 @@ static int ExecuteEntry(entry *entries, int pos) { char *fp; char *p=g_usrvars[parms[0]]; - process_string_fromtab(buf,parms[1]); + process_string_fromtab(buf,parms[1]); if (!SearchPath(NULL,buf,NULL,NSIS_MAX_STRLEN,p,&fp)) { p[0]=0; @@ -339,7 +338,7 @@ static int ExecuteEntry(entry *entries, int pos) } if (overwriteflag == 3) // check date and time { - WIN32_FIND_DATA *ffd=file_exists(buf); + WIN32_FIND_DATA *ffd=file_exists(buf); overwriteflag=1; // if it doesn't exist, fall back to no overwrites (since it shouldn't matter anyway) if (ffd) { @@ -349,37 +348,37 @@ static int ExecuteEntry(entry *entries, int pos) hOut=myOpenFile(buf,GENERIC_WRITE,(overwriteflag==1)?CREATE_NEW:CREATE_ALWAYS); if (hOut == INVALID_HANDLE_VALUE) { - if (overwriteflag) + if (overwriteflag) { - update_status_text_from_tab(LANG_SKIPPED,buf4); + update_status_text_from_lang(LANGID_SKIPPED,buf4); if (overwriteflag==2) exec_errorflag++; - log_printf3("File: skipped: \"%s\" (overwriteflag=%d)",buf,overwriteflag); + log_printf3("File: skipped: \"%s\" (overwriteflag=%d)",buf,overwriteflag); return 0; } - log_printf2("File: error creating \"%s\"",buf); + log_printf2("File: error creating \"%s\"",buf); lstrcpy(buf3,g_usrvars[0]);//save $0 - lstrcpy(g_usrvars[0],buf); + lstrcpy(g_usrvars[0],buf); - process_string_fromtab(buf2,COMMON_STR(fileerrtext)); + process_string_from_lang(buf2,LANGID_FILEERR); lstrcpy(g_usrvars[0],buf3); // restore $0 switch (my_MessageBox(buf2,MB_ABORTRETRYIGNORE|MB_ICONSTOP)) { case IDRETRY: - log_printf("File: error, user retry"); + log_printf("File: error, user retry"); goto _tryagain; case IDIGNORE: - log_printf("File: error, user cancel"); + log_printf("File: error, user cancel"); exec_errorflag++; return 0; default: - log_printf("File: error, user abort"); - update_status_text_from_tab(LANG_CANTWRITE,buf); + log_printf("File: error, user abort"); + update_status_text_from_lang(LANGID_CANTWRITE,buf); return EXEC_ERROR; } } - update_status_text_from_tab(LANG_EXTRACT,buf4); + update_status_text_from_lang(LANGID_EXTRACT,buf4); ret=GetCompressedDataFromDataBlock(parms[2],hOut); log_printf3("File: wrote %d to \"%s\"",ret,buf); @@ -413,22 +412,22 @@ static int ExecuteEntry(entry *entries, int pos) WIN32_FIND_DATA fd; process_string_fromtab(buf2,parms[0]); lstrcpy(buf,buf2); - log_printf2("Delete: \"%s\"",buf); + log_printf2("Delete: \"%s\"",buf); trimslashtoend(buf); h=FindFirstFile(buf2,&fd); if (h != INVALID_HANDLE_VALUE) { do { - if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { wsprintf(buf2,"%s\\%s",buf,fd.cFileName); - if (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) + if (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) SetFileAttributes(buf2,fd.dwFileAttributes^FILE_ATTRIBUTE_READONLY); if (DeleteFile(buf2)) { - log_printf2("Delete: DeleteFile(\"%s\")",buf2); - update_status_text_from_tab(LANG_DELETEFILE,buf2); + log_printf2("Delete: DeleteFile(\"%s\")",buf2); + update_status_text_from_lang(LANGID_DELETEFILE,buf2); } else { @@ -438,8 +437,8 @@ static int ExecuteEntry(entry *entries, int pos) #ifdef NSIS_SUPPORT_REBOOT exec_rebootflag++; #endif - log_printf2("Delete: DeleteFile on Reboot(\"%s\")",buf2); - update_status_text_from_tab(LANG_DELETEONREBOOT,buf2); + log_printf2("Delete: DeleteFile on Reboot(\"%s\")",buf2); + update_status_text_from_lang(LANGID_DELETEONREBOOT,buf2); MoveFileOnReboot(buf2,NULL); } else @@ -456,11 +455,11 @@ static int ExecuteEntry(entry *entries, int pos) return 0; #endif//NSIS_SUPPORT_DELETE #ifdef NSIS_SUPPORT_MESSAGEBOX - case EW_MESSAGEBOX: // MessageBox + case EW_MESSAGEBOX: // MessageBox { int v; process_string_fromtab(buf4,parms[1]); - log_printf3("MessageBox: %d,\"%s\"",parms[0],buf4); + log_printf3("MessageBox: %d,\"%s\"",parms[0],buf4); v=my_MessageBox(buf4,parms[0]); if (v) { @@ -481,7 +480,7 @@ static int ExecuteEntry(entry *entries, int pos) case EW_RMDIR: { process_string_fromtab(buf,parms[0]); - log_printf2("RMDir: \"%s\"",buf); + log_printf2("RMDir: \"%s\"",buf); if (lastchar(buf)=='\\') trimslashtoend(buf); @@ -511,7 +510,7 @@ static int ExecuteEntry(entry *entries, int pos) if (start>=0) { if (start>l) start=l; - lstrcpy(p,buf+start); + lstrcpy(p,buf+start); if (newlen) { if (newlen<0) newlen=lstrlen(p)+newlen; @@ -602,7 +601,7 @@ static int ExecuteEntry(entry *entries, int pos) #ifdef NSIS_SUPPORT_STACK case EW_PUSHPOP: { - stack_t *s=g_st; + stack_t *s=g_st; int cnt=parms[2]; if (cnt) //Exch contributed by Fritz Elfert { @@ -616,16 +615,16 @@ static int ExecuteEntry(entry *entries, int pos) lstrcpy(s->text,g_st->text); lstrcpy(g_st->text,buf); } - else if (parms[1]) + else if (parms[1]) { - if (!s) + if (!s) { log_printf("Pop: stack empty"); exec_errorflag++; return 0; } - lstrcpy(g_usrvars[parms[0]],s->text); - g_st=s->next; + lstrcpy(g_usrvars[parms[0]],s->text); + g_st=s->next; GlobalFree((HGLOBAL)s); } else @@ -651,7 +650,7 @@ static int ExecuteEntry(entry *entries, int pos) if (which == EW_SENDMESSAGE) v=SendMessage((HWND)myatoi(buf),myatoi(buf2),b3,b4); else v=(int)FindWindowEx((HWND)b3,(HWND)b4,buf[0]?buf:NULL,buf2[0]?buf2:NULL); - + if (parms[0]>=0) myitoa(g_usrvars[parms[0]],v); } @@ -672,7 +671,7 @@ static int ExecuteEntry(entry *entries, int pos) process_string_fromtab(buf2,parms[1]); process_string_fromtab(buf3,parms[2]); wsprintf(buf4,"%s %s",buf,buf2); - update_status_text_from_tab(LANG_EXECSHELL, buf4); + update_status_text_from_lang(LANGID_EXECSHELL, buf4); x=(int)ShellExecute(g_hwnd,buf[0]?buf:NULL,buf2,buf3[0]?buf3:NULL,state_output_directory,parms[3]); if (x < 33) { @@ -692,14 +691,14 @@ static int ExecuteEntry(entry *entries, int pos) HANDLE hProc; process_string_fromtab(buf,parms[0]); log_printf2("Exec: command=\"%s\"",buf); - update_status_text_from_tab(LANG_EXECUTE,buf); + update_status_text_from_lang(LANGID_EXECUTE,buf); hProc=myCreateProcess(buf,*state_output_directory?state_output_directory:NULL); if (hProc) { log_printf2("Exec: success (\"%s\")",buf); - if (parms[1]) + if (parms[1]) { DWORD lExitCode; while (WaitForSingleObject(hProc,100) == WAIT_TIMEOUT) @@ -715,35 +714,35 @@ static int ExecuteEntry(entry *entries, int pos) } CloseHandle( hProc ); } - else - { + else + { exec_errorflag++; - log_printf2("Exec: failed createprocess (\"%s\")",buf); + log_printf2("Exec: failed createprocess (\"%s\")",buf); } } return 0; #endif//NSIS_SUPPORT_EXECUTE #ifdef NSIS_SUPPORT_GETFILETIME - case EW_GETFILETIME: + case EW_GETFILETIME: // this new implementation based on one by Dave Bau // used FindFirstFile instead of GetFileTime to better handle files that are locked. // also allows GetFileTime to be passed a wildcard. - { - WIN32_FIND_DATA *ffd; - char *highout=g_usrvars[parms[1]]; - char *lowout=g_usrvars[parms[2]]; - process_string_fromtab(buf,parms[0]); + { + WIN32_FIND_DATA *ffd; + char *highout=g_usrvars[parms[1]]; + char *lowout=g_usrvars[parms[2]]; + process_string_fromtab(buf,parms[0]); ffd=file_exists(buf); - if (ffd) - { - myitoa(lowout,ffd->ftLastWriteTime.dwLowDateTime); - myitoa(highout,ffd->ftLastWriteTime.dwHighDateTime); - } - else + if (ffd) + { + myitoa(lowout,ffd->ftLastWriteTime.dwLowDateTime); + myitoa(highout,ffd->ftLastWriteTime.dwHighDateTime); + } + else { *lowout=*highout=0; - exec_errorflag++; + exec_errorflag++; } } return 0; @@ -791,12 +790,12 @@ static int ExecuteEntry(entry *entries, int pos) HANDLE h; process_string_fromtab(buf,parms[0]); process_string_fromtab(buf2,parms[1]); - + h=LoadLibrary(buf); if (h) { FARPROC funke = GetProcAddress(h,buf2); - if (funke) + if (funke) { exec_errorflag--; if (parms[2]<0) @@ -810,7 +809,7 @@ static int ExecuteEntry(entry *entries, int pos) NULL); #endif } - else + else { process_string_fromtab(buf3,parms[2]); update_status_text(buf3,buf); @@ -819,21 +818,21 @@ static int ExecuteEntry(entry *entries, int pos) } else { - update_status_text_from_tab(LANG_CANNOTFINDSYMBOL,buf2); + update_status_text_from_lang(LANGID_CANNOTFINDSYMBOL,buf2); log_printf3("Error registering DLL: %s not found in %s",buf2,buf); } FreeLibrary(h); } else { - update_status_text_from_tab(LANG_COULDNOTLOAD,buf); + update_status_text_from_lang(LANGID_COULDNOTLOAD,buf); log_printf2("Error registering DLL: Could not load %s",buf); } OleUninitialize(); } else { - update_status_text_from_tab(LANG_NOOLE,buf); + update_status_text_from_lang(LANGID_NOOLE,buf); log_printf("Error registering DLL: Could not initialize OLE"); } } @@ -847,17 +846,17 @@ static int ExecuteEntry(entry *entries, int pos) process_string_fromtab(buf4,parms[3]); log_printf8("CreateShortCut: out: \"%s\", in: \"%s %s\", icon: %s,%d, sw=%d, hk=%d", - buf3,buf2,buf,buf4,parms[4]&0xff,(parms[4]&0xff00)>>8,parms[4]>>16); + buf3,buf2,buf,buf4,parms[4]&0xff,(parms[4]&0xff00)>>8,parms[4]>>16); if (CreateShortCut(g_hwnd, buf3, buf4[0]?buf4:NULL, parms[4]&0xff, buf2, buf[0]?buf:NULL, state_output_directory,(parms[4]&0xff00)>>8,parms[4]>>16)) { exec_errorflag++; - update_status_text_from_tab(LANG_ERRORCREATINGSHORTCUT,buf3); + update_status_text_from_lang(LANGID_ERRORCREATINGSHORTCUT,buf3); } else { - update_status_text_from_tab(LANG_CREATESHORTCUT,buf3); + update_status_text_from_lang(LANGID_CREATESHORTCUT,buf3); } return 0; #endif//NSIS_SUPPORT_CREATESHORTCUT @@ -879,12 +878,12 @@ static int ExecuteEntry(entry *entries, int pos) op.pFrom=buf; op.pTo=buf2; op.lpszProgressTitle=buf3; - op.fFlags=parms[2]; + op.fFlags=parms[2]; update_status_text("",buf3); res=SHFileOperation(&op); - if (res) + if (res) { // some of these changes were from Edgewise (wiked_edge@yahoo.com) - update_status_text_from_tab(LANG_COPYFAILED,""); + update_status_text_from_lang(LANGID_COPYFAILED,""); exec_errorflag++; } } @@ -893,7 +892,7 @@ static int ExecuteEntry(entry *entries, int pos) #ifdef NSIS_SUPPORT_REBOOT case EW_REBOOT: exec_errorflag++; - if (parms[0] == 0xbadf00d) + if (parms[0] == 0xbadf00d) { HANDLE h=LoadLibrary("advapi32.dll"); if (h) @@ -906,18 +905,18 @@ static int ExecuteEntry(entry *entries, int pos) ATP=(void*)GetProcAddress(h,"AdjustTokenPrivileges"); if (OPT && LPV && ATP) { - HANDLE hToken; - TOKEN_PRIVILEGES tkp; + HANDLE hToken; + TOKEN_PRIVILEGES tkp; if (OPT(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) { - LPV(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); + LPV(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; - tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - ATP(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); + tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + ATP(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); } } } - + if (ExitWindowsEx(EWX_REBOOT|EWX_FORCE,0)) ExitProcess(0); FreeLibrary(h); @@ -933,22 +932,22 @@ static int ExecuteEntry(entry *entries, int pos) { char *sec, *ent; sec=ent=0; -#ifdef NSIS_CONFIG_LOG +#ifdef NSIS_CONFIG_LOG lstrcpy(buf2,""); lstrcpy(buf3,buf2); #endif process_string_fromtab(buf,parms[0]); - if (parms[1]>=0) - { - process_string_fromtab(buf2,parms[1]); - sec=buf2; + if (parms[1]>=0) + { + process_string_fromtab(buf2,parms[1]); + sec=buf2; } - if (parms[2]>=0) - { - process_string_fromtab(buf3,parms[2]); - ent=buf3; + if (parms[2]>=0) + { + process_string_fromtab(buf3,parms[2]); + ent=buf3; } - process_string_fromtab(buf4,parms[3]); + process_string_fromtab(buf4,parms[3]); log_printf5("WriteINIStr: wrote [%s] %s=%s in %s",buf,buf2,buf3,buf4); if (!WritePrivateProfileString(buf,sec,ent,buf4)) exec_errorflag++; } @@ -978,7 +977,7 @@ static int ExecuteEntry(entry *entries, int pos) if (parms[2] != -1) { HKEY hKey; - if (RegOpenKeyEx((HKEY)rootkey,buf4,0,KEY_ALL_ACCESS,&hKey) == ERROR_SUCCESS) + if (RegOpenKeyEx((HKEY)rootkey,buf4,0,KEY_ALL_ACCESS,&hKey) == ERROR_SUCCESS) { process_string_fromtab(buf,parms[2]); log_printf4("DeleteRegValue: %d\\%s\\%s",rootkey,buf4,buf); @@ -998,10 +997,10 @@ static int ExecuteEntry(entry *entries, int pos) HKEY hKey; int rootkey=parms[0]; int type=parms[4]; - exec_errorflag++; + exec_errorflag++; process_string_fromtab(buf2,parms[2]); process_string_fromtab(buf4,parms[1]); - if (RegCreateKey((HKEY)rootkey,buf4,&hKey) == ERROR_SUCCESS) + if (RegCreateKey((HKEY)rootkey,buf4,&hKey) == ERROR_SUCCESS) { if (type <= 1) { @@ -1051,8 +1050,8 @@ static int ExecuteEntry(entry *entries, int pos) exec_errorflag++; } else - { - if (t==REG_DWORD) + { + if (t==REG_DWORD) { if (!parms[4]) exec_errorflag++; myitoa(p,*((DWORD*)p)); @@ -1071,7 +1070,7 @@ static int ExecuteEntry(entry *entries, int pos) int b=process_string_fromtab_toint(parms[3]); process_string_fromtab(buf2,parms[2]); p[0]=0; - if (RegOpenKeyEx((HKEY)parms[1],buf2,0,KEY_ALL_ACCESS,&key) == ERROR_SUCCESS) + if (RegOpenKeyEx((HKEY)parms[1],buf2,0,KEY_ALL_ACCESS,&key) == ERROR_SUCCESS) { DWORD d=NSIS_MAX_STRLEN-1; if (parms[4]) RegEnumKey(key,b,p,d); @@ -1085,7 +1084,7 @@ static int ExecuteEntry(entry *entries, int pos) return 0; #endif//NSIS_SUPPORT_REGISTRYFUNCTIONS #ifdef NSIS_SUPPORT_FILEFUNCTIONS - case EW_FCLOSE: + case EW_FCLOSE: { char *t=g_usrvars[parms[0]]; if (*t) CloseHandle((HANDLE)myatoi(t)); @@ -1153,7 +1152,7 @@ static int ExecuteEntry(entry *entries, int pos) return 0; } if (!c) break; - if (lc == '\r' || lc == '\n') + if (lc == '\r' || lc == '\n') { if (lc == c || (c != '\r' && c != '\n')) SetFilePointer(h,-1,NULL,FILE_CURRENT); else textout[rpos++]=c; @@ -1173,7 +1172,7 @@ static int ExecuteEntry(entry *entries, int pos) if (*t) { DWORD v=SetFilePointer((HANDLE)myatoi(t),process_string_fromtab_toint(parms[1]),NULL,parms[2]); - + if (parms[3]>=0) { myitoa(g_usrvars[parms[3]],v); @@ -1239,7 +1238,7 @@ static int ExecuteEntry(entry *entries, int pos) { lstrcpy(buf2,buf); } - else + else { lstrcpy(buf2,state_install_directory); addtrailingslash(buf2); @@ -1288,11 +1287,11 @@ static int ExecuteEntry(entry *entries, int pos) log_printf3("created uninstaller: %d, \"%s\"",ret,buf2); if (ret < 0) { - update_status_text_from_tab(LANG_ERRORCREATING,buf); + update_status_text_from_lang(LANGID_ERRORCREATING,buf); DeleteFile(buf2); } else - update_status_text_from_tab(LANG_CREATEDUNINST,buf); + update_status_text_from_lang(LANGID_CREATEDUNINST,buf); } return 0; #endif//NSIS_CONFIG_UNINSTALL_SUPPORT diff --git a/Source/exehead/fileform.h b/Source/exehead/fileform.h index a7650db3..ad18904f 100644 --- a/Source/exehead/fileform.h +++ b/Source/exehead/fileform.h @@ -126,7 +126,6 @@ enum }; - // used for section->default_state #define DFS_SET 0x80000000 #define DFS_RO 0x40000000 @@ -150,8 +149,6 @@ typedef struct // Strings common to both installers and uninstallers typedef struct { - WORD lang_id; - // unprocessed strings int branding; int cancelbutton; @@ -219,12 +216,18 @@ typedef struct int inst_corrupted; int output_dir; int create_dir; + + // Note - should be at the end (everything before here should be just ints) + WORD lang_id; + } common_strings; // Settings common to both installers and uninstallers typedef struct { - int str_tables; // offset to tables array + int str_tables_num; // number of strings tables in array + int str_tables; // offset to common string tables array + int inst_str_tables; // offset to install/uninstall string tables array int num_entries; // total number of entries @@ -259,8 +262,6 @@ typedef struct // Strings specific to installers typedef struct { - WORD lang_id; - // these first strings are literals (should not be encoded) int backbutton; int nextbutton; @@ -288,9 +289,6 @@ typedef struct // common settings common_header common; - int str_tables_num; // number of strings tables in array - int str_tables; // offset to tables array - int install_reg_rootkey, install_reg_key_ptr, install_reg_value_ptr; #ifdef NSIS_CONFIG_COMPONENTPAGE @@ -337,8 +335,6 @@ typedef struct // Strings specific to uninstallers typedef struct { - WORD lang_id; - // unprocessed strings int uninstbutton; int uninstalltext; @@ -351,9 +347,6 @@ typedef struct // common settings common_header common; - int str_tables_num; // number of strings tables in array - int str_tables; // offset to tables array - int code; int code_size; diff --git a/Source/exehead/lang.h b/Source/exehead/lang.h index 074e25eb..b7c25be9 100644 --- a/Source/exehead/lang.h +++ b/Source/exehead/lang.h @@ -24,74 +24,140 @@ // Changed by Amir Szekely 3rd August 2002 // Now supports more than one language in each installer -// Please note that all of these define the offset not the string itself. -// To get the string it self use process_string_fromtab, GetStringFromStringTab or STR(). +// Modified by Dave Laundon 10th August 2002 +// In many places, these strings are now referenced by an ID (just their offsets +// into the (common|installer|uninstall)_strings structures) through *_from_lang +// and *FromLang functions - removing code-costly references to the +// cur_(common|install|uninstall)_strings_table globals. Common strings are +// identified by IDs >=0 and install/uninstall strings by IDs <0. What's more, +// these IDs fall between -128 to +127 and compile to tiny 2-byte PUSH <8-bit> +// instructions when being passed to the functions. -#define STR(x) GetStringFromStringTab(x) +typedef void *langid_t; // Just so compiler can warn if an ID is given to a + // function expecting a string offset and vice-versa. -#define INSTALL_STR(x) (cur_install_strings_table->x) +// Please note that all LANG_* define the offset not the string itself. +// To get the string itself use process_string_fromtab, GetStringFromStringTab or STR(). + +#define STR(x) GetStringFromStringTab(x) + +#define INSTALL_STR(x) (((installer_strings *)cur_install_strings_table)->x) +#define INSTALL_ID(x) ((langid_t)((~(UINT)0) - FIELD_OFFSET(installer_strings, x) / sizeof(int))) // Installer specific strings -#define LANG_BTN_BACK (INSTALL_STR(backbutton)) -#define LANG_BTN_NEXT (INSTALL_STR(nextbutton)) -#define LANG_BTN_BROWSE (INSTALL_STR(browse)) -#define LANG_BTN_INSTALL (INSTALL_STR(installbutton)) -#define LANG_SPACE_REQ (INSTALL_STR(spacerequired)) -#define LANG_SPACE_AVAIL (INSTALL_STR(spaceavailable)) -#define LANG_COMP_CUSTOM (INSTALL_STR(custom)) -#define LANG_DIR_TEXT (INSTALL_STR(text)) -#define LANG_DIR_SUBTEXT (INSTALL_STR(dirsubtext)) -#define LANG_COMP_TEXT (INSTALL_STR(componenttext)) -#define LANG_COMP_SUBTEXT(x) (INSTALL_STR(componentsubtext[x])) -#define LANG_LICENSE_TEXT (INSTALL_STR(licensetext)) -#define LANG_LICENSE_DATA (INSTALL_STR(licensedata)) -#define LANG_BTN_LICENSE (INSTALL_STR(licensebutton)) +#define LANG_BTN_BACK (INSTALL_STR(backbutton)) +#define LANGID_BTN_BACK (INSTALL_ID(backbutton)) +#define LANG_BTN_NEXT (INSTALL_STR(nextbutton)) +#define LANGID_BTN_NEXT (INSTALL_ID(nextbutton)) +#define LANG_BTN_BROWSE (INSTALL_STR(browse)) +#define LANGID_BTN_BROWSE (INSTALL_ID(browse)) +#define LANG_BTN_INSTALL (INSTALL_STR(installbutton)) +#define LANGID_BTN_INSTALL (INSTALL_ID(installbutton)) +#define LANG_SPACE_REQ (INSTALL_STR(spacerequired)) +#define LANGID_SPACE_REQ (INSTALL_ID(spacerequired)) +#define LANG_SPACE_AVAIL (INSTALL_STR(spaceavailable)) +#define LANGID_SPACE_AVAIL (INSTALL_ID(spaceavailable)) +#define LANG_COMP_CUSTOM (INSTALL_STR(custom)) +#define LANGID_COMP_CUSTOM (INSTALL_ID(custom)) +#define LANG_DIR_TEXT (INSTALL_STR(text)) +#define LANGID_DIR_TEXT (INSTALL_ID(text)) +#define LANG_DIR_SUBTEXT (INSTALL_STR(dirsubtext)) +#define LANGID_DIR_SUBTEXT (INSTALL_ID(dirsubtext)) +#define LANG_COMP_TEXT (INSTALL_STR(componenttext)) +#define LANGID_COMP_TEXT (INSTALL_ID(componenttext)) +#define LANG_COMP_SUBTEXT(x) (INSTALL_STR(componentsubtext[x])) +#define LANGID_COMP_SUBTEXT(x) (INSTALL_ID(componentsubtext[x])) +#define LANG_LICENSE_TEXT (INSTALL_STR(licensetext)) +#define LANGID_LICENSE_TEXT (INSTALL_ID(licensetext)) +#define LANG_LICENSE_DATA (INSTALL_STR(licensedata)) +#define LANGID_LICENSE_DATA (INSTALL_ID(licensedata)) +#define LANG_BTN_LICENSE (INSTALL_STR(licensebutton)) +#define LANGID_BTN_LICENSE (INSTALL_ID(licensebutton)) -#define UNINSTALL_STR(x) (cur_uninstall_strings_table->x) +#define UNINSTALL_STR(x) (((uninstall_strings *)cur_install_strings_table)->x) +#define UNINSTALL_ID(x) ((langid_t)((~(UINT)0) - FIELD_OFFSET(uninstall_strings, x) / sizeof(int))) // Uninstall specific strings -#define LANG_BTN_UNINST (UNINSTALL_STR(uninstbutton)) -#define LANG_UNINST_TEXT (UNINSTALL_STR(uninstalltext)) -#define LANG_UNINST_SUBTEXT (UNINSTALL_STR(uninstalltext2)) +#define LANG_BTN_UNINST (UNINSTALL_STR(uninstbutton)) +#define LANGID_BTN_UNINST (UNINSTALL_ID(uninstbutton)) +#define LANG_UNINST_TEXT (UNINSTALL_STR(uninstalltext)) +#define LANGID_UNINST_TEXT (UNINSTALL_ID(uninstalltext)) +#define LANG_UNINST_SUBTEXT (UNINSTALL_STR(uninstalltext2)) +#define LANGID_UNINST_SUBTEXT (UNINSTALL_ID(uninstalltext2)) -#define COMMON_STR(x) (cur_common_strings_table->x) +#define COMMON_STR(x) (cur_common_strings_table->x) +#define COMMON_ID(x) ((langid_t)(FIELD_OFFSET(common_strings, x) / sizeof(int))) // Common strings -#define LANG_BRANDING (COMMON_STR(branding)) -#define LANG_BTN_CANCEL (COMMON_STR(cancelbutton)) -#define LANG_BTN_DETAILS (COMMON_STR(showdetailsbutton)) -#define LANG_COMPLETED (COMMON_STR(completed)) -#define LANG_BTN_CLOSE (COMMON_STR(closebutton)) -#define LANG_NAME (COMMON_STR(name)) -#define LANG_CAPTION (COMMON_STR(caption)) -#define LANG_SUBCAPTION(x) (COMMON_STR(subcaptions[x])) +#define LANG_BRANDING (COMMON_STR(branding)) +#define LANGID_BRANDING (COMMON_ID(branding)) +#define LANG_BTN_CANCEL (COMMON_STR(cancelbutton)) +#define LANGID_BTN_CANCEL (COMMON_ID(cancelbutton)) +#define LANG_BTN_DETAILS (COMMON_STR(showdetailsbutton)) +#define LANGID_BTN_DETAILS (COMMON_ID(showdetailsbutton)) +#define LANG_COMPLETED (COMMON_STR(completed)) +#define LANGID_COMPLETED (COMMON_ID(completed)) +#define LANG_BTN_CLOSE (COMMON_STR(closebutton)) +#define LANGID_BTN_CLOSE (COMMON_ID(closebutton)) +#define LANG_NAME (COMMON_STR(name)) +#define LANGID_NAME (COMMON_ID(name)) +#define LANG_CAPTION (COMMON_STR(caption)) +#define LANGID_CAPTION (COMMON_ID(caption)) +#define LANG_SUBCAPTION(x) (COMMON_STR(subcaptions[x])) +#define LANGID_SUBCAPTION(x) (COMMON_ID(subcaptions[x])) // instruction strings -#define LANG_FILEERR (COMMON_STR(fileerrtext)) -#define LANG_DELETEFILE (COMMON_STR(del_file)) -#define LANG_DLLREGERROR (COMMON_STR(err_reg_dll)) -#define LANG_REMOVEDIR (COMMON_STR(remove_dir)) -#define LANG_OUTPUTDIR (COMMON_STR(output_dir)) -#define LANG_CREATEDIR (COMMON_STR(create_dir)) -#define LANG_RENAME (COMMON_STR(rename)) -#define LANG_RENAMEONREBOOT (COMMON_STR(rename_on_reboot)) -#define LANG_SKIPPED (COMMON_STR(skipped)) -#define LANG_CANTWRITE (COMMON_STR(cant_write)) -#define LANG_EXTRACT (COMMON_STR(extract)) -#define LANG_ERRORWRITING (COMMON_STR(err_writing)) -#define LANG_ERRORDECOMPRESSING (COMMON_STR(err_decompressing)) -#define LANG_DELETEONREBOOT (COMMON_STR(del_on_reboot)) -#define LANG_EXECSHELL (COMMON_STR(exec_shell)) -#define LANG_EXECUTE (COMMON_STR(exec)) -#define LANG_CANNOTFINDSYMBOL (COMMON_STR(symbol_not_found)) -#define LANG_COULDNOTLOAD (COMMON_STR(could_not_load)) -#define LANG_NOOLE (COMMON_STR(no_ole)) -#define LANG_ERRORCREATINGSHORTCUT (COMMON_STR(err_creating_shortcut)) -#define LANG_CREATESHORTCUT (COMMON_STR(create_shortcut)) -#define LANG_COPYTO (COMMON_STR(copy_to)) -#define LANG_COPYFAILED (COMMON_STR(copy_failed)) -#define LANG_ERRORCREATING (COMMON_STR(err_creating)) -#define LANG_CREATEDUNINST (COMMON_STR(created_uninst)) -#define LANG_INSTCORRUPTED (COMMON_STR(inst_corrupted)) +#define LANG_FILEERR (COMMON_STR(fileerrtext)) +#define LANGID_FILEERR (COMMON_ID(fileerrtext)) +#define LANG_DELETEFILE (COMMON_STR(del_file)) +#define LANGID_DELETEFILE (COMMON_ID(del_file)) +#define LANG_DLLREGERROR (COMMON_STR(err_reg_dll)) +#define LANGID_DLLREGERROR (COMMON_ID(err_reg_dll)) +#define LANG_REMOVEDIR (COMMON_STR(remove_dir)) +#define LANGID_REMOVEDIR (COMMON_ID(remove_dir)) +#define LANG_OUTPUTDIR (COMMON_STR(output_dir)) +#define LANGID_OUTPUTDIR (COMMON_ID(output_dir)) +#define LANG_CREATEDIR (COMMON_STR(create_dir)) +#define LANGID_CREATEDIR (COMMON_ID(create_dir)) +#define LANG_RENAME (COMMON_STR(rename)) +#define LANGID_RENAME (COMMON_ID(rename)) +#define LANG_RENAMEONREBOOT (COMMON_STR(rename_on_reboot)) +#define LANGID_RENAMEONREBOOT (COMMON_ID(rename_on_reboot)) +#define LANG_SKIPPED (COMMON_STR(skipped)) +#define LANGID_SKIPPED (COMMON_ID(skipped)) +#define LANG_CANTWRITE (COMMON_STR(cant_write)) +#define LANGID_CANTWRITE (COMMON_ID(cant_write)) +#define LANG_EXTRACT (COMMON_STR(extract)) +#define LANGID_EXTRACT (COMMON_ID(extract)) +#define LANG_ERRORWRITING (COMMON_STR(err_writing)) +#define LANGID_ERRORWRITING (COMMON_ID(err_writing)) +#define LANG_ERRORDECOMPRESSING (COMMON_STR(err_decompressing)) +#define LANGID_ERRORDECOMPRESSING (COMMON_ID(err_decompressing)) +#define LANG_DELETEONREBOOT (COMMON_STR(del_on_reboot)) +#define LANGID_DELETEONREBOOT (COMMON_ID(del_on_reboot)) +#define LANG_EXECSHELL (COMMON_STR(exec_shell)) +#define LANGID_EXECSHELL (COMMON_ID(exec_shell)) +#define LANG_EXECUTE (COMMON_STR(exec)) +#define LANGID_EXECUTE (COMMON_ID(exec)) +#define LANG_CANNOTFINDSYMBOL (COMMON_STR(symbol_not_found)) +#define LANGID_CANNOTFINDSYMBOL (COMMON_ID(symbol_not_found)) +#define LANG_COULDNOTLOAD (COMMON_STR(could_not_load)) +#define LANGID_COULDNOTLOAD (COMMON_ID(could_not_load)) +#define LANG_NOOLE (COMMON_STR(no_ole)) +#define LANGID_NOOLE (COMMON_ID(no_ole)) +#define LANG_ERRORCREATINGSHORTCUT (COMMON_STR(err_creating_shortcut)) +#define LANGID_ERRORCREATINGSHORTCUT (COMMON_ID(err_creating_shortcut)) +#define LANG_CREATESHORTCUT (COMMON_STR(create_shortcut)) +#define LANGID_CREATESHORTCUT (COMMON_ID(create_shortcut)) +#define LANG_COPYTO (COMMON_STR(copy_to)) +#define LANGID_COPYTO (COMMON_ID(copy_to)) +#define LANG_COPYFAILED (COMMON_STR(copy_failed)) +#define LANGID_COPYFAILED (COMMON_ID(copy_failed)) +#define LANG_ERRORCREATING (COMMON_STR(err_creating)) +#define LANGID_ERRORCREATING (COMMON_ID(err_creating)) +#define LANG_CREATEDUNINST (COMMON_STR(created_uninst)) +#define LANGID_CREATEDUNINST (COMMON_ID(created_uninst)) +#define LANG_INSTCORRUPTED (COMMON_STR(inst_corrupted)) +#define LANGID_INSTCORRUPTED (COMMON_ID(inst_corrupted)) -#endif//_NSIS_LANG_H_ \ No newline at end of file +#endif//_NSIS_LANG_H_ diff --git a/Source/exehead/ui.h b/Source/exehead/ui.h index dede75f0..f3a5437c 100644 --- a/Source/exehead/ui.h +++ b/Source/exehead/ui.h @@ -1,13 +1,14 @@ #ifndef _UI_H_ #define _UI_H_ +#include "lang.h" + // Added by Amir Szekely 3rd August 2002 -extern installer_strings *cur_install_strings_table; extern common_strings *cur_common_strings_table; -extern uninstall_strings *cur_uninstall_strings_table; +extern char *cur_install_strings_table; // installer_strings/uninstall_strings depending on installer type int ui_doinstall(void); -void update_status_text_from_tab(int texttab, const char *text2); +void update_status_text_from_lang(langid_t id, const char *text2); void update_status_text(const char *text1, const char *text2); extern int ui_st_updateflag; diff --git a/Source/exehead/util.c b/Source/exehead/util.c index aa4f8203..ce293583 100644 --- a/Source/exehead/util.c +++ b/Source/exehead/util.c @@ -44,7 +44,7 @@ void doRMDir(char *buf, int recurse) WIN32_FIND_DATA fd; lstrcat(buf,"\\*.*"); h = FindFirstFile(buf,&fd); - if (h != INVALID_HANDLE_VALUE) + if (h != INVALID_HANDLE_VALUE) { do { @@ -53,10 +53,10 @@ void doRMDir(char *buf, int recurse) { lstrcpy(buf+i+1,fd.cFileName); if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) doRMDir(buf,recurse); - else + else { - update_status_text_from_tab(LANG_DELETEFILE,buf); - if (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) + update_status_text_from_lang(LANGID_DELETEFILE,buf); + if (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) SetFileAttributes(buf,fd.dwFileAttributes^FILE_ATTRIBUTE_READONLY); DeleteFile(buf); } @@ -67,7 +67,7 @@ void doRMDir(char *buf, int recurse) buf[i]=0; // fix buffer } log_printf2("RMDir: RemoveDirectory(\"%s\")",buf); - update_status_text_from_tab(LANG_REMOVEDIR,buf); + update_status_text_from_lang(LANGID_REMOVEDIR,buf); RemoveDirectory(buf); } #endif//NSIS_SUPPORT_RMDIR @@ -106,7 +106,7 @@ char *scanendslash(const char *str) int validpathspec(char *ubuf) { - return ((ubuf[0]=='\\' && ubuf[1]=='\\') || (ubuf[0] && *CharNext(ubuf)==':')); + return ((ubuf[0]=='\\' && ubuf[1]=='\\') || (ubuf[0] && *CharNext(ubuf)==':')); } int is_valid_instpath(char *s) @@ -117,7 +117,7 @@ int is_valid_instpath(char *s) if (s[0] == '\\' && s[1] == '\\') // \\ path { if (lastchar(s)!='\\') ivp++; - while (*s) + while (*s) { if (*s == '\\') ivp++; s=CharNext(s); @@ -213,34 +213,34 @@ BOOL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew) // wininit is used as a temporary here GetShortPathName(pszExisting,wininit,1024); cchRenameLine = wsprintf(szRenameLine,"%s=%s\r\n",tmpbuf,wininit); - + GetWindowsDirectory(wininit, 1024-16); lstrcat(wininit, "\\wininit.ini"); - hfile = CreateFile(wininit, - GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, + hfile = CreateFile(wininit, + GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); - if (hfile != INVALID_HANDLE_VALUE) + if (hfile != INVALID_HANDLE_VALUE) { dwFileSize = GetFileSize(hfile, NULL); hfilemap = CreateFileMapping(hfile, NULL, PAGE_READWRITE, 0, dwFileSize + cchRenameLine + 10, NULL); - if (hfilemap != NULL) + if (hfilemap != NULL) { LPSTR pszWinInit = (LPSTR) MapViewOfFile(hfilemap, FILE_MAP_WRITE, 0, 0, 0); - if (pszWinInit != NULL) + if (pszWinInit != NULL) { int do_write=0; LPSTR pszRenameSecInFile = findinmem(pszWinInit, szRenameSec,-1); - if (pszRenameSecInFile == NULL) + if (pszRenameSecInFile == NULL) { lstrcpy(pszWinInit+dwFileSize, szRenameSec); dwFileSize += 10; dwRenameLinePos = dwFileSize; do_write++; - } - else + } + else { char *pszFirstRenameLine = findinmem(pszRenameSecInFile, "\n",-1)+1; int l=pszWinInit + dwFileSize-pszFirstRenameLine; @@ -256,7 +256,7 @@ BOOL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew) } } - if (do_write) + if (do_write) { mini_memcpy(&pszWinInit[dwRenameLinePos], szRenameLine,cchRenameLine); dwFileSize += cchRenameLine; @@ -355,6 +355,19 @@ void process_string_fromtab(char *out, int offs) lstrcpyn(out,ps_tmpbuf,NSIS_MAX_STRLEN); } +void process_string_from_lang(char *out, langid_t id) +{ + process_string_fromtab(out, GetLangString(id)); +} + +// Retrieve the string offset associated with the language string ID given +int GetLangString(langid_t id) +{ + return (int)id < 0 ? + *((int *)cur_install_strings_table - 1 - (int)id) : + *((int *)cur_common_strings_table + (int)id); +} + void myitoa(char *s, int d) { wsprintf(s,"%d",d); } int myatoi(char *s) { @@ -498,7 +511,7 @@ void process_string(char *out, const char *in) break; case VAR_CODES_START + 34: // LANGUAGE - wsprintf(out, "%u", cur_install_strings_table->lang_id); + wsprintf(out, "%u", cur_common_strings_table->lang_id); break; #ifdef NSIS_CONFIG_PLUGIN_SUPPORT @@ -529,12 +542,12 @@ void process_string(char *out, const char *in) char log_text[4096]; int log_dolog; void log_write(int close) -{ +{ extern char g_log_file[1024]; static HANDLE fp=INVALID_HANDLE_VALUE; if (close) { - if (fp!=INVALID_HANDLE_VALUE) + if (fp!=INVALID_HANDLE_VALUE) { CloseHandle(fp); } @@ -546,7 +559,7 @@ void log_write(int close) if (g_log_file[0] && fp==INVALID_HANDLE_VALUE) { fp = CreateFile(g_log_file,GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_ALWAYS,0,NULL); - if (fp!=INVALID_HANDLE_VALUE) + if (fp!=INVALID_HANDLE_VALUE) SetFilePointer(fp,0,NULL,FILE_END); } if (fp!=INVALID_HANDLE_VALUE) @@ -585,7 +598,7 @@ int CreateShortCut(HWND hwnd, LPCSTR pszShortcutFile, LPCSTR pszIconFile, int ic if (showmode) psl->lpVtbl->SetShowCmd(psl,showmode); if (hotkey) psl->lpVtbl->SetHotkey(psl,(unsigned short)hotkey); if (pszIconFile) psl->lpVtbl->SetIconLocation(psl,pszIconFile,iconindex); - if (pszArg) + if (pszArg) { psl->lpVtbl->SetArguments(psl,pszArg); } @@ -604,4 +617,4 @@ int CreateShortCut(HWND hwnd, LPCSTR pszShortcutFile, LPCSTR pszIconFile, int ic OleUninitialize(); return rv; } -#endif//NSIS_SUPPORT_CREATESHORTCUT \ No newline at end of file +#endif//NSIS_SUPPORT_CREATESHORTCUT diff --git a/Source/exehead/util.h b/Source/exehead/util.h index b174d4a4..f7bc15e0 100644 --- a/Source/exehead/util.h +++ b/Source/exehead/util.h @@ -1,10 +1,13 @@ #include "config.h" +#include "lang.h" void recursive_create_directory(char *directory); extern char ps_tmpbuf[NSIS_MAX_STRLEN*2]; void process_string(char *out, const char *in); void process_string_fromtab(char *out, int offs); +void process_string_from_lang(char *out, langid_t id); +int GetLangString(langid_t id); int process_string_fromtab_toint(int offs); void myRegGetStr(HKEY root, const char *sub, const char *name, char *out); int myatoi(char *s); @@ -36,7 +39,7 @@ HANDLE myCreateProcess(char *cmd, char *dir); int my_MessageBox(const char *text, UINT type); void doRMDir(char *buf, int recurse); - + HANDLE myOpenFile(const char *fn, DWORD da, DWORD cd); int CreateShortCut(HWND hwnd, LPCSTR pszShortcutFile, LPCSTR pszIconFile, int iconindex, LPCSTR pszExe, LPCSTR pszArg, LPCSTR workingdir, int showmode, int hotkey); int validpathspec(char *ubuf);