2010-03-24 17:22:56 +00:00
/*
* build . h
*
* This file is a part of NSIS .
*
2021-01-01 20:27:52 +00:00
* Copyright ( C ) 1999 - 2021 Nullsoft and Contributors
2010-03-24 17:22:56 +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 .
*
* Unicode support by Jim Park - - 08 / 10 / 2007
*/
# ifndef _BUILD_H_
# define _BUILD_H_
# include "strlist.h"
# include "lineparse.h"
# include "lang.h"
# include "ResourceEditor.h"
# include "ResourceVersionInfo.h"
# include "uservars.h"
# include "ShConstants.h"
# include "mmap.h"
# include "manifest.h"
# include "icon.h"
2012-10-13 01:47:50 +00:00
# include <memory.h>
2013-03-07 21:25:35 +00:00
# include "utf.h"
2010-03-24 17:22:56 +00:00
# include "exehead/fileform.h"
# include "exehead/config.h"
# include "tstring.h"
# include <set>
2017-09-01 23:06:48 +00:00
# include <map>
2010-03-24 17:22:56 +00:00
# ifdef NSIS_SUPPORT_STANDARD_PREDEFINES
// Added by Sunil Kamath 11 June 2003
# include <time.h>
# include <sys / stat.h>
# endif
# ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
// Changed by Amir Szekely 31st July 2002
# include "compressor.h"
# include "czlib.h"
# include "cbzip2.h"
# include "clzma.h"
2017-04-25 13:09:41 +00:00
# endif //~ NSIS_CONFIG_COMPRESSION_SUPPORT
2010-03-24 17:22:56 +00:00
# ifdef NSIS_CONFIG_PLUGIN_SUPPORT
# include "Plugins.h"
2017-04-25 13:09:41 +00:00
# endif //~ NSIS_CONFIG_PLUGIN_SUPPORT
// 1000..4999 Errors
// 5000..5999 Important generic warnings
// 6000..6999 Script warnings
// 7000..7499 Recovered from bad input etc. warnings
2020-05-01 13:15:03 +00:00
// 7500..7999 Discouraged usage warnings (allocated high to low to reserve as much space as possible for more bad input codes)
2017-04-25 13:09:41 +00:00
// 8000..8999 Generic warnings
// 9000..9999 Breaking our and/or MS guidelines warnings
typedef enum {
//DE_OOM = 1000?, // Generic out of memory
//DE_MMAP = 1001?,
//DE_STUB_SECTION = 1100?,
//DE_PP_VERBOSE_BAD_LEVEL = 4000?,
//DW_STALE_TEMP = 5020?, TODO: There is currently no way to disable this
DW_PACKHDR_RETNONZERO = 5021 ,
2021-06-25 20:44:37 +00:00
DW_BADFORMAT_EXTERNAL_FILE = 5040 ,
2017-04-25 13:09:41 +00:00
DW_UNSUPP_STORE_FILE_ATT = 5050 ,
//DW_CMDLINE_UNSUPP = 5200?,
//DW_CMDLINE_UNSUPP_WIN = 5201?,
DW_CMDLINE_UNSUPP_NIX = 5202 ,
DW_CMDLINE_BAD_INPUTENC = 5210 , // reserved ..5229
DW_VAR_IGNORED_UNKNOWN = 6000 , // reserved ..6009
DW_VAR_NOREF = 6001 ,
DW_UNUSED_FUNCTION = 6010 , // reserved ..6019
DW_UNUSED_GLOBALLABEL = 6011 ,
DW_UNUSED_LABEL = 6012 ,
DW_UNCODE_WITHOUT_UNEXE = 6020 ,
DW_INNERSTRING_MULTISETWASTE = 6029 ,
DW_STRING_MULTISETWASTE = DW_INNERSTRING_MULTISETWASTE ,
DW_LANGSTRING_MULTISETWASTE = 6030 , // reserved ..6049
DW_LANGSTRING_NOTSETINLANG = 6040 ,
DW_LANGSTRING_SILENTLICENSE = 6049 ,
DW_COMMENT_NEWLINE = 6050 , // reserved ..6079
DW_PLUGIN_NOUNLOAD_PLACEMENT = 6080 , // reserved ..6099
DW_PP_PRAGMA_UNKNOWN = 6100 , // reserved ..6199
DW_PP_PRAGMA_INVALID = 6101 ,
2018-06-14 22:13:23 +00:00
DW_PP_DELFILE_DELERROR = 6149 ,
DW_PP_DELFILE_NOMATCH = DW_PP_DELFILE_DELERROR ,
2017-04-25 13:09:41 +00:00
DW_PP_VERBOSE_POP_EMPTY_STACK = 6150 ,
//DW_PP_VERBOSE_BAD_LEVEL = 6151?, // 2.x failed to issue a warning. 3.x currently aborts with hard error.
2018-11-02 19:51:54 +00:00
DW_PP_UNDEF_UNDEFINED = 6155 ,
2017-04-25 13:09:41 +00:00
DW_INCLUDE_NONFATAL_NOT_FOUND = 7000 , // reserved ..7009
DW_FILE_NONFATAL_NOT_FOUND = 7010 , // reserved ..7019
DW_LANGSTRING_OVERLONGLENGTH = 7020 , // reserved ..7024
DW_BAD_LANGID = 7025 , // reserved ..7029
DW_NLF_OLDVERSION = 7030 , // reserved ..7049
DW_NLF_SYSCP = 7031 ,
DW_NLF_UNSUPPORTED_CP = 7032 ,
DW_NLF_NOT_PREFERRED_ENC = 7033 ,
DW_LICENSE_EMPTY = 7050 ,
DW_ATTRIBUTE_OVERLONGSTRING = 7060 ,
DW_PARSE_BADNUMBER = 7070 ,
2020-05-01 13:15:03 +00:00
DW_PARSE_NUMBEROUTOFSPEC = 7071 ,
2017-04-25 13:09:41 +00:00
DW_PARSE_LNK_HK = 7075 ,
2019-02-02 20:25:07 +00:00
DW_GENERIC_DEPRECATED = 7998 ,
2017-04-25 13:09:41 +00:00
DW_PARSE_REGPATHPREFIX = 7999 ,
DW_INSTFILESPAGE_NOT_USED = 8000 , // reserved ..8019
DW_COMP_FINAL = 8020 , // reserved ..8059
DW_COMP_WHOLE_IGNORE_OFF = 8021 ,
DW_COMP_LEVEL_IGNORE = 8025 ,
DW_COMP_DICT_IGNORE = 8026 ,
DW_COMP_DICTWHOLE = 8030 ,
DW_CMDLINE_HIGHPRIORITY = 8499 ,
DW_INSECURE_OUTFILENAME = 9000 ,
DW_VI_MISSINGSTDKEY = 9100 ,
DIAGCODE_INTERNAL_HIDEDIAGCODE = 9999 ,
DIAGCODE_INTERNAL_FIRST = 1000 , DIAGCODE_INTERNAL_LAST = 9999
} DIAGCODE ;
2010-03-24 17:22:56 +00:00
# define PS_OK 0
# define PS_EOF 1
# define PS_ERROR 50
# define PS_WARNING 100
// token placement
# define TP_SEC 1
# define TP_FUNC 2
# define TP_CODE (TP_SEC | TP_FUNC)
# define TP_GLOBAL 4
# define TP_PAGEEX 8
# define TP_PG (TP_GLOBAL | TP_PAGEEX)
# define TP_ALL (TP_CODE | TP_PG)
2013-03-14 18:00:00 +00:00
namespace MakensisAPI {
extern const TCHAR * SigintEventNameFmt ;
extern const TCHAR * SigintEventNameLegacy ;
2020-04-20 17:21:04 +00:00
enum datatransfer_e {
NOTIFY_SCRIPT , // Compiler -> Host: main nsi file(s)
2013-03-14 18:00:00 +00:00
NOTIFY_WARNING ,
NOTIFY_ERROR ,
2020-04-20 17:21:04 +00:00
NOTIFY_OUTPUT , // Compiler -> Host: Generated .exe file
PROMPT_FILEPATH // [0x03006000] Compiler -> Host -> Compiler
2013-03-14 18:00:00 +00:00
} ;
2013-05-04 13:32:47 +00:00
# ifdef _WIN32
enum sndmsg_e {
2016-11-22 21:17:00 +00:00
QUERYHOST = WM_APP // [0x03000000] QUERYHOST_e in wParam. MUST return 0 for unknown QUERYHOST_e values!
2013-05-04 13:32:47 +00:00
} ;
2016-11-23 00:38:57 +00:00
# endif
2013-05-04 13:32:47 +00:00
enum QUERYHOST_e {
2016-11-22 21:17:00 +00:00
QH_OUTPUTCHARSET = 1 , // [0x03000000] return (wincodepage+1) or 0 for default (This encoding is used by stdout, stderr and the notify messages)
2020-04-20 17:21:04 +00:00
QH_ENABLESTDERR , // [0x03001000] return 1 to output error messages to stderr or 0 to output error messages to stdout
QH_SUPPORTEDVERSION , // [0x03006000] The host must return new highest makensis compiler version it supports
2013-05-04 13:32:47 +00:00
} ;
2020-04-20 17:21:04 +00:00
typedef struct {
unsigned char Platform ; // Bitness OR'ed with sizeof(TCHAR) of the compiler
unsigned char Reserved ;
TCHAR Path [ 1 ] ;
} PROMPT_FILEPATH_DATA ;
2013-03-14 18:00:00 +00:00
}
2010-03-24 17:22:56 +00:00
# define PAGE_CUSTOM 0
# define PAGE_LICENSE 1
# define PAGE_COMPONENTS 2
# define PAGE_DIRECTORY 3
# define PAGE_INSTFILES 4
# define PAGE_UNINSTCONFIRM 5
# define PAGE_COMPLETED 6
2012-10-13 01:47:50 +00:00
# define FLAG_OFFSET(flag) (FIELD_OFFSET(exec_flags_t, flag) / sizeof(int))
2017-07-23 19:53:39 +00:00
class DiagState {
2017-09-01 23:06:48 +00:00
template < class C , class K , class V > void insert_or_assign ( C & c , const K & k , V val )
{
typename C : : value_type item ( k , val ) ;
2018-06-25 21:33:30 +00:00
std : : pair < NSIS_CXX_TYPENAME C : : iterator , bool > ret = c . insert ( item ) ;
2017-09-01 23:06:48 +00:00
if ( ! ret . second ) ret . first - > second = val ;
}
2018-11-07 16:58:43 +00:00
template < class C , class K > typename STL : : mapped_type < C > : : type get_paired_value ( const C & c , const K & k , typename STL : : mapped_type < C > : : type defval ) const
2017-09-01 23:06:48 +00:00
{
typename C : : const_iterator it = c . find ( k ) ;
return c . end ( ) = = it ? defval : it - > second ;
}
template < class T > int get_code_state ( T t , int def ) const { return get_paired_value ( m_Warnings , static_cast < unsigned short > ( t ) , def ) ; }
2017-07-23 19:53:39 +00:00
public :
2017-09-01 23:06:48 +00:00
typedef enum { wunspecified = - 1 , wdisabled = 0 , wwarning , wenabled , werror } WARNSTATE ;
DiagState ( ) : m_pStack ( 0 ) , m_FallbackState ( get_default_state ( ) ) { assert ( DIAGCODE_INTERNAL_LAST < = 0xffff ) ; }
2017-07-23 19:53:39 +00:00
~ DiagState ( ) { delete m_pStack ; }
2017-09-01 23:06:48 +00:00
static WARNSTATE get_default_state ( DIAGCODE n = ( DIAGCODE ) 0 ) { return wenabled ; } // All warnings currently default to enabled
void def ( DIAGCODE n ) { insert_or_assign ( m_Warnings , static_cast < unsigned short > ( n ) , get_default_state ( n ) ) ; }
void enable ( DIAGCODE n ) { insert_or_assign ( m_Warnings , static_cast < unsigned short > ( n ) , wenabled ) ; }
void disable ( DIAGCODE n ) { insert_or_assign ( m_Warnings , static_cast < unsigned short > ( n ) , wdisabled ) ; }
void warning ( DIAGCODE n ) { insert_or_assign ( m_Warnings , static_cast < unsigned short > ( n ) , wwarning ) ; } // Always !warning
void error ( DIAGCODE n ) { insert_or_assign ( m_Warnings , static_cast < unsigned short > ( n ) , werror ) ; } // Always !error
bool is_disabled ( DIAGCODE n ) const { return get_code_state ( n , m_FallbackState ) = = wdisabled ; }
bool is_error ( DIAGCODE n ) const { int s = get_code_state ( n , m_FallbackState ) ; return s = = werror ; }
void push ( ) ;
bool pop ( ) ;
void set_all ( WARNSTATE wm ) { m_Warnings . clear ( ) ; m_FallbackState = wm ; }
void set_warning_as_error ( ) { set_all ( werror ) ; }
static bool is_valid_code ( unsigned int n ) { return n > = DIAGCODE_INTERNAL_FIRST & & n < = DIAGCODE_INTERNAL_LAST ; }
2017-07-23 19:53:39 +00:00
protected :
DiagState * m_pStack ;
2017-09-01 23:06:48 +00:00
signed char m_FallbackState ; // A fallback state so we don't have to fill the m_Warnings map with values for codes that are not explicitly set by the user
std : : map < unsigned short , signed char > m_Warnings ;
2017-07-23 19:53:39 +00:00
} ;
2010-03-24 17:22:56 +00:00
class CEXEBuild {
public :
2017-09-01 23:06:48 +00:00
CEXEBuild ( signed char pponly , bool warnaserror ) ;
2010-03-24 17:22:56 +00:00
void initialize ( const TCHAR * makensis_path ) ;
~ CEXEBuild ( ) ;
2013-03-17 21:13:07 +00:00
enum {
2014-07-04 23:27:04 +00:00
MAX_LINELENGTH = 16384 , // NSI/NSH line limit, in TCHARs (including \0)
MAX_MACRORECURSION = 50
2013-03-17 21:13:07 +00:00
} ;
2017-05-03 12:08:09 +00:00
static const TCHAR * get_commandlinecode_filename ( ) { return _T ( " <command line> " ) ; }
2013-03-17 21:13:07 +00:00
2017-04-25 13:09:41 +00:00
void warning ( DIAGCODE dc , const TCHAR * s , . . . ) ; // to add a warning to the compiler's warning list.
void warning_fl ( DIAGCODE dc , const TCHAR * s , . . . ) ; // warning with file name and line number
2012-10-13 01:47:50 +00:00
void ERROR_MSG ( const TCHAR * s , . . . ) const ;
void SCRIPT_MSG ( const TCHAR * s , . . . ) const ;
void INFO_MSG ( const TCHAR * s , . . . ) const ;
2010-03-24 17:22:56 +00:00
2012-10-13 01:47:50 +00:00
typedef enum {
TARGETFIRST ,
TARGET_X86ANSI = TARGETFIRST ,
TARGET_X86UNICODE ,
2013-09-06 23:48:59 +00:00
TARGET_AMD64 , // Always Unicode
2018-06-03 21:00:53 +00:00
TARGET_ARM64 , // Always Unicode
2012-10-13 01:47:50 +00:00
TARGET_UNKNOWN ,
TARGETCOUNT = ( TARGET_UNKNOWN - TARGETFIRST )
} TARGETTYPE ;
TARGETTYPE m_target_type ;
TARGETTYPE get_target_type ( const TCHAR * s ) const ;
2015-12-09 00:47:50 +00:00
bool m_previous_x86_unicode ;
2014-03-04 19:26:56 +00:00
const TCHAR * get_target_suffix ( CEXEBuild : : TARGETTYPE tt , const TCHAR * defval = _T ( " ? " ) ) const ;
2015-12-09 00:47:50 +00:00
const TCHAR * get_target_suffix ( ) const { return get_target_suffix ( m_target_type ) ; }
2018-06-03 21:00:53 +00:00
static bool is_targettype_64bit ( TARGETTYPE tt ) { return TARGET_AMD64 = = tt | | TARGET_ARM64 = = tt ; }
2015-10-01 17:32:56 +00:00
bool is_target_64bit ( ) const { return is_targettype_64bit ( m_target_type ) ; }
2015-12-09 00:47:50 +00:00
void print_bad_targettype_parameter ( const TCHAR * cmdname , const TCHAR * prefix = _T ( " " ) ) const ;
2015-09-18 15:55:56 +00:00
unsigned int get_header_size ( ) const { return ( unsigned int ) sizeof ( header ) + ( is_target_64bit ( ) ? ( 4 * BLOCKS_NUM ) : 0 ) ; }
2010-03-24 17:22:56 +00:00
2010-06-16 15:07:05 +00:00
void set_default_output_filename ( const tstring & filename ) ;
2021-08-17 15:08:24 +00:00
const TCHAR * get_output_filename ( ) const { return build_output_filename ; }
2010-06-16 15:07:05 +00:00
2010-03-24 17:22:56 +00:00
// process a script (you can process as many scripts as you want,
// it is as if they are concatenated)
2013-03-07 21:25:35 +00:00
int process_script ( NIStream & Strm , const TCHAR * filename ) ;
2014-06-19 19:06:49 +00:00
int process_oneline ( const TCHAR * line , const TCHAR * curfilename , int lineptr ) ;
2010-03-24 17:22:56 +00:00
// you only get to call write_output once, so use it wisely.
int write_output ( void ) ;
2013-03-07 21:25:35 +00:00
void print_help ( const TCHAR * commandname = NULL ) ;
2018-02-04 21:19:55 +00:00
bool print_cmdhelp ( const TCHAR * commandname , bool cmdhelp = false ) ;
2010-03-24 17:22:56 +00:00
DefineList definedlist ; // List of identifiers marked as "defined" like
// C++ macro definitions such as _UNICODE.
2013-12-08 14:34:38 +00:00
void define ( const TCHAR * p , const TCHAR * v = _T ( " " ) ) ; // to add a defined thing.
2014-06-19 19:06:49 +00:00
signed char preprocessonly ; // > 0 = safe, < 0 = unsafe
2010-03-24 17:22:56 +00:00
2014-06-15 19:12:12 +00:00
int get_verbosity ( ) const ;
void set_verbosity ( int lvl ) ;
bool display_errors ;
bool display_script ;
bool display_warnings ;
bool display_info ;
2010-03-24 17:22:56 +00:00
int linecnt ;
const TCHAR * curfilename ;
2013-03-07 21:25:35 +00:00
NStreamLineReader * curlinereader ;
2010-03-24 17:22:56 +00:00
HWND notify_hwnd ;
2020-04-20 17:21:04 +00:00
void notify ( MakensisAPI : : datatransfer_e code , const TCHAR * data ) const ;
# ifdef _WIN32
typedef bool ( CALLBACK * HOSTAPIREQUESTDATAPROC ) ( void * cookie , HWND hWnd , UINT Msg , WPARAM wParam , LPARAM lParam ) ;
# else
typedef bool ( * HOSTAPIREQUESTDATAPROC ) ( void * cookie ) ;
# endif
2020-08-13 00:49:05 +00:00
bool hostapi_request_data ( MakensisAPI : : datatransfer_e operation , UINT minver , HOSTAPIREQUESTDATAPROC proc , void * cookie , const void * input , size_t inputsize ) const ;
2020-04-20 17:21:04 +00:00
bool prompt_for_output_path ( TCHAR * path , UINT pathcap ) const ;
2010-03-24 17:22:56 +00:00
private :
int check_write_output_errors ( ) const ;
int prepare_uninstaller ( ) ;
int pack_exe_header ( ) ;
int set_compressor ( const tstring & compressor , const bool solid ) ;
2010-06-14 10:07:22 +00:00
int load_stub ( ) ;
2010-03-24 17:22:56 +00:00
int update_exehead ( const tstring & file , size_t * size = NULL ) ;
void update_exehead ( const unsigned char * new_exehead , size_t new_size ) ;
// tokens.cpp
2015-11-05 04:46:14 +00:00
bool is_ppbranch_token ( const TCHAR * s ) ;
2014-06-19 19:06:49 +00:00
bool is_pp_token ( int tkid ) ;
bool is_unsafe_pp_token ( int tkid ) ;
2014-08-21 13:15:07 +00:00
int get_commandtoken ( const TCHAR * s , int * np , int * op , int * pos ) ;
2012-10-13 01:47:50 +00:00
const TCHAR * get_commandtoken_name ( int tok ) ;
2010-03-24 17:22:56 +00:00
/**
* Returns the current " state " by looking at whether it is in a
* section / function / pagex or global .
* @ return TP_FUNC , TP_SEC , TP_PAGEEX , TP_GLOBAL .
*/
int GetCurrentTokenPlace ( ) ;
2014-08-21 13:15:07 +00:00
int IsTokenPlacedRight ( int pos , const TCHAR * tok ) ;
2010-03-24 17:22:56 +00:00
// script.cpp
# ifdef NSIS_SUPPORT_STANDARD_PREDEFINES
// Added by Sunil Kamath 11 June 2003
TCHAR * set_file_predefine ( const TCHAR * ) ;
void restore_file_predefine ( TCHAR * ) ;
TCHAR * set_timestamp_predefine ( const TCHAR * ) ;
void restore_timestamp_predefine ( TCHAR * ) ;
TCHAR * set_line_predefine ( int , BOOL ) ;
void restore_line_predefine ( TCHAR * ) ;
void set_date_time_predefines ( ) ;
void del_date_time_predefines ( ) ;
# endif
int parseScript ( ) ;
2013-03-07 21:25:35 +00:00
int includeScript ( const TCHAR * f , NStreamEncoding & enc ) ;
2013-03-16 20:09:44 +00:00
TCHAR * GetMacro ( const TCHAR * macroname , TCHAR * * macroend = 0 ) ;
2014-07-05 11:55:28 +00:00
bool MacroExists ( const TCHAR * macroname ) { return ! ! GetMacro ( macroname ) ; }
2016-02-26 16:16:29 +00:00
LANGID ParseLangIdParameter ( const LineParser & line , int token ) ;
2013-03-07 21:25:35 +00:00
int LoadLicenseFile ( const TCHAR * file , TCHAR * * pdata , const TCHAR * cmdname , WORD AnsiCP ) ;
2010-03-24 17:22:56 +00:00
# ifdef NSIS_FIX_DEFINES_IN_STRINGS
void ps_addtoline ( const TCHAR * str , GrowBuf & linedata , StringList & hist , bool bIgnoreDefines = false ) ;
# else
void ps_addtoline ( const TCHAR * str , GrowBuf & linedata , StringList & hist ) ;
# endif
2017-10-13 21:23:33 +00:00
int doParse ( int verbosity , const TCHAR * fmt , . . . ) ;
2010-03-24 17:22:56 +00:00
int doParse ( const TCHAR * str ) ;
int doCommand ( int which_token , LineParser & line ) ;
2013-03-17 21:13:07 +00:00
TCHAR m_templinebuf [ MAX_LINELENGTH ] ; // Buffer used by parseScript() & doCommand(), not recursion safe!
2020-03-10 01:44:23 +00:00
int add_flag_instruction_entry ( int which_token , int opcode , LineParser & line , int offset , int data = 0 ) ;
2010-03-24 17:22:56 +00:00
int do_add_file ( const TCHAR * lgss , int attrib , int recurse , int * total_files , const TCHAR
* name_override = 0 , int generatecode = 1 , int * data_handle = 0 ,
const std : : set < tstring > & excluded = std : : set < tstring > ( ) ,
const tstring & basedir = tstring ( _T ( " " ) ) , bool dir_created = false ) ;
int add_file ( const tstring & dir , const tstring & file , int attrib , const TCHAR
* name_override , int generatecode , int * data_handle ) ;
int do_add_file_create_dir ( const tstring & local_dir , const tstring & dir , int attrib = 0 ) ;
GrowBuf m_linebuild ; // used for concatenating lines
// used by doParse to do preprocessing
struct ifblock
{
int hasexeced ;
int elseused ;
int ignore ;
int inherited_ignore ;
} * cur_ifblock ;
TinyGrowBuf build_preprocessor_data ;
void start_ifblock ( ) ;
void end_ifblock ( ) ;
int num_ifblock ( ) ;
int last_line_had_slash ;
bool inside_comment ;
int multiple_entries_instruction ; // 1 (true) or 0 (false)
2017-05-03 12:08:09 +00:00
int pp_macro ( LineParser & line ) ;
int pp_macroundef ( LineParser & line ) ;
int pp_insertmacro ( LineParser & line ) ;
int pp_tempfile ( LineParser & line ) ;
int pp_delfile ( LineParser & line ) ;
int pp_appendfile ( LineParser & line ) ;
2017-10-03 20:48:29 +00:00
int pp_getversionhelper ( const TCHAR * cmdname , const TCHAR * path , const TCHAR * basesymname , DWORD high , DWORD low , DWORD flags ) ;
int pp_getversion ( int which_token , LineParser & line ) ;
2017-05-03 12:08:09 +00:00
int pp_searchreplacestring ( LineParser & line ) ;
int pp_searchparsestring ( LineParser & line ) ;
2013-04-16 21:02:50 +00:00
DefineList * searchParseString ( const TCHAR * source_string , LineParser & line , int parmOffs , bool ignCase , bool noErrors , UINT * failParam = 0 ) ;
2017-05-03 12:08:09 +00:00
int pp_verbose ( LineParser & line ) ;
int pp_define ( LineParser & line ) ;
int pp_undef ( LineParser & line ) ;
int pp_packhdr ( LineParser & line ) ;
2021-08-18 13:53:50 +00:00
int pp_finalize ( int which_token , LineParser & line ) ;
2017-05-03 12:08:09 +00:00
int pp_execute ( int which_token , LineParser & line ) ;
int pp_addincludedir ( LineParser & line ) ;
int pp_include ( LineParser & line ) ;
int pp_cd ( LineParser & line ) ;
int pp_pragma ( LineParser & line ) ;
2010-03-24 17:22:56 +00:00
// build.cpp functions used mostly by script.cpp
2014-02-08 00:13:52 +00:00
int set_target_architecture_data ( ) ;
int change_target_architecture ( TARGETTYPE tt ) ;
2010-03-24 17:22:56 +00:00
void set_code_type_predefines ( const TCHAR * value = NULL ) ;
int getcurdbsize ( ) ;
int add_section ( const TCHAR * secname , const TCHAR * defname , int expand = 0 ) ;
int section_end ( ) ;
int add_function ( const TCHAR * funname ) ;
int function_end ( ) ;
void section_add_size_kb ( int kb ) ;
int section_add_flags ( int flags ) ;
int section_add_install_type ( int inst_type ) ;
int add_page ( int type ) ;
int page_end ( ) ;
int add_label ( const TCHAR * name ) ;
int add_entry ( const entry * ent ) ;
int add_entry_direct ( int which , int o0 = 0 , int o1 = 0 , int o2 = 0 , int o3 = 0 , int o4 = 0 , int o5 = 0 ) ;
int add_db_data ( IMMap * map ) ; // returns offset
int add_db_data ( const char * data , int length ) ; // returns offset
2014-02-08 00:13:52 +00:00
int add_db_data ( const char * data , size_t length ) { assert ( length < = 0x7FFFFFFF ) ; return add_db_data ( data , ( int ) length ) ; }
2010-03-24 17:22:56 +00:00
int add_data ( const char * data , int length , IGrowBuf * dblock ) ; // returns offset
2013-03-07 21:25:35 +00:00
int add_string ( const TCHAR * string , int process = 1 , UINT codepage = - 2 ) ; // returns offset (in string table)
int add_asciistring ( const TCHAR * string , int process = 1 ) ; // For hardcoded 7bit/ASCII strings
2010-03-24 17:22:56 +00:00
int add_intstring ( const int i ) ; // returns offset in stringblock
int preprocess_string ( TCHAR * out , const TCHAR * in , WORD codepage = CP_ACP ) ;
2013-03-07 21:25:35 +00:00
void init_shellconstantvalues ( ) ;
2017-04-25 13:09:41 +00:00
int parse_pragma ( LineParser & line ) ;
2010-03-24 17:22:56 +00:00
# ifdef NSIS_CONFIG_PLUGIN_SUPPORT
2012-10-13 01:47:50 +00:00
int add_plugins_dir_initializer ( void ) ;
int initialize_default_plugins ( bool newtargetarc = false ) ;
Plugins m_plugins [ TARGETCOUNT ] , * m_pPlugins ;
2010-03-24 17:22:56 +00:00
bool plugin_used ;
bool uninst_plugin_used ;
2012-10-13 01:47:50 +00:00
int build_plugin_unload ; // TOK_SETPLUGINUNLOAD
2010-03-24 17:22:56 +00:00
# endif //NSIS_CONFIG_PLUGIN_SUPPORT
// build.cpp functions used mostly within build.cpp
int datablock_optimize ( int start_offset , int first_int ) ;
2014-03-30 03:25:52 +00:00
bool datablock_finddata ( IMMap & mmap , int mmstart , int size , int * ofs ) ;
2010-03-24 17:22:56 +00:00
void printline ( int l ) ;
int process_jump ( LineParser & line , int wt , int * offs ) ;
int AddVersionInfo ( ) ;
int ProcessPages ( ) ;
void PrepareInstTypes ( ) ;
void AddStandardStrings ( ) ;
void PrepareHeaders ( IGrowBuf * hdrbuf ) ;
int SetVarsSection ( ) ;
int SetManifest ( ) ;
int UpdatePEHeader ( ) ;
int resolve_jump_int ( const TCHAR * fn , int * a , int offs , int start , int end ) ;
int resolve_call_int ( const TCHAR * fn , const TCHAR * str , int fptr , int * ofs ) ;
int resolve_instruction ( const TCHAR * fn , const TCHAR * str , entry * w , int offs , int start , int end ) ;
int resolve_coderefs ( const TCHAR * str ) ;
2017-05-03 12:08:09 +00:00
int uninstall_generate ( ) ;
2010-03-24 17:22:56 +00:00
void print_warnings ( ) ;
2017-04-25 13:09:41 +00:00
void warninghelper ( DIAGCODE dc , bool fl , const TCHAR * fmt , va_list args ) ;
2017-07-23 19:53:39 +00:00
DiagState diagstate ;
2019-02-02 20:25:07 +00:00
bool changed_target ;
2010-03-24 17:22:56 +00:00
/** Are we defining an uninstall version of the code?
* @ param un Use like a boolean to define whether in uninstall mode .
*/
void set_uninstall_mode ( int un ) ;
// lang.cpp functions and variables
void InitLangTables ( ) ;
/**
* This function gets a LanguageTable structure for the specified language
* via LANGID . If create = = true , it will create a new LanguageTable if
* the appropriate one cannot be found . If lang is LANG_NEUTRAL ( 0 ) , then
* it will get the LanguageTable of the last used language or more
* correctly , the last Language ID that generated a valid return value
* ( not NULL ) .
2014-07-02 20:03:18 +00:00
*
2010-03-24 17:22:56 +00:00
* @ param lang [ in / out ] Language ID reference . If LANG_NEUTRAL , it gets
* set to thelast used language ID .
* @ param create Create a new LanguageTable ? Default = true .
* @ return Appropriate LanguagTable * if exists , otherwise NULL .
*/
LanguageTable * GetLangTable ( LANGID & lang , bool create = true ) ;
2014-07-02 20:03:18 +00:00
/**
* Get the language name as a TCHAR * and the code page value via an
* out parameter . It will look for a LanguageTable to get the values .
* If not found , then it will set the codepage to English for ANSI
* or Unicode for Unicode version of NSIS . The language name is looked
* up via the LanguageTable if it exists , otherwise , it returns " ??? " except
* a hardcoded check for 1033 ( english ) . It really should fall back to
* calling GetLocaleInfo ( ) with the LANGID to get the string .
*
* This function is not thread - safe ! For a thread - safe version , the
* parameter must include the buffer to write to .
*
* @ param lang The language ID
* @ param codepage [ out ] The code page referred to by the language ID .
* @ return The language string in English .
*/
2010-03-24 17:22:56 +00:00
const TCHAR * GetLangNameAndCP ( LANGID lang , unsigned int * codepage = NULL ) ;
2011-07-29 22:11:00 +00:00
const TCHAR * GetLangNameAndCPForVersionResource ( LANGID & lang , unsigned int * codepage = NULL , bool deflangfallback = true ) ;
2010-03-24 17:22:56 +00:00
int DefineLangString ( const TCHAR * name , int process = - 1 ) ;
int DefineInnerLangString ( int id , int process = - 1 ) ;
/**
* A LangString is a string variable that varies in value depending on what
* language is being used . This function sets the string value for the
* variable ' name ' for a given language ID .
*
* @ return If the language id , the variable name or string is invalid , it will
2012-10-13 01:47:50 +00:00
* return a PS_ERROR . If this function call is overwriting a set user string ,
2010-03-24 17:22:56 +00:00
* this will return a PS_WARNING .
*/
2013-03-07 21:25:35 +00:00
int SetLangString ( const TCHAR * name , LANGID lang , const TCHAR * str , BOOL LicenseData ) ;
int SetLangString ( const TCHAR * name , LANGID lang , const TCHAR * str ) ;
2010-03-24 17:22:56 +00:00
/**
* Sets the user string to the specific NLF_STRINGS id .
*
* @ return If the id is invalid or the string is not valid , it will return
2012-10-13 01:47:50 +00:00
* a PS_ERROR . If this function call is overwriting a set user string ,
2010-03-24 17:22:56 +00:00
* this will return a PS_WARNING .
*/
2019-10-24 22:15:30 +00:00
int SetInnerString ( int id , const TCHAR * str ) ;
2010-03-24 17:22:56 +00:00
int GenerateLangTable ( LanguageTable * lt , int num_lang_tables ) ;
int GenerateLangTables ( ) ;
void FillLanguageTable ( LanguageTable * table ) ;
int HasUserDefined ( int id ) {
const TCHAR * us = UserInnerStrings . get ( id ) ;
return us & & * us ;
} ;
LanguageTable * LoadLangFile ( TCHAR * filename ) ;
void DeleteLangTable ( LanguageTable * table ) ;
NLFRef NLFRefs [ NLF_STRINGS ] ;
bool keep_ref ;
StringsArray UserInnerStrings ;
bool defcodepage_set ;
GrowBuf lang_tables ;
LANGID last_used_lang ;
LangStringList build_langstrings ;
int build_langstring_num , ubuild_langstring_num ;
TCHAR build_font [ 1024 ] ;
int build_font_size ;
unsigned int uDefCodePage ;
// pages stuff
int license_res_id ;
page * cur_page ; // Current page we are defining, NULL if not.
int cur_page_type ;
int enable_last_page_cancel , uenable_last_page_cancel ;
int disable_window_icon ;
// User variables stuff
2016-12-05 15:44:19 +00:00
int GetUnsafeUserVarIndex ( LineParser & line , int token ) ;
2010-03-24 17:22:56 +00:00
int GetUserVarIndex ( LineParser & line , int token ) ;
// Added by ramon 3 jun 2003
UserVarsStringList m_UserVarNames ;
int m_iBaseVarsNum ;
int DeclaredUserVar ( const TCHAR * VarName ) ;
void VerifyDeclaredUserVarRefs ( UserVarsStringList * pVarsStringList ) ;
2014-04-15 23:26:54 +00:00
bool IsIntOrUserVar ( const LineParser & line , int token ) const ;
2020-05-02 21:53:41 +00:00
static bool IsVarPrefix ( const TCHAR * s ) { return * s + + = = _T ( ' $ ' ) & & * s > ' ' ; }
2010-03-24 17:22:56 +00:00
ConstantsStringList m_ShellConstants ;
// a whole bunch O data.
tstring stubs_dir ;
2010-06-14 10:07:22 +00:00
tstring stub_filename ;
2010-03-24 17:22:56 +00:00
# ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
ICompressor * compressor ;
CZlib zlib_compressor ;
CBzip2 bzip2_compressor ;
CLZMA lzma_compressor ;
# endif
bool build_compressor_set ;
bool build_compressor_final ;
bool build_compress_whole ;
int build_compress ;
int build_compress_level ;
int build_compress_dict_size ;
bool no_space_texts ;
2012-10-13 01:47:50 +00:00
bool build_unicode ; // generate installer with unicode exehead?
2013-03-07 21:25:35 +00:00
bool build_lockedunicodetarget ;
2015-09-18 15:55:56 +00:00
class writer_target_info mk_writer_target_info ( ) ;
2010-03-24 17:22:56 +00:00
bool has_called_write_output ;
2011-06-09 20:05:18 +00:00
struct postbuild_cmd
{
struct postbuild_cmd * next ;
2016-07-14 10:53:25 +00:00
int cmpop , cmpval ;
2011-06-09 20:05:18 +00:00
TCHAR cmd [ 1 ] ;
2018-10-24 19:01:00 +00:00
void delete_all ( ) ;
static postbuild_cmd * make ( const TCHAR * cmdstr , int cmpop , int cmpval ) ;
2021-08-18 13:53:50 +00:00
} * postbuild_cmds , * postubuild_cmds ;
2018-10-24 19:01:00 +00:00
int run_postbuild_cmds ( const postbuild_cmd * cmds , const TCHAR * templatearg_pc1 , const TCHAR * commandname ) ;
2016-07-14 10:53:25 +00:00
int check_external_exitcode ( int exitcode , int op , int val ) ;
2011-06-09 20:05:18 +00:00
2010-03-24 17:22:56 +00:00
TCHAR build_packname [ 1024 ] , build_packcmd [ 1024 ] ;
int build_overwrite , build_last_overwrite , build_crcchk ,
build_datesave , build_optimize_datablock ,
build_allowskipfiles ; // Added by ramon 23 May 2003
header build_header , build_uninst , * cur_header ;
2014-07-02 20:03:18 +00:00
int uninstall_mode ; // Are we in uninstall mode? Acts like a bool.
2010-03-24 17:22:56 +00:00
int uninstall_size , uninstall_size_full ;
int uninstaller_writes_used ;
TCHAR build_output_filename [ 1024 ] ;
int build_include_depth ;
// Added by ramon 6 jun 2003
# ifdef NSIS_SUPPORT_VERSION_INFO
CResourceVersionInfo rVersionInfo ;
2011-07-29 22:11:00 +00:00
unsigned int version_fixedflags ;
2010-03-24 17:22:56 +00:00
# endif
int sectiongroup_open_cnt ;
FastStringList m_warnings ;
2011-11-13 17:31:14 +00:00
const TCHAR * m_currentmacroname ;
2010-03-24 17:22:56 +00:00
GrowBuf m_macros ;
2014-04-05 16:50:11 +00:00
UINT64 db_opt_save , db_opt_save_u , db_full_size , db_full_size_u ;
2014-03-31 17:34:58 +00:00
int db_comp_save , db_comp_save_u ;
2010-03-24 17:22:56 +00:00
FastStringList include_dirs ;
StringList ns_func ; // function namespace
StringList ns_label ; // label namespace
int build_cursection_isfunc ; // Are we in the middle of func definition?
section * build_cursection ; // The section we are defining, NULL if not in section.
// This could be a function or a section.
2014-07-02 20:03:18 +00:00
// The ubuild prefixed objects / variables are for the uninstall versions
2010-03-24 17:22:56 +00:00
// of the code. The cur prefix objects are what the current objects that
// need to be referenced should be. What is pointed to by the cur* objects
// are determined by whether or not we are in uninstall mode or not.
TinyGrowBuf build_sections , ubuild_sections , * cur_sections ;
GrowBuf build_entries , ubuild_entries , * cur_entries ;
GrowBuf build_instruction_entry_map , ubuild_instruction_entry_map , * cur_instruction_entry_map ;
TinyGrowBuf build_functions , ubuild_functions , * cur_functions ;
TinyGrowBuf build_labels , ubuild_labels , * cur_labels ;
2013-03-07 21:25:35 +00:00
ExeHeadStringList build_strlist , ubuild_strlist , * cur_strlist ;
2010-03-24 17:22:56 +00:00
GrowBuf build_langtables , ubuild_langtables , * cur_langtables ;
TinyGrowBuf build_pages , ubuild_pages , * cur_pages ;
TinyGrowBuf build_ctlcolors , ubuild_ctlcolors , * cur_ctlcolors ;
// don't forget to update the cache after updating the datablock
// see datablock_optimize for an example
MMapBuf build_datablock , ubuild_datablock ;
TinyGrowBuf build_datablock_cache , ubuild_datablock_cache ;
IGrowBuf * cur_datablock , * cur_datablock_cache ;
struct cached_db_size
{
int first_int ; // size | (compressed ? 0x80000000 : 0)
int start_offset ;
} ;
int build_filebuflen ;
TinyGrowBuf verbose_stack ;
unsigned char * m_exehead ;
size_t m_exehead_size ;
size_t m_exehead_original_size ;
bool branding_image_found ;
WORD branding_image_id ;
IconGroup installer_icon ;
IconGroup uninstaller_icon ;
size_t m_unicon_size ;
# ifdef NSIS_SUPPORT_BGBG
LOGFONT bg_font ;
LOGFONT bg_default_font ;
# endif
# ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
int deflateToFile ( FILE * fp , char * buf , int len ) ; // len==0 to flush
# endif
2015-07-27 20:41:17 +00:00
WORD PEDllCharacteristics , PESubsysVerMaj , PESubsysVerMin ;
2018-05-14 19:07:17 +00:00
unsigned int manifest_flags ;
2010-03-24 17:22:56 +00:00
manifest : : comctl manifest_comctl ;
manifest : : exec_level manifest_exec_level ;
2012-09-20 18:42:21 +00:00
manifest : : dpiaware manifest_dpiaware ;
2017-09-14 17:10:33 +00:00
tstring manifest_dpiawareness ;
2019-08-16 19:07:02 +00:00
manifest : : longpathaware manifest_lpaware ;
2012-09-20 10:18:40 +00:00
manifest : : SupportedOSList manifest_sosl ;
2019-06-06 00:42:08 +00:00
tstring manifest_maxversiontested ;
2010-03-24 17:22:56 +00:00
CResourceEditor * res_editor ;
void init_res_editor ( ) ;
void close_res_editor ( ) ;
} ;
# endif //_BUILD_H_