Implemented a method where LANG_* strings can be referenced

by constant id's - reducing code overhead associated with
looking up the global strings variables.  Kind of.  Just compare
the assembly output...


git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@685 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
eccles 2002-08-11 18:56:30 +00:00
parent adb237d9a1
commit ac00a53e1a
7 changed files with 347 additions and 280 deletions

View file

@ -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
@ -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);
@ -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);
}

View file

@ -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;
@ -201,10 +200,10 @@ static int ExecuteEntry(entry *entries, int pos)
log_printf3("CreateDirectory: \"%s\" (%d)",buf2,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:
@ -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
@ -351,7 +350,7 @@ static int ExecuteEntry(entry *entries, int pos)
{
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);
return 0;
@ -360,7 +359,7 @@ static int ExecuteEntry(entry *entries, int pos)
lstrcpy(buf3,g_usrvars[0]);//save $0
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))
@ -374,12 +373,12 @@ static int ExecuteEntry(entry *entries, int pos)
return 0;
default:
log_printf("File: error, user abort");
update_status_text_from_tab(LANG_CANTWRITE,buf);
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);
@ -428,7 +427,7 @@ static int ExecuteEntry(entry *entries, int pos)
if (DeleteFile(buf2))
{
log_printf2("Delete: DeleteFile(\"%s\")",buf2);
update_status_text_from_tab(LANG_DELETEFILE,buf2);
update_status_text_from_lang(LANGID_DELETEFILE,buf2);
}
else
{
@ -439,7 +438,7 @@ static int ExecuteEntry(entry *entries, int pos)
exec_rebootflag++;
#endif
log_printf2("Delete: DeleteFile on Reboot(\"%s\")",buf2);
update_status_text_from_tab(LANG_DELETEONREBOOT,buf2);
update_status_text_from_lang(LANGID_DELETEONREBOOT,buf2);
MoveFileOnReboot(buf2,NULL);
}
else
@ -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,7 +691,7 @@ 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);
@ -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");
}
}
@ -853,11 +852,11 @@ static int ExecuteEntry(entry *entries, int pos)
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
@ -884,7 +883,7 @@ static int ExecuteEntry(entry *entries, int pos)
res=SHFileOperation(&op);
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++;
}
}
@ -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

View file

@ -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;

View file

@ -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.
typedef void *langid_t; // Just so compiler can warn if an ID is given to a
// function expecting a string offset and vice-versa.
// 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) (cur_install_strings_table->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 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 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_ID(x) ((langid_t)(FIELD_OFFSET(common_strings, x) / sizeof(int)))
// Common strings
#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 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_

View file

@ -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;

View file

@ -55,7 +55,7 @@ void doRMDir(char *buf, int recurse)
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) doRMDir(buf,recurse);
else
{
update_status_text_from_tab(LANG_DELETEFILE,buf);
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
@ -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

View file

@ -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);