Added SectionSetInstTypes and SectionGetInstTypes, about 70 bytes saved

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2249 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2003-03-07 21:10:48 +00:00
parent da2dd5a56d
commit 76183f6fe9
6 changed files with 67 additions and 26 deletions

View file

@ -59,7 +59,7 @@ HWND g_progresswnd;
static char g_tmp[4096];
static int num_sections;
int num_sections;
// sent to the last child window to tell it that the install thread is done
#define WM_NOTIFY_INSTPROC_DONE (WM_USER+0x4)
@ -1069,7 +1069,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
uMsg=WM_IN_UPDATEMSG;
}
if (uMsg == WM_USER+0x17)
if (uMsg == WM_USER+0x17) // update text
{
int x=wParam;
int ns=lParam;

View file

@ -30,8 +30,6 @@ union flags g_flags;
char plugins_temp_dir[NSIS_MAX_STRLEN]="";
#endif
extern HWND m_curwnd;
static WIN32_FIND_DATA * NSISCALL file_exists(char *buf)
{
HANDLE h;
@ -1494,32 +1492,43 @@ static int NSISCALL ExecuteEntry(entry *entry_)
case EW_SECTIONSET:
{
int x=process_string_fromparm_toint(0);
if (g_inst_section && x >= 0 && x < g_inst_header->num_sections)
if ((unsigned int)x < (unsigned int)num_sections)
{
if (parm1==0) //set text
section *sec=g_inst_section+x;
if (parm1>=0) // get something
{
if (g_SectionHack)
int res=((int*)sec)[parm1];
if (!parm1)
{
// getting text
process_string_fromtab(var2,res);
}
else
{
// getting number
myitoa(var2,res);
}
}
else // set something
{
parm1=-parm1-1;
if (parm1)
{
// not setting text, get int
parm2=process_string_fromparm_toint(2);
}
else
{
// setting text, send the message to do it
SendMessage(g_SectionHack,WM_USER+0x17,x,parm2);
}
g_inst_section[x].name_ptr=parm2;
}
else if (parm1==1) // get text
{
process_string_fromtab(var2,g_inst_section[x].name_ptr);
}
else if (parm1==2) // set flags
{
g_inst_section[x].flags=process_string_fromparm_toint(2);
if (g_SectionHack)
((int*)sec)[parm1]=parm2;
if (parm1)
{
SendMessage(g_SectionHack,WM_USER+0x18,x,(LPARAM)(g_inst_section[x].flags&SF_SELECTED));
// update tree view
SendMessage(g_SectionHack,WM_USER+0x18,x,(LPARAM)(sec->flags&SF_SELECTED));
}
}
else // get flags
{
myitoa(var2,g_inst_section[x].flags);
}
}
else g_flags.exec_error++;
}

View file

@ -9,6 +9,7 @@ int NSISCALL ui_doinstall(void);
void NSISCALL update_status_text_from_lang(int id, const char *text2);
void NSISCALL update_status_text(const char *text1, const char *text2);
extern int ui_st_updateflag;
extern int num_sections;
//extern int g_autoclose;
extern void *g_inst_combinedheader;

View file

@ -3816,7 +3816,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
}
ent.which=EW_SECTIONSET;
ent.offsets[0]=add_string(line.gettoken_str(1));
ent.offsets[1]=0;
ent.offsets[1]=-1;
ent.offsets[2]=add_string(line.gettoken_str(2));
SCRIPT_MSG("SectionSetText: %s=%s\n",line.gettoken_str(1),line.gettoken_str(2));
return add_entry(&ent);
@ -3828,7 +3828,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
}
ent.which=EW_SECTIONSET;
ent.offsets[0]=add_string(line.gettoken_str(1));
ent.offsets[1]=1;
ent.offsets[1]=0;
ent.offsets[2]=line.gettoken_enum(2,usrvars);
if (line.gettoken_str(2)[0] && ent.offsets[2]<0) PRINTHELP()
SCRIPT_MSG("SectionGetText: %s->%s\n",line.gettoken_str(1),line.gettoken_str(2));
@ -3841,7 +3841,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
}
ent.which=EW_SECTIONSET;
ent.offsets[0]=add_string(line.gettoken_str(1));
ent.offsets[1]=2;
ent.offsets[1]=-3;
ent.offsets[2]=add_string(line.gettoken_str(2));
SCRIPT_MSG("SectionSetFlags: %s->%s\n",line.gettoken_str(1),line.gettoken_str(2));
return add_entry(&ent);
@ -3853,16 +3853,43 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
}
ent.which=EW_SECTIONSET;
ent.offsets[0]=add_string(line.gettoken_str(1));
ent.offsets[1]=3;
ent.offsets[1]=2;
ent.offsets[2]=line.gettoken_enum(2,usrvars);
if (line.gettoken_str(2)[0] && ent.offsets[2]<0) PRINTHELP()
SCRIPT_MSG("SectionGetFlags: %s->%s\n",line.gettoken_str(1),line.gettoken_str(2));
return add_entry(&ent);
case TOK_SECTIONSETINSTTYPES:
if (uninstall_mode)
{
ERROR_MSG("Error: %s called in uninstall section.\n", line.gettoken_str(0));
return PS_ERROR;
}
ent.which=EW_SECTIONSET;
ent.offsets[0]=add_string(line.gettoken_str(1));
ent.offsets[1]=-2;
ent.offsets[2]=add_string(line.gettoken_str(2));
SCRIPT_MSG("SectionSetInstTypes: %s->%s\n",line.gettoken_str(1),line.gettoken_str(2));
return add_entry(&ent);
case TOK_SECTIONGETINSTTYPES:
if (uninstall_mode)
{
ERROR_MSG("Error: %s called in uninstall section.\n", line.gettoken_str(0));
return PS_ERROR;
}
ent.which=EW_SECTIONSET;
ent.offsets[0]=add_string(line.gettoken_str(1));
ent.offsets[1]=1;
ent.offsets[2]=line.gettoken_enum(2,usrvars);
if (line.gettoken_str(2)[0] && ent.offsets[2]<0) PRINTHELP()
SCRIPT_MSG("SectionGetInstTypes: %s->%s\n",line.gettoken_str(1),line.gettoken_str(2));
return add_entry(&ent);
#else//!NSIS_CONFIG_COMPONENTPAGE
case TOK_SECTIONGETTEXT:
case TOK_SECTIONSETTEXT:
case TOK_SECTIONSETFLAGS:
case TOK_SECTIONGETFLAGS:
case TOK_SECTIONSETINSTTYPES:
case TOK_SECTIONGETINSTTYPES:
ERROR_MSG("Error: %s specified, NSIS_CONFIG_COMPONENTPAGE not defined.\n", line.gettoken_str(0));
return PS_ERROR;
#endif//!NSIS_CONFIG_COMPONENTPAGE

View file

@ -129,6 +129,8 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_SEARCHPATH,"SearchPath",2,0,"$(user_var: result) filename"},
{TOK_SECTIONSETFLAGS,"SectionSetFlags",2,0,"section_index flags"},
{TOK_SECTIONGETFLAGS,"SectionGetFlags",2,0,"section_index $(user_var: output flags)"},
{TOK_SECTIONSETINSTTYPES,"SectionSetInstTypes",2,0,"section_index flags"},
{TOK_SECTIONGETINSTTYPES,"SectionGetInstTypes",2,0,"section_index $(user_var: output flags)"},
{TOK_SECTIONGETTEXT,"SectionGetText",2,0,"section_index $(user_var: output text)"},
{TOK_SECTIONSETTEXT,"SectionSetText",2,0,"section_index text_string"},
{TOK_SECTIONEND,"SectionEnd",0,0,""},

View file

@ -197,6 +197,8 @@ enum
TOK_SECTIONGETTEXT,
TOK_SECTIONSETFLAGS,
TOK_SECTIONGETFLAGS,
TOK_SECTIONSETINSTTYPES,
TOK_SECTIONGETINSTTYPES,
TOK_SETSHELLVARCONTEXT,
TOK_PLUGINDIR,
TOK_INITPLUGINSDIR,