Added IfAbort

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2412 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2003-04-02 19:54:53 +00:00
parent 104df88ca3
commit 6e963b9e91
8 changed files with 52 additions and 43 deletions

View file

@ -985,18 +985,11 @@ int CEXEBuild::resolve_instruction(const char *fn, const char *str, entry *w, in
if (resolve_jump_int(fn,&w->offsets[1],offs,start,end)) return 1;
if (resolve_jump_int(fn,&w->offsets[2],offs,start,end)) return 1;
}
else if (w->which == EW_IFERRORS)
else if (w->which == EW_IFFLAG)
{
if (resolve_jump_int(fn,&w->offsets[0],offs,start,end)) return 1;
if (resolve_jump_int(fn,&w->offsets[1],offs,start,end)) return 1;
}
#ifdef NSIS_SUPPORT_REBOOT
else if (w->which == EW_IFREBOOTFLAG)
{
if (resolve_jump_int(fn,&w->offsets[0],offs,start,end)) return 1;
if (resolve_jump_int(fn,&w->offsets[1],offs,start,end)) return 1;
}
#endif
#ifdef NSIS_SUPPORT_STROPTS
else if (w->which == EW_STRCMP)
{
@ -2309,7 +2302,7 @@ again:
ret=add_entry_direct(EW_CREATEDIR, zero_offset);
if (ret != PS_OK) return ret;
// IfErrors Initialize_____Plugins_error - detect errors
ret=add_entry_direct(EW_IFERRORS, ns_label.add("Initialize_____Plugins_error",0));
ret=add_entry_direct(EW_IFFLAG, ns_label.add("Initialize_____Plugins_error",0), 0, FIELD_OFFSET(installer_flags, exec_error));
if (ret != PS_OK) return ret;
// Copy $0 to $PLUGINSDIR
ret=add_entry_direct(EW_PLUGINCOMMANDPREP);

View file

@ -79,7 +79,7 @@ int num_sections;
#define WM_TREEVIEW_KEYHACK (WM_USER+0x13)
static int m_page=-1,m_abort,m_retcode,m_delta=1;
static int m_page=-1,m_retcode,m_delta=1;
#define NOTIFY_BYE_BYE 'x'
@ -631,7 +631,7 @@ nextPage:
}
if (id == IDCANCEL)
{
if (m_abort)
if (g_flags.abort)
{
#ifdef NSIS_SUPPORT_CODECALLBACKS
ExecuteCodeSegment(g_inst_cmnheader->code_onInstFailed,NULL);
@ -1332,20 +1332,20 @@ static DWORD WINAPI install_thread(LPVOID p)
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
if (g_is_uninstaller)
{
if (ExecuteCodeSegment(g_inst_uninstheader->code,g_progresswnd)) m_abort++;
if (ExecuteCodeSegment(g_inst_uninstheader->code,g_progresswnd)) g_flags.abort++;
}
else
{
#endif
int m_inst_sec=0;
while (m_inst_sec<num_sections && !m_abort)
while (m_inst_sec<num_sections && !g_flags.abort)
{
#ifdef NSIS_CONFIG_COMPONENTPAGE
if (g_inst_section[m_inst_sec].flags&SF_SELECTED)
#endif
{
log_printf2("Section: \"%s\"",GetStringFromStringTab(g_inst_section[m_inst_sec].name_ptr));
if (ExecuteCodeSegment(g_inst_section[m_inst_sec].code,g_progresswnd)) m_abort++;
if (ExecuteCodeSegment(g_inst_section[m_inst_sec].code,g_progresswnd)) g_flags.abort++;
}
#ifdef NSIS_CONFIG_COMPONENTPAGE
else
@ -1358,8 +1358,8 @@ static DWORD WINAPI install_thread(LPVOID p)
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
}
#endif
if (m_curwnd) SendMessage(m_curwnd,WM_NOTIFY_INSTPROC_DONE,m_abort,0);
return m_abort;
if (m_curwnd) SendMessage(m_curwnd,WM_NOTIFY_INSTPROC_DONE,g_flags.abort,0);
return g_flags.abort;
}
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT

View file

@ -24,7 +24,7 @@ typedef struct _stack_t {
static stack_t *g_st;
#endif
union flags g_flags;
union installer_flags g_flags;
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
char plugins_temp_dir[NSIS_MAX_STRLEN]="";
@ -208,6 +208,12 @@ static int NSISCALL ExecuteEntry(entry *entry_)
case EW_SETFLAG:
g_flags.flags[parm0]=parm1;
break;
case EW_IFFLAG:
{
int f=entry_->offsets[!g_flags.flags[parm2]];
g_flags.flags[parm2]&=parm3;
return f;
}
case EW_CHDETAILSVIEW:
if (insthwndbutton) ShowWindow(insthwndbutton,parm1);
if (insthwnd) ShowWindow(insthwnd,parm0);
@ -274,12 +280,6 @@ static int NSISCALL ExecuteEntry(entry *entry_)
log_printf3("IfFileExists: file \"%s\" does not exist, jumping %d",buf0,parm2);
}
return parm2;
case EW_IFERRORS:
{
int f=entry_->offsets[!g_flags.exec_error];
g_flags.exec_error=0;
return f;
}
#ifdef NSIS_SUPPORT_RENAME
case EW_RENAME:
{
@ -1110,7 +1110,6 @@ static int NSISCALL ExecuteEntry(entry *entry_)
FreeLibrary(h);
}
break;
case EW_IFREBOOTFLAG: return entry_->offsets[!g_flags.exec_reboot];
#endif//NSIS_SUPPORT_REBOOT
#ifdef NSIS_SUPPORT_INIFILES
case EW_WRITEINI:

View file

@ -1,17 +1,7 @@
#ifndef _EXEC_H_
#define _EXEC_H_
extern union flags {
struct {
int autoclose;
int all_user_var;
int exec_error;
#ifdef NSIS_SUPPORT_REBOOT
int exec_reboot;
#endif
};
int flags[1];
} g_flags;
extern union installer_flags g_flags;
int NSISCALL ExecuteCodeSegment(int pos, HWND hwndProgress); // returns 0 on success

View file

@ -45,8 +45,8 @@ enum
EW_SETFILEATTRIBUTES, // SetFileAttributes: 2 [filename, attributes]
EW_CREATEDIR, // Create directory: 2, [path, ?update$INSTDIR]
EW_IFFILEEXISTS, // IfFileExists: 3, [file name, jump amount if exists, jump amount if not exists]
EW_IFERRORS, // IfErrors: 2 [jump if error, jump if not error]
EW_SETFLAG, // Sets a flag: 2 [id, data]
EW_IFFLAG, // If a flag: 4 [on, off, id, new value mask]
#ifdef NSIS_SUPPORT_RENAME
EW_RENAME, // Rename: 3 [old, new, rebootok]
#endif
@ -513,5 +513,17 @@ DWORD NSISCALL SetSelfFilePointer(LONG lDistanceToMove, DWORD dwMoveMethod);
#define VAR_CODES_START (256 - 36)
#endif
union installer_flags {
struct {
int autoclose;
int all_user_var;
int exec_error;
int abort;
#ifdef NSIS_SUPPORT_REBOOT
int exec_reboot;
#endif
};
int flags[1];
};
#endif //_FILEFORM_H_

View file

@ -356,6 +356,8 @@ int CEXEBuild::process_jump(LineParser &line, int wt, int *offs)
return 0;
}
#define FLAG_OFFSET(flag) (FIELD_OFFSET(installer_flags, flag)/sizeof(int))
int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char *curfilename, int *lineptr)
{
int linecnt = *lineptr;
@ -2470,7 +2472,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
return add_entry(&ent);
case TOK_SETSHELLVARCONTEXT:
ent.which=EW_SETFLAG;
ent.offsets[0]=1;
ent.offsets[0]=FLAG_OFFSET(all_user_var);
ent.offsets[1]=line.gettoken_enum(1,"current\0all\0");
if (ent.offsets[1]<0) PRINTHELP()
SCRIPT_MSG("SetShellVarContext: %s\n",line.gettoken_str(1));
@ -3248,26 +3250,35 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
return add_entry(&ent);
case TOK_SETAUTOCLOSE:
ent.which=EW_SETFLAG;
ent.offsets[0]=0;
ent.offsets[0]=FLAG_OFFSET(autoclose);
ent.offsets[1]=line.gettoken_enum(1,"false\0true\0");
if (ent.offsets[1] < 0) PRINTHELP()
SCRIPT_MSG("SetAutoClose: %s\n",line.gettoken_str(1));
return add_entry(&ent);
case TOK_IFERRORS:
ent.which=EW_IFERRORS;
ent.which=EW_IFFLAG;
if (process_jump(line,1,&ent.offsets[0]) ||
process_jump(line,2,&ent.offsets[1])) PRINTHELP()
ent.offsets[2]=FLAG_OFFSET(exec_error);
ent.offsets[3]=0;//new value mask - clean error
SCRIPT_MSG("IfErrors ?%s:%s\n",line.gettoken_str(1),line.gettoken_str(2));
case TOK_IFABORT:
ent.which=EW_IFFLAG;
if (process_jump(line,1,&ent.offsets[0]) ||
process_jump(line,2,&ent.offsets[1])) PRINTHELP()
ent.offsets[2]=FLAG_OFFSET(abort);
ent.offsets[3]=(int)~0;//new value mask - keep flag
SCRIPT_MSG("IfAbort ?%s:%s\n",line.gettoken_str(1),line.gettoken_str(2));
return add_entry(&ent);
case TOK_CLEARERRORS:
ent.which=EW_SETFLAG;
ent.offsets[0]=2;
ent.offsets[0]=FLAG_OFFSET(exec_error);
ent.offsets[1]=0;
SCRIPT_MSG("ClearErrors\n");
return add_entry(&ent);
case TOK_SETERRORS:
ent.which=EW_SETFLAG;
ent.offsets[0]=2;
ent.offsets[0]=FLAG_OFFSET(exec_error);
ent.offsets[1]=1;
SCRIPT_MSG("SetErrors\n");
return add_entry(&ent);
@ -3997,14 +4008,16 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
SCRIPT_MSG("Reboot! (WOW)\n");
return add_entry(&ent);
case TOK_IFREBOOTFLAG:
ent.which=EW_IFREBOOTFLAG;
ent.which=EW_IFFLAG;
if (process_jump(line,1,&ent.offsets[0]) ||
process_jump(line,2,&ent.offsets[1])) PRINTHELP()
ent.offsets[2]=FLAG_OFFSET(exec_reboot);
ent.offsets[3]=(int)~0;//new value mask - keep flag
SCRIPT_MSG("IfRebootFlag ?%s:%s\n",line.gettoken_str(1),line.gettoken_str(2));
return add_entry(&ent);
case TOK_SETREBOOTFLAG:
ent.which=EW_SETFLAG;
ent.offsets[0]=3;
ent.offsets[0]=FLAG_OFFSET(exec_reboot);
ent.offsets[1]=line.gettoken_enum(1,"false\0true\0");
if (ent.offsets[1] < 0) PRINTHELP()
return add_entry(&ent);

View file

@ -80,6 +80,7 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_GETWINTEXT,"GetWindowText",2,0,"$(user_var: handle output) hwnd"},
{TOK_HIDEWINDOW,"HideWindow",0,0,""},
{TOK_ICON,"Icon",1,0,"local_icon.ico"},
{TOK_IFABORT,"IfAbort",1,1,"label_to_goto_if_abort [label_to_goto_if_no_abort]"},
{TOK_IFERRORS,"IfErrors",1,1,"label_to_goto_if_errors [label_to_goto_if_no_errors]"},
{TOK_IFFILEEXISTS,"IfFileExists",2,1,"filename label_to_goto_if_file_exists [label_to_goto_otherwise]"},
{TOK_IFREBOOTFLAG,"IfRebootFlag",1,1,"jump_if_set [jump_if_not_set]"},

View file

@ -144,6 +144,7 @@ enum
TOK_IFERRORS,
TOK_CLEARERRORS,
TOK_SETERRORS,
TOK_IFABORT,
TOK_STRCPY,
TOK_STRCMP,
TOK_GETTEMPFILENAME,