2006-10-28 19:45:02 +00:00
/*
* script . cpp
*
* This file is a part of NSIS .
*
2009-02-01 14:44:30 +00:00
* Copyright ( C ) 1999 - 2009 Nullsoft and Contributors
2006-10-28 19:45:02 +00:00
*
* Licensed under the zlib / libpng license ( the " License " ) ;
* you may not use this file except in compliance with the License .
*
* Licence details can be found in the file COPYING .
*
* This software is provided ' as - is ' , without any express or implied
* warranty .
*/
2004-01-30 22:04:10 +00:00
# include "Platform.h"
2002-08-02 10:01:35 +00:00
# include <stdio.h>
2004-03-29 20:21:00 +00:00
# include <ctype.h>
2002-08-02 10:01:35 +00:00
# include "tokens.h"
# include "build.h"
# include "util.h"
2007-02-17 15:11:12 +00:00
# include "winchar.h"
2002-08-02 10:01:35 +00:00
# include "ResourceEditor.h"
# include "DialogTemplate.h"
2002-08-03 23:06:10 +00:00
# include "lang.h"
2004-11-26 15:44:02 +00:00
# include "dirreader.h"
2009-02-04 14:05:48 +00:00
# include <nsis-version.h>
2007-10-03 13:31:56 +00:00
# include "icon.h"
2008-12-09 23:13:51 +00:00
# include "exehead/api.h"
2002-11-11 19:19:02 +00:00
# include "exehead/resource.h"
2004-10-11 21:24:33 +00:00
# include <cassert> // for assert(3)
2004-11-26 18:49:50 +00:00
# include <time.h>
2010-03-24 17:22:56 +00:00
# include "tstring.h"
2005-04-02 12:04:07 +00:00
# include <algorithm>
2005-10-22 13:40:52 +00:00
# include "boost/scoped_ptr.hpp"
2002-08-02 10:01:35 +00:00
2004-11-26 15:44:02 +00:00
using namespace std ;
2004-10-25 23:34:07 +00:00
# ifdef _WIN32
2005-07-01 21:08:48 +00:00
# include <direct.h> // for chdir
2004-10-25 23:34:07 +00:00
# else
2005-10-07 13:08:44 +00:00
# include <sys / stat.h> // for stat and umask
# include <sys / types.h> // for mode_t
2004-10-11 21:24:33 +00:00
# include <fcntl.h> // for O_RDONLY
2004-10-25 23:34:07 +00:00
# include <unistd.h>
2005-10-07 13:08:44 +00:00
# include <stdlib.h> // for mkstemp
2004-03-29 20:21:00 +00:00
# endif
2002-08-02 10:01:35 +00:00
# define MAX_INCLUDEDEPTH 10
2004-05-07 11:16:03 +00:00
# define MAX_LINELENGTH 16384
2002-08-02 10:01:35 +00:00
2003-06-12 15:09:27 +00:00
# ifdef NSIS_SUPPORT_STANDARD_PREDEFINES
// Added by Sunil Kamath 11 June 2003
2010-03-24 17:22:56 +00:00
TCHAR * CEXEBuild : : set_file_predefine ( const TCHAR * filename )
2003-06-12 15:09:27 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR * oldfilename = definedlist . find ( _T ( " __FILE__ " ) ) ;
2003-06-12 22:44:45 +00:00
if ( oldfilename )
{
2010-03-29 14:24:47 +00:00
oldfilename = _tcsdup ( oldfilename ) ;
2010-03-24 17:22:56 +00:00
definedlist . del ( _T ( " __FILE__ " ) ) ;
2003-06-12 22:44:45 +00:00
}
2010-03-24 17:22:56 +00:00
const TCHAR * p = _tcsrchr ( filename , _T ( ' \\ ' ) ) ;
2003-06-12 15:09:27 +00:00
if ( p ) {
p + + ;
}
else {
p = curfilename ;
}
2010-03-24 17:22:56 +00:00
definedlist . add ( _T ( " __FILE__ " ) , p ) ;
2003-06-12 15:09:27 +00:00
return oldfilename ;
}
2010-03-24 17:22:56 +00:00
void CEXEBuild : : restore_file_predefine ( TCHAR * oldfilename )
2003-06-12 15:09:27 +00:00
{
2010-03-24 17:22:56 +00:00
definedlist . del ( _T ( " __FILE__ " ) ) ;
2003-06-13 03:48:29 +00:00
if ( oldfilename ) {
2010-03-24 17:22:56 +00:00
definedlist . add ( _T ( " __FILE__ " ) , oldfilename ) ;
2003-06-13 03:48:29 +00:00
free ( oldfilename ) ;
}
2003-06-12 15:09:27 +00:00
}
2010-03-24 17:22:56 +00:00
TCHAR * CEXEBuild : : set_timestamp_predefine ( const TCHAR * filename )
2003-06-12 15:09:27 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR * oldtimestamp = definedlist . find ( _T ( " __TIMESTAMP__ " ) ) ;
2003-06-12 22:44:45 +00:00
if ( oldtimestamp ) {
2010-03-29 14:24:47 +00:00
oldtimestamp = _tcsdup ( oldtimestamp ) ;
2010-03-24 17:22:56 +00:00
definedlist . del ( _T ( " __TIMESTAMP__ " ) ) ;
2003-06-12 22:44:45 +00:00
}
2004-03-29 20:21:00 +00:00
# ifdef _WIN32
2010-03-24 17:22:56 +00:00
TCHAR timestampbuf [ 256 ] = _T ( " " ) ;
TCHAR datebuf [ 128 ] = _T ( " " ) ;
TCHAR timebuf [ 128 ] = _T ( " " ) ;
2003-06-12 22:44:45 +00:00
WIN32_FIND_DATA fd ;
2003-06-23 15:12:49 +00:00
FILETIME floctime ;
SYSTEMTIME stime ;
2003-06-12 22:44:45 +00:00
HANDLE hSearch = FindFirstFile ( filename , & fd ) ;
if ( hSearch ! = INVALID_HANDLE_VALUE )
{
FindClose ( hSearch ) ;
2003-06-23 15:12:49 +00:00
FileTimeToLocalFileTime ( & fd . ftLastWriteTime , & floctime ) ;
FileTimeToSystemTime ( & floctime , & stime ) ;
2003-06-12 22:44:45 +00:00
2010-03-30 17:50:08 +00:00
GetDateFormat ( LOCALE_USER_DEFAULT , DATE_LONGDATE , & stime , NULL , datebuf , COUNTOF ( datebuf ) ) ;
GetTimeFormat ( LOCALE_USER_DEFAULT , 0 , & stime , NULL , timebuf , COUNTOF ( timebuf ) ) ;
2010-03-24 17:22:56 +00:00
wsprintf ( timestampbuf , _T ( " %s %s " ) , datebuf , timebuf ) ;
2003-06-12 22:44:45 +00:00
2010-03-24 17:22:56 +00:00
definedlist . add ( _T ( " __TIMESTAMP__ " ) , timestampbuf ) ;
2003-06-12 22:44:45 +00:00
}
2004-03-29 20:21:00 +00:00
# else
struct stat st ;
if ( ! stat ( filename , & st ) )
2010-03-24 17:22:56 +00:00
definedlist . add ( _T ( " __TIMESTAMP__ " ) , _tctime ( & st . st_mtime ) ) ;
2004-03-29 20:21:00 +00:00
# endif
2003-06-12 15:09:27 +00:00
return oldtimestamp ;
}
2010-03-24 17:22:56 +00:00
void CEXEBuild : : restore_timestamp_predefine ( TCHAR * oldtimestamp )
2003-06-12 15:09:27 +00:00
{
2010-03-24 17:22:56 +00:00
definedlist . del ( _T ( " __TIMESTAMP__ " ) ) ;
2003-06-13 03:48:29 +00:00
if ( oldtimestamp ) {
2010-03-24 17:22:56 +00:00
definedlist . add ( _T ( " __TIMESTAMP__ " ) , oldtimestamp ) ;
2003-06-13 03:48:29 +00:00
free ( oldtimestamp ) ;
}
2003-06-12 15:09:27 +00:00
}
2010-03-24 17:22:56 +00:00
TCHAR * CEXEBuild : : set_line_predefine ( int linecnt , BOOL is_macro )
2003-06-12 15:09:27 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR * linebuf = NULL ;
2004-10-15 03:59:46 +00:00
MANAGE_WITH ( linebuf , free ) ;
2004-10-11 21:24:33 +00:00
2010-03-24 17:22:56 +00:00
TCHAR temp [ 128 ] = _T ( " " ) ;
_stprintf ( temp , _T ( " %d " ) , linecnt ) ;
2003-06-12 15:09:27 +00:00
2010-03-24 17:22:56 +00:00
TCHAR * oldline = definedlist . find ( _T ( " __LINE__ " ) ) ;
2003-06-12 22:44:45 +00:00
if ( oldline ) {
2010-03-29 14:24:47 +00:00
oldline = _tcsdup ( oldline ) ;
2010-03-24 17:22:56 +00:00
definedlist . del ( _T ( " __LINE__ " ) ) ;
2003-06-12 22:44:45 +00:00
}
2003-06-13 15:59:30 +00:00
if ( is_macro & & oldline ) {
2010-03-24 17:22:56 +00:00
linebuf = ( TCHAR * ) malloc ( ( _tcsclen ( oldline ) + _tcsclen ( temp ) + 2 ) * sizeof ( TCHAR ) ) ;
_stprintf ( linebuf , _T ( " %s.%s " ) , oldline , temp ) ;
2003-06-13 15:59:30 +00:00
}
else {
2010-03-29 14:24:47 +00:00
linebuf = _tcsdup ( temp ) ;
2003-06-13 15:59:30 +00:00
}
2010-03-24 17:22:56 +00:00
definedlist . add ( _T ( " __LINE__ " ) , linebuf ) ;
2003-06-12 15:09:27 +00:00
return oldline ;
}
2010-03-24 17:22:56 +00:00
void CEXEBuild : : restore_line_predefine ( TCHAR * oldline )
2003-06-12 15:09:27 +00:00
{
2010-03-24 17:22:56 +00:00
definedlist . del ( _T ( " __LINE__ " ) ) ;
2003-06-13 03:48:29 +00:00
if ( oldline ) {
2010-03-24 17:22:56 +00:00
definedlist . add ( _T ( " __LINE__ " ) , oldline ) ;
2003-06-13 03:48:29 +00:00
free ( oldline ) ;
}
2003-06-12 15:09:27 +00:00
}
2003-07-18 02:43:03 +00:00
void CEXEBuild : : set_date_time_predefines ( )
{
time_t etime ;
struct tm * ltime ;
2010-03-24 17:22:56 +00:00
TCHAR datebuf [ 128 ] ;
TCHAR timebuf [ 128 ] ;
2003-07-18 02:43:03 +00:00
time ( & etime ) ;
ltime = localtime ( & etime ) ;
2004-03-29 20:21:00 +00:00
# ifdef _WIN32
SYSTEMTIME stime ;
2003-07-18 02:43:03 +00:00
stime . wYear = ltime - > tm_year + 1900 ;
stime . wMonth = ltime - > tm_mon + 1 ;
stime . wDay = ltime - > tm_mday ;
2004-03-29 20:21:00 +00:00
stime . wHour = ltime - > tm_hour ;
stime . wMinute = ltime - > tm_min ;
stime . wSecond = ltime - > tm_sec ;
stime . wMilliseconds = 0 ;
GetDateFormat ( LOCALE_USER_DEFAULT , DATE_SHORTDATE , & stime , NULL , datebuf , sizeof ( datebuf ) ) ;
2010-03-24 17:22:56 +00:00
definedlist . add ( _T ( " __DATE__ " ) , ( TCHAR * ) datebuf ) ;
2004-03-29 20:21:00 +00:00
GetTimeFormat ( LOCALE_USER_DEFAULT , 0 , & stime , NULL , timebuf , sizeof ( timebuf ) ) ;
2010-03-24 17:22:56 +00:00
definedlist . add ( _T ( " __TIME__ " ) , ( TCHAR * ) timebuf ) ;
2004-03-29 20:21:00 +00:00
# else
2010-03-24 17:22:56 +00:00
my_strftime ( datebuf , sizeof ( datebuf ) , _T ( " %x " ) , ltime ) ;
definedlist . add ( _T ( " __DATE__ " ) , ( TCHAR * ) datebuf ) ;
my_strftime ( timebuf , sizeof ( timebuf ) , _T ( " %X " ) , ltime ) ;
definedlist . add ( _T ( " __TIME__ " ) , ( TCHAR * ) timebuf ) ;
2004-03-29 20:21:00 +00:00
# endif
2003-07-18 02:43:03 +00:00
}
void CEXEBuild : : del_date_time_predefines ( )
{
2010-03-24 17:22:56 +00:00
definedlist . del ( _T ( " __DATE__ " ) ) ;
definedlist . del ( _T ( " __TIME__ " ) ) ;
2003-07-18 02:43:03 +00:00
}
2003-06-12 15:09:27 +00:00
# endif
2002-08-02 10:01:35 +00:00
2010-03-24 17:22:56 +00:00
int CEXEBuild : : process_script ( FILE * filepointer , const TCHAR * filename )
2002-08-02 10:01:35 +00:00
{
2003-06-05 21:53:52 +00:00
linecnt = 0 ;
fp = filepointer ;
curfilename = filename ;
2002-08-02 10:01:35 +00:00
if ( has_called_write_output )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error (process_script): write_output already called, can't continue \n " ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
2003-06-12 15:09:27 +00:00
# ifdef NSIS_SUPPORT_STANDARD_PREDEFINES
// Added by Sunil Kamath 11 June 2003
2003-07-18 02:43:03 +00:00
set_date_time_predefines ( ) ;
2010-03-24 17:22:56 +00:00
TCHAR * oldfilename = set_file_predefine ( curfilename ) ;
TCHAR * oldtimestamp = set_timestamp_predefine ( curfilename ) ;
2003-06-12 15:09:27 +00:00
# endif
2003-06-05 21:53:52 +00:00
int ret = parseScript ( ) ;
2003-06-05 21:55:40 +00:00
2003-06-12 15:09:27 +00:00
# ifdef NSIS_SUPPORT_STANDARD_PREDEFINES
// Added by Sunil Kamath 11 June 2003
restore_file_predefine ( oldfilename ) ;
restore_timestamp_predefine ( oldtimestamp ) ;
2003-07-18 02:43:03 +00:00
del_date_time_predefines ( ) ;
2003-06-12 15:09:27 +00:00
# endif
2003-06-05 21:55:40 +00:00
fp = 0 ;
curfilename = 0 ;
2002-08-02 10:01:35 +00:00
if ( m_linebuild . getlen ( ) )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: invalid script: last line ended with \\ \n " ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
2003-09-04 18:25:57 +00:00
2003-09-05 14:14:29 +00:00
if ( ret = = PS_EOF & & num_ifblock ( ) )
2003-09-04 18:25:57 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !if[macro][n]def: open at EOF - need !endif \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
2002-08-02 10:01:35 +00:00
return ret ;
}
2003-09-04 18:25:57 +00:00
# define PRINTHELP() { print_help(line.gettoken_str(0)); return PS_ERROR; }
2002-08-02 10:01:35 +00:00
2003-09-04 18:25:57 +00:00
void CEXEBuild : : start_ifblock ( )
{
ifblock ib = { 0 , } ;
if ( cur_ifblock )
ib . inherited_ignore = cur_ifblock - > ignore | | cur_ifblock - > inherited_ignore ;
int num = build_preprocessor_data . getlen ( ) / sizeof ( ifblock ) ;
build_preprocessor_data . add ( & ib , sizeof ( ifblock ) ) ;
cur_ifblock = ( ifblock * ) build_preprocessor_data . get ( ) + num ;
}
2002-08-02 10:01:35 +00:00
2003-09-04 18:25:57 +00:00
void CEXEBuild : : end_ifblock ( )
{
if ( build_preprocessor_data . getlen ( ) )
{
cur_ifblock - - ;
build_preprocessor_data . resize ( build_preprocessor_data . getlen ( ) - sizeof ( ifblock ) ) ;
if ( ! build_preprocessor_data . getlen ( ) )
cur_ifblock = 0 ;
}
}
int CEXEBuild : : num_ifblock ( )
2002-08-02 10:01:35 +00:00
{
2003-09-04 18:25:57 +00:00
return build_preprocessor_data . getlen ( ) / sizeof ( ifblock ) ;
}
2002-10-17 19:58:23 +00:00
2004-10-11 21:24:33 +00:00
// Func size: just under 200 lines (orip)
2010-03-24 17:22:56 +00:00
int CEXEBuild : : doParse ( const TCHAR * str )
2003-09-04 18:25:57 +00:00
{
2003-06-09 18:59:14 +00:00
LineParser line ( inside_comment ) ;
2002-08-02 10:01:35 +00:00
int res ;
2010-03-24 17:22:56 +00:00
while ( * str = = _T ( ' ' ) | | * str = = _T ( ' \t ' ) ) str + + ;
2002-08-02 10:01:35 +00:00
2006-12-09 13:08:05 +00:00
// remove trailing slash and null, if there's a previous line
if ( m_linebuild . getlen ( ) > 1 )
2010-03-24 17:22:56 +00:00
m_linebuild . resize ( m_linebuild . getlen ( ) - ( 2 * sizeof ( TCHAR ) ) ) ;
2002-08-02 10:01:35 +00:00
2007-11-18 19:19:55 +00:00
// warn of comment with line-continuation
if ( m_linebuild . getlen ( ) )
{
LineParser prevline ( inside_comment ) ;
2010-03-24 17:22:56 +00:00
prevline . parse ( ( TCHAR * ) m_linebuild . get ( ) ) ;
2007-11-18 19:19:55 +00:00
LineParser thisline ( inside_comment ) ;
2010-03-24 17:22:56 +00:00
thisline . parse ( ( TCHAR * ) str ) ;
2007-11-18 19:19:55 +00:00
if ( prevline . inComment ( ) & & ! thisline . inComment ( ) )
{
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " comment contains line-continuation character, following line will be ignored " ) ) ;
2007-11-18 19:19:55 +00:00
}
}
// add new line to line buffer
2010-03-24 17:22:56 +00:00
m_linebuild . add ( str , ( _tcsclen ( str ) + 1 ) * sizeof ( TCHAR ) ) ;
2002-08-02 10:01:35 +00:00
2006-12-09 13:08:05 +00:00
// keep waiting for more lines, if this line ends with a backslash
2010-03-24 17:22:56 +00:00
if ( str [ 0 ] & & CharPrev ( str , str + _tcsclen ( str ) ) [ 0 ] = = _T ( ' \\ ' ) )
2007-01-24 13:24:28 +00:00
{
2003-02-26 15:28:55 +00:00
return PS_OK ;
2007-01-24 13:24:28 +00:00
}
2002-08-02 10:01:35 +00:00
2006-12-09 13:08:05 +00:00
// parse before checking if the line should be ignored, so block comments won't be missed
2007-08-09 00:19:37 +00:00
// escaped quotes should be ignored for compile time commands that set defines
// because defines can be inserted in commands at a later stage
2010-03-29 14:24:47 +00:00
bool ignore_escaping = ( ! _tcsncicmp ( ( TCHAR * ) m_linebuild . get ( ) , _T ( " !define " ) , 7 ) | | ! _tcsncicmp ( ( TCHAR * ) m_linebuild . get ( ) , _T ( " !insertmacro " ) , 12 ) ) ;
2010-03-24 17:22:56 +00:00
res = line . parse ( ( TCHAR * ) m_linebuild . get ( ) , ignore_escaping ) ;
2002-08-02 10:01:35 +00:00
2007-01-24 13:25:44 +00:00
inside_comment = line . inCommentBlock ( ) ;
2003-06-09 18:59:14 +00:00
2005-11-25 11:54:11 +00:00
// if ignoring, ignore all lines that don't begin with an exclamation mark
{
bool ignore_line = cur_ifblock & & ( cur_ifblock - > ignore | | cur_ifblock - > inherited_ignore ) ;
2010-03-24 17:22:56 +00:00
TCHAR first_char = * ( TCHAR * ) m_linebuild . get ( ) ;
if ( ignore_line & & ( first_char ! = _T ( ' ! ' ) | | ! is_valid_token ( line . gettoken_str ( 0 ) ) ) )
2006-12-09 13:08:05 +00:00
{
m_linebuild . resize ( 0 ) ;
2005-11-25 11:54:11 +00:00
return PS_OK ;
2006-12-09 13:08:05 +00:00
}
2005-11-25 11:54:11 +00:00
}
2006-12-09 13:08:05 +00:00
m_linebuild . resize ( 0 ) ;
2002-08-02 10:01:35 +00:00
if ( res )
{
2010-03-24 17:22:56 +00:00
if ( res = = - 2 ) ERROR_MSG ( _T ( " Error: unterminated string parsing line at %s:%d \n " ) , curfilename , linecnt ) ;
else ERROR_MSG ( _T ( " Error: error parsing line (%s:%d) \ n " ),curfilename,linecnt) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
parse_again :
if ( line . getnumtokens ( ) < 1 ) return PS_OK ;
2003-12-24 15:54:06 +00:00
int np , op , pos ;
int tkid = get_commandtoken ( line . gettoken_str ( 0 ) , & np , & op , & pos ) ;
2002-08-02 10:01:35 +00:00
if ( tkid = = - 1 )
{
2010-03-24 17:22:56 +00:00
TCHAR * p = line . gettoken_str ( 0 ) ;
if ( p [ 0 ] & & p [ _tcsclen ( p ) - 1 ] = = _T ( ' : ' ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
if ( p [ 0 ] = = _T ( ' ! ' ) | | ( p [ 0 ] > = _T ( ' 0 ' ) & & p [ 0 ] < = _T ( ' 9 ' ) ) | | p [ 0 ] = = _T ( ' $ ' ) | | p [ 0 ] = = _T ( ' - ' ) | | p [ 0 ] = = _T ( ' + ' ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Invalid label: %s (labels cannot begin with !, $, -, +, or 0-9) \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
if ( add_label ( line . gettoken_str ( 0 ) ) ) return PS_ERROR ;
line . eattoken ( ) ;
goto parse_again ;
}
2002-08-05 02:05:00 +00:00
# ifdef NSIS_CONFIG_PLUGIN_SUPPORT
// Added by Ximon Eighteen 5th August 2002
// We didn't recognise this command, could it be the name of a
// function exported from a dll?
2002-08-05 19:13:52 +00:00
if ( m_plugins . IsPluginCommand ( line . gettoken_str ( 0 ) ) )
2002-08-05 02:05:00 +00:00
{
np = 0 ; // parameters are optional
op = - 1 ; // unlimited number of optional parameters
2003-12-24 15:54:06 +00:00
pos = - 1 ; // placement will tested later
2002-08-05 19:13:52 +00:00
tkid = TOK__PLUGINCOMMAND ;
2002-08-05 02:05:00 +00:00
}
else
# endif
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Invalid command: %s \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-05 02:05:00 +00:00
return PS_ERROR ;
}
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
if ( IsTokenPlacedRight ( pos , line . gettoken_str ( 0 ) ) ! = PS_OK )
return PS_ERROR ;
2002-08-02 10:01:35 +00:00
int v = line . getnumtokens ( ) - ( np + 1 ) ;
if ( v < 0 | | ( op > = 0 & & v > op ) ) // opt_parms is -1 for unlimited
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " %s expects %d " ) , line . gettoken_str ( 0 ) , np ) ;
if ( op < 0 ) ERROR_MSG ( _T ( " + " ) ) ;
if ( op > 0 ) ERROR_MSG ( _T ( " -%d " ) , op + np ) ;
ERROR_MSG ( _T ( " parameters, got %d. \n " ) , line . getnumtokens ( ) - 1 ) ;
2002-08-02 10:01:35 +00:00
PRINTHELP ( )
}
2003-09-04 18:25:57 +00:00
int if_from_else = 0 ;
2002-08-11 18:57:16 +00:00
if ( tkid = = TOK_P_ELSE )
2002-08-02 10:01:35 +00:00
{
2003-09-04 18:25:57 +00:00
if ( cur_ifblock & & cur_ifblock - > inherited_ignore )
2002-12-01 13:19:23 +00:00
return PS_OK ;
2003-09-04 18:25:57 +00:00
2006-02-24 15:06:30 +00:00
if ( ! num_ifblock ( ) )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !else: no if block open (!if[macro][n][def]) \n " ) ) ;
2006-02-24 15:06:30 +00:00
return PS_ERROR ;
}
if ( cur_ifblock - > elseused )
2003-09-04 18:25:57 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !else: else already used in current if block \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
2003-02-26 15:28:55 +00:00
}
2002-12-01 13:19:23 +00:00
2003-09-06 19:48:00 +00:00
if ( cur_ifblock - > hasexeced )
{
cur_ifblock - > ignore + + ;
return PS_OK ;
}
2003-09-04 18:25:57 +00:00
if ( line . getnumtokens ( ) = = 1 )
{
cur_ifblock - > ignore = ! cur_ifblock - > ignore ;
// if not executed up until now, it will now
cur_ifblock - > hasexeced + + ;
cur_ifblock - > elseused + + ;
return PS_OK ;
}
2002-08-02 10:01:35 +00:00
line . eattoken ( ) ;
2010-03-24 17:22:56 +00:00
int v = line . gettoken_enum ( 0 , _T ( " if \0 ifdef \0 ifndef \0 ifmacrodef \0 ifmacrondef \0 " ) ) ;
2002-08-02 10:01:35 +00:00
if ( v < 0 ) PRINTHELP ( )
if ( line . getnumtokens ( ) = = 1 ) PRINTHELP ( )
2006-02-24 15:06:30 +00:00
int cmds [ ] = { TOK_P_IF , TOK_P_IFDEF , TOK_P_IFNDEF , TOK_P_IFMACRODEF , TOK_P_IFMACRONDEF } ;
2003-11-30 16:44:06 +00:00
tkid = cmds [ v ] ;
2003-09-04 18:25:57 +00:00
if_from_else + + ;
2002-08-02 10:01:35 +00:00
}
2003-11-30 16:31:43 +00:00
if ( tkid = = TOK_P_IFNDEF | | tkid = = TOK_P_IFDEF | |
2006-02-24 15:06:30 +00:00
tkid = = TOK_P_IFMACRODEF | | tkid = = TOK_P_IFMACRONDEF | |
tkid = = TOK_P_IF )
2002-08-02 10:01:35 +00:00
{
2003-09-04 18:25:57 +00:00
if ( ! if_from_else )
start_ifblock ( ) ;
if ( cur_ifblock & & cur_ifblock - > inherited_ignore )
{
2002-10-17 19:58:23 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
}
2002-10-17 19:58:23 +00:00
int istrue = 0 ;
2004-12-10 11:09:10 +00:00
2002-10-17 19:58:23 +00:00
int mod = 0 ;
2006-02-24 15:52:40 +00:00
2006-02-24 15:06:30 +00:00
int p = 0 ;
if ( tkid = = TOK_P_IF ) {
2010-03-24 17:22:56 +00:00
if ( ! _tcscmp ( line . gettoken_str ( 1 ) , _T ( " ! " ) ) ) {
2006-02-24 15:06:30 +00:00
p = 1 ;
line . eattoken ( ) ;
}
if ( line . getnumtokens ( ) = = 2 )
istrue = line . gettoken_int ( 1 ) ;
else if ( line . getnumtokens ( ) = = 4 ) {
2010-03-24 17:22:56 +00:00
mod = line . gettoken_enum ( 2 , _T ( " = \0 == \0 != \0 <= \0 < \0 > \0 >= \0 & \0 && \0 | \0 || \0 " ) ) ;
2006-02-24 15:06:30 +00:00
switch ( mod ) {
case 0 :
case 1 :
2010-03-29 14:24:47 +00:00
istrue = _tcsicmp ( line . gettoken_str ( 1 ) , line . gettoken_str ( 3 ) ) = = 0 ; break ;
2006-02-24 15:06:30 +00:00
case 2 :
2010-03-29 14:24:47 +00:00
istrue = _tcsicmp ( line . gettoken_str ( 1 ) , line . gettoken_str ( 3 ) ) ! = 0 ; break ;
2006-02-24 15:06:30 +00:00
case 3 :
istrue = line . gettoken_float ( 1 ) < = line . gettoken_float ( 3 ) ; break ;
case 4 :
istrue = line . gettoken_float ( 1 ) < line . gettoken_float ( 3 ) ; break ;
case 5 :
istrue = line . gettoken_float ( 1 ) > line . gettoken_float ( 3 ) ; break ;
case 6 :
istrue = line . gettoken_float ( 1 ) > = line . gettoken_float ( 3 ) ; break ;
case 7 :
case 8 :
istrue = line . gettoken_int ( 1 ) & & line . gettoken_int ( 3 ) ; break ;
case 9 :
case 10 :
istrue = line . gettoken_int ( 1 ) | | line . gettoken_int ( 3 ) ; break ;
default :
PRINTHELP ( )
}
}
else PRINTHELP ( )
if ( p ) istrue = ! istrue ;
}
2002-08-02 10:01:35 +00:00
2006-02-24 15:06:30 +00:00
else {
// pure left to right precedence. Not too powerful, but useful.
for ( p = 1 ; p < line . getnumtokens ( ) ; p + + )
2002-10-17 19:58:23 +00:00
{
2006-02-24 15:06:30 +00:00
if ( p & 1 )
{
int new_s ;
if ( tkid = = TOK_P_IFNDEF | | tkid = = TOK_P_IFDEF )
new_s = ! ! definedlist . find ( line . gettoken_str ( p ) ) ;
else
new_s = MacroExists ( line . gettoken_str ( p ) ) ;
if ( tkid = = TOK_P_IFNDEF | | tkid = = TOK_P_IFMACRONDEF )
new_s = ! new_s ;
if ( mod = = 0 ) istrue = istrue | | new_s ;
else istrue = istrue & & new_s ;
}
2003-11-30 16:31:43 +00:00
else
2006-02-24 15:06:30 +00:00
{
2010-03-24 17:22:56 +00:00
mod = line . gettoken_enum ( p , _T ( " | \0 & \0 || \0 && \0 " ) ) ;
2006-02-24 15:06:30 +00:00
if ( mod = = - 1 ) PRINTHELP ( )
mod & = 1 ;
}
2002-08-02 10:01:35 +00:00
}
}
2003-09-04 18:25:57 +00:00
if ( istrue )
{
cur_ifblock - > hasexeced + + ;
cur_ifblock - > ignore = 0 ;
}
else
cur_ifblock - > ignore + + ;
2002-10-17 19:58:23 +00:00
return PS_OK ;
}
if ( tkid = = TOK_P_ENDIF ) {
2003-09-04 18:25:57 +00:00
if ( ! num_ifblock ( ) )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !endif: no if block open (!if[macro][n][def]) \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
2002-08-02 10:01:35 +00:00
}
2003-09-04 18:25:57 +00:00
end_ifblock ( ) ;
2002-08-02 10:01:35 +00:00
return PS_OK ;
}
2003-09-04 18:25:57 +00:00
if ( ! cur_ifblock | | ( ! cur_ifblock - > ignore & & ! cur_ifblock - > inherited_ignore ) )
2002-08-02 10:01:35 +00:00
{
2003-06-05 21:53:52 +00:00
return doCommand ( tkid , line ) ;
2002-08-02 10:01:35 +00:00
}
2003-09-04 18:25:57 +00:00
2002-08-02 10:01:35 +00:00
return PS_OK ;
}
2004-10-11 21:24:33 +00:00
// Func size: about 140 lines (orip)
2003-06-16 19:58:29 +00:00
# ifdef NSIS_FIX_DEFINES_IN_STRINGS
2010-03-24 17:22:56 +00:00
void CEXEBuild : : ps_addtoline ( const TCHAR * str , GrowBuf & linedata , StringList & hist , bool bIgnoreDefines /*= false*/ )
2003-06-16 19:58:29 +00:00
# else
2010-03-24 17:22:56 +00:00
void CEXEBuild : : ps_addtoline ( const TCHAR * str , GrowBuf & linedata , StringList & hist )
2003-06-16 19:58:29 +00:00
# endif
2002-08-02 10:01:35 +00:00
{
2003-11-25 06:25:31 +00:00
// convert $\r, $\n to their literals
// preprocessor replace ${VAR} and $%VAR% with whatever value
// note that if VAR does not exist, ${VAR} or $%VAR% will go through unmodified
2010-03-24 17:22:56 +00:00
const TCHAR * in = str ;
2002-08-02 10:01:35 +00:00
while ( * in )
{
int add = 1 ;
2010-03-24 17:22:56 +00:00
TCHAR * t ;
TCHAR c = * in ;
2002-08-02 10:01:35 +00:00
t = CharNext ( in ) ;
if ( t - in > 1 ) // handle multibyte chars (no escape)
{
2010-03-24 17:22:56 +00:00
linedata . add ( ( void * ) in , ( t - in ) * sizeof ( TCHAR ) ) ;
2002-08-02 10:01:35 +00:00
in = t ;
continue ;
}
in = t ;
2002-08-11 18:57:16 +00:00
2010-03-24 17:22:56 +00:00
if ( c = = _T ( ' $ ' ) )
2002-08-11 18:57:16 +00:00
{
2010-03-24 17:22:56 +00:00
if ( in [ 0 ] = = _T ( ' \\ ' ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
if ( in [ 1 ] = = _T ( ' r ' ) )
2002-08-02 10:01:35 +00:00
{
in + = 2 ;
2010-03-24 17:22:56 +00:00
c = _T ( ' \r ' ) ;
2002-08-02 10:01:35 +00:00
}
2010-03-24 17:22:56 +00:00
else if ( in [ 1 ] = = _T ( ' n ' ) )
2002-08-02 10:01:35 +00:00
{
in + = 2 ;
2010-03-24 17:22:56 +00:00
c = _T ( ' \n ' ) ;
2002-08-02 10:01:35 +00:00
}
2010-03-24 17:22:56 +00:00
else if ( in [ 1 ] = = _T ( ' t ' ) )
2003-04-21 13:32:34 +00:00
{
in + = 2 ;
2010-03-24 17:22:56 +00:00
c = _T ( ' \t ' ) ;
2003-04-21 13:32:34 +00:00
}
2002-08-02 10:01:35 +00:00
}
2010-03-24 17:22:56 +00:00
else if ( in [ 0 ] = = _T ( ' { ' ) )
2002-08-02 10:01:35 +00:00
{
2010-03-29 14:24:47 +00:00
TCHAR * s = _tcsdup ( in + 1 ) ;
2004-10-15 03:59:46 +00:00
MANAGE_WITH ( s , free ) ;
2010-03-24 17:22:56 +00:00
TCHAR * t = s ;
2002-12-02 17:48:22 +00:00
unsigned int bn = 0 ;
2002-08-02 10:01:35 +00:00
while ( * t )
{
2010-03-24 17:22:56 +00:00
if ( * t = = _T ( ' { ' ) ) bn + + ;
if ( * t = = _T ( ' } ' ) & & bn - - = = 0 ) break ;
2002-08-02 10:01:35 +00:00
t = CharNext ( t ) ;
}
2004-12-10 11:09:10 +00:00
if ( * t & & t ! = s
2003-06-16 19:58:29 +00:00
# ifdef NSIS_FIX_DEFINES_IN_STRINGS
2004-12-10 11:09:10 +00:00
& & ! bIgnoreDefines
2003-06-16 19:58:29 +00:00
# endif
)
2002-08-02 10:01:35 +00:00
{
* t = 0 ;
2002-12-02 17:48:22 +00:00
// check for defines inside the define name - ${bla${blo}}
GrowBuf defname ;
ps_addtoline ( s , defname , hist ) ;
2010-03-24 17:22:56 +00:00
defname . add ( _T ( " " ) , sizeof ( _T ( " " ) ) ) ;
t = definedlist . find ( ( TCHAR * ) defname . get ( ) ) ;
if ( t & & hist . find ( ( TCHAR * ) defname . get ( ) , 0 ) < 0 )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
in + = _tcsclen ( s ) + 2 ;
2002-08-02 10:01:35 +00:00
add = 0 ;
2010-03-24 17:22:56 +00:00
hist . add ( ( TCHAR * ) defname . get ( ) , 0 ) ;
2003-06-16 19:58:29 +00:00
# ifdef NSIS_FIX_DEFINES_IN_STRINGS
2003-11-25 06:25:31 +00:00
ps_addtoline ( t , linedata , hist , true ) ;
# else
ps_addtoline ( t , linedata , hist ) ;
# endif
2010-03-24 17:22:56 +00:00
hist . delbypos ( hist . find ( ( TCHAR * ) defname . get ( ) , 0 ) ) ;
2003-11-25 06:25:31 +00:00
}
}
}
2010-03-24 17:22:56 +00:00
else if ( in [ 0 ] = = _T ( ' % ' ) )
2003-11-25 06:25:31 +00:00
{
2010-03-29 14:24:47 +00:00
TCHAR * s = _tcsdup ( in + 1 ) ;
2004-10-15 03:59:46 +00:00
MANAGE_WITH ( s , free ) ;
2010-03-24 17:22:56 +00:00
TCHAR * t = s ;
2003-11-25 06:25:31 +00:00
while ( * t )
{
2010-03-24 17:22:56 +00:00
if ( * t = = _T ( ' % ' ) ) break ;
2003-11-25 06:25:31 +00:00
t = CharNext ( t ) ;
}
if ( * t & & t ! = s )
{
* t = 0 ;
// check for defines inside the define name - ${bla${blo}}
GrowBuf defname ;
ps_addtoline ( s , defname , hist ) ;
2010-03-24 17:22:56 +00:00
defname . add ( _T ( " " ) , sizeof ( _T ( " " ) ) ) ;
t = _tgetenv ( ( TCHAR * ) defname . get ( ) ) ;
if ( t & & hist . find ( ( TCHAR * ) defname . get ( ) , 0 ) < 0 )
2003-11-25 06:25:31 +00:00
{
2010-03-24 17:22:56 +00:00
in + = _tcsclen ( s ) + 2 ;
2003-11-25 06:25:31 +00:00
add = 0 ;
2010-03-24 17:22:56 +00:00
hist . add ( ( TCHAR * ) defname . get ( ) , 0 ) ;
2003-11-25 06:25:31 +00:00
# ifdef NSIS_FIX_DEFINES_IN_STRINGS
ps_addtoline ( t , linedata , hist , true ) ;
2003-06-16 19:58:29 +00:00
# else
2002-08-02 10:01:35 +00:00
ps_addtoline ( t , linedata , hist ) ;
2003-06-16 19:58:29 +00:00
# endif
2010-03-24 17:22:56 +00:00
hist . delbypos ( hist . find ( ( TCHAR * ) defname . get ( ) , 0 ) ) ;
2002-08-02 10:01:35 +00:00
}
}
}
2003-06-16 19:58:29 +00:00
# ifdef NSIS_FIX_DEFINES_IN_STRINGS
2010-03-24 17:22:56 +00:00
else if ( in [ 0 ] = = _T ( ' $ ' ) )
2003-06-16 19:58:29 +00:00
{
2010-03-24 17:22:56 +00:00
if ( in [ 1 ] = = _T ( ' { ' ) ) // Found $$ before - Don't replace this define
2003-06-16 19:58:29 +00:00
{
2010-03-29 14:24:47 +00:00
TCHAR * s = _tcsdup ( in + 2 ) ;
2004-10-15 03:59:46 +00:00
MANAGE_WITH ( s , free ) ;
2010-03-24 17:22:56 +00:00
TCHAR * t = s ;
2003-06-16 19:58:29 +00:00
unsigned int bn = 0 ;
while ( * t )
{
2010-03-24 17:22:56 +00:00
if ( * t = = _T ( ' { ' ) ) bn + + ;
if ( * t = = _T ( ' } ' ) & & bn - - = = 0 ) break ;
2003-06-16 19:58:29 +00:00
t = CharNext ( t ) ;
}
2003-11-25 06:25:31 +00:00
if ( * t & & t ! = s )
2003-06-16 19:58:29 +00:00
{
* t = 0 ;
// add text unchanged
GrowBuf defname ;
ps_addtoline ( s , defname , hist ) ;
in + + ;
}
}
else
{
2010-03-24 17:22:56 +00:00
linedata . add ( ( void * ) & c , 1 * sizeof ( TCHAR ) ) ;
2003-06-16 19:58:29 +00:00
in + + ;
}
}
# endif
2002-08-02 10:01:35 +00:00
}
2010-03-24 17:22:56 +00:00
if ( add ) linedata . add ( ( void * ) & c , 1 * sizeof ( TCHAR ) ) ;
2002-08-02 10:01:35 +00:00
}
}
2003-06-05 21:53:52 +00:00
int CEXEBuild : : parseScript ( )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR str [ MAX_LINELENGTH ] ;
2002-08-02 10:01:35 +00:00
for ( ; ; )
{
2010-03-24 17:22:56 +00:00
TCHAR * p = str ;
2002-08-02 10:01:35 +00:00
* p = 0 ;
2010-03-24 17:22:56 +00:00
_fgetts ( str , MAX_LINELENGTH , fp ) ;
2003-06-05 21:53:52 +00:00
linecnt + + ;
2002-08-02 10:01:35 +00:00
if ( feof ( fp ) & & ! str [ 0 ] ) break ;
// remove trailing whitespace
while ( * p ) p + + ;
if ( p > str ) p - - ;
2010-03-24 17:22:56 +00:00
while ( p > = str & & ( * p = = _T ( ' \r ' ) | | * p = = _T ( ' \n ' ) | | * p = = _T ( ' ' ) | | * p = = _T ( ' \t ' ) ) ) p - - ;
2002-08-02 10:01:35 +00:00
* + + p = 0 ;
StringList hist ;
GrowBuf linedata ;
2003-06-12 15:09:27 +00:00
# ifdef NSIS_SUPPORT_STANDARD_PREDEFINES
// Added by Sunil Kamath 11 June 2003
2010-03-24 17:22:56 +00:00
TCHAR * oldline = set_line_predefine ( linecnt , FALSE ) ;
2003-06-12 15:09:27 +00:00
# endif
2002-08-02 10:01:35 +00:00
ps_addtoline ( str , linedata , hist ) ;
2010-03-24 17:22:56 +00:00
linedata . add ( _T ( " " ) , sizeof ( _T ( " " ) ) ) ;
int ret = doParse ( ( TCHAR * ) linedata . get ( ) ) ;
2003-06-12 15:09:27 +00:00
# ifdef NSIS_SUPPORT_STANDARD_PREDEFINES
// Added by Sunil Kamath 11 June 2003
restore_line_predefine ( oldline ) ;
# endif
2004-12-10 11:09:10 +00:00
2002-08-02 10:01:35 +00:00
if ( ret ! = PS_OK ) return ret ;
}
2002-08-05 02:05:00 +00:00
2002-08-02 10:01:35 +00:00
return PS_EOF ;
}
2010-03-24 17:22:56 +00:00
int CEXEBuild : : includeScript ( TCHAR * f )
2003-11-25 07:09:53 +00:00
{
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " !include: \" %s \" \n " ) , f ) ;
2010-03-29 14:24:47 +00:00
FILE * incfp = FOPENTEXT ( f , _T ( " rt " ) ) ;
2003-11-25 07:09:53 +00:00
if ( ! incfp )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !include: could not open file: \" %s \" \n " ) , f ) ;
2003-11-25 07:09:53 +00:00
return PS_ERROR ;
}
2004-10-11 21:24:33 +00:00
// auto-fclose(3) incfp
2004-10-15 03:59:46 +00:00
MANAGE_WITH ( incfp , fclose ) ;
2004-12-10 11:09:10 +00:00
2003-11-25 07:09:53 +00:00
if ( build_include_depth > = MAX_INCLUDEDEPTH )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " parseScript: too many levels of includes (%d max). \n " ) , MAX_INCLUDEDEPTH ) ;
2003-11-25 07:09:53 +00:00
return PS_ERROR ;
}
build_include_depth + + ;
int last_linecnt = linecnt ;
linecnt = 0 ;
2010-03-24 17:22:56 +00:00
const TCHAR * last_filename = curfilename ;
2003-11-25 07:09:53 +00:00
curfilename = f ;
FILE * last_fp = fp ;
fp = incfp ;
# ifdef NSIS_SUPPORT_STANDARD_PREDEFINES
// Added by Sunil Kamath 11 June 2003
2010-03-24 17:22:56 +00:00
TCHAR * oldfilename = set_file_predefine ( curfilename ) ;
TCHAR * oldtimestamp = set_timestamp_predefine ( curfilename ) ;
2003-11-25 07:09:53 +00:00
# endif
int r = parseScript ( ) ;
# ifdef NSIS_SUPPORT_STANDARD_PREDEFINES
// Added by Sunil Kamath 11 June 2003
restore_file_predefine ( oldfilename ) ;
restore_timestamp_predefine ( oldtimestamp ) ;
# endif
int errlinecnt = linecnt ;
linecnt = last_linecnt ;
curfilename = last_filename ;
fp = last_fp ;
build_include_depth - - ;
if ( r ! = PS_EOF & & r ! = PS_OK )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !include: error in script: \" %s \" on line %d \n " ) , f , errlinecnt ) ;
2003-11-25 07:09:53 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " !include: closed: \" %s \" \n " ) , f ) ;
2003-11-25 07:09:53 +00:00
return PS_OK ;
}
2003-11-30 16:31:43 +00:00
// !ifmacro[n]def based on Anders Kjersem's code
2010-03-24 17:22:56 +00:00
int CEXEBuild : : MacroExists ( const TCHAR * macroname )
2003-11-30 16:31:43 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR * m = ( TCHAR * ) m_macros . get ( ) ;
2003-11-30 16:31:43 +00:00
while ( m & & * m )
{
// check if macroname matches
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( m , macroname ) )
2003-11-30 16:31:43 +00:00
return 1 ;
// skip macro name
2010-03-24 17:22:56 +00:00
m + = _tcsclen ( m ) + 1 ;
2003-11-30 16:31:43 +00:00
// skip params
2010-03-24 17:22:56 +00:00
while ( * m ) m + = _tcsclen ( m ) + 1 ;
2003-11-30 16:31:43 +00:00
m + + ;
// skip data
2010-03-24 17:22:56 +00:00
while ( * m ) m + = _tcsclen ( m ) + 1 ;
if ( m - ( TCHAR * ) m_macros . get ( ) > = m_macros . getlen ( ) - 1 ) break ;
2003-11-30 16:31:43 +00:00
m + + ;
}
return 0 ;
}
2010-03-24 17:22:56 +00:00
int CEXEBuild : : process_oneline ( TCHAR * line , const TCHAR * filename , int linenum )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
const TCHAR * last_filename = curfilename ;
2003-06-05 21:53:52 +00:00
curfilename = filename ;
int last_linecnt = linecnt ;
linecnt = linenum ;
2002-08-02 10:01:35 +00:00
StringList hist ;
GrowBuf linedata ;
2004-12-10 11:09:10 +00:00
2003-06-12 15:09:27 +00:00
# ifdef NSIS_SUPPORT_STANDARD_PREDEFINES
// Added by Sunil Kamath 11 June 2003
2010-03-24 17:22:56 +00:00
TCHAR * oldfilename = NULL ;
TCHAR * oldtimestamp = NULL ;
TCHAR * oldline = NULL ;
BOOL is_commandline = ! _tcscmp ( filename , _T ( " command line " ) ) ;
BOOL is_macro = ! _tcsncmp ( filename , _T ( " macro: " ) , _tcsclen ( _T ( " macro: " ) ) ) ;
2003-06-12 16:14:03 +00:00
2003-06-12 21:50:17 +00:00
if ( ! is_commandline ) { // Don't set the predefines for command line /X option
2003-06-13 15:59:30 +00:00
if ( ! is_macro ) {
2003-06-12 21:50:17 +00:00
oldfilename = set_file_predefine ( curfilename ) ;
oldtimestamp = set_timestamp_predefine ( curfilename ) ;
}
2003-06-13 15:59:30 +00:00
oldline = set_line_predefine ( linecnt , is_macro ) ;
2003-06-12 21:50:17 +00:00
}
2003-06-12 15:09:27 +00:00
# endif
2002-08-02 10:01:35 +00:00
ps_addtoline ( line , linedata , hist ) ;
2010-03-24 17:22:56 +00:00
linedata . add ( _T ( " " ) , sizeof ( _T ( " " ) ) ) ;
int ret = doParse ( ( TCHAR * ) linedata . get ( ) ) ;
2003-06-12 15:09:27 +00:00
# ifdef NSIS_SUPPORT_STANDARD_PREDEFINES
// Added by Sunil Kamath 11 June 2003
2003-06-12 21:50:17 +00:00
if ( ! is_commandline ) { // Don't set the predefines for command line /X option
if ( ! is_macro ) {
restore_file_predefine ( oldfilename ) ;
restore_timestamp_predefine ( oldtimestamp ) ;
}
2003-06-12 16:14:03 +00:00
restore_line_predefine ( oldline ) ;
}
2003-06-12 15:09:27 +00:00
# endif
2003-06-05 21:53:52 +00:00
linecnt = last_linecnt ;
curfilename = last_filename ;
return ret ;
2002-08-02 10:01:35 +00:00
}
int CEXEBuild : : process_jump ( LineParser & line , int wt , int * offs )
{
2010-03-24 17:22:56 +00:00
const TCHAR * s = line . gettoken_str ( wt ) ;
2002-08-02 10:01:35 +00:00
int v ;
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( s , _T ( " 0 " ) ) | | ! _tcsicmp ( s , _T ( " " ) ) ) * offs = 0 ;
2003-06-09 18:59:14 +00:00
else if ( ( v = GetUserVarIndex ( line , wt ) ) > = 0 )
2002-08-02 10:01:35 +00:00
{
* offs = - v - 1 ; // to jump to a user variable target, -variable_index-1 is stored.
}
else
{
2010-03-24 17:22:56 +00:00
if ( ( s [ 0 ] = = _T ( ' - ' ) | | s [ 0 ] = = _T ( ' + ' ) ) & & ! _ttoi ( s + 1 ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: Goto targets beginning with '+' or '-' must be followed by nonzero integer (relative jump) \n " ) ) ;
2002-08-02 10:01:35 +00:00
return 1 ;
}
2010-03-24 17:22:56 +00:00
if ( ( s [ 0 ] > = _T ( ' 0 ' ) & & s [ 0 ] < = _T ( ' 9 ' ) ) | | s [ 0 ] = = _T ( ' $ ' ) | | s [ 0 ] = = _T ( ' ! ' ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: Goto targets cannot begin with 0-9, $, ! \n " ) ) ;
2002-08-02 10:01:35 +00:00
return 1 ;
}
* offs = ns_label . add ( s , 0 ) ;
}
return 0 ;
}
2008-12-09 23:10:07 +00:00
# define FLAG_OFFSET(flag) (FIELD_OFFSET(exec_flags_t, flag) / sizeof(int))
2003-05-11 18:30:38 +00:00
# define SECTION_FIELD_GET(field) (FIELD_OFFSET(section, field) / sizeof(int))
# define SECTION_FIELD_SET(field) (-1 - (int)(FIELD_OFFSET(section, field) / sizeof(int)))
2003-04-02 19:54:53 +00:00
2004-10-11 21:24:33 +00:00
// Func size: about 5000 lines (orip)
2003-06-05 21:53:52 +00:00
int CEXEBuild : : doCommand ( int which_token , LineParser & line )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
static const TCHAR * rootkeys [ 2 ] = {
_T ( " HKCR \0 HKLM \0 HKCU \0 HKU \0 HKCC \0 HKDD \0 HKPD \0 SHCTX \0 " ) ,
_T ( " HKEY_CLASSES_ROOT \0 HKEY_LOCAL_MACHINE \0 HKEY_CURRENT_USER \0 HKEY_USERS \0 HKEY_CURRENT_CONFIG \0 HKEY_DYN_DATA \0 HKEY_PERFORMANCE_DATA \0 SHELL_CONTEXT \0 " )
2002-08-02 10:01:35 +00:00
} ;
static HKEY rootkey_tab [ ] = {
2005-02-17 21:20:05 +00:00
HKEY_CLASSES_ROOT , HKEY_LOCAL_MACHINE , HKEY_CURRENT_USER , HKEY_USERS , HKEY_CURRENT_CONFIG , HKEY_DYN_DATA , HKEY_PERFORMANCE_DATA , 0
2002-08-02 10:01:35 +00:00
} ;
2004-01-04 17:25:59 +00:00
# ifdef NSIS_CONFIG_PLUGIN_SUPPORT
2003-11-30 18:00:39 +00:00
build_plugin_table ( ) ;
2004-01-04 17:25:59 +00:00
# endif
2003-11-30 18:00:39 +00:00
2004-09-25 13:35:03 +00:00
multiple_entries_instruction = 0 ;
2002-08-02 10:01:35 +00:00
entry ent = { 0 , } ;
switch ( which_token )
{
2010-03-24 17:22:56 +00:00
// macro stuff
2002-08-02 10:01:35 +00:00
///////////////////////////////////////////////////////////////////////////////
case TOK_P_MACRO :
{
if ( ! line . gettoken_str ( 1 ) [ 0 ] ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
TCHAR * t = ( TCHAR * ) m_macros . get ( ) ;
2002-08-02 10:01:35 +00:00
while ( t & & * t )
{
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( t , line . gettoken_str ( 1 ) ) ) break ;
2010-03-24 17:22:56 +00:00
t + = _tcsclen ( t ) + 1 ;
2002-08-02 10:01:35 +00:00
// advance over parameters
2010-03-24 17:22:56 +00:00
while ( * t ) t + = _tcsclen ( t ) + 1 ;
2002-08-02 10:01:35 +00:00
t + + ;
// advance over data
2010-03-24 17:22:56 +00:00
while ( * t ) t + = _tcsclen ( t ) + 1 ;
if ( t - ( TCHAR * ) m_macros . get ( ) > = m_macros . getlen ( ) - 1 )
2002-08-02 10:01:35 +00:00
break ;
t + + ;
}
2002-08-11 18:57:16 +00:00
if ( t & & * t )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !macro: macro named \" %s \" already found! \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
m_macros . add ( line . gettoken_str ( 1 ) , ( _tcsclen ( line . gettoken_str ( 1 ) ) + 1 ) * sizeof ( TCHAR ) ) ;
2002-08-02 10:01:35 +00:00
int pc ;
for ( pc = 2 ; pc < line . getnumtokens ( ) ; pc + + )
{
if ( ! line . gettoken_str ( pc ) [ 0 ] )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !macro: macro parameter %d is empty, not valid! \n " ) , pc - 1 ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
int a ;
for ( a = 2 ; a < pc ; a + + )
{
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( pc ) , line . gettoken_str ( a ) ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !macro: macro parameter named %s is used multiple times! \n " ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( pc ) ) ;
return PS_ERROR ;
}
}
2010-03-24 17:22:56 +00:00
m_macros . add ( line . gettoken_str ( pc ) , ( _tcsclen ( line . gettoken_str ( pc ) ) + 1 ) * sizeof ( TCHAR ) ) ;
2002-08-02 10:01:35 +00:00
}
2010-03-24 17:22:56 +00:00
m_macros . add ( _T ( " " ) , sizeof ( _T ( " " ) ) ) ;
2002-08-02 10:01:35 +00:00
for ( ; ; )
{
2010-03-24 17:22:56 +00:00
TCHAR str [ MAX_LINELENGTH ] ;
TCHAR * p = str ;
2002-08-02 10:01:35 +00:00
str [ 0 ] = 0 ;
2010-03-24 17:22:56 +00:00
_fgetts ( str , MAX_LINELENGTH , fp ) ;
//SCRIPT_MSG(_T("%s%s"), str, str[_tcsclen(str)-1]==_T('\n')?_T(""):_T("\n"));
2002-08-28 14:59:35 +00:00
if ( feof ( fp ) & & ! str [ 0 ] )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !macro \" %s \" : unterminated (no !macroend found in file)! \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
// remove trailing whitespace
while ( * p ) p + + ;
if ( p > str ) p - - ;
2010-03-24 17:22:56 +00:00
while ( p > = str & & ( * p = = _T ( ' \r ' ) | | * p = = _T ( ' \n ' ) | | * p = = _T ( ' ' ) | | * p = = _T ( ' \t ' ) ) ) p - - ;
2002-08-02 10:01:35 +00:00
* + + p = 0 ;
2003-06-09 18:59:14 +00:00
LineParser l2 ( false ) ;
2002-11-05 17:24:49 +00:00
if ( ! l2 . parse ( str ) )
{
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( l2 . gettoken_str ( 0 ) , _T ( " !macroend " ) ) )
2002-12-01 13:19:23 +00:00
{
2003-06-05 21:53:52 +00:00
linecnt + + ;
2002-12-01 13:19:23 +00:00
break ;
}
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( l2 . gettoken_str ( 0 ) , _T ( " !macro " ) ) )
2002-11-05 17:24:49 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: can't define a macro inside a macro! \n " ) ) ;
2002-11-05 17:24:49 +00:00
return PS_ERROR ;
}
}
2010-03-24 17:22:56 +00:00
if ( str [ 0 ] ) m_macros . add ( str , ( _tcsclen ( str ) + 1 ) * sizeof ( TCHAR ) ) ;
else m_macros . add ( _T ( " " ) , sizeof ( _T ( " " ) ) ) ;
2003-06-05 21:53:52 +00:00
linecnt + + ;
2002-08-02 10:01:35 +00:00
}
2010-03-24 17:22:56 +00:00
m_macros . add ( _T ( " " ) , sizeof ( _T ( " " ) ) ) ;
2002-08-02 10:01:35 +00:00
}
return PS_OK ;
case TOK_P_MACROEND :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !macroend: no macro currently open. \n " ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
case TOK_P_INSERTMACRO :
{
if ( ! line . gettoken_str ( 1 ) [ 0 ] ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
TCHAR * t = ( TCHAR * ) m_macros . get ( ) ;
TCHAR * m = t ;
2002-08-02 10:01:35 +00:00
while ( t & & * t )
{
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( t , line . gettoken_str ( 1 ) ) ) break ;
2010-03-24 17:22:56 +00:00
t + = _tcsclen ( t ) + 1 ;
2002-08-11 18:57:16 +00:00
2002-08-02 10:01:35 +00:00
// advance over parms
2010-03-24 17:22:56 +00:00
while ( * t ) t + = _tcsclen ( t ) + 1 ;
2002-08-02 10:01:35 +00:00
t + + ;
// advance over data
2010-03-24 17:22:56 +00:00
while ( * t ) t + = _tcsclen ( t ) + 1 ;
if ( t - ( TCHAR * ) m_macros . get ( ) > = m_macros . getlen ( ) - 1 )
2002-08-02 10:01:35 +00:00
break ;
t + + ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " !insertmacro: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-11 18:57:16 +00:00
if ( ! t | | ! * t )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !insertmacro: macro named \" %s \" not found! \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
t + = _tcsclen ( t ) + 1 ;
2002-08-02 10:01:35 +00:00
GrowBuf l_define_names ;
DefineList l_define_saves ;
int npr = 0 ;
// advance over parms
2002-08-11 18:57:16 +00:00
while ( * t )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR * v = definedlist . find ( t ) ;
2004-03-12 20:43:54 +00:00
if ( v )
2002-08-02 10:01:35 +00:00
{
l_define_saves . add ( t , v ) ;
definedlist . del ( t ) ;
}
2010-03-24 17:22:56 +00:00
l_define_names . add ( t , ( _tcsclen ( t ) + 1 ) * sizeof ( TCHAR ) ) ;
2002-08-02 10:01:35 +00:00
definedlist . add ( t , line . gettoken_str ( npr + 2 ) ) ;
npr + + ;
2010-03-24 17:22:56 +00:00
t + = _tcsclen ( t ) + 1 ;
2002-08-02 10:01:35 +00:00
}
2010-03-24 17:22:56 +00:00
l_define_names . add ( _T ( " " ) , sizeof ( _T ( " " ) ) ) ;
2002-08-02 10:01:35 +00:00
t + + ;
if ( npr ! = line . getnumtokens ( ) - 2 )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !insertmacro: macro \" %s \" requires %d parameter(s), passed %d! \n " ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 1 ) , npr , line . getnumtokens ( ) - 2 ) ;
return PS_ERROR ;
}
int lp = 0 ;
2010-03-24 17:22:56 +00:00
TCHAR str [ 1024 ] ;
2002-08-02 10:01:35 +00:00
if ( m_macro_entry . find ( line . gettoken_str ( 1 ) , 0 ) > = 0 )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !insertmacro: macro \" %s \" already being inserted! \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
int npos = m_macro_entry . add ( line . gettoken_str ( 1 ) , 0 ) ;
2010-03-24 17:22:56 +00:00
wsprintf ( str , _T ( " macro:%s " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
while ( * t )
{
lp + + ;
2010-03-24 17:22:56 +00:00
if ( _tcscmp ( t , _T ( " " ) ) )
2002-08-02 10:01:35 +00:00
{
int ret = process_oneline ( t , str , lp ) ;
2002-08-11 18:57:16 +00:00
if ( ret ! = PS_OK )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error in macro %s on macroline %d \n " ) , line . gettoken_str ( 1 ) , lp ) ;
2002-08-02 10:01:35 +00:00
return ret ;
}
}
2004-06-25 10:16:31 +00:00
{
// fix t if process_oneline changed m_macros
2010-03-24 17:22:56 +00:00
TCHAR * nm = ( TCHAR * ) m_macros . get ( ) ;
2004-06-25 10:16:31 +00:00
if ( nm ! = m )
{
t + = nm - m ;
m = nm ;
}
}
2010-03-24 17:22:56 +00:00
t + = _tcsclen ( t ) + 1 ;
2002-08-02 10:01:35 +00:00
}
m_macro_entry . delbypos ( npos ) ;
{
2010-03-24 17:22:56 +00:00
TCHAR * p = ( TCHAR * ) l_define_names . get ( ) ;
2002-08-02 10:01:35 +00:00
while ( * p )
{
definedlist . del ( p ) ;
2010-03-24 17:22:56 +00:00
TCHAR * v ;
2002-08-02 10:01:35 +00:00
if ( ( v = l_define_saves . find ( p ) ) ) definedlist . add ( p , v ) ;
2010-03-24 17:22:56 +00:00
p + = _tcsclen ( p ) + 1 ;
2002-08-02 10:01:35 +00:00
}
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " !insertmacro: end of %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
}
2005-10-07 13:08:44 +00:00
return PS_OK ;
// preprocessor files fun
///////////////////////////////////////////////////////////////////////////////
case TOK_P_TEMPFILE :
{
2010-03-24 17:22:56 +00:00
TCHAR * symbol = line . gettoken_str ( 1 ) ;
TCHAR * fpath ;
2005-10-07 13:08:44 +00:00
# ifdef _WIN32
2010-03-24 17:22:56 +00:00
TCHAR buf [ MAX_PATH ] , buf2 [ MAX_PATH ] ;
2005-10-07 13:08:44 +00:00
GetTempPath ( MAX_PATH , buf ) ;
2010-03-24 17:22:56 +00:00
if ( ! GetTempFileName ( buf , _T ( " nst " ) , 0 , buf2 ) )
2005-10-07 13:08:44 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !tempfile: unable to create temporary file. \n " ) ) ;
2005-10-07 13:08:44 +00:00
return PS_ERROR ;
}
fpath = buf2 ;
# else
2010-03-24 17:22:56 +00:00
TCHAR t [ ] = _T ( " /tmp/makensisXXXXXX " ) ;
2005-10-07 13:08:44 +00:00
2005-10-07 13:41:44 +00:00
mode_t old_umask = umask ( 0077 ) ;
2005-10-07 13:08:44 +00:00
int fd = mkstemp ( t ) ;
if ( fd = = - 1 ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !tempfile: unable to create temporary file. \n " ) ) ;
2005-10-07 13:08:44 +00:00
return PS_ERROR ;
}
close ( fd ) ;
umask ( old_umask ) ;
fpath = t ;
# endif
2002-08-02 10:01:35 +00:00
2005-10-07 13:08:44 +00:00
if ( definedlist . add ( symbol , fpath ) )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !tempfile: \" %s \" already defined! \n " ) , symbol ) ;
2005-10-07 13:08:44 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " !tempfile: \" %s \" = \" %s \" \n " ) , symbol , fpath ) ;
2005-10-07 13:08:44 +00:00
}
2002-08-02 10:01:35 +00:00
return PS_OK ;
2005-10-07 13:08:44 +00:00
case TOK_P_DELFILE :
2005-10-12 14:40:36 +00:00
{
2009-06-06 18:31:56 +00:00
int fatal = 1 ;
int a = 1 ;
2010-03-24 17:22:56 +00:00
TCHAR * fc = line . gettoken_str ( a ) ;
2009-06-06 18:31:56 +00:00
if ( line . getnumtokens ( ) = = 3 )
{
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( fc , _T ( " /nonfatal " ) ) )
2009-06-06 18:31:56 +00:00
{
fatal = 0 ;
fc = line . gettoken_str ( + + a ) ;
}
else PRINTHELP ( ) ;
2005-10-12 14:40:36 +00:00
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " !delfile: \" %s \" \n " ) , line . gettoken_str ( a ) ) ;
2009-06-06 18:31:56 +00:00
2010-03-24 17:22:56 +00:00
tstring dir = get_dir_name ( fc ) ;
tstring spec = get_file_name ( fc ) ;
tstring basedir = dir + PLATFORM_PATH_SEPARATOR_STR ;
2009-06-06 18:31:56 +00:00
if ( dir = = spec ) {
// no path, just file name
2010-03-24 17:22:56 +00:00
dir = _T ( " . " ) ;
basedir = _T ( " " ) ;
2009-06-06 18:31:56 +00:00
}
boost : : scoped_ptr < dir_reader > dr ( new_dir_reader ( ) ) ;
dr - > read ( dir ) ;
for ( dir_reader : : iterator files_itr = dr - > files ( ) . begin ( ) ;
files_itr ! = dr - > files ( ) . end ( ) ;
files_itr + + )
{
if ( ! dir_reader : : matches ( * files_itr , spec ) )
continue ;
2010-03-24 17:22:56 +00:00
tstring file = basedir + * files_itr ;
2009-06-06 18:31:56 +00:00
2010-03-29 14:24:47 +00:00
int result = _tunlink ( file . c_str ( ) ) ;
2009-06-06 18:31:56 +00:00
if ( result = = - 1 ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !delfile: \" %s \" couldn't be deleted. \n " ) , file . c_str ( ) ) ;
2009-06-06 18:31:56 +00:00
if ( fatal )
{
return PS_ERROR ;
}
}
else
{
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " !delfile: deleted \" %s \" \n " ) , file . c_str ( ) ) ;
2009-06-06 18:31:56 +00:00
}
}
2005-10-07 13:08:44 +00:00
}
return PS_OK ;
2005-10-12 14:24:21 +00:00
case TOK_P_APPENDFILE :
{
2010-03-24 17:22:56 +00:00
TCHAR * file = line . gettoken_str ( 1 ) ;
TCHAR * text = line . gettoken_str ( 2 ) ;
2005-10-12 14:24:21 +00:00
2010-03-29 14:24:47 +00:00
FILE * fp = FOPENTEXT ( file , _T ( " a " ) ) ;
2005-10-12 14:24:21 +00:00
if ( ! fp )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !appendfile: \" %s \" couldn't be opened. \n " ) , file ) ;
2005-10-12 14:24:21 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
if ( _fputts ( text , fp ) < 0 )
2005-10-12 14:24:21 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !appendfile: error writing to \" %s \" . \n " ) , file ) ;
2005-10-12 14:24:21 +00:00
return PS_ERROR ;
}
fclose ( fp ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " !appendfile: \" %s \" \" %s \" \n " ) , file , text ) ;
2005-10-12 14:24:21 +00:00
}
return PS_OK ;
2010-03-24 17:22:56 +00:00
// page ordering stuff
2002-11-01 20:34:55 +00:00
///////////////////////////////////////////////////////////////////////////////
2003-09-04 18:25:57 +00:00
# ifdef NSIS_CONFIG_VISIBLE_SUPPORT
case TOK_UNINSTPAGE :
set_uninstall_mode ( 1 ) ;
2002-11-01 20:34:55 +00:00
case TOK_PAGE :
{
2003-09-04 18:25:57 +00:00
if ( ! uninstall_mode ) {
enable_last_page_cancel = 0 ;
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( line . getnumtokens ( ) - 1 ) , _T ( " /ENABLECANCEL " ) ) )
2003-09-04 18:25:57 +00:00
enable_last_page_cancel = 1 ;
}
else {
uenable_last_page_cancel = 0 ;
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( line . getnumtokens ( ) - 1 ) , _T ( " /ENABLECANCEL " ) ) )
2003-09-04 18:25:57 +00:00
uenable_last_page_cancel = 1 ;
}
2003-03-06 21:24:19 +00:00
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " custom \0 license \0 components \0 directory \0 instfiles \0 uninstConfirm \0 " ) ) ;
2003-09-04 18:25:57 +00:00
if ( k < 0 ) PRINTHELP ( ) ;
if ( add_page ( k ) ! = PS_OK )
return PS_ERROR ;
2002-11-01 20:34:55 +00:00
2003-01-24 19:40:20 +00:00
# ifndef NSIS_SUPPORT_CODECALLBACKS
if ( ! k ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: custom page specified, NSIS_SUPPORT_CODECALLBACKS not defined. \n " ) ) ;
2003-01-24 19:40:20 +00:00
return PS_ERROR ;
}
# endif //!NSIS_SUPPORT_CODECALLBACKS
if ( k ) {
// not custom
2002-11-01 20:34:55 +00:00
# ifdef NSIS_SUPPORT_CODECALLBACKS
2003-03-06 21:24:19 +00:00
switch ( line . getnumtokens ( ) - enable_last_page_cancel ) {
2003-01-24 19:40:20 +00:00
case 6 :
2003-09-04 18:25:57 +00:00
PRINTHELP ( ) ;
2003-07-12 15:19:49 +00:00
case 5 :
2003-01-24 19:40:20 +00:00
if ( * line . gettoken_str ( 4 ) )
2003-09-04 18:25:57 +00:00
cur_page - > leavefunc = ns_func . add ( line . gettoken_str ( 4 ) , 0 ) ;
2003-01-24 19:40:20 +00:00
case 4 :
2002-11-11 17:37:59 +00:00
if ( * line . gettoken_str ( 3 ) )
2003-09-04 18:25:57 +00:00
cur_page - > showfunc = ns_func . add ( line . gettoken_str ( 3 ) , 0 ) ;
2003-01-24 19:40:20 +00:00
case 3 :
if ( * line . gettoken_str ( 2 ) )
2003-09-04 18:25:57 +00:00
cur_page - > prefunc = ns_func . add ( line . gettoken_str ( 2 ) , 0 ) ;
2002-11-01 20:34:55 +00:00
}
2003-01-24 19:40:20 +00:00
# endif //NSIS_SUPPORT_CODECALLBACKS
2002-11-01 20:34:55 +00:00
}
2003-01-24 19:40:20 +00:00
# ifdef NSIS_SUPPORT_CODECALLBACKS
else {
// a custom page
2003-03-06 21:24:19 +00:00
switch ( line . getnumtokens ( ) - enable_last_page_cancel ) {
2003-01-24 19:40:20 +00:00
case 6 :
2003-09-04 18:25:57 +00:00
PRINTHELP ( ) ;
2003-01-24 19:40:20 +00:00
case 5 :
2003-09-04 18:25:57 +00:00
cur_page - > caption = add_string ( line . gettoken_str ( 4 ) ) ;
2003-01-24 19:40:20 +00:00
case 4 :
2003-03-18 15:45:25 +00:00
if ( * line . gettoken_str ( 3 ) )
2003-09-04 18:25:57 +00:00
cur_page - > leavefunc = ns_func . add ( line . gettoken_str ( 3 ) , 0 ) ;
2003-01-24 19:40:20 +00:00
case 3 :
if ( * line . gettoken_str ( 2 ) )
2003-09-04 18:25:57 +00:00
cur_page - > prefunc = ns_func . add ( line . gettoken_str ( 2 ) , 0 ) ;
2003-01-24 19:40:20 +00:00
break ;
case 2 :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: custom page must have a creator function! \n " ) ) ;
2003-01-24 19:40:20 +00:00
PRINTHELP ( ) ;
}
2002-11-01 20:34:55 +00:00
}
2003-01-24 19:40:20 +00:00
# endif //NSIS_SUPPORT_CODECALLBACKS
2002-11-01 20:34:55 +00:00
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %sPage: %s " ) , uninstall_mode ? _T ( " Uninst " ) : _T ( " " ) , line . gettoken_str ( 1 ) ) ;
2004-01-29 01:23:24 +00:00
2002-11-01 20:34:55 +00:00
# ifdef NSIS_SUPPORT_CODECALLBACKS
2003-09-04 18:25:57 +00:00
if ( cur_page - > prefunc > = 0 )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " (%s:%s) " ) , k ? _T ( " pre " ) : _T ( " creator " ) , line . gettoken_str ( 2 ) ) ;
2003-09-04 18:25:57 +00:00
if ( cur_page - > showfunc > = 0 & & k )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " (show:%s) " ) , line . gettoken_str ( 3 ) ) ;
2003-09-04 18:25:57 +00:00
if ( cur_page - > leavefunc > = 0 )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " (leave:%s) " ) , line . gettoken_str ( 4 - ! k ) ) ;
2003-09-04 18:25:57 +00:00
else if ( cur_page - > caption & & ! k )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " (caption:%s) " ) , line . gettoken_str ( 3 ) ) ;
2002-11-01 20:34:55 +00:00
# endif
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " \n " ) ) ;
2002-11-01 20:34:55 +00:00
2003-09-04 18:25:57 +00:00
page_end ( ) ;
if ( k = = PAGE_INSTFILES ) {
add_page ( PAGE_COMPLETED ) ;
page_end ( ) ;
2002-11-01 20:34:55 +00:00
}
2003-09-04 18:25:57 +00:00
set_uninstall_mode ( 0 ) ;
2002-11-01 20:34:55 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-11-01 20:34:55 +00:00
2003-09-04 18:25:57 +00:00
// extended page setting
case TOK_PAGEEX :
{
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " custom \0 license \0 components \0 directory \0 instfiles \0 uninstConfirm \0 " ) ) ;
2003-09-04 18:25:57 +00:00
if ( k < 0 ) {
2010-03-24 17:22:56 +00:00
k = line . gettoken_enum ( 1 , _T ( " un.custom \0 un.license \0 un.components \0 un.directory \0 un.instfiles \0 un.uninstConfirm \0 " ) ) ;
2003-09-04 18:25:57 +00:00
if ( k < 0 ) PRINTHELP ( ) ;
set_uninstall_mode ( 1 ) ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " PageEx: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2003-09-04 18:25:57 +00:00
if ( add_page ( k ) ! = PS_OK )
return PS_ERROR ;
cur_page - > flags | = PF_PAGE_EX ;
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2003-09-04 18:25:57 +00:00
case TOK_PAGEEXEND :
{
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " PageExEnd \n " ) ) ;
2003-09-04 18:25:57 +00:00
2002-11-01 20:34:55 +00:00
# ifdef NSIS_SUPPORT_CODECALLBACKS
2003-09-04 18:25:57 +00:00
if ( cur_page_type = = PAGE_CUSTOM & & ! cur_page - > prefunc ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: custom pages must have a creator function. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
2002-11-01 20:34:55 +00:00
# endif
2003-09-04 18:25:57 +00:00
page_end ( ) ;
2003-01-24 19:40:20 +00:00
2003-09-04 18:25:57 +00:00
if ( cur_page_type = = PAGE_INSTFILES ) {
add_page ( PAGE_COMPLETED ) ;
page_end ( ) ;
}
2003-03-03 13:51:46 +00:00
2003-09-04 18:25:57 +00:00
set_uninstall_mode ( 0 ) ;
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2003-09-04 18:25:57 +00:00
case TOK_PAGECALLBACKS :
2002-11-01 20:34:55 +00:00
# ifdef NSIS_SUPPORT_CODECALLBACKS
2003-09-04 18:25:57 +00:00
{
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " PageCallbacks: " ) ) ;
2003-12-24 15:54:06 +00:00
2003-09-04 18:25:57 +00:00
if ( cur_page_type = = PAGE_CUSTOM )
{
switch ( line . getnumtokens ( ) )
{
case 4 :
{
PRINTHELP ( ) ;
}
case 3 :
{
if ( * line . gettoken_str ( 2 ) )
{
2010-03-29 14:24:47 +00:00
if ( _tcsncicmp ( line . gettoken_str ( 2 ) , _T ( " un. " ) , 3 ) )
2003-09-04 18:25:57 +00:00
{
if ( uninstall_mode )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " \n Error: function names must start with \" un. \" in an uninstall page. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
2003-03-03 13:51:46 +00:00
}
2003-09-04 18:25:57 +00:00
else
{
if ( ! uninstall_mode )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " \n Error: function names must start with \" un. \" in an uninstall page. \n " ) ) ;
2003-01-24 19:40:20 +00:00
return PS_ERROR ;
}
2002-11-11 17:37:59 +00:00
}
2003-09-04 18:25:57 +00:00
cur_page - > leavefunc = ns_func . add ( line . gettoken_str ( 2 ) , 0 ) ;
}
}
case 2 :
{
if ( * line . gettoken_str ( 1 ) )
{
2010-03-29 14:24:47 +00:00
if ( _tcsncicmp ( line . gettoken_str ( 1 ) , _T ( " un. " ) , 3 ) )
2003-09-04 18:25:57 +00:00
{
if ( uninstall_mode )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " \n Error: function names must start with \" un. \" in an uninstall page. \n " ) ) ;
2002-11-11 17:37:59 +00:00
return PS_ERROR ;
}
2003-01-24 19:40:20 +00:00
}
2003-09-04 18:25:57 +00:00
else
{
if ( ! uninstall_mode )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " \n Error: function names must start with \" un. \" in an uninstall page. \n " ) ) ;
2003-01-24 19:40:20 +00:00
return PS_ERROR ;
}
2002-11-11 15:11:49 +00:00
}
2003-09-04 18:25:57 +00:00
cur_page - > prefunc = ns_func . add ( line . gettoken_str ( 1 ) , 0 ) ;
}
2002-11-01 20:34:55 +00:00
}
}
2003-09-04 18:25:57 +00:00
}
else
{
switch ( line . getnumtokens ( ) )
{
case 4 :
{
if ( * line . gettoken_str ( 3 ) )
{
2010-03-29 14:24:47 +00:00
if ( _tcsncicmp ( line . gettoken_str ( 3 ) , _T ( " un. " ) , 3 ) )
2003-09-04 18:25:57 +00:00
{
if ( uninstall_mode )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " \n Error: function names must start with \" un. \" in an uninstall page. \n " ) ) ;
2003-03-18 15:45:25 +00:00
return PS_ERROR ;
}
}
2003-09-04 18:25:57 +00:00
else
{
if ( ! uninstall_mode )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " \n Error: function names must start with \" un. \" in an uninstall page. \n " ) ) ;
2003-01-24 19:40:20 +00:00
return PS_ERROR ;
}
}
2003-09-04 18:25:57 +00:00
cur_page - > leavefunc = ns_func . add ( line . gettoken_str ( 3 ) , 0 ) ;
}
}
case 3 :
{
if ( * line . gettoken_str ( 2 ) )
{
2010-03-29 14:24:47 +00:00
if ( _tcsncicmp ( line . gettoken_str ( 2 ) , _T ( " un. " ) , 3 ) )
2003-09-04 18:25:57 +00:00
{
if ( uninstall_mode )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " \n Error: function names must start with \" un. \" in an uninstall page. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
}
else
{
if ( ! uninstall_mode )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " \n Error: function names must start with \" un. \" in an uninstall page. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
}
cur_page - > showfunc = ns_func . add ( line . gettoken_str ( 2 ) , 0 ) ;
}
2003-01-24 19:40:20 +00:00
}
2002-11-01 20:34:55 +00:00
case 2 :
2003-09-04 18:25:57 +00:00
{
if ( * line . gettoken_str ( 1 ) )
{
2010-03-29 14:24:47 +00:00
if ( _tcsncicmp ( line . gettoken_str ( 1 ) , _T ( " un. " ) , 3 ) )
2003-09-04 18:25:57 +00:00
{
if ( uninstall_mode )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " \n Error: function names must start with \" un. \" in an uninstall page. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
}
else
{
if ( ! uninstall_mode )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " \n Error: function names must start with \" un. \" in an uninstall page. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
}
cur_page - > prefunc = ns_func . add ( line . gettoken_str ( 1 ) , 0 ) ;
}
}
2002-11-01 20:34:55 +00:00
}
2003-09-04 18:25:57 +00:00
}
2004-12-10 11:09:10 +00:00
2003-09-04 18:25:57 +00:00
int custom = cur_page_type = = PAGE_CUSTOM ? 1 : 0 ;
2002-11-01 20:34:55 +00:00
2003-09-04 18:25:57 +00:00
if ( cur_page - > prefunc > = 0 )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %s:%s " ) , ! custom ? _T ( " pre " ) : _T ( " creator " ) , line . gettoken_str ( 1 ) ) ;
2003-09-04 18:25:57 +00:00
if ( cur_page - > showfunc > = 0 & & ! custom )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " show:%s " ) , line . gettoken_str ( 2 ) ) ;
2003-09-04 18:25:57 +00:00
if ( cur_page - > leavefunc > = 0 )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " leave:%s " ) , line . gettoken_str ( 3 - custom ) ) ;
2002-11-01 20:34:55 +00:00
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " \n " ) ) ;
2003-09-04 18:25:57 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-11-01 20:34:55 +00:00
# else
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_CODECALLBACKS not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-11-01 20:34:55 +00:00
return PS_ERROR ;
2003-09-04 18:25:57 +00:00
# endif //NSIS_SUPPORT_CODECALLBACKS
# else
case TOK_PAGE :
case TOK_UNINSTPAGE :
case TOK_PAGEEX :
case TOK_PAGEEXEND :
case TOK_PAGECALLBACKS :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_VISIBLE_SUPPORT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
# endif //NSIS_CONFIG_VISIBLE_SUPPORT
2002-08-02 10:01:35 +00:00
// header flags
///////////////////////////////////////////////////////////////////////////////
2002-09-29 20:25:15 +00:00
case TOK_LANGSTRING :
2003-09-04 18:25:57 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR * name = line . gettoken_str ( 1 ) ;
2003-09-04 18:25:57 +00:00
LANGID lang = line . gettoken_int ( 2 ) ;
2010-03-24 17:22:56 +00:00
TCHAR * str = line . gettoken_str ( 3 ) ;
2003-09-04 18:25:57 +00:00
int ret = SetLangString ( name , lang , str ) ;
if ( ret = = PS_WARNING )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " LangString \" %s \" set multiple times for %d, wasting space " ) , name , lang ) ;
2003-09-04 18:25:57 +00:00
else if ( ret = = PS_ERROR ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: can't set LangString \" %s \" ! \n " ) , name ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " LangString: \" %s \" %d \" %s \" \n " ) , name , lang , str ) ;
2003-09-04 18:25:57 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-10-04 10:27:46 +00:00
case TOK_LANGSTRINGUP :
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Error: LangStringUP is obsolete, there are no more unprocessed strings. Use LangString. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
case TOK_LICENSELANGSTRING :
{
# ifdef NSIS_CONFIG_SILENT_SUPPORT
if ( build_header . flags & ( CH_FLAGS_SILENT | CH_FLAGS_SILENT_LOG ) )
2002-09-29 20:25:15 +00:00
{
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " LicenseLangString: SilentInstall enabled, wasting space " ) ) ;
2003-09-04 18:25:57 +00:00
}
# endif
2010-03-24 17:22:56 +00:00
TCHAR * name = line . gettoken_str ( 1 ) ;
2003-09-04 18:25:57 +00:00
LANGID lang = line . gettoken_int ( 2 ) ;
2010-03-24 17:22:56 +00:00
TCHAR * file = line . gettoken_str ( 3 ) ;
2003-09-04 18:25:57 +00:00
FILE * fp ;
2004-03-12 20:43:54 +00:00
unsigned int datalen ;
2010-03-24 17:22:56 +00:00
fp = FOPEN ( file , _T ( " rb " ) ) ;
2003-09-04 18:25:57 +00:00
if ( ! fp )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " LicenseLangString: open failed \" %s \" \n " ) , file ) ;
2003-09-04 18:25:57 +00:00
PRINTHELP ( )
}
2004-10-15 03:59:46 +00:00
MANAGE_WITH ( fp , fclose ) ;
2003-09-04 18:25:57 +00:00
fseek ( fp , 0 , SEEK_END ) ;
datalen = ftell ( fp ) ;
if ( ! datalen )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " LicenseLangString: empty license file \" %s \" \n " ) , file ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
rewind ( fp ) ;
2010-03-24 17:22:56 +00:00
TCHAR * data = ( TCHAR * ) malloc ( datalen + 2 * sizeof ( TCHAR ) ) ;
2003-09-12 11:16:33 +00:00
if ( ! data )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Internal compiler error #12345: LicenseData malloc(%d) failed. \n " ) , datalen + 2 ) ;
2003-09-12 11:16:33 +00:00
return PS_ERROR ;
}
2004-10-15 03:59:46 +00:00
MANAGE_WITH ( data , free ) ;
2010-03-24 17:22:56 +00:00
TCHAR * ldata = data + 1 ;
if ( fread ( ( void * ) ldata , 1 , datalen , fp ) ! = datalen )
2003-09-04 18:25:57 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " LicenseLangString: can't read file. \n " ) ) ;
2002-09-29 20:25:15 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
ldata [ datalen / sizeof ( TCHAR ) ] = 0 ;
if ( ! strncmp ( ( char * ) ldata , " { \\ rtf " , sizeof ( " { \\ rtf " ) - 1 ) )
2003-09-04 18:25:57 +00:00
* data = SF_RTF ;
else
* data = SF_TEXT ;
int ret = SetLangString ( name , lang , data ) ;
if ( ret = = PS_WARNING )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " LicenseLangString \" %s \" set multiple times for %d, wasting space " ) , name , lang ) ;
2003-09-04 18:25:57 +00:00
else if ( ret = = PS_ERROR )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: can't set LicenseLangString \" %s \" ! \n " ) , name ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " LicenseLangString: \" %s \" %d \" %s \" \n " ) , name , lang , file ) ;
2003-09-04 18:25:57 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_NAME :
{
2003-09-04 18:25:57 +00:00
if ( SetInnerString ( NLF_NAME , line . gettoken_str ( 1 ) ) = = PS_WARNING )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %s: specified multiple times, wasting space " ) , line . gettoken_str ( 0 ) ) ;
2003-12-17 23:22:14 +00:00
SetInnerString ( NLF_NAME_DA , line . gettoken_str ( 2 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Name: \" %s \" " ) , line . gettoken_str ( 1 ) ) ;
2003-12-17 23:22:14 +00:00
if ( * line . gettoken_str ( 2 ) )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " \" %s \" " ) , line . gettoken_str ( 2 ) ) ;
SCRIPT_MSG ( _T ( " \n " ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_CAPTION :
{
2003-09-04 18:25:57 +00:00
if ( ! cur_page )
{
if ( SetInnerString ( NLF_CAPTION , line . gettoken_str ( 1 ) ) = = PS_WARNING )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %s: specified multiple times, wasting space " ) , line . gettoken_str ( 0 ) ) ;
2003-09-04 18:25:57 +00:00
}
else
{
cur_page - > caption = add_string ( line . gettoken_str ( 1 ) ) ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Caption: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_ICON :
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Icon: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
try {
2007-10-03 17:37:56 +00:00
free_loaded_icon ( installer_icon ) ;
installer_icon = load_icon_file ( line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
}
catch ( exception & err ) {
2010-03-29 14:24:47 +00:00
ERROR_MSG ( _T ( " Error while loading icon from \" %s \" : %s \n " ) , line . gettoken_str ( 1 ) , CtoTString ( err . what ( ) ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
# ifdef NSIS_CONFIG_COMPONENTPAGE
case TOK_CHECKBITMAP :
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " CheckBitmap: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
try {
2002-11-09 13:51:40 +00:00
init_res_editor ( ) ;
2003-05-09 19:50:16 +00:00
int err = update_bitmap ( res_editor , IDB_BITMAP1 , line . gettoken_str ( 1 ) , 96 , 16 , 8 ) ;
if ( err ) {
switch ( err ) {
2003-07-12 15:19:49 +00:00
case - 1 :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: can't find bitmap \n " ) ) ;
2003-05-09 19:50:16 +00:00
break ;
case - 2 :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: invalid bitmap file - corrupted or not a bitmap \n " ) ) ;
2003-05-09 19:50:16 +00:00
break ;
case - 3 :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: bitmap isn't 96x16 in size \n " ) ) ;
2003-05-09 19:50:16 +00:00
break ;
case - 4 :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: bitmap has more than 8bpp \n " ) ) ;
2003-05-09 19:50:16 +00:00
break ;
}
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
}
catch ( exception & err ) {
2010-03-29 14:24:47 +00:00
ERROR_MSG ( _T ( " Error while replacing bitmap: %s \n " ) , CtoTString ( err . what ( ) ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
# else //NSIS_CONFIG_COMPONENTPAGE
2002-09-18 19:08:53 +00:00
case TOK_CHECKBITMAP :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_COMPONENTPAGE not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_CONFIG_COMPONENTPAGE
case TOK_DIRTEXT :
2002-09-18 19:08:53 +00:00
# ifdef NSIS_CONFIG_VISIBLE_SUPPORT
2002-08-02 10:01:35 +00:00
{
2003-09-04 18:25:57 +00:00
if ( ! cur_page ) {
if ( SetInnerString ( NLF_DIR_TEXT , line . gettoken_str ( 1 ) ) = = PS_WARNING )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %s: specified multiple times, wasting space " ) , line . gettoken_str ( 0 ) ) ;
2003-09-04 18:25:57 +00:00
if ( line . getnumtokens ( ) > 2 )
SetInnerString ( NLF_DIR_SUBTEXT , line . gettoken_str ( 2 ) ) ;
if ( line . getnumtokens ( ) > 3 )
SetInnerString ( NLF_BTN_BROWSE , line . gettoken_str ( 3 ) ) ;
if ( line . getnumtokens ( ) > 4 )
SetInnerString ( NLF_DIR_BROWSETEXT , line . gettoken_str ( 4 ) ) ;
}
else {
if ( cur_page_type ! = PAGE_DIRECTORY ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: DirText can only be used inside PageEx directory. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
cur_page - > parms [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
if ( line . getnumtokens ( ) > 2 )
cur_page - > parms [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
if ( line . getnumtokens ( ) > 3 )
cur_page - > parms [ 2 ] = add_string ( line . gettoken_str ( 3 ) ) ;
if ( line . getnumtokens ( ) > 4 )
cur_page - > parms [ 3 ] = add_string ( line . gettoken_str ( 4 ) ) ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " DirText: \" %s \" \" %s \" \" %s \" \" %s \" \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-09-18 19:08:53 +00:00
# else //NSIS_CONFIG_VISIBLE_SUPPORT
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_VISIBLE_SUPPORT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-09-18 19:08:53 +00:00
return PS_ERROR ;
# endif //!NSIS_CONFIG_VISIBLE_SUPPORT
2003-09-04 18:25:57 +00:00
case TOK_DIRVAR :
{
2003-12-24 15:54:06 +00:00
if ( cur_page_type ! = PAGE_DIRECTORY & & cur_page_type ! = PAGE_UNINSTCONFIRM ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: can't use DirVar outside of PageEx directory|uninstConfirm. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
cur_page - > parms [ 4 ] = GetUserVarIndex ( line , 1 ) + 1 ;
if ( cur_page - > parms [ 4 ] < = 0 ) PRINTHELP ( ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " DirVar: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2003-09-04 18:25:57 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2003-11-24 17:05:10 +00:00
case TOK_DIRVERIFY :
{
2003-12-24 15:54:06 +00:00
if ( cur_page_type ! = PAGE_DIRECTORY ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: can't use DirVerify outside of PageEx directory. \n " ) ) ;
2003-11-24 17:05:10 +00:00
return PS_ERROR ;
}
cur_page - > flags & = ~ PF_DIR_NO_BTN_DISABLE ;
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " auto \0 leave \0 " ) ) ;
2003-11-24 17:05:10 +00:00
if ( k = = - 1 )
PRINTHELP ( ) ;
if ( k )
cur_page - > flags | = PF_DIR_NO_BTN_DISABLE ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " DirVerify: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2003-11-24 17:05:10 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2003-11-24 17:05:10 +00:00
case TOK_GETINSTDIRERROR :
ent . which = EW_GETFLAG ;
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
ent . offsets [ 1 ] = FLAG_OFFSET ( instdir_error ) ;
return add_entry ( & ent ) ;
2002-08-02 10:01:35 +00:00
# ifdef NSIS_CONFIG_COMPONENTPAGE
case TOK_COMPTEXT :
{
2003-09-04 18:25:57 +00:00
if ( ! cur_page ) {
if ( SetInnerString ( NLF_COMP_TEXT , line . gettoken_str ( 1 ) ) = = PS_WARNING )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %s: specified multiple times, wasting space " ) , line . gettoken_str ( 0 ) ) ;
2003-09-04 18:25:57 +00:00
if ( line . getnumtokens ( ) > 2 )
SetInnerString ( NLF_COMP_SUBTEXT1 , line . gettoken_str ( 2 ) ) ;
if ( line . getnumtokens ( ) > 3 )
SetInnerString ( NLF_COMP_SUBTEXT2 , line . gettoken_str ( 3 ) ) ;
}
else {
if ( cur_page_type ! = PAGE_COMPONENTS ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: ComponentText can only be used inside PageEx components. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
cur_page - > parms [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
cur_page - > parms [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
cur_page - > parms [ 2 ] = add_string ( line . gettoken_str ( 3 ) ) ;
cur_page - > parms [ 3 ] = cur_page - > parms [ 1 ] ;
cur_page - > parms [ 4 ] = cur_page - > parms [ 2 ] ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " ComponentText: \" %s \" \" %s \" \" %s \" \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_INSTTYPE :
{
int x ;
2003-03-18 20:36:52 +00:00
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( 1 ) , _T ( " /NOCUSTOM " ) ) )
2002-08-02 10:01:35 +00:00
{
2003-09-04 18:25:57 +00:00
build_header . flags | = CH_FLAGS_NO_CUSTOM ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " InstType: disabling custom install type \n " ) ) ;
2002-08-02 10:01:35 +00:00
}
2010-03-29 14:24:47 +00:00
else if ( ! _tcsicmp ( line . gettoken_str ( 1 ) , _T ( " /COMPONENTSONLYONCUSTOM " ) ) )
2002-08-02 10:01:35 +00:00
{
2003-09-04 18:25:57 +00:00
build_header . flags | = CH_FLAGS_COMP_ONLY_ON_CUSTOM ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " InstType: making components viewable only on custom install type \n " ) ) ;
2002-08-02 10:01:35 +00:00
}
2010-03-29 14:24:47 +00:00
else if ( ! _tcsncicmp ( line . gettoken_str ( 1 ) , _T ( " /CUSTOMSTRING= " ) , 14 ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " InstType: setting custom text to: \" %s \" \n " ) , line . gettoken_str ( 1 ) + 14 ) ;
2003-09-04 18:25:57 +00:00
if ( SetInnerString ( NLF_COMP_CUSTOM , line . gettoken_str ( 1 ) + 14 ) = = PS_WARNING )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %s: specified multiple times, wasting space " ) , _T ( " InstType /CUSTOMSTRING " ) ) ;
2003-09-04 18:25:57 +00:00
}
2010-03-24 17:22:56 +00:00
else if ( line . gettoken_str ( 1 ) [ 0 ] = = _T ( ' / ' ) )
2003-09-04 18:25:57 +00:00
{
PRINTHELP ( )
2002-08-02 10:01:35 +00:00
}
else
{
2010-03-24 17:22:56 +00:00
TCHAR * itname = line . gettoken_str ( 1 ) ;
2003-09-04 18:25:57 +00:00
2010-03-29 14:24:47 +00:00
if ( ! _tcsncicmp ( itname , _T ( " un. " ) , 3 ) ) {
2003-09-04 18:25:57 +00:00
set_uninstall_mode ( 1 ) ;
itname + = 3 ;
}
for ( x = 0 ; x < NSIS_MAX_INST_TYPES & & cur_header - > install_types [ x ] ; x + + ) ;
if ( x = = NSIS_MAX_INST_TYPES )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " InstType: no more than %d install types allowed. %d specified \n " ) , NSIS_MAX_INST_TYPES , NSIS_MAX_INST_TYPES + 1 ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
2002-08-11 18:57:16 +00:00
else
2002-08-02 10:01:35 +00:00
{
2003-09-04 18:25:57 +00:00
cur_header - > install_types [ x ] = add_string ( itname ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " InstType: %s%d= \" %s \" \n " ) , uninstall_mode ? _T ( " (uninstall) " ) : _T ( " " ) , x + 1 , itname ) ;
2002-08-02 10:01:35 +00:00
}
2003-09-04 18:25:57 +00:00
set_uninstall_mode ( 0 ) ;
2002-08-02 10:01:35 +00:00
}
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
# else //NSIS_CONFIG_COMPONENTPAGE
case TOK_COMPTEXT :
case TOK_INSTTYPE :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified but NSIS_CONFIG_COMPONENTPAGE not defined \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_CONFIG_COMPONENTPAGE
# ifdef NSIS_CONFIG_LICENSEPAGE
case TOK_LICENSETEXT :
{
2003-09-04 18:25:57 +00:00
if ( ! cur_page ) {
if ( SetInnerString ( NLF_LICENSE_TEXT , line . gettoken_str ( 1 ) ) = = PS_WARNING )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %s: specified multiple times, wasting space " ) , line . gettoken_str ( 0 ) ) ;
2003-09-04 18:25:57 +00:00
SetInnerString ( NLF_LICENSE_TEXT_FSRB , line . gettoken_str ( 1 ) ) ;
SetInnerString ( NLF_LICENSE_TEXT_FSCB , line . gettoken_str ( 1 ) ) ;
if ( line . getnumtokens ( ) > 2 )
SetInnerString ( NLF_BTN_LICENSE , line . gettoken_str ( 2 ) ) ;
}
else {
if ( cur_page_type ! = PAGE_LICENSE ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: LicenseText can only be used inside PageEx license. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
cur_page - > parms [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
cur_page - > next = add_string ( line . gettoken_str ( 2 ) ) ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " LicenseText: \" %s \" \" %s \" \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_LICENSEDATA :
{
2003-09-04 18:25:57 +00:00
int idx = 0 ;
2010-03-24 17:22:56 +00:00
TCHAR * file = line . gettoken_str ( 1 ) ;
TCHAR * data = NULL ;
2003-09-04 18:25:57 +00:00
2010-03-24 17:22:56 +00:00
if ( file [ 0 ] = = _T ( ' $ ' ) & & file [ 1 ] = = _T ( ' ( ' ) )
2002-08-02 10:01:35 +00:00
{
2010-03-29 14:24:47 +00:00
TCHAR * cp = _tcsdup ( file + 2 ) ;
2004-10-15 03:59:46 +00:00
MANAGE_WITH ( cp , free ) ;
2010-03-24 17:22:56 +00:00
TCHAR * p = _tcschr ( cp , _T ( ' ) ' ) ) ;
2003-09-04 18:25:57 +00:00
if ( p & & p [ 1 ] = = 0 ) { // if string is only a language str identifier
* p = 0 ;
idx = DefineLangString ( cp , 0 ) ;
}
data = file ;
2002-08-02 10:01:35 +00:00
}
2003-09-04 18:25:57 +00:00
if ( ! idx )
2003-04-30 12:40:37 +00:00
{
2004-03-12 20:43:54 +00:00
unsigned int datalen ;
2010-03-24 17:22:56 +00:00
FILE * fp = FOPEN ( file , _T ( " rb " ) ) ;
2003-09-04 18:25:57 +00:00
if ( ! fp )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " LicenseData: open failed \" %s \" \n " ) , file ) ;
2003-09-04 18:25:57 +00:00
PRINTHELP ( )
}
2004-10-15 03:59:46 +00:00
MANAGE_WITH ( fp , fclose ) ;
2003-09-04 18:25:57 +00:00
fseek ( fp , 0 , SEEK_END ) ;
datalen = ftell ( fp ) ;
if ( ! datalen )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " LicenseData: empty license file \" %s \" \n " ) , file ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
rewind ( fp ) ;
2010-03-24 17:22:56 +00:00
data = ( TCHAR * ) malloc ( datalen + 2 * sizeof ( TCHAR ) ) ;
2003-09-12 11:16:33 +00:00
if ( ! data )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Internal compiler error #12345: LicenseData malloc(%d) failed. \n " ) , ( datalen + 2 ) * sizeof ( TCHAR ) ) ;
2003-09-12 11:16:33 +00:00
return PS_ERROR ;
}
2004-10-15 03:59:46 +00:00
//MANAGE_WITH(data, free);
2010-03-24 17:22:56 +00:00
TCHAR * ldata = ( TCHAR * ) data + 1 ;
if ( fread ( ( void * ) ldata , 1 , datalen , fp ) ! = datalen ) {
ERROR_MSG ( _T ( " LicenseData: can't read file. \n " ) ) ;
2004-10-12 19:57:18 +00:00
free ( data ) ; // TODO: fix later (orip)
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
ldata [ datalen / sizeof ( TCHAR ) ] = 0 ;
if ( ! strncmp ( ( char * ) ldata , " { \\ rtf " , sizeof ( " { \\ rtf " ) - 1 ) )
2003-09-04 18:25:57 +00:00
* data = SF_RTF ;
else
* data = SF_TEXT ;
2003-04-30 12:40:37 +00:00
}
2003-09-04 18:25:57 +00:00
if ( ! cur_page ) {
if ( SetInnerString ( NLF_LICENSE_DATA , data ) = = PS_WARNING )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %s: specified multiple times, wasting space " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-09-04 18:25:57 +00:00
else {
if ( cur_page_type ! = PAGE_LICENSE ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: LicenseData can only be used inside PageEx license. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
cur_page - > parms [ 1 ] = add_string ( data , 0 ) ;
}
2003-09-12 11:16:33 +00:00
2004-10-12 19:57:18 +00:00
if ( ! idx ) free ( data ) ; // TODO: fix later (orip)
2003-09-12 11:16:33 +00:00
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " LicenseData: \" %s \" \n " ) , file ) ;
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2003-03-26 17:47:46 +00:00
case TOK_LICENSEFORCESELECTION :
{
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " off \0 checkbox \0 radiobuttons \0 " ) ) ;
2003-03-26 17:47:46 +00:00
if ( k = = - 1 ) PRINTHELP ( )
2003-09-04 18:25:57 +00:00
if ( k < line . getnumtokens ( ) - 2 ) PRINTHELP ( )
2003-03-26 18:04:03 +00:00
2003-09-04 18:25:57 +00:00
if ( ! cur_page ) {
switch ( line . getnumtokens ( ) ) {
case 4 :
SetInnerString ( NLF_BTN_LICENSE_DISAGREE , line . gettoken_str ( 3 ) ) ;
case 3 :
SetInnerString ( NLF_BTN_LICENSE_AGREE , line . gettoken_str ( 2 ) ) ;
break ;
}
2003-03-26 17:47:46 +00:00
switch ( k ) {
2003-07-12 15:19:49 +00:00
case 0 :
2003-09-04 18:25:57 +00:00
license_res_id = IDD_LICENSE ;
2003-03-26 17:47:46 +00:00
break ;
case 1 :
2003-09-04 18:25:57 +00:00
license_res_id = IDD_LICENSE_FSCB ;
2003-03-26 17:47:46 +00:00
break ;
case 2 :
2003-09-04 18:25:57 +00:00
license_res_id = IDD_LICENSE_FSRB ;
break ;
}
}
else {
if ( cur_page_type ! = PAGE_LICENSE ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: LicenseForceSelection can only be used inside PageEx license. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
switch ( line . getnumtokens ( ) ) {
case 4 :
cur_page - > parms [ 3 ] = add_string ( line . gettoken_str ( 3 ) ) ;
case 3 :
cur_page - > parms [ 2 ] = add_string ( line . gettoken_str ( 2 ) ) ;
break ;
}
2003-03-26 17:47:46 +00:00
2003-09-04 18:25:57 +00:00
cur_page - > flags & = ~ ( PF_LICENSE_FORCE_SELECTION | PF_LICENSE_NO_FORCE_SELECTION ) ;
2003-03-26 17:47:46 +00:00
2003-09-04 18:25:57 +00:00
switch ( k ) {
2003-11-30 16:31:43 +00:00
case 0 :
2003-09-04 18:25:57 +00:00
cur_page - > dlg_id = IDD_LICENSE ;
cur_page - > flags | = PF_LICENSE_NO_FORCE_SELECTION ;
break ;
case 1 :
cur_page - > dlg_id = IDD_LICENSE_FSCB ;
cur_page - > flags | = PF_LICENSE_FORCE_SELECTION ;
break ;
case 2 :
cur_page - > dlg_id = IDD_LICENSE_FSRB ;
cur_page - > flags | = PF_LICENSE_FORCE_SELECTION ;
break ;
2003-03-26 17:47:46 +00:00
}
}
2003-09-04 18:25:57 +00:00
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " LicenseForceSelection: %s \" %s \" \" %s \" \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) ) ;
2003-03-26 17:47:46 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_LICENSEBKCOLOR :
{
2010-03-24 17:22:56 +00:00
TCHAR * p = line . gettoken_str ( 1 ) ;
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( p , _T ( " /windows " ) ) )
2003-05-25 17:51:20 +00:00
{
build_header . license_bg = - COLOR_WINDOW ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " LicenseBkColor: /windows \n " ) ) ;
2003-05-25 17:51:20 +00:00
}
2010-03-29 14:24:47 +00:00
else if ( ! _tcsicmp ( p , _T ( " /grey " ) ) | | ! _tcsicmp ( p , _T ( " /gray " ) ) )
2003-05-25 17:51:20 +00:00
{
build_header . license_bg = - COLOR_BTNFACE ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " LicenseBkColor: /grey \n " ) ) ;
2003-05-25 17:51:20 +00:00
}
else
{
2010-03-24 17:22:56 +00:00
int v = _tcstoul ( p , & p , 16 ) ;
2003-05-26 17:55:15 +00:00
build_header . license_bg = ( ( v & 0xff ) < < 16 ) | ( v & 0xff00 ) | ( ( v & 0xff0000 ) > > 16 ) ;
2003-09-04 18:25:57 +00:00
build_uninst . license_bg = build_header . license_bg ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " LicenseBkColor: %06X \n " ) , v ) ;
2003-05-26 17:55:15 +00:00
}
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
# else //!NSIS_CONFIG_LICENSEPAGE
case TOK_LICENSETEXT :
case TOK_LICENSEDATA :
case TOK_LICENSEBKCOLOR :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_LICENSEPAGE not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_CONFIG_LICENSEPAGE
# ifdef NSIS_CONFIG_SILENT_SUPPORT
case TOK_SILENTINST :
2003-03-18 20:36:52 +00:00
{
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " normal \0 silent \0 silentlog \0 " ) ) ;
2003-03-18 20:36:52 +00:00
if ( k < 0 ) PRINTHELP ( )
2002-08-02 10:01:35 +00:00
# ifndef NSIS_CONFIG_LOG
2003-03-18 20:36:52 +00:00
if ( k = = 2 )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " SilentInstall: silentlog specified, no log support compiled in (use NSIS_CONFIG_LOG) \n " ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
# endif //NSIS_CONFIG_LOG
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SilentInstall: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
# ifdef NSIS_CONFIG_LICENSEPAGE
2003-09-04 18:25:57 +00:00
if ( k & & HasUserDefined ( NLF_LICENSE_DATA ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " SilentInstall: LicenseData already specified. wasting space " ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-03-18 20:36:52 +00:00
if ( k ) {
2003-09-04 18:25:57 +00:00
build_header . flags | = CH_FLAGS_SILENT ;
2003-03-18 20:36:52 +00:00
if ( k = = 2 )
2003-09-04 18:25:57 +00:00
build_header . flags | = CH_FLAGS_SILENT_LOG ;
2003-03-18 20:36:52 +00:00
}
else {
2003-09-04 18:25:57 +00:00
build_header . flags & = ~ CH_FLAGS_SILENT ;
build_header . flags & = ~ CH_FLAGS_SILENT_LOG ;
2003-03-18 20:36:52 +00:00
}
2002-08-02 10:01:35 +00:00
# endif //NSIS_CONFIG_LICENSEPAGE
2003-03-18 20:36:52 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_SILENTUNINST :
# ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
2003-09-04 18:25:57 +00:00
{
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " normal \0 silent \0 " ) ) ;
2003-03-18 20:36:52 +00:00
if ( k < 0 ) PRINTHELP ( )
if ( k )
2003-09-04 18:25:57 +00:00
build_uninst . flags | = CH_FLAGS_SILENT ;
2003-03-18 20:36:52 +00:00
else
2003-09-04 18:25:57 +00:00
build_uninst . flags & = ~ CH_FLAGS_SILENT ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SilentUnInstall: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2003-03-18 20:36:52 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
# else
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_UNINSTALL_SUPPORT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif
2003-09-04 18:25:57 +00:00
case TOK_IFSILENT :
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 ( silent ) ;
ent . offsets [ 3 ] = ~ 0 ; //new value mask - keep flag
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " IfSilent ?%s:%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2003-09-04 18:25:57 +00:00
return add_entry ( & ent ) ;
case TOK_SETSILENT :
{
ent . which = EW_SETFLAG ;
ent . offsets [ 0 ] = FLAG_OFFSET ( silent ) ;
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " normal \0 silent \0 " ) ) ;
2003-09-04 18:25:57 +00:00
if ( k < 0 ) PRINTHELP ( )
ent . offsets [ 1 ] = add_intstring ( k ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetSilent: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2003-09-04 18:25:57 +00:00
}
return add_entry ( & ent ) ;
2002-08-02 10:01:35 +00:00
# else //!NSIS_CONFIG_SILENT_SUPPORT
case TOK_SILENTINST :
case TOK_SILENTUNINST :
2003-09-04 18:25:57 +00:00
case TOK_IFSILENT :
case TOK_SETSILENT :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_SILENT_SUPPORT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //NSIS_CONFIG_SILENT_SUPPORT
case TOK_OUTFILE :
2010-03-24 17:22:56 +00:00
_tcsnccpy ( build_output_filename , line . gettoken_str ( 1 ) , 1024 - 1 ) ;
SCRIPT_MSG ( _T ( " OutFile: \" %s \" \n " ) , build_output_filename ) ;
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_INSTDIR :
2003-06-05 20:33:33 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR * p = line . gettoken_str ( 1 ) ;
2002-09-29 20:25:15 +00:00
if ( build_header . install_directory_ptr )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %s: specified multiple times. wasting space " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-09-04 18:25:57 +00:00
build_header . install_directory_ptr = add_string ( p ) ;
2003-06-05 20:33:33 +00:00
build_header . install_directory_auto_append = 0 ;
2010-03-24 17:22:56 +00:00
TCHAR * p2 = p + _tcsclen ( p ) ;
if ( * p & & * CharPrev ( p , p2 ) ! = _T ( ' \\ ' ) )
2003-06-05 20:33:33 +00:00
{
2004-02-27 14:13:08 +00:00
// we risk hitting $\r or something like $(bla\ad) or ${bla\ad} here, but it's better
// than hitting backslashes in processed strings
2010-03-24 17:22:56 +00:00
while ( p2 > p & & * p2 ! = _T ( ' \\ ' ) )
2004-02-27 14:13:08 +00:00
p2 = CharPrev ( p , p2 ) ;
2010-03-24 17:22:56 +00:00
if ( * p2 = = _T ( ' \\ ' ) )
2003-06-05 20:33:33 +00:00
{
2004-02-27 14:13:08 +00:00
build_header . install_directory_auto_append = add_string ( p2 + 1 ) ;
2003-06-05 20:33:33 +00:00
}
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " InstallDir: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2003-06-05 20:33:33 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_INSTALLDIRREGKEY : // InstallDirRegKey
{
2002-09-29 20:25:15 +00:00
if ( build_header . install_reg_key_ptr )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %s: specified multiple times, wasting space " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
}
int k = line . gettoken_enum ( 1 , rootkeys [ 0 ] ) ;
if ( k = = - 1 ) k = line . gettoken_enum ( 1 , rootkeys [ 1 ] ) ;
if ( k = = - 1 ) PRINTHELP ( )
2010-03-27 19:20:16 +00:00
build_header . install_reg_rootkey = ( INT_PTR ) rootkey_tab [ k ] ;
2005-02-17 21:20:05 +00:00
if ( ! build_header . install_reg_rootkey ) PRINTHELP ( ) // SHCTX is invalid here
2003-09-04 18:25:57 +00:00
build_header . install_reg_key_ptr = add_string ( line . gettoken_str ( 2 ) , 0 ) ;
2010-03-24 17:22:56 +00:00
if ( line . gettoken_str ( 2 ) [ 0 ] = = _T ( ' \\ ' ) )
warning_fl ( _T ( " %s: registry path name begins with \' \\ \' , may cause problems " ) , line . gettoken_str ( 0 ) ) ;
2003-09-04 18:25:57 +00:00
build_header . install_reg_value_ptr = add_string ( line . gettoken_str ( 3 ) , 0 ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " InstallRegKey: \" %s \\ %s \\ %s \" \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_CRCCHECK :
2010-03-24 17:22:56 +00:00
build_crcchk = line . gettoken_enum ( 1 , _T ( " off \0 on \0 force \0 " ) ) ;
2002-08-02 10:01:35 +00:00
if ( build_crcchk = = - 1 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " CRCCheck: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_INSTPROGRESSFLAGS :
{
int x ;
2003-03-18 20:36:52 +00:00
int smooth = 0 ;
2003-09-04 18:25:57 +00:00
build_header . flags & = ~ CH_FLAGS_PROGRESS_COLORED ;
2002-08-02 10:01:35 +00:00
for ( x = 1 ; x < line . getnumtokens ( ) ; x + + )
{
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( x ) , _T ( " smooth " ) ) ) smooth = 1 ;
else if ( ! _tcsicmp ( line . gettoken_str ( x ) , _T ( " colored " ) ) ) build_header . flags | = CH_FLAGS_PROGRESS_COLORED ;
2002-08-02 10:01:35 +00:00
else PRINTHELP ( )
}
2003-03-18 20:36:52 +00:00
try {
init_res_editor ( ) ;
2010-04-12 16:00:17 +00:00
BYTE * dlg = res_editor - > GetResource ( RT_DIALOG , IDD_INSTFILES , NSIS_DEFAULT_LANG ) ;
2003-03-18 20:36:52 +00:00
if ( ! dlg ) throw runtime_error ( " IDD_INSTFILES doesn't exist! " ) ;
2003-04-21 13:32:34 +00:00
CDialogTemplate dt ( dlg , uDefCodePage ) ;
2003-03-18 20:36:52 +00:00
free ( dlg ) ;
DialogItemTemplate * progress = dt . GetItem ( IDC_PROGRESS ) ;
if ( ! progress ) {
throw runtime_error ( " IDC_PROGRESS doesn't exist! " ) ;
}
if ( smooth )
progress - > dwStyle | = PBS_SMOOTH ;
else
progress - > dwStyle & = ~ PBS_SMOOTH ;
DWORD dwSize ;
dlg = dt . Save ( dwSize ) ;
2010-04-12 16:00:17 +00:00
res_editor - > UpdateResource ( RT_DIALOG , IDD_INSTFILES , NSIS_DEFAULT_LANG , dlg , dwSize ) ;
2005-05-11 16:20:18 +00:00
delete [ ] dlg ;
2003-03-18 20:36:52 +00:00
}
catch ( exception & err ) {
2010-03-29 14:24:47 +00:00
ERROR_MSG ( _T ( " Error setting smooth progress bar: %s \n " ) , CtoTString ( err . what ( ) ) ) ;
2003-03-18 20:36:52 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " InstProgressFlags: smooth=%d, colored=%d \n " ) , smooth ,
2003-09-04 18:25:57 +00:00
! ! ( build_header . flags & CH_FLAGS_PROGRESS_COLORED ) ) ;
2002-08-11 18:57:16 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_AUTOCLOSE :
{
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " false \0 true \0 " ) ) ;
2003-03-18 20:36:52 +00:00
if ( k = = - 1 ) PRINTHELP ( ) ;
if ( k )
2003-09-04 18:25:57 +00:00
build_header . flags | = CH_FLAGS_AUTO_CLOSE ;
2003-03-18 20:36:52 +00:00
else
2003-09-04 18:25:57 +00:00
build_header . flags & = ~ CH_FLAGS_AUTO_CLOSE ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " AutoCloseWindow: %s \n " ) , k ? _T ( " true " ) : _T ( " false " ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_WINDOWICON :
# ifdef NSIS_CONFIG_VISIBLE_SUPPORT
2010-03-24 17:22:56 +00:00
disable_window_icon = line . gettoken_enum ( 1 , _T ( " on \0 off \0 " ) ) ;
2003-09-06 09:59:02 +00:00
if ( disable_window_icon = = - 1 ) PRINTHELP ( ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " WindowIcon: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
# else
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_VISIBLE_SUPPORT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif // NSIS_CONFIG_VISIBLE_SUPPORT
case TOK_SHOWDETAILSUNINST :
# ifndef NSIS_CONFIG_UNINSTALL_SUPPORT
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: ShowUninstDetails specified but NSIS_CONFIG_UNINSTALL_SUPPORT not defined \n " ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif
case TOK_SHOWDETAILS :
{
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " hide \0 show \0 nevershow \0 " ) ) ;
2002-08-02 10:01:35 +00:00
if ( k = = - 1 ) PRINTHELP ( )
# ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
2003-03-18 20:36:52 +00:00
if ( which_token = = TOK_SHOWDETAILSUNINST )
{
2003-09-04 18:25:57 +00:00
build_uninst . flags & = ~ ( CH_FLAGS_DETAILS_NEVERSHOW | CH_FLAGS_DETAILS_SHOWDETAILS ) ;
2003-03-18 20:36:52 +00:00
if ( k = = 1 )
2003-09-04 18:25:57 +00:00
build_uninst . flags | = CH_FLAGS_DETAILS_SHOWDETAILS ;
2003-03-18 20:36:52 +00:00
else if ( k = = 2 )
2003-09-04 18:25:57 +00:00
build_uninst . flags | = CH_FLAGS_DETAILS_NEVERSHOW ;
2003-03-18 20:36:52 +00:00
}
2002-08-11 18:57:16 +00:00
else
2002-08-02 10:01:35 +00:00
# endif
2003-03-18 20:36:52 +00:00
{
2003-09-04 18:25:57 +00:00
build_header . flags & = ~ ( CH_FLAGS_DETAILS_NEVERSHOW | CH_FLAGS_DETAILS_SHOWDETAILS ) ;
2003-03-18 20:36:52 +00:00
if ( k = = 1 )
2003-09-04 18:25:57 +00:00
build_header . flags | = CH_FLAGS_DETAILS_SHOWDETAILS ;
2003-03-18 20:36:52 +00:00
else if ( k = = 2 )
2003-09-04 18:25:57 +00:00
build_header . flags | = CH_FLAGS_DETAILS_NEVERSHOW ;
2003-03-18 20:36:52 +00:00
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %s: %s \n " ) , line . gettoken_str ( 0 ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_DIRSHOW :
2003-12-24 15:54:06 +00:00
/*{
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " show \0 hide \0 " ) ) ;
2003-03-18 20:36:52 +00:00
if ( k = = - 1 ) PRINTHELP ( ) ;
if ( k )
2003-09-04 18:25:57 +00:00
build_header . flags | = CH_FLAGS_DIR_NO_SHOW ;
2003-03-18 20:36:52 +00:00
else
2003-09-04 18:25:57 +00:00
build_header . flags & = ~ CH_FLAGS_DIR_NO_SHOW ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " DirShow: %s \n " ) , k ? _T ( " hide " ) : _T ( " show " ) ) ;
2003-12-24 15:54:06 +00:00
} */
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: DirShow doesn't currently work \n " ) ) ;
2003-12-24 15:54:06 +00:00
return PS_ERROR ;
2002-08-02 10:01:35 +00:00
case TOK_ROOTDIRINST :
{
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " true \0 false \0 " ) ) ;
2003-03-18 20:36:52 +00:00
if ( k = = - 1 ) PRINTHELP ( ) ;
if ( k )
2003-09-04 18:25:57 +00:00
build_header . flags | = CH_FLAGS_NO_ROOT_DIR ;
2003-03-18 20:36:52 +00:00
else
2003-09-04 18:25:57 +00:00
build_header . flags & = ~ CH_FLAGS_NO_ROOT_DIR ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " AllowRootDirInstall: %s \n " ) , k ? _T ( " false " ) : _T ( " true " ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2004-06-11 15:33:00 +00:00
case TOK_BGFONT :
# ifndef NSIS_SUPPORT_BGBG
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: BGFont specified but NSIS_SUPPORT_BGBG not defined \n " ) ) ;
2004-06-11 15:33:00 +00:00
return PS_ERROR ;
# else //NSIS_SUPPORT_BGBG
if ( line . getnumtokens ( ) = = 1 )
{
memcpy ( & bg_font , & bg_default_font , sizeof ( LOGFONT ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " BGFont: default font \n " ) ) ;
2004-06-11 15:33:00 +00:00
return PS_OK ;
}
LOGFONT newfont ;
newfont . lfHeight = 40 ;
newfont . lfWidth = 0 ;
newfont . lfEscapement = 0 ;
newfont . lfOrientation = 0 ;
newfont . lfWeight = FW_NORMAL ;
newfont . lfItalic = FALSE ;
newfont . lfUnderline = FALSE ;
newfont . lfStrikeOut = FALSE ;
newfont . lfCharSet = DEFAULT_CHARSET ;
newfont . lfOutPrecision = OUT_DEFAULT_PRECIS ;
newfont . lfClipPrecision = CLIP_DEFAULT_PRECIS ;
newfont . lfQuality = DEFAULT_QUALITY ;
newfont . lfPitchAndFamily = DEFAULT_PITCH ;
2010-03-24 17:22:56 +00:00
_tcsnccpy ( newfont . lfFaceName , line . gettoken_str ( 1 ) , LF_FACESIZE ) ;
2004-06-11 15:33:00 +00:00
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " BGFont: \" %s \" " ) , line . gettoken_str ( 1 ) ) ;
2004-06-11 15:33:00 +00:00
{
bool height = false ;
bool weight = false ;
for ( int i = 2 ; i < line . getnumtokens ( ) ; i + + ) {
2010-03-24 17:22:56 +00:00
TCHAR * tok = line . gettoken_str ( i ) ;
if ( tok [ 0 ] = = _T ( ' / ' ) ) {
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( tok , _T ( " /ITALIC " ) ) ) {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " /ITALIC " ) ) ;
2004-06-11 15:33:00 +00:00
newfont . lfItalic = TRUE ;
}
2010-03-29 14:24:47 +00:00
else if ( ! _tcsicmp ( tok , _T ( " /UNDERLINE " ) ) ) {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " /UNDERLINE " ) ) ;
2004-06-11 15:33:00 +00:00
newfont . lfUnderline = TRUE ;
}
2010-03-29 14:24:47 +00:00
else if ( ! _tcsicmp ( tok , _T ( " /STRIKE " ) ) ) {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " /STRIKE " ) ) ;
2004-06-11 15:33:00 +00:00
newfont . lfStrikeOut = TRUE ;
}
else {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " \n " ) ) ;
2004-06-11 15:33:00 +00:00
PRINTHELP ( ) ;
}
}
else {
if ( ! height ) {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " height=%s " ) , tok ) ;
2004-06-11 15:33:00 +00:00
newfont . lfHeight = line . gettoken_int ( i ) ;
height = true ;
}
else if ( ! weight ) {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " weight=%s " ) , tok ) ;
2004-06-11 15:33:00 +00:00
newfont . lfWeight = line . gettoken_int ( i ) ;
weight = true ;
}
else {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " \n " ) ) ;
2004-06-11 15:33:00 +00:00
PRINTHELP ( ) ;
}
}
}
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " \n " ) ) ;
2004-06-11 15:33:00 +00:00
memcpy ( & bg_font , & newfont , sizeof ( LOGFONT ) ) ;
return PS_OK ;
# endif //NSIS_SUPPORT_BGBG
2002-08-02 10:01:35 +00:00
case TOK_BGGRADIENT :
# ifndef NSIS_SUPPORT_BGBG
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: BGGradient specified but NSIS_SUPPORT_BGBG not defined \n " ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# else //NSIS_SUPPORT_BGBG
if ( line . getnumtokens ( ) = = 1 )
{
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " BGGradient: default colors \n " ) ) ;
2003-09-04 18:25:57 +00:00
build_header . bg_color1 = 0 ;
build_header . bg_color2 = RGB ( 0 , 0 , 255 ) ;
2002-08-02 10:01:35 +00:00
}
2010-03-29 14:24:47 +00:00
else if ( ! _tcsicmp ( line . gettoken_str ( 1 ) , _T ( " off " ) ) )
2002-08-02 10:01:35 +00:00
{
2004-06-11 15:33:00 +00:00
build_header . bg_color1 = build_header . bg_color2 = build_header . bg_textcolor = - 1 ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " BGGradient: off \n " ) ) ;
2002-08-02 10:01:35 +00:00
if ( line . getnumtokens ( ) > 2 ) PRINTHELP ( )
}
else
{
2010-03-24 17:22:56 +00:00
TCHAR * p = line . gettoken_str ( 1 ) ;
2002-08-02 10:01:35 +00:00
int v1 , v2 , v3 = - 1 ;
2010-03-24 17:22:56 +00:00
v1 = _tcstoul ( p , & p , 16 ) ;
2003-09-04 18:25:57 +00:00
build_header . bg_color1 = ( ( v1 & 0xff ) < < 16 ) | ( v1 & 0xff00 ) | ( ( v1 & 0xff0000 ) > > 16 ) ;
2002-08-02 10:01:35 +00:00
p = line . gettoken_str ( 2 ) ;
2010-03-24 17:22:56 +00:00
v2 = _tcstoul ( p , & p , 16 ) ;
2003-09-04 18:25:57 +00:00
build_header . bg_color2 = ( ( v2 & 0xff ) < < 16 ) | ( v2 & 0xff00 ) | ( ( v2 & 0xff0000 ) > > 16 ) ;
2002-08-02 10:01:35 +00:00
p = line . gettoken_str ( 3 ) ;
if ( * p )
{
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( p , _T ( " notext " ) ) ) build_header . bg_textcolor = - 1 ;
2002-08-02 10:01:35 +00:00
else
{
2010-03-24 17:22:56 +00:00
v3 = _tcstoul ( p , & p , 16 ) ;
2003-09-04 18:25:57 +00:00
build_header . bg_textcolor = ( ( v3 & 0xff ) < < 16 ) | ( v3 & 0xff00 ) | ( ( v3 & 0xff0000 ) > > 16 ) ;
2002-08-02 10:01:35 +00:00
}
}
2002-08-11 18:57:16 +00:00
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " BGGradient: 0x%06X->0x%06X (text=0x%06X) \n " ) , v1 , v2 , v3 ) ;
2002-08-02 10:01:35 +00:00
}
# ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
2003-09-04 18:25:57 +00:00
build_uninst . bg_color1 = build_header . bg_color1 ;
build_uninst . bg_color2 = build_header . bg_color2 ;
build_uninst . bg_textcolor = build_header . bg_textcolor ;
2002-08-02 10:01:35 +00:00
# endif //NSIS_CONFIG_UNINSTALL_SUPPORT
# endif //NSIS_SUPPORT_BGBG
2003-12-24 15:54:06 +00:00
return PS_OK ;
2003-09-04 18:25:57 +00:00
# ifdef NSIS_CONFIG_VISIBLE_SUPPORT
2002-08-02 10:01:35 +00:00
case TOK_INSTCOLORS :
2003-09-04 18:25:57 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR * p = line . gettoken_str ( 1 ) ;
if ( p [ 0 ] = = _T ( ' / ' ) )
2002-08-02 10:01:35 +00:00
{
2010-03-29 14:24:47 +00:00
if ( _tcsicmp ( p , _T ( " /windows " ) ) | | line . getnumtokens ( ) ! = 2 ) PRINTHELP ( )
2003-09-04 18:25:57 +00:00
build_header . lb_fg = build_header . lb_bg = - 1 ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " InstallColors: windows default colors \n " ) ) ;
2003-09-04 18:25:57 +00:00
}
else
{
int v1 , v2 ;
if ( line . getnumtokens ( ) ! = 3 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
v1 = _tcstoul ( p , & p , 16 ) ;
2003-09-04 18:25:57 +00:00
build_header . lb_fg = ( ( v1 & 0xff ) < < 16 ) | ( v1 & 0xff00 ) | ( ( v1 & 0xff0000 ) > > 16 ) ;
p = line . gettoken_str ( 2 ) ;
2010-03-24 17:22:56 +00:00
v2 = _tcstoul ( p , & p , 16 ) ;
2003-09-04 18:25:57 +00:00
build_header . lb_bg = ( ( v2 & 0xff ) < < 16 ) | ( v2 & 0xff00 ) | ( ( v2 & 0xff0000 ) > > 16 ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " InstallColors: fg=%06X bg=%06X \n " ) , v1 , v2 ) ;
2003-09-04 18:25:57 +00:00
}
2002-08-02 10:01:35 +00:00
# ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
2003-09-04 18:25:57 +00:00
build_uninst . lb_fg = build_header . lb_fg ;
build_uninst . lb_bg = build_header . lb_bg ;
2002-08-02 10:01:35 +00:00
# endif
2003-09-04 18:25:57 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-22 21:53:54 +00:00
case TOK_XPSTYLE :
2006-09-16 13:38:21 +00:00
{
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " on \0 off \0 " ) ) ;
2002-08-02 10:01:35 +00:00
if ( k = = - 1 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " XPStyle: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2006-09-16 13:38:21 +00:00
if ( ! k )
manifest_comctl = manifest : : comctl_xp ;
else
manifest_comctl = manifest : : comctl_old ;
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-22 21:53:54 +00:00
case TOK_CHANGEUI :
try {
2002-09-02 11:28:36 +00:00
DWORD dwSize ;
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " all \0 IDD_LICENSE \0 IDD_DIR \0 IDD_SELCOM \0 IDD_INST \0 IDD_INSTFILES \0 IDD_UNINST \0 IDD_VERIFY \0 IDD_LICENSE_FSRB \0 IDD_LICENSE_FSCB \0 " ) ) ;
2002-08-06 11:24:49 +00:00
if ( k < 0 ) PRINTHELP ( ) ;
2010-03-24 17:22:56 +00:00
FILE * fui = FOPEN ( line . gettoken_str ( 2 ) , _T ( " rb " ) ) ;
2004-03-29 20:21:00 +00:00
if ( ! fui ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: Can't open \" %s \" ! \n " ) , line . gettoken_str ( 2 ) ) ;
2004-03-29 20:21:00 +00:00
return PS_ERROR ;
}
2004-10-15 03:59:46 +00:00
MANAGE_WITH ( fui , fclose ) ;
2004-03-29 20:21:00 +00:00
fseek ( fui , 0 , SEEK_END ) ;
unsigned int len = ftell ( fui ) ;
fseek ( fui , 0 , SEEK_SET ) ;
LPBYTE ui = ( LPBYTE ) malloc ( len ) ;
if ( ! ui ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Internal compiler error #12345: malloc(%d) failed \n " ) , len ) ;
2004-03-29 20:21:00 +00:00
extern void quit ( ) ; quit ( ) ;
}
2004-10-15 03:59:46 +00:00
MANAGE_WITH ( ui , free ) ;
2004-03-29 20:21:00 +00:00
if ( fread ( ui , 1 , len , fui ) ! = len ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: Can't read \" %s \" ! \n " ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
2004-03-29 20:21:00 +00:00
CResourceEditor * uire = new CResourceEditor ( ui , len ) ;
2002-08-06 11:24:49 +00:00
2002-11-09 13:51:40 +00:00
init_res_editor ( ) ;
2002-08-06 11:24:49 +00:00
// Search for required items
2010-04-12 16:00:17 +00:00
# define GET(x) dlg = uire->GetResource(RT_DIALOG, x, 0); if (!dlg) return PS_ERROR; CDialogTemplate UIDlg(dlg, uDefCodePage);
# define SEARCH(x) if (!UIDlg.GetItem(x)) {ERROR_MSG(_T("Error: Can't find %s (%u) in the custom UI!\n"), _T(#x), x);delete [] dlg;delete uire;return PS_ERROR;}
# define SAVE(x) dwSize = UIDlg.GetSize(); res_editor->UpdateResource(RT_DIALOG, x, NSIS_DEFAULT_LANG, dlg, dwSize); delete [] dlg;
2002-08-06 11:24:49 +00:00
2004-03-29 20:21:00 +00:00
LPBYTE dlg = NULL ;
2002-08-06 11:24:49 +00:00
if ( k = = 0 | | k = = 1 ) {
2004-03-29 20:21:00 +00:00
GET ( IDD_LICENSE ) ;
2002-08-06 11:24:49 +00:00
SEARCH ( IDC_EDIT1 ) ;
2002-09-02 11:28:36 +00:00
SAVE ( IDD_LICENSE ) ;
2002-08-02 10:01:35 +00:00
}
2002-08-06 11:24:49 +00:00
if ( k = = 0 | | k = = 2 ) {
2004-03-29 20:21:00 +00:00
GET ( IDD_DIR ) ;
2002-08-06 11:24:49 +00:00
SEARCH ( IDC_DIR ) ;
SEARCH ( IDC_BROWSE ) ;
2002-08-21 19:09:09 +00:00
# ifdef NSIS_CONFIG_LOG
2002-08-06 11:24:49 +00:00
SEARCH ( IDC_CHECK1 ) ;
2002-08-21 19:09:09 +00:00
# endif
2002-09-02 11:28:36 +00:00
SAVE ( IDD_DIR ) ;
2002-08-02 10:01:35 +00:00
}
2002-08-06 11:24:49 +00:00
if ( k = = 0 | | k = = 3 ) {
2004-03-29 20:21:00 +00:00
GET ( IDD_SELCOM ) ;
2002-08-06 11:24:49 +00:00
SEARCH ( IDC_TREE1 ) ;
SEARCH ( IDC_COMBO1 ) ;
2002-09-02 11:28:36 +00:00
SAVE ( IDD_SELCOM ) ;
2002-08-06 11:24:49 +00:00
}
2002-08-02 10:01:35 +00:00
2002-08-06 11:24:49 +00:00
if ( k = = 0 | | k = = 4 ) {
2004-03-29 20:21:00 +00:00
GET ( IDD_INST ) ;
2002-08-06 11:24:49 +00:00
SEARCH ( IDC_BACK ) ;
SEARCH ( IDC_CHILDRECT ) ;
SEARCH ( IDC_VERSTR ) ;
SEARCH ( IDOK ) ;
SEARCH ( IDCANCEL ) ;
// Search for bitmap holder (default for SetBrandingImage)
2002-11-04 19:19:55 +00:00
branding_image_found = false ;
2002-08-06 11:24:49 +00:00
DialogItemTemplate * dlgItem = 0 ;
2004-03-12 20:43:54 +00:00
for ( int i = 0 ; ( dlgItem = UIDlg . GetItemByIdx ( i ) ) ; i + + ) {
2007-02-17 15:11:12 +00:00
bool check = false ;
if ( IS_INTRESOURCE ( dlgItem - > szClass ) ) {
if ( dlgItem - > szClass = = MAKEINTRESOURCEW ( 0x0082 ) ) {
check = true ;
}
} else {
2010-03-29 14:24:47 +00:00
check = _wcsicmp ( dlgItem - > szClass , L " Static " ) = = 0 ;
2007-02-17 15:11:12 +00:00
}
if ( check ) {
2005-07-23 13:07:04 +00:00
if ( ( dlgItem - > dwStyle & SS_BITMAP ) = = SS_BITMAP ) {
branding_image_found = true ;
branding_image_id = dlgItem - > wId ;
break ;
2002-08-02 10:01:35 +00:00
}
}
}
2002-08-06 11:24:49 +00:00
2002-09-02 11:28:36 +00:00
SAVE ( IDD_INST ) ;
2002-08-06 11:24:49 +00:00
}
if ( k = = 0 | | k = = 5 ) {
2004-03-29 20:21:00 +00:00
GET ( IDD_INSTFILES ) ;
2002-08-06 11:24:49 +00:00
SEARCH ( IDC_LIST1 ) ;
2003-03-18 20:36:52 +00:00
SEARCH ( IDC_PROGRESS ) ;
2002-08-06 11:24:49 +00:00
SEARCH ( IDC_SHOWDETAILS ) ;
2002-09-02 11:28:36 +00:00
SAVE ( IDD_INSTFILES ) ;
2002-08-06 11:24:49 +00:00
}
if ( k = = 0 | | k = = 6 ) {
2004-03-29 20:21:00 +00:00
GET ( IDD_UNINST ) ;
2002-08-06 11:24:49 +00:00
SEARCH ( IDC_EDIT1 ) ;
2002-09-02 11:28:36 +00:00
SAVE ( IDD_UNINST ) ;
2002-08-02 10:01:35 +00:00
}
2002-08-02 18:37:30 +00:00
2002-08-22 21:53:54 +00:00
if ( k = = 0 | | k = = 7 ) {
2004-03-29 20:21:00 +00:00
GET ( IDD_VERIFY ) ;
2002-08-22 21:53:54 +00:00
SEARCH ( IDC_STR ) ;
2004-03-29 20:21:00 +00:00
SAVE ( IDD_VERIFY ) ;
2002-08-22 21:53:54 +00:00
}
2003-09-04 18:25:57 +00:00
if ( k = = 0 | | k = = 8 ) {
2004-03-29 20:21:00 +00:00
GET ( IDD_LICENSE_FSRB ) ;
2003-09-04 18:25:57 +00:00
SEARCH ( IDC_EDIT1 ) ;
SEARCH ( IDC_LICENSEAGREE ) ;
SEARCH ( IDC_LICENSEDISAGREE ) ;
SAVE ( IDD_LICENSE_FSRB ) ;
2002-08-06 11:24:49 +00:00
}
2003-09-04 18:25:57 +00:00
if ( k = = 0 | | k = = 9 ) {
2004-03-29 20:21:00 +00:00
GET ( IDD_LICENSE_FSCB ) ;
2003-09-04 18:25:57 +00:00
SEARCH ( IDC_EDIT1 ) ;
SEARCH ( IDC_LICENSEAGREE ) ;
SAVE ( IDD_LICENSE_FSCB ) ;
}
2004-03-29 20:21:00 +00:00
delete uire ;
2003-09-04 18:25:57 +00:00
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " ChangeUI: %s %s%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , branding_image_found ? _T ( " (branding image holder found) " ) : _T ( " " ) ) ;
2002-08-07 15:14:40 +00:00
}
2003-09-04 18:25:57 +00:00
catch ( exception & err ) {
2010-03-29 14:24:47 +00:00
ERROR_MSG ( _T ( " Error while changing UI: %s \n " ) , CtoTString ( err . what ( ) ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-22 21:53:54 +00:00
case TOK_ADDBRANDINGIMAGE :
2004-03-29 20:21:00 +00:00
# ifdef _WIN32
2003-09-04 18:25:57 +00:00
try {
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " top \0 left \0 bottom \0 right \0 " ) ) ;
2002-08-02 10:01:35 +00:00
int wh = line . gettoken_int ( 2 ) ;
2003-03-18 13:53:29 +00:00
if ( k = = - 1 ) PRINTHELP ( ) ;
int padding = 2 ;
if ( line . getnumtokens ( ) = = 4 )
padding = line . gettoken_int ( 3 ) ;
2002-08-11 18:57:16 +00:00
2002-11-09 13:51:40 +00:00
init_res_editor ( ) ;
2010-04-12 16:00:17 +00:00
BYTE * dlg = res_editor - > GetResource ( RT_DIALOG , IDD_INST , NSIS_DEFAULT_LANG ) ;
2002-08-02 10:01:35 +00:00
2005-03-19 17:06:45 +00:00
CDialogTemplate dt ( dlg , uDefCodePage ) ;
res_editor - > FreeResource ( dlg ) ;
2002-08-02 10:01:35 +00:00
DialogItemTemplate brandingCtl = { 0 , } ;
brandingCtl . dwStyle = SS_BITMAP | WS_CHILD | WS_VISIBLE ;
2003-03-18 13:53:29 +00:00
brandingCtl . sX = padding ;
brandingCtl . sY = padding ;
2007-02-17 15:11:12 +00:00
brandingCtl . szClass = MAKEINTRESOURCEW ( 0x0082 ) ;
brandingCtl . szTitle = NULL ;
2002-08-02 10:01:35 +00:00
brandingCtl . wId = IDC_BRANDIMAGE ;
brandingCtl . sHeight = wh ;
brandingCtl . sWidth = wh ;
dt . PixelsToDlgUnits ( brandingCtl . sWidth , brandingCtl . sHeight ) ;
2003-03-18 13:53:29 +00:00
if ( k % 2 ) {
// left (1) / right (3)
2002-08-02 10:01:35 +00:00
2003-03-18 13:53:29 +00:00
if ( k & 2 ) // right
brandingCtl . sX + = dt . GetWidth ( ) ;
else // left
dt . MoveAll ( brandingCtl . sWidth + ( padding * 2 ) , 0 ) ;
2004-12-10 11:09:10 +00:00
2003-03-18 13:53:29 +00:00
dt . Resize ( brandingCtl . sWidth + ( padding * 2 ) , 0 ) ;
brandingCtl . sHeight = dt . GetHeight ( ) - ( padding * 2 ) ;
2002-08-02 10:01:35 +00:00
}
else {
2003-03-18 13:53:29 +00:00
// top (0) / bottom (2)
if ( k & 2 ) // bottom
brandingCtl . sY + = dt . GetHeight ( ) ;
else // top
dt . MoveAll ( 0 , brandingCtl . sHeight + ( padding * 2 ) ) ;
dt . Resize ( 0 , brandingCtl . sHeight + ( padding * 2 ) ) ;
2002-08-02 10:01:35 +00:00
2003-03-18 13:53:29 +00:00
brandingCtl . sWidth = dt . GetWidth ( ) - ( padding * 2 ) ;
2002-08-02 10:01:35 +00:00
}
dt . AddItem ( brandingCtl ) ;
DWORD dwDlgSize ;
dlg = dt . Save ( dwDlgSize ) ;
2010-04-12 16:00:17 +00:00
res_editor - > UpdateResource ( RT_DIALOG , IDD_INST , NSIS_DEFAULT_LANG , dlg , dwDlgSize ) ;
2002-08-02 10:01:35 +00:00
2005-03-19 17:06:45 +00:00
delete [ ] dlg ;
2002-08-02 10:01:35 +00:00
dt . DlgUnitsToPixels ( brandingCtl . sWidth , brandingCtl . sHeight ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " AddBrandingImage: %s %ux%u \n " ) , line . gettoken_str ( 1 ) , brandingCtl . sWidth , brandingCtl . sHeight ) ;
2002-08-02 10:01:35 +00:00
branding_image_found = true ;
branding_image_id = IDC_BRANDIMAGE ;
}
catch ( exception & err ) {
2010-03-29 14:24:47 +00:00
ERROR_MSG ( _T ( " Error while adding image branding support: %s \n " ) , CtoTString ( err . what ( ) ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2004-03-29 20:21:00 +00:00
# else
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: AddBrandingImage is disabled for non Win32 platforms. \n " ) ) ;
2004-03-29 20:21:00 +00:00
return PS_ERROR ;
# endif
2002-08-22 21:53:54 +00:00
case TOK_SETFONT :
2003-09-06 09:59:02 +00:00
{
2010-03-29 14:24:47 +00:00
if ( ! _tcsncicmp ( line . gettoken_str ( 1 ) , _T ( " /LANG= " ) , 6 ) )
2003-09-06 09:59:02 +00:00
{
2010-03-24 17:22:56 +00:00
LANGID lang_id = _ttoi ( line . gettoken_str ( 1 ) + 6 ) ;
2003-09-06 09:59:02 +00:00
LanguageTable * table = GetLangTable ( lang_id ) ;
2010-03-24 17:22:56 +00:00
table - > nlf . m_szFont = ( TCHAR * ) malloc ( ( _tcsclen ( line . gettoken_str ( 2 ) ) + 1 ) * sizeof ( TCHAR ) ) ;
_tcscpy ( table - > nlf . m_szFont , line . gettoken_str ( 2 ) ) ;
2003-09-06 09:59:02 +00:00
table - > nlf . m_iFontSize = line . gettoken_int ( 3 ) ;
2002-08-02 10:01:35 +00:00
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetFont: lang=%d \" %s \" %s \n " ) , lang_id , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-09-06 09:59:02 +00:00
else
{
2010-03-30 17:50:08 +00:00
_tcsnccpy ( build_font , line . gettoken_str ( 1 ) , COUNTOF ( build_font ) ) ;
2003-09-06 09:59:02 +00:00
build_font_size = line . gettoken_int ( 2 ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetFont: \" %s \" %s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-09-06 09:59:02 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
# else
2006-09-16 13:41:17 +00:00
case TOK_INSTCOLORS :
case TOK_XPSTYLE :
case TOK_CHANGEUI :
case TOK_ADDBRANDINGIMAGE :
case TOK_SETFONT :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_VISIBLE_SUPPORT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2006-09-16 13:41:17 +00:00
return PS_ERROR ;
2002-08-02 10:01:35 +00:00
# endif // NSIS_CONFIG_VISIBLE_SUPPORT
2006-09-16 14:06:45 +00:00
case TOK_REQEXECLEVEL :
{
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " none \0 user \0 highest \0 admin \0 " ) ) ;
2006-09-16 14:06:45 +00:00
switch ( k )
{
case 0 :
manifest_exec_level = manifest : : exec_level_none ;
break ;
case 1 :
manifest_exec_level = manifest : : exec_level_user ;
break ;
case 2 :
2006-11-10 14:54:23 +00:00
manifest_exec_level = manifest : : exec_level_highest ;
break ;
case 3 :
2006-09-16 14:06:45 +00:00
manifest_exec_level = manifest : : exec_level_admin ;
break ;
default :
PRINTHELP ( ) ;
}
}
return PS_OK ;
2002-08-02 10:01:35 +00:00
// Ability to change compression methods from within the script
case TOK_SETCOMPRESSOR :
2002-09-18 19:08:53 +00:00
# ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
2003-09-05 11:46:48 +00:00
{
if ( build_compressor_set ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: can't change compressor after data already got compressed or header already changed! \n " ) ) ;
2003-09-05 11:46:48 +00:00
return PS_ERROR ;
}
2005-04-02 12:04:07 +00:00
if ( build_compressor_final )
{
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " SetCompressor ignored due to previous call with the /FINAL switch " ) ) ;
2005-04-02 12:04:07 +00:00
return PS_OK ;
}
int a = 1 ;
build_compress_whole = false ;
2010-03-24 17:22:56 +00:00
while ( line . gettoken_str ( a ) [ 0 ] = = _T ( ' / ' ) )
2002-08-02 10:01:35 +00:00
{
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( a ) , _T ( " /FINAL " ) ) )
2003-09-05 11:46:48 +00:00
{
build_compressor_final = true ;
a + + ;
2002-08-02 10:01:35 +00:00
}
2010-03-29 14:24:47 +00:00
else if ( ! _tcsicmp ( line . gettoken_str ( a ) , _T ( " /SOLID " ) ) )
2003-09-05 11:46:48 +00:00
{
2005-04-02 12:04:07 +00:00
build_compress_whole = true ;
a + + ;
2003-09-05 11:46:48 +00:00
}
2005-04-23 20:18:54 +00:00
else PRINTHELP ( ) ;
2005-04-02 12:04:07 +00:00
}
2004-10-02 18:04:41 +00:00
2005-04-02 12:04:07 +00:00
if ( a ! = line . getnumtokens ( ) - 1 )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " %s expects %d parameters, got %d. \n " ) , line . gettoken_str ( 0 ) , a + 1 , line . getnumtokens ( ) ) ;
2005-04-02 12:04:07 +00:00
PRINTHELP ( ) ;
}
2004-10-02 18:04:41 +00:00
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( a , _T ( " zlib \0 bzip2 \0 lzma \0 " ) ) ;
2005-04-02 12:04:07 +00:00
switch ( k ) {
case 0 :
compressor = & zlib_compressor ;
break ;
case 1 :
compressor = & bzip2_compressor ;
2003-11-24 00:08:58 +00:00
break ;
2004-10-02 18:04:41 +00:00
2005-04-02 12:04:07 +00:00
case 2 :
compressor = & lzma_compressor ;
break ;
default :
PRINTHELP ( ) ;
2002-08-02 10:01:35 +00:00
}
2005-04-02 12:04:07 +00:00
2010-03-24 17:22:56 +00:00
tstring compressor_name = line . gettoken_str ( a ) ;
2005-08-27 19:56:00 +00:00
compressor_name = lowercase ( compressor_name ) ;
2005-04-02 12:04:07 +00:00
if ( set_compressor ( compressor_name , build_compress_whole ) ! = PS_OK )
2003-09-05 11:46:48 +00:00
{
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetCompressor: error loading stub for \" %s \" compressor. \n " ) , compressor_name . c_str ( ) ) ;
2005-04-02 12:04:07 +00:00
return PS_ERROR ;
2003-09-05 11:46:48 +00:00
}
2005-04-02 12:04:07 +00:00
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetCompressor: %s%s%s \n " ) , build_compressor_final ? _T ( " /FINAL " ) : _T ( " " ) , build_compress_whole ? _T ( " /SOLID " ) : _T ( " " ) , line . gettoken_str ( a ) ) ;
2003-09-05 11:46:48 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-09-18 19:08:53 +00:00
# else //NSIS_CONFIG_COMPRESSION_SUPPORT
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_COMPRESSION_SUPPORT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-09-18 19:08:53 +00:00
return PS_ERROR ;
# endif //NSIS_CONFIG_COMPRESSION_SUPPORT
2002-08-02 18:37:30 +00:00
case TOK_LOADNLF :
{
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " LoadLanguageFile: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2003-06-12 00:06:23 +00:00
2003-09-04 18:25:57 +00:00
LanguageTable * table = LoadLangFile ( line . gettoken_str ( 1 ) ) ;
2003-06-12 00:06:23 +00:00
2003-09-04 18:25:57 +00:00
if ( ! table )
2002-08-02 20:11:36 +00:00
return PS_ERROR ;
2003-09-04 18:25:57 +00:00
if ( ! defcodepage_set )
{
uDefCodePage = table - > nlf . m_uCodePage ;
defcodepage_set = true ;
}
last_used_lang = table - > lang_id ;
// define LANG_LangName as "####" (lang id)
// for example ${LANG_ENGLISH} = 1033
2010-03-24 17:22:56 +00:00
TCHAR lang_id [ 16 ] ;
TCHAR lang_cp [ 16 ] ;
TCHAR lang_name [ 1024 ] ;
wsprintf ( lang_name , _T ( " LANG_%s " ) , table - > nlf . m_szName ) ;
wsprintf ( lang_id , _T ( " %u " ) , table - > lang_id ) ;
wsprintf ( lang_cp , _T ( " %u " ) , table - > nlf . m_uCodePage ) ;
2003-09-04 18:25:57 +00:00
definedlist . add ( lang_name , lang_id ) ;
2010-03-24 17:22:56 +00:00
wsprintf ( lang_name , _T ( " LANG_%s_CP " ) , table - > nlf . m_szName ) ;
2007-04-14 23:03:40 +00:00
definedlist . add ( lang_name , lang_cp ) ;
2002-08-02 18:37:30 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
// preprocessor-ish (ifdef/ifndef/else/endif are handled one step out from here)
///////////////////////////////////////////////////////////////////////////////
case TOK_P_DEFINE :
2004-11-26 18:49:50 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR * define = line . gettoken_str ( 1 ) ;
TCHAR * value ;
2008-07-13 00:37:11 +00:00
GrowBuf file_buf ;
2010-03-24 17:22:56 +00:00
TCHAR datebuf [ 256 ] ;
TCHAR mathbuf [ 256 ] ;
2004-11-26 18:49:50 +00:00
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( define , _T ( " /date " ) ) | | ! _tcsicmp ( define , _T ( " /utcdate " ) ) ) {
2004-11-26 18:49:50 +00:00
if ( line . getnumtokens ( ) ! = 4 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
TCHAR * date_type = define ;
2006-03-28 18:20:28 +00:00
2004-11-26 18:49:50 +00:00
define = line . gettoken_str ( 2 ) ;
value = line . gettoken_str ( 3 ) ;
time_t rawtime ;
2006-02-24 15:52:40 +00:00
time ( & rawtime ) ;
2004-11-26 18:49:50 +00:00
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( date_type , _T ( " /utcdate " ) ) )
2006-03-28 18:20:28 +00:00
rawtime = mktime ( gmtime ( & rawtime ) ) ;
2004-11-26 18:49:50 +00:00
datebuf [ 0 ] = 0 ;
2010-03-30 17:50:08 +00:00
size_t s = _tcsftime ( datebuf , COUNTOF ( datebuf ) , value , localtime ( & rawtime ) ) ;
2004-12-10 11:09:10 +00:00
2007-07-23 18:43:07 +00:00
if ( s = = 0 )
2004-11-26 18:49:50 +00:00
datebuf [ 0 ] = 0 ;
else
2010-03-30 17:50:08 +00:00
datebuf [ max ( s , COUNTOF ( datebuf ) - 1 ) ] = 0 ;
2004-11-26 18:49:50 +00:00
value = datebuf ;
2010-03-29 14:24:47 +00:00
} else if ( ! _tcsicmp ( define , _T ( " /file " ) ) | | ! _tcsicmp ( define , _T ( " /file_noerr " ) ) ) {
2009-03-10 20:14:10 +00:00
if ( line . getnumtokens ( ) ! = 4 ) PRINTHELP ( )
define = line . gettoken_str ( 2 ) ;
2010-03-24 17:22:56 +00:00
const TCHAR * filename = line . gettoken_str ( 3 ) ;
2010-03-29 14:24:47 +00:00
FILE * fp = FOPENTEXT ( filename , _T ( " r " ) ) ;
2009-03-10 20:14:10 +00:00
2010-03-29 14:24:47 +00:00
if ( ! fp & & _tcsicmp ( define , _T ( " /file_noerr " ) ) ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !define /file: file not found ( \" %s \" ) \n " ) , filename ) ;
2009-03-10 20:14:10 +00:00
return PS_ERROR ;
}
if ( fp ) {
2010-03-24 17:22:56 +00:00
TCHAR str [ MAX_LINELENGTH ] ;
2009-03-10 20:14:10 +00:00
for ( ; ; ) {
2010-03-24 17:22:56 +00:00
TCHAR * p = str ;
2009-03-10 20:14:10 +00:00
* p = 0 ;
2010-04-12 16:00:17 +00:00
_fgetts ( str , MAX_LINELENGTH , fp ) ;
2009-03-10 20:14:10 +00:00
linecnt + + ;
if ( feof ( fp ) & & ! str [ 0 ] ) break ;
while ( * p ) p + + ;
if ( p > str ) p - - ;
2010-03-24 17:22:56 +00:00
while ( p > = str & & ( * p = = _T ( ' \r ' ) | | * p = = _T ( ' \n ' ) ) ) p - - ;
2009-03-10 20:14:10 +00:00
* + + p = 0 ;
2010-03-24 17:22:56 +00:00
if ( file_buf . getlen ( ) ) file_buf . add ( _T ( " \n " ) , 1 ) ;
2010-03-29 14:24:47 +00:00
file_buf . add ( str , _tcsclen ( str ) ) ;
2009-03-10 20:14:10 +00:00
}
fclose ( fp ) ;
}
2010-03-24 17:22:56 +00:00
file_buf . add ( _T ( " \0 " ) , 1 ) ;
value = ( TCHAR * ) file_buf . get ( ) ;
2004-11-26 18:49:50 +00:00
2010-03-29 14:24:47 +00:00
} else if ( ! _tcsicmp ( define , _T ( " /math " ) ) ) {
2006-02-24 15:52:40 +00:00
int value1 ;
int value2 ;
2010-03-24 17:22:56 +00:00
TCHAR * mathop ;
2006-02-24 15:52:40 +00:00
if ( line . getnumtokens ( ) ! = 6 ) PRINTHELP ( )
define = line . gettoken_str ( 2 ) ;
2006-02-24 15:55:51 +00:00
value1 = line . gettoken_int ( 3 ) ;
2006-02-24 15:52:40 +00:00
mathop = line . gettoken_str ( 4 ) ;
value2 = line . gettoken_int ( 5 ) ;
2006-02-24 16:00:23 +00:00
value = mathbuf ;
2006-02-24 15:52:40 +00:00
2010-03-24 17:22:56 +00:00
if ( ! _tcscmp ( mathop , _T ( " + " ) ) ) {
_stprintf ( value , _T ( " %d " ) , value1 + value2 ) ;
} else if ( ! _tcscmp ( mathop , _T ( " - " ) ) ) {
_stprintf ( value , _T ( " %d " ) , value1 - value2 ) ;
} else if ( ! _tcscmp ( mathop , _T ( " * " ) ) ) {
_stprintf ( value , _T ( " %d " ) , value1 * value2 ) ;
} else if ( ! _tcscmp ( mathop , _T ( " & " ) ) ) {
_stprintf ( value , _T ( " %d " ) , value1 & value2 ) ;
} else if ( ! _tcscmp ( mathop , _T ( " | " ) ) ) {
_stprintf ( value , _T ( " %d " ) , value1 | value2 ) ;
} else if ( ! _tcscmp ( mathop , _T ( " ^ " ) ) ) {
_stprintf ( value , _T ( " %d " ) , value1 ^ value2 ) ;
} else if ( ! _tcscmp ( mathop , _T ( " / " ) ) ) {
2006-02-24 15:52:40 +00:00
if ( value2 = = 0 ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !define /math: division by zero! ( \" %i / %i \" ) \n " ) , value1 , value2 ) ;
2006-02-24 15:52:40 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
_stprintf ( value , _T ( " %d " ) , value1 / value2 ) ;
} else if ( ! _tcscmp ( mathop , _T ( " % " ) ) ) {
2006-02-24 15:52:40 +00:00
if ( value2 = = 0 ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !define /math: division by zero! ( \" %i %% %i \" ) \n " ) , value1 , value2 ) ;
2006-02-24 15:52:40 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
_stprintf ( value , _T ( " %d " ) , value1 % value2 ) ;
2006-02-24 15:52:40 +00:00
} else PRINTHELP ( )
2004-11-26 18:49:50 +00:00
} else {
if ( line . getnumtokens ( ) = = 4 ) PRINTHELP ( )
value = line . gettoken_str ( 2 ) ;
}
if ( definedlist . add ( define , value ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !define: \" %s \" already defined! \n " ) , define ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " !define: \" %s \" = \" %s \" \n " ) , define , value ) ;
2004-11-26 18:49:50 +00:00
}
2002-08-02 10:01:35 +00:00
return PS_OK ;
case TOK_P_UNDEF :
if ( definedlist . del ( line . gettoken_str ( 1 ) ) )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !undef: \" %s \" not defined! \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " !undef: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_OK ;
case TOK_P_PACKEXEHEADER :
2010-03-30 17:50:08 +00:00
_tcsnccpy ( build_packname , line . gettoken_str ( 1 ) , COUNTOF ( build_packname ) - 1 ) ;
_tcsnccpy ( build_packcmd , line . gettoken_str ( 2 ) , COUNTOF ( build_packcmd ) - 1 ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " !packhdr: filename= \" %s \" , command= \" %s \" \n " ) ,
2002-08-02 10:01:35 +00:00
build_packname , build_packcmd ) ;
return PS_OK ;
case TOK_P_SYSTEMEXEC :
{
2010-03-24 17:22:56 +00:00
TCHAR * exec = line . gettoken_str ( 1 ) ;
int comp = line . gettoken_enum ( 2 , _T ( " < \0 > \0 <> \0 = \0 ignore \0 " ) ) ;
2002-12-30 15:33:53 +00:00
if ( line . getnumtokens ( ) = = 2 ) comp = 4 ;
2002-08-02 10:01:35 +00:00
if ( comp = = - 1 & & line . getnumtokens ( ) = = 3 ) comp = 4 ;
if ( comp = = - 1 ) PRINTHELP ( )
int success = 0 ;
int cmpv = line . gettoken_int ( 3 , & success ) ;
if ( ! success & & comp ! = 4 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " !system: \" %s \" \n " ) , exec ) ;
2004-08-20 15:40:38 +00:00
# ifdef _WIN32
2006-07-30 10:29:23 +00:00
int ret = sane_system ( exec ) ;
2004-08-20 15:40:38 +00:00
# else
2009-03-28 09:47:26 +00:00
PATH_CONVERT ( exec ) ;
int ret = system ( exec ) ;
2004-08-20 15:40:38 +00:00
# endif
2002-08-02 10:01:35 +00:00
if ( comp = = 0 & & ret < cmpv ) ;
else if ( comp = = 1 & & ret > cmpv ) ;
else if ( comp = = 2 & & ret ! = cmpv ) ;
else if ( comp = = 3 & & ret = = cmpv ) ;
else if ( comp = = 4 ) ;
else
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !system: returned %d, aborting \n " ) , ret ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " !system: returned %d \n " ) , ret ) ;
2002-08-02 10:01:35 +00:00
}
return PS_OK ;
2004-08-06 11:29:28 +00:00
case TOK_P_EXECUTE :
{
2010-03-24 17:22:56 +00:00
TCHAR * exec = line . gettoken_str ( 1 ) ;
2004-08-06 11:29:28 +00:00
# ifdef _WIN32
PROCESS_INFORMATION pi ;
STARTUPINFO si = { sizeof ( STARTUPINFO ) , } ;
if ( CreateProcess ( NULL , exec , NULL , NULL , FALSE , 0 , NULL , NULL , & si , & pi ) )
{
WaitForSingleObject ( pi . hProcess , INFINITE ) ;
CloseHandle ( pi . hThread ) ;
CloseHandle ( pi . hProcess ) ;
}
# else
2010-03-24 17:22:56 +00:00
TCHAR * execfixed = my_convert ( exec ) ;
2004-08-20 15:40:38 +00:00
system ( execfixed ) ;
my_convert_free ( execfixed ) ;
2004-08-06 11:29:28 +00:00
# endif
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " !execute: \" %s \" \n " ) , exec ) ;
2004-08-06 11:29:28 +00:00
}
2002-12-15 20:54:17 +00:00
case TOK_P_ADDINCLUDEDIR :
2006-02-23 11:27:56 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR * f = line . gettoken_str ( 1 ) ;
2009-03-28 09:47:26 +00:00
PATH_CONVERT ( f ) ;
include_dirs . add ( f , 0 ) ;
2006-02-23 11:27:56 +00:00
}
2002-12-15 20:54:17 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_P_INCLUDE :
{
2005-12-03 09:45:17 +00:00
bool required = true ;
2010-03-24 17:22:56 +00:00
TCHAR * f = line . gettoken_str ( 1 ) ;
2007-02-17 15:11:12 +00:00
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( f , _T ( " /nonfatal " ) ) ) {
2005-12-03 09:45:17 +00:00
if ( line . getnumtokens ( ) ! = 3 )
PRINTHELP ( ) ;
2007-02-17 15:11:12 +00:00
2005-12-03 09:45:17 +00:00
f = line . gettoken_str ( 2 ) ;
2007-02-17 15:11:12 +00:00
required = false ;
2005-12-03 09:45:17 +00:00
} else if ( line . getnumtokens ( ) ! = 2 ) {
PRINTHELP ( ) ;
}
2007-02-17 15:11:12 +00:00
2010-03-24 17:22:56 +00:00
TCHAR * fc = my_convert ( f ) ;
2005-07-01 21:08:48 +00:00
int included = 0 ;
2003-11-25 07:09:53 +00:00
2010-03-24 17:22:56 +00:00
tstring dir = get_dir_name ( fc ) ;
tstring spec = get_file_name ( fc ) ;
tstring basedir = dir + PLATFORM_PATH_SEPARATOR_STR ;
2005-07-01 21:08:48 +00:00
if ( dir = = spec ) {
// no path, just file name
2010-03-24 17:22:56 +00:00
dir = _T ( " . " ) ;
basedir = _T ( " " ) ;
2005-07-01 21:08:48 +00:00
}
2003-11-25 07:09:53 +00:00
2005-07-01 21:08:48 +00:00
my_convert_free ( fc ) ;
// search working directory
2009-06-06 18:32:40 +00:00
boost : : scoped_ptr < dir_reader > dr ( new_dir_reader ( ) ) ;
dr - > read ( dir ) ;
2005-07-01 21:08:48 +00:00
2009-06-06 18:32:40 +00:00
for ( dir_reader : : iterator files_itr = dr - > files ( ) . begin ( ) ;
files_itr ! = dr - > files ( ) . end ( ) ;
files_itr + + )
{
if ( ! dir_reader : : matches ( * files_itr , spec ) )
continue ;
2005-07-01 21:08:48 +00:00
2010-03-24 17:22:56 +00:00
tstring incfile = basedir + * files_itr ;
2005-07-01 21:08:48 +00:00
2010-03-24 17:22:56 +00:00
if ( includeScript ( ( TCHAR * ) incfile . c_str ( ) ) ! = PS_OK ) {
2009-06-06 18:32:40 +00:00
return PS_ERROR ;
}
2005-07-01 21:08:48 +00:00
included + + ;
2003-11-25 07:09:53 +00:00
}
2002-12-15 20:54:17 +00:00
2005-07-01 21:08:48 +00:00
if ( included )
2007-02-17 15:11:12 +00:00
return PS_OK ;
2004-03-29 20:21:00 +00:00
2005-07-01 21:08:48 +00:00
// search include dirs
2010-03-24 17:22:56 +00:00
TCHAR * incdir = include_dirs . get ( ) ;
2005-07-01 21:08:48 +00:00
int incdirs = include_dirs . getnum ( ) ;
2010-03-24 17:22:56 +00:00
for ( int i = 0 ; i < incdirs ; i + + , incdir + = _tcsclen ( incdir ) + 1 ) {
tstring curincdir = tstring ( incdir ) + PLATFORM_PATH_SEPARATOR_STR + dir ;
2005-07-01 21:08:48 +00:00
2005-10-22 13:40:52 +00:00
boost : : scoped_ptr < dir_reader > dr ( new_dir_reader ( ) ) ;
2005-07-01 21:08:48 +00:00
dr - > read ( curincdir ) ;
2005-10-22 14:46:01 +00:00
for ( dir_reader : : iterator incdir_itr = dr - > files ( ) . begin ( ) ;
incdir_itr ! = dr - > files ( ) . end ( ) ;
incdir_itr + + )
{
if ( ! dir_reader : : matches ( * incdir_itr , spec ) )
2005-07-01 21:08:48 +00:00
continue ;
2010-03-24 17:22:56 +00:00
tstring incfile = tstring ( incdir ) + PLATFORM_PATH_SEPARATOR_STR + basedir + * incdir_itr ;
2005-07-01 21:08:48 +00:00
2010-03-24 17:22:56 +00:00
if ( includeScript ( ( TCHAR * ) incfile . c_str ( ) ) ! = PS_OK ) {
2005-07-01 21:08:48 +00:00
return PS_ERROR ;
2003-11-25 07:09:53 +00:00
}
2005-07-01 21:08:48 +00:00
included + + ;
2002-12-15 20:54:17 +00:00
}
2005-07-01 21:08:48 +00:00
2006-03-02 17:12:40 +00:00
if ( included )
return PS_OK ;
2002-08-02 10:01:35 +00:00
}
2003-06-05 21:53:52 +00:00
2005-07-01 21:08:48 +00:00
// nothing found
2003-11-29 16:10:10 +00:00
if ( ! included )
{
2005-12-03 09:45:17 +00:00
if ( required ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !include: could not find: \" %s \" \n " ) , f ) ;
2007-02-17 15:11:12 +00:00
return PS_ERROR ;
} else {
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " !include: could not find: \" %s \" " ) , f ) ;
2003-11-29 16:10:10 +00:00
}
2002-08-02 10:01:35 +00:00
}
2007-02-17 15:11:12 +00:00
}
2002-08-02 10:01:35 +00:00
return PS_OK ;
case TOK_P_CD :
2010-03-29 14:24:47 +00:00
if ( ! line . gettoken_str ( 1 ) [ 0 ] | | _tchdir ( line . gettoken_str ( 1 ) ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !cd: error changing to: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
return PS_OK ;
case TOK_P_ERROR :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !error: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
case TOK_P_WARNING :
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " !warning: %s " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_OK ;
case TOK_P_ECHO :
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %s (%s:%d) \n " ) , line . gettoken_str ( 1 ) , curfilename , linecnt ) ;
2009-03-10 20:14:10 +00:00
return PS_OK ;
case TOK_P_SEARCHPARSESTRING :
{
bool ignCase = false ;
bool noErrors = false ;
bool isFile = false ;
int parmOffs = 1 ;
while ( parmOffs < line . getnumtokens ( ) )
{
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( parmOffs ) , _T ( " /ignorecase " ) ) ) { ignCase = true ; parmOffs + + ; }
else if ( ! _tcsicmp ( line . gettoken_str ( parmOffs ) , _T ( " /noerrors " ) ) ) { noErrors = true ; parmOffs + + ; }
else if ( ! _tcsicmp ( line . gettoken_str ( parmOffs ) , _T ( " /file " ) ) ) { isFile = true ; parmOffs + + ; }
2009-03-10 20:14:10 +00:00
else break ;
}
if ( parmOffs + 3 > line . getnumtokens ( ) )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !searchparse: not enough parameters \n " ) ) ;
2009-03-10 20:14:10 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
const TCHAR * source_string = line . gettoken_str ( parmOffs + + ) ;
2009-03-10 20:14:10 +00:00
DefineList * list = NULL ;
if ( isFile )
{
2010-03-29 14:24:47 +00:00
FILE * fp = FOPENTEXT ( source_string , _T ( " r " ) ) ;
2009-03-10 20:14:10 +00:00
if ( ! fp )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !searchparse /file: error opening \" %s \" \n " ) , source_string ) ;
2009-03-10 20:14:10 +00:00
return PS_ERROR ;
}
int req_parm = ( line . getnumtokens ( ) - parmOffs ) / 2 ;
GrowBuf tmpstr ;
2010-03-24 17:22:56 +00:00
TCHAR str [ MAX_LINELENGTH ] ;
2009-03-10 20:14:10 +00:00
for ( ; ; )
2009-06-06 19:35:20 +00:00
{
2009-03-10 22:24:04 +00:00
tmpstr . resize ( 0 ) ;
2009-03-10 20:14:10 +00:00
for ( ; ; )
{
str [ 0 ] = 0 ;
2010-03-30 17:50:08 +00:00
_fgetts ( str , COUNTOF ( str ) , fp ) ;
2009-06-10 21:26:01 +00:00
if ( ! str [ 0 ] ) break ; // eof
2009-03-10 20:14:10 +00:00
2010-03-24 17:22:56 +00:00
TCHAR * p = str ;
2009-03-10 20:14:10 +00:00
while ( * p ) p + + ;
if ( p > str ) p - - ;
2010-03-24 17:22:56 +00:00
while ( p > = str & & ( * p = = _T ( ' \r ' ) | | * p = = _T ( ' \n ' ) ) ) p - - ;
2009-03-10 20:14:10 +00:00
* + + p = 0 ;
2010-03-29 14:24:47 +00:00
bool endSlash = ( str [ 0 ] & & str [ _tcsclen ( str ) - 1 ] = = _T ( ' \\ ' ) ) ;
if ( tmpstr . getlen ( ) | | endSlash ) tmpstr . add ( str , _tcsclen ( str ) ) ;
2009-03-10 20:14:10 +00:00
2009-06-10 21:26:01 +00:00
// if we have valid contents and not ending on slash, then done
if ( ! endSlash & & ( str [ 0 ] | | tmpstr . getlen ( ) ) ) break ;
2009-06-06 19:35:20 +00:00
}
2009-06-10 21:26:01 +00:00
if ( ! str [ 0 ] & & ! tmpstr . getlen ( ) ) break ; // reached eof
2009-03-10 20:14:10 +00:00
2010-03-24 17:22:56 +00:00
TCHAR * thisline = str ;
2009-03-10 20:14:10 +00:00
if ( tmpstr . getlen ( ) )
{
2010-03-24 17:22:56 +00:00
tmpstr . add ( _T ( " \0 " ) , 1 ) ;
thisline = ( TCHAR * ) tmpstr . get ( ) ;
2009-03-10 20:14:10 +00:00
}
DefineList * tlist = searchParseString ( thisline , & line , parmOffs , ignCase , true ) ;
if ( tlist & & tlist - > getnum ( ) )
{
if ( ! list | | tlist - > getnum ( ) > list - > getnum ( ) )
{
delete list ;
list = tlist ;
if ( tlist - > getnum ( ) > = req_parm ) break ; // success!
}
else delete list ;
}
// parse line
}
fclose ( fp ) ;
if ( ! noErrors )
{
if ( ! list )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !searchparse: starting string \" %s \" not found in file! \n " ) , line . gettoken_str ( parmOffs ) ) ;
2009-03-10 20:14:10 +00:00
return PS_ERROR ;
}
else if ( list - > getnum ( ) < req_parm )
{
2010-03-24 17:22:56 +00:00
TCHAR * p = line . gettoken_str ( parmOffs + list - > getnum ( ) * 2 ) ;
ERROR_MSG ( _T ( " !searchparse: failed search at string \" %s \" not found in file! \n " ) , p ? p : _T ( " (null) " ) ) ;
2009-03-10 20:14:10 +00:00
return PS_ERROR ;
}
}
}
else
{
list = searchParseString ( source_string , & line , parmOffs , ignCase , noErrors ) ;
if ( ! list & & ! noErrors ) return PS_ERROR ;
}
if ( list ) // if we got our list, merge them defines in
{
int i ;
for ( i = 0 ; i < list - > getnum ( ) ; i + + )
{
2010-03-24 17:22:56 +00:00
TCHAR * def = list - > getname ( i ) ;
TCHAR * val = list - > getvalue ( i ) ;
2009-03-10 20:14:10 +00:00
if ( def & & val )
{
if ( definedlist . find ( def ) ) definedlist . del ( def ) ;
definedlist . add ( def , val ) ;
}
}
}
delete list ;
}
return PS_OK ;
case TOK_P_SEARCHREPLACESTRING :
{
2010-03-29 14:24:47 +00:00
int ignoreCase = ! _tcsicmp ( line . gettoken_str ( 1 ) , _T ( " /ignorecase " ) ) ;
2009-03-10 20:14:10 +00:00
if ( line . getnumtokens ( ) ! = 5 + ignoreCase ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
TCHAR * define = line . gettoken_str ( 1 + ignoreCase ) ;
TCHAR * src = line . gettoken_str ( 2 + ignoreCase ) ;
TCHAR * search = line . gettoken_str ( 3 + ignoreCase ) ;
TCHAR * replace = line . gettoken_str ( 4 + ignoreCase ) ;
int searchlen = _tcsclen ( search ) ;
int replacelen = _tcsclen ( replace ) ;
2009-03-10 20:14:10 +00:00
if ( ! searchlen )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !searchreplace: search string must not be empty for search/replace! \n " ) ) ;
2009-03-10 20:14:10 +00:00
return PS_ERROR ;
}
GrowBuf valout ;
while ( * src )
{
2010-03-29 14:24:47 +00:00
if ( ignoreCase ? _tcsncicmp ( src , search , searchlen ) : _tcsncmp ( src , search , searchlen ) )
2009-03-10 20:14:10 +00:00
valout . add ( src + + , 1 ) ;
else
{
valout . add ( replace , replacelen ) ;
src + = searchlen ;
}
}
2010-03-24 17:22:56 +00:00
valout . add ( _T ( " " ) , 1 ) ;
2009-03-10 20:14:10 +00:00
definedlist . del ( define ) ; // allow changing variables since we'll often use this in series
2010-03-24 17:22:56 +00:00
if ( definedlist . add ( define , ( TCHAR * ) valout . get ( ) ) )
2009-03-10 20:14:10 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !searchreplace: error defining \" %s \" ! \n " ) , define ) ;
2009-03-10 20:14:10 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " !searchreplace: \" %s \" = \" %s \" \n " ) , define , ( TCHAR * ) valout . get ( ) ) ;
2009-03-10 20:14:10 +00:00
}
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_P_VERBOSE :
{
extern int g_display_errors ;
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " push \0 pop \0 " ) ) ;
2003-09-04 18:25:57 +00:00
int v ;
if ( k < 0 )
// just set
v = line . gettoken_int ( 1 ) ;
else
{
if ( k )
{
// pop
int l = verbose_stack . getlen ( ) ;
if ( l )
{
v = ( ( int * ) verbose_stack . get ( ) ) [ ( l / sizeof ( int ) ) - 1 ] ;
verbose_stack . resize ( l - sizeof ( int ) ) ;
}
else
return PS_OK ;
}
else
{
// push
v = 0 ;
if ( display_errors )
{
v + + ;
if ( display_warnings )
{
v + + ;
if ( display_info )
{
v + + ;
if ( display_script )
{
v + + ;
}
}
}
}
verbose_stack . add ( & v , sizeof ( int ) ) ;
return PS_OK ;
}
}
2002-08-02 10:01:35 +00:00
display_script = v > 3 ;
display_info = v > 2 ;
display_warnings = v > 1 ;
display_errors = v > 0 ;
g_display_errors = display_errors ;
}
return PS_OK ;
case TOK_UNINSTALLEXENAME : PRINTHELP ( )
2002-08-11 18:57:16 +00:00
2002-08-02 10:01:35 +00:00
# ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
case TOK_UNINSTCAPTION :
{
2003-09-04 18:25:57 +00:00
if ( SetInnerString ( NLF_UCAPTION , line . gettoken_str ( 1 ) ) = = PS_WARNING )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %s: specified multiple times, wasting space " ) , line . gettoken_str ( 0 ) ) ;
SCRIPT_MSG ( _T ( " UninstCaption: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_UNINSTICON :
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " UninstallIcon: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
try {
2007-10-03 17:37:56 +00:00
free_loaded_icon ( uninstaller_icon ) ;
uninstaller_icon = load_icon_file ( line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
}
catch ( exception & err ) {
2010-03-29 14:24:47 +00:00
ERROR_MSG ( _T ( " Error while loading icon from \" %s \" : %s \n " ) , line . gettoken_str ( 1 ) , CtoTString ( err . what ( ) ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_UNINSTTEXT :
{
2003-09-04 18:25:57 +00:00
if ( ! cur_page ) {
if ( SetInnerString ( NLF_UNINST_TEXT , line . gettoken_str ( 1 ) ) = = PS_WARNING )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %s: specified multiple times, wasting space " ) , line . gettoken_str ( 0 ) ) ;
2003-09-04 18:25:57 +00:00
SetInnerString ( NLF_UNINST_SUBTEXT , line . gettoken_str ( 2 ) ) ;
}
else {
if ( cur_page_type ! = PAGE_UNINSTCONFIRM ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: UninstallText can only be used inside PageEx uninstConfirm. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
cur_page - > parms [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
cur_page - > parms [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " UninstallText: \" %s \" \" %s \" \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_UNINSTSUBCAPTION :
{
int s ;
2003-09-04 18:25:57 +00:00
int w = line . gettoken_int ( 1 , & s ) ;
2002-08-02 10:01:35 +00:00
if ( ! s | | w < 0 | | w > 2 ) PRINTHELP ( )
2003-09-04 18:25:57 +00:00
SetInnerString ( NLF_USUBCAPTION_CONFIRM + w , line . gettoken_str ( 2 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " UninstSubCaption: page:%d, text=%s \n " ) , w , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_WRITEUNINSTALLER :
2007-07-05 17:43:22 +00:00
{
2002-08-02 10:01:35 +00:00
if ( uninstall_mode )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " WriteUninstaller only valid from install, not from uninstall. \n " ) ) ;
2002-08-02 10:01:35 +00:00
PRINTHELP ( )
}
uninstaller_writes_used + + ;
ent . which = EW_WRITEUNINSTALLER ;
2003-09-04 18:25:57 +00:00
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2010-03-24 17:22:56 +00:00
tstring full = tstring ( _T ( " $INSTDIR \\ " ) ) + tstring ( line . gettoken_str ( 1 ) ) ;
2007-07-05 17:43:22 +00:00
ent . offsets [ 3 ] = add_string ( full . c_str ( ) ) ;
// ent.offsets[1] and ent.offsets[2] are set in CEXEBuild::uninstall_generate()
2002-09-29 20:25:15 +00:00
if ( ! ent . offsets [ 0 ] ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " WriteUninstaller: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2003-09-04 18:25:57 +00:00
DefineInnerLangString ( NLF_ERR_CREATING ) ;
DefineInnerLangString ( NLF_CREATED_UNINST ) ;
2007-07-05 17:43:22 +00:00
}
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
# else //!NSIS_CONFIG_UNINSTALL_SUPPORT
case TOK_WRITEUNINSTALLER :
case TOK_UNINSTCAPTION :
case TOK_UNINSTICON :
case TOK_UNINSTTEXT :
case TOK_UNINSTSUBCAPTION :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_UNINSTALL_SUPPORT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif
2002-08-11 18:57:16 +00:00
2010-03-24 17:22:56 +00:00
// section/function stuff
2002-08-02 10:01:35 +00:00
///////////////////////////////////////////////////////////////////////////////
case TOK_SECTION :
2002-08-22 21:53:54 +00:00
{
2003-05-24 13:50:24 +00:00
int a = 1 , unselected = 0 ;
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( 1 ) , _T ( " /o " ) ) )
2002-08-02 10:01:35 +00:00
{
2003-05-24 13:50:24 +00:00
unselected = 1 ;
2002-08-22 21:53:54 +00:00
a + + ;
}
2003-11-24 00:08:58 +00:00
else if ( line . getnumtokens ( ) > 3 )
PRINTHELP ( ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Section: \" %s \" " ) , line . gettoken_str ( a ) ) ;
if ( line . gettoken_str ( a + 1 ) [ 0 ] ) SCRIPT_MSG ( _T ( " ->(%s) " ) , line . gettoken_str ( a + 1 ) ) ;
SCRIPT_MSG ( _T ( " \n " ) ) ;
2002-08-02 10:01:35 +00:00
# ifndef NSIS_CONFIG_UNINSTALL_SUPPORT
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( a ) , _T ( " uninstall " ) ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: Uninstall section declared, no NSIS_CONFIG_UNINSTALL_SUPPORT \n " ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
# endif
2003-05-24 13:50:24 +00:00
int ret ;
2010-03-24 17:22:56 +00:00
if ( line . gettoken_str ( a ) [ 0 ] = = _T ( ' - ' ) )
2003-09-04 18:25:57 +00:00
{
2010-03-29 14:24:47 +00:00
if ( ! _tcsncicmp ( line . gettoken_str ( a ) + 1 , _T ( " un. " ) , 3 ) )
2010-03-24 17:22:56 +00:00
ret = add_section ( _T ( " un. " ) , line . gettoken_str ( a + 1 ) ) ;
2003-09-04 18:25:57 +00:00
else
2010-03-24 17:22:56 +00:00
ret = add_section ( _T ( " " ) , line . gettoken_str ( a + 1 ) ) ;
2003-09-04 18:25:57 +00:00
}
2003-06-05 21:53:52 +00:00
else ret = add_section ( line . gettoken_str ( a ) , line . gettoken_str ( a + 1 ) ) ;
2003-05-24 13:50:24 +00:00
if ( ret ! = PS_OK ) return ret ;
2004-12-10 11:09:10 +00:00
2003-05-24 13:50:24 +00:00
if ( unselected )
build_cursection - > flags & = ~ SF_SELECTED ;
return PS_OK ;
2002-08-22 21:53:54 +00:00
}
2002-08-02 10:01:35 +00:00
case TOK_SECTIONEND :
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SectionEnd \n " ) ) ;
2002-08-02 10:01:35 +00:00
return section_end ( ) ;
case TOK_SECTIONIN :
{
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SectionIn: " ) ) ;
2002-08-02 10:01:35 +00:00
int wt ;
for ( wt = 1 ; wt < line . getnumtokens ( ) ; wt + + )
{
2010-03-24 17:22:56 +00:00
TCHAR * p = line . gettoken_str ( wt ) ;
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( p , _T ( " RO " ) ) )
2002-08-02 10:01:35 +00:00
{
2003-05-29 08:46:55 +00:00
if ( section_add_flags ( SF_RO ) ! = PS_OK ) return PS_ERROR ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " [RO] " ) ) ;
2002-08-02 10:01:35 +00:00
}
else
{
2010-03-24 17:22:56 +00:00
int x = _ttoi ( p ) - 1 ;
2002-08-02 10:01:35 +00:00
if ( x > = 0 & & x < NSIS_MAX_INST_TYPES )
{
2002-10-02 15:01:06 +00:00
if ( section_add_install_type ( 1 < < x ) ! = PS_OK ) return PS_ERROR ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " [%d] " ) , x ) ;
2002-08-02 10:01:35 +00:00
}
else if ( x < 0 )
{
PRINTHELP ( )
}
else
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: SectionIn section %d out of range 1-%d \n " ) , x + 1 , NSIS_MAX_INST_TYPES ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
p + + ;
}
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " \n " ) ) ;
2002-08-02 10:01:35 +00:00
}
return PS_OK ;
2005-01-10 12:43:52 +00:00
case TOK_SECTIONGROUPEND :
2002-08-02 10:01:35 +00:00
case TOK_SUBSECTIONEND :
2005-01-10 12:43:52 +00:00
case TOK_SECTIONGROUP :
2002-08-02 10:01:35 +00:00
case TOK_SUBSECTION :
{
2010-03-24 17:22:56 +00:00
TCHAR buf [ 1024 ] ;
2002-08-28 14:59:35 +00:00
int a = 1 , ex = 0 ;
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( 1 ) , _T ( " /e " ) ) )
2002-08-02 10:01:35 +00:00
{
2002-08-28 14:59:35 +00:00
ex = 1 ;
a + + ;
}
2010-03-24 17:22:56 +00:00
wsprintf ( buf , _T ( " -%s " ) , line . gettoken_str ( a ) ) ;
2005-01-10 12:43:52 +00:00
if ( which_token = = TOK_SECTIONGROUP | | which_token = = TOK_SUBSECTION )
2003-11-19 13:11:07 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR * s = line . gettoken_str ( a ) ;
2010-03-29 14:24:47 +00:00
if ( ! s [ 0 ] | | ( ! _tcsicmp ( s , _T ( " un. " ) ) & & ! s [ 3 ] ) )
2003-11-19 13:11:07 +00:00
PRINTHELP ( ) ;
}
2002-08-02 10:01:35 +00:00
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %s %s " ) , line . gettoken_str ( 0 ) , line . gettoken_str ( a ) ) ;
if ( line . gettoken_str ( a + 1 ) [ 0 ] ) SCRIPT_MSG ( _T ( " ->(%s) " ) , line . gettoken_str ( a + 1 ) ) ;
SCRIPT_MSG ( _T ( " \n " ) ) ;
2003-06-05 21:53:52 +00:00
return add_section ( buf , line . gettoken_str ( a + 1 ) , ex ) ;
2002-08-02 10:01:35 +00:00
}
case TOK_FUNCTION :
if ( ! line . gettoken_str ( 1 ) [ 0 ] ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
if ( line . gettoken_str ( 1 ) [ 0 ] = = _T ( ' : ' ) | | line . gettoken_str ( 1 ) [ 0 ] = = _T ( ' / ' ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Function: function name cannot begin with : or /. \n " ) ) ;
2002-08-02 10:01:35 +00:00
PRINTHELP ( )
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Function: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
# ifndef NSIS_CONFIG_UNINSTALL_SUPPORT
2010-03-29 14:24:47 +00:00
if ( ! _tcsncicmp ( line . gettoken_str ( 1 ) , _T ( " un. " ) , 3 ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: Uninstall function declared, no NSIS_CONFIG_UNINSTALL_SUPPORT \n " ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
# endif
return add_function ( line . gettoken_str ( 1 ) ) ;
case TOK_FUNCTIONEND :
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " FunctionEnd \n " ) ) ;
2002-08-02 10:01:35 +00:00
return function_end ( ) ;
// flag setters
///////////////////////////////////////////////////////////////////////////////
2003-05-26 17:55:15 +00:00
// BEGIN - Added by ramon 23 May 2003
case TOK_ALLOWSKIPFILES :
2010-03-24 17:22:56 +00:00
build_allowskipfiles = line . gettoken_enum ( 1 , _T ( " off \0 on \0 " ) ) ;
2003-05-26 17:55:15 +00:00
if ( build_allowskipfiles = = - 1 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " AllowSkipFiles: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2003-05-26 17:55:15 +00:00
return PS_OK ;
// END - Added by ramon 23 May 2003
2002-08-02 10:01:35 +00:00
case TOK_SETDATESAVE :
2010-03-24 17:22:56 +00:00
build_datesave = line . gettoken_enum ( 1 , _T ( " off \0 on \0 " ) ) ;
2002-08-02 10:01:35 +00:00
if ( build_datesave = = - 1 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetDateSave: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_OK ;
case TOK_SETOVERWRITE :
2003-09-05 11:46:48 +00:00
{
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " on \0 off \0 try \0 ifnewer \0 ifdiff \0 lastused \0 " ) ) ;
2003-09-05 11:46:48 +00:00
if ( k = = - 1 ) PRINTHELP ( )
2003-09-07 16:46:50 +00:00
if ( k = = 5 )
2003-09-05 11:46:48 +00:00
{
k = build_overwrite ;
build_overwrite = build_last_overwrite ;
build_last_overwrite = k ;
}
else
{
build_last_overwrite = build_overwrite ;
build_overwrite = k ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetOverwrite: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2003-09-05 11:46:48 +00:00
}
2002-08-02 10:01:35 +00:00
return PS_OK ;
2002-10-02 19:18:24 +00:00
# ifdef NSIS_CONFIG_PLUGIN_SUPPORT
case TOK_SETPLUGINUNLOAD :
2010-03-24 17:22:56 +00:00
build_plugin_unload = line . gettoken_enum ( 1 , _T ( " manual \0 alwaysoff \0 " ) ) ;
2002-10-02 19:18:24 +00:00
if ( build_plugin_unload = = - 1 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetPluginUnload: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-10-02 19:18:24 +00:00
return PS_OK ;
# endif //NSIS_CONFIG_PLUGIN_SUPPORT
2002-08-02 10:01:35 +00:00
case TOK_SETCOMPRESS :
2010-03-24 17:22:56 +00:00
build_compress = line . gettoken_enum ( 1 , _T ( " off \0 auto \0 force \0 " ) ) ;
2002-08-02 10:01:35 +00:00
if ( build_compress = = - 1 ) PRINTHELP ( )
2003-06-05 21:53:52 +00:00
if ( build_compress = = 0 & & build_compress_whole )
2002-09-03 16:52:14 +00:00
{
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " 'SetCompress off' encountered, and in whole compression mode. Effectively ignored. " ) ) ;
2002-09-03 16:52:14 +00:00
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetCompress: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_OK ;
case TOK_DBOPTIMIZE :
2010-03-24 17:22:56 +00:00
build_optimize_datablock = line . gettoken_enum ( 1 , _T ( " off \0 on \0 " ) ) ;
2002-08-02 10:01:35 +00:00
if ( build_optimize_datablock = = - 1 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetDatablockOptimize: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_OK ;
2003-09-15 22:05:06 +00:00
case TOK_FILEBUFSIZE :
build_filebuflen = line . gettoken_int ( 1 ) ;
build_filebuflen < < = 20 ;
if ( build_filebuflen < = 0 )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: FileBufSize: invalid buffer size -- %d \n " ) , build_filebuflen ) ;
2003-09-15 22:05:06 +00:00
return PS_ERROR ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " FileBufSize: %smb (%d bytes) \n " ) , line . gettoken_str ( 1 ) , build_filebuflen ) ;
2003-09-15 22:05:06 +00:00
return PS_OK ;
2004-01-29 01:23:24 +00:00
# ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
2003-11-24 00:08:58 +00:00
case TOK_SETCOMPRESSIONLEVEL :
{
if ( compressor = = & lzma_compressor )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " SetCompressionLevel: compressor is set to LZMA. Effectively ignored. " ) ) ;
2003-11-24 00:08:58 +00:00
if ( build_compressor_set & & build_compress_whole )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " SetCompressionLevel: data already compressed in compress whole mode. Effectively ignored. " ) ) ;
2003-11-24 00:08:58 +00:00
int s ;
build_compress_level = line . gettoken_int ( 1 , & s ) ;
if ( ! s | | build_compress_level < 0 | | build_compress_level > 9 ) PRINTHELP ( ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetCompressionLevel: %u \n " ) , build_compress_level ) ;
2003-11-24 00:08:58 +00:00
}
return PS_OK ;
case TOK_SETCOMPRESSORDICTSIZE :
{
if ( compressor ! = & lzma_compressor )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " SetCompressorDictSize: compressor is not set to LZMA. Effectively ignored. " ) ) ;
2003-11-24 00:08:58 +00:00
if ( build_compressor_set & & build_compress_whole )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " SetCompressorDictSize: data already compressed in compress whole mode. Effectively ignored. " ) ) ;
2003-11-24 00:08:58 +00:00
int s ;
build_compress_dict_size = line . gettoken_int ( 1 , & s ) ;
if ( ! s ) PRINTHELP ( ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetCompressorDictSize: %u mb \n " ) , build_compress_dict_size ) ;
2003-11-24 00:08:58 +00:00
build_compress_dict_size < < = 20 ;
}
return PS_OK ;
2004-01-29 01:23:24 +00:00
# else
case TOK_SETCOMPRESSIONLEVEL :
case TOK_SETCOMPRESSORDICTSIZE :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_COMPRESSION_SUPPORT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2004-01-29 01:23:24 +00:00
return PS_ERROR ;
# endif //NSIS_CONFIG_COMPRESSION_SUPPORT
2002-08-02 10:01:35 +00:00
case TOK_ADDSIZE :
{
int s ;
int size_kb = line . gettoken_int ( 1 , & s ) ;
if ( ! s ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " AddSize: %d kb \n " ) , size_kb ) ;
2002-08-02 10:01:35 +00:00
section_add_size_kb ( size_kb ) ;
}
return PS_OK ;
case TOK_SUBCAPTION :
{
int s ;
2003-09-04 18:25:57 +00:00
int w = line . gettoken_int ( 1 , & s ) ;
2002-08-05 13:52:27 +00:00
if ( ! s | | w < 0 | | w > 4 ) PRINTHELP ( )
2003-09-04 18:25:57 +00:00
SetInnerString ( NLF_SUBCAPTION_LICENSE + w , line . gettoken_str ( 2 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SubCaption: page:%d, text=%s \n " ) , w , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_FILEERRORTEXT :
# ifdef NSIS_SUPPORT_FILE
2002-08-04 20:25:10 +00:00
{
2003-09-04 18:25:57 +00:00
SetInnerString ( NLF_FILE_ERROR , line . gettoken_str ( 1 ) ) ;
SetInnerString ( NLF_FILE_ERROR_NOIGNORE , line . gettoken_str ( 2 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " FileErrorText: \" %s \" \" %s \" \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-04 20:25:10 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
# else
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_FILE not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif
case TOK_BRANDINGTEXT :
2002-08-04 20:25:10 +00:00
{
int a = 1 ;
2002-08-28 10:07:18 +00:00
int trim = 0 ;
2010-03-24 17:22:56 +00:00
while ( line . gettoken_str ( a ) [ 0 ] = = _T ( ' / ' ) ) {
2010-03-29 14:24:47 +00:00
if ( ! _tcsncicmp ( line . gettoken_str ( a ) , _T ( " /TRIM " ) , 5 ) ) {
if ( ! _tcsicmp ( line . gettoken_str ( a ) + 5 , _T ( " LEFT " ) ) ) trim = 1 ;
else if ( ! _tcsicmp ( line . gettoken_str ( a ) + 5 , _T ( " RIGHT " ) ) ) trim = 2 ;
else if ( ! _tcsicmp ( line . gettoken_str ( a ) + 5 , _T ( " CENTER " ) ) ) trim = 3 ;
2002-08-28 14:59:35 +00:00
else PRINTHELP ( ) ;
2002-08-28 10:07:18 +00:00
a + + ;
}
2002-12-12 19:26:55 +00:00
else break ;
2002-08-28 10:07:18 +00:00
}
2002-08-28 15:41:33 +00:00
if ( line . getnumtokens ( ) ! = a + 1 & & ! trim ) PRINTHELP ( ) ;
2003-09-04 18:25:57 +00:00
if ( line . getnumtokens ( ) = = a + 1 )
SetInnerString ( NLF_BRANDING , line . gettoken_str ( a ) ) ;
2004-03-29 20:21:00 +00:00
# ifdef _WIN32
2002-08-28 10:07:18 +00:00
if ( trim ) try {
2002-11-09 13:51:40 +00:00
init_res_editor ( ) ;
2002-08-28 10:07:18 +00:00
2010-04-12 16:00:17 +00:00
BYTE * dlg = res_editor - > GetResource ( RT_DIALOG , IDD_INST , NSIS_DEFAULT_LANG ) ;
2003-04-21 13:32:34 +00:00
CDialogTemplate td ( dlg , uDefCodePage ) ;
2002-08-28 10:07:18 +00:00
free ( dlg ) ;
2002-10-26 16:11:29 +00:00
if ( trim ) {
2010-03-24 17:22:56 +00:00
TCHAR str [ 512 ] ;
2002-10-26 16:11:29 +00:00
if ( line . getnumtokens ( ) = = a + 1 & & line . gettoken_str ( a ) [ 0 ] )
2010-03-29 14:24:47 +00:00
_tcscpy ( str , line . gettoken_str ( a ) ) ;
2002-10-26 16:11:29 +00:00
else
2010-03-24 17:22:56 +00:00
wsprintf ( str , _T ( " Nullsoft Install System %s " ) , NSIS_VERSION ) ;
2002-08-28 15:41:33 +00:00
2005-12-31 14:13:16 +00:00
short old_width = td . GetItem ( IDC_VERSTR ) - > sWidth ;
2002-10-26 16:11:29 +00:00
switch ( trim ) {
case 1 : td . LTrimToString ( IDC_VERSTR , str , 4 ) ; break ;
case 2 : td . RTrimToString ( IDC_VERSTR , str , 4 ) ; break ;
case 3 : td . CTrimToString ( IDC_VERSTR , str , 4 ) ; break ;
}
2005-12-31 14:13:16 +00:00
if ( td . GetItem ( IDC_VERSTR ) - > sWidth > old_width )
{
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " BrandingText: \" %s \" is too long, trimming has expanded the label " ) , str ) ;
2005-12-31 14:13:16 +00:00
}
2002-08-28 10:07:18 +00:00
}
DWORD dwSize ;
dlg = td . Save ( dwSize ) ;
2010-04-12 16:00:17 +00:00
res_editor - > UpdateResource ( RT_DIALOG , IDD_INST , NSIS_DEFAULT_LANG , dlg , dwSize ) ;
2004-02-05 12:19:02 +00:00
res_editor - > FreeResource ( dlg ) ;
2002-08-28 10:07:18 +00:00
}
catch ( exception & err ) {
2010-03-29 14:24:47 +00:00
ERROR_MSG ( _T ( " Error while triming branding text control: %s \n " ) , CtoTString ( err . what ( ) ) ) ;
2002-08-28 10:07:18 +00:00
return PS_ERROR ;
}
2004-03-29 20:21:00 +00:00
# else
if ( trim )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: BrandingText /TRIM* is disabled for non Win32 platforms. \n " ) ) ;
2004-03-29 20:21:00 +00:00
return PS_ERROR ;
}
# endif
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " BrandingText: \" %s \" \n " ) , line . gettoken_str ( a ) ) ;
2002-08-04 20:25:10 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_MISCBUTTONTEXT :
2002-08-04 20:25:10 +00:00
{
2003-09-04 18:25:57 +00:00
SetInnerString ( NLF_BTN_BACK , line . gettoken_str ( 1 ) ) ;
SetInnerString ( NLF_BTN_NEXT , line . gettoken_str ( 2 ) ) ;
SetInnerString ( NLF_BTN_CANCEL , line . gettoken_str ( 3 ) ) ;
SetInnerString ( NLF_BTN_CLOSE , line . gettoken_str ( 4 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " MiscButtonText: back= \" %s \" next= \" %s \" cancel= \" %s \" close= \" %s \" \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) ) ;
2002-08-04 20:25:10 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_SPACETEXTS :
2002-08-04 20:25:10 +00:00
{
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( 1 ) , _T ( " none " ) ) ) {
2002-08-04 20:25:10 +00:00
no_space_texts = true ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SpaceTexts: none \n " ) ) ;
2002-08-04 20:25:10 +00:00
}
else {
2003-09-12 21:40:33 +00:00
no_space_texts = false ;
2003-09-04 18:25:57 +00:00
SetInnerString ( NLF_SPACE_REQ , line . gettoken_str ( 1 ) ) ;
SetInnerString ( NLF_SPACE_AVAIL , line . gettoken_str ( 2 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SpaceTexts: required= \" %s \" available= \" %s \" \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-04 20:25:10 +00:00
}
2002-08-02 10:01:35 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_INSTBUTTONTEXT :
2002-08-04 20:25:10 +00:00
{
2003-09-04 18:25:57 +00:00
SetInnerString ( NLF_BTN_INSTALL , line . gettoken_str ( 1 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " InstallButtonText: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-04 20:25:10 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_DETAILSBUTTONTEXT :
2002-08-04 20:25:10 +00:00
{
2003-09-04 18:25:57 +00:00
if ( ! cur_page ) {
if ( SetInnerString ( NLF_BTN_DETAILS , line . gettoken_str ( 1 ) ) = = PS_WARNING )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %s: specified multiple times, wasting space " ) , line . gettoken_str ( 0 ) ) ;
2003-09-04 18:25:57 +00:00
}
else {
if ( cur_page_type ! = PAGE_INSTFILES ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: DetailsButtonText can only be used inside PageEx instfiles. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
cur_page - > parms [ 1 ] = add_string ( line . gettoken_str ( 1 ) ) ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " DetailsButtonText: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-04 20:25:10 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_COMPLETEDTEXT :
2002-08-04 20:25:10 +00:00
{
2003-09-04 18:25:57 +00:00
if ( ! cur_page ) {
if ( SetInnerString ( NLF_COMPLETED , line . gettoken_str ( 1 ) ) = = PS_WARNING )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %s: specified multiple times, wasting space " ) , line . gettoken_str ( 0 ) ) ;
2003-09-04 18:25:57 +00:00
}
else {
if ( cur_page_type ! = PAGE_INSTFILES ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: CompletedText can only be used inside PageEx instfiles. \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
cur_page - > parms [ 2 ] = add_string ( line . gettoken_str ( 1 ) ) ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " CompletedText: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-04 20:25:10 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_UNINSTBUTTONTEXT :
# ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
2002-08-04 20:25:10 +00:00
{
2003-09-04 18:25:57 +00:00
SetInnerString ( NLF_BTN_UNINSTALL , line . gettoken_str ( 1 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " UninstButtonText: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-04 20:25:10 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2002-08-02 10:01:35 +00:00
# else
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_UNINSTALL_SUPPORT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif
// instructions
///////////////////////////////////////////////////////////////////////////////
2002-08-11 18:57:16 +00:00
case TOK_NOP :
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Nop \n " ) ) ;
2002-08-02 10:01:35 +00:00
ent . which = EW_NOP ;
return add_entry ( & ent ) ;
2002-08-11 18:57:16 +00:00
case TOK_GOTO :
2002-08-02 10:01:35 +00:00
ent . which = EW_NOP ;
if ( process_jump ( line , 1 , & ent . offsets [ 0 ] ) ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Goto: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
2007-04-14 12:50:32 +00:00
case TOK_SETREGVIEW :
{
ent . which = EW_SETFLAG ;
ent . offsets [ 0 ] = FLAG_OFFSET ( alter_reg_view ) ;
// "64" results in setting the flag to 1 which alters the view
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " 32 \0 " ) _T ( " 64 \0 lastused \0 " ) ) ;
2007-04-14 12:50:32 +00:00
if ( k < 0 ) PRINTHELP ( )
2007-04-26 20:26:04 +00:00
if ( k = = 0 ) // 32
ent . offsets [ 1 ] = add_intstring ( 0 ) ;
else if ( k = = 1 ) // 64
ent . offsets [ 1 ] = add_intstring ( KEY_WOW64_64KEY ) ;
2007-09-08 17:27:28 +00:00
else if ( k = = 2 ) // last used
ent . offsets [ 2 ] = 1 ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetRegView: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2007-04-14 12:50:32 +00:00
}
return add_entry ( & ent ) ;
2002-08-02 10:01:35 +00:00
case TOK_SETSHELLVARCONTEXT :
2003-05-24 13:50:24 +00:00
{
2003-02-07 23:04:25 +00:00
ent . which = EW_SETFLAG ;
2003-04-02 19:54:53 +00:00
ent . offsets [ 0 ] = FLAG_OFFSET ( all_user_var ) ;
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " current \0 all \0 " ) ) ;
2003-05-24 13:50:24 +00:00
if ( k < 0 ) PRINTHELP ( )
ent . offsets [ 1 ] = add_intstring ( k ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetShellVarContext: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2003-05-24 13:50:24 +00:00
}
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_RET :
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Return \n " ) ) ;
2002-08-02 10:01:35 +00:00
ent . which = EW_RET ;
return add_entry ( & ent ) ;
case TOK_CALL :
2010-03-24 17:22:56 +00:00
if ( ! line . gettoken_str ( 1 ) [ 0 ] | | ( line . gettoken_str ( 1 ) [ 0 ] = = _T ( ' : ' ) & & ! line . gettoken_str ( 1 ) [ 1 ] ) ) PRINTHELP ( )
2002-08-02 10:01:35 +00:00
# ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
2010-03-29 14:24:47 +00:00
if ( uninstall_mode & & _tcsncicmp ( line . gettoken_str ( 1 ) , _T ( " un. " ) , 3 )
2010-03-24 17:22:56 +00:00
& & ( GetUserVarIndex ( line , 1 ) < 0 ) & & line . gettoken_str ( 1 ) [ 0 ] ! = _T ( ' : ' ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Call must be used with function names starting with \" un. \" in the uninstall section. \n " ) ) ;
2002-08-02 10:01:35 +00:00
PRINTHELP ( )
}
2010-03-29 14:24:47 +00:00
if ( ! uninstall_mode & & ! _tcsncicmp ( line . gettoken_str ( 1 ) , _T ( " un. " ) , 3 ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Call must not be used with functions starting with \" un. \" in the non-uninstall sections. \n " ) ) ;
2002-08-02 10:01:35 +00:00
PRINTHELP ( )
}
# endif
ent . which = EW_CALL ;
ent . offsets [ 1 ] = 0 ;
{
int v ;
2003-06-09 18:59:14 +00:00
if ( ( v = GetUserVarIndex ( line , 1 ) ) > = 0 )
2002-08-02 10:01:35 +00:00
{
ent . offsets [ 0 ] = - v - 2 ;
}
else
{
2010-03-24 17:22:56 +00:00
if ( line . gettoken_str ( 1 ) [ 0 ] = = _T ( ' : ' ) )
2002-08-02 10:01:35 +00:00
{
2002-08-11 18:57:16 +00:00
ent . offsets [ 1 ] = 1 ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 0 ] = ns_label . add ( line . gettoken_str ( 1 ) + 1 , 0 ) ;
}
else ent . offsets [ 0 ] = ns_func . add ( line . gettoken_str ( 1 ) , 0 ) ;
}
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Call \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_SETOUTPATH :
{
2010-03-24 17:22:56 +00:00
const TCHAR * op = line . gettoken_str ( 1 ) ;
if ( ! _tcscmp ( op , _T ( " - " ) ) )
2004-06-04 11:05:29 +00:00
{
2010-03-24 17:22:56 +00:00
op = _T ( " $INSTDIR " ) ;
2004-06-04 11:05:29 +00:00
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetOutPath: \" %s \" \n " ) , op ) ;
2002-08-02 10:01:35 +00:00
ent . which = EW_CREATEDIR ;
2004-06-04 11:05:29 +00:00
ent . offsets [ 0 ] = add_string ( op ) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 1 ] = 1 ;
2003-09-04 18:25:57 +00:00
DefineInnerLangString ( NLF_OUTPUT_DIR ) ;
2002-08-02 10:01:35 +00:00
}
return add_entry ( & ent ) ;
case TOK_CREATEDIR :
{
2010-03-24 17:22:56 +00:00
TCHAR out_path [ 1024 ] ;
TCHAR * p = line . gettoken_str ( 1 ) ;
if ( * p = = _T ( ' - ' ) ) out_path [ 0 ] = 0 ;
2002-08-02 10:01:35 +00:00
else
2002-08-11 18:57:16 +00:00
{
2010-03-24 17:22:56 +00:00
if ( p [ 0 ] = = _T ( ' \\ ' ) & & p [ 1 ] ! = _T ( ' \\ ' ) ) p + + ;
2010-03-29 14:24:47 +00:00
_tcsnccpy ( out_path , p , 1024 - 1 ) ;
if ( * CharPrev ( out_path , out_path + _tcsclen ( out_path ) ) = = _T ( ' \\ ' ) )
* CharPrev ( out_path , out_path + _tcsclen ( out_path ) ) = 0 ; // remove trailing slash
2002-08-02 10:01:35 +00:00
}
if ( ! * out_path ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " CreateDirectory: \" %s \" \n " ) , out_path ) ;
2002-08-02 10:01:35 +00:00
ent . which = EW_CREATEDIR ;
ent . offsets [ 0 ] = add_string ( out_path ) ;
2003-09-04 18:25:57 +00:00
DefineInnerLangString ( NLF_CREATE_DIR ) ;
2002-08-02 10:01:35 +00:00
}
return add_entry ( & ent ) ;
case TOK_EXEC :
case TOK_EXECWAIT :
# ifdef NSIS_SUPPORT_EXECUTE
ent . which = EW_EXECUTE ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2003-11-27 20:19:48 +00:00
ent . offsets [ 2 ] = 0 ;
2002-08-11 18:57:16 +00:00
if ( which_token = = TOK_EXECWAIT )
2002-08-02 10:01:35 +00:00
{
2003-11-27 20:19:48 +00:00
ent . offsets [ 2 ] = 1 ;
ent . offsets [ 1 ] = GetUserVarIndex ( line , 2 ) ;
if ( line . gettoken_str ( 2 ) [ 0 ] & & ent . offsets [ 1 ] < 0 ) PRINTHELP ( )
2002-08-02 10:01:35 +00:00
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %s: \" %s \" (->%s) \n " ) , ent . offsets [ 2 ] ? _T ( " ExecWait " ) : _T ( " Exec " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2003-09-04 18:25:57 +00:00
DefineInnerLangString ( NLF_EXEC ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_EXECUTE
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_EXECUTE not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_EXECUTE
case TOK_EXECSHELL : // this uses improvements of Andras Varga
# ifdef NSIS_SUPPORT_SHELLEXECUTE
2007-07-06 09:55:20 +00:00
{
2002-08-02 10:01:35 +00:00
ent . which = EW_SHELLEXEC ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 3 ) ) ;
ent . offsets [ 3 ] = SW_SHOWNORMAL ;
if ( line . getnumtokens ( ) > 4 )
{
2009-06-06 13:59:38 +00:00
int tab [ 5 ] = { SW_SHOWDEFAULT , SW_SHOWNORMAL , SW_SHOWMAXIMIZED , SW_SHOWMINIMIZED , SW_HIDE } ;
2010-03-24 17:22:56 +00:00
int a = line . gettoken_enum ( 4 , _T ( " SW_SHOWDEFAULT \0 SW_SHOWNORMAL \0 SW_SHOWMAXIMIZED \0 SW_SHOWMINIMIZED \0 SW_HIDE \0 " ) ) ;
2002-08-02 10:01:35 +00:00
if ( a < 0 ) PRINTHELP ( )
ent . offsets [ 3 ] = tab [ a ] ;
}
2010-03-24 17:22:56 +00:00
tstring detail = tstring ( line . gettoken_str ( 1 ) ) + _T ( " " ) + tstring ( line . gettoken_str ( 2 ) ) ;
2007-07-06 09:55:20 +00:00
ent . offsets [ 5 ] = add_string ( detail . c_str ( ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " ExecShell: %s: \" %s \" \" %s \" %s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) ) ;
2003-09-04 18:25:57 +00:00
DefineInnerLangString ( NLF_EXEC_SHELL ) ;
2007-07-06 09:55:20 +00:00
}
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_SHELLEXECUTE
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_SHELLEXECUTE not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_SHELLEXECUTE
case TOK_CALLINSTDLL :
case TOK_REGDLL :
case TOK_UNREGDLL :
# ifndef NSIS_SUPPORT_ACTIVEXREG
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " %s: support not compiled in (NSIS_SUPPORT_ACTIVEXREG) \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# else //NSIS_SUPPORT_ACTIVEXREG
ent . which = EW_REGISTERDLL ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2002-08-11 18:57:16 +00:00
if ( which_token = = TOK_UNREGDLL )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ent . offsets [ 1 ] = add_string ( _T ( " DllUnregisterServer " ) ) ;
2003-09-04 18:25:57 +00:00
ent . offsets [ 2 ] = DefineInnerLangString ( NLF_UNREGISTERING ) ;
2002-08-02 10:01:35 +00:00
}
else if ( which_token = = TOK_CALLINSTDLL )
{
2002-08-29 10:25:45 +00:00
int a = 2 ;
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( a ) , _T ( " /NOUNLOAD " ) ) ) {
2002-08-29 10:25:45 +00:00
ent . offsets [ 3 ] = 1 ;
2002-08-29 16:44:24 +00:00
a + + ;
}
2002-08-29 10:25:45 +00:00
if ( a + 1 ! = line . getnumtokens ( ) ) PRINTHELP ( ) ;
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( a ) ) ;
2002-09-29 20:25:15 +00:00
if ( ! ent . offsets [ 1 ] ) PRINTHELP ( )
ent . offsets [ 2 ] = 0 ;
2002-08-02 10:01:35 +00:00
}
else // register
{
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
2010-03-24 17:22:56 +00:00
if ( ! ent . offsets [ 1 ] ) ent . offsets [ 1 ] = add_string ( _T ( " DllRegisterServer " ) ) ;
2003-09-04 18:25:57 +00:00
ent . offsets [ 2 ] = DefineInnerLangString ( NLF_REGISTERING ) ;
2002-08-02 10:01:35 +00:00
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %s: \" %s \" %s \n " ) , line . gettoken_str ( 0 ) , line . gettoken_str ( 1 ) , line . gettoken_str ( ent . offsets [ 3 ] ? 3 : 2 ) ) ;
2003-09-04 18:25:57 +00:00
DefineInnerLangString ( NLF_SYMBOL_NOT_FOUND ) ;
DefineInnerLangString ( NLF_COULD_NOT_LOAD ) ;
DefineInnerLangString ( NLF_NO_OLE ) ;
2006-08-07 14:01:54 +00:00
// not used anywhere - DefineInnerLangString(NLF_ERR_REG_DLL);
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
# endif //NSIS_SUPPORT_ACTIVEXREG
case TOK_RENAME :
# ifdef NSIS_SUPPORT_RENAME
{
int a = 1 ;
ent . which = EW_RENAME ;
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( 1 ) , _T ( " /REBOOTOK " ) ) )
2002-08-02 10:01:35 +00:00
{
ent . offsets [ 2 ] = 1 ;
a + + ;
# ifndef NSIS_SUPPORT_MOVEONREBOOT
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: /REBOOTOK specified, NSIS_SUPPORT_MOVEONREBOOT not defined \n " ) ) ;
2002-08-02 10:01:35 +00:00
PRINTHELP ( )
# endif
}
2010-03-24 17:22:56 +00:00
else if ( line . gettoken_str ( 1 ) [ 0 ] = = _T ( ' / ' ) )
2002-08-02 10:01:35 +00:00
{
a = line . getnumtokens ( ) ; // cause usage to go here:
}
if ( line . getnumtokens ( ) ! = a + 2 ) PRINTHELP ( )
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( a ) ) ;
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( a + 1 ) ) ;
2010-03-24 17:22:56 +00:00
tstring print = tstring ( line . gettoken_str ( a ) ) + _T ( " -> " ) + tstring ( line . gettoken_str ( a + 1 ) ) ;
2007-07-05 17:43:22 +00:00
ent . offsets [ 3 ] = add_string ( print . c_str ( ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Rename: %s%s->%s \n " ) , ent . offsets [ 2 ] ? _T ( " /REBOOTOK " ) : _T ( " " ) , line . gettoken_str ( a ) , line . gettoken_str ( a + 1 ) ) ;
2003-09-04 18:25:57 +00:00
DefineInnerLangString ( NLF_RENAME ) ;
# ifdef NSIS_SUPPORT_MOVEONREBOOT
DefineInnerLangString ( NLF_RENAME_ON_REBOOT ) ;
# endif
2002-08-02 10:01:35 +00:00
}
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_RENAME
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_RENAME not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_RENAME
case TOK_MESSAGEBOX :
# ifdef NSIS_SUPPORT_MESSAGEBOX
{
2010-03-24 17:22:56 +00:00
# define MBD(x) {x,_T(#x)},
2002-08-11 18:57:16 +00:00
struct
2002-08-02 10:01:35 +00:00
{
int id ;
2010-03-24 17:22:56 +00:00
const TCHAR * str ;
2002-08-02 10:01:35 +00:00
} list [ ] =
{
MBD ( MB_ABORTRETRYIGNORE )
MBD ( MB_OK )
MBD ( MB_OKCANCEL )
MBD ( MB_RETRYCANCEL )
MBD ( MB_YESNO )
MBD ( MB_YESNOCANCEL )
MBD ( MB_ICONEXCLAMATION )
MBD ( MB_ICONINFORMATION )
MBD ( MB_ICONQUESTION )
MBD ( MB_ICONSTOP )
2007-04-03 11:19:36 +00:00
MBD ( MB_USERICON )
2002-08-02 10:01:35 +00:00
MBD ( MB_TOPMOST )
MBD ( MB_SETFOREGROUND )
MBD ( MB_RIGHT )
2005-03-15 17:48:22 +00:00
MBD ( MB_RTLREADING )
2002-08-02 10:01:35 +00:00
MBD ( MB_DEFBUTTON1 )
MBD ( MB_DEFBUTTON2 )
MBD ( MB_DEFBUTTON3 )
MBD ( MB_DEFBUTTON4 )
} ;
# undef MBD
int r = 0 ;
int x ;
2010-03-24 17:22:56 +00:00
TCHAR * p = line . gettoken_str ( 1 ) ;
2002-08-02 10:01:35 +00:00
while ( * p )
{
2010-03-24 17:22:56 +00:00
TCHAR * np = p ;
while ( * np & & * np ! = _T ( ' | ' ) ) np + + ;
2002-08-02 10:01:35 +00:00
if ( * np ) * np + + = 0 ;
2010-03-30 17:50:08 +00:00
for ( x = 0 ; ( unsigned ) x < COUNTOF ( list ) & & _tcsicmp ( list [ x ] . str , p ) ; x + + ) ;
if ( ( unsigned ) x < COUNTOF ( list ) )
2002-08-02 10:01:35 +00:00
{
r | = list [ x ] . id ;
}
else PRINTHELP ( )
p = np ;
}
ent . which = EW_MESSAGEBOX ;
ent . offsets [ 0 ] = r ;
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
2002-08-11 18:57:16 +00:00
int rettab [ ] =
2002-08-02 10:01:35 +00:00
{
0 , IDABORT , IDCANCEL , IDIGNORE , IDNO , IDOK , IDRETRY , IDYES
} ;
2010-03-24 17:22:56 +00:00
const TCHAR * retstr = _T ( " 0 \0 IDABORT \0 IDCANCEL \0 IDIGNORE \0 IDNO \0 IDOK \0 IDRETRY \0 IDYES \0 " ) ;
2003-11-25 17:07:40 +00:00
int a = 3 ;
2002-08-02 10:01:35 +00:00
if ( line . getnumtokens ( ) > 3 )
{
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( 3 ) , _T ( " /SD " ) ) )
2002-08-02 10:01:35 +00:00
{
2003-11-25 17:07:40 +00:00
int k = line . gettoken_enum ( 4 , retstr ) ;
if ( k < = 0 ) PRINTHELP ( ) ;
2005-03-17 20:44:31 +00:00
ent . offsets [ 0 ] | = rettab [ k ] < < 21 ;
2003-11-25 17:07:40 +00:00
a = 5 ;
}
else if ( line . getnumtokens ( ) > 7 )
PRINTHELP ( ) ;
if ( line . getnumtokens ( ) > a )
{
ent . offsets [ 2 ] = line . gettoken_enum ( a , retstr ) ;
if ( ent . offsets [ 2 ] < 0 )
PRINTHELP ( ) ;
ent . offsets [ 2 ] = rettab [ ent . offsets [ 2 ] ] ;
if ( process_jump ( line , a + 1 , & ent . offsets [ 3 ] ) )
PRINTHELP ( ) ;
if ( line . getnumtokens ( ) > a + 2 )
{
int v = line . gettoken_enum ( a + 2 , retstr ) ;
if ( v < 0 )
PRINTHELP ( ) ;
ent . offsets [ 4 ] = rettab [ v ] ;
if ( process_jump ( line , a + 3 , & ent . offsets [ 5 ] ) )
PRINTHELP ( ) ;
}
2002-08-02 10:01:35 +00:00
}
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " MessageBox: %d: \" %s \" " ) , r , line . gettoken_str ( 2 ) ) ;
if ( line . getnumtokens ( ) > a + 1 ) SCRIPT_MSG ( _T ( " (on %s goto %s) " ) , line . gettoken_str ( a ) , line . gettoken_str ( a + 1 ) ) ;
SCRIPT_MSG ( _T ( " \n " ) ) ;
2002-08-11 18:57:16 +00:00
}
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_MESSAGEBOX
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_MESSAGEBOX not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_MESSAGEBOX
case TOK_CREATESHORTCUT :
# ifdef NSIS_SUPPORT_CREATESHORTCUT
ent . which = EW_CREATESHORTCUT ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 3 ) ) ;
ent . offsets [ 3 ] = add_string ( line . gettoken_str ( 4 ) ) ;
2002-09-25 12:54:10 +00:00
ent . offsets [ 5 ] = add_string ( line . gettoken_str ( 8 ) ) ;
2002-08-02 10:01:35 +00:00
int s ;
ent . offsets [ 4 ] = line . gettoken_int ( 5 , & s ) & 0xff ;
if ( ! s )
{
2002-12-26 22:04:54 +00:00
if ( line . getnumtokens ( ) > 5 & & * line . gettoken_str ( 5 ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " CreateShortCut: cannot interpret icon index \n " ) ) ;
2002-08-02 10:01:35 +00:00
PRINTHELP ( )
}
ent . offsets [ 4 ] = 0 ;
}
2002-12-26 22:04:54 +00:00
if ( line . getnumtokens ( ) > 6 & & * line . gettoken_str ( 6 ) )
2002-08-02 10:01:35 +00:00
{
int tab [ 3 ] = { SW_SHOWNORMAL , SW_SHOWMAXIMIZED , SW_SHOWMINNOACTIVE /*SW_SHOWMINIMIZED doesn't work*/ } ;
2010-03-24 17:22:56 +00:00
int a = line . gettoken_enum ( 6 , _T ( " SW_SHOWNORMAL \0 SW_SHOWMAXIMIZED \0 SW_SHOWMINIMIZED \0 " ) ) ;
2002-08-02 10:01:35 +00:00
if ( a < 0 )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " CreateShortCut: unknown show mode \" %s \" \n " ) , line . gettoken_str ( 6 ) ) ;
2002-08-02 10:01:35 +00:00
PRINTHELP ( )
}
ent . offsets [ 4 ] | = tab [ a ] < < 8 ;
}
if ( line . getnumtokens ( ) > 7 )
{
2010-03-24 17:22:56 +00:00
TCHAR * s = ( line . gettoken_str ( 7 ) ) ;
2004-01-12 18:06:06 +00:00
2010-03-24 17:22:56 +00:00
TCHAR b [ 255 ] ;
2010-03-29 14:24:47 +00:00
for ( unsigned int spos = 0 ; ( spos < = _tcsclen ( s ) ) & & ( spos < = 255 ) ; spos + + )
b [ spos ] = _totupper ( * ( s + spos ) ) ;
_tcscpy ( s , b ) ;
2004-03-11 19:29:04 +00:00
2002-08-02 10:01:35 +00:00
if ( * s )
{
int c = 0 ;
2010-03-24 17:22:56 +00:00
if ( _tcsstr ( s , _T ( " ALT| " ) ) ) ent . offsets [ 4 ] | = HOTKEYF_ALT < < 24 ;
if ( _tcsstr ( s , _T ( " CONTROL| " ) ) ) ent . offsets [ 4 ] | = HOTKEYF_CONTROL < < 24 ;
if ( _tcsstr ( s , _T ( " EXT| " ) ) ) ent . offsets [ 4 ] | = HOTKEYF_EXT < < 24 ;
if ( _tcsstr ( s , _T ( " SHIFT| " ) ) ) ent . offsets [ 4 ] | = HOTKEYF_SHIFT < < 24 ;
while ( _tcsstr ( s , _T ( " | " ) ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
s = _tcsstr ( s , _T ( " | " ) ) + 1 ;
2002-08-02 10:01:35 +00:00
}
2010-03-24 17:22:56 +00:00
if ( ( s [ 0 ] = = _T ( ' F ' ) ) & & ( s [ 1 ] > = _T ( ' 1 ' ) & & s [ 1 ] < = _T ( ' 9 ' ) ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
c = VK_F1 - 1 + _ttoi ( s + 1 ) ;
if ( _ttoi ( s + 1 ) < 1 | | _ttoi ( s + 1 ) > 24 )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " CreateShortCut: F-key \" %s \" out of range " ) , s ) ;
2002-08-02 10:01:35 +00:00
}
}
2010-03-24 17:22:56 +00:00
else if ( ( ( s [ 0 ] > = _T ( ' A ' ) & & s [ 0 ] < = _T ( ' Z ' ) ) | | ( s [ 0 ] > = _T ( ' 0 ' ) & & s [ 0 ] < = _T ( ' 9 ' ) ) ) & & ! s [ 1 ] )
2002-08-02 10:01:35 +00:00
c = s [ 0 ] ;
else
{
c = s [ 0 ] ;
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " CreateShortCut: unrecognized hotkey \" %s \" " ) , s ) ;
2002-08-02 10:01:35 +00:00
}
ent . offsets [ 4 ] | = ( c ) < < 16 ;
}
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " CreateShortCut: \" %s \" -> \" %s \" %s icon:%s,%d, showmode=0x%X, hotkey=0x%X, comment=%s \n " ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) ,
2002-09-25 12:54:10 +00:00
line . gettoken_str ( 4 ) , ent . offsets [ 4 ] & 0xff , ( ent . offsets [ 4 ] > > 8 ) & 0xff , ent . offsets [ 4 ] > > 16 , line . gettoken_str ( 8 ) ) ;
2003-09-04 18:25:57 +00:00
DefineInnerLangString ( NLF_CREATE_SHORTCUT ) ;
DefineInnerLangString ( NLF_ERR_CREATING_SHORTCUT ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_CREATESHORTCUT
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_CREATESHORTCUT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //NSIS_SUPPORT_CREATESHORTCUT
# ifdef NSIS_SUPPORT_HWNDS
case TOK_FINDWINDOW :
ent . which = EW_FINDWINDOW ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 3 ) ) ;
ent . offsets [ 3 ] = add_string ( line . gettoken_str ( 4 ) ) ;
ent . offsets [ 4 ] = add_string ( line . gettoken_str ( 5 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " FindWindow: output=%s, class= \" %s \" , text= \" %s \" hwndparent= \" %s \" hwndafter= \" %s \" \n " ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) , line . gettoken_str ( 5 ) ) ;
return add_entry ( & ent ) ;
case TOK_SENDMESSAGE :
ent . which = EW_SENDMESSAGE ;
2002-09-13 23:09:23 +00:00
2010-03-24 17:22:56 +00:00
if ( line . gettoken_str ( 1 ) [ 0 ] = = _T ( ' / ' ) | | line . gettoken_str ( 2 ) [ 0 ] = = _T ( ' / ' ) | |
line . gettoken_str ( 3 ) [ 0 ] = = _T ( ' / ' ) | | line . gettoken_str ( 4 ) [ 0 ] = = _T ( ' / ' ) )
2002-09-13 23:09:23 +00:00
{
PRINTHELP ( )
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SendMessage: " ) ) ;
2002-08-02 10:01:35 +00:00
{
2002-09-13 21:23:01 +00:00
int a = 5 ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 5 ) ;
2002-09-13 21:23:01 +00:00
if ( ent . offsets [ 0 ] > = 0 )
{
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " (->%s) " ) , line . gettoken_str ( 5 ) ) ;
2002-09-13 21:23:01 +00:00
a + + ;
}
2002-10-02 22:45:51 +00:00
2010-03-24 17:22:56 +00:00
if ( ! _tcsncmp ( line . gettoken_str ( a ) , _T ( " /TIMEOUT= " ) , 9 ) )
2002-09-13 21:23:01 +00:00
{
2010-03-24 17:22:56 +00:00
ent . offsets [ 5 ] | = _ttoi ( line . gettoken_str ( a ) + 9 ) < < 2 ;
SCRIPT_MSG ( _T ( " (timeout=%d) " ) , ent . offsets [ 5 ] > > 2 ) ;
2002-09-13 23:09:23 +00:00
a + + ;
}
2002-10-02 22:45:51 +00:00
if ( line . getnumtokens ( ) > a )
2002-09-13 23:09:23 +00:00
{
PRINTHELP ( )
2002-09-13 21:23:01 +00:00
}
2002-08-02 10:01:35 +00:00
}
2010-03-24 17:22:56 +00:00
if ( ! _tcsncmp ( line . gettoken_str ( 3 ) , _T ( " STR: " ) , 4 ) )
2002-09-13 21:25:03 +00:00
{
ent . offsets [ 5 ] | = 1 ;
ent . offsets [ 3 ] = add_string ( line . gettoken_str ( 3 ) + 4 ) ;
}
else ent . offsets [ 3 ] = add_string ( line . gettoken_str ( 3 ) ) ;
2010-03-24 17:22:56 +00:00
if ( ! _tcsncmp ( line . gettoken_str ( 4 ) , _T ( " STR: " ) , 4 ) )
2002-09-13 21:25:03 +00:00
{
ent . offsets [ 5 ] | = 2 ;
ent . offsets [ 4 ] = add_string ( line . gettoken_str ( 4 ) + 4 ) ;
}
else ent . offsets [ 4 ] = add_string ( line . gettoken_str ( 4 ) ) ;
2002-09-13 21:23:01 +00:00
2002-08-02 10:01:35 +00:00
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 1 ) ) ;
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 2 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " (%s,%s,%s,%s) \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_ISWINDOW :
ent . which = EW_ISWINDOW ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
if ( process_jump ( line , 2 , & ent . offsets [ 1 ] ) | |
process_jump ( line , 3 , & ent . offsets [ 2 ] ) ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " IsWindow(%s): %s:%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
2002-09-18 18:39:24 +00:00
# ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT
2002-08-21 19:09:09 +00:00
case TOK_GETDLGITEM :
ent . which = EW_GETDLGITEM ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-07 15:14:40 +00:00
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( ) ;
2002-08-21 19:09:09 +00:00
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
2002-08-07 15:14:40 +00:00
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 3 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " GetDlgItem: output=%s dialog=%s item=%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
2003-09-04 18:25:57 +00:00
case TOK_SETCTLCOLORS :
{
ctlcolors c = { 0 , } ;
ent . which = EW_SETCTLCOLORS ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2003-09-07 08:53:22 +00:00
int a = 2 ;
2003-09-04 18:25:57 +00:00
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( 2 ) , _T ( " /BRANDING " ) ) )
2003-09-07 08:53:22 +00:00
a + + ;
2004-12-10 11:09:10 +00:00
2003-09-07 08:53:22 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR * p ;
2003-09-04 18:25:57 +00:00
2003-09-07 08:53:22 +00:00
if ( a = = 2 & & line . getnumtokens ( ) = = 5 ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: SetCtlColors expected 3 parameters, got 4 \n " ) ) ;
2003-09-04 18:25:57 +00:00
return PS_ERROR ;
}
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( a + 1 ) , _T ( " transparent " ) ) ) {
2003-09-04 18:25:57 +00:00
c . flags | = CC_BKB ;
2003-12-29 14:27:33 +00:00
c . lbStyle = BS_NULL ;
2003-09-04 18:25:57 +00:00
c . bkmode = TRANSPARENT ;
}
else {
2003-09-07 08:53:22 +00:00
p = line . gettoken_str ( a + 1 ) ;
2003-09-04 18:25:57 +00:00
if ( * p ) {
2010-03-24 17:22:56 +00:00
int v = _tcstoul ( p , & p , 16 ) ;
2003-12-29 14:27:33 +00:00
c . bkc = ( ( v & 0xff ) < < 16 ) | ( v & 0xff00 ) | ( ( v & 0xff0000 ) > > 16 ) ;
2003-09-04 18:25:57 +00:00
c . flags | = CC_BK | CC_BKB ;
}
2003-12-29 14:27:33 +00:00
c . lbStyle = BS_SOLID ;
2003-09-04 18:25:57 +00:00
c . bkmode = OPAQUE ;
}
2003-09-07 08:53:22 +00:00
p = line . gettoken_str ( a ) ;
2003-09-04 18:25:57 +00:00
if ( * p ) {
2010-03-24 17:22:56 +00:00
int v = _tcstoul ( p , & p , 16 ) ;
2003-09-04 18:25:57 +00:00
c . text = ( ( v & 0xff ) < < 16 ) | ( v & 0xff00 ) | ( ( v & 0xff0000 ) > > 16 ) ;
c . flags | = CC_TEXT ;
}
2003-03-28 18:41:15 +00:00
}
2003-09-04 18:25:57 +00:00
2003-09-07 08:53:22 +00:00
if ( a = = 3 )
{
c . flags | = CC_BK | CC_BKB ;
2003-12-29 14:27:33 +00:00
c . lbStyle = BS_NULL ;
2004-09-17 16:48:38 +00:00
if ( ! * line . gettoken_str ( a + 1 ) )
2003-09-07 08:53:22 +00:00
{
2003-12-29 14:27:33 +00:00
c . bkc = COLOR_BTNFACE ;
2003-09-07 08:53:22 +00:00
c . flags | = CC_BK_SYS ;
}
c . flags | = CC_TEXT ;
2004-09-17 16:48:38 +00:00
if ( ! * line . gettoken_str ( a ) )
2003-09-07 08:53:22 +00:00
{
c . text = COLOR_BTNFACE ;
c . flags | = CC_TEXT_SYS ;
}
c . bkmode = OPAQUE ;
}
2003-09-04 18:25:57 +00:00
int i ;
int l = cur_ctlcolors - > getlen ( ) / sizeof ( ctlcolors ) ;
for ( i = 0 ; i < l ; i + + ) {
if ( ! memcmp ( ( ctlcolors * ) cur_ctlcolors - > get ( ) + i , & c , sizeof ( ctlcolors ) ) ) {
ent . offsets [ 1 ] = i * sizeof ( ctlcolors ) ;
break ;
}
}
if ( i > = l ) {
ent . offsets [ 1 ] = cur_ctlcolors - > add ( & c , sizeof ( ctlcolors ) ) ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetCtlColors: hwnd=%s %stext=%s background=%s \n " ) , line . gettoken_str ( 1 ) , a = = 2 ? _T ( " " ) : _T ( " /BRANDING " ) , line . gettoken_str ( a ) , line . gettoken_str ( a + 1 ) ) ;
2003-09-04 18:25:57 +00:00
}
2002-08-25 10:53:00 +00:00
return add_entry ( & ent ) ;
2002-11-15 13:15:42 +00:00
case TOK_CREATEFONT :
ent . which = EW_CREATEFONT ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2009-06-06 13:47:59 +00:00
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
2002-11-15 13:15:42 +00:00
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " CreateFont: output=%s \" %s \" " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-11-15 13:15:42 +00:00
{
int height = 0 ;
int weight = 0 ;
int flags = 0 ;
for ( int i = 3 ; i < line . getnumtokens ( ) ; i + + ) {
2010-03-24 17:22:56 +00:00
TCHAR * tok = line . gettoken_str ( i ) ;
2002-11-15 13:15:42 +00:00
if ( tok [ 0 ] = = ' / ' ) {
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( tok , _T ( " /ITALIC " ) ) ) {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " /ITALIC " ) ) ;
2002-11-15 13:15:42 +00:00
flags | = 1 ;
}
2010-03-29 14:24:47 +00:00
else if ( ! _tcsicmp ( tok , _T ( " /UNDERLINE " ) ) ) {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " /UNDERLINE " ) ) ;
2002-11-15 13:15:42 +00:00
flags | = 2 ;
}
2010-03-29 14:24:47 +00:00
else if ( ! _tcsicmp ( tok , _T ( " /STRIKE " ) ) ) {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " /STRIKE " ) ) ;
2002-11-15 13:15:42 +00:00
flags | = 4 ;
}
else {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " \n " ) ) ;
2002-11-15 13:15:42 +00:00
PRINTHELP ( ) ;
}
}
else {
if ( ! height ) {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " height=%s " ) , tok ) ;
2002-11-15 13:15:42 +00:00
height = add_string ( tok ) ;
}
else if ( ! weight ) {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " weight=%s " ) , tok ) ;
2002-11-15 13:15:42 +00:00
weight = add_string ( tok ) ;
}
else {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " \n " ) ) ;
2002-11-15 13:15:42 +00:00
PRINTHELP ( ) ;
}
}
}
ent . offsets [ 2 ] = height ;
ent . offsets [ 3 ] = weight ;
ent . offsets [ 4 ] = flags ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " \n " ) ) ;
2002-11-15 13:15:42 +00:00
return add_entry ( & ent ) ;
2003-07-16 22:36:18 +00:00
case TOK_ENABLEWINDOW :
ent . which = EW_SHOWWINDOW ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
ent . offsets [ 3 ] = 1 ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " EnableWindow: handle=%s enable=%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2003-07-16 22:36:18 +00:00
return add_entry ( & ent ) ;
2002-11-15 13:15:42 +00:00
case TOK_SHOWWINDOW :
ent . which = EW_SHOWWINDOW ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " ShowWindow: handle=%s show state=%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-11-15 13:15:42 +00:00
return add_entry ( & ent ) ;
2003-03-04 20:33:07 +00:00
case TOK_HIDEWINDOW :
ent . which = EW_SHOWWINDOW ;
2010-03-24 17:22:56 +00:00
ent . offsets [ 0 ] = add_string ( _T ( " $HWNDPARENT " ) ) ;
ent . offsets [ 1 ] = add_string ( _T ( " 0 " ) /*SW_HIDE*/ ) ;
2003-03-04 20:33:07 +00:00
ent . offsets [ 2 ] = 1 ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " HideWindow \n " ) ) ;
2003-03-04 20:33:07 +00:00
return add_entry ( & ent ) ;
2003-03-29 17:16:09 +00:00
case TOK_BRINGTOFRONT :
{
int ret ;
ent . which = EW_SHOWWINDOW ;
2010-03-24 17:22:56 +00:00
ent . offsets [ 0 ] = add_string ( _T ( " $HWNDPARENT " ) ) ;
ent . offsets [ 1 ] = add_string ( _T ( " 5 " ) /*SW_SHOW*/ ) ;
2003-03-29 17:16:09 +00:00
ret = add_entry ( & ent ) ;
if ( ret ! = PS_OK ) return ret ;
ent . which = EW_BRINGTOFRONT ;
ent . offsets [ 0 ] = 0 ;
ent . offsets [ 1 ] = 0 ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " BringToFront \n " ) ) ;
2003-03-29 17:16:09 +00:00
}
return add_entry ( & ent ) ;
2002-09-18 18:39:24 +00:00
# else //NSIS_CONFIG_ENHANCEDUI_SUPPORT
case TOK_GETDLGITEM :
2003-09-04 18:25:57 +00:00
case TOK_SETCTLCOLORS :
2002-11-15 13:15:42 +00:00
case TOK_SHOWWINDOW :
2003-03-29 17:16:09 +00:00
case TOK_BRINGTOFRONT :
2002-11-15 13:15:42 +00:00
case TOK_CREATEFONT :
2003-03-04 20:33:07 +00:00
case TOK_HIDEWINDOW :
2003-07-16 22:36:18 +00:00
case TOK_ENABLEWINDOW :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_ENHANCEDUI_SUPPORT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-09-18 18:39:24 +00:00
return PS_ERROR ;
# endif //NSIS_CONFIG_ENHANCEDUI_SUPPORT
2002-08-02 10:01:35 +00:00
# else //!NSIS_SUPPORT_HWNDS
case TOK_ISWINDOW :
case TOK_SENDMESSAGE :
case TOK_FINDWINDOW :
2002-08-21 19:09:09 +00:00
case TOK_GETDLGITEM :
2004-01-04 17:25:59 +00:00
case TOK_SETCTLCOLORS :
2002-11-15 13:15:42 +00:00
case TOK_SHOWWINDOW :
2003-07-16 22:36:18 +00:00
case TOK_ENABLEWINDOW :
2002-11-15 13:15:42 +00:00
case TOK_CREATEFONT :
2003-03-04 20:33:07 +00:00
case TOK_HIDEWINDOW :
2003-03-29 17:16:09 +00:00
case TOK_BRINGTOFRONT :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_HWNDS not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_HWNDS
case TOK_DELETE :
# ifdef NSIS_SUPPORT_DELETE
{
int a = 1 ;
ent . which = EW_DELETEFILE ;
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( a ) , _T ( " /REBOOTOK " ) ) )
2002-08-02 10:01:35 +00:00
{
a + + ;
2004-08-06 17:03:07 +00:00
ent . offsets [ 1 ] = DEL_REBOOT ;
2002-08-02 10:01:35 +00:00
# ifndef NSIS_SUPPORT_MOVEONREBOOT
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: /REBOOTOK specified, NSIS_SUPPORT_MOVEONREBOOT not defined \n " ) ) ;
2002-08-02 10:01:35 +00:00
PRINTHELP ( )
# endif
}
2010-03-24 17:22:56 +00:00
else if ( line . gettoken_str ( 1 ) [ 0 ] = = _T ( ' / ' ) )
2002-08-02 10:01:35 +00:00
{
a = line . getnumtokens ( ) ;
}
if ( line . getnumtokens ( ) ! = a + 1 ) PRINTHELP ( )
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( a ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Delete: %s \" %s \" \n " ) , ent . offsets [ 1 ] ? _T ( " /REBOOTOK " ) : _T ( " " ) , line . gettoken_str ( a ) ) ;
2003-09-04 18:25:57 +00:00
DefineInnerLangString ( NLF_DEL_FILE ) ;
# ifdef NSIS_SUPPORT_MOVEONREBOOT
DefineInnerLangString ( NLF_DEL_ON_REBOOT ) ;
# endif
2002-08-02 10:01:35 +00:00
}
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_DELETE
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_DELETE not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_DELETE
case TOK_RMDIR :
# ifdef NSIS_SUPPORT_RMDIR
{
int a = 1 ;
ent . which = EW_RMDIR ;
2004-08-06 17:03:07 +00:00
ent . offsets [ 1 ] = DEL_DIR ;
2010-03-24 17:22:56 +00:00
while ( line . gettoken_str ( a ) [ 0 ] = = _T ( ' / ' ) )
2002-08-02 10:01:35 +00:00
{
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( a ) , _T ( " /r " ) ) )
2004-08-06 17:03:07 +00:00
{
if ( a = = 3 ) PRINTHELP ( ) ;
a + + ;
ent . offsets [ 1 ] | = DEL_RECURSE ;
}
2010-03-29 14:24:47 +00:00
else if ( ! _tcsicmp ( line . gettoken_str ( a ) , _T ( " /REBOOTOK " ) ) )
2004-08-06 17:03:07 +00:00
{
if ( a = = 3 ) PRINTHELP ( ) ;
a + + ;
ent . offsets [ 1 ] | = DEL_REBOOT ;
2004-12-10 11:09:10 +00:00
}
2004-08-06 17:03:07 +00:00
else PRINTHELP ( ) ;
2002-08-02 10:01:35 +00:00
}
2004-08-06 17:03:07 +00:00
if ( a < line . getnumtokens ( ) - 1 ) PRINTHELP ( ) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( a ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " RMDir: " ) ) ;
2004-08-06 17:03:07 +00:00
if ( a > 1 )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %s " ) , line . gettoken_str ( 1 ) ) ;
2004-08-06 17:03:07 +00:00
if ( a > 2 )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %s " ) , line . gettoken_str ( 2 ) ) ;
SCRIPT_MSG ( _T ( " \" %s \" \n " ) , line . gettoken_str ( a ) ) ;
2003-09-04 18:25:57 +00:00
DefineInnerLangString ( NLF_REMOVE_DIR ) ;
2004-08-06 17:03:07 +00:00
DefineInnerLangString ( NLF_DEL_FILE ) ;
# ifdef NSIS_SUPPORT_MOVEONREBOOT
DefineInnerLangString ( NLF_DEL_ON_REBOOT ) ;
# endif
2002-08-02 10:01:35 +00:00
}
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_RMDIR
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_RMDIR not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_RMDIR
2002-09-21 02:10:04 +00:00
case TOK_RESERVEFILE :
2002-08-02 10:01:35 +00:00
case TOK_FILE :
# ifdef NSIS_SUPPORT_FILE
{
2010-03-24 17:22:56 +00:00
set < tstring > excluded ;
2002-10-20 17:27:37 +00:00
int a = 1 , attrib = 0 , rec = 0 , fatal = 1 ;
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( a ) , _T ( " /nonfatal " ) ) ) {
2002-10-20 17:27:37 +00:00
fatal = 0 ;
a + + ;
}
2010-03-29 14:24:47 +00:00
if ( which_token = = TOK_FILE & & ! _tcsicmp ( line . gettoken_str ( a ) , _T ( " /a " ) ) )
2002-08-02 10:01:35 +00:00
{
2004-11-26 15:44:02 +00:00
# ifdef _WIN32
2002-08-02 10:01:35 +00:00
attrib = 1 ;
2004-11-26 15:44:02 +00:00
# else
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %sFile /a is disabled for non Win32 platforms. " ) , ( which_token = = TOK_FILE ) ? _T ( " " ) : _T ( " Reserve " ) ) ;
2004-11-26 15:44:02 +00:00
# endif
2002-08-02 10:01:35 +00:00
a + + ;
}
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( a ) , _T ( " /r " ) ) )
2002-08-02 10:01:35 +00:00
{
rec = 1 ;
a + + ;
}
2010-03-29 14:24:47 +00:00
else if ( which_token = = TOK_FILE & & ! _tcsncicmp ( line . gettoken_str ( a ) , _T ( " /oname= " ) , 7 ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR * on = line . gettoken_str ( a ) + 7 ;
2002-08-02 10:01:35 +00:00
a + + ;
2010-03-24 17:22:56 +00:00
if ( ! * on | | line . getnumtokens ( ) ! = a + 1 | | _tcsstr ( on , _T ( " * " ) ) | | _tcsstr ( on , _T ( " ? " ) ) ) PRINTHELP ( )
2002-08-02 10:01:35 +00:00
2010-03-24 17:22:56 +00:00
if ( on [ 0 ] = = _T ( ' " ' ) )
2005-06-03 18:45:51 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " %sFile: output name must not begin with a quote, use \" /oname=name with spaces \" . \n " ) , ( which_token = = TOK_FILE ) ? _T ( " " ) : _T ( " Reserve " ) , line . gettoken_str ( a ) ) ;
2005-06-03 18:45:51 +00:00
PRINTHELP ( ) ;
}
2002-08-02 10:01:35 +00:00
int tf = 0 ;
2010-03-24 17:22:56 +00:00
TCHAR * fn = line . gettoken_str ( a ) ;
2009-03-28 09:47:26 +00:00
PATH_CONVERT ( fn ) ;
2004-11-26 15:44:02 +00:00
int v = do_add_file ( fn , attrib , 0 , & tf , on ) ;
2002-08-02 10:01:35 +00:00
if ( v ! = PS_OK ) return v ;
if ( tf > 1 ) PRINTHELP ( )
if ( ! tf )
{
2003-10-27 15:46:33 +00:00
if ( fatal )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " %sFile: \" %s \" -> no files found. \n " ) , ( which_token = = TOK_FILE ) ? _T ( " " ) : _T ( " Reserve " ) , line . gettoken_str ( a ) ) ;
2003-10-27 15:46:33 +00:00
PRINTHELP ( )
}
else
{
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %sFile: \" %s \" -> no files found " ) , ( which_token = = TOK_FILE ) ? _T ( " " ) : _T ( " Reserve " ) , line . gettoken_str ( a ) ) ;
2005-12-31 14:23:57 +00:00
// workaround for bug #1299100
// add a nop opcode so relative jumps will work as expected
add_entry_direct ( EW_NOP ) ;
2003-10-27 15:46:33 +00:00
}
2002-08-02 10:01:35 +00:00
}
return PS_OK ;
}
2010-03-29 14:24:47 +00:00
if ( ! _tcsncicmp ( line . gettoken_str ( a ) , _T ( " /x " ) , 2 ) )
2004-11-26 17:18:10 +00:00
{
2010-03-29 14:24:47 +00:00
while ( ! _tcsncicmp ( line . gettoken_str ( a ) , _T ( " /x " ) , 2 ) )
2004-11-26 17:18:10 +00:00
{
a + + ;
if ( line . getnumtokens ( ) < a + 1 ) PRINTHELP ( )
excluded . insert ( line . gettoken_str ( a ) ) ;
a + + ;
}
}
2004-08-20 15:40:38 +00:00
# ifdef _WIN32
2010-03-24 17:22:56 +00:00
if ( line . gettoken_str ( a ) [ 0 ] = = _T ( ' / ' ) ) PRINTHELP ( )
2004-08-20 15:40:38 +00:00
# endif
2002-08-02 10:01:35 +00:00
if ( line . getnumtokens ( ) < a + 1 ) PRINTHELP ( )
while ( a < line . getnumtokens ( ) )
{
2004-08-20 15:40:38 +00:00
# ifdef _WIN32
2010-03-24 17:22:56 +00:00
if ( line . gettoken_str ( a ) [ 0 ] = = _T ( ' / ' ) ) PRINTHELP ( )
2004-08-20 15:40:38 +00:00
# endif
2010-03-24 17:22:56 +00:00
TCHAR buf [ 32 ] ;
TCHAR * t = line . gettoken_str ( a + + ) ;
if ( t [ 0 ] & & CharNext ( t ) [ 0 ] = = _T ( ' : ' ) & & CharNext ( t ) [ 1 ] = = _T ( ' \\ ' ) & & ! CharNext ( t ) [ 2 ] )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
_tcscpy ( buf , _T ( " X: \\ *.* " ) ) ;
2002-08-02 10:01:35 +00:00
buf [ 0 ] = t [ 0 ] ;
t = buf ;
}
int tf = 0 ;
2010-03-24 17:22:56 +00:00
TCHAR * fn = my_convert ( t ) ;
2004-11-26 17:18:10 +00:00
int v = do_add_file ( fn , attrib , rec , & tf , NULL , which_token = = TOK_FILE , NULL , excluded ) ;
2004-08-20 15:40:38 +00:00
my_convert_free ( fn ) ;
2002-08-02 10:01:35 +00:00
if ( v ! = PS_OK ) return v ;
if ( ! tf )
{
2004-06-25 19:53:05 +00:00
if ( fatal )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " %sFile: \" %s \" -> no files found. \n " ) , ( which_token = = TOK_FILE ) ? _T ( " " ) : _T ( " Reserve " ) , t ) ;
2004-06-25 19:53:05 +00:00
PRINTHELP ( ) ;
}
else
{
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %sFile: \" %s \" -> no files found. " ) , ( which_token = = TOK_FILE ) ? _T ( " " ) : _T ( " Reserve " ) , t ) ;
2004-06-25 19:53:05 +00:00
}
2002-08-02 10:01:35 +00:00
}
}
}
return PS_OK ;
# else //!NSIS_SUPPORT_FILE
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_FILE not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_FILE
# ifdef NSIS_SUPPORT_COPYFILES
case TOK_COPYFILES :
{
ent . which = EW_COPYFILES ;
ent . offsets [ 2 ] = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_SIMPLEPROGRESS ;
2002-08-11 18:57:16 +00:00
2002-08-02 10:01:35 +00:00
int a = 1 ;
int x ;
for ( x = 0 ; x < 2 ; x + + )
{
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( a ) , _T ( " /SILENT " ) ) )
2002-08-02 10:01:35 +00:00
{
a + + ;
ent . offsets [ 2 ] & = ~ FOF_SIMPLEPROGRESS ;
ent . offsets [ 2 ] | = FOF_SILENT ;
}
2010-03-29 14:24:47 +00:00
else if ( ! _tcsicmp ( line . gettoken_str ( a ) , _T ( " /FILESONLY " ) ) )
2002-08-02 10:01:35 +00:00
{
a + + ;
ent . offsets [ 2 ] | = FOF_FILESONLY ;
}
2010-03-24 17:22:56 +00:00
else if ( line . gettoken_str ( a ) [ 0 ] = = _T ( ' / ' ) ) PRINTHELP ( )
2002-08-02 10:01:35 +00:00
else break ;
2002-08-11 18:57:16 +00:00
}
2004-10-01 09:57:01 +00:00
if ( line . getnumtokens ( ) < a + 2 ) PRINTHELP ( )
2002-08-02 10:01:35 +00:00
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( a ) ) ;
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( a + 1 ) ) ;
2010-03-24 17:22:56 +00:00
tstring copy_to = tstring ( _T ( " $(^CopyTo) " ) ) + line . gettoken_str ( a + 1 ) ;
2007-07-05 17:43:22 +00:00
ent . offsets [ 3 ] = add_string ( copy_to . c_str ( ) ) ;
2002-08-02 10:01:35 +00:00
int s ;
int size_kb = line . gettoken_int ( a + 2 , & s ) ;
if ( ! s & & line . gettoken_str ( a + 2 ) [ 0 ] ) PRINTHELP ( )
section_add_size_kb ( size_kb ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " CopyFiles: %s \" %s \" -> \" %s \" , size=%iKB \n " ) , ent . offsets [ 2 ] & FOF_SILENT ? _T ( " (silent) " ) : _T ( " " ) , line . gettoken_str ( a ) , line . gettoken_str ( a + 1 ) , size_kb ) ;
2003-09-04 18:25:57 +00:00
DefineInnerLangString ( NLF_COPY_FAILED ) ;
DefineInnerLangString ( NLF_COPY_TO ) ;
2002-08-02 10:01:35 +00:00
}
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_COPYFILES
case TOK_COPYFILES :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_COPYFILES not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_COPYFILES
case TOK_SETFILEATTRIBUTES :
{
2010-03-24 17:22:56 +00:00
# define MBD(x) {x,_T(#x)},
2002-08-11 18:57:16 +00:00
struct
2002-08-02 10:01:35 +00:00
{
int id ;
2010-03-24 17:22:56 +00:00
const TCHAR * str ;
2002-08-02 10:01:35 +00:00
} list [ ] =
{
MBD ( FILE_ATTRIBUTE_NORMAL )
MBD ( FILE_ATTRIBUTE_ARCHIVE )
MBD ( FILE_ATTRIBUTE_HIDDEN )
MBD ( FILE_ATTRIBUTE_OFFLINE )
MBD ( FILE_ATTRIBUTE_READONLY )
MBD ( FILE_ATTRIBUTE_SYSTEM )
MBD ( FILE_ATTRIBUTE_TEMPORARY )
2010-03-24 17:22:56 +00:00
{ FILE_ATTRIBUTE_NORMAL , _T ( " NORMAL " ) } ,
{ FILE_ATTRIBUTE_ARCHIVE , _T ( " ARCHIVE " ) } ,
{ FILE_ATTRIBUTE_HIDDEN , _T ( " HIDDEN " ) } ,
{ FILE_ATTRIBUTE_OFFLINE , _T ( " OFFLINE " ) } ,
{ FILE_ATTRIBUTE_READONLY , _T ( " READONLY " ) } ,
{ FILE_ATTRIBUTE_SYSTEM , _T ( " SYSTEM " ) } ,
{ FILE_ATTRIBUTE_TEMPORARY , _T ( " TEMPORARY " ) } ,
{ FILE_ATTRIBUTE_NORMAL , _T ( " 0 " ) } ,
2002-08-02 10:01:35 +00:00
} ;
# undef MBD
int r = 0 ;
int x ;
2010-03-24 17:22:56 +00:00
TCHAR * p = line . gettoken_str ( 2 ) ;
2002-08-02 10:01:35 +00:00
while ( * p )
{
2010-03-24 17:22:56 +00:00
TCHAR * np = p ;
while ( * np & & * np ! = _T ( ' | ' ) ) np + + ;
2002-08-02 10:01:35 +00:00
if ( * np ) * np + + = 0 ;
2010-03-30 17:50:08 +00:00
for ( x = 0 ; ( unsigned ) x < COUNTOF ( list ) & & _tcsicmp ( list [ x ] . str , p ) ; x + + ) ;
2002-08-02 10:01:35 +00:00
2010-03-30 17:50:08 +00:00
if ( ( unsigned ) x < COUNTOF ( list ) )
2002-08-02 10:01:35 +00:00
{
r | = list [ x ] . id ;
}
else PRINTHELP ( )
p = np ;
}
ent . which = EW_SETFILEATTRIBUTES ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
ent . offsets [ 1 ] = r ;
}
return add_entry ( & ent ) ;
case TOK_SLEEP :
{
2002-08-11 18:57:16 +00:00
ent . which = EW_SLEEP ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Sleep: %s ms \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
}
return add_entry ( & ent ) ;
case TOK_IFFILEEXISTS :
ent . which = EW_IFFILEEXISTS ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2002-08-11 18:57:16 +00:00
if ( process_jump ( line , 2 , & ent . offsets [ 1 ] ) | |
2002-08-02 10:01:35 +00:00
process_jump ( line , 3 , & ent . offsets [ 2 ] ) ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " IfFileExists: \" %s \" ? %s : %s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_QUIT :
ent . which = EW_QUIT ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Quit \n " ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_ABORT :
ent . which = EW_ABORT ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Abort: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_SETDETAILSVIEW :
{
2010-03-24 17:22:56 +00:00
int v = line . gettoken_enum ( 1 , _T ( " hide \0 show \0 " ) ) ;
2002-08-02 10:01:35 +00:00
ent . which = EW_CHDETAILSVIEW ;
if ( v < 0 ) PRINTHELP ( )
ent . offsets [ 0 ] = v ? SW_SHOWNA : SW_HIDE ;
ent . offsets [ 1 ] = v ? SW_HIDE : SW_SHOWNA ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetDetailsView: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
}
return add_entry ( & ent ) ;
case TOK_SETDETAILSPRINT :
2007-09-08 17:20:11 +00:00
{
ent . which = EW_SETFLAG ;
ent . offsets [ 0 ] = FLAG_OFFSET ( status_update ) ;
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " both \0 textonly \0 listonly \0 none \0 lastused \0 " ) ) ;
2007-09-08 17:20:11 +00:00
if ( k < 0 ) PRINTHELP ( )
2007-09-21 18:20:12 +00:00
if ( k = = 4 )
2007-09-08 17:20:11 +00:00
{
ent . offsets [ 2 ] = 1 ;
}
else
{
2007-09-21 18:20:12 +00:00
// both 0
// textonly 2
// listonly 4
// none 6
ent . offsets [ 1 ] = add_intstring ( k * 2 ) ;
2003-09-04 18:25:57 +00:00
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetDetailsPrint: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2007-09-08 17:20:11 +00:00
}
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_SETAUTOCLOSE :
2003-05-24 13:50:24 +00:00
{
2003-02-07 23:04:25 +00:00
ent . which = EW_SETFLAG ;
2003-04-02 19:54:53 +00:00
ent . offsets [ 0 ] = FLAG_OFFSET ( autoclose ) ;
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " false \0 true \0 " ) ) ;
2003-05-24 13:50:24 +00:00
if ( k < 0 ) PRINTHELP ( )
ent . offsets [ 1 ] = add_intstring ( k ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetAutoClose: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2003-05-24 13:50:24 +00:00
}
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_IFERRORS :
2003-04-02 19:54:53 +00:00
ent . which = EW_IFFLAG ;
2002-08-11 18:57:16 +00:00
if ( process_jump ( line , 1 , & ent . offsets [ 0 ] ) | |
2002-08-02 10:01:35 +00:00
process_jump ( line , 2 , & ent . offsets [ 1 ] ) ) PRINTHELP ( )
2003-04-02 19:54:53 +00:00
ent . offsets [ 2 ] = FLAG_OFFSET ( exec_error ) ;
ent . offsets [ 3 ] = 0 ; //new value mask - clean error
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " IfErrors ?%s:%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2003-04-04 11:34:03 +00:00
return add_entry ( & ent ) ;
2003-04-02 19:54:53 +00:00
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 ) ;
2003-06-08 14:45:56 +00:00
ent . offsets [ 3 ] = ~ 0 ; //new value mask - keep flag
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " IfAbort ?%s:%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_CLEARERRORS :
2003-02-07 23:04:25 +00:00
ent . which = EW_SETFLAG ;
2003-04-02 19:54:53 +00:00
ent . offsets [ 0 ] = FLAG_OFFSET ( exec_error ) ;
2003-05-24 13:50:24 +00:00
ent . offsets [ 1 ] = add_intstring ( 0 ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " ClearErrors \n " ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_SETERRORS :
2003-02-07 23:04:25 +00:00
ent . which = EW_SETFLAG ;
2003-04-02 19:54:53 +00:00
ent . offsets [ 0 ] = FLAG_OFFSET ( exec_error ) ;
2003-05-24 13:50:24 +00:00
ent . offsets [ 1 ] = add_intstring ( 1 ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetErrors \n " ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
2004-09-25 10:49:08 +00:00
case TOK_SETERRORLEVEL :
ent . which = EW_SETFLAG ;
ent . offsets [ 0 ] = FLAG_OFFSET ( errlvl ) ;
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetErrorLevel: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2004-09-25 10:49:08 +00:00
return add_entry ( & ent ) ;
case TOK_GETERRORLEVEL :
ent . which = EW_GETFLAG ;
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
ent . offsets [ 1 ] = FLAG_OFFSET ( errlvl ) ;
if ( line . gettoken_str ( 1 ) [ 0 ] & & ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " GetErrorLevel: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2004-09-25 10:49:08 +00:00
return add_entry ( & ent ) ;
2002-08-02 10:01:35 +00:00
# ifdef NSIS_SUPPORT_STROPTS
case TOK_STRLEN :
ent . which = EW_STRLEN ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " StrLen %s \" %s \" \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_STRCPY :
ent . which = EW_ASSIGNVAR ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 3 ) ) ;
ent . offsets [ 3 ] = add_string ( line . gettoken_str ( 4 ) ) ;
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " StrCpy %s \" %s \" (%s) (%s) \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_GETFUNCTIONADDR :
ent . which = EW_GETFUNCTIONADDR ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 1 ] = ns_func . add ( line . gettoken_str ( 2 ) , 0 ) ;
2002-09-29 20:25:15 +00:00
ent . offsets [ 2 ] = 0 ;
ent . offsets [ 3 ] = 0 ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " GetFunctionAddress: %s %s " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_GETLABELADDR :
ent . which = EW_GETLABELADDR ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 0 ] < 0 | | process_jump ( line , 2 , & ent . offsets [ 1 ] ) ) PRINTHELP ( )
2002-09-29 20:25:15 +00:00
ent . offsets [ 2 ] = 0 ;
ent . offsets [ 3 ] = 0 ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " GetLabelAddress: %s %s " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_GETCURRENTADDR :
ent . which = EW_ASSIGNVAR ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR buf [ 32 ] ;
wsprintf ( buf , _T ( " %d " ) , 1 + ( cur_header - > blocks [ NB_ENTRIES ] . num ) ) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 1 ] = add_string ( buf ) ;
}
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
2002-09-29 20:25:15 +00:00
ent . offsets [ 2 ] = 0 ;
ent . offsets [ 3 ] = 0 ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " GetCurrentAddress: %s " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_STRCMP :
2006-01-06 16:00:15 +00:00
case TOK_STRCMPS :
2002-08-02 10:01:35 +00:00
ent . which = EW_STRCMP ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
2006-01-06 16:00:15 +00:00
ent . offsets [ 4 ] = which_token = = TOK_STRCMPS ;
2002-08-02 10:01:35 +00:00
if ( process_jump ( line , 3 , & ent . offsets [ 2 ] ) | |
process_jump ( line , 4 , & ent . offsets [ 3 ] ) ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %s \" %s \" \" %s \" equal=%s, nonequal=%s \n " ) , line . gettoken_str ( 0 ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_GETDLLVERSIONLOCAL :
{
2007-04-24 14:11:35 +00:00
DWORD low , high ;
if ( ! GetDLLVersion ( line . gettoken_str ( 1 ) , high , low ) )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " GetDLLVersionLocal: error reading version info from \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
ent . which = EW_ASSIGNVAR ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 2 ) ;
2007-04-24 14:11:35 +00:00
ent . offsets [ 1 ] = add_intstring ( high ) ;
2002-09-29 20:25:15 +00:00
ent . offsets [ 2 ] = 0 ;
ent . offsets [ 3 ] = 0 ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
add_entry ( & ent ) ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 3 ) ;
2007-04-24 14:11:35 +00:00
ent . offsets [ 1 ] = add_intstring ( low ) ;
2002-09-29 20:25:15 +00:00
ent . offsets [ 2 ] = 0 ;
ent . offsets [ 3 ] = 0 ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " GetDLLVersionLocal: %s (%u,%u)->(%s,%s) \n " ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 1 ) , high , low , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) ) ;
}
return add_entry ( & ent ) ;
case TOK_GETFILETIMELOCAL :
{
2010-03-24 17:22:56 +00:00
TCHAR buf [ 129 ] ;
2004-03-12 20:43:54 +00:00
DWORD high = 0 , low = 0 ;
2004-03-29 20:21:00 +00:00
# ifdef _WIN32
2002-08-02 10:01:35 +00:00
int flag = 0 ;
HANDLE hFile = CreateFile ( line . gettoken_str ( 1 ) , 0 , 0 , NULL , OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL ) ;
if ( hFile ! = INVALID_HANDLE_VALUE )
{
FILETIME ft ;
if ( GetFileTime ( hFile , NULL , NULL , & ft ) )
{
high = ft . dwHighDateTime ;
low = ft . dwLowDateTime ;
flag = 1 ;
2002-08-11 18:57:16 +00:00
}
2002-08-02 10:01:35 +00:00
CloseHandle ( hFile ) ;
}
if ( ! flag )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " GetFileTimeLocal: error reading date from \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
2004-03-29 20:21:00 +00:00
# else
struct stat st ;
if ( ! stat ( line . gettoken_str ( 1 ) , & st ) )
{
2006-08-19 12:47:17 +00:00
unsigned long long ll = ( st . st_mtime * 10000000LL ) + 116444736000000000LL ;
high = ( DWORD ) ( ll > > 32 ) ;
low = ( DWORD ) ll ;
2004-03-29 20:21:00 +00:00
}
else
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " GetFileTimeLocal: error reading date from \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2004-03-29 20:21:00 +00:00
return PS_ERROR ;
}
# endif
2002-08-02 10:01:35 +00:00
ent . which = EW_ASSIGNVAR ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 2 ) ;
2010-03-24 17:22:56 +00:00
wsprintf ( buf , _T ( " %u " ) , high ) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 1 ] = add_string ( buf ) ;
2002-09-29 20:25:15 +00:00
ent . offsets [ 2 ] = 0 ;
ent . offsets [ 3 ] = 0 ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
add_entry ( & ent ) ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 3 ) ;
2010-03-24 17:22:56 +00:00
wsprintf ( buf , _T ( " %u " ) , low ) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 1 ] = add_string ( buf ) ;
2002-09-29 20:25:15 +00:00
ent . offsets [ 2 ] = 0 ;
ent . offsets [ 3 ] = 0 ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " GetFileTimeLocal: %s (%u,%u)->(%s,%s) \n " ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 1 ) , high , low , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) ) ;
}
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_STROPTS
case TOK_GETDLLVERSIONLOCAL :
case TOK_GETFILETIMELOCAL :
case TOK_GETFUNCTIONADDR :
case TOK_GETLABELADDR :
case TOK_GETCURRENTADDR :
case TOK_STRLEN :
case TOK_STRCPY :
case TOK_STRCMP :
2006-01-06 16:00:15 +00:00
case TOK_STRCMPS :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_STROPTS not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_STROPTS
# ifdef NSIS_SUPPORT_INIFILES
case TOK_DELETEINISEC :
case TOK_DELETEINISTR :
{
2010-03-24 17:22:56 +00:00
const TCHAR * vname = _T ( " " ) ;
const TCHAR * space = _T ( " " ) ;
2002-08-02 10:01:35 +00:00
ent . which = EW_WRITEINI ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 2 ) ) ; // section name
2002-08-11 18:57:16 +00:00
if ( line . getnumtokens ( ) > 3 )
2002-08-02 10:01:35 +00:00
{
vname = line . gettoken_str ( 3 ) ;
ent . offsets [ 1 ] = add_string ( vname ) ; // value name
2010-03-24 17:22:56 +00:00
space = _T ( " " ) ;
2002-08-02 10:01:35 +00:00
}
2002-09-29 20:25:15 +00:00
else ent . offsets [ 1 ] = 0 ;
ent . offsets [ 2 ] = 0 ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 3 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " DeleteINI%s: [%s] %s%sin %s \n " ) , * vname ? _T ( " Str " ) : _T ( " Sec " ) ,
2003-03-15 13:54:23 +00:00
line . gettoken_str ( 2 ) , vname , space , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
}
return add_entry ( & ent ) ;
2003-03-17 13:23:01 +00:00
case TOK_FLUSHINI :
ent . which = EW_WRITEINI ;
ent . offsets [ 3 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " FlushINI: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2003-03-17 13:23:01 +00:00
return add_entry ( & ent ) ;
2002-08-02 10:01:35 +00:00
case TOK_WRITEINISTR :
ent . which = EW_WRITEINI ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 2 ) ) ;
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 3 ) ) ;
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 4 ) ) ;
ent . offsets [ 3 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2003-03-15 13:54:23 +00:00
ent . offsets [ 4 ] = 1 ; // write
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " WriteINIStr: [%s] %s=%s in %s \n " ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) , line . gettoken_str ( 1 ) ) ;
return add_entry ( & ent ) ;
case TOK_READINISTR :
ent . which = EW_READINISTR ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 3 ) ) ;
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 4 ) ) ;
ent . offsets [ 3 ] = add_string ( line . gettoken_str ( 2 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " ReadINIStr %s [%s]:%s from %s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_INIFILES
case TOK_DELETEINISEC :
case TOK_DELETEINISTR :
2003-03-17 13:23:01 +00:00
case TOK_FLUSHINI :
2002-08-02 10:01:35 +00:00
case TOK_WRITEINISTR :
case TOK_READINISTR :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_INIFILES not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_INIFILES
case TOK_DETAILPRINT :
ent . which = EW_UPDATETEXT ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
ent . offsets [ 1 ] = 0 ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " DetailPrint: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
# ifdef NSIS_SUPPORT_FNUTIL
case TOK_GETTEMPFILENAME :
ent . which = EW_GETTEMPFILENAME ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2003-07-18 14:22:17 +00:00
if ( line . getnumtokens ( ) = = 3 )
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
else
2010-03-24 17:22:56 +00:00
ent . offsets [ 1 ] = add_string ( _T ( " $TEMP " ) ) ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " GetTempFileName -> %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_GETFULLPATHNAME :
{
int a = 0 ;
ent . which = EW_GETFULLPATHNAME ;
2010-03-29 14:24:47 +00:00
if ( line . getnumtokens ( ) = = 4 & & ! _tcsicmp ( line . gettoken_str ( 1 ) , _T ( " /SHORT " ) ) ) a + + ;
2010-03-24 17:22:56 +00:00
else if ( line . getnumtokens ( ) = = 4 | | * line . gettoken_str ( 1 ) = = _T ( ' / ' ) ) PRINTHELP ( )
2003-11-27 20:19:48 +00:00
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 2 + a ) ) ;
ent . offsets [ 1 ] = GetUserVarIndex ( line , 1 + a ) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 2 ] = ! a ;
2007-12-21 22:28:04 +00:00
if ( ent . offsets [ 1 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " GetFullPathName: %s->%s (%d) \n " ) ,
line . gettoken_str ( 2 + a ) , line . gettoken_str ( 1 + a ) , a ? _T ( " sfn " ) : _T ( " lfn " ) ) ;
2002-08-02 10:01:35 +00:00
}
return add_entry ( & ent ) ;
case TOK_SEARCHPATH :
ent . which = EW_SEARCHPATH ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SearchPath %s %s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
# else
case TOK_SEARCHPATH :
case TOK_GETTEMPFILENAME :
case TOK_GETFULLPATHNAME :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_FNUTIL not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif
2002-08-11 18:57:16 +00:00
case TOK_GETDLLVERSION :
2002-08-02 10:01:35 +00:00
# ifdef NSIS_SUPPORT_GETDLLVERSION
ent . which = EW_GETDLLVERSION ;
2003-11-27 20:19:48 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 2 ) ;
ent . offsets [ 1 ] = GetUserVarIndex ( line , 3 ) ;
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 1 ) ) ;
if ( ent . offsets [ 0 ] < 0 | | ent . offsets [ 1 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " GetDLLVersion: %s->%s,%s \n " ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) ) ;
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_GETDLLVERSION
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_GETDLLVERSION not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_GETDLLVERSION
case TOK_GETFILETIME :
# ifdef NSIS_SUPPORT_GETFILETIME
ent . which = EW_GETFILETIME ;
2003-11-27 20:19:48 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 2 ) ;
ent . offsets [ 1 ] = GetUserVarIndex ( line , 3 ) ;
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 1 ) ) ;
if ( ent . offsets [ 0 ] < 0 | | ent . offsets [ 1 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " GetFileTime: %s->%s,%s \n " ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) ) ;
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_GETFILETIME
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_GETFILETIME not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_GETFILETIME
# ifdef NSIS_SUPPORT_INTOPTS
case TOK_INTOP :
ent . which = EW_INTOP ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2010-03-24 17:22:56 +00:00
ent . offsets [ 3 ] = line . gettoken_enum ( 3 , _T ( " + \0 - \0 * \0 / \0 | \0 & \0 ^ \0 ! \0 || \0 && \0 % \0 << \0 >> \0 ~ \0 " ) ) ;
2004-06-25 15:24:20 +00:00
if ( ent . offsets [ 0 ] < 0 | | ent . offsets [ 3 ] < 0 | |
( ( ent . offsets [ 3 ] = = 7 | | ent . offsets [ 3 ] = = 13 ) & & line . getnumtokens ( ) > 4 ) )
PRINTHELP ( )
2002-08-02 10:01:35 +00:00
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
2004-06-25 15:24:20 +00:00
if ( ent . offsets [ 3 ] ! = 7 & & ent . offsets [ 3 ] ! = 13 ) ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 4 ) ) ;
if ( ent . offsets [ 3 ] = = 13 ) {
2003-03-28 18:41:15 +00:00
ent . offsets [ 3 ] = 6 ;
2010-03-24 17:22:56 +00:00
ent . offsets [ 2 ] = add_string ( _T ( " 0xFFFFFFFF " ) ) ;
2003-03-28 18:41:15 +00:00
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " IntOp: %s=%s%s%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_INTFMT :
ent . which = EW_INTFMT ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 3 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " IntFmt: %s->%s (fmt:%s) \n " ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_INTCMP :
case TOK_INTCMPU :
2003-03-20 20:49:13 +00:00
ent . which = EW_INTCMP ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
2003-03-20 20:49:13 +00:00
ent . offsets [ 5 ] = which_token = = TOK_INTCMPU ;
2002-08-02 10:01:35 +00:00
if ( process_jump ( line , 3 , & ent . offsets [ 2 ] ) | |
2002-08-11 18:57:16 +00:00
process_jump ( line , 4 , & ent . offsets [ 3 ] ) | |
2002-08-02 10:01:35 +00:00
process_jump ( line , 5 , & ent . offsets [ 4 ] ) ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %s %s:%s equal=%s, < %s, > %s \n " ) , line . gettoken_str ( 0 ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) , line . gettoken_str ( 5 ) ) ;
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_INTOPTS
case TOK_INTOP :
case TOK_INTCMP :
case TOK_INTFMT :
case TOK_INTCMPU :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_INTOPTS not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_INTOPTS
# ifdef NSIS_SUPPORT_REGISTRYFUNCTIONS
case TOK_READREGSTR :
case TOK_READREGDWORD :
{
ent . which = EW_READREGSTR ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
int k = line . gettoken_enum ( 2 , rootkeys [ 0 ] ) ;
if ( k = = - 1 ) k = line . gettoken_enum ( 2 , rootkeys [ 1 ] ) ;
2002-10-01 14:13:23 +00:00
if ( ent . offsets [ 0 ] = = - 1 | | k = = - 1 ) PRINTHELP ( )
2010-03-27 19:20:16 +00:00
ent . offsets [ 1 ] = ( INT_PTR ) rootkey_tab [ k ] ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 3 ) ) ;
ent . offsets [ 3 ] = add_string ( line . gettoken_str ( 4 ) ) ;
if ( which_token = = TOK_READREGDWORD ) ent . offsets [ 4 ] = 1 ;
else ent . offsets [ 4 ] = 0 ;
2010-03-24 17:22:56 +00:00
if ( line . gettoken_str ( 3 ) [ 0 ] = = _T ( ' \\ ' ) )
warning_fl ( _T ( " %s: registry path name begins with \' \\ \' , may cause problems " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %s %s %s \\ %s \\ %s \n " ) , line . gettoken_str ( 0 ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) ) ;
}
return add_entry ( & ent ) ;
case TOK_DELETEREGVALUE :
case TOK_DELETEREGKEY :
{
int a = 1 ;
if ( which_token = = TOK_DELETEREGKEY )
{
2004-06-25 19:53:05 +00:00
ent . offsets [ 4 ] = 1 ;
2010-03-24 17:22:56 +00:00
TCHAR * s = line . gettoken_str ( a ) ;
if ( s [ 0 ] = = _T ( ' / ' ) )
2002-08-02 10:01:35 +00:00
{
2010-03-29 14:24:47 +00:00
if ( _tcsicmp ( s , _T ( " /ifempty " ) ) ) PRINTHELP ( )
2002-08-02 10:01:35 +00:00
a + + ;
2004-06-25 19:53:05 +00:00
ent . offsets [ 4 ] = 3 ;
2002-08-02 10:01:35 +00:00
}
2002-09-02 23:00:04 +00:00
if ( line . gettoken_str ( a + 2 ) [ 0 ] ) PRINTHELP ( )
2002-08-02 10:01:35 +00:00
}
int k = line . gettoken_enum ( a , rootkeys [ 0 ] ) ;
if ( k = = - 1 ) k = line . gettoken_enum ( a , rootkeys [ 1 ] ) ;
if ( k = = - 1 ) PRINTHELP ( )
ent . which = EW_DELREG ;
2010-03-27 19:20:16 +00:00
ent . offsets [ 1 ] = ( INT_PTR ) rootkey_tab [ k ] ;
2004-06-25 19:53:05 +00:00
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( a + 1 ) ) ;
ent . offsets [ 3 ] = ( which_token = = TOK_DELETEREGKEY ) ? 0 : add_string ( line . gettoken_str ( a + 2 ) ) ;
2010-03-24 17:22:56 +00:00
if ( line . gettoken_str ( a + 1 ) [ 0 ] = = _T ( ' \\ ' ) )
warning_fl ( _T ( " %s: registry path name begins with \' \\ \' , may cause problems " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
if ( which_token = = TOK_DELETEREGKEY )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " DeleteRegKey: %s \\ %s \n " ) , line . gettoken_str ( a ) , line . gettoken_str ( a + 1 ) ) ;
2002-08-02 10:01:35 +00:00
else
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " DeleteRegValue: %s \\ %s \\ %s \n " ) , line . gettoken_str ( a ) , line . gettoken_str ( a + 1 ) , line . gettoken_str ( a + 2 ) ) ;
2002-08-02 10:01:35 +00:00
}
return add_entry ( & ent ) ;
case TOK_WRITEREGSTR :
case TOK_WRITEREGEXPANDSTR :
case TOK_WRITEREGBIN :
case TOK_WRITEREGDWORD :
{
int k = line . gettoken_enum ( 1 , rootkeys [ 0 ] ) ;
if ( k = = - 1 ) k = line . gettoken_enum ( 1 , rootkeys [ 1 ] ) ;
if ( k = = - 1 ) PRINTHELP ( )
ent . which = EW_WRITEREG ;
2010-03-27 19:20:16 +00:00
ent . offsets [ 0 ] = ( INT_PTR ) rootkey_tab [ k ] ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
2010-03-24 17:22:56 +00:00
if ( line . gettoken_str ( 2 ) [ 0 ] = = _T ( ' \\ ' ) )
warning_fl ( _T ( " %s: registry path name begins with \' \\ \' , may cause problems " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 3 ) ) ;
if ( which_token = = TOK_WRITEREGSTR | | which_token = = TOK_WRITEREGEXPANDSTR )
{
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %s: %s \\ %s \\ %s=%s \n " ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 0 ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) ) ;
ent . offsets [ 3 ] = add_string ( line . gettoken_str ( 4 ) ) ;
2003-11-27 23:21:15 +00:00
ent . offsets [ 4 ] = ent . offsets [ 5 ] = REG_SZ ;
2002-08-02 10:01:35 +00:00
if ( which_token = = TOK_WRITEREGEXPANDSTR )
{
2003-11-27 23:21:15 +00:00
ent . offsets [ 5 ] = REG_EXPAND_SZ ;
2002-08-02 10:01:35 +00:00
}
}
2002-08-11 18:57:16 +00:00
if ( which_token = = TOK_WRITEREGBIN )
2002-08-02 10:01:35 +00:00
{
2004-06-25 19:53:05 +00:00
char data [ 3 * NSIS_MAX_STRLEN ] ;
2010-03-24 17:22:56 +00:00
TCHAR * p = line . gettoken_str ( 4 ) ;
2002-08-02 10:01:35 +00:00
int data_len = 0 ;
while ( * p )
{
int c ;
int a , b ;
a = * p ;
2010-03-24 17:22:56 +00:00
if ( a > = _T ( ' 0 ' ) & & a < = _T ( ' 9 ' ) ) a - = _T ( ' 0 ' ) ;
else if ( a > = _T ( ' a ' ) & & a < = _T ( ' f ' ) ) a - = _T ( ' a ' ) - 10 ;
else if ( a > = _T ( ' A ' ) & & a < = _T ( ' F ' ) ) a - = _T ( ' A ' ) - 10 ;
2002-08-02 10:01:35 +00:00
else break ;
b = * + + p ;
2010-03-24 17:22:56 +00:00
if ( b > = _T ( ' 0 ' ) & & b < = _T ( ' 9 ' ) ) b - = _T ( ' 0 ' ) ;
else if ( b > = _T ( ' a ' ) & & b < = _T ( ' f ' ) ) b - = _T ( ' a ' ) - 10 ;
else if ( b > = _T ( ' A ' ) & & b < = _T ( ' F ' ) ) b - = _T ( ' A ' ) - 10 ;
2002-08-02 10:01:35 +00:00
else break ;
p + + ;
c = ( a < < 4 ) | b ;
2004-06-25 19:53:05 +00:00
if ( data_len > = 3 * NSIS_MAX_STRLEN )
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " WriteRegBin: %d bytes of data exceeded \n " ) , 3 * NSIS_MAX_STRLEN ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
data [ data_len + + ] = c ;
}
if ( * p ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " WriteRegBin: %s \\ %s \\ %s=%s \n " ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) ) ;
2003-09-15 22:05:06 +00:00
ent . offsets [ 3 ] = add_db_data ( data , data_len ) ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 3 ] < 0 ) return PS_ERROR ;
2003-11-27 23:21:15 +00:00
ent . offsets [ 4 ] = ent . offsets [ 5 ] = REG_BINARY ;
2002-08-02 10:01:35 +00:00
}
2002-08-11 18:57:16 +00:00
if ( which_token = = TOK_WRITEREGDWORD )
2002-08-02 10:01:35 +00:00
{
ent . offsets [ 3 ] = add_string ( line . gettoken_str ( 4 ) ) ;
2003-11-27 23:21:15 +00:00
ent . offsets [ 4 ] = ent . offsets [ 5 ] = REG_DWORD ;
2002-08-02 10:01:35 +00:00
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " WriteRegDWORD: %s \\ %s \\ %s=%s \n " ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) ) ;
}
}
return add_entry ( & ent ) ;
case TOK_ENUMREGKEY :
case TOK_ENUMREGVAL :
{
ent . which = EW_REGENUM ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
int k = line . gettoken_enum ( 2 , rootkeys [ 0 ] ) ;
if ( k = = - 1 ) k = line . gettoken_enum ( 2 , rootkeys [ 1 ] ) ;
2003-03-01 12:44:33 +00:00
if ( ent . offsets [ 0 ] = = - 1 | | k = = - 1 ) PRINTHELP ( )
2010-03-27 19:20:16 +00:00
ent . offsets [ 1 ] = ( INT_PTR ) rootkey_tab [ k ] ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 3 ) ) ;
ent . offsets [ 3 ] = add_string ( line . gettoken_str ( 4 ) ) ;
ent . offsets [ 4 ] = which_token = = TOK_ENUMREGKEY ;
2010-03-24 17:22:56 +00:00
if ( line . gettoken_str ( 3 ) [ 0 ] = = _T ( ' \\ ' ) ) warning_fl ( _T ( " %s: registry path name begins with \' \\ \' , may cause problems " ) , line . gettoken_str ( 0 ) ) ;
SCRIPT_MSG ( _T ( " %s %s %s \\ %s \\ %s \n " ) , which_token = = TOK_ENUMREGKEY ? _T ( " EnumRegKey " ) : _T ( " EnumRegValue " ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 4 ) ) ;
}
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_REGISTRYFUNCTIONS
case TOK_READREGSTR :
case TOK_READREGDWORD :
case TOK_DELETEREGVALUE :
case TOK_DELETEREGKEY :
case TOK_WRITEREGSTR :
case TOK_WRITEREGEXPANDSTR :
case TOK_WRITEREGBIN :
case TOK_WRITEREGDWORD :
case TOK_ENUMREGKEY :
case TOK_ENUMREGVAL :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_REGISTRYFUNCTIONS not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_REGISTRYFUNCTIONS
# ifdef NSIS_SUPPORT_STACK
case TOK_EXCH :
{
int swapitem = 1 ;
2003-06-09 18:59:14 +00:00
int save = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
ent . which = EW_PUSHPOP ;
if ( line . gettoken_str ( 1 ) [ 0 ] & & save < 0 )
{
int s = 0 ;
swapitem = line . gettoken_int ( 1 , & s ) ;
if ( ! s | | swapitem < = 0 ) PRINTHELP ( )
}
if ( save > = 0 )
{
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Exch(%s,0) \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
ent . offsets [ 1 ] = 0 ;
ent . offsets [ 2 ] = 0 ;
add_entry ( & ent ) ;
}
2010-03-24 17:22:56 +00:00
else SCRIPT_MSG ( _T ( " Exch(st(%d) , 0 ) \ n " ),swapitem) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 0 ] = 0 ;
ent . offsets [ 1 ] = 0 ;
ent . offsets [ 2 ] = swapitem ;
if ( save > = 0 )
{
add_entry ( & ent ) ;
ent . offsets [ 0 ] = save ;
ent . offsets [ 1 ] = 1 ;
ent . offsets [ 2 ] = 0 ;
}
2003-09-04 18:25:57 +00:00
DefineInnerLangString ( NLF_INST_CORRUPTED ) ;
2002-08-02 10:01:35 +00:00
}
return add_entry ( & ent ) ;
case TOK_PUSH :
ent . which = EW_PUSHPOP ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
ent . offsets [ 1 ] = 0 ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Push: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_POP :
ent . which = EW_PUSHPOP ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 1 ] = 1 ;
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Pop: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_STACK
case TOK_POP :
case TOK_PUSH :
case TOK_EXCH :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_STACK not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_STACK
# ifdef NSIS_SUPPORT_ENVIRONMENT
case TOK_READENVSTR :
ent . which = EW_READENVSTR ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
{
2010-03-24 17:22:56 +00:00
TCHAR str [ NSIS_MAX_STRLEN ] ;
2010-03-29 14:24:47 +00:00
_tcscpy ( str , _T ( " % " ) ) ;
_tcscat ( str , line . gettoken_str ( 2 ) ) ;
_tcscat ( str , _T ( " % " ) ) ;
2007-03-03 14:18:20 +00:00
ent . offsets [ 1 ] = add_string ( str ) ;
2010-03-24 17:22:56 +00:00
if ( ent . offsets [ 0 ] < 0 | | _tcsclen ( line . gettoken_str ( 2 ) ) < 1 ) PRINTHELP ( )
2002-08-02 10:01:35 +00:00
}
ent . offsets [ 2 ] = 1 ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " ReadEnvStr: %s->%s \n " ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_EXPANDENVSTRS :
ent . which = EW_READENVSTR ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
ent . offsets [ 2 ] = 0 ;
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " ExpandEnvStrings: %s->%s \n " ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_ENVIRONMENT
case TOK_EXPANDENVSTRS :
case TOK_READENVSTR :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_ENVIRONMENT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_ENVIRONMENT
# ifdef NSIS_SUPPORT_FINDFIRST
case TOK_FINDFIRST :
ent . which = EW_FINDFIRST ;
2003-11-27 20:19:48 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 2 ) ; // out
ent . offsets [ 1 ] = GetUserVarIndex ( line , 1 ) ; // handleout
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 3 ) ) ; // filespec
if ( ent . offsets [ 0 ] < 0 | | ent . offsets [ 1 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " FindFirst: spec= \" %s \" handle=%s output=%s \n " ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_FINDNEXT :
ent . which = EW_FINDNEXT ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 2 ) ;
ent . offsets [ 1 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 0 ] < 0 | | ent . offsets [ 1 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " FindNext: handle=%s output=%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_FINDCLOSE :
ent . which = EW_FINDCLOSE ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " FindClose: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_FINDFIRST
case TOK_FINDCLOSE :
case TOK_FINDNEXT :
case TOK_FINDFIRST :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_FINDFIRST not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_FINDFIRST
# ifdef NSIS_SUPPORT_FILEFUNCTIONS
case TOK_FILEOPEN :
{
ent . which = EW_FOPEN ;
2003-11-27 20:19:48 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ; // file handle
ent . offsets [ 3 ] = add_string ( line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 1 ] = 0 ; //openmode
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( 3 ) , _T ( " r " ) ) )
2002-08-02 10:01:35 +00:00
{
ent . offsets [ 1 ] = GENERIC_READ ;
ent . offsets [ 2 ] = OPEN_EXISTING ;
}
2010-03-29 14:24:47 +00:00
else if ( ! _tcsicmp ( line . gettoken_str ( 3 ) , _T ( " w " ) ) )
2002-08-02 10:01:35 +00:00
{
ent . offsets [ 1 ] = GENERIC_WRITE ;
ent . offsets [ 2 ] = CREATE_ALWAYS ;
}
2010-03-29 14:24:47 +00:00
else if ( ! _tcsicmp ( line . gettoken_str ( 3 ) , _T ( " a " ) ) )
2002-08-02 10:01:35 +00:00
{
ent . offsets [ 1 ] = GENERIC_WRITE | GENERIC_READ ;
ent . offsets [ 2 ] = OPEN_ALWAYS ;
}
2002-08-11 18:57:16 +00:00
2006-03-28 17:02:23 +00:00
if ( ent . offsets [ 0 ] < 0 | | ! ent . offsets [ 1 ] ) PRINTHELP ( )
2002-08-02 10:01:35 +00:00
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " FileOpen: %s as %s -> %s \n " ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_FILECLOSE :
ent . which = EW_FCLOSE ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ; // file handle
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " FileClose: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_FILEREAD :
ent . which = EW_FGETS ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ; // file handle
ent . offsets [ 1 ] = GetUserVarIndex ( line , 2 ) ; // output string
2005-12-27 19:22:56 +00:00
if ( line . gettoken_str ( 3 ) [ 0 ] )
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 3 ) ) ;
else
ent . offsets [ 2 ] = add_intstring ( NSIS_MAX_STRLEN - 1 ) ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 0 ] < 0 | | ent . offsets [ 1 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " FileRead: %s->%s (max:%s) \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 3 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_FILEWRITE :
ent . which = EW_FPUTS ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ; // file handle
2002-08-02 10:01:35 +00:00
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " FileWrite: %s->%s \n " ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_FILEREADBYTE :
ent . which = EW_FGETS ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ; // file handle
ent . offsets [ 1 ] = GetUserVarIndex ( line , 2 ) ; // output string
2010-03-24 17:22:56 +00:00
ent . offsets [ 2 ] = add_string ( _T ( " 1 " ) ) ;
2002-08-02 10:01:35 +00:00
ent . offsets [ 3 ] = 1 ;
if ( ent . offsets [ 0 ] < 0 | | ent . offsets [ 1 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " FileReadByte: %s->%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_FILEWRITEBYTE :
ent . which = EW_FPUTS ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ; // file handle
2002-08-02 10:01:35 +00:00
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
ent . offsets [ 2 ] = 1 ;
if ( ent . offsets [ 0 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " FileWriteByte: %s->%s \n " ) , line . gettoken_str ( 2 ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_FILESEEK :
{
2010-03-24 17:22:56 +00:00
const TCHAR * modestr ;
2002-08-02 10:01:35 +00:00
int tab [ 3 ] = { FILE_BEGIN , FILE_CURRENT , FILE_END } ;
2010-03-24 17:22:56 +00:00
int mode = line . gettoken_enum ( 3 , _T ( " SET \0 CUR \0 END \0 " ) ) ;
2002-08-02 10:01:35 +00:00
ent . which = EW_FSEEK ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 0 ] = GetUserVarIndex ( line , 1 ) ;
2003-11-27 20:19:48 +00:00
ent . offsets [ 1 ] = GetUserVarIndex ( line , 4 ) ;
ent . offsets [ 2 ] = add_string ( line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
2002-08-11 18:57:16 +00:00
if ( mode < 0 & & ! line . gettoken_str ( 3 ) [ 0 ] )
2002-08-02 10:01:35 +00:00
{
mode = 0 ;
2010-03-24 17:22:56 +00:00
modestr = _T ( " SET " ) ;
2002-08-02 10:01:35 +00:00
}
else modestr = line . gettoken_str ( 3 ) ;
2003-11-27 20:19:48 +00:00
if ( mode < 0 | | ent . offsets [ 0 ] < 0 | | ( ent . offsets [ 1 ] < 0 & & line . gettoken_str ( 4 ) [ 0 ] ) ) PRINTHELP ( )
ent . offsets [ 3 ] = tab [ mode ] ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " FileSeek: fp=%s, ofs=%s, mode=%s, output=%s \n " ) ,
2002-08-02 10:01:35 +00:00
line . gettoken_str ( 1 ) ,
line . gettoken_str ( 2 ) ,
modestr ,
line . gettoken_str ( 4 ) ) ;
}
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_FILEFUNCTIONS
case TOK_FILEOPEN :
case TOK_FILECLOSE :
case TOK_FILESEEK :
case TOK_FILEREAD :
case TOK_FILEWRITE :
case TOK_FILEREADBYTE :
case TOK_FILEWRITEBYTE :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_FILEFUNCTIONS not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_FILEFUNCTIONS
# ifdef NSIS_SUPPORT_REBOOT
case TOK_REBOOT :
2004-10-14 13:56:02 +00:00
{
int ret = add_entry_direct ( EW_REBOOT , 0xbadf00d ) ;
if ( ret ! = PS_OK ) return ret ;
ret = add_entry_direct ( EW_QUIT ) ;
if ( ret ! = PS_OK ) return ret ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Reboot! (WOW) \n " ) ) ;
2003-09-04 18:25:57 +00:00
DefineInnerLangString ( NLF_INST_CORRUPTED ) ;
2004-10-14 13:56:02 +00:00
}
return PS_OK ;
2002-08-02 10:01:35 +00:00
case TOK_IFREBOOTFLAG :
2003-04-02 19:54:53 +00:00
ent . which = EW_IFFLAG ;
2002-08-11 18:57:16 +00:00
if ( process_jump ( line , 1 , & ent . offsets [ 0 ] ) | |
2002-08-02 10:01:35 +00:00
process_jump ( line , 2 , & ent . offsets [ 1 ] ) ) PRINTHELP ( )
2003-04-02 19:54:53 +00:00
ent . offsets [ 2 ] = FLAG_OFFSET ( exec_reboot ) ;
2003-06-08 14:45:56 +00:00
ent . offsets [ 3 ] = ~ 0 ; //new value mask - keep flag
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " IfRebootFlag ?%s:%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_SETREBOOTFLAG :
2003-05-24 13:50:24 +00:00
{
2003-02-07 23:04:25 +00:00
ent . which = EW_SETFLAG ;
2003-04-02 19:54:53 +00:00
ent . offsets [ 0 ] = FLAG_OFFSET ( exec_reboot ) ;
2010-03-24 17:22:56 +00:00
int k = line . gettoken_enum ( 1 , _T ( " false \0 true \0 " ) ) ;
2003-05-24 13:50:24 +00:00
if ( k < 0 ) PRINTHELP ( )
ent . offsets [ 1 ] = add_intstring ( k ) ;
}
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
# else //!NSIS_SUPPORT_REBOOT
case TOK_REBOOT :
case TOK_IFREBOOTFLAG :
case TOK_SETREBOOTFLAG :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_REBOOT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_SUPPORT_REBOOT
# ifdef NSIS_CONFIG_LOG
case TOK_LOGSET :
ent . which = EW_LOG ;
ent . offsets [ 0 ] = 1 ;
2010-03-24 17:22:56 +00:00
ent . offsets [ 1 ] = line . gettoken_enum ( 1 , _T ( " off \0 on \0 " ) ) ;
2002-08-02 10:01:35 +00:00
if ( ent . offsets [ 1 ] < 0 ) PRINTHELP ( )
2002-08-11 18:57:16 +00:00
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " LogSet: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_LOGTEXT :
ent . which = EW_LOG ;
ent . offsets [ 0 ] = 0 ;
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " LogText \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
# else //!NSIS_CONFIG_LOG
case TOK_LOGSET :
case TOK_LOGTEXT :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_LOG not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_CONFIG_LOG
# ifdef NSIS_CONFIG_COMPONENTPAGE
case TOK_SECTIONSETTEXT :
ent . which = EW_SECTIONSET ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2003-11-27 20:19:48 +00:00
ent . offsets [ 2 ] = SECTION_FIELD_SET ( name_ptr ) ;
2005-01-14 15:13:47 +00:00
ent . offsets [ 4 ] = add_string ( line . gettoken_str ( 2 ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SectionSetText: %s->%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_SECTIONGETTEXT :
ent . which = EW_SECTIONSET ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2003-11-27 20:19:48 +00:00
ent . offsets [ 1 ] = GetUserVarIndex ( line , 2 ) ;
ent . offsets [ 2 ] = SECTION_FIELD_GET ( name_ptr ) ;
if ( line . gettoken_str ( 2 ) [ 0 ] & & ent . offsets [ 1 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SectionGetText: %s->%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-11 18:57:16 +00:00
return add_entry ( & ent ) ;
2002-08-02 10:01:35 +00:00
case TOK_SECTIONSETFLAGS :
ent . which = EW_SECTIONSET ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2003-11-27 20:19:48 +00:00
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
ent . offsets [ 2 ] = SECTION_FIELD_SET ( flags ) ;
2005-01-11 16:33:12 +00:00
ent . offsets [ 3 ] = 1 ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SectionSetFlags: %s->%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
case TOK_SECTIONGETFLAGS :
ent . which = EW_SECTIONSET ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2003-11-27 20:19:48 +00:00
ent . offsets [ 1 ] = GetUserVarIndex ( line , 2 ) ;
ent . offsets [ 2 ] = SECTION_FIELD_GET ( flags ) ;
if ( line . gettoken_str ( 2 ) [ 0 ] & & ent . offsets [ 1 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SectionGetFlags: %s->%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2002-08-02 10:01:35 +00:00
return add_entry ( & ent ) ;
2003-05-24 13:50:24 +00:00
case TOK_INSTTYPESETTEXT :
ent . which = EW_INSTTYPESET ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
ent . offsets [ 2 ] = 1 ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " InstTypeSetText: %s->%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2003-05-24 13:50:24 +00:00
return add_entry ( & ent ) ;
case TOK_INSTTYPEGETTEXT :
ent . which = EW_INSTTYPESET ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2003-06-09 18:59:14 +00:00
ent . offsets [ 1 ] = GetUserVarIndex ( line , 2 ) ;
2003-05-24 13:50:24 +00:00
ent . offsets [ 2 ] = 0 ;
if ( line . gettoken_str ( 1 ) [ 0 ] & & ent . offsets [ 1 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " InstTypeGetText: %s->%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2003-05-24 13:50:24 +00:00
return add_entry ( & ent ) ;
2003-03-07 21:10:48 +00:00
case TOK_SECTIONSETINSTTYPES :
ent . which = EW_SECTIONSET ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2003-11-27 20:19:48 +00:00
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
ent . offsets [ 2 ] = SECTION_FIELD_SET ( install_types ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SectionSetInstTypes: %s->%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2003-03-07 21:10:48 +00:00
return add_entry ( & ent ) ;
case TOK_SECTIONGETINSTTYPES :
ent . which = EW_SECTIONSET ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2003-11-27 20:19:48 +00:00
ent . offsets [ 1 ] = GetUserVarIndex ( line , 2 ) ;
ent . offsets [ 2 ] = SECTION_FIELD_GET ( install_types ) ;
if ( line . gettoken_str ( 2 ) [ 0 ] & & ent . offsets [ 1 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SectionGetInstTypes: %s->%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2003-03-07 21:10:48 +00:00
return add_entry ( & ent ) ;
2003-05-24 13:50:24 +00:00
case TOK_SECTIONSETSIZE :
ent . which = EW_SECTIONSET ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2003-11-27 20:19:48 +00:00
ent . offsets [ 1 ] = add_string ( line . gettoken_str ( 2 ) ) ;
ent . offsets [ 2 ] = SECTION_FIELD_SET ( size_kb ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SectionSetSize: %s->%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2003-05-24 13:50:24 +00:00
return add_entry ( & ent ) ;
case TOK_SECTIONGETSIZE :
ent . which = EW_SECTIONSET ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
2003-11-27 20:19:48 +00:00
ent . offsets [ 1 ] = GetUserVarIndex ( line , 2 ) ;
ent . offsets [ 2 ] = SECTION_FIELD_GET ( size_kb ) ;
if ( line . gettoken_str ( 2 ) [ 0 ] & & ent . offsets [ 1 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SectionGetSize: %s->%s \n " ) , line . gettoken_str ( 1 ) , line . gettoken_str ( 2 ) ) ;
2003-05-24 13:50:24 +00:00
return add_entry ( & ent ) ;
case TOK_SETCURINSTTYPE :
2005-01-11 16:33:12 +00:00
ent . which = EW_INSTTYPESET ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( 1 ) ) ;
ent . offsets [ 1 ] = 0 ;
ent . offsets [ 2 ] = 1 ;
ent . offsets [ 3 ] = 1 ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetCurInstType: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2005-01-11 16:33:12 +00:00
return add_entry ( & ent ) ;
2003-05-24 13:50:24 +00:00
case TOK_GETCURINSTTYPE :
2005-01-11 16:33:12 +00:00
ent . which = EW_INSTTYPESET ;
ent . offsets [ 0 ] = 0 ;
ent . offsets [ 1 ] = GetUserVarIndex ( line , 1 ) ;
ent . offsets [ 2 ] = 0 ;
ent . offsets [ 3 ] = 1 ;
2007-12-21 22:25:36 +00:00
if ( line . gettoken_str ( 1 ) [ 0 ] & & ent . offsets [ 1 ] < 0 ) PRINTHELP ( )
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " GetCurInstType: %s \n " ) , line . gettoken_str ( 1 ) ) ;
2003-05-24 13:50:24 +00:00
return add_entry ( & ent ) ;
2002-08-02 10:01:35 +00:00
# else //!NSIS_CONFIG_COMPONENTPAGE
case TOK_SECTIONSETTEXT :
2003-05-24 13:50:24 +00:00
case TOK_SECTIONGETTEXT :
2002-08-02 10:01:35 +00:00
case TOK_SECTIONSETFLAGS :
case TOK_SECTIONGETFLAGS :
2003-05-24 13:50:24 +00:00
case TOK_SECTIONSETSIZE :
case TOK_SECTIONGETSIZE :
2003-03-07 21:10:48 +00:00
case TOK_SECTIONSETINSTTYPES :
case TOK_SECTIONGETINSTTYPES :
2003-05-24 13:50:24 +00:00
case TOK_SETCURINSTTYPE :
case TOK_GETCURINSTTYPE :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_COMPONENTPAGE not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
# endif //!NSIS_CONFIG_COMPONENTPAGE
2002-10-04 14:45:20 +00:00
# ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT
2002-08-02 10:01:35 +00:00
case TOK_SETBRANDINGIMAGE :
{
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " SetBrandingImage: " ) ) ;
2002-08-02 10:01:35 +00:00
if ( ! branding_image_found ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " \n Error: no branding image found in chosen UI! \n " ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
ent . which = EW_SETBRANDINGIMAGE ;
for ( int i = 1 ; i < line . getnumtokens ( ) ; i + + )
2010-03-29 14:24:47 +00:00
if ( ! _tcsncicmp ( line . gettoken_str ( i ) , _T ( " /IMGID= " ) , 7 ) ) {
2010-03-24 17:22:56 +00:00
ent . offsets [ 1 ] = _ttoi ( line . gettoken_str ( i ) + 7 ) ;
SCRIPT_MSG ( _T ( " /IMGID=%d " ) , ent . offsets [ 1 ] ) ;
2002-08-28 18:35:46 +00:00
}
2010-03-29 14:24:47 +00:00
else if ( ! _tcsicmp ( line . gettoken_str ( i ) , _T ( " /RESIZETOFIT " ) ) ) {
2003-11-24 00:08:58 +00:00
ent . offsets [ 2 ] = 1 ; // must be 1 or 0
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " /RESIZETOFIT " ) ) ;
2002-08-28 18:35:46 +00:00
}
else if ( ! ent . offsets [ 0 ] ) {
2002-08-02 10:01:35 +00:00
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( i ) ) ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " \" %s \" " ) , line . gettoken_str ( i ) ) ;
2002-08-28 18:35:46 +00:00
}
else {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " \n " ) ) ;
2002-08-02 10:01:35 +00:00
PRINTHELP ( ) ;
2002-08-28 18:35:46 +00:00
}
2002-08-02 10:01:35 +00:00
if ( ! ent . offsets [ 1 ] )
ent . offsets [ 1 ] = branding_image_id ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " \n " ) ) ;
2002-08-02 10:01:35 +00:00
}
return add_entry ( & ent ) ;
2002-09-18 18:39:24 +00:00
# else //NSIS_CONFIG_ENHANCEDUI_SUPPORT
2002-10-04 14:45:20 +00:00
case TOK_SETBRANDINGIMAGE :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_ENHANCEDUI_SUPPORT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-10-04 14:45:20 +00:00
return PS_ERROR ;
2002-09-18 18:39:24 +00:00
# endif //!NSIS_SUPPORT_CREATEFONT
2002-08-02 10:01:35 +00:00
2003-07-12 15:19:49 +00:00
// Added by ramon 3 jun 2003
2003-06-09 18:59:14 +00:00
case TOK_DEFVAR :
{
2005-08-06 16:04:17 +00:00
int a = 1 ;
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( 1 ) , _T ( " /GLOBAL " ) ) )
2005-08-06 16:04:17 +00:00
{
a + + ;
}
2007-10-05 09:01:06 +00:00
else if ( line . getnumtokens ( ) = = 3 )
{
PRINTHELP ( ) ;
}
2005-08-06 16:04:17 +00:00
if ( build_cursection )
{
if ( a = = 1 )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Var: currently, only global variables can be defined. \n " ) ) ;
2005-08-06 16:04:17 +00:00
PRINTHELP ( ) ;
}
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " Var: \" %s \" \n " ) , line . gettoken_str ( a ) ) ;
2005-08-06 16:04:17 +00:00
int res = DeclaredUserVar ( line . gettoken_str ( a ) ) ;
if ( res ! = PS_OK )
return res ;
2003-06-09 18:59:14 +00:00
}
2003-12-24 15:54:06 +00:00
return PS_OK ;
2003-06-09 18:59:14 +00:00
// Added by ramon 6 jun 2003
# ifdef NSIS_SUPPORT_VERSION_INFO
2003-06-10 04:35:09 +00:00
case TOK_VI_ADDKEY :
2003-06-09 18:59:14 +00:00
{
2007-01-23 21:21:30 +00:00
LANGID LangID = 0 ;
int a = 1 ;
2010-03-29 14:24:47 +00:00
if ( ! _tcsncicmp ( line . gettoken_str ( a ) , _T ( " /LANG= " ) , 6 ) )
2010-03-24 17:22:56 +00:00
LangID = _ttoi ( line . gettoken_str ( a + + ) + 6 ) ;
2007-01-23 21:21:30 +00:00
if ( line . getnumtokens ( ) ! = a + 2 ) PRINTHELP ( ) ;
2010-03-24 17:22:56 +00:00
TCHAR * pKey = line . gettoken_str ( a ) ;
TCHAR * pValue = line . gettoken_str ( a + 1 ) ;
2007-01-23 21:21:30 +00:00
if ( ! ( * pKey ) )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: empty name for version info key! \n " ) ) ;
2007-01-23 21:21:30 +00:00
return PS_ERROR ;
}
else
{
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %s: \" %s \" \" %s \" \n " ) , line . gettoken_str ( 0 ) , line . gettoken_str ( a ) , line . gettoken_str ( a + 1 ) ) ;
2007-01-23 21:21:30 +00:00
LANGID lReaded = LangID ;
if ( a > 1 & & lReaded = = 0 )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " %s: %s language not loaded, using default \" 1033-English \" " ) , line . gettoken_str ( 0 ) , line . gettoken_str ( 1 ) ) ;
2007-01-23 21:21:30 +00:00
unsigned int codepage ;
2010-03-24 17:22:56 +00:00
const TCHAR * lang_name = GetLangNameAndCP ( LangID , & codepage ) ;
2007-01-23 21:21:30 +00:00
if ( rVersionInfo . SetKeyValue ( LangID , codepage , pKey , pValue ) )
2003-06-09 18:59:14 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " %s: \" %s \" \" %04d-%s \" already defined! \n " ) , line . gettoken_str ( 0 ) , line . gettoken_str ( 2 ) , LangID , lang_name ) ;
2007-01-23 21:21:30 +00:00
return PS_ERROR ;
2003-06-09 18:59:14 +00:00
}
2007-01-23 21:21:30 +00:00
return PS_OK ;
}
2003-06-09 18:59:14 +00:00
}
2003-06-10 04:35:09 +00:00
case TOK_VI_SETPRODUCTVERSION :
2003-06-12 00:06:23 +00:00
if ( version_product_v [ 0 ] )
2003-06-10 04:35:09 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s already defined! \n " ) , line . gettoken_str ( 0 ) ) ;
2007-01-23 21:21:30 +00:00
return PS_ERROR ;
2003-06-10 04:35:09 +00:00
}
2010-03-24 17:22:56 +00:00
_tcscpy ( version_product_v , line . gettoken_str ( 1 ) ) ;
2003-12-24 15:54:06 +00:00
return PS_OK ;
2003-06-09 18:59:14 +00:00
# else
2003-06-10 04:35:09 +00:00
case TOK_VI_ADDKEY :
case TOK_VI_SETPRODUCTVERSION :
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_SUPPORT_VERSION_INFO not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2003-06-09 18:59:14 +00:00
return PS_ERROR ;
# endif
2002-08-02 10:01:35 +00:00
// end of instructions
///////////////////////////////////////////////////////////////////////////////
2002-08-05 02:05:00 +00:00
// Added by Ximon Eighteen 5th August 2002
# ifdef NSIS_CONFIG_PLUGIN_SUPPORT
2002-08-05 19:13:52 +00:00
case TOK_PLUGINDIR :
{
if ( line . getnumtokens ( ) = = 2 )
{
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " PluginDir: \" %s \" \n " ) , line . gettoken_str ( 1 ) ) ;
TCHAR * path = line . gettoken_str ( 1 ) ;
2009-03-28 09:47:26 +00:00
PATH_CONVERT ( path ) ;
m_plugins . FindCommands ( path , display_info ? true : false ) ;
2002-08-05 19:13:52 +00:00
return PS_OK ;
}
}
return PS_ERROR ;
case TOK__PLUGINCOMMAND :
2002-08-05 02:05:00 +00:00
{
2005-08-27 19:56:00 +00:00
int ret ;
2002-08-05 02:05:00 +00:00
2010-03-24 17:22:56 +00:00
const tstring command = m_plugins . NormalizedCommand ( line . gettoken_str ( 0 ) ) ;
const tstring dllPath = m_plugins . GetPluginPath ( command ) ;
2005-08-30 16:30:48 +00:00
int data_handle = m_plugins . GetPluginHandle ( uninstall_mode ? true : false , command ) ;
2002-08-09 22:12:10 +00:00
2005-08-27 19:56:00 +00:00
if ( uninstall_mode ) uninst_plugin_used = true ;
else plugin_used = true ;
// Initialize $PLUGINSDIR
ent . which = EW_CALL ;
2010-03-24 17:22:56 +00:00
ent . offsets [ 0 ] = ns_func . add ( uninstall_mode ? _T ( " un.Initialize_____Plugins " ) : _T ( " Initialize_____Plugins " ) , 0 ) ;
2005-08-27 19:56:00 +00:00
ret = add_entry ( & ent ) ;
if ( ret ! = PS_OK ) {
return ret ;
}
// DLL name on the user machine
2010-03-24 17:22:56 +00:00
TCHAR tempDLL [ NSIS_MAX_STRLEN ] ;
tstring dllName = get_file_name ( dllPath ) ;
wsprintf ( tempDLL , _T ( " $PLUGINSDIR \\ %s " ) , dllName . c_str ( ) ) ;
2005-08-27 19:56:00 +00:00
// Add the DLL to the installer
if ( data_handle = = - 1 )
{
int files_added ;
int old_build_allowskipfiles = build_allowskipfiles ;
build_allowskipfiles = 1 ; // on
int old_build_overwrite = build_overwrite ;
build_overwrite = 1 ; // off
int old_build_datesave = build_datesave ;
build_datesave = 0 ; // off
ret = do_add_file ( dllPath . c_str ( ) , 0 , 0 , & files_added , tempDLL , 2 , & data_handle ) ; // 2 means no size add
2002-12-21 09:14:28 +00:00
if ( ret ! = PS_OK ) {
return ret ;
}
2005-08-30 16:30:48 +00:00
m_plugins . SetDllDataHandle ( uninstall_mode ? true : false , line . gettoken_str ( 0 ) , data_handle ) ;
2005-08-27 19:56:00 +00:00
build_overwrite = old_build_overwrite ;
build_datesave = old_build_datesave ;
// Added by ramon 23 May 2003
build_allowskipfiles = old_build_allowskipfiles ;
}
else
{
ent . which = EW_EXTRACTFILE ;
DefineInnerLangString ( NLF_SKIPPED ) ;
DefineInnerLangString ( NLF_ERR_DECOMPRESSING ) ;
DefineInnerLangString ( NLF_ERR_WRITING ) ;
DefineInnerLangString ( NLF_EXTRACT ) ;
DefineInnerLangString ( NLF_CANT_WRITE ) ;
ent . offsets [ 0 ] = 1 ; // overwrite off
ent . offsets [ 0 ] | = ( MB_RETRYCANCEL | MB_ICONSTOP | ( IDCANCEL < < 21 ) ) < < 3 ;
ent . offsets [ 1 ] = add_string ( tempDLL ) ;
ent . offsets [ 2 ] = data_handle ;
ent . offsets [ 3 ] = 0xffffffff ;
ent . offsets [ 4 ] = 0xffffffff ;
ent . offsets [ 5 ] = DefineInnerLangString ( NLF_FILE_ERROR ) ;
2002-10-01 17:16:49 +00:00
ret = add_entry ( & ent ) ;
2002-12-21 09:14:28 +00:00
if ( ret ! = PS_OK ) {
return ret ;
}
2005-08-27 19:56:00 +00:00
}
2002-10-01 17:16:49 +00:00
2005-08-27 19:56:00 +00:00
// SetDetailsPrint lastused
2007-09-18 22:02:44 +00:00
ret = add_entry_direct ( EW_SETFLAG , FLAG_OFFSET ( status_update ) , 0 , 1 ) ;
2005-08-27 19:56:00 +00:00
if ( ret ! = PS_OK ) {
return ret ;
}
2002-08-05 02:05:00 +00:00
2005-08-27 19:56:00 +00:00
// Call the DLL
2010-03-24 17:22:56 +00:00
tstring funcname = get_string_suffix ( command , _T ( " :: " ) ) ;
SCRIPT_MSG ( _T ( " Plugin Command: %s " ) , funcname . c_str ( ) ) ;
2002-08-29 11:27:21 +00:00
2005-08-27 19:56:00 +00:00
int i = 1 ;
int nounload = 0 ;
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( i ) , _T ( " /NOUNLOAD " ) ) ) {
2005-08-27 19:56:00 +00:00
i + + ;
nounload + + ;
}
2002-09-21 18:37:25 +00:00
2005-08-27 19:56:00 +00:00
// First push dll args
2002-08-05 02:05:00 +00:00
2005-08-27 19:56:00 +00:00
int parmst = i ; // we push em in reverse order
int nounloadmisused = 0 ;
for ( ; i < line . getnumtokens ( ) ; i + + ) {
int w = parmst + ( line . getnumtokens ( ) - i - 1 ) ;
ent . which = EW_PUSHPOP ;
ent . offsets [ 0 ] = add_string ( line . gettoken_str ( w ) ) ;
2010-03-29 14:24:47 +00:00
if ( ! _tcsicmp ( line . gettoken_str ( w ) , _T ( " /NOUNLOAD " ) ) ) nounloadmisused = 1 ;
2005-08-27 19:56:00 +00:00
ent . offsets [ 1 ] = 0 ;
2007-04-21 09:37:59 +00:00
ent . offsets [ 2 ] = 0 ;
2002-08-08 15:04:45 +00:00
ret = add_entry ( & ent ) ;
2002-12-21 09:14:28 +00:00
if ( ret ! = PS_OK ) {
return ret ;
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %s " ) , line . gettoken_str ( i ) ) ;
2005-08-27 19:56:00 +00:00
}
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " \n " ) ) ;
2005-08-27 19:56:00 +00:00
if ( nounloadmisused )
2010-03-24 17:22:56 +00:00
warning_fl ( _T ( " /NOUNLOAD must come first before any plugin parameter. Unless the plugin you are trying to use has a parameter /NOUNLOAD, you are doing something wrong " ) ) ;
2002-12-21 09:14:28 +00:00
2005-08-27 19:56:00 +00:00
// next, call it
ent . which = EW_REGISTERDLL ;
ent . offsets [ 0 ] = add_string ( tempDLL ) ; ;
ent . offsets [ 1 ] = add_string ( funcname . c_str ( ) ) ;
ent . offsets [ 2 ] = 0 ;
ent . offsets [ 3 ] = nounload | build_plugin_unload ;
ent . offsets [ 4 ] = 1 ;
ret = add_entry ( & ent ) ;
if ( ret ! = PS_OK ) {
return ret ;
2002-08-05 02:05:00 +00:00
}
2005-08-27 19:56:00 +00:00
2006-08-07 13:57:13 +00:00
DefineInnerLangString ( NLF_SYMBOL_NOT_FOUND ) ;
DefineInnerLangString ( NLF_COULD_NOT_LOAD ) ;
DefineInnerLangString ( NLF_NO_OLE ) ;
2006-08-07 14:01:54 +00:00
// not used anywhere - DefineInnerLangString(NLF_ERR_REG_DLL);
2006-08-07 13:57:13 +00:00
2005-08-27 19:56:00 +00:00
return PS_OK ;
2002-08-11 18:57:16 +00:00
}
2002-11-25 20:16:57 +00:00
case TOK_INITPLUGINSDIR :
2002-11-09 13:51:40 +00:00
{
int ret ;
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %s \n " ) , line . gettoken_str ( 0 ) ) ;
2002-11-25 20:16:57 +00:00
if ( uninstall_mode ) uninst_plugin_used = true ;
else plugin_used = true ;
2002-11-09 13:51:40 +00:00
// Call [un.]Initialize_____Plugins
ent . which = EW_CALL ;
2010-03-24 17:22:56 +00:00
ent . offsets [ 0 ] = ns_func . add ( uninstall_mode ? _T ( " un.Initialize_____Plugins " ) : _T ( " Initialize_____Plugins " ) , 0 ) ;
2002-11-09 13:51:40 +00:00
ret = add_entry ( & ent ) ;
if ( ret ! = PS_OK ) return ret ;
// SetDetailsPrint lastused
2007-09-18 22:02:44 +00:00
ret = add_entry_direct ( EW_SETFLAG , FLAG_OFFSET ( status_update ) , 0 , 1 ) ;
2002-11-09 13:51:40 +00:00
if ( ret ! = PS_OK ) return ret ;
}
return PS_OK ;
2002-08-05 02:05:00 +00:00
# else
2002-08-05 19:13:52 +00:00
case TOK_PLUGINDIR :
case TOK__PLUGINCOMMAND :
2002-11-25 20:16:57 +00:00
case TOK_INITPLUGINSDIR :
2002-08-05 19:13:52 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_CONFIG_PLUGIN_SUPPORT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-05 19:13:52 +00:00
}
2002-08-05 02:05:00 +00:00
return PS_ERROR ;
# endif // NSIS_CONFIG_PLUGIN_SUPPORT
2002-08-05 19:13:52 +00:00
2003-11-09 22:45:25 +00:00
# ifdef NSIS_LOCKWINDOW_SUPPORT
case TOK_LOCKWINDOW :
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " LockWindow: lock state=%d \n " ) , line . gettoken_str ( 1 ) ) ;
2003-11-09 22:45:25 +00:00
ent . which = EW_LOCKWINDOW ;
2010-03-24 17:22:56 +00:00
ent . offsets [ 0 ] = line . gettoken_enum ( 1 , _T ( " on \0 off \0 " ) ) ;
2003-11-27 23:21:15 +00:00
if ( ent . offsets [ 0 ] = = - 1 )
PRINTHELP ( ) ;
2003-11-09 22:45:25 +00:00
return add_entry ( & ent ) ;
# else
case TOK_LOCKWINDOW :
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: %s specified, NSIS_LOCKWINDOW_SUPPORT not defined. \n " ) , line . gettoken_str ( 0 ) ) ;
2003-11-09 22:45:25 +00:00
}
return PS_ERROR ;
# endif // NSIS_LOCKWINDOW_SUPPORT
2002-08-02 10:01:35 +00:00
default : break ;
}
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " Error: doCommand: Invalid token \" %s \" . \n " ) , line . gettoken_str ( 0 ) ) ;
2002-08-02 10:01:35 +00:00
return PS_ERROR ;
}
2002-09-18 19:08:53 +00:00
# ifdef NSIS_SUPPORT_FILE
2010-03-24 17:22:56 +00:00
int CEXEBuild : : do_add_file ( const TCHAR * lgss , int attrib , int recurse , int * total_files , const TCHAR * name_override , int generatecode , int * data_handle , const set < tstring > & excluded , const tstring & basedir , bool dir_created )
2002-08-02 10:01:35 +00:00
{
2004-11-26 15:44:02 +00:00
assert ( ! name_override | | ! recurse ) ;
2010-03-24 17:22:56 +00:00
tstring dir = get_dir_name ( lgss ) ;
tstring spec ;
2004-11-26 15:44:02 +00:00
if ( dir = = lgss ) {
2010-03-24 17:22:56 +00:00
dir = _T ( " . " ) ;
2004-11-26 15:44:02 +00:00
spec = lgss ;
} else {
2010-03-24 17:22:56 +00:00
spec = tstring ( lgss ) . substr ( dir . length ( ) + 1 , tstring : : npos ) ;
2003-04-29 16:28:30 +00:00
}
2002-08-02 10:01:35 +00:00
2010-03-24 17:22:56 +00:00
if ( spec = = _T ( " " ) ) {
spec = _T ( " * " ) ;
2004-11-26 15:44:02 +00:00
}
2004-03-29 20:21:00 +00:00
2010-03-24 17:22:56 +00:00
if ( basedir = = _T ( " " ) ) {
2004-11-26 15:44:02 +00:00
dir_created = true ;
2004-10-11 21:24:33 +00:00
2004-11-26 15:44:02 +00:00
if ( recurse ) {
2005-01-05 13:40:42 +00:00
// save $OUTDIR into $_OUTDIR [StrCpy $_OUTDIR $OUTDIR]
2010-03-24 17:22:56 +00:00
if ( add_entry_direct ( EW_ASSIGNVAR , m_UserVarNames . get ( _T ( " _OUTDIR " ) ) , add_string ( _T ( " $OUTDIR " ) ) ) ! = PS_OK ) {
2004-11-26 15:44:02 +00:00
return PS_ERROR ;
}
}
}
2004-10-11 21:24:33 +00:00
2005-10-22 13:40:52 +00:00
boost : : scoped_ptr < dir_reader > dr ( new_dir_reader ( ) ) ;
dr - > exclude ( excluded ) ;
dr - > read ( dir ) ;
2004-12-10 11:09:10 +00:00
// add files in the current directory
2005-10-22 14:46:01 +00:00
for ( dir_reader : : iterator files_itr = dr - > files ( ) . begin ( ) ;
files_itr ! = dr - > files ( ) . end ( ) ;
files_itr + + )
{
2004-11-26 15:44:02 +00:00
if ( ! dir_reader : : matches ( * files_itr , spec ) )
continue ;
2002-08-02 10:01:35 +00:00
2004-11-26 15:44:02 +00:00
if ( ! dir_created & & generatecode ) {
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %sFile: Descending to: \" %s \" \n " ) , generatecode ? _T ( " " ) : _T ( " Reserve " ) , dir . c_str ( ) ) ;
2003-09-04 18:25:57 +00:00
2004-11-26 15:44:02 +00:00
if ( do_add_file_create_dir ( dir , basedir , attrib ) ! = PS_OK ) {
return PS_ERROR ;
}
2003-09-04 18:25:57 +00:00
2004-11-26 15:44:02 +00:00
dir_created = true ;
}
2002-08-02 10:01:35 +00:00
2004-11-26 15:44:02 +00:00
if ( add_file ( dir , * files_itr , attrib , name_override , generatecode , data_handle ) ! = PS_OK ) {
return PS_ERROR ;
}
2002-08-02 10:01:35 +00:00
2004-11-26 15:44:02 +00:00
( * total_files ) + + ;
}
2002-08-02 10:01:35 +00:00
2005-10-22 14:46:01 +00:00
if ( ! recurse ) {
return PS_OK ;
}
2002-08-02 10:01:35 +00:00
2005-10-22 14:46:01 +00:00
// recurse into directories
for ( dir_reader : : iterator dirs_itr = dr - > dirs ( ) . begin ( ) ;
dirs_itr ! = dr - > dirs ( ) . end ( ) ;
dirs_itr + + )
{
2010-03-24 17:22:56 +00:00
tstring new_dir ;
2005-10-22 14:46:01 +00:00
bool created = false ;
2003-09-04 18:25:57 +00:00
2010-03-24 17:22:56 +00:00
if ( basedir = = _T ( " " ) ) {
2005-10-22 14:46:01 +00:00
new_dir = * dirs_itr ;
} else {
2010-03-24 17:22:56 +00:00
new_dir = basedir + _T ( ' \\ ' ) + * dirs_itr ;
2005-10-22 14:46:01 +00:00
}
2003-11-25 17:07:40 +00:00
2010-03-24 17:22:56 +00:00
tstring new_spec = dir + PLATFORM_PATH_SEPARATOR_STR + * dirs_itr + PLATFORM_PATH_SEPARATOR_STR ;
2005-01-05 13:01:07 +00:00
2005-10-22 14:46:01 +00:00
if ( ! dir_reader : : matches ( * dirs_itr , spec ) ) {
new_spec + = spec ;
} else if ( generatecode ) {
// always create directories that match
2005-01-05 13:01:07 +00:00
2010-03-24 17:22:56 +00:00
SCRIPT_MSG ( _T ( " %sFile: Descending to: \" %s \" \n " ) , generatecode ? _T ( " " ) : _T ( " Reserve " ) , new_spec . c_str ( ) ) ;
2004-12-10 11:09:10 +00:00
2010-03-24 17:22:56 +00:00
if ( do_add_file_create_dir ( dir + _T ( ' \\ ' ) + * dirs_itr , new_dir , attrib ) ! = PS_OK ) {
2005-10-22 14:46:01 +00:00
return PS_ERROR ;
2004-11-26 15:44:02 +00:00
}
2002-08-02 10:01:35 +00:00
2005-10-22 14:46:01 +00:00
created = true ;
}
2004-12-10 11:09:10 +00:00
2010-03-24 17:22:56 +00:00
const TCHAR * new_spec_c = new_spec . c_str ( ) ;
2005-10-22 14:46:01 +00:00
int res = do_add_file ( new_spec_c , attrib , 1 , total_files , NULL , generatecode , NULL , excluded , new_dir , created ) ;
if ( res ! = PS_OK ) {
return PS_ERROR ;
2004-03-29 20:21:00 +00:00
}
2005-10-22 14:46:01 +00:00
}
2004-11-26 15:44:02 +00:00
2010-03-24 17:22:56 +00:00
if ( basedir = = _T ( " " ) ) {
SCRIPT_MSG ( _T ( " %sFile: Returning to: \" %s \" \n " ) , generatecode ? _T ( " " ) : _T ( " Reserve " ) , dir . c_str ( ) ) ;
2004-11-26 15:44:02 +00:00
2005-10-22 14:46:01 +00:00
// restore $OUTDIR from $_OUTDIR [SetOutPath $_OUTDIR]
2010-03-24 17:22:56 +00:00
if ( add_entry_direct ( EW_CREATEDIR , add_string ( _T ( " $_OUTDIR " ) ) , 1 ) ! = PS_OK ) {
2005-10-22 14:46:01 +00:00
return PS_ERROR ;
2004-11-26 15:44:02 +00:00
}
}
return PS_OK ;
}
2010-03-24 17:22:56 +00:00
int CEXEBuild : : add_file ( const tstring & dir , const tstring & file , int attrib , const TCHAR * name_override , int generatecode , int * data_handle ) {
tstring newfn_s = dir + PLATFORM_PATH_SEPARATOR_C + file ;
const TCHAR * newfn = newfn_s . c_str ( ) ;
const TCHAR * filename = file . c_str ( ) ;
2004-11-26 15:44:02 +00:00
MMapFile mmap ;
DWORD len ;
2004-03-29 20:21:00 +00:00
# ifdef _WIN32
2004-11-26 15:44:02 +00:00
HANDLE hFile = CreateFile (
newfn ,
GENERIC_READ ,
FILE_SHARE_READ ,
NULL ,
OPEN_EXISTING ,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN ,
NULL
) ;
if ( hFile = = INVALID_HANDLE_VALUE )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " %sFile: failed opening file \" %s \" \n " ) , generatecode ? _T ( " " ) : _T ( " Reserve " ) , newfn ) ;
2004-11-26 15:44:02 +00:00
return PS_ERROR ;
}
// Will auto-CloseHandle hFile
MANAGE_WITH ( hFile , CloseHandle ) ;
len = GetFileSize ( hFile , NULL ) ;
if ( len & & ! mmap . setfile ( hFile , len ) )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " %sFile: failed creating mmap of \" %s \" \n " ) , generatecode ? _T ( " " ) : _T ( " Reserve " ) , newfn ) ;
2004-11-26 15:44:02 +00:00
return PS_ERROR ;
}
2004-03-29 20:21:00 +00:00
# else
2004-11-26 15:44:02 +00:00
struct stat s ;
if ( stat ( newfn , & s ) ) {
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " %sFile: failed stating file \" %s \" \n " ) , generatecode ? _T ( " " ) : _T ( " Reserve " ) , newfn ) ;
2004-11-26 15:44:02 +00:00
return PS_ERROR ;
2002-08-02 10:01:35 +00:00
}
2003-04-29 16:28:30 +00:00
2004-11-26 15:44:02 +00:00
len = ( DWORD ) s . st_size ;
int fd = OPEN ( newfn , O_RDONLY ) ;
if ( fd = = - 1 )
2003-04-29 16:28:30 +00:00
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " %sFile: failed opening file \" %s \" \n " ) , generatecode ? _T ( " " ) : _T ( " Reserve " ) , newfn ) ;
2004-11-26 15:44:02 +00:00
return PS_ERROR ;
}
// Will auto-close(2) fd
MANAGE_WITH ( fd , close ) ;
if ( len & & ! mmap . setfile ( fd , len ) )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " %sFile: failed creating mmap of \" %s \" \n " ) , generatecode ? _T ( " " ) : _T ( " Reserve " ) , newfn ) ;
2004-11-26 15:44:02 +00:00
return PS_ERROR ;
}
2004-03-29 20:21:00 +00:00
# endif
2003-09-04 18:25:57 +00:00
2004-11-26 15:44:02 +00:00
if ( generatecode & 1 )
section_add_size_kb ( ( len + 1023 ) / 1024 ) ;
2010-03-24 17:22:56 +00:00
if ( name_override ) SCRIPT_MSG ( _T ( " %sFile: \" %s \" -> \" %s \" " ) , generatecode ? _T ( " " ) : _T ( " Reserve " ) , filename , name_override ) ;
else SCRIPT_MSG ( _T ( " %sFile: \" %s \" " ) , generatecode ? _T ( " " ) : _T ( " Reserve " ) , filename ) ;
2004-11-26 15:44:02 +00:00
if ( ! build_compress_whole )
2010-03-24 17:22:56 +00:00
if ( build_compress ) SCRIPT_MSG ( _T ( " [compress] " ) ) ;
2004-11-26 15:44:02 +00:00
fflush ( stdout ) ;
2010-03-24 17:22:56 +00:00
TCHAR buf [ 1024 ] ;
2004-11-26 15:44:02 +00:00
int last_build_datablock_used = getcurdbsize ( ) ;
entry ent = { 0 , } ;
if ( generatecode )
{
ent . which = EW_EXTRACTFILE ;
2004-09-30 22:46:33 +00:00
2004-11-26 15:44:02 +00:00
DefineInnerLangString ( NLF_SKIPPED ) ;
DefineInnerLangString ( NLF_ERR_DECOMPRESSING ) ;
DefineInnerLangString ( NLF_ERR_WRITING ) ;
DefineInnerLangString ( NLF_EXTRACT ) ;
DefineInnerLangString ( NLF_CANT_WRITE ) ;
ent . offsets [ 0 ] = build_overwrite ;
if ( name_override )
2004-03-29 20:21:00 +00:00
{
2004-11-26 15:44:02 +00:00
ent . offsets [ 1 ] = add_string ( name_override ) ;
2004-03-29 20:21:00 +00:00
}
2003-04-29 16:28:30 +00:00
else
{
2010-03-24 17:22:56 +00:00
const TCHAR * i = filename ;
TCHAR * o = buf ;
2004-11-26 15:44:02 +00:00
while ( * i )
{
2010-03-24 17:22:56 +00:00
const TCHAR c = * i + + ;
2004-11-26 15:44:02 +00:00
* o + + = c ;
2010-03-24 17:22:56 +00:00
if ( c = = _T ( ' $ ' ) ) * o + + = _T ( ' $ ' ) ;
2004-11-26 15:44:02 +00:00
}
* o = 0 ;
ent . offsets [ 1 ] = add_string ( buf ) ;
2003-04-29 16:28:30 +00:00
}
2004-11-26 15:44:02 +00:00
}
ent . offsets [ 2 ] = add_db_data ( & mmap ) ;
mmap . clear ( ) ;
if ( ent . offsets [ 2 ] < 0 )
{
return PS_ERROR ;
}
if ( data_handle )
{
* data_handle = ent . offsets [ 2 ] ;
}
{
DWORD s = getcurdbsize ( ) - last_build_datablock_used ;
if ( s ) s - = 4 ;
2010-03-24 17:22:56 +00:00
if ( s ! = len ) SCRIPT_MSG ( _T ( " %d/%d bytes \n " ) , s , len ) ;
else SCRIPT_MSG ( _T ( " %d bytes \n " ) , len ) ;
2004-11-26 15:44:02 +00:00
}
if ( generatecode )
{
if ( build_datesave | | build_overwrite > = 0x3 /*ifnewer or ifdiff*/ )
2003-04-29 16:28:30 +00:00
{
2004-11-26 15:44:02 +00:00
# ifdef _WIN32
FILETIME ft ;
if ( GetFileTime ( hFile , NULL , NULL , & ft ) )
2003-04-29 16:28:30 +00:00
{
2005-11-05 14:07:47 +00:00
// FAT write time has a resolution of 2 seconds
PULONGLONG fti = ( PULONGLONG ) & ft ;
* fti - = * fti % 20000000 ;
2004-11-26 15:44:02 +00:00
ent . offsets [ 3 ] = ft . dwLowDateTime ;
ent . offsets [ 4 ] = ft . dwHighDateTime ;
}
2004-03-29 20:21:00 +00:00
# else
2004-11-26 15:44:02 +00:00
struct stat st ;
if ( ! fstat ( fd , & st ) )
2004-03-29 20:21:00 +00:00
{
2006-08-19 12:47:17 +00:00
unsigned long long ll = ( st . st_mtime * 10000000LL ) + 116444736000000000LL ;
2005-11-05 14:07:47 +00:00
// FAT write time has a resolution of 2 seconds
ll - = ll % 20000000 ;
2006-08-19 12:47:17 +00:00
ent . offsets [ 3 ] = ( int ) ll ;
ent . offsets [ 4 ] = ( int ) ( ll > > 32 ) ;
2004-11-26 15:44:02 +00:00
}
2004-03-29 20:21:00 +00:00
# endif
2004-11-26 15:44:02 +00:00
else
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " %sFile: failed getting file date from \" %s \" \n " ) , generatecode ? _T ( " " ) : _T ( " Reserve " ) , newfn ) ;
2004-11-26 15:44:02 +00:00
return PS_ERROR ;
}
}
else
{
ent . offsets [ 3 ] = 0xffffffff ;
ent . offsets [ 4 ] = 0xffffffff ;
}
2003-04-29 16:28:30 +00:00
2004-11-26 15:44:02 +00:00
// overwrite flag can be 0, 1, 2 or 3. in all cases, 2 bits
int mb = 0 ;
if ( build_allowskipfiles )
{
mb = MB_ABORTRETRYIGNORE | MB_ICONSTOP ;
// default for silent installers
2005-03-17 20:44:31 +00:00
mb | = IDIGNORE < < 21 ;
2004-11-26 15:44:02 +00:00
}
else
{
mb = MB_RETRYCANCEL | MB_ICONSTOP ;
// default for silent installers
2005-03-17 20:44:31 +00:00
mb | = IDCANCEL < < 21 ;
2004-11-26 15:44:02 +00:00
}
ent . offsets [ 0 ] | = mb < < 3 ;
2003-04-29 16:28:30 +00:00
2004-11-26 15:44:02 +00:00
ent . offsets [ 5 ] = DefineInnerLangString ( build_allowskipfiles ? NLF_FILE_ERROR : NLF_FILE_ERROR_NOIGNORE ) ;
}
2003-04-29 16:28:30 +00:00
2004-11-26 15:44:02 +00:00
if ( generatecode )
{
int a = add_entry ( & ent ) ;
if ( a ! = PS_OK )
{
return a ;
}
if ( attrib )
{
2004-03-29 20:21:00 +00:00
# ifdef _WIN32
2004-11-26 15:44:02 +00:00
ent . which = EW_SETFILEATTRIBUTES ;
// $OUTDIR is the working directory
ent . offsets [ 0 ] = add_string ( name_override ? name_override : buf ) ;
ent . offsets [ 1 ] = GetFileAttributes ( newfn ) ;
ent . offsets [ 2 ] = 0 ;
ent . offsets [ 3 ] = 0 ;
ent . offsets [ 4 ] = 0 ;
ent . offsets [ 5 ] = 0 ;
2003-09-04 18:25:57 +00:00
2007-04-12 19:24:21 +00:00
if ( ent . offsets [ 1 ] ! = INVALID_FILE_ATTRIBUTES )
2004-11-26 15:44:02 +00:00
{
2007-04-12 19:24:21 +00:00
a = add_entry ( & ent ) ;
if ( a ! = PS_OK )
{
return a ;
}
2004-11-26 15:44:02 +00:00
}
2004-03-29 20:21:00 +00:00
# endif
2004-11-26 15:44:02 +00:00
}
}
2003-09-04 18:25:57 +00:00
2004-11-26 15:44:02 +00:00
return PS_OK ;
}
2003-04-29 16:28:30 +00:00
2010-03-24 17:22:56 +00:00
int CEXEBuild : : do_add_file_create_dir ( const tstring & local_dir , const tstring & dir , int attrib ) {
tstring outdir_s = _T ( " $_OUTDIR \\ " ) + dir ;
2003-04-29 16:28:30 +00:00
2010-03-24 17:22:56 +00:00
tstring : : size_type pos = 1 ;
pos = outdir_s . find ( _T ( ' $ ' ) , pos ) ;
while ( pos ! = tstring : : npos ) {
outdir_s = outdir_s . insert ( pos , _T ( " $ " ) ) ;
pos = outdir_s . find ( _T ( ' $ ' ) , pos + 2 ) ;
2004-11-26 15:44:02 +00:00
}
int outdir = add_string ( outdir_s . c_str ( ) ) ;
if ( add_entry_direct ( EW_CREATEDIR , outdir , 1 ) ! = PS_OK ) {
return PS_ERROR ;
}
2003-09-04 18:25:57 +00:00
2004-03-29 20:21:00 +00:00
# ifdef _WIN32
2004-11-26 15:44:02 +00:00
if ( attrib ) {
2010-03-24 17:22:56 +00:00
int ndc = add_string ( _T ( " . " ) ) ;
2003-04-29 16:28:30 +00:00
2004-11-26 15:44:02 +00:00
DWORD attr = GetFileAttributes ( local_dir . c_str ( ) ) ;
2007-04-12 19:24:21 +00:00
if ( attr ! = INVALID_FILE_ATTRIBUTES )
{
if ( add_entry_direct ( EW_SETFILEATTRIBUTES , ndc , attr ) ! = PS_OK )
{
return PS_ERROR ;
}
2003-04-29 16:28:30 +00:00
}
}
2004-11-26 15:44:02 +00:00
# endif
2003-04-29 16:28:30 +00:00
2002-08-02 10:01:35 +00:00
return PS_OK ;
}
2002-10-02 22:45:51 +00:00
# endif
2009-03-10 20:14:10 +00:00
2010-03-24 17:22:56 +00:00
DefineList * CEXEBuild : : searchParseString ( const TCHAR * source_string , LineParser * line , int parmOffs , bool ignCase , bool noErrors )
2009-03-10 20:14:10 +00:00
{
2010-03-24 17:22:56 +00:00
const TCHAR * tok = line - > gettoken_str ( parmOffs + + ) ;
2009-03-10 20:14:10 +00:00
if ( tok & & * tok )
{
2010-03-24 17:22:56 +00:00
int toklen = _tcsclen ( tok ) ;
2010-03-29 14:24:47 +00:00
while ( * source_string & & ( ignCase ? _tcsncicmp ( source_string , tok , toklen ) : _tcsncmp ( source_string , tok , toklen ) ) ) source_string + + ;
2009-03-10 20:14:10 +00:00
if ( ! * source_string )
{
2010-03-24 17:22:56 +00:00
if ( ! noErrors ) ERROR_MSG ( _T ( " !searchparse: starting string \" %s \" not found, aborted search! \n " ) , tok ) ;
2009-03-10 20:14:10 +00:00
return NULL ;
}
if ( * source_string ) source_string + = toklen ;
}
DefineList * ret = NULL ;
while ( parmOffs < line - > getnumtokens ( ) )
{
2010-03-24 17:22:56 +00:00
const TCHAR * defout = line - > gettoken_str ( parmOffs + + ) ;
2009-03-10 20:14:10 +00:00
if ( parmOffs < line - > getnumtokens ( ) ) tok = line - > gettoken_str ( parmOffs + + ) ;
else tok = NULL ;
int maxlen = - 1 ;
2010-03-24 17:22:56 +00:00
const TCHAR * src_start = source_string ;
2009-03-10 20:14:10 +00:00
if ( tok & & * tok )
{
2010-03-24 17:22:56 +00:00
int toklen = _tcsclen ( tok ) ;
2010-03-29 14:24:47 +00:00
while ( * source_string & & ( ignCase ? _tcsncicmp ( source_string , tok , toklen ) : _tcsncmp ( source_string , tok , toklen ) ) ) source_string + + ;
2009-03-10 20:14:10 +00:00
maxlen = source_string - src_start ;
if ( * source_string ) source_string + = toklen ;
else if ( ! noErrors )
{
2010-03-24 17:22:56 +00:00
ERROR_MSG ( _T ( " !searchparse: string \" %s \" not found, aborted search! \n " ) , tok ) ;
2009-03-10 20:14:10 +00:00
delete ret ;
return NULL ;
}
}
if ( defout & & defout [ 0 ] )
{
if ( ! ret ) ret = new DefineList ;
if ( maxlen < 0 ) ret - > add ( defout , src_start ) ;
else
{
2010-03-29 14:24:47 +00:00
TCHAR * p = _tcsdup ( src_start ) ;
2009-03-10 20:14:10 +00:00
if ( p )
{
p [ maxlen ] = 0 ;
ret - > add ( defout , p ) ;
free ( p ) ;
}
}
}
}
return ret ;
}