| 1 |
/* |
| 2 |
* script.cpp |
| 3 |
* |
| 4 |
* This file is a part of NSIS. |
| 5 |
* |
| 6 |
* Copyright (C) 1999-2026 Nullsoft and Contributors |
| 7 |
* |
| 8 |
* Licensed under the zlib/libpng license (the "License"); |
| 9 |
* you may not use this file except in compliance with the License. |
| 10 |
* |
| 11 |
* Licence details can be found in the file COPYING. |
| 12 |
* |
| 13 |
* This software is provided 'as-is', without any express or implied |
| 14 |
* warranty. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include "Platform.h" |
| 18 |
#include <stdio.h> |
| 19 |
#include <ctype.h> |
| 20 |
#include "tokens.h" |
| 21 |
#include "build.h" |
| 22 |
#include "util.h" |
| 23 |
#include "winchar.h" |
| 24 |
#include "ResourceEditor.h" |
| 25 |
#include "DialogTemplate.h" |
| 26 |
#include "BinInterop.h" |
| 27 |
#include "lang.h" |
| 28 |
#include "dirreader.h" |
| 29 |
#include <nsis-version.h> |
| 30 |
#include "icon.h" |
| 31 |
#include "exehead/api.h" |
| 32 |
#include "exehead/resource.h" |
| 33 |
#include <cassert> // for assert(3) |
| 34 |
#include <time.h> |
| 35 |
#include "tstring.h" |
| 36 |
#include "utf.h" |
| 37 |
#include <algorithm> |
| 38 |
#include "boost/scoped_ptr.hpp" |
| 39 |
|
| 40 |
using namespace std; |
| 41 |
|
| 42 |
#ifndef _WIN32 |
| 43 |
# include <sys/stat.h> // for stat and umask |
| 44 |
# include <sys/types.h> // for mode_t |
| 45 |
# include <fcntl.h> // for O_RDONLY |
| 46 |
# include <unistd.h> |
| 47 |
# include <stdlib.h> // for mkstemp |
| 48 |
#endif |
| 49 |
|
| 50 |
#define REGROOTKEYTOINT(hk) ( (INT) (((INT_PTR)(hk)) & 0xffffffff) ) // Masking off non-existing top bits to make GCC happy |
| 51 |
#define REGROOTKEYTOINTEX(hk, removeviewbits) ( REGROOTKEYTOINT(hk) & ~(removeviewbits ? (REGROOTVIEW32|REGROOTVIEW64) : 0) ) |
| 52 |
|
| 53 |
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT |
| 54 |
typedef enum { LU_INVALID = -1, LU_PIXEL = 0, LU_DIALOG } LAYOUTUNIT; |
| 55 |
static int ParseLayoutUnit(const TCHAR*Str, LAYOUTUNIT&LU) |
| 56 |
{ |
| 57 |
TCHAR buf[200]; |
| 58 |
int succ, val = LineParser::parse_int(Str, &succ); |
| 59 |
if (succ) return (LU = LU_PIXEL, val); |
| 60 |
size_t cch = my_strncpy(buf, Str, COUNTOF(buf)); |
| 61 |
if (cch > 1 && S7IsChEqualI('u', buf[cch-1])) // Something with a 'u' suffix? |
| 62 |
{ |
| 63 |
buf[cch-1] = _T('\0'); |
| 64 |
val = LineParser::parse_int(buf, &succ); |
| 65 |
if (succ) return (LU = LU_DIALOG, val); |
| 66 |
} |
| 67 |
return (LU = LU_INVALID, -1); |
| 68 |
} |
| 69 |
#endif |
| 70 |
|
| 71 |
#ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT |
| 72 |
static bool LookupWinSysColorId(const TCHAR*Str, UINT&Clr) |
| 73 |
{ |
| 74 |
static const struct { const TCHAR*Name; UINT Id; } map[] = { // Note: This list is incomplete. |
| 75 |
{ _T("WINDOW"), 5 }, { _T("WINDOWTEXT"), 8 }, |
| 76 |
{ _T("3DFACE"), 15 }, { _T("BTNTEXT"), 18 }, // "Three-dimensional display elements and dialog box" |
| 77 |
{ _T("HIGHLIGHT"), 13 }, { _T("HIGHLIGHTTEXT"), 14 }, // "Item(s) selected in a control" |
| 78 |
{ _T("GRAYTEXT"), 17 }, // "Grayed (disabled) text" |
| 79 |
{ _T("HOTLIGHT"), 26 }, // "Color for a hyperlink or hot-tracked item" (Win98+) |
| 80 |
}; |
| 81 |
for (UINT i = 0; i < COUNTOF(map); ++i) |
| 82 |
if (!_tcsicmp(map[i].Name, Str)) return (Clr = map[i].Id, true); |
| 83 |
return false; |
| 84 |
} |
| 85 |
static UINT ParseCtlColor(const TCHAR*Str, int&CCFlags, int CCFlagmask) |
| 86 |
{ |
| 87 |
UINT clr, v; |
| 88 |
TCHAR buf[7+!0], *pEnd; |
| 89 |
my_strncpy(buf, Str, 7+!0), buf[7] = '\0'; |
| 90 |
if (!_tcscmp(_T("SYSCLR:"), buf)) |
| 91 |
{ |
| 92 |
CCFlags |= ((CC_TEXT_SYS|CC_BK_SYS) & CCFlagmask); // ExeHead must call GetSysColor |
| 93 |
if (!LookupWinSysColorId(Str+7, clr)) clr = _tcstoul(Str+7, &pEnd, 0); |
| 94 |
} |
| 95 |
else |
| 96 |
v = _tcstoul(Str, &pEnd, 16), clr = ((v&0xff)<<16)|(v&0xff00)|((v&0xff0000)>>16); |
| 97 |
return clr; |
| 98 |
} |
| 99 |
#endif //~ NSIS_CONFIG_ENHANCEDUI_SUPPORT |
| 100 |
|
| 101 |
static LANGID ParseLangId(const TCHAR*Str) |
| 102 |
{ |
| 103 |
const TCHAR *p = Str; |
| 104 |
if (_T('+') == *p || _T('-') == *p) ++p; |
| 105 |
return _T('0') == p[0] && _T('x') == (p[1]|32) ? LineParser::parse_int(Str) : _ttoi(Str); |
| 106 |
} |
| 107 |
|
| 108 |
LANGID CEXEBuild::ParseLangIdParameter(const LineParser&line, int token) |
| 109 |
{ |
| 110 |
int succ, lid = line.gettoken_int(token, &succ); |
| 111 |
if (!lid) lid = last_used_lang; |
| 112 |
if (!succ) |
| 113 |
warning_fl(DW_BAD_LANGID, _T("\"%") NPRIs _T("\" is not a valid language id, using language id %u!"), line.gettoken_str(token), lid); |
| 114 |
return lid; |
| 115 |
} |
| 116 |
|
| 117 |
int CEXEBuild::process_script(NIStream&Strm, const TCHAR *filename) |
| 118 |
{ |
| 119 |
NStreamLineReader linereader(Strm); |
| 120 |
curlinereader = &linereader; |
| 121 |
curfilename = filename; |
| 122 |
linecnt = 0; |
| 123 |
|
| 124 |
if (has_called_write_output) |
| 125 |
{ |
| 126 |
ERROR_MSG(_T("Error (process_script): write_output already called, can't continue\n")); |
| 127 |
return PS_ERROR; |
| 128 |
} |
| 129 |
|
| 130 |
#ifdef NSIS_SUPPORT_STANDARD_PREDEFINES |
| 131 |
set_date_time_predefines(); |
| 132 |
TCHAR *oldfilename = set_file_predefine(curfilename); |
| 133 |
TCHAR *oldtimestamp = set_timestamp_predefine(curfilename); |
| 134 |
#endif |
| 135 |
|
| 136 |
int ret=parseScript(); |
| 137 |
|
| 138 |
#ifdef NSIS_SUPPORT_STANDARD_PREDEFINES |
| 139 |
restore_file_predefine(oldfilename); |
| 140 |
restore_timestamp_predefine(oldtimestamp); |
| 141 |
del_date_time_predefines(); |
| 142 |
#endif |
| 143 |
|
| 144 |
curlinereader = 0; |
| 145 |
curfilename = 0; |
| 146 |
|
| 147 |
if (m_linebuild.getlen()) |
| 148 |
{ |
| 149 |
ERROR_MSG(_T("Error: invalid script: last line ended with \\\n")); |
| 150 |
return PS_ERROR; |
| 151 |
} |
| 152 |
|
| 153 |
if (ret == PS_EOF && num_ifblock()) |
| 154 |
{ |
| 155 |
ERROR_MSG(_T("!if[macro][n]def: open at EOF - need !endif\n")); |
| 156 |
return PS_ERROR; |
| 157 |
} |
| 158 |
|
| 159 |
return ret; |
| 160 |
} |
| 161 |
|
| 162 |
#define PRINTHELPEX(cmdname) { print_help((cmdname)); return PS_ERROR; } |
| 163 |
#define PRINTHELP() PRINTHELPEX(line.gettoken_str(0)) |
| 164 |
|
| 165 |
void CEXEBuild::start_ifblock() |
| 166 |
{ |
| 167 |
ifblock ib = {0, }; |
| 168 |
if (cur_ifblock) |
| 169 |
ib.inherited_ignore = cur_ifblock->ignore || cur_ifblock->inherited_ignore; |
| 170 |
int num = build_preprocessor_data.getlen() / sizeof(ifblock); |
| 171 |
build_preprocessor_data.add(&ib, sizeof(ifblock)); |
| 172 |
cur_ifblock = (ifblock *) build_preprocessor_data.get() + num; |
| 173 |
} |
| 174 |
|
| 175 |
void CEXEBuild::end_ifblock() |
| 176 |
{ |
| 177 |
if (build_preprocessor_data.getlen()) |
| 178 |
{ |
| 179 |
cur_ifblock--; |
| 180 |
build_preprocessor_data.resize(build_preprocessor_data.getlen() - sizeof(ifblock)); |
| 181 |
if (!build_preprocessor_data.getlen()) |
| 182 |
cur_ifblock = 0; |
| 183 |
} |
| 184 |
} |
| 185 |
|
| 186 |
int CEXEBuild::num_ifblock() |
| 187 |
{ |
| 188 |
return build_preprocessor_data.getlen() / sizeof(ifblock); |
| 189 |
} |
| 190 |
|
| 191 |
int CEXEBuild::doParse(int verbosity, const TCHAR *fmt, ...) |
| 192 |
{ |
| 193 |
ExpandoString<TCHAR, NSIS_MAX_STRLEN> buf; |
| 194 |
int orgv = get_verbosity(), res; |
| 195 |
va_list val; |
| 196 |
va_start(val, fmt); |
| 197 |
buf.StrVFmt(fmt, val); |
| 198 |
va_end(val); |
| 199 |
if (verbosity >= 0) set_verbosity(verbosity); |
| 200 |
res = doParse(buf.GetPtr()); |
| 201 |
set_verbosity(orgv); |
| 202 |
return res; |
| 203 |
} |
| 204 |
|
| 205 |
int CEXEBuild::doParse(const TCHAR *str) |
| 206 |
{ |
| 207 |
LineParser line(inside_comment); |
| 208 |
int res; |
| 209 |
|
| 210 |
while (*str == _T(' ') || *str == _T('\t')) str++; |
| 211 |
|
| 212 |
// remove trailing slash and null, if there's a previous line |
| 213 |
if (m_linebuild.getlen()>1) |
| 214 |
m_linebuild.resize(m_linebuild.getlen()-(2*sizeof(TCHAR))); |
| 215 |
|
| 216 |
// warn of comment with line-continuation |
| 217 |
if (m_linebuild.getlen()) |
| 218 |
{ |
| 219 |
LineParser prevline(inside_comment); |
| 220 |
prevline.parse((TCHAR*)m_linebuild.get()); |
| 221 |
LineParser thisline(inside_comment); |
| 222 |
thisline.parse(str); |
| 223 |
|
| 224 |
if (prevline.inComment() && !thisline.inComment()) |
| 225 |
{ |
| 226 |
warning_fl(DW_COMMENT_NEWLINE, _T("comment contains line-continuation character, following line will be ignored")); |
| 227 |
} |
| 228 |
} |
| 229 |
|
| 230 |
// add new line to line buffer |
| 231 |
const unsigned int cchstr = (unsigned int) _tcslen(str); |
| 232 |
m_linebuild.add(str,(cchstr+1)*sizeof(TCHAR)); |
| 233 |
|
| 234 |
// keep waiting for more lines if this line ends with a backslash |
| 235 |
if (str[0] && CharPrev(str,str+cchstr)[0] == _T('\\')) |
| 236 |
{ |
| 237 |
return PS_OK; |
| 238 |
} |
| 239 |
|
| 240 |
// parse before checking if the line should be ignored, so block comments won't be missed |
| 241 |
|
| 242 |
// escaped quotes should be ignored for compile time commands that set defines |
| 243 |
// because defines can be inserted in commands at a later stage |
| 244 |
bool ignore_escaping = (!_tcsnicmp((TCHAR*)m_linebuild.get(),_T("!define"),7) || !_tcsncicmp((TCHAR*)m_linebuild.get(),_T("!insertmacro"),12)); |
| 245 |
|
| 246 |
NStreamEncoding enc(NStreamEncoding::UNKNOWN); |
| 247 |
|
| 248 |
res=line.parse((TCHAR*)m_linebuild.get(), ignore_escaping, linecnt < 3 ? &enc : NULL); |
| 249 |
|
| 250 |
if (enc.GetCodepage() != NStreamEncoding::UNKNOWN && curlinereader) |
| 251 |
curlinereader->StreamEncoding().SafeSetCodepage(enc.GetCodepage()); |
| 252 |
|
| 253 |
inside_comment = line.inCommentBlock(); |
| 254 |
|
| 255 |
// if ignoring, ignore all lines that don't begin with an exclamation mark |
| 256 |
{ |
| 257 |
bool ignore_line = cur_ifblock && (cur_ifblock->ignore || cur_ifblock->inherited_ignore); |
| 258 |
if (ignore_line) |
| 259 |
{ |
| 260 |
TCHAR *rawline = (TCHAR*) m_linebuild.get(), first_char = *rawline, buf[30], *first_token = buf; |
| 261 |
if (!res) |
| 262 |
first_token = line.gettoken_str(0); |
| 263 |
else // LineParser::parse() failed so we cannot call gettoken_str but we still might need to ignore this line |
| 264 |
for (size_t i = 0; i < COUNTOF(buf); ++i) if ((buf[i] = rawline[i]) <= ' ') { buf[i] = _T('\0'); break; } |
| 265 |
if (first_char!=_T('!') || !is_ppbranch_token(first_token)) |
| 266 |
{ |
| 267 |
m_linebuild.resize(0); |
| 268 |
return PS_OK; |
| 269 |
} |
| 270 |
} |
| 271 |
} |
| 272 |
|
| 273 |
GrowBuf ppoline; |
| 274 |
if (preprocessonly) m_linebuild.swap(ppoline); // LineParser strips quotes and we need to display them |
| 275 |
m_linebuild.resize(0); |
| 276 |
|
| 277 |
if (res) |
| 278 |
{ |
| 279 |
if (res==-2) ERROR_MSG(_T("Error: unterminated string parsing line at %") NPRIs _T(":%d\n"),curfilename,linecnt); |
| 280 |
else ERROR_MSG(_T("Error: error parsing line (%") NPRIs _T(":%d)\n"),curfilename,linecnt); |
| 281 |
return PS_ERROR; |
| 282 |
} |
| 283 |
|
| 284 |
parse_again: |
| 285 |
if (line.getnumtokens() < 1) return PS_OK; |
| 286 |
|
| 287 |
const TCHAR* const tokstr0 = line.gettoken_str(0); |
| 288 |
int np,op,pos; |
| 289 |
int tkid=get_commandtoken(tokstr0,&np,&op,&pos); |
| 290 |
if (tkid == -1) |
| 291 |
{ |
| 292 |
const TCHAR *p=tokstr0; |
| 293 |
if (p[0] && p[_tcslen(p)-1]==_T(':')) |
| 294 |
{ |
| 295 |
if (p[0] == _T('!') || (p[0] >= _T('0') && p[0] <= _T('9')) || p[0] == _T('$') || p[0] == _T('-') || p[0] == _T('+')) |
| 296 |
{ |
| 297 |
ERROR_MSG(_T("Invalid label: %") NPRIs _T(" (labels cannot begin with !, $, -, +, or 0-9)\n"),tokstr0); |
| 298 |
return PS_ERROR; |
| 299 |
} |
| 300 |
extern FILE *g_output; |
| 301 |
if (preprocessonly) |
| 302 |
_ftprintf(g_output,_T("%") NPRIs _T("\n"),tokstr0); |
| 303 |
else |
| 304 |
if (add_label(tokstr0)) return PS_ERROR; |
| 305 |
line.eattoken(); |
| 306 |
goto parse_again; |
| 307 |
} |
| 308 |
|
| 309 |
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT |
| 310 |
// We didn't recognise this command, could it be the name of a function exported from a dll? |
| 311 |
// Plugins cannot be called in global scope so there is no need to initialize the list first |
| 312 |
if (m_pPlugins && m_pPlugins->IsPluginCommand(tokstr0)) |
| 313 |
{ |
| 314 |
np = 0; // parameters are optional |
| 315 |
op = -1; // unlimited number of optional parameters |
| 316 |
pos = -1; // placement will tested later |
| 317 |
tkid = TOK__PLUGINCOMMAND; |
| 318 |
} |
| 319 |
else |
| 320 |
#endif |
| 321 |
{ |
| 322 |
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT |
| 323 |
if (Plugins::IsPluginCallSyntax(tokstr0)) |
| 324 |
{ |
| 325 |
if (m_pPlugins && display_warnings) m_pPlugins->PrintPluginDirs(); |
| 326 |
ERROR_MSG(_T("Plugin%") NPRIs _T(" not found, cannot call %") NPRIs _T("\n"),m_pPlugins && m_pPlugins->IsKnownPlugin(tokstr0) ? _T(" function") : _T(""),tokstr0); |
| 327 |
} |
| 328 |
else |
| 329 |
#endif |
| 330 |
ERROR_MSG(_T("Invalid command: \"%") NPRIs _T("\"\n"),tokstr0); |
| 331 |
return PS_ERROR; |
| 332 |
} |
| 333 |
} |
| 334 |
|
| 335 |
if (IsTokenPlacedRight(pos, tokstr0) != PS_OK) |
| 336 |
return PS_ERROR; |
| 337 |
|
| 338 |
int v=line.getnumtokens()-(np+1); |
| 339 |
if (v < 0 || (op >= 0 && v > op)) // opt_parms is -1 for unlimited |
| 340 |
{ |
| 341 |
ERROR_MSG(_T("%") NPRIs _T(" expects %d"),tokstr0,np); |
| 342 |
if (op < 0) ERROR_MSG(_T("+")); |
| 343 |
if (op > 0) ERROR_MSG(_T("-%d"),op+np); |
| 344 |
ERROR_MSG(_T(" parameters, got %d.\n"),line.getnumtokens()-1); |
| 345 |
PRINTHELP() |
| 346 |
} |
| 347 |
|
| 348 |
int if_from_else = 0; |
| 349 |
|
| 350 |
if (tkid == TOK_P_ELSE) |
| 351 |
{ |
| 352 |
if (cur_ifblock && cur_ifblock->inherited_ignore) |
| 353 |
return PS_OK; |
| 354 |
|
| 355 |
if (!num_ifblock()) |
| 356 |
{ |
| 357 |
ERROR_MSG(_T("!else: no if block open (!if[macro][n][def])\n")); |
| 358 |
return PS_ERROR; |
| 359 |
} |
| 360 |
|
| 361 |
if (cur_ifblock->elseused) |
| 362 |
{ |
| 363 |
ERROR_MSG(_T("!else: else already used in current if block\n")); |
| 364 |
return PS_ERROR; |
| 365 |
} |
| 366 |
|
| 367 |
if (cur_ifblock->hasexeced) |
| 368 |
{ |
| 369 |
cur_ifblock->ignore++; |
| 370 |
return PS_OK; |
| 371 |
} |
| 372 |
|
| 373 |
if (line.getnumtokens() == 1) |
| 374 |
{ |
| 375 |
cur_ifblock->ignore = !cur_ifblock->ignore; |
| 376 |
// if not executed up until now, it will now |
| 377 |
cur_ifblock->hasexeced++; |
| 378 |
cur_ifblock->elseused++; |
| 379 |
return PS_OK; |
| 380 |
} |
| 381 |
|
| 382 |
line.eattoken(); |
| 383 |
|
| 384 |
int v=line.gettoken_enum(0,_T("if\0ifdef\0ifndef\0ifmacrodef\0ifmacrondef\0")); |
| 385 |
if (v < 0) PRINTHELP() |
| 386 |
if (line.getnumtokens() == 1) PRINTHELP() |
| 387 |
const int cmds[] = {TOK_P_IF, TOK_P_IFDEF, TOK_P_IFNDEF, TOK_P_IFMACRODEF, TOK_P_IFMACRONDEF}; |
| 388 |
tkid = cmds[v]; |
| 389 |
if_from_else++; |
| 390 |
} |
| 391 |
|
| 392 |
if (tkid == TOK_P_IFNDEF || tkid == TOK_P_IFDEF || |
| 393 |
tkid == TOK_P_IFMACRODEF || tkid == TOK_P_IFMACRONDEF || |
| 394 |
tkid == TOK_P_IF) |
| 395 |
{ |
| 396 |
if (!if_from_else) |
| 397 |
start_ifblock(); |
| 398 |
|
| 399 |
if (cur_ifblock && cur_ifblock->inherited_ignore) |
| 400 |
{ |
| 401 |
return PS_OK; |
| 402 |
} |
| 403 |
|
| 404 |
int istrue=0, mod=0; |
| 405 |
|
| 406 |
if (tkid == TOK_P_IF) { |
| 407 |
res = pp_boolifyexpression(line, istrue, true); |
| 408 |
if (res != PS_OK) return res; |
| 409 |
} |
| 410 |
else { |
| 411 |
|
| 412 |
// pure left to right precedence. Not too powerful, but useful. |
| 413 |
for (int p = 1; p < line.getnumtokens(); p++) |
| 414 |
{ |
| 415 |
if (p & 1) |
| 416 |
{ |
| 417 |
bool new_s; |
| 418 |
if (tkid == TOK_P_IFNDEF || tkid == TOK_P_IFDEF) |
| 419 |
new_s=!!definedlist.find(line.gettoken_str(p)); |
| 420 |
else |
| 421 |
new_s=MacroExists(line.gettoken_str(p)); |
| 422 |
if (tkid == TOK_P_IFNDEF || tkid == TOK_P_IFMACRONDEF) |
| 423 |
new_s=!new_s; |
| 424 |
|
| 425 |
if (mod == 0) istrue = istrue || new_s; |
| 426 |
else istrue = istrue && new_s; |
| 427 |
} |
| 428 |
else |
| 429 |
{ |
| 430 |
mod=line.gettoken_enum(p,_T("|\0&\0||\0&&\0")); |
| 431 |
if (mod == -1) PRINTHELP() |
| 432 |
mod &= 1; |
| 433 |
} |
| 434 |
} |
| 435 |
} |
| 436 |
|
| 437 |
if (istrue) |
| 438 |
{ |
| 439 |
cur_ifblock->hasexeced++; |
| 440 |
cur_ifblock->ignore = 0; |
| 441 |
} |
| 442 |
else |
| 443 |
cur_ifblock->ignore++; |
| 444 |
|
| 445 |
return PS_OK; |
| 446 |
} |
| 447 |
if (tkid == TOK_P_ENDIF) { |
| 448 |
if (!num_ifblock()) |
| 449 |
{ |
| 450 |
ERROR_MSG(_T("!endif: no if block open (!if[macro][n][def])\n")); |
| 451 |
return PS_ERROR; |
| 452 |
} |
| 453 |
end_ifblock(); |
| 454 |
return PS_OK; |
| 455 |
} |
| 456 |
if (!cur_ifblock || (!cur_ifblock->ignore && !cur_ifblock->inherited_ignore)) |
| 457 |
{ |
| 458 |
if (preprocessonly) |
| 459 |
{ |
| 460 |
extern FILE *g_output; |
| 461 |
bool pptok = is_pp_token(tkid), docmd = pptok; |
| 462 |
bool both = TOK_P_VERBOSE == tkid || TOK_P_WARNING == tkid || TOK_P_ECHO == tkid; |
| 463 |
if (TOK_P_FINALIZE == tkid || TOK_P_UNINSTFINALIZE == tkid || TOK_P_PACKEXEHEADER == tkid) docmd = false; |
| 464 |
if (docmd && is_unsafe_pp_token(tkid) && preprocessonly > 0) docmd = false; |
| 465 |
if (!docmd || both) _ftprintf(g_output,(_T("%") NPRIs _T("\n")),ppoline.get()); |
| 466 |
if (!docmd && !both) return PS_OK; |
| 467 |
} |
| 468 |
return doCommand(tkid,line); |
| 469 |
} |
| 470 |
|
| 471 |
return PS_OK; |
| 472 |
} |
| 473 |
|
| 474 |
#ifdef NSIS_FIX_DEFINES_IN_STRINGS |
| 475 |
void CEXEBuild::ps_addtoline(const TCHAR *str, GrowBuf &linedata, StringList &hist, bool bIgnoreDefines /*= false*/) |
| 476 |
#else |
| 477 |
void CEXEBuild::ps_addtoline(const TCHAR *str, GrowBuf &linedata, StringList &hist) |
| 478 |
#endif |
| 479 |
{ |
| 480 |
// convert $\r, $\n to their literals |
| 481 |
// preprocessor replace ${VAR} and $%VAR% with whatever value |
| 482 |
// note that if VAR does not exist, ${VAR} or $%VAR% will go through unmodified |
| 483 |
const TCHAR *in=str; |
| 484 |
while (*in) |
| 485 |
{ |
| 486 |
int add=1; |
| 487 |
TCHAR c=*in, *t=CharNext(in); |
| 488 |
|
| 489 |
if (t-in > 1) // handle multibyte chars (no escape) |
| 490 |
{ |
| 491 |
linedata.add((void*)in,truncate_cast(int, (size_t)((t-in)*sizeof(TCHAR)))); |
| 492 |
in=t; |
| 493 |
continue; |
| 494 |
} |
| 495 |
in=t; |
| 496 |
|
| 497 |
if (c == _T('$')) |
| 498 |
{ |
| 499 |
if (in[0] == _T('\\')) |
| 500 |
{ |
| 501 |
if (in[1] == _T('r')) |
| 502 |
in+=2, c=_T('\r'); |
| 503 |
else if (in[1] == _T('n')) |
| 504 |
in+=2, c=_T('\n'); |
| 505 |
else if (in[1] == _T('t')) |
| 506 |
in+=2, c=_T('\t'); |
| 507 |
} |
| 508 |
else if (in[0] == _T('{')) |
| 509 |
{ |
| 510 |
TCHAR *s=_tcsdup(in+1), *t=s; |
| 511 |
MANAGE_WITH(s, free); |
| 512 |
unsigned int bn = 0; |
| 513 |
while (*t) |
| 514 |
{ |
| 515 |
if (*t == _T('{')) bn++; |
| 516 |
if (*t == _T('}') && bn-- == 0) break; |
| 517 |
t=CharNext(t); |
| 518 |
} |
| 519 |
if (*t && t!=s |
| 520 |
#ifdef NSIS_FIX_DEFINES_IN_STRINGS |
| 521 |
&& !bIgnoreDefines |
| 522 |
#endif |
| 523 |
) |
| 524 |
{ |
| 525 |
*t=0; |
| 526 |
// check for defines inside the define name - ${bla${blo}} |
| 527 |
GrowBuf defname; |
| 528 |
ps_addtoline(s,defname,hist); |
| 529 |
defname.add(_T(""),sizeof(_T(""))); |
| 530 |
t=definedlist.find((TCHAR*)defname.get()); |
| 531 |
TCHAR dyndefbuf[10+1]; |
| 532 |
if (!t) |
| 533 |
{ |
| 534 |
if (_T('_')==s[0] && _T('_')==s[1]) |
| 535 |
{ |
| 536 |
if (!_tcscmp(s,_T("__COUNTER__"))) |
| 537 |
{ |
| 538 |
static unsigned long cntr=0; |
| 539 |
_stprintf(dyndefbuf,_T("%lu"),cntr++); |
| 540 |
t=dyndefbuf; |
| 541 |
} |
| 542 |
} |
| 543 |
if (_T('U')==s[0] && _T('+')==s[1]) |
| 544 |
{ |
| 545 |
TCHAR *n=s+2; |
| 546 |
UINT32 utf32=_tcstoul(n,&t,16); |
| 547 |
// We only want to accept "${U+HEXDIGITS}" and not "${U+ -HEXDIGITS }" |
| 548 |
if (*t || _T('-')==*n || _T('+')==*n) t=0; |
| 549 |
if (_T(' ')==*n || _T('\t')==*n) t=0; // TODO: _istspace()? |
| 550 |
if (!utf32) t=0; // Don't allow "${U+0}" |
| 551 |
if (t) |
| 552 |
{ |
| 553 |
UINT32 codpts[]={utf32,UNICODE_REPLACEMENT_CHARACTER,'?'}; |
| 554 |
for(size_t i=0, cch; i < COUNTOF(codpts); ++i) |
| 555 |
{ |
| 556 |
cch = WCFromCodePoint(dyndefbuf,COUNTOF(dyndefbuf),codpts[i]); |
| 557 |
if (cch) { dyndefbuf[cch] = _T('\0'); break; } |
| 558 |
} |
| 559 |
t=dyndefbuf; |
| 560 |
} |
| 561 |
} |
| 562 |
} |
| 563 |
if (t && hist.find((TCHAR*)defname.get(),0)<0) |
| 564 |
{ |
| 565 |
in+=_tcslen(s)+2; |
| 566 |
add=0; |
| 567 |
hist.add((TCHAR*)defname.get(),0); |
| 568 |
#ifdef NSIS_FIX_DEFINES_IN_STRINGS |
| 569 |
ps_addtoline(t,linedata,hist,true); |
| 570 |
#else |
| 571 |
ps_addtoline(t,linedata,hist); |
| 572 |
#endif |
| 573 |
hist.delbypos(hist.find((TCHAR*)defname.get(),0)); |
| 574 |
} |
| 575 |
} |
| 576 |
} |
| 577 |
else if (in[0] == _T('%')) |
| 578 |
{ |
| 579 |
TCHAR *s=_tcsdup(in+1); |
| 580 |
MANAGE_WITH(s, free); |
| 581 |
TCHAR *t=s; |
| 582 |
while (*t) |
| 583 |
{ |
| 584 |
if (*t == _T('%')) break; |
| 585 |
t=CharNext(t); |
| 586 |
} |
| 587 |
if (*t && t!=s) |
| 588 |
{ |
| 589 |
*t=0; |
| 590 |
// check for defines inside the define name - ${bla${blo}} |
| 591 |
GrowBuf defname; |
| 592 |
ps_addtoline(s,defname,hist); |
| 593 |
defname.add(_T(""),sizeof(_T(""))); |
| 594 |
t=_tgetenv((TCHAR*)defname.get()); |
| 595 |
if (t && hist.find((TCHAR*)defname.get(),0)<0) |
| 596 |
{ |
| 597 |
in+=_tcslen(s)+2; |
| 598 |
add=0; |
| 599 |
hist.add((TCHAR*)defname.get(),0); |
| 600 |
#ifdef NSIS_FIX_DEFINES_IN_STRINGS |
| 601 |
ps_addtoline(t,linedata,hist,true); |
| 602 |
#else |
| 603 |
ps_addtoline(t,linedata,hist); |
| 604 |
#endif |
| 605 |
hist.delbypos(hist.find((TCHAR*)defname.get(),0)); |
| 606 |
} |
| 607 |
} |
| 608 |
} |
| 609 |
#ifdef NSIS_FIX_DEFINES_IN_STRINGS |
| 610 |
else if (in[0] == _T('$')) |
| 611 |
{ |
| 612 |
if (in[1] == _T('{')) // Found $$ before - Don't replace this define |
| 613 |
{ |
| 614 |
TCHAR *s=_tcsdup(in+2); |
| 615 |
MANAGE_WITH(s, free); |
| 616 |
TCHAR *t=s; |
| 617 |
unsigned int bn = 0; |
| 618 |
while (*t) |
| 619 |
{ |
| 620 |
if (*t == _T('{')) bn++; |
| 621 |
if (*t == _T('}') && bn-- == 0) break; |
| 622 |
t=CharNext(t); |
| 623 |
} |
| 624 |
if (*t && t!=s) |
| 625 |
{ |
| 626 |
*t=0; |
| 627 |
// add text unchanged |
| 628 |
GrowBuf defname; |
| 629 |
ps_addtoline(s,defname,hist); |
| 630 |
in++; |
| 631 |
} |
| 632 |
} |
| 633 |
else |
| 634 |
{ |
| 635 |
linedata.add((void*)&c,1*sizeof(TCHAR)); |
| 636 |
in++; |
| 637 |
} |
| 638 |
} |
| 639 |
#endif |
| 640 |
} |
| 641 |
if (add) linedata.add((void*)&c,1*sizeof(TCHAR)); |
| 642 |
} |
| 643 |
} |
| 644 |
|
| 645 |
int CEXEBuild::parseScript() |
| 646 |
{ |
| 647 |
assert(curlinereader); |
| 648 |
TCHAR *str = m_templinebuf; |
| 649 |
NStreamLineReader &linereader = *curlinereader; |
| 650 |
|
| 651 |
for (;;) |
| 652 |
{ |
| 653 |
UINT lrres = linereader.ReadLine(str,MAX_LINELENGTH); |
| 654 |
linecnt++; |
| 655 |
if (NStream::OK != lrres) |
| 656 |
{ |
| 657 |
if (linereader.IsEOF()) |
| 658 |
{ |
| 659 |
if (!str[0]) break; |
| 660 |
} |
| 661 |
else |
| 662 |
{ |
| 663 |
ERROR_MSG(linereader.GetErrorMessage(lrres,curfilename,linecnt).c_str()); |
| 664 |
return PS_ERROR; |
| 665 |
} |
| 666 |
} |
| 667 |
|
| 668 |
// remove trailing whitespace |
| 669 |
TCHAR *p = str; |
| 670 |
while (*p) p++; |
| 671 |
if (p > str) p--; |
| 672 |
while (p >= str && (*p == _T('\r') || *p == _T('\n') || *p == _T(' ') || *p == _T('\t'))) p--; |
| 673 |
*++p=0; |
| 674 |
|
| 675 |
StringList hist; |
| 676 |
GrowBuf linedata; |
| 677 |
|
| 678 |
#ifdef NSIS_SUPPORT_STANDARD_PREDEFINES |
| 679 |
TCHAR *oldline = set_line_predefine(linecnt, FALSE); |
| 680 |
#endif |
| 681 |
ps_addtoline(str,linedata,hist); |
| 682 |
linedata.add(_T(""),sizeof(_T(""))); |
| 683 |
int ret=doParse((TCHAR*)linedata.get()); |
| 684 |
#ifdef NSIS_SUPPORT_STANDARD_PREDEFINES |
| 685 |
restore_line_predefine(oldline); |
| 686 |
#endif |
| 687 |
|
| 688 |
if (ret != PS_OK) return ret; |
| 689 |
} |
| 690 |
|
| 691 |
return PS_EOF; |
| 692 |
} |
| 693 |
|
| 694 |
int CEXEBuild::LoadLicenseFile(const TCHAR *file, TCHAR** pdata, const TCHAR *cmdname, WORD AnsiCP) // caller must free *pdata, even on error result |
| 695 |
{ |
| 696 |
NIStream strm; |
| 697 |
if (!strm.OpenFileForReading(file)) |
| 698 |
{ |
| 699 |
ERROR_MSG(_T("%") NPRIs _T(": open failed \"%") NPRIs _T("\"\n"),cmdname,file); |
| 700 |
print_help(cmdname); |
| 701 |
return PS_ERROR; |
| 702 |
} |
| 703 |
FILE *f=strm.GetHandle(); |
| 704 |
UINT cbBOMOffset=ftell(f); // We might be positioned after a BOM |
| 705 |
UINT32 cbFileSize=get_file_size32(f); |
| 706 |
UINT cbFileData=(invalid_file_size32 == cbFileSize) ? 0 : cbFileSize - cbBOMOffset; |
| 707 |
if (!cbFileData) |
| 708 |
{ |
| 709 |
warning_fl(DW_LICENSE_EMPTY, _T("%") NPRIs _T(": empty license file \"%") NPRIs _T("\"\n"),cmdname,file); |
| 710 |
} |
| 711 |
else |
| 712 |
build_lockedunicodetarget=true; |
| 713 |
|
| 714 |
fseek(f,cbBOMOffset,SEEK_SET); |
| 715 |
UINT cbTotalData=sizeof(TCHAR)+cbFileData+sizeof(TCHAR); // SF_*+file+\0 |
| 716 |
TCHAR*data=(TCHAR*)malloc(cbTotalData); |
| 717 |
*pdata=data; // memory will be released by caller |
| 718 |
if (!data) |
| 719 |
{ |
| 720 |
ERROR_MSG(_T("Internal compiler error #12345: %") NPRIs _T(" malloc(%d) failed.\n"),cmdname,cbTotalData); |
| 721 |
return PS_ERROR; |
| 722 |
} |
| 723 |
*((TCHAR*)((char*)data+cbTotalData-sizeof(TCHAR)))=_T('\0'); |
| 724 |
|
| 725 |
TCHAR*ldata=data+1; |
| 726 |
if (!strm.ReadOctets(ldata,&cbFileData)) |
| 727 |
{ |
| 728 |
ERROR_MSG(_T("%") NPRIs _T(": can't read file.\n"),cmdname); |
| 729 |
return PS_ERROR; |
| 730 |
} |
| 731 |
// We have to convert the content of the license file to wchar_t |
| 732 |
const WORD srccp=strm.StreamEncoding().IsUnicode() ? strm.StreamEncoding().GetCodepage() : AnsiCP; |
| 733 |
const UINT cbcu=NStreamEncoding::GetCodeUnitSize(srccp); |
| 734 |
if (sizeof(TCHAR) < cbcu) |
| 735 |
{ |
| 736 |
l_errwcconv: |
| 737 |
ERROR_MSG(_T("%") NPRIs _T(": wchar_t conversion failed!\n"),cmdname); |
| 738 |
return PS_ERROR; |
| 739 |
} |
| 740 |
// Create a fake character in the "header" part of the buffer (For DupWCFromBytes) |
| 741 |
char*lichdr=((char*)ldata) - cbcu; |
| 742 |
*((char*)lichdr)='X'; |
| 743 |
if (cbcu > 1) *((WORD*)lichdr)='X'; |
| 744 |
//BUGBUG: No room, cannot support UTF-32: if (cbcu > 2) *((UINT32*)lichdr)='X'; |
| 745 |
const bool canOptRet = (char*)data == lichdr; |
| 746 |
wchar_t*wcdata=DupWCFromBytes(lichdr,cbcu+cbFileData,srccp|(canOptRet?DWCFBF_ALLOWOPTIMIZEDRETURN:0)); |
| 747 |
if (!wcdata) goto l_errwcconv; |
| 748 |
if (wcdata != data) free(data); |
| 749 |
*pdata=data=wcdata, ldata=data+1; |
| 750 |
|
| 751 |
const bool isRTF=!memcmp(ldata,_T("{\\rtf"),5*sizeof(TCHAR)); |
| 752 |
if (isRTF) |
| 753 |
*data=SF_RTF; |
| 754 |
else |
| 755 |
*data=build_unicode ? (SF_TEXT|SF_UNICODE) : (SF_TEXT); |
| 756 |
|
| 757 |
return PS_OK; |
| 758 |
} |
| 759 |
|
| 760 |
int CEXEBuild::process_oneline(const TCHAR *line, const TCHAR *filename, int linenum, unsigned int plflags) |
| 761 |
{ |
| 762 |
const TCHAR *last_filename = curfilename; |
| 763 |
int last_linecnt = linecnt; |
| 764 |
curfilename = filename, linecnt = linenum; |
| 765 |
|
| 766 |
StringList hist; |
| 767 |
GrowBuf linedata; |
| 768 |
|
| 769 |
#ifdef NSIS_SUPPORT_STANDARD_PREDEFINES |
| 770 |
TCHAR *oldfilename = NULL, *oldtimestamp = NULL, *oldline = NULL; |
| 771 |
bool realfile = !(plflags & PLF_VIRTUALFILE); |
| 772 |
bool is_macro = (plflags & PLF_MACRO); |
| 773 |
bool setline = linenum != 0; |
| 774 |
|
| 775 |
if (setline) { |
| 776 |
if (!is_macro) { |
| 777 |
oldfilename = set_file_predefine(curfilename); |
| 778 |
if (realfile) oldtimestamp = set_timestamp_predefine(curfilename); |
| 779 |
} |
| 780 |
oldline = set_line_predefine(linecnt, is_macro); |
| 781 |
} |
| 782 |
#endif |
| 783 |
|
| 784 |
ps_addtoline(line,linedata,hist); |
| 785 |
linedata.add(_T(""),sizeof(_T(""))); |
| 786 |
int ret = doParse((TCHAR*)linedata.get()); |
| 787 |
|
| 788 |
#ifdef NSIS_SUPPORT_STANDARD_PREDEFINES |
| 789 |
if (setline) { |
| 790 |
if (!is_macro) { |
| 791 |
restore_file_predefine(oldfilename); |
| 792 |
if (realfile) restore_timestamp_predefine(oldtimestamp); |
| 793 |
} |
| 794 |
restore_line_predefine(oldline); |
| 795 |
} |
| 796 |
#endif |
| 797 |
curfilename = last_filename, linecnt = last_linecnt; |
| 798 |
return ret; |
| 799 |
} |
| 800 |
|
| 801 |
int CEXEBuild::process_jump(LineParser &line, int wt, int *offs) |
| 802 |
{ |
| 803 |
const TCHAR *s=line.gettoken_str(wt); |
| 804 |
int v; |
| 805 |
|
| 806 |
if (!_tcsicmp(s,_T("0")) || !_tcsicmp(s,_T(""))) *offs=0; |
| 807 |
else if ((v=GetUserVarIndex(line, wt))>=0) |
| 808 |
{ |
| 809 |
*offs=-v-1; // to jump to a user variable target, -variable_index-1 is stored. |
| 810 |
} |
| 811 |
else |
| 812 |
{ |
| 813 |
if ((s[0] == _T('-') || s[0] == _T('+')) && !_ttoi(s+1)) |
| 814 |
{ |
| 815 |
ERROR_MSG(_T("Error: Goto targets beginning with '+' or '-' must be followed by nonzero integer (relative jump)\n")); |
| 816 |
return 1; |
| 817 |
} |
| 818 |
if ((s[0] >= _T('0') && s[0] <= _T('9')) || s[0] == _T('$') || s[0] == _T('!')) |
| 819 |
{ |
| 820 |
ERROR_MSG(_T("Error: Goto targets cannot begin with 0-9, $, !\n")); |
| 821 |
return 1; |
| 822 |
} |
| 823 |
*offs=ns_label.add(s,0); |
| 824 |
} |
| 825 |
return 0; |
| 826 |
} |
| 827 |
|
| 828 |
#define SECTION_FIELD_GET(field) (FIELD_OFFSET(section, field)/sizeof(int)) |
| 829 |
#define SECTION_FIELD_SET(field) (-1 - (int)(FIELD_OFFSET(section, field)/sizeof(int))) |
| 830 |
|
| 831 |
#define INVALIDREGROOT ( (HKEY) (UINT_PTR) 0x8000baad ) |
| 832 |
static HKEY ParseRegRootKey(LineParser &line, int tok) |
| 833 |
{ |
| 834 |
static const TCHAR *rootkeys[2] = { |
| 835 |
_T("HKCR\0HKLM\0HKCU\0HKU\0HKCC\0HKDD\0HKPD\0SHCTX\0HKCR32\0HKCR64\0HKCU32\0HKCU64\0HKLM32\0HKLM64\0HKCRANY\0HKCUANY\0HKLMANY\0SHCTX32\0SHCTX64\0SHCTXANY\0"), |
| 836 |
_T("HKEY_CLASSES_ROOT\0HKEY_LOCAL_MACHINE\0HKEY_CURRENT_USER\0HKEY_USERS\0HKEY_CURRENT_CONFIG\0HKEY_DYN_DATA\0HKEY_PERFORMANCE_DATA\0SHELL_CONTEXT\0") |
| 837 |
}; |
| 838 |
static const HKEY rootkey_tab[] = { |
| 839 |
HKEY_CLASSES_ROOT,HKEY_LOCAL_MACHINE,HKEY_CURRENT_USER,HKEY_USERS,HKEY_CURRENT_CONFIG,HKEY_DYN_DATA,HKEY_PERFORMANCE_DATA,HKSHCTX,HKCR32,HKCR64,HKCU32,HKCU64,HKLM32,HKLM64,HKCRANY,HKCUANY,HKLMANY,HKSHCTX32,HKSHCTX64,HKSHCTXANY |
| 840 |
}; |
| 841 |
int k = line.gettoken_enum(tok, rootkeys[0]); |
| 842 |
if (k == -1) k = line.gettoken_enum(tok, rootkeys[1]); |
| 843 |
return k == -1 ? INVALIDREGROOT : rootkey_tab[k]; |
| 844 |
} |
| 845 |
|
| 846 |
#define AFIE_LASTUSED ( -1 ) |
| 847 |
int CEXEBuild::add_flag_instruction_entry(int which_token, int opcode, LineParser &line, int offset, int data) |
| 848 |
{ |
| 849 |
entry ent = { opcode, }; |
| 850 |
switch(opcode) |
| 851 |
{ |
| 852 |
case EW_SETFLAG: |
| 853 |
ent.offsets[0] = offset; |
| 854 |
if (data != AFIE_LASTUSED) ent.offsets[1] = data; else ent.offsets[2] = 1; |
| 855 |
if (display_script) SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T("\n"), get_commandtoken_name(which_token), line.gettoken_str(1)); |
| 856 |
return add_entry(&ent); |
| 857 |
case EW_IFFLAG: |
| 858 |
if (process_jump(line, 1, &ent.offsets[0]) || process_jump(line, 2, &ent.offsets[1])) PRINTHELP() |
| 859 |
ent.offsets[2]=offset; |
| 860 |
ent.offsets[3]=data; |
| 861 |
if (display_script) SCRIPT_MSG(_T("%") NPRIs _T(" ?%") NPRIs _T(":%") NPRIs _T("\n"), get_commandtoken_name(which_token), line.gettoken_str(1), line.gettoken_str(2)); |
| 862 |
return add_entry(&ent); |
| 863 |
case EW_GETFLAG: |
| 864 |
if ((ent.offsets[0] = GetUserVarIndex(line, 1)) < 0) PRINTHELP(); |
| 865 |
ent.offsets[1] = offset; |
| 866 |
if (display_script) SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T("\n"), get_commandtoken_name(which_token), line.gettoken_str(1)); |
| 867 |
return add_entry(&ent); |
| 868 |
} |
| 869 |
return PS_ERROR; |
| 870 |
} |
| 871 |
|
| 872 |
int CEXEBuild::doCommand(int which_token, LineParser &line) |
| 873 |
{ |
| 874 |
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT |
| 875 |
if (PS_OK != initialize_default_plugins()) return PS_ERROR; |
| 876 |
#endif |
| 877 |
|
| 878 |
multiple_entries_instruction=0; |
| 879 |
entry ent={0,}; |
| 880 |
switch (which_token) |
| 881 |
{ |
| 882 |
// macro stuff |
| 883 |
/////////////////////////////////////////////////////////////////////////////// |
| 884 |
case TOK_P_MACRO: |
| 885 |
return pp_macro(line); |
| 886 |
case TOK_P_MACROEND: |
| 887 |
return (ERROR_MSG(_T("!macroend: no macro currently open.\n")), PS_ERROR); |
| 888 |
case TOK_P_MACROUNDEF: |
| 889 |
return pp_macroundef(line); |
| 890 |
case TOK_P_INSERTMACRO: |
| 891 |
return pp_insertmacro(line); |
| 892 |
|
| 893 |
// preprocessor files fun |
| 894 |
/////////////////////////////////////////////////////////////////////////////// |
| 895 |
case TOK_P_TEMPFILE: |
| 896 |
return pp_tempfile(line); |
| 897 |
case TOK_P_DELFILE: |
| 898 |
return pp_delfile(line); |
| 899 |
case TOK_P_APPENDFILE: |
| 900 |
return pp_appendfile(line); |
| 901 |
case TOK_P_APPENDMEMFILE: |
| 902 |
return pp_appendmemfile(line); |
| 903 |
case TOK_P_GETDLLVERSION: |
| 904 |
case TOK_P_GETTLBVERSION: |
| 905 |
return pp_getversion(which_token, line); |
| 906 |
|
| 907 |
// page ordering stuff |
| 908 |
/////////////////////////////////////////////////////////////////////////////// |
| 909 |
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT |
| 910 |
case TOK_UNINSTPAGE: |
| 911 |
set_uninstall_mode(1); |
| 912 |
case TOK_PAGE: |
| 913 |
{ |
| 914 |
if (!uninstall_mode) { |
| 915 |
enable_last_page_cancel = 0; |
| 916 |
if (!_tcsicmp(line.gettoken_str(line.getnumtokens()-1),_T("/ENABLECANCEL"))) |
| 917 |
enable_last_page_cancel = 1; |
| 918 |
} |
| 919 |
else { |
| 920 |
uenable_last_page_cancel = 0; |
| 921 |
if (!_tcsicmp(line.gettoken_str(line.getnumtokens()-1),_T("/ENABLECANCEL"))) |
| 922 |
uenable_last_page_cancel = 1; |
| 923 |
} |
| 924 |
|
| 925 |
int k = line.gettoken_enum(1,_T("custom\0license\0components\0directory\0instfiles\0uninstConfirm\0")); |
| 926 |
if (k < 0) PRINTHELP(); |
| 927 |
if (add_page(k) != PS_OK) |
| 928 |
return PS_ERROR; |
| 929 |
|
| 930 |
#ifndef NSIS_SUPPORT_CODECALLBACKS |
| 931 |
if (!k) { |
| 932 |
ERROR_MSG(_T("Error: custom page specified, NSIS_SUPPORT_CODECALLBACKS not defined.\n")); |
| 933 |
return PS_ERROR; |
| 934 |
} |
| 935 |
#endif //~ NSIS_SUPPORT_CODECALLBACKS |
| 936 |
if (k) { // not custom |
| 937 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 938 |
switch (line.getnumtokens() - enable_last_page_cancel) { |
| 939 |
case 6: |
| 940 |
PRINTHELP(); |
| 941 |
case 5: |
| 942 |
if (*line.gettoken_str(4)) |
| 943 |
cur_page->leavefunc = ns_func.add(line.gettoken_str(4),0); |
| 944 |
case 4: |
| 945 |
if (*line.gettoken_str(3)) |
| 946 |
cur_page->showfunc = ns_func.add(line.gettoken_str(3),0); |
| 947 |
case 3: |
| 948 |
if (*line.gettoken_str(2)) |
| 949 |
cur_page->prefunc = ns_func.add(line.gettoken_str(2),0); |
| 950 |
} |
| 951 |
#endif //~ NSIS_SUPPORT_CODECALLBACKS |
| 952 |
} |
| 953 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 954 |
else { // a custom page |
| 955 |
switch (line.getnumtokens() - enable_last_page_cancel) { |
| 956 |
case 6: |
| 957 |
PRINTHELP(); |
| 958 |
case 5: |
| 959 |
cur_page->caption = add_string(line.gettoken_str(4)); |
| 960 |
case 4: |
| 961 |
if (*line.gettoken_str(3)) |
| 962 |
cur_page->leavefunc = ns_func.add(line.gettoken_str(3),0); |
| 963 |
case 3: |
| 964 |
if (*line.gettoken_str(2)) |
| 965 |
cur_page->prefunc = ns_func.add(line.gettoken_str(2),0); |
| 966 |
break; |
| 967 |
case 2: |
| 968 |
ERROR_MSG(_T("Error: custom page must have a creator function!\n")); |
| 969 |
PRINTHELP(); |
| 970 |
} |
| 971 |
} |
| 972 |
#endif //~ NSIS_SUPPORT_CODECALLBACKS |
| 973 |
|
| 974 |
SCRIPT_MSG(_T("%") NPRIs _T("Page: %") NPRIs, uninstall_mode?_T("Uninst"):_T(""), line.gettoken_str(1)); |
| 975 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 976 |
if (cur_page->prefunc>=0) |
| 977 |
SCRIPT_MSG(_T(" (%") NPRIs _T(":%") NPRIs _T(")"), k?_T("pre"):_T("creator"), line.gettoken_str(2)); |
| 978 |
if (cur_page->showfunc>=0 && k) |
| 979 |
SCRIPT_MSG(_T(" (show:%") NPRIs _T(")"), line.gettoken_str(3)); |
| 980 |
if (cur_page->leavefunc>=0) |
| 981 |
SCRIPT_MSG(_T(" (leave:%") NPRIs _T(")"), line.gettoken_str(4-!k)); |
| 982 |
else if (cur_page->caption && !k) |
| 983 |
SCRIPT_MSG(_T(" (caption:%") NPRIs _T(")"), line.gettoken_str(3)); |
| 984 |
#endif |
| 985 |
SCRIPT_MSG(_T("\n")); |
| 986 |
|
| 987 |
page_end(); |
| 988 |
|
| 989 |
if (k == PAGE_INSTFILES) { |
| 990 |
add_page(PAGE_COMPLETED); |
| 991 |
page_end(); |
| 992 |
} |
| 993 |
set_uninstall_mode(0); |
| 994 |
} |
| 995 |
return PS_OK; |
| 996 |
case TOK_PAGEEX: // extended page setting |
| 997 |
{ |
| 998 |
int k = line.gettoken_enum(1,_T("custom\0license\0components\0directory\0instfiles\0uninstConfirm\0")); |
| 999 |
if (k < 0) { |
| 1000 |
k = line.gettoken_enum(1,_T("un.custom\0un.license\0un.components\0un.directory\0un.instfiles\0un.uninstConfirm\0")); |
| 1001 |
if (k < 0) PRINTHELP(); |
| 1002 |
set_uninstall_mode(1); |
| 1003 |
} |
| 1004 |
SCRIPT_MSG(_T("PageEx: %") NPRIs _T("\n"), line.gettoken_str(1)); |
| 1005 |
if (add_page(k) != PS_OK) |
| 1006 |
return PS_ERROR; |
| 1007 |
|
| 1008 |
cur_page->flags |= PF_PAGE_EX; |
| 1009 |
} |
| 1010 |
return PS_OK; |
| 1011 |
case TOK_PAGEEXEND: |
| 1012 |
{ |
| 1013 |
SCRIPT_MSG(_T("PageExEnd\n")); |
| 1014 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 1015 |
if (cur_page_type == PAGE_CUSTOM && !cur_page->prefunc) { |
| 1016 |
ERROR_MSG(_T("Error: custom pages must have a creator function.\n")); |
| 1017 |
return PS_ERROR; |
| 1018 |
} |
| 1019 |
#endif |
| 1020 |
page_end(); |
| 1021 |
|
| 1022 |
if (cur_page_type == PAGE_INSTFILES) { |
| 1023 |
add_page(PAGE_COMPLETED); |
| 1024 |
page_end(); |
| 1025 |
} |
| 1026 |
set_uninstall_mode(0); |
| 1027 |
} |
| 1028 |
return PS_OK; |
| 1029 |
case TOK_PAGECALLBACKS: |
| 1030 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 1031 |
{ |
| 1032 |
SCRIPT_MSG(_T("PageCallbacks:")); |
| 1033 |
if (cur_page_type == PAGE_CUSTOM) |
| 1034 |
{ |
| 1035 |
switch (line.getnumtokens()) |
| 1036 |
{ |
| 1037 |
case 4: |
| 1038 |
PRINTHELP(); |
| 1039 |
case 3: |
| 1040 |
{ |
| 1041 |
if (*line.gettoken_str(2)) |
| 1042 |
{ |
| 1043 |
if (_tcsnicmp(line.gettoken_str(2), _T("un."), 3)) |
| 1044 |
{ |
| 1045 |
if (uninstall_mode) |
| 1046 |
{ |
| 1047 |
ERROR_MSG(_T("\nError: function names must start with \"un.\" in an uninstall page.\n")); |
| 1048 |
return PS_ERROR; |
| 1049 |
} |
| 1050 |
} |
| 1051 |
else |
| 1052 |
{ |
| 1053 |
if (!uninstall_mode) |
| 1054 |
{ |
| 1055 |
ERROR_MSG(_T("\nError: function names must start with \"un.\" in an uninstall page.\n")); |
| 1056 |
return PS_ERROR; |
| 1057 |
} |
| 1058 |
} |
| 1059 |
cur_page->leavefunc = ns_func.add(line.gettoken_str(2),0); |
| 1060 |
} |
| 1061 |
} |
| 1062 |
case 2: |
| 1063 |
{ |
| 1064 |
if (*line.gettoken_str(1)) |
| 1065 |
{ |
| 1066 |
if (_tcsnicmp(line.gettoken_str(1), _T("un."), 3)) |
| 1067 |
{ |
| 1068 |
if (uninstall_mode) |
| 1069 |
{ |
| 1070 |
ERROR_MSG(_T("\nError: function names must start with \"un.\" in an uninstall page.\n")); |
| 1071 |
return PS_ERROR; |
| 1072 |
} |
| 1073 |
} |
| 1074 |
else |
| 1075 |
{ |
| 1076 |
if (!uninstall_mode) |
| 1077 |
{ |
| 1078 |
ERROR_MSG(_T("\nError: function names must start with \"un.\" in an uninstall page.\n")); |
| 1079 |
return PS_ERROR; |
| 1080 |
} |
| 1081 |
} |
| 1082 |
cur_page->prefunc = ns_func.add(line.gettoken_str(1),0); |
| 1083 |
} |
| 1084 |
} |
| 1085 |
} |
| 1086 |
} |
| 1087 |
else |
| 1088 |
{ |
| 1089 |
switch (line.getnumtokens()) |
| 1090 |
{ |
| 1091 |
case 4: |
| 1092 |
{ |
| 1093 |
if (*line.gettoken_str(3)) |
| 1094 |
{ |
| 1095 |
if (_tcsnicmp(line.gettoken_str(3), _T("un."), 3)) |
| 1096 |
{ |
| 1097 |
if (uninstall_mode) |
| 1098 |
{ |
| 1099 |
ERROR_MSG(_T("\nError: function names must start with \"un.\" in an uninstall page.\n")); |
| 1100 |
return PS_ERROR; |
| 1101 |
} |
| 1102 |
} |
| 1103 |
else |
| 1104 |
{ |
| 1105 |
if (!uninstall_mode) |
| 1106 |
{ |
| 1107 |
ERROR_MSG(_T("\nError: function names must start with \"un.\" in an uninstall page.\n")); |
| 1108 |
return PS_ERROR; |
| 1109 |
} |
| 1110 |
} |
| 1111 |
cur_page->leavefunc = ns_func.add(line.gettoken_str(3),0); |
| 1112 |
} |
| 1113 |
} |
| 1114 |
case 3: |
| 1115 |
{ |
| 1116 |
if (*line.gettoken_str(2)) |
| 1117 |
{ |
| 1118 |
if (_tcsnicmp(line.gettoken_str(2), _T("un."), 3)) |
| 1119 |
{ |
| 1120 |
if (uninstall_mode) |
| 1121 |
{ |
| 1122 |
ERROR_MSG(_T("\nError: function names must start with \"un.\" in an uninstall page.\n")); |
| 1123 |
return PS_ERROR; |
| 1124 |
} |
| 1125 |
} |
| 1126 |
else |
| 1127 |
{ |
| 1128 |
if (!uninstall_mode) |
| 1129 |
{ |
| 1130 |
ERROR_MSG(_T("\nError: function names must start with \"un.\" in an uninstall page.\n")); |
| 1131 |
return PS_ERROR; |
| 1132 |
} |
| 1133 |
} |
| 1134 |
cur_page->showfunc = ns_func.add(line.gettoken_str(2),0); |
| 1135 |
} |
| 1136 |
} |
| 1137 |
case 2: |
| 1138 |
{ |
| 1139 |
if (*line.gettoken_str(1)) |
| 1140 |
{ |
| 1141 |
if (_tcsnicmp(line.gettoken_str(1), _T("un."), 3)) |
| 1142 |
{ |
| 1143 |
if (uninstall_mode) |
| 1144 |
{ |
| 1145 |
ERROR_MSG(_T("\nError: function names must start with \"un.\" in an uninstall page.\n")); |
| 1146 |
return PS_ERROR; |
| 1147 |
} |
| 1148 |
} |
| 1149 |
else |
| 1150 |
{ |
| 1151 |
if (!uninstall_mode) |
| 1152 |
{ |
| 1153 |
ERROR_MSG(_T("\nError: function names must start with \"un.\" in an uninstall page.\n")); |
| 1154 |
return PS_ERROR; |
| 1155 |
} |
| 1156 |
} |
| 1157 |
cur_page->prefunc = ns_func.add(line.gettoken_str(1),0); |
| 1158 |
} |
| 1159 |
} |
| 1160 |
} |
| 1161 |
} |
| 1162 |
int custom = cur_page_type == PAGE_CUSTOM ? 1 : 0; |
| 1163 |
if (cur_page->prefunc>=0) |
| 1164 |
SCRIPT_MSG(_T(" %") NPRIs _T(":%") NPRIs, !custom?_T("pre"):_T("creator"), line.gettoken_str(1)); |
| 1165 |
if (cur_page->showfunc>=0 && !custom) |
| 1166 |
SCRIPT_MSG(_T(" show:%") NPRIs, line.gettoken_str(2)); |
| 1167 |
if (cur_page->leavefunc>=0) |
| 1168 |
SCRIPT_MSG(_T(" leave:%") NPRIs, line.gettoken_str(3-custom)); |
| 1169 |
SCRIPT_MSG(_T("\n")); |
| 1170 |
} |
| 1171 |
return PS_OK; |
| 1172 |
#else |
| 1173 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_CODECALLBACKS not defined.\n"), line.gettoken_str(0)); |
| 1174 |
return PS_ERROR; |
| 1175 |
#endif //~ NSIS_SUPPORT_CODECALLBACKS |
| 1176 |
#else |
| 1177 |
case TOK_PAGE: |
| 1178 |
case TOK_UNINSTPAGE: |
| 1179 |
case TOK_PAGEEX: |
| 1180 |
case TOK_PAGEEXEND: |
| 1181 |
case TOK_PAGECALLBACKS: |
| 1182 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_VISIBLE_SUPPORT not defined.\n"), line.gettoken_str(0)); |
| 1183 |
return PS_ERROR; |
| 1184 |
#endif //~ NSIS_CONFIG_VISIBLE_SUPPORT |
| 1185 |
|
| 1186 |
// header flags |
| 1187 |
/////////////////////////////////////////////////////////////////////////////// |
| 1188 |
case TOK_LANGSTRING: |
| 1189 |
{ |
| 1190 |
TCHAR *name = line.gettoken_str(1); |
| 1191 |
LANGID lang = ParseLangIdParameter(line, 2); |
| 1192 |
TCHAR *str = line.gettoken_str(3); |
| 1193 |
const int ret = SetLangString(name, lang, str); |
| 1194 |
if (ret == PS_WARNING) |
| 1195 |
warning_fl(DW_LANGSTRING_MULTISETWASTE, _T("LangString \"%") NPRIs _T("\" set multiple times for %d, wasting space"), name, lang); |
| 1196 |
else if (ret == PS_ERROR) { |
| 1197 |
ERROR_MSG(_T("Error: can't set LangString \"%") NPRIs _T("\"!\n"), name); |
| 1198 |
return PS_ERROR; |
| 1199 |
} |
| 1200 |
SCRIPT_MSG(_T("LangString: \"%") NPRIs _T("\" %d \"%") NPRIs _T("\"\n"), name, lang, str); |
| 1201 |
} |
| 1202 |
return PS_OK; |
| 1203 |
case TOK_LANGSTRINGUP: |
| 1204 |
SCRIPT_MSG(_T("Error: LangStringUP is obsolete, there are no more unprocessed strings. Use LangString.\n")); |
| 1205 |
return PS_ERROR; |
| 1206 |
case TOK_LICENSELANGSTRING: |
| 1207 |
{ |
| 1208 |
const TCHAR *cmdnam = get_commandtoken_name(which_token); |
| 1209 |
#ifdef NSIS_CONFIG_SILENT_SUPPORT |
| 1210 |
if (build_header.flags&(CH_FLAGS_SILENT|CH_FLAGS_SILENT_LOG)) |
| 1211 |
warning_fl(DW_LANGSTRING_SILENTLICENSE, _T("%") NPRIs _T(": SilentInstall enabled, wasting space"), cmdnam); |
| 1212 |
#endif |
| 1213 |
TCHAR *name = line.gettoken_str(1); |
| 1214 |
LANGID lang = ParseLangIdParameter(line, 2); |
| 1215 |
TCHAR *file = line.gettoken_str(3), *data = NULL; |
| 1216 |
MANAGE_WITH(data, free); |
| 1217 |
|
| 1218 |
LanguageTable *pLT = GetLangTable(lang); |
| 1219 |
WORD acp = pLT ? pLT->nlf.m_uCodePage : CP_ACP; |
| 1220 |
int ret = LoadLicenseFile(file, &data, cmdnam, acp); |
| 1221 |
if (ret != PS_OK) |
| 1222 |
return ret; |
| 1223 |
|
| 1224 |
ret = SetLangString(name, lang, data, true); |
| 1225 |
if (ret == PS_WARNING) |
| 1226 |
warning_fl(DW_LANGSTRING_MULTISETWASTE, _T("%") NPRIs _T(" \"%") NPRIs _T("\" set multiple times for %d, wasting space"), cmdnam, name, lang); |
| 1227 |
else if (ret == PS_ERROR) |
| 1228 |
{ |
| 1229 |
ERROR_MSG(_T("Error: can't set %") NPRIs _T(" \"%") NPRIs _T("\"!\n"), cmdnam, name); |
| 1230 |
return PS_ERROR; |
| 1231 |
} |
| 1232 |
|
| 1233 |
SCRIPT_MSG(_T("%") NPRIs _T(": \"%") NPRIs _T("\" %d \"%") NPRIs _T("\"\n"), cmdnam, name, lang, file); |
| 1234 |
return PS_OK; |
| 1235 |
} |
| 1236 |
return PS_OK; |
| 1237 |
case TOK_NAME: |
| 1238 |
{ |
| 1239 |
if (SetInnerString(NLF_NAME,line.gettoken_str(1)) == PS_WARNING) |
| 1240 |
warning_fl(DW_INNERSTRING_MULTISETWASTE, _T("%") NPRIs _T(": specified multiple times, wasting space"),line.gettoken_str(0)); |
| 1241 |
tstring da; |
| 1242 |
const TCHAR *normstr = line.gettoken_str(1), *dastr = line.gettoken_str(2); |
| 1243 |
if (!*dastr && _tcschr(normstr,_T('&'))) dastr = (da = replace_all(normstr,_T("&"),_T("&&"))).c_str(); |
| 1244 |
SetInnerString(NLF_NAME_DA,dastr); |
| 1245 |
SCRIPT_MSG(_T("Name: \"%") NPRIs _T("\""),line.gettoken_str(1)); |
| 1246 |
if (*line.gettoken_str(2)) |
| 1247 |
SCRIPT_MSG(_T(" \"%") NPRIs _T("\""),line.gettoken_str(2)); |
| 1248 |
SCRIPT_MSG(_T("\n")); |
| 1249 |
} |
| 1250 |
return PS_OK; |
| 1251 |
case TOK_CAPTION: |
| 1252 |
{ |
| 1253 |
if (!cur_page) |
| 1254 |
{ |
| 1255 |
if (SetInnerString(NLF_CAPTION,line.gettoken_str(1)) == PS_WARNING) |
| 1256 |
warning_fl(DW_INNERSTRING_MULTISETWASTE, _T("%") NPRIs _T(": specified multiple times, wasting space"),line.gettoken_str(0)); |
| 1257 |
} |
| 1258 |
else |
| 1259 |
{ |
| 1260 |
cur_page->caption = add_string(line.gettoken_str(1)); |
| 1261 |
} |
| 1262 |
SCRIPT_MSG(_T("Caption: \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 1263 |
} |
| 1264 |
return PS_OK; |
| 1265 |
case TOK_ICON: |
| 1266 |
SCRIPT_MSG(_T("Icon: \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 1267 |
try { |
| 1268 |
free_loaded_icon(installer_icon); |
| 1269 |
installer_icon = load_icon(line.gettoken_str(1)); |
| 1270 |
} |
| 1271 |
catch (exception& err) { |
| 1272 |
ERROR_MSG(_T("Error while loading icon from \"%") NPRIs _T("\": %") NPRIs _T("\n"), line.gettoken_str(1), CtoTStrParam(err.what())); |
| 1273 |
return PS_ERROR; |
| 1274 |
} |
| 1275 |
return PS_OK; |
| 1276 |
#ifdef NSIS_CONFIG_COMPONENTPAGE |
| 1277 |
case TOK_CHECKBITMAP: |
| 1278 |
SCRIPT_MSG(_T("CheckBitmap: \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 1279 |
try { |
| 1280 |
init_res_editor(); |
| 1281 |
int err = update_bitmap(res_editor, IDB_BITMAP1, line.gettoken_str(1), 96, 16, 8); |
| 1282 |
if (err) { |
| 1283 |
switch (err) { |
| 1284 |
case -1: |
| 1285 |
ERROR_MSG(_T("Error: can't find bitmap\n")); |
| 1286 |
break; |
| 1287 |
case -2: |
| 1288 |
ERROR_MSG(_T("Error: invalid bitmap file - corrupted or not a bitmap\n")); |
| 1289 |
break; |
| 1290 |
case -3: |
| 1291 |
ERROR_MSG(_T("Error: bitmap isn't 96x16 in size\n")); |
| 1292 |
break; |
| 1293 |
case -4: |
| 1294 |
ERROR_MSG(_T("Error: bitmap has more than 8bpp\n")); |
| 1295 |
break; |
| 1296 |
} |
| 1297 |
return PS_ERROR; |
| 1298 |
} |
| 1299 |
} |
| 1300 |
catch (exception& err) { |
| 1301 |
ERROR_MSG(_T("Error while replacing bitmap: %") NPRIs _T("\n"), CtoTStrParam(err.what())); |
| 1302 |
return PS_ERROR; |
| 1303 |
} |
| 1304 |
return PS_OK; |
| 1305 |
#else |
| 1306 |
case TOK_CHECKBITMAP: |
| 1307 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_COMPONENTPAGE not defined.\n"), line.gettoken_str(0)); |
| 1308 |
return PS_ERROR; |
| 1309 |
#endif //~ NSIS_CONFIG_COMPONENTPAGE |
| 1310 |
case TOK_DIRTEXT: |
| 1311 |
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT |
| 1312 |
{ |
| 1313 |
if (!cur_page) { |
| 1314 |
if (SetInnerString(NLF_DIR_TEXT, line.gettoken_str(1)) == PS_WARNING) |
| 1315 |
warning_fl(DW_INNERSTRING_MULTISETWASTE, _T("%") NPRIs _T(": specified multiple times, wasting space"),line.gettoken_str(0)); |
| 1316 |
if (line.getnumtokens() > 2) |
| 1317 |
SetInnerString(NLF_DIR_SUBTEXT, line.gettoken_str(2)); |
| 1318 |
if (line.getnumtokens() > 3) |
| 1319 |
SetInnerString(NLF_BTN_BROWSE, line.gettoken_str(3)); |
| 1320 |
if (line.getnumtokens() > 4) |
| 1321 |
SetInnerString(NLF_DIR_BROWSETEXT, line.gettoken_str(4)); |
| 1322 |
} |
| 1323 |
else { |
| 1324 |
if (cur_page_type != PAGE_DIRECTORY) { |
| 1325 |
ERROR_MSG(_T("Error: DirText can only be used inside PageEx directory.\n")); |
| 1326 |
return PS_ERROR; |
| 1327 |
} |
| 1328 |
cur_page->parms[0] = add_string(line.gettoken_str(1)); |
| 1329 |
if (line.getnumtokens() > 2) |
| 1330 |
cur_page->parms[1] = add_string(line.gettoken_str(2)); |
| 1331 |
if (line.getnumtokens() > 3) |
| 1332 |
cur_page->parms[2] = add_string(line.gettoken_str(3)); |
| 1333 |
if (line.getnumtokens() > 4) |
| 1334 |
cur_page->parms[3] = add_string(line.gettoken_str(4)); |
| 1335 |
} |
| 1336 |
SCRIPT_MSG(_T("DirText: \"%") NPRIs _T("\" \"%") NPRIs _T("\" \"%") NPRIs _T("\" \"%") NPRIs _T("\"\n"),line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(4)); |
| 1337 |
} |
| 1338 |
return PS_OK; |
| 1339 |
#else |
| 1340 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_VISIBLE_SUPPORT not defined.\n"), line.gettoken_str(0)); |
| 1341 |
return PS_ERROR; |
| 1342 |
#endif //~ NSIS_CONFIG_VISIBLE_SUPPORT |
| 1343 |
case TOK_DIRVAR: |
| 1344 |
{ |
| 1345 |
if (cur_page_type != PAGE_DIRECTORY && cur_page_type != PAGE_UNINSTCONFIRM) { |
| 1346 |
ERROR_MSG(_T("Error: can't use DirVar outside of PageEx directory|uninstConfirm.\n")); |
| 1347 |
return PS_ERROR; |
| 1348 |
} |
| 1349 |
cur_page->parms[4] = GetUserVarIndex(line, 1) + 1; |
| 1350 |
if (cur_page->parms[4] <= 0) PRINTHELP(); |
| 1351 |
SCRIPT_MSG(_T("DirVar: %") NPRIs _T("\n"), line.gettoken_str(1)); |
| 1352 |
} |
| 1353 |
return PS_OK; |
| 1354 |
case TOK_DIRVERIFY: |
| 1355 |
{ |
| 1356 |
if (cur_page_type != PAGE_DIRECTORY) { |
| 1357 |
ERROR_MSG(_T("Error: can't use DirVerify outside of PageEx directory.\n")); |
| 1358 |
return PS_ERROR; |
| 1359 |
} |
| 1360 |
cur_page->flags &= ~PF_DIR_NO_BTN_DISABLE; |
| 1361 |
int k = line.gettoken_enum(1,_T("auto\0leave\0")); |
| 1362 |
if (k == -1) |
| 1363 |
PRINTHELP(); |
| 1364 |
if (k) |
| 1365 |
cur_page->flags |= PF_DIR_NO_BTN_DISABLE; |
| 1366 |
SCRIPT_MSG(_T("DirVerify: %") NPRIs _T("\n"), line.gettoken_str(1)); |
| 1367 |
} |
| 1368 |
return PS_OK; |
| 1369 |
case TOK_GETINSTDIRERROR: |
| 1370 |
return add_flag_instruction_entry(which_token, EW_GETFLAG, line, FLAG_OFFSET(instdir_error)); |
| 1371 |
#ifdef NSIS_CONFIG_COMPONENTPAGE |
| 1372 |
case TOK_COMPTEXT: |
| 1373 |
{ |
| 1374 |
if (!cur_page) { |
| 1375 |
if (SetInnerString(NLF_COMP_TEXT, line.gettoken_str(1)) == PS_WARNING) |
| 1376 |
warning_fl(DW_INNERSTRING_MULTISETWASTE, _T("%") NPRIs _T(": specified multiple times, wasting space"),line.gettoken_str(0)); |
| 1377 |
if (line.getnumtokens() > 2) |
| 1378 |
SetInnerString(NLF_COMP_SUBTEXT1, line.gettoken_str(2)); |
| 1379 |
if (line.getnumtokens() > 3) |
| 1380 |
SetInnerString(NLF_COMP_SUBTEXT2, line.gettoken_str(3)); |
| 1381 |
} |
| 1382 |
else { |
| 1383 |
if (cur_page_type != PAGE_COMPONENTS) { |
| 1384 |
ERROR_MSG(_T("Error: ComponentText can only be used inside PageEx components.\n")); |
| 1385 |
return PS_ERROR; |
| 1386 |
} |
| 1387 |
cur_page->parms[0] = add_string(line.gettoken_str(1)); |
| 1388 |
cur_page->parms[1] = add_string(line.gettoken_str(2)); |
| 1389 |
cur_page->parms[2] = add_string(line.gettoken_str(3)); |
| 1390 |
cur_page->parms[3] = cur_page->parms[1]; |
| 1391 |
cur_page->parms[4] = cur_page->parms[2]; |
| 1392 |
} |
| 1393 |
SCRIPT_MSG(_T("ComponentText: \"%") NPRIs _T("\" \"%") NPRIs _T("\" \"%") NPRIs _T("\"\n"),line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3)); |
| 1394 |
} |
| 1395 |
return PS_OK; |
| 1396 |
case TOK_INSTTYPE: |
| 1397 |
{ |
| 1398 |
int x; |
| 1399 |
if (!_tcsicmp(line.gettoken_str(1),_T("/NOCUSTOM"))) |
| 1400 |
{ |
| 1401 |
build_header.flags|=CH_FLAGS_NO_CUSTOM; |
| 1402 |
SCRIPT_MSG(_T("InstType: disabling custom %") NPRIs _T("install type\n"), _T("")); |
| 1403 |
} |
| 1404 |
else if (!_tcsicmp(line.gettoken_str(1),_T("/UNINSTNOCUSTOM"))) |
| 1405 |
{ |
| 1406 |
build_uninst.flags|=CH_FLAGS_NO_CUSTOM; |
| 1407 |
SCRIPT_MSG(_T("InstType: disabling custom %") NPRIs _T("install type\n"), _T("un")); |
| 1408 |
} |
| 1409 |
else if (!_tcsicmp(line.gettoken_str(1),_T("/COMPONENTSONLYONCUSTOM"))) |
| 1410 |
{ |
| 1411 |
build_header.flags|=CH_FLAGS_COMP_ONLY_ON_CUSTOM; |
| 1412 |
SCRIPT_MSG(_T("InstType: making components viewable only on custom %") NPRIs _T("install type\n"), _T("")); |
| 1413 |
} |
| 1414 |
else if (!_tcsicmp(line.gettoken_str(1),_T("/UNINSTCOMPONENTSONLYONCUSTOM"))) |
| 1415 |
{ |
| 1416 |
build_uninst.flags|=CH_FLAGS_COMP_ONLY_ON_CUSTOM; |
| 1417 |
SCRIPT_MSG(_T("InstType: making components viewable only on custom %") NPRIs _T("install type\n"), _T("un")); |
| 1418 |
} |
| 1419 |
else if (!_tcsnicmp(line.gettoken_str(1),_T("/CUSTOMSTRING="),14)) |
| 1420 |
{ |
| 1421 |
SCRIPT_MSG(_T("InstType: setting custom text to: \"%") NPRIs _T("\"\n"),line.gettoken_str(1)+14); |
| 1422 |
if (SetInnerString(NLF_COMP_CUSTOM,line.gettoken_str(1)+14) == PS_WARNING) |
| 1423 |
warning_fl(DW_INNERSTRING_MULTISETWASTE, _T("%") NPRIs _T(": specified multiple times, wasting space"),_T("InstType /CUSTOMSTRING")); |
| 1424 |
} |
| 1425 |
else if (line.gettoken_str(1)[0]==_T('/')) |
| 1426 |
{ |
| 1427 |
PRINTHELP() |
| 1428 |
} |
| 1429 |
else |
| 1430 |
{ |
| 1431 |
const TCHAR *itname = line.gettoken_str(1), *defname = line.gettoken_str(2), setdef = *defname, *eqstr = setdef ? _T("=") : _T(""); |
| 1432 |
if (!_tcsnicmp(itname, _T("un."), 3)) set_uninstall_mode(1), itname += 3; |
| 1433 |
|
| 1434 |
for (x = 0; x < NSIS_MAX_INST_TYPES && cur_header->install_types[x]; x++); |
| 1435 |
if (x == NSIS_MAX_INST_TYPES) |
| 1436 |
{ |
| 1437 |
ERROR_MSG(_T("InstType: no more than %d install types allowed. %d specified\n"), NSIS_MAX_INST_TYPES, NSIS_MAX_INST_TYPES + 1); |
| 1438 |
return PS_ERROR; |
| 1439 |
} |
| 1440 |
else |
| 1441 |
{ |
| 1442 |
cur_header->install_types[x] = add_string(itname); |
| 1443 |
if (setdef) definedlist.set_si32(defname, x); |
| 1444 |
SCRIPT_MSG(_T("InstType: %") NPRIs _T("\"%") NPRIs _T("\" (%") NPRIs _T("%") NPRIs _T("%d)\n"), uninstall_mode ? _T("(uninstall) ") : _T(""), itname, defname, eqstr, x); |
| 1445 |
} |
| 1446 |
|
| 1447 |
set_uninstall_mode(0); |
| 1448 |
} |
| 1449 |
} |
| 1450 |
return PS_OK; |
| 1451 |
#else |
| 1452 |
case TOK_COMPTEXT: |
| 1453 |
case TOK_INSTTYPE: |
| 1454 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified but NSIS_CONFIG_COMPONENTPAGE not defined\n"),line.gettoken_str(0)); |
| 1455 |
return PS_ERROR; |
| 1456 |
#endif //~ NSIS_CONFIG_COMPONENTPAGE |
| 1457 |
#ifdef NSIS_CONFIG_LICENSEPAGE |
| 1458 |
case TOK_LICENSETEXT: |
| 1459 |
{ |
| 1460 |
if (!cur_page) { |
| 1461 |
if (SetInnerString(NLF_LICENSE_TEXT, line.gettoken_str(1)) == PS_WARNING) |
| 1462 |
warning_fl(DW_INNERSTRING_MULTISETWASTE, _T("%") NPRIs _T(": specified multiple times, wasting space"),line.gettoken_str(0)); |
| 1463 |
SetInnerString(NLF_LICENSE_TEXT_FSRB, line.gettoken_str(1)); |
| 1464 |
SetInnerString(NLF_LICENSE_TEXT_FSCB, line.gettoken_str(1)); |
| 1465 |
if (line.getnumtokens() > 2) |
| 1466 |
SetInnerString(NLF_BTN_LICENSE, line.gettoken_str(2)); |
| 1467 |
} |
| 1468 |
else { |
| 1469 |
if (cur_page_type != PAGE_LICENSE) { |
| 1470 |
ERROR_MSG(_T("Error: LicenseText can only be used inside PageEx license.\n")); |
| 1471 |
return PS_ERROR; |
| 1472 |
} |
| 1473 |
cur_page->parms[0] = add_string(line.gettoken_str(1)); |
| 1474 |
cur_page->next = add_string(line.gettoken_str(2)); |
| 1475 |
} |
| 1476 |
SCRIPT_MSG(_T("LicenseText: \"%") NPRIs _T("\" \"%") NPRIs _T("\"\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 1477 |
} |
| 1478 |
return PS_OK; |
| 1479 |
case TOK_LICENSEDATA: |
| 1480 |
{ |
| 1481 |
const TCHAR *cmdnam = get_commandtoken_name(which_token); |
| 1482 |
int idx = 0; |
| 1483 |
TCHAR *file = line.gettoken_str(1), *data = NULL, *filedata = NULL; |
| 1484 |
MANAGE_WITH(filedata, free); |
| 1485 |
WORD wincp = CP_ACP; |
| 1486 |
|
| 1487 |
if (file[0] == _T('$') && file[1] == _T('(')) |
| 1488 |
{ |
| 1489 |
TCHAR *cp = _tcsdup(file+2); |
| 1490 |
MANAGE_WITH(cp, free); |
| 1491 |
TCHAR *p = _tcschr(cp, _T(')')); |
| 1492 |
if (p && p[1] == 0) { // if string is only a language str identifier |
| 1493 |
*p = 0; |
| 1494 |
idx = DefineLangString(cp, 0); |
| 1495 |
} |
| 1496 |
data = file; |
| 1497 |
} |
| 1498 |
|
| 1499 |
if (!idx) |
| 1500 |
{ |
| 1501 |
int ret = LoadLicenseFile(file, &filedata, cmdnam, wincp); |
| 1502 |
if (ret != PS_OK) |
| 1503 |
return ret; |
| 1504 |
data = filedata; |
| 1505 |
} |
| 1506 |
|
| 1507 |
if (!cur_page) { |
| 1508 |
if (SetInnerString(NLF_LICENSE_DATA,data) == PS_WARNING) |
| 1509 |
warning_fl(DW_INNERSTRING_MULTISETWASTE, _T("%") NPRIs _T(": specified multiple times, wasting space"),cmdnam); |
| 1510 |
} |
| 1511 |
else { |
| 1512 |
if (cur_page_type != PAGE_LICENSE) { |
| 1513 |
ERROR_MSG(_T("Error: LicenseData can only be used inside PageEx license.\n")); |
| 1514 |
return PS_ERROR; |
| 1515 |
} |
| 1516 |
cur_page->parms[1] = add_string(data, false, wincp); |
| 1517 |
} |
| 1518 |
|
| 1519 |
SCRIPT_MSG(_T("LicenseData: \"%") NPRIs _T("\"\n"),file); |
| 1520 |
} |
| 1521 |
return PS_OK; |
| 1522 |
case TOK_LICENSEFORCESELECTION: |
| 1523 |
{ |
| 1524 |
int k=line.gettoken_enum(1,_T("off\0checkbox\0radiobuttons\0")); |
| 1525 |
if (k == -1) PRINTHELP() |
| 1526 |
if (k < line.getnumtokens() - 2) PRINTHELP() |
| 1527 |
|
| 1528 |
if (!cur_page) { |
| 1529 |
switch (line.getnumtokens()) { |
| 1530 |
case 4: |
| 1531 |
SetInnerString(NLF_BTN_LICENSE_DISAGREE, line.gettoken_str(3)); |
| 1532 |
case 3: |
| 1533 |
SetInnerString(NLF_BTN_LICENSE_AGREE, line.gettoken_str(2)); |
| 1534 |
break; |
| 1535 |
} |
| 1536 |
switch (k) { |
| 1537 |
case 0: license_res_id = IDD_LICENSE; break; |
| 1538 |
case 1: license_res_id = IDD_LICENSE_FSCB; break; |
| 1539 |
case 2: license_res_id = IDD_LICENSE_FSRB; break; |
| 1540 |
} |
| 1541 |
} |
| 1542 |
else { |
| 1543 |
if (cur_page_type != PAGE_LICENSE) { |
| 1544 |
ERROR_MSG(_T("Error: LicenseForceSelection can only be used inside PageEx license.\n")); |
| 1545 |
return PS_ERROR; |
| 1546 |
} |
| 1547 |
switch (line.getnumtokens()) { |
| 1548 |
case 4: |
| 1549 |
cur_page->parms[3] = add_string(line.gettoken_str(3)); |
| 1550 |
case 3: |
| 1551 |
cur_page->parms[2] = add_string(line.gettoken_str(2)); |
| 1552 |
break; |
| 1553 |
} |
| 1554 |
|
| 1555 |
cur_page->flags &= ~(PF_LICENSE_FORCE_SELECTION | PF_LICENSE_NO_FORCE_SELECTION); |
| 1556 |
switch (k) { |
| 1557 |
case 0: |
| 1558 |
cur_page->dlg_id = IDD_LICENSE; |
| 1559 |
cur_page->flags |= PF_LICENSE_NO_FORCE_SELECTION; |
| 1560 |
break; |
| 1561 |
case 1: |
| 1562 |
cur_page->dlg_id = IDD_LICENSE_FSCB; |
| 1563 |
cur_page->flags |= PF_LICENSE_FORCE_SELECTION; |
| 1564 |
break; |
| 1565 |
case 2: |
| 1566 |
cur_page->dlg_id = IDD_LICENSE_FSRB; |
| 1567 |
cur_page->flags |= PF_LICENSE_FORCE_SELECTION; |
| 1568 |
break; |
| 1569 |
} |
| 1570 |
} |
| 1571 |
SCRIPT_MSG(_T("LicenseForceSelection: %") NPRIs _T(" \"%") NPRIs _T("\" \"%") NPRIs _T("\"\n"), line.gettoken_str(1), line.gettoken_str(2), line.gettoken_str(3)); |
| 1572 |
} |
| 1573 |
return PS_OK; |
| 1574 |
case TOK_LICENSEBKCOLOR: |
| 1575 |
{ |
| 1576 |
const TCHAR *cmdname = _T("LicenseBkColor"), *paramname; |
| 1577 |
TCHAR *p = line.gettoken_str(1), *p2; |
| 1578 |
if (!_tcsicmp(p,paramname = _T("/windows")) || !_tcsicmp(p,_T("/window"))) |
| 1579 |
{ |
| 1580 |
build_header.license_bg=-COLOR_WINDOW; |
| 1581 |
SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T("\n"),cmdname,paramname); |
| 1582 |
} |
| 1583 |
else if (!_tcsicmp(p,paramname = _T("/grey")) || !_tcsicmp(p,_T("/gray"))) |
| 1584 |
{ |
| 1585 |
build_header.license_bg=-COLOR_BTNFACE; /* Note: This might not actually be gray */ |
| 1586 |
SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T("\n"),cmdname,paramname); |
| 1587 |
} |
| 1588 |
else |
| 1589 |
{ |
| 1590 |
const int v=_tcstoul(p,&p2,16); |
| 1591 |
if (p2 == p) return PS_ERROR; |
| 1592 |
build_header.license_bg=((v&0xff)<<16)|(v&0xff00)|((v&0xff0000)>>16); |
| 1593 |
SCRIPT_MSG(_T("%") NPRIs _T(": %06X\n"),cmdname,v); |
| 1594 |
} |
| 1595 |
build_uninst.license_bg=build_header.license_bg; |
| 1596 |
} |
| 1597 |
return PS_OK; |
| 1598 |
#else |
| 1599 |
case TOK_LICENSETEXT: |
| 1600 |
case TOK_LICENSEDATA: |
| 1601 |
case TOK_LICENSEBKCOLOR: |
| 1602 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_LICENSEPAGE not defined.\n"), line.gettoken_str(0)); |
| 1603 |
return PS_ERROR; |
| 1604 |
#endif //~ NSIS_CONFIG_LICENSEPAGE |
| 1605 |
#ifdef NSIS_CONFIG_SILENT_SUPPORT |
| 1606 |
case TOK_SILENTINST: |
| 1607 |
{ |
| 1608 |
int k=line.gettoken_enum(1,_T("normal\0silent\0silentlog\0")); |
| 1609 |
if (k<0) PRINTHELP() |
| 1610 |
#ifndef NSIS_CONFIG_LOG |
| 1611 |
if (k == 2) |
| 1612 |
{ |
| 1613 |
ERROR_MSG(_T("SilentInstall: silentlog specified, no log support compiled in (use NSIS_CONFIG_LOG)\n")); |
| 1614 |
return PS_ERROR; |
| 1615 |
} |
| 1616 |
#endif //~ NSIS_CONFIG_LOG |
| 1617 |
SCRIPT_MSG(_T("SilentInstall: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 1618 |
#ifdef NSIS_CONFIG_LICENSEPAGE |
| 1619 |
if (k && HasUserDefined(NLF_LICENSE_DATA)) |
| 1620 |
{ |
| 1621 |
warning_fl(DW_LANGSTRING_SILENTLICENSE, _T("SilentInstall: LicenseData already specified. wasting space")); |
| 1622 |
} |
| 1623 |
if (k) { |
| 1624 |
build_header.flags|=CH_FLAGS_SILENT; |
| 1625 |
if (k == 2) |
| 1626 |
build_header.flags|=CH_FLAGS_SILENT_LOG; |
| 1627 |
} |
| 1628 |
else { |
| 1629 |
build_header.flags&=~CH_FLAGS_SILENT; |
| 1630 |
build_header.flags&=~CH_FLAGS_SILENT_LOG; |
| 1631 |
} |
| 1632 |
#endif //~ NSIS_CONFIG_LICENSEPAGE |
| 1633 |
} |
| 1634 |
return PS_OK; |
| 1635 |
case TOK_SILENTUNINST: |
| 1636 |
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT |
| 1637 |
{ |
| 1638 |
int k=line.gettoken_enum(1,_T("normal\0silent\0")); |
| 1639 |
if (k<0) PRINTHELP() |
| 1640 |
if (k) |
| 1641 |
build_uninst.flags|=CH_FLAGS_SILENT; |
| 1642 |
else |
| 1643 |
build_uninst.flags&=~CH_FLAGS_SILENT; |
| 1644 |
SCRIPT_MSG(_T("SilentUnInstall: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 1645 |
} |
| 1646 |
return PS_OK; |
| 1647 |
#else |
| 1648 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_UNINSTALL_SUPPORT not defined.\n"), line.gettoken_str(0)); |
| 1649 |
return PS_ERROR; |
| 1650 |
#endif |
| 1651 |
case TOK_IFSILENT: |
| 1652 |
return add_flag_instruction_entry(which_token, EW_IFFLAG, line, FLAG_OFFSET(silent), ~0); //new value mask - keep flag |
| 1653 |
case TOK_SETSILENT: |
| 1654 |
ent.offsets[1] = line.gettoken_enum(1,_T("normal\0silent\0")); |
| 1655 |
if (ent.offsets[1] < 0 ) PRINTHELP() |
| 1656 |
return add_flag_instruction_entry(which_token, EW_SETFLAG, line, FLAG_OFFSET(silent), add_intstring(ent.offsets[1])); |
| 1657 |
#else |
| 1658 |
case TOK_SILENTINST: |
| 1659 |
case TOK_SILENTUNINST: |
| 1660 |
case TOK_IFSILENT: |
| 1661 |
case TOK_SETSILENT: |
| 1662 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_SILENT_SUPPORT not defined.\n"), line.gettoken_str(0)); |
| 1663 |
return PS_ERROR; |
| 1664 |
#endif //~ NSIS_CONFIG_SILENT_SUPPORT |
| 1665 |
case TOK_IFRTLLANG: |
| 1666 |
return add_flag_instruction_entry(which_token, EW_IFFLAG, line, FLAG_OFFSET(rtl), ~0); //new value mask - keep flag |
| 1667 |
case TOK_OUTFILE: |
| 1668 |
my_strncpy(build_output_filename,line.gettoken_str(1),COUNTOF(build_output_filename)); |
| 1669 |
SCRIPT_MSG(_T("OutFile: \"%") NPRIs _T("\"\n"),build_output_filename); |
| 1670 |
return PS_OK; |
| 1671 |
case TOK_INSTDIR: |
| 1672 |
{ |
| 1673 |
TCHAR *p = line.gettoken_str(1); |
| 1674 |
if (build_header.install_directory_ptr) |
| 1675 |
{ |
| 1676 |
warning_fl(DW_STRING_MULTISETWASTE, _T("%") NPRIs _T(": specified multiple times. wasting space"),line.gettoken_str(0)); |
| 1677 |
} |
| 1678 |
build_header.install_directory_ptr = add_string(p); |
| 1679 |
build_header.install_directory_auto_append = 0; |
| 1680 |
TCHAR *p2 = p + _tcslen(p); |
| 1681 |
if (*p && *CharPrev(p, p2) != _T('\\')) |
| 1682 |
{ |
| 1683 |
// we risk hitting $\r or something like $(bla\ad) or ${bla\ad} here, but it's better |
| 1684 |
// than hitting backslashes in processed strings |
| 1685 |
while (p2 > p && *p2 != _T('\\')) |
| 1686 |
p2 = CharPrev(p, p2); |
| 1687 |
if (*p2 == _T('\\')) |
| 1688 |
{ |
| 1689 |
build_header.install_directory_auto_append = add_string(p2 + 1); |
| 1690 |
} |
| 1691 |
} |
| 1692 |
SCRIPT_MSG(_T("InstallDir: \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 1693 |
} |
| 1694 |
return PS_OK; |
| 1695 |
case TOK_INSTALLDIRREGKEY: // InstallDirRegKey |
| 1696 |
{ |
| 1697 |
if (build_header.install_reg_key_ptr) |
| 1698 |
warning_fl(DW_STRING_MULTISETWASTE, _T("%") NPRIs _T(": specified multiple times, wasting space"),line.gettoken_str(0)); |
| 1699 |
|
| 1700 |
HKEY hRK = ParseRegRootKey(line,1); |
| 1701 |
if (INVALIDREGROOT == hRK) PRINTHELP() |
| 1702 |
if (HKSHCTX == hRK) PRINTHELP() // SHCTX is invalid here |
| 1703 |
if (IsRegRootkeyForcedView(hRK)) PRINTHELP() // 32|64 views are also invalid |
| 1704 |
build_header.install_reg_rootkey=REGROOTKEYTOINT(hRK); |
| 1705 |
build_header.install_reg_key_ptr = add_string(line.gettoken_str(2),0); |
| 1706 |
if (line.gettoken_str(2)[0] == _T('\\')) |
| 1707 |
warning_fl(DW_PARSE_REGPATHPREFIX, _T("%") NPRIs _T(": registry path name begins with \'\\\', may cause problems"),line.gettoken_str(0)); |
| 1708 |
build_header.install_reg_value_ptr = add_string(line.gettoken_str(3),0); |
| 1709 |
SCRIPT_MSG(_T("InstallRegKey: \"%") NPRIs _T("\\%") NPRIs _T("\\%") NPRIs _T("\"\n"),line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3)); |
| 1710 |
} |
| 1711 |
return PS_OK; |
| 1712 |
case TOK_CRCCHECK: |
| 1713 |
build_crcchk=line.gettoken_enum(1,_T("off\0on\0force\0")); |
| 1714 |
if (build_crcchk==-1) PRINTHELP() |
| 1715 |
SCRIPT_MSG(_T("CRCCheck: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 1716 |
return PS_OK; |
| 1717 |
case TOK_INSTPROGRESSFLAGS: |
| 1718 |
{ |
| 1719 |
int smooth=0; |
| 1720 |
build_header.flags&=~CH_FLAGS_PROGRESS_COLORED; |
| 1721 |
for (int x = 1; x < line.getnumtokens(); x++) |
| 1722 |
{ |
| 1723 |
if (!_tcsicmp(line.gettoken_str(x),_T("smooth"))) smooth=1; |
| 1724 |
else if (!_tcsicmp(line.gettoken_str(x),_T("colored"))) build_header.flags|=CH_FLAGS_PROGRESS_COLORED; |
| 1725 |
else PRINTHELP() |
| 1726 |
} |
| 1727 |
try { |
| 1728 |
init_res_editor(); |
| 1729 |
|
| 1730 |
BYTE* dlg = res_editor->GetResource(RT_DIALOG, IDD_INSTFILES, NSIS_DEFAULT_LANG); |
| 1731 |
if (!dlg) throw runtime_error("IDD_INSTFILES doesn't exist!"); |
| 1732 |
CDialogTemplate dt(dlg,build_unicode,uDefCodePage); |
| 1733 |
res_editor->FreeResource(dlg); |
| 1734 |
DialogItemTemplate* progress = dt.GetItem(IDC_PROGRESS); |
| 1735 |
if (!progress) throw runtime_error("IDC_PROGRESS doesn't exist!"); |
| 1736 |
|
| 1737 |
if (smooth) progress->dwStyle |= PBS_SMOOTH; else progress->dwStyle &= ~PBS_SMOOTH; |
| 1738 |
|
| 1739 |
DWORD dwSize; |
| 1740 |
dlg = dt.Save(dwSize); |
| 1741 |
res_editor->UpdateResource(RT_DIALOG, IDD_INSTFILES, NSIS_DEFAULT_LANG, dlg, dwSize); |
| 1742 |
dt.FreeSavedTemplate(dlg); |
| 1743 |
} |
| 1744 |
catch (exception& err) { |
| 1745 |
ERROR_MSG(_T("Error setting smooth progress bar: %") NPRIs _T("\n"), CtoTStrParam(err.what())); |
| 1746 |
return PS_ERROR; |
| 1747 |
} |
| 1748 |
SCRIPT_MSG(_T("InstProgressFlags: smooth=%d, colored=%d\n"),smooth, |
| 1749 |
!!(build_header.flags&CH_FLAGS_PROGRESS_COLORED)); |
| 1750 |
} |
| 1751 |
return PS_OK; |
| 1752 |
case TOK_AUTOCLOSE: |
| 1753 |
{ |
| 1754 |
int k=line.gettoken_enum(1,_T("false\0true\0")); |
| 1755 |
if (k == -1) PRINTHELP(); |
| 1756 |
if (k) |
| 1757 |
build_header.flags|=CH_FLAGS_AUTO_CLOSE; |
| 1758 |
else |
| 1759 |
build_header.flags&=~CH_FLAGS_AUTO_CLOSE; |
| 1760 |
SCRIPT_MSG(_T("AutoCloseWindow: %") NPRIs _T("\n"),k?_T("true"):_T("false")); |
| 1761 |
} |
| 1762 |
return PS_OK; |
| 1763 |
case TOK_WINDOWICON: |
| 1764 |
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT |
| 1765 |
disable_window_icon=line.gettoken_enum(1,_T("on\0off\0")); |
| 1766 |
if (disable_window_icon == -1) PRINTHELP(); |
| 1767 |
SCRIPT_MSG(_T("WindowIcon: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 1768 |
return PS_OK; |
| 1769 |
#else |
| 1770 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_VISIBLE_SUPPORT not defined.\n"),line.gettoken_str(0)); |
| 1771 |
return PS_ERROR; |
| 1772 |
#endif //~ NSIS_CONFIG_VISIBLE_SUPPORT |
| 1773 |
case TOK_SHOWDETAILSUNINST: |
| 1774 |
#ifndef NSIS_CONFIG_UNINSTALL_SUPPORT |
| 1775 |
ERROR_MSG(_T("Error: ShowUninstDetails specified but NSIS_CONFIG_UNINSTALL_SUPPORT not defined\n")); |
| 1776 |
return PS_ERROR; |
| 1777 |
#endif |
| 1778 |
case TOK_SHOWDETAILS: |
| 1779 |
{ |
| 1780 |
int k=line.gettoken_enum(1,_T("hide\0show\0nevershow\0")); |
| 1781 |
if (k == -1) PRINTHELP() |
| 1782 |
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT |
| 1783 |
if (which_token == TOK_SHOWDETAILSUNINST) |
| 1784 |
{ |
| 1785 |
build_uninst.flags&=~(CH_FLAGS_DETAILS_NEVERSHOW|CH_FLAGS_DETAILS_SHOWDETAILS); |
| 1786 |
if (k==1) |
| 1787 |
build_uninst.flags|=CH_FLAGS_DETAILS_SHOWDETAILS; |
| 1788 |
else if (k==2) |
| 1789 |
build_uninst.flags|=CH_FLAGS_DETAILS_NEVERSHOW; |
| 1790 |
} |
| 1791 |
else |
| 1792 |
#endif |
| 1793 |
{ |
| 1794 |
build_header.flags&=~(CH_FLAGS_DETAILS_NEVERSHOW|CH_FLAGS_DETAILS_SHOWDETAILS); |
| 1795 |
if (k==1) |
| 1796 |
build_header.flags|=CH_FLAGS_DETAILS_SHOWDETAILS; |
| 1797 |
else if (k==2) |
| 1798 |
build_header.flags|=CH_FLAGS_DETAILS_NEVERSHOW; |
| 1799 |
} |
| 1800 |
SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T("\n"),line.gettoken_str(0),line.gettoken_str(1)); |
| 1801 |
} |
| 1802 |
return PS_OK; |
| 1803 |
case TOK_DIRSHOW: |
| 1804 |
/*{ |
| 1805 |
int k=line.gettoken_enum(1,_T("show\0hide\0")); |
| 1806 |
if (k < 0) PRINTHELP(); |
| 1807 |
if (k) |
| 1808 |
build_header.flags|=CH_FLAGS_DIR_NO_SHOW; |
| 1809 |
else |
| 1810 |
build_header.flags&=~CH_FLAGS_DIR_NO_SHOW; |
| 1811 |
SCRIPT_MSG(_T("DirShow: %") NPRIs _T("\n"),k?_T("hide"):_T("show")); |
| 1812 |
}*/ |
| 1813 |
ERROR_MSG(_T("Error: DirShow doesn't currently work\n")); |
| 1814 |
return PS_ERROR; |
| 1815 |
case TOK_ROOTDIRINST: |
| 1816 |
{ |
| 1817 |
int k=line.gettoken_enum(1,_T("true\0false\0")); |
| 1818 |
if (k == -1) PRINTHELP(); |
| 1819 |
if (k) |
| 1820 |
build_header.flags|=CH_FLAGS_NO_ROOT_DIR; |
| 1821 |
else |
| 1822 |
build_header.flags&=~CH_FLAGS_NO_ROOT_DIR; |
| 1823 |
SCRIPT_MSG(_T("AllowRootDirInstall: %") NPRIs _T("\n"),k?_T("false"):_T("true")); |
| 1824 |
} |
| 1825 |
return PS_OK; |
| 1826 |
case TOK_BGFONT: |
| 1827 |
#ifndef NSIS_SUPPORT_BGBG |
| 1828 |
ERROR_MSG(_T("Error: BGFont specified but NSIS_SUPPORT_BGBG not defined\n")); |
| 1829 |
return PS_ERROR; |
| 1830 |
#else // NSIS_SUPPORT_BGBG |
| 1831 |
if (line.getnumtokens()==1) |
| 1832 |
{ |
| 1833 |
memcpy(&bg_font,&bg_default_font,sizeof(LOGFONT)); |
| 1834 |
SCRIPT_MSG(_T("BGFont: default font\n")); |
| 1835 |
return PS_OK; |
| 1836 |
} |
| 1837 |
LOGFONT newfont; |
| 1838 |
newfont.lfHeight=40; |
| 1839 |
newfont.lfWidth=0; |
| 1840 |
newfont.lfEscapement=0, newfont.lfOrientation=0; |
| 1841 |
newfont.lfWeight=FW_NORMAL; |
| 1842 |
newfont.lfItalic=newfont.lfUnderline=newfont.lfStrikeOut=FALSE; |
| 1843 |
newfont.lfCharSet=DEFAULT_CHARSET; |
| 1844 |
newfont.lfOutPrecision=OUT_DEFAULT_PRECIS; |
| 1845 |
newfont.lfClipPrecision=CLIP_DEFAULT_PRECIS; |
| 1846 |
newfont.lfQuality=DEFAULT_QUALITY; |
| 1847 |
newfont.lfPitchAndFamily=DEFAULT_PITCH; |
| 1848 |
my_strncpy(newfont.lfFaceName,line.gettoken_str(1),LF_FACESIZE); |
| 1849 |
|
| 1850 |
SCRIPT_MSG(_T("BGFont: \"%") NPRIs _T("\""),line.gettoken_str(1)); |
| 1851 |
{ |
| 1852 |
bool height=false, weight=false; |
| 1853 |
for (int i = 2; i < line.getnumtokens(); i++) { |
| 1854 |
TCHAR *tok=line.gettoken_str(i); |
| 1855 |
if (tok[0]==_T('/')) { |
| 1856 |
if (!_tcsicmp(tok,_T("/ITALIC"))) { |
| 1857 |
SCRIPT_MSG(_T(" /ITALIC")); |
| 1858 |
newfont.lfItalic=TRUE; |
| 1859 |
} |
| 1860 |
else if (!_tcsicmp(tok,_T("/UNDERLINE"))) { |
| 1861 |
SCRIPT_MSG(_T(" /UNDERLINE")); |
| 1862 |
newfont.lfUnderline=TRUE; |
| 1863 |
} |
| 1864 |
else if (!_tcsicmp(tok,_T("/STRIKE"))) { |
| 1865 |
SCRIPT_MSG(_T(" /STRIKE")); |
| 1866 |
newfont.lfStrikeOut=TRUE; |
| 1867 |
} |
| 1868 |
else { |
| 1869 |
SCRIPT_MSG(_T("\n")); |
| 1870 |
PRINTHELP(); |
| 1871 |
} |
| 1872 |
} |
| 1873 |
else { |
| 1874 |
if (!height) { |
| 1875 |
SCRIPT_MSG(_T(" height=%") NPRIs,tok); |
| 1876 |
newfont.lfHeight=line.gettoken_int(i); |
| 1877 |
height=true; |
| 1878 |
} |
| 1879 |
else if (!weight) { |
| 1880 |
SCRIPT_MSG(_T(" weight=%") NPRIs,tok); |
| 1881 |
newfont.lfWeight=line.gettoken_int(i); |
| 1882 |
weight=true; |
| 1883 |
} |
| 1884 |
else { |
| 1885 |
SCRIPT_MSG(_T("\n")); |
| 1886 |
PRINTHELP(); |
| 1887 |
} |
| 1888 |
} |
| 1889 |
} |
| 1890 |
} |
| 1891 |
SCRIPT_MSG(_T("\n")); |
| 1892 |
memcpy(&bg_font, &newfont, sizeof(LOGFONT)); |
| 1893 |
return PS_OK; |
| 1894 |
#endif //~ NSIS_SUPPORT_BGBG |
| 1895 |
case TOK_BGGRADIENT: |
| 1896 |
#ifndef NSIS_SUPPORT_BGBG |
| 1897 |
ERROR_MSG(_T("Error: BGGradient specified but NSIS_SUPPORT_BGBG not defined\n")); |
| 1898 |
return PS_ERROR; |
| 1899 |
#else // NSIS_SUPPORT_BGBG |
| 1900 |
if (line.getnumtokens()==1) |
| 1901 |
{ |
| 1902 |
SCRIPT_MSG(_T("BGGradient: default colors\n")); |
| 1903 |
build_header.bg_color1=0; |
| 1904 |
build_header.bg_color2=RGB(0,0,255); |
| 1905 |
} |
| 1906 |
else if (!_tcsicmp(line.gettoken_str(1),_T("off"))) |
| 1907 |
{ |
| 1908 |
build_header.bg_color1=build_header.bg_color2=build_header.bg_textcolor=-1; |
| 1909 |
SCRIPT_MSG(_T("BGGradient: off\n")); |
| 1910 |
if (line.getnumtokens()>2) PRINTHELP() |
| 1911 |
} |
| 1912 |
else |
| 1913 |
{ |
| 1914 |
TCHAR *p = line.gettoken_str(1); |
| 1915 |
int v1,v2,v3=-1; |
| 1916 |
v1=_tcstoul(p,&p,16); |
| 1917 |
build_header.bg_color1=((v1&0xff)<<16)|(v1&0xff00)|((v1&0xff0000)>>16); |
| 1918 |
p=line.gettoken_str(2); |
| 1919 |
v2=_tcstoul(p,&p,16); |
| 1920 |
build_header.bg_color2=((v2&0xff)<<16)|(v2&0xff00)|((v2&0xff0000)>>16); |
| 1921 |
|
| 1922 |
p=line.gettoken_str(3); |
| 1923 |
if (*p) |
| 1924 |
{ |
| 1925 |
if (!_tcsicmp(p,_T("notext"))) build_header.bg_textcolor=-1; |
| 1926 |
else |
| 1927 |
{ |
| 1928 |
v3=_tcstoul(p,&p,16); |
| 1929 |
build_header.bg_textcolor=((v3&0xff)<<16)|(v3&0xff00)|((v3&0xff0000)>>16); |
| 1930 |
} |
| 1931 |
} |
| 1932 |
|
| 1933 |
SCRIPT_MSG(_T("BGGradient: 0x%06X->0x%06X (text=0x%06X)\n"),v1,v2,v3); |
| 1934 |
} |
| 1935 |
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT |
| 1936 |
build_uninst.bg_color1=build_header.bg_color1; |
| 1937 |
build_uninst.bg_color2=build_header.bg_color2; |
| 1938 |
build_uninst.bg_textcolor=build_header.bg_textcolor; |
| 1939 |
#endif //~ NSIS_CONFIG_UNINSTALL_SUPPORT |
| 1940 |
#endif //~ NSIS_SUPPORT_BGBG |
| 1941 |
return PS_OK; |
| 1942 |
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT |
| 1943 |
case TOK_INSTCOLORS: |
| 1944 |
{ |
| 1945 |
TCHAR *p = line.gettoken_str(1); |
| 1946 |
if (p[0]==_T('/')) |
| 1947 |
{ |
| 1948 |
if (_tcsicmp(p,_T("/windows")) || line.getnumtokens()!=2) PRINTHELP() |
| 1949 |
build_header.lb_fg=build_header.lb_bg=-1; |
| 1950 |
SCRIPT_MSG(_T("InstallColors: windows default colors\n")); |
| 1951 |
} |
| 1952 |
else |
| 1953 |
{ |
| 1954 |
if (line.getnumtokens()!=3) PRINTHELP() |
| 1955 |
int v1=_tcstoul(p,&p,16); |
| 1956 |
build_header.lb_fg=((v1&0xff)<<16)|(v1&0xff00)|((v1&0xff0000)>>16); |
| 1957 |
p=line.gettoken_str(2); |
| 1958 |
int v2=_tcstoul(p,&p,16); |
| 1959 |
build_header.lb_bg=((v2&0xff)<<16)|(v2&0xff00)|((v2&0xff0000)>>16); |
| 1960 |
SCRIPT_MSG(_T("InstallColors: fg=%06X bg=%06X\n"),v1,v2); |
| 1961 |
} |
| 1962 |
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT |
| 1963 |
build_uninst.lb_fg=build_header.lb_fg; |
| 1964 |
build_uninst.lb_bg=build_header.lb_bg; |
| 1965 |
#endif |
| 1966 |
} |
| 1967 |
return PS_OK; |
| 1968 |
case TOK_XPSTYLE: |
| 1969 |
{ |
| 1970 |
int k=line.gettoken_enum(1,_T("on\0off\0")); |
| 1971 |
if (k == -1) PRINTHELP() |
| 1972 |
SCRIPT_MSG(_T("XPStyle: %") NPRIs _T("\n"), line.gettoken_str(1)); |
| 1973 |
manifest_comctl = !k ? manifest::comctl_xp : manifest::comctl_old; |
| 1974 |
} |
| 1975 |
return PS_OK; |
| 1976 |
case TOK_CHANGEUI: |
| 1977 |
try { |
| 1978 |
DWORD dwSize; |
| 1979 |
int k=line.gettoken_enum(1, _T("all\0IDD_LICENSE\0IDD_DIR\0IDD_SELCOM\0IDD_INST\0IDD_INSTFILES\0IDD_UNINST\0IDD_VERIFY\0IDD_LICENSE_FSRB\0IDD_LICENSE_FSCB\0")); |
| 1980 |
if (k<0) PRINTHELP(); |
| 1981 |
|
| 1982 |
unsigned long uifilesize; |
| 1983 |
BYTE *uifiledata = alloc_and_read_file(line.gettoken_str(2), uifilesize); |
| 1984 |
if (!uifiledata) { |
| 1985 |
ERROR_MSG(_T("Error: Can't read \"%") NPRIs _T("\"!\n"), line.gettoken_str(2)); |
| 1986 |
return PS_ERROR; |
| 1987 |
} |
| 1988 |
MANAGE_WITH(uifiledata, free); |
| 1989 |
|
| 1990 |
CResourceEditor *uire = new CResourceEditor(uifiledata, uifilesize); |
| 1991 |
init_res_editor(); |
| 1992 |
|
| 1993 |
// Search for required items |
| 1994 |
#define CUISEARCHERR(n,v) ERROR_MSG(_T("Error: Can't find %") NPRIs _T(" (%u) in the custom UI!\n"), n, v); |
| 1995 |
#define GET(x) if (!(dlg = uire->GetResource(RT_DIALOG, x, uire->ANYLANGID))) { CUISEARCHERR(_T(#x), x); return PS_ERROR; } CDialogTemplate UIDlg(dlg, build_unicode, uDefCodePage); |
| 1996 |
#define SEARCH(x) if (!UIDlg.GetItem(x)) { CUISEARCHERR(_T(#x), x); uire->FreeResource(dlg); delete uire; return PS_ERROR; } |
| 1997 |
#define SAVE(x) uire->FreeResource(dlg); dlg = UIDlg.Save(dwSize); res_editor->UpdateResource(RT_DIALOG, x, NSIS_DEFAULT_LANG, dlg, dwSize); UIDlg.FreeSavedTemplate(dlg); |
| 1998 |
|
| 1999 |
LPBYTE dlg = NULL; |
| 2000 |
if (k == 0 || k == 1) { |
| 2001 |
GET(IDD_LICENSE); |
| 2002 |
SEARCH(IDC_EDIT1); |
| 2003 |
SAVE(IDD_LICENSE); |
| 2004 |
} |
| 2005 |
|
| 2006 |
if (k == 0 || k == 2) { |
| 2007 |
GET(IDD_DIR); |
| 2008 |
SEARCH(IDC_DIR); |
| 2009 |
SEARCH(IDC_BROWSE); |
| 2010 |
#ifdef NSIS_CONFIG_LOG |
| 2011 |
SEARCH(IDC_CHECK1); |
| 2012 |
#endif |
| 2013 |
SAVE(IDD_DIR); |
| 2014 |
} |
| 2015 |
|
| 2016 |
if (k == 0 || k == 3) { |
| 2017 |
GET(IDD_SELCOM); |
| 2018 |
SEARCH(IDC_TREE1); |
| 2019 |
SEARCH(IDC_COMBO1); |
| 2020 |
SAVE(IDD_SELCOM); |
| 2021 |
} |
| 2022 |
|
| 2023 |
if (k == 0 || k == 4) { |
| 2024 |
GET(IDD_INST); |
| 2025 |
SEARCH(IDC_BACK); |
| 2026 |
SEARCH(IDC_CHILDRECT); |
| 2027 |
SEARCH(IDC_VERSTR); |
| 2028 |
SEARCH(IDOK); |
| 2029 |
SEARCH(IDCANCEL); |
| 2030 |
|
| 2031 |
// Search for bitmap holder (default for SetBrandingImage) |
| 2032 |
branding_image_found = false; |
| 2033 |
DialogItemTemplate* dlgItem = 0; |
| 2034 |
for (int i = 0; (dlgItem = UIDlg.GetItemByIdx(i)); i++) { |
| 2035 |
bool check = false; |
| 2036 |
if (IS_INTRESOURCE(dlgItem->szClass)) { |
| 2037 |
if (dlgItem->szClass == MAKEINTRESOURCEWINW(0x0082)) { |
| 2038 |
check = true; |
| 2039 |
} |
| 2040 |
} else |
| 2041 |
check = WinWStrICmpASCII(dlgItem->szClass, "Static") == 0; |
| 2042 |
|
| 2043 |
if (check) { |
| 2044 |
if ((dlgItem->dwStyle & SS_BITMAP) == SS_BITMAP) { |
| 2045 |
branding_image_found = true; |
| 2046 |
branding_image_id = dlgItem->wId; |
| 2047 |
break; |
| 2048 |
} |
| 2049 |
} |
| 2050 |
} |
| 2051 |
SAVE(IDD_INST); |
| 2052 |
} |
| 2053 |
|
| 2054 |
if (k == 0 || k == 5) { |
| 2055 |
GET(IDD_INSTFILES); |
| 2056 |
SEARCH(IDC_LIST1); |
| 2057 |
SEARCH(IDC_PROGRESS); |
| 2058 |
SEARCH(IDC_SHOWDETAILS); |
| 2059 |
SAVE(IDD_INSTFILES); |
| 2060 |
} |
| 2061 |
|
| 2062 |
if (k == 0 || k == 6) { |
| 2063 |
GET(IDD_UNINST); |
| 2064 |
SEARCH(IDC_EDIT1); |
| 2065 |
SAVE(IDD_UNINST); |
| 2066 |
} |
| 2067 |
|
| 2068 |
if (k == 0 || k == 7) { |
| 2069 |
GET(IDD_VERIFY); |
| 2070 |
SEARCH(IDC_STR); |
| 2071 |
SAVE(IDD_VERIFY); |
| 2072 |
} |
| 2073 |
|
| 2074 |
if (k == 0 || k == 8) { |
| 2075 |
GET(IDD_LICENSE_FSRB); |
| 2076 |
SEARCH(IDC_EDIT1); |
| 2077 |
SEARCH(IDC_LICENSEAGREE); |
| 2078 |
SEARCH(IDC_LICENSEDISAGREE); |
| 2079 |
SAVE(IDD_LICENSE_FSRB); |
| 2080 |
} |
| 2081 |
|
| 2082 |
if (k == 0 || k == 9) { |
| 2083 |
GET(IDD_LICENSE_FSCB); |
| 2084 |
SEARCH(IDC_EDIT1); |
| 2085 |
SEARCH(IDC_LICENSEAGREE); |
| 2086 |
SAVE(IDD_LICENSE_FSCB); |
| 2087 |
} |
| 2088 |
|
| 2089 |
delete uire; |
| 2090 |
|
| 2091 |
SCRIPT_MSG(_T("ChangeUI: %") NPRIs _T(" %") NPRIs _T("%") NPRIs _T("\n"), line.gettoken_str(1), line.gettoken_str(2), branding_image_found?_T(" (branding image holder found)"):_T("")); |
| 2092 |
} |
| 2093 |
catch (exception& err) { |
| 2094 |
ERROR_MSG(_T("Error while changing UI: %") NPRIs _T("\n"), CtoTStrParam(err.what())); |
| 2095 |
return PS_ERROR; |
| 2096 |
} |
| 2097 |
return PS_OK; |
| 2098 |
case TOK_ADDBRANDINGIMAGE: |
| 2099 |
try { |
| 2100 |
LAYOUTUNIT whtype, padtype; |
| 2101 |
int k = line.gettoken_enum(1,_T("top\0left\0bottom\0right\0")), defpadding = 2; |
| 2102 |
int wh = ParseLayoutUnit(line.gettoken_str(2), whtype); |
| 2103 |
if (k == -1) PRINTHELP(); |
| 2104 |
int padding = (line.getnumtokens() >= 4) ? ParseLayoutUnit(line.gettoken_str(3), padtype) : (padtype = whtype, defpadding); |
| 2105 |
if (whtype == LU_INVALID || whtype != padtype) |
| 2106 |
throw runtime_error("Invalid number!"); |
| 2107 |
init_res_editor(); |
| 2108 |
BYTE* dlg = res_editor->GetResource(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG); |
| 2109 |
CDialogTemplate dt(dlg, build_unicode, uDefCodePage); |
| 2110 |
res_editor->FreeResource(dlg); |
| 2111 |
if (whtype != LU_DIALOG && !CDialogTemplate::SupportsDialogUnitComputation()) |
| 2112 |
throw runtime_error("Must use dialog units on non-Win32 platforms!"); |
| 2113 |
|
| 2114 |
DialogItemTemplate brandingCtl = {0,}; |
| 2115 |
brandingCtl.dwStyle = SS_BITMAP | WS_CHILD | WS_VISIBLE; |
| 2116 |
brandingCtl.sX = brandingCtl.sY = padding; |
| 2117 |
brandingCtl.szClass = MAKEINTRESOURCEWINW(0x0082); |
| 2118 |
brandingCtl.szTitle = NULL; |
| 2119 |
brandingCtl.wId = IDC_BRANDIMAGE; |
| 2120 |
brandingCtl.sHeight = brandingCtl.sWidth = wh; |
| 2121 |
if (whtype == LU_PIXEL) dt.PixelsToDlgUnits(brandingCtl.sWidth, brandingCtl.sHeight); |
| 2122 |
if (k%2) { // left (1) / right (3) |
| 2123 |
if (k & 2) // right |
| 2124 |
brandingCtl.sX += dt.GetWidth(); |
| 2125 |
else // left |
| 2126 |
dt.MoveAll(brandingCtl.sWidth + (padding * 2), 0); |
| 2127 |
|
| 2128 |
dt.Resize(brandingCtl.sWidth + (padding * 2), 0); |
| 2129 |
brandingCtl.sHeight = dt.GetHeight() - (padding * 2); |
| 2130 |
} |
| 2131 |
else { // top (0) / bottom (2) |
| 2132 |
if (k & 2) // bottom |
| 2133 |
brandingCtl.sY += dt.GetHeight(); |
| 2134 |
else // top |
| 2135 |
dt.MoveAll(0, brandingCtl.sHeight + (padding * 2)); |
| 2136 |
|
| 2137 |
dt.Resize(0, brandingCtl.sHeight + (padding * 2)); |
| 2138 |
brandingCtl.sWidth = dt.GetWidth() - (padding * 2); |
| 2139 |
} |
| 2140 |
dt.AddItem(brandingCtl); |
| 2141 |
|
| 2142 |
DWORD dwDlgSize; |
| 2143 |
dlg = dt.Save(dwDlgSize); |
| 2144 |
res_editor->UpdateResource(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG, dlg, dwDlgSize); |
| 2145 |
dt.FreeSavedTemplate(dlg); |
| 2146 |
|
| 2147 |
if (whtype == LU_PIXEL) dt.DlgUnitsToPixels(brandingCtl.sWidth, brandingCtl.sHeight); |
| 2148 |
const char* unitstr = whtype == LU_PIXEL ? "pixels" : "dialog units"; |
| 2149 |
SCRIPT_MSG(_T("AddBrandingImage: %") NPRIs _T(" %ux%u %") NPRIns _T("\n"), line.gettoken_str(1), brandingCtl.sWidth, brandingCtl.sHeight, unitstr); |
| 2150 |
|
| 2151 |
branding_image_found = true; |
| 2152 |
branding_image_id = IDC_BRANDIMAGE; |
| 2153 |
} |
| 2154 |
catch (exception& err) { |
| 2155 |
ERROR_MSG(_T("Error while adding image branding support: %") NPRIs _T("\n"), CtoTStrParam(err.what())); |
| 2156 |
return PS_ERROR; |
| 2157 |
} |
| 2158 |
return PS_OK; |
| 2159 |
case TOK_SETFONT: |
| 2160 |
{ |
| 2161 |
unsigned char failed = 0; |
| 2162 |
if (!_tcsnicmp(line.gettoken_str(1), _T("/LANG="), 6)) |
| 2163 |
{ |
| 2164 |
LANGID lang_id = ParseLangId(line.gettoken_str(1) + 6); |
| 2165 |
LanguageTable *table = GetLangTable(lang_id); |
| 2166 |
const TCHAR*facename = line.gettoken_str(2); |
| 2167 |
table->nlf.m_szFont = _tcsdup(facename); |
| 2168 |
table->nlf.m_iFontSize = line.gettoken_int(3); |
| 2169 |
|
| 2170 |
if (table->nlf.m_szFont) |
| 2171 |
SCRIPT_MSG(_T("SetFont: lang=%d \"%") NPRIs _T("\" %") NPRIs _T("\n"), lang_id, facename, line.gettoken_str(3)); |
| 2172 |
else |
| 2173 |
++failed; |
| 2174 |
} |
| 2175 |
else |
| 2176 |
{ |
| 2177 |
const TCHAR*facename = line.gettoken_str(1); |
| 2178 |
my_strncpy(build_font, facename, COUNTOF(build_font)); |
| 2179 |
build_font_size = line.gettoken_int(2); |
| 2180 |
|
| 2181 |
if (!failed) SCRIPT_MSG(_T("SetFont: \"%") NPRIs _T("\" %") NPRIs _T("\n"), facename, line.gettoken_str(2)); |
| 2182 |
} |
| 2183 |
if (failed) |
| 2184 |
{ |
| 2185 |
ERROR_MSG(_T("Error: Unable to convert font name\n")); |
| 2186 |
return PS_ERROR; |
| 2187 |
} |
| 2188 |
} |
| 2189 |
return PS_OK; |
| 2190 |
#else |
| 2191 |
case TOK_INSTCOLORS: |
| 2192 |
case TOK_XPSTYLE: |
| 2193 |
case TOK_CHANGEUI: |
| 2194 |
case TOK_ADDBRANDINGIMAGE: |
| 2195 |
case TOK_SETFONT: |
| 2196 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_VISIBLE_SUPPORT not defined.\n"),line.gettoken_str(0)); |
| 2197 |
return PS_ERROR; |
| 2198 |
#endif //~ NSIS_CONFIG_VISIBLE_SUPPORT |
| 2199 |
|
| 2200 |
case TOK_PEADDRESOURCE: |
| 2201 |
{ |
| 2202 |
init_res_editor(); |
| 2203 |
int tokidx = 1, ovr = 0, rep = 0, result = PS_ERROR; |
| 2204 |
if (!_tcsicmp(line.gettoken_str(tokidx), _T("/OVERWRITE"))) // Update the resource even if it exists |
| 2205 |
++ovr, ++tokidx; |
| 2206 |
else if (!_tcsicmp(line.gettoken_str(tokidx), _T("/REPLACE"))) // Only update existing resource |
| 2207 |
++rep, ++tokidx; |
| 2208 |
const TCHAR *rt = line.gettoken_str(tokidx+1), *rnraw = line.gettoken_str(tokidx+2), *rlraw = line.gettoken_str(tokidx+3); |
| 2209 |
if (!*rlraw) |
| 2210 |
rlraw = _T("Default"); // Language parameter is optional |
| 2211 |
LANGID rl = res_editor->ParseResourceTypeNameLangString(&rt, &rnraw, rlraw), foundrl; |
| 2212 |
if (rl == CResourceEditor::INVALIDLANGID || rl == CResourceEditor::ALLLANGID) |
| 2213 |
PRINTHELP(); |
| 2214 |
WORD rn = (WORD)(size_t) rnraw; assert(!CResourceEditor::EditorSupportsStringNames()); |
| 2215 |
bool exists = res_editor->ResourceExists(rt, rn, rl, &foundrl); |
| 2216 |
if (rl == CResourceEditor::ANYLANGID) |
| 2217 |
rl = exists ? foundrl : NSIS_DEFAULT_LANG; |
| 2218 |
if ((rep && !exists) || (!ovr && exists)) |
| 2219 |
{ |
| 2220 |
ERROR_MSG(_T("Error: Resource %") NPRIns _T("\n"), rep ? ("does not exist") : ("already exists")); |
| 2221 |
return PS_ERROR; |
| 2222 |
} |
| 2223 |
if (res_editor->UpdateResourceFromExternal(rt, rn, rl, line.gettoken_str(tokidx+0), CResourceEditor::TM_AUTO)) |
| 2224 |
{ |
| 2225 |
SCRIPT_MSG(_T("PEAddResource: %") NPRIs _T("=%") NPRIs _T("\n"), make_friendly_resource_path(rt, rnraw, rl).c_str(), line.gettoken_str(tokidx+0)); |
| 2226 |
result = PS_OK; |
| 2227 |
} |
| 2228 |
return result; |
| 2229 |
} |
| 2230 |
return PS_OK; |
| 2231 |
case TOK_PEREMOVERESOURCE: |
| 2232 |
{ |
| 2233 |
init_res_editor(); |
| 2234 |
int tokidx = 1, noerr = 0; |
| 2235 |
if (!_tcsicmp(line.gettoken_str(tokidx), _T("/NOERRORS"))) |
| 2236 |
++noerr, ++tokidx; |
| 2237 |
const TCHAR *rt = line.gettoken_str(tokidx+0), *rnraw = line.gettoken_str(tokidx+1), *rlraw = line.gettoken_str(tokidx+2); |
| 2238 |
LANGID rl = res_editor->ParseResourceTypeNameLangString(&rt, &rnraw, rlraw); |
| 2239 |
if (rl == CResourceEditor::INVALIDLANGID || rl == CResourceEditor::ANYLANGID) |
| 2240 |
PRINTHELP(); |
| 2241 |
WORD rn = (WORD)(size_t) rnraw; assert(!CResourceEditor::EditorSupportsStringNames()); |
| 2242 |
if (!noerr && !res_editor->ResourceExists(rt, rn, rl)) |
| 2243 |
{ |
| 2244 |
ERROR_MSG(_T("Error: Resource %") NPRIns _T("\n"), ("does not exist")); |
| 2245 |
return PS_ERROR; |
| 2246 |
} |
| 2247 |
if (res_editor->DeleteResource(rt, rn, rl, CResourceEditor::TM_AUTO)) |
| 2248 |
SCRIPT_MSG(_T("PERemoveResource: %") NPRIs _T("\n"), make_friendly_resource_path(rt, rnraw, rl).c_str()); |
| 2249 |
else if (!noerr) |
| 2250 |
return PS_ERROR; |
| 2251 |
} |
| 2252 |
return PS_OK; |
| 2253 |
|
| 2254 |
case TOK_PEDLLCHARACTERISTICS: |
| 2255 |
{ |
| 2256 |
int s1, s2; |
| 2257 |
WORD add = (WORD)line.gettoken_int(1, &s1), del = (WORD)line.gettoken_int(2, &s2), org = PEDllCharacteristics; |
| 2258 |
if (!s1 || !s2) PRINTHELP(); |
| 2259 |
PEDllCharacteristics &= ~del, PEDllCharacteristics |= add; |
| 2260 |
SCRIPT_MSG(_T("PEDllCharacteristics: 0x%.4x -> 0x%.4x\n"), org, PEDllCharacteristics); |
| 2261 |
} |
| 2262 |
return PS_OK; |
| 2263 |
|
| 2264 |
case TOK_PESUBSYSVER: |
| 2265 |
{ |
| 2266 |
unsigned int mj, mi; |
| 2267 |
if (2 == _stscanf(line.gettoken_str(1), _T("%u.%u"), &mj, &mi)) |
| 2268 |
if (mj <= 0xffff && mi <= 0xffff) |
| 2269 |
return (PESubsysVerMaj = (WORD) mj, PESubsysVerMin = (WORD) mi, PS_OK); |
| 2270 |
} |
| 2271 |
PRINTHELP(); |
| 2272 |
return PS_ERROR; |
| 2273 |
|
| 2274 |
case TOK_REQEXECLEVEL: |
| 2275 |
switch (line.gettoken_enum(1,_T("none\0user\0highest\0admin\0"))) |
| 2276 |
{ |
| 2277 |
case 0: manifest_exec_level = manifest::exec_level_none; break; |
| 2278 |
case 1: manifest_exec_level = manifest::exec_level_user; break; |
| 2279 |
case 2: manifest_exec_level = manifest::exec_level_highest; break; |
| 2280 |
case 3: manifest_exec_level = manifest::exec_level_admin; break; |
| 2281 |
default: PRINTHELP(); |
| 2282 |
} |
| 2283 |
return PS_OK; |
| 2284 |
|
| 2285 |
case TOK_MANIFEST_APPENDCUSTOMSTRING: |
| 2286 |
if (!manifest::addappendstring(line.gettoken_str(1), line.gettoken_str(2))) PRINTHELP(); |
| 2287 |
return PS_OK; |
| 2288 |
case TOK_MANIFEST_DPIAWARE: |
| 2289 |
switch(line.gettoken_enum(1,_T("none\0notset\0false\0true\0system\0permonitor\0explorer\0"))) |
| 2290 |
{ |
| 2291 |
case 0: // A lot of attributes use "none" so we support that along with the documented value |
| 2292 |
case 1: manifest_dpiaware = manifest::dpiaware_notset; break; |
| 2293 |
case 2: manifest_dpiaware = manifest::dpiaware_false; break; |
| 2294 |
case 3: // "True" == "System DPI" |
| 2295 |
case 4: manifest_dpiaware = manifest::dpiaware_true; break; |
| 2296 |
case 5: manifest_dpiaware = manifest::dpiaware_permonitor; break; |
| 2297 |
case 6: manifest_dpiaware = manifest::dpiaware_explorer; break; |
| 2298 |
default: PRINTHELP(); |
| 2299 |
} |
| 2300 |
return PS_OK; |
| 2301 |
case TOK_MANIFEST_DPIAWARENESS: |
| 2302 |
manifest_dpiawareness = line.gettoken_str(1); |
| 2303 |
return PS_OK; |
| 2304 |
|
| 2305 |
case TOK_MANIFEST_LPAWARE: |
| 2306 |
switch(line.gettoken_enum(1,_T("none\0notset\0true\0false\0"))) |
| 2307 |
{ |
| 2308 |
case 0: // A lot of attributes use "none" so we support that along with the documented value |
| 2309 |
case 1: manifest_lpaware = manifest::lpaware_notset; break; |
| 2310 |
case 2: manifest_lpaware = manifest::lpaware_true; break; |
| 2311 |
case 3: manifest_lpaware = manifest::lpaware_false; break; |
| 2312 |
default: PRINTHELP(); |
| 2313 |
} |
| 2314 |
return PS_OK; |
| 2315 |
|
| 2316 |
case TOK_MANIFEST_SUPPORTEDOS: |
| 2317 |
{ |
| 2318 |
manifest_sosl.deleteall(); |
| 2319 |
if (2 == line.getnumtokens()) |
| 2320 |
switch(line.gettoken_enum(1,_T("none\0all\0"))) |
| 2321 |
{ |
| 2322 |
case 0: return PS_OK; |
| 2323 |
case 1: return manifest_sosl.addall() ? PS_OK : PS_ERROR; |
| 2324 |
} |
| 2325 |
for(int argi = 1; argi < line.getnumtokens(); ++argi) |
| 2326 |
if (!manifest_sosl.append(line.gettoken_str(argi))) |
| 2327 |
PRINTHELP(); |
| 2328 |
} |
| 2329 |
return PS_OK; |
| 2330 |
case TOK_MANIFEST_MAXVERSIONTESTED: |
| 2331 |
manifest_maxversiontested = line.gettoken_enum(1, _T("none\0notset\0")) == -1 ? line.gettoken_str(1) : _T(""); |
| 2332 |
return PS_OK; |
| 2333 |
|
| 2334 |
case TOK_MANIFEST_DISABLEWINDOWFILTERING: |
| 2335 |
switch(line.gettoken_enum(1,_T("notset\0false\0true"))) |
| 2336 |
{ |
| 2337 |
case 0: |
| 2338 |
case 1: manifest_flags &= ~manifest::disablewindowfiltering; break; |
| 2339 |
case 2: manifest_flags |= manifest::disablewindowfiltering; break; |
| 2340 |
default: PRINTHELP(); |
| 2341 |
} |
| 2342 |
return PS_OK; |
| 2343 |
|
| 2344 |
case TOK_MANIFEST_GDISCALING: |
| 2345 |
switch(line.gettoken_enum(1,_T("notset\0false\0true"))) |
| 2346 |
{ |
| 2347 |
case 0: |
| 2348 |
case 1: manifest_flags &= ~manifest::gdiscaling; break; |
| 2349 |
case 2: manifest_flags |= manifest::gdiscaling; break; |
| 2350 |
default: PRINTHELP(); |
| 2351 |
} |
| 2352 |
return PS_OK; |
| 2353 |
|
| 2354 |
#ifdef _UNICODE |
| 2355 |
case TOK_TARGET: |
| 2356 |
{ |
| 2357 |
const TCHAR *cmdnam = get_commandtoken_name(which_token); |
| 2358 |
CEXEBuild::TARGETTYPE tt = get_target_type(line.gettoken_str(1)); |
| 2359 |
if (CEXEBuild::TARGET_UNKNOWN == tt) |
| 2360 |
{ |
| 2361 |
print_bad_targettype_parameter(cmdnam); |
| 2362 |
return PS_ERROR; |
| 2363 |
} |
| 2364 |
if (m_target_type != tt && PS_OK != change_target_architecture(tt)) |
| 2365 |
{ |
| 2366 |
ERROR_MSG(_T("Error: Unable to set target %") NPRIs _T(" (adequate stub not found?)\n"), _T("architecture")); |
| 2367 |
return PS_ERROR; |
| 2368 |
} |
| 2369 |
SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T("\n"), cmdnam, get_target_suffix(tt)); |
| 2370 |
} |
| 2371 |
return PS_OK; |
| 2372 |
case TOK_TARGETCPU: |
| 2373 |
{ |
| 2374 |
int k = line.gettoken_enum(1, _T("x86\0amd64\0x64\0")); |
| 2375 |
if (-1 == k) PRINTHELP(); |
| 2376 |
CEXEBuild::TARGETTYPE tt = TARGET_AMD64; |
| 2377 |
if (0 == k) tt = m_previous_x86_unicode ? TARGET_X86UNICODE : TARGET_X86ANSI; |
| 2378 |
if (m_target_type != tt && PS_OK != change_target_architecture(tt)) |
| 2379 |
{ |
| 2380 |
ERROR_MSG(_T("Error: Unable to set target %") NPRIs _T(" (adequate stub not found?)\n"), _T("architecture")); |
| 2381 |
return PS_ERROR; |
| 2382 |
} |
| 2383 |
SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T("\n"), get_commandtoken_name(which_token), line.gettoken_str(1)); |
| 2384 |
} |
| 2385 |
return PS_OK; |
| 2386 |
case TOK_TARGETUNICODE: |
| 2387 |
{ |
| 2388 |
int k = line.gettoken_enum(1, _T("false\0true\0")); |
| 2389 |
if (-1 == k) PRINTHELP(); |
| 2390 |
CEXEBuild::TARGETTYPE tt = k ? (TARGET_X86ANSI == m_target_type ? TARGET_X86UNICODE : m_target_type) : TARGET_X86ANSI; |
| 2391 |
if (tt != m_target_type && (build_compressor_set | build_lockedunicodetarget)) |
| 2392 |
{ |
| 2393 |
ERROR_MSG(_T("Error: Can't change target %") NPRIs _T(" after data already got compressed or header already changed!\n"), _T("charset")); |
| 2394 |
return PS_ERROR; |
| 2395 |
} |
| 2396 |
SCRIPT_MSG(_T("Unicode: %") NPRIs _T("\n"), k ? _T("true") : _T("false")); |
| 2397 |
if (is_targettype_64bit(tt) != is_targettype_64bit(m_target_type) || PS_OK != change_target_architecture(tt)) |
| 2398 |
{ |
| 2399 |
ERROR_MSG(_T("Error: Unable to set target %") NPRIs _T(" (adequate stub not found?)\n"), _T("charset")); |
| 2400 |
return PS_ERROR; |
| 2401 |
} |
| 2402 |
} |
| 2403 |
return PS_OK; |
| 2404 |
#endif //~ _UNICODE |
| 2405 |
|
| 2406 |
// Ability to change compression methods from within the script |
| 2407 |
case TOK_SETCOMPRESSOR: |
| 2408 |
#ifdef NSIS_CONFIG_COMPRESSION_SUPPORT |
| 2409 |
{ |
| 2410 |
if (build_compressor_set) { |
| 2411 |
ERROR_MSG(_T("Error: can't change compressor after data already got compressed or header already changed!\n")); |
| 2412 |
return PS_ERROR; |
| 2413 |
} |
| 2414 |
if (build_compressor_final) |
| 2415 |
{ |
| 2416 |
warning_fl(DW_COMP_FINAL, _T("SetCompressor ignored due to previous call with the /FINAL switch")); |
| 2417 |
return PS_OK; |
| 2418 |
} |
| 2419 |
build_compress_whole = false; |
| 2420 |
|
| 2421 |
int a = 1; |
| 2422 |
while (line.gettoken_str(a)[0] == _T('/')) |
| 2423 |
{ |
| 2424 |
if (!_tcsicmp(line.gettoken_str(a),_T("/FINAL"))) |
| 2425 |
build_compressor_final = true, a++; |
| 2426 |
else if (!_tcsicmp(line.gettoken_str(a),_T("/SOLID"))) |
| 2427 |
build_compress_whole = true, a++; |
| 2428 |
else |
| 2429 |
PRINTHELP(); |
| 2430 |
} |
| 2431 |
|
| 2432 |
if (a != line.getnumtokens() - 1) |
| 2433 |
{ |
| 2434 |
ERROR_MSG(_T("%") NPRIs _T(" expects %d parameters, got %d.\n"), line.gettoken_str(0), a + 1, line.getnumtokens()); |
| 2435 |
PRINTHELP(); |
| 2436 |
} |
| 2437 |
|
| 2438 |
int k=line.gettoken_enum(a, _T("zlib\0bzip2\0lzma\0")); |
| 2439 |
switch (k) { |
| 2440 |
case 0: compressor = &zlib_compressor; break; |
| 2441 |
case 1: compressor = &bzip2_compressor; break; |
| 2442 |
case 2: compressor = &lzma_compressor; break; |
| 2443 |
default: PRINTHELP(); |
| 2444 |
} |
| 2445 |
|
| 2446 |
tstring compressor_name = line.gettoken_str(a); |
| 2447 |
compressor_name = lowercase(compressor_name); |
| 2448 |
|
| 2449 |
if (set_compressor(compressor_name, build_compress_whole) != PS_OK) |
| 2450 |
{ |
| 2451 |
SCRIPT_MSG(_T("SetCompressor: error loading stub for \"%") NPRIs _T("\" compressor.\n"), compressor_name.c_str()); |
| 2452 |
return PS_ERROR; |
| 2453 |
} |
| 2454 |
|
| 2455 |
SCRIPT_MSG(_T("SetCompressor: %") NPRIs _T("%") NPRIs _T("%") NPRIs _T("\n"), build_compressor_final ? _T("/FINAL ") : _T(""), build_compress_whole ? _T("/SOLID ") : _T(""), line.gettoken_str(a)); |
| 2456 |
} |
| 2457 |
return PS_OK; |
| 2458 |
#else |
| 2459 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_COMPRESSION_SUPPORT not defined.\n"), line.gettoken_str(0)); |
| 2460 |
return PS_ERROR; |
| 2461 |
#endif //~ NSIS_CONFIG_COMPRESSION_SUPPORT |
| 2462 |
case TOK_LOADNLF: |
| 2463 |
{ |
| 2464 |
SCRIPT_MSG(_T("LoadLanguageFile: %") NPRIs _T("\n"), line.gettoken_str(1)); |
| 2465 |
|
| 2466 |
LanguageTable *table = LoadLangFile(line.gettoken_str(1)); |
| 2467 |
if (!table) return PS_ERROR; |
| 2468 |
|
| 2469 |
if (!defcodepage_set) |
| 2470 |
{ |
| 2471 |
uDefCodePage = table->nlf.m_uCodePage; |
| 2472 |
defcodepage_set = true; |
| 2473 |
} |
| 2474 |
|
| 2475 |
last_used_lang = table->lang_id; |
| 2476 |
// define LANG_LangName as "####" (lang id), for example ${LANG_ENGLISH} = 1033 |
| 2477 |
TCHAR lang_id[16], lang_cp[16], lang_def[1024]; |
| 2478 |
wsprintf(lang_def, _T("LANG_%") NPRIs, table->nlf.m_szName); |
| 2479 |
wsprintf(lang_id, _T("%u"), table->lang_id); |
| 2480 |
definedlist.add(lang_def, lang_id); |
| 2481 |
wsprintf(lang_def, _T("LANG_%") NPRIs _T("_CP"), table->nlf.m_szName); |
| 2482 |
wsprintf(lang_cp, _T("%u"), table->nlf.m_uCodePage); |
| 2483 |
definedlist.add(lang_def, lang_cp); |
| 2484 |
} |
| 2485 |
return PS_OK; |
| 2486 |
|
| 2487 |
// preprocessor-ish (ifdef/ifndef/else/endif are handled one step out from here) |
| 2488 |
/////////////////////////////////////////////////////////////////////////////// |
| 2489 |
case TOK_P_DEFINE: |
| 2490 |
return pp_define(line); |
| 2491 |
case TOK_P_UNDEF: |
| 2492 |
return pp_undef(line); |
| 2493 |
case TOK_P_PACKEXEHEADER: |
| 2494 |
return pp_packhdr(line); |
| 2495 |
case TOK_P_FINALIZE: |
| 2496 |
case TOK_P_UNINSTFINALIZE: |
| 2497 |
return pp_finalize(which_token, line); |
| 2498 |
case TOK_P_SYSTEMEXEC: |
| 2499 |
case TOK_P_EXECUTE: |
| 2500 |
case TOK_P_MAKENSIS: |
| 2501 |
return pp_execute(which_token, line); |
| 2502 |
case TOK_P_ADDINCLUDEDIR: |
| 2503 |
return pp_addincludedir(line); |
| 2504 |
case TOK_P_INCLUDE: |
| 2505 |
return pp_include(line); |
| 2506 |
case TOK_P_CD: |
| 2507 |
return pp_cd(line); |
| 2508 |
case TOK_P_PRAGMA: |
| 2509 |
return parse_pragma(line) == PS_ERROR ? PS_ERROR : PS_OK; |
| 2510 |
case TOK_P_ERROR: |
| 2511 |
ERROR_MSG(_T("!error: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 2512 |
return PS_ERROR; |
| 2513 |
case TOK_P_WARNING: |
| 2514 |
warning_fl(DIAGCODE_INTERNAL_HIDEDIAGCODE, _T("!warning: %") NPRIs,line.gettoken_str(1)); |
| 2515 |
return PS_OK; |
| 2516 |
case TOK_P_ECHO: |
| 2517 |
SCRIPT_MSG(_T("%") NPRIs _T(" (%") NPRIs _T(":%d)\n"), line.gettoken_str(1),curfilename,linecnt); |
| 2518 |
return PS_OK; |
| 2519 |
case TOK_P_ASSERT: |
| 2520 |
return pp_assert(line); |
| 2521 |
case TOK_P_SEARCHPARSESTRING: |
| 2522 |
return pp_searchparsestring(line); |
| 2523 |
case TOK_P_SEARCHREPLACESTRING: |
| 2524 |
return pp_searchreplacestring(line); |
| 2525 |
case TOK_P_VERBOSE: |
| 2526 |
return pp_verbose(line); |
| 2527 |
|
| 2528 |
case TOK_UNINSTALLEXENAME: PRINTHELP() |
| 2529 |
|
| 2530 |
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT |
| 2531 |
case TOK_UNINSTCAPTION: |
| 2532 |
{ |
| 2533 |
if (SetInnerString(NLF_UCAPTION,line.gettoken_str(1)) == PS_WARNING) |
| 2534 |
warning_fl(DW_INNERSTRING_MULTISETWASTE, _T("%") NPRIs _T(": specified multiple times, wasting space"),line.gettoken_str(0)); |
| 2535 |
SCRIPT_MSG(_T("UninstCaption: \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 2536 |
} |
| 2537 |
return PS_OK; |
| 2538 |
case TOK_UNINSTICON: |
| 2539 |
SCRIPT_MSG(_T("UninstallIcon: \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 2540 |
try { |
| 2541 |
free_loaded_icon(uninstaller_icon); |
| 2542 |
uninstaller_icon = load_icon(line.gettoken_str(1)); |
| 2543 |
} |
| 2544 |
catch (exception& err) { |
| 2545 |
ERROR_MSG(_T("Error while loading icon from \"%") NPRIs _T("\": %") NPRIs _T("\n"), line.gettoken_str(1), CtoTStrParam(err.what())); |
| 2546 |
return PS_ERROR; |
| 2547 |
} |
| 2548 |
return PS_OK; |
| 2549 |
case TOK_UNINSTTEXT: |
| 2550 |
{ |
| 2551 |
if (!cur_page) { |
| 2552 |
if (SetInnerString(NLF_UNINST_TEXT, line.gettoken_str(1)) == PS_WARNING) |
| 2553 |
warning_fl(DW_INNERSTRING_MULTISETWASTE, _T("%") NPRIs _T(": specified multiple times, wasting space"),line.gettoken_str(0)); |
| 2554 |
SetInnerString(NLF_UNINST_SUBTEXT, line.gettoken_str(2)); |
| 2555 |
} |
| 2556 |
else { |
| 2557 |
if (cur_page_type != PAGE_UNINSTCONFIRM) { |
| 2558 |
ERROR_MSG(_T("Error: UninstallText can only be used inside PageEx uninstConfirm.\n")); |
| 2559 |
return PS_ERROR; |
| 2560 |
} |
| 2561 |
cur_page->parms[0] = add_string(line.gettoken_str(1)); |
| 2562 |
cur_page->parms[1] = add_string(line.gettoken_str(2)); |
| 2563 |
} |
| 2564 |
SCRIPT_MSG(_T("UninstallText: \"%") NPRIs _T("\" \"%") NPRIs _T("\"\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 2565 |
} |
| 2566 |
return PS_OK; |
| 2567 |
case TOK_UNINSTSUBCAPTION: |
| 2568 |
{ |
| 2569 |
int succ, w=line.gettoken_int(1,&succ); |
| 2570 |
if (!succ || w < 0 || w > 2) PRINTHELP() |
| 2571 |
SetInnerString(NLF_USUBCAPTION_CONFIRM+w,line.gettoken_str(2)); |
| 2572 |
SCRIPT_MSG(_T("UninstSubCaption: page:%d, text=%") NPRIs _T("\n"),w,line.gettoken_str(2)); |
| 2573 |
} |
| 2574 |
return PS_OK; |
| 2575 |
case TOK_WRITEUNINSTALLER: |
| 2576 |
{ |
| 2577 |
if (uninstall_mode) |
| 2578 |
{ |
| 2579 |
ERROR_MSG(_T("WriteUninstaller only valid from install, not from uninstall.\n")); |
| 2580 |
PRINTHELP() |
| 2581 |
} |
| 2582 |
uninstaller_writes_used++; |
| 2583 |
ent.which=EW_WRITEUNINSTALLER; |
| 2584 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 2585 |
tstring full = tstring(_T("$INSTDIR\\")) + tstring(line.gettoken_str(1)); |
| 2586 |
ent.offsets[3]=add_string(full.c_str()); |
| 2587 |
// ent.offsets[1] and ent.offsets[2] are set in CEXEBuild::uninstall_generate() |
| 2588 |
if (!ent.offsets[0]) PRINTHELP() |
| 2589 |
SCRIPT_MSG(_T("WriteUninstaller: \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 2590 |
|
| 2591 |
DefineInnerLangString(NLF_ERR_CREATING); |
| 2592 |
DefineInnerLangString(NLF_CREATED_UNINST); |
| 2593 |
} |
| 2594 |
return add_entry(&ent); |
| 2595 |
#else //! NSIS_CONFIG_UNINSTALL_SUPPORT |
| 2596 |
case TOK_WRITEUNINSTALLER: |
| 2597 |
case TOK_UNINSTCAPTION: |
| 2598 |
case TOK_UNINSTICON: |
| 2599 |
case TOK_UNINSTTEXT: |
| 2600 |
case TOK_UNINSTSUBCAPTION: |
| 2601 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_UNINSTALL_SUPPORT not defined.\n"), line.gettoken_str(0)); |
| 2602 |
return PS_ERROR; |
| 2603 |
#endif |
| 2604 |
|
| 2605 |
// section/function stuff |
| 2606 |
/////////////////////////////////////////////////////////////////////////////// |
| 2607 |
case TOK_SECTION: |
| 2608 |
{ |
| 2609 |
int a = 1, unselected = 0; |
| 2610 |
if (!_tcsicmp(line.gettoken_str(1),_T("/o"))) |
| 2611 |
unselected++, a++; |
| 2612 |
else if (line.getnumtokens() > 3) |
| 2613 |
PRINTHELP(); |
| 2614 |
SCRIPT_MSG(_T("Section: \"%") NPRIs _T("\""),line.gettoken_str(a)); |
| 2615 |
if (line.gettoken_str(a+1)[0]) SCRIPT_MSG(_T(" ->(%") NPRIs _T(")"),line.gettoken_str(a+1)); |
| 2616 |
SCRIPT_MSG(_T("\n")); |
| 2617 |
#ifndef NSIS_CONFIG_UNINSTALL_SUPPORT |
| 2618 |
if (!_tcsicmp(line.gettoken_str(a),_T("uninstall"))) |
| 2619 |
{ |
| 2620 |
ERROR_MSG(_T("Error: Uninstall section declared, no NSIS_CONFIG_UNINSTALL_SUPPORT\n")); |
| 2621 |
return PS_ERROR; |
| 2622 |
} |
| 2623 |
#endif |
| 2624 |
int ret = add_section(line.gettoken_str(a),line.gettoken_str(a+1)); |
| 2625 |
if (PS_OK == ret && unselected) |
| 2626 |
build_cursection->flags &= ~SF_SELECTED; |
| 2627 |
return ret; |
| 2628 |
} |
| 2629 |
case TOK_SECTIONEND: |
| 2630 |
SCRIPT_MSG(_T("SectionEnd\n")); |
| 2631 |
return section_end(); |
| 2632 |
case TOK_SECTIONINSTTYPE: // 0 based |
| 2633 |
case TOK_SECTIONIN: // Legacy 1 based instruction |
| 2634 |
{ |
| 2635 |
int zerobased = which_token == TOK_SECTIONINSTTYPE, itid, succ; |
| 2636 |
const TCHAR *cmdname = get_commandtoken_name(which_token); |
| 2637 |
SCRIPT_MSG(_T("%") NPRIs _T(": "), cmdname); |
| 2638 |
for (int ti = 0; ++ti < line.getnumtokens();) |
| 2639 |
{ |
| 2640 |
const TCHAR *p = line.gettoken_str(ti); |
| 2641 |
if (!_tcsicmp(p, _T("RO"))) |
| 2642 |
{ |
| 2643 |
if (section_add_flags(SF_RO) != PS_OK) return PS_ERROR; |
| 2644 |
SCRIPT_MSG(_T("[RO] ")); |
| 2645 |
} |
| 2646 |
else |
| 2647 |
{ |
| 2648 |
itid = line.gettoken_int(ti, &succ) - (zerobased ? 0 : 1); |
| 2649 |
if (succ && itid >= 0 && itid < NSIS_MAX_INST_TYPES) |
| 2650 |
{ |
| 2651 |
if (section_add_install_type(1<<itid) != PS_OK) return PS_ERROR; |
| 2652 |
SCRIPT_MSG(_T("[%d] "), itid); |
| 2653 |
} |
| 2654 |
else |
| 2655 |
{ |
| 2656 |
ERROR_MSG(_T("Error: %") NPRIs _T(" %") NPRIs _T(" out of range %d..%d\n"), cmdname, p, 1 - zerobased, NSIS_MAX_INST_TYPES - zerobased); |
| 2657 |
return PS_ERROR; |
| 2658 |
} |
| 2659 |
} |
| 2660 |
} |
| 2661 |
SCRIPT_MSG(_T("\n")); |
| 2662 |
} |
| 2663 |
return PS_OK; |
| 2664 |
case TOK_SECTIONGROUPEND: |
| 2665 |
case TOK_SUBSECTIONEND: |
| 2666 |
case TOK_SECTIONGROUP: |
| 2667 |
case TOK_SUBSECTION: |
| 2668 |
{ |
| 2669 |
TCHAR buf[1024]; |
| 2670 |
int a = 1, ex = 0; |
| 2671 |
if (!_tcsicmp(line.gettoken_str(1),_T("/e"))) ex = 1, a++; |
| 2672 |
|
| 2673 |
wsprintf(buf,_T("\x1F%") NPRIs,line.gettoken_str(a)); |
| 2674 |
if (which_token == TOK_SECTIONGROUP || which_token == TOK_SUBSECTION) |
| 2675 |
{ |
| 2676 |
TCHAR *s = line.gettoken_str(a); |
| 2677 |
if (!s[0] || (!_tcsicmp(s, _T("un.")) && !s[3])) |
| 2678 |
PRINTHELP(); |
| 2679 |
} |
| 2680 |
|
| 2681 |
SCRIPT_MSG(_T("%") NPRIs _T(" %") NPRIs,line.gettoken_str(0),line.gettoken_str(a)); |
| 2682 |
if (line.gettoken_str(a+1)[0]) SCRIPT_MSG(_T(" ->(%") NPRIs _T(")"),line.gettoken_str(a+1)); |
| 2683 |
SCRIPT_MSG(_T("\n")); |
| 2684 |
return add_section(buf,line.gettoken_str(a+1),ex); |
| 2685 |
} |
| 2686 |
case TOK_FUNCTION: |
| 2687 |
if (!line.gettoken_str(1)[0]) PRINTHELP() |
| 2688 |
if (line.gettoken_str(1)[0]==_T(':') || line.gettoken_str(1)[0]==_T('/')) |
| 2689 |
{ |
| 2690 |
ERROR_MSG(_T("Function: function name cannot begin with : or /.\n")); |
| 2691 |
PRINTHELP() |
| 2692 |
} |
| 2693 |
SCRIPT_MSG(_T("Function: \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 2694 |
#ifndef NSIS_CONFIG_UNINSTALL_SUPPORT |
| 2695 |
if (!_tcsnicmp(line.gettoken_str(1),_T("un."),3)) |
| 2696 |
{ |
| 2697 |
ERROR_MSG(_T("Error: Uninstall function declared, no NSIS_CONFIG_UNINSTALL_SUPPORT\n")); |
| 2698 |
return PS_ERROR; |
| 2699 |
} |
| 2700 |
#endif |
| 2701 |
return add_function(line.gettoken_str(1)); |
| 2702 |
case TOK_FUNCTIONEND: |
| 2703 |
SCRIPT_MSG(_T("FunctionEnd\n")); |
| 2704 |
return function_end(); |
| 2705 |
|
| 2706 |
// flag setters |
| 2707 |
/////////////////////////////////////////////////////////////////////////////// |
| 2708 |
case TOK_ALLOWSKIPFILES: |
| 2709 |
build_allowskipfiles=line.gettoken_enum(1,_T("off\0on\0")); |
| 2710 |
if (build_allowskipfiles==-1) PRINTHELP() |
| 2711 |
SCRIPT_MSG(_T("AllowSkipFiles: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 2712 |
return PS_OK; |
| 2713 |
case TOK_SETDATESAVE: |
| 2714 |
build_datesave=line.gettoken_enum(1,_T("off\0on\0")); |
| 2715 |
if (build_datesave==-1) PRINTHELP() |
| 2716 |
SCRIPT_MSG(_T("SetDateSave: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 2717 |
return PS_OK; |
| 2718 |
case TOK_SETOVERWRITE: |
| 2719 |
{ |
| 2720 |
int k=line.gettoken_enum(1,_T("on\0off\0try\0ifnewer\0ifdiff\0lastused\0")); |
| 2721 |
if (k==-1) PRINTHELP() |
| 2722 |
if (k==5) |
| 2723 |
k=build_overwrite, build_overwrite=build_last_overwrite, build_last_overwrite=k; |
| 2724 |
else |
| 2725 |
build_last_overwrite=build_overwrite, build_overwrite=k; |
| 2726 |
SCRIPT_MSG(_T("SetOverwrite: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 2727 |
} |
| 2728 |
return PS_OK; |
| 2729 |
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT |
| 2730 |
case TOK_SETPLUGINUNLOAD: |
| 2731 |
build_plugin_unload=line.gettoken_enum(1,_T("manual\0alwaysoff\0")); |
| 2732 |
if (build_plugin_unload==-1) PRINTHELP() |
| 2733 |
SCRIPT_MSG(_T("SetPluginUnload: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 2734 |
return PS_OK; |
| 2735 |
#endif //~ NSIS_CONFIG_PLUGIN_SUPPORT |
| 2736 |
case TOK_SETCOMPRESS: |
| 2737 |
build_compress=line.gettoken_enum(1,_T("off\0auto\0force\0")); |
| 2738 |
if (build_compress==-1) PRINTHELP() |
| 2739 |
if (build_compress==0 && build_compress_whole) |
| 2740 |
warning_fl(DW_COMP_WHOLE_IGNORE_OFF, _T("'SetCompress off' encountered, and in whole compression mode. Effectively ignored.")); |
| 2741 |
SCRIPT_MSG(_T("SetCompress: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 2742 |
return PS_OK; |
| 2743 |
case TOK_DBOPTIMIZE: |
| 2744 |
build_optimize_datablock=line.gettoken_enum(1,_T("off\0on\0")); |
| 2745 |
if (build_optimize_datablock==-1) PRINTHELP() |
| 2746 |
SCRIPT_MSG(_T("SetDatablockOptimize: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 2747 |
return PS_OK; |
| 2748 |
case TOK_FILEBUFSIZE: |
| 2749 |
build_filebuflen=line.gettoken_int(1); |
| 2750 |
build_filebuflen<<=20; |
| 2751 |
if (build_filebuflen<=0) |
| 2752 |
{ |
| 2753 |
ERROR_MSG(_T("Error: FileBufSize: invalid buffer size -- %d\n"),build_filebuflen); |
| 2754 |
return PS_ERROR; |
| 2755 |
} |
| 2756 |
SCRIPT_MSG(_T("FileBufSize: %") NPRIs _T("mb (%d bytes)\n"),line.gettoken_str(1),build_filebuflen); |
| 2757 |
return PS_OK; |
| 2758 |
#ifdef NSIS_CONFIG_COMPRESSION_SUPPORT |
| 2759 |
case TOK_SETCOMPRESSIONLEVEL: |
| 2760 |
{ |
| 2761 |
if (compressor == &lzma_compressor) |
| 2762 |
warning_fl(DW_COMP_LEVEL_IGNORE, _T("SetCompressionLevel: compressor is set to LZMA. Effectively ignored.")); |
| 2763 |
if (build_compressor_set && build_compress_whole) |
| 2764 |
warning_fl(DW_COMP_LEVEL_IGNORE, _T("SetCompressionLevel: data already compressed in compress whole mode. Effectively ignored.")); |
| 2765 |
|
| 2766 |
int s; |
| 2767 |
build_compress_level=line.gettoken_int(1,&s); |
| 2768 |
if (!s || build_compress_level < 0 || build_compress_level > 9) PRINTHELP(); |
| 2769 |
SCRIPT_MSG(_T("SetCompressionLevel: %u\n"), build_compress_level); |
| 2770 |
} |
| 2771 |
return PS_OK; |
| 2772 |
case TOK_SETCOMPRESSORDICTSIZE: |
| 2773 |
{ |
| 2774 |
if (compressor != &lzma_compressor) |
| 2775 |
warning_fl(DW_COMP_DICT_IGNORE, _T("SetCompressorDictSize: compressor is not set to LZMA. Effectively ignored.")); |
| 2776 |
if (build_compressor_set && build_compress_whole) |
| 2777 |
warning_fl(DW_COMP_DICT_IGNORE, _T("SetCompressorDictSize: data already compressed in compress whole mode. Effectively ignored.")); |
| 2778 |
|
| 2779 |
int s; |
| 2780 |
build_compress_dict_size=line.gettoken_int(1,&s); |
| 2781 |
if (!s) PRINTHELP(); |
| 2782 |
SCRIPT_MSG(_T("SetCompressorDictSize: %u mb\n"), build_compress_dict_size); |
| 2783 |
build_compress_dict_size <<= 20; |
| 2784 |
} |
| 2785 |
return PS_OK; |
| 2786 |
#else |
| 2787 |
case TOK_SETCOMPRESSIONLEVEL: |
| 2788 |
case TOK_SETCOMPRESSORDICTSIZE: |
| 2789 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_COMPRESSION_SUPPORT not defined.\n"), line.gettoken_str(0)); |
| 2790 |
return PS_ERROR; |
| 2791 |
#endif //~ NSIS_CONFIG_COMPRESSION_SUPPORT |
| 2792 |
case TOK_ADDSIZE: |
| 2793 |
{ |
| 2794 |
int succ, size_kb=line.gettoken_int(1,&succ); |
| 2795 |
if (!succ) PRINTHELP() |
| 2796 |
SCRIPT_MSG(_T("AddSize: %d kb\n"),size_kb); |
| 2797 |
section_add_size_kb(size_kb); |
| 2798 |
} |
| 2799 |
return PS_OK; |
| 2800 |
case TOK_SUBCAPTION: |
| 2801 |
{ |
| 2802 |
int succ, w=line.gettoken_int(1,&succ); |
| 2803 |
if (!succ || w < 0 || w > 4) PRINTHELP() |
| 2804 |
SetInnerString(NLF_SUBCAPTION_LICENSE+w,line.gettoken_str(2)); |
| 2805 |
SCRIPT_MSG(_T("SubCaption: page:%d, text=%") NPRIs _T("\n"),w,line.gettoken_str(2)); |
| 2806 |
} |
| 2807 |
return PS_OK; |
| 2808 |
case TOK_FILEERRORTEXT: |
| 2809 |
#ifdef NSIS_SUPPORT_FILE |
| 2810 |
{ |
| 2811 |
SetInnerString(NLF_FILE_ERROR,line.gettoken_str(1)); |
| 2812 |
SetInnerString(NLF_FILE_ERROR_NOIGNORE,line.gettoken_str(2)); |
| 2813 |
SCRIPT_MSG(_T("FileErrorText: \"%") NPRIs _T("\" \"%") NPRIs _T("\"\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 2814 |
} |
| 2815 |
return PS_OK; |
| 2816 |
#else |
| 2817 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_FILE not defined.\n"), line.gettoken_str(0)); |
| 2818 |
return PS_ERROR; |
| 2819 |
#endif |
| 2820 |
case TOK_BRANDINGTEXT: |
| 2821 |
{ |
| 2822 |
int a = 1, trim = 0; |
| 2823 |
while (line.gettoken_str(a)[0] == _T('/')) { |
| 2824 |
if (!_tcsnicmp(line.gettoken_str(a),_T("/TRIM"),5)) { |
| 2825 |
if (!_tcsicmp(line.gettoken_str(a)+5,_T("LEFT"))) trim = 1; |
| 2826 |
else if (!_tcsicmp(line.gettoken_str(a)+5,_T("RIGHT"))) trim = 2; |
| 2827 |
else if (!_tcsicmp(line.gettoken_str(a)+5,_T("CENTER"))) trim = 3; |
| 2828 |
else PRINTHELP(); |
| 2829 |
a++; |
| 2830 |
} |
| 2831 |
else break; |
| 2832 |
} |
| 2833 |
if (line.getnumtokens()!=a+1 && !trim) PRINTHELP(); |
| 2834 |
if (line.getnumtokens()==a+1) |
| 2835 |
SetInnerString(NLF_BRANDING,line.gettoken_str(a)); |
| 2836 |
#ifdef _WIN32 |
| 2837 |
if (trim) try { |
| 2838 |
init_res_editor(); |
| 2839 |
|
| 2840 |
BYTE* dlg = res_editor->GetResource(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG); |
| 2841 |
CDialogTemplate td(dlg,build_unicode,uDefCodePage); |
| 2842 |
res_editor->FreeResource(dlg); |
| 2843 |
|
| 2844 |
if (trim) { |
| 2845 |
TCHAR str[512]; |
| 2846 |
if (line.getnumtokens()==a+1 && line.gettoken_str(a)[0]) |
| 2847 |
_tcscpy(str, line.gettoken_str(a)); |
| 2848 |
else |
| 2849 |
wsprintf(str, _T("Nullsoft Install System %") NPRIs, NSIS_VERSION); |
| 2850 |
|
| 2851 |
short old_width = td.GetItem(IDC_VERSTR)->sWidth; |
| 2852 |
switch (trim) { |
| 2853 |
case 1: td.LTrimToString(IDC_VERSTR, str, 4); break; |
| 2854 |
case 2: td.RTrimToString(IDC_VERSTR, str, 4); break; |
| 2855 |
case 3: td.CTrimToString(IDC_VERSTR, str, 4); break; |
| 2856 |
} |
| 2857 |
if (td.GetItem(IDC_VERSTR)->sWidth > old_width) |
| 2858 |
warning_fl(DW_ATTRIBUTE_OVERLONGSTRING, _T("BrandingText: \"%") NPRIs _T("\" is too long, trimming has expanded the label"), str); |
| 2859 |
} |
| 2860 |
DWORD dwSize; |
| 2861 |
dlg = td.Save(dwSize); |
| 2862 |
res_editor->UpdateResource(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG, dlg, dwSize); |
| 2863 |
td.FreeSavedTemplate(dlg); |
| 2864 |
} |
| 2865 |
catch (exception& err) { |
| 2866 |
ERROR_MSG(_T("Error while trimming branding text control: %") NPRIs _T("\n"), CtoTStrParam(err.what())); |
| 2867 |
return PS_ERROR; |
| 2868 |
} |
| 2869 |
#else |
| 2870 |
if (trim) |
| 2871 |
{ |
| 2872 |
ERROR_MSG(_T("Error: BrandingText /TRIM* is disabled for non Win32 platforms.\n")); |
| 2873 |
return PS_ERROR; |
| 2874 |
} |
| 2875 |
#endif |
| 2876 |
SCRIPT_MSG(_T("BrandingText: \"%") NPRIs _T("\"\n"),line.gettoken_str(a)); |
| 2877 |
} |
| 2878 |
return PS_OK; |
| 2879 |
case TOK_MISCBUTTONTEXT: |
| 2880 |
{ |
| 2881 |
SetInnerString(NLF_BTN_BACK,line.gettoken_str(1)); |
| 2882 |
SetInnerString(NLF_BTN_NEXT,line.gettoken_str(2)); |
| 2883 |
SetInnerString(NLF_BTN_CANCEL,line.gettoken_str(3)); |
| 2884 |
SetInnerString(NLF_BTN_CLOSE,line.gettoken_str(4)); |
| 2885 |
SCRIPT_MSG(_T("MiscButtonText: back=\"%") NPRIs _T("\" next=\"%") NPRIs _T("\" cancel=\"%") NPRIs _T("\" close=\"%") NPRIs _T("\"\n"),line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(4)); |
| 2886 |
} |
| 2887 |
return PS_OK; |
| 2888 |
case TOK_SPACETEXTS: |
| 2889 |
{ |
| 2890 |
if (!_tcsicmp(line.gettoken_str(1), _T("none"))) { |
| 2891 |
no_space_texts=true; |
| 2892 |
SCRIPT_MSG(_T("SpaceTexts: none\n")); |
| 2893 |
} |
| 2894 |
else { |
| 2895 |
no_space_texts=false; |
| 2896 |
SetInnerString(NLF_SPACE_REQ,line.gettoken_str(1)); |
| 2897 |
SetInnerString(NLF_SPACE_AVAIL,line.gettoken_str(2)); |
| 2898 |
SCRIPT_MSG(_T("SpaceTexts: required=\"%") NPRIs _T("\" available=\"%") NPRIs _T("\"\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 2899 |
} |
| 2900 |
} |
| 2901 |
return PS_OK; |
| 2902 |
case TOK_INSTBUTTONTEXT: |
| 2903 |
{ |
| 2904 |
SetInnerString(NLF_BTN_INSTALL,line.gettoken_str(1)); |
| 2905 |
SCRIPT_MSG(_T("InstallButtonText: \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 2906 |
} |
| 2907 |
return PS_OK; |
| 2908 |
case TOK_DETAILSBUTTONTEXT: |
| 2909 |
{ |
| 2910 |
if (!cur_page) { |
| 2911 |
if (SetInnerString(NLF_BTN_DETAILS,line.gettoken_str(1)) == PS_WARNING) |
| 2912 |
warning_fl(DW_INNERSTRING_MULTISETWASTE, _T("%") NPRIs _T(": specified multiple times, wasting space"),line.gettoken_str(0)); |
| 2913 |
} |
| 2914 |
else { |
| 2915 |
if (cur_page_type != PAGE_INSTFILES) { |
| 2916 |
ERROR_MSG(_T("Error: DetailsButtonText can only be used inside PageEx instfiles.\n")); |
| 2917 |
return PS_ERROR; |
| 2918 |
} |
| 2919 |
cur_page->parms[1] = add_string(line.gettoken_str(1)); |
| 2920 |
} |
| 2921 |
SCRIPT_MSG(_T("DetailsButtonText: \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 2922 |
} |
| 2923 |
return PS_OK; |
| 2924 |
case TOK_COMPLETEDTEXT: |
| 2925 |
{ |
| 2926 |
if (!cur_page) { |
| 2927 |
if (SetInnerString(NLF_COMPLETED,line.gettoken_str(1)) == PS_WARNING) |
| 2928 |
warning_fl(DW_INNERSTRING_MULTISETWASTE, _T("%") NPRIs _T(": specified multiple times, wasting space"),line.gettoken_str(0)); |
| 2929 |
} |
| 2930 |
else { |
| 2931 |
if (cur_page_type != PAGE_INSTFILES) { |
| 2932 |
ERROR_MSG(_T("Error: CompletedText can only be used inside PageEx instfiles.\n")); |
| 2933 |
return PS_ERROR; |
| 2934 |
} |
| 2935 |
cur_page->parms[2] = add_string(line.gettoken_str(1)); |
| 2936 |
} |
| 2937 |
SCRIPT_MSG(_T("CompletedText: \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 2938 |
} |
| 2939 |
return PS_OK; |
| 2940 |
case TOK_UNINSTBUTTONTEXT: |
| 2941 |
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT |
| 2942 |
{ |
| 2943 |
SetInnerString(NLF_BTN_UNINSTALL,line.gettoken_str(1)); |
| 2944 |
SCRIPT_MSG(_T("UninstButtonText: \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 2945 |
} |
| 2946 |
return PS_OK; |
| 2947 |
#else |
| 2948 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_UNINSTALL_SUPPORT not defined.\n"), line.gettoken_str(0)); |
| 2949 |
return PS_ERROR; |
| 2950 |
#endif |
| 2951 |
|
| 2952 |
// instructions |
| 2953 |
/////////////////////////////////////////////////////////////////////////////// |
| 2954 |
case TOK_NOP: |
| 2955 |
SCRIPT_MSG(_T("Nop\n")); |
| 2956 |
ent.which=EW_NOP; |
| 2957 |
return add_entry(&ent); |
| 2958 |
case TOK_GOTO: |
| 2959 |
ent.which=EW_NOP; |
| 2960 |
if (process_jump(line,1,&ent.offsets[0])) PRINTHELP() |
| 2961 |
SCRIPT_MSG(_T("Goto: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 2962 |
return add_entry(&ent); |
| 2963 |
case TOK_GETREGVIEW: |
| 2964 |
return add_flag_instruction_entry(which_token, EW_GETFLAG, line, FLAG_OFFSET(alter_reg_view)); |
| 2965 |
case TOK_SETREGVIEW: |
| 2966 |
{ |
| 2967 |
ent.which=EW_SETFLAG; |
| 2968 |
ent.offsets[0]=FLAG_OFFSET(alter_reg_view); |
| 2969 |
int k=line.gettoken_enum(1,_T("32\0") _T("64\0default\0lastused\0")); |
| 2970 |
if (k == 0) ent.offsets[1]=add_intstring(is_target_64bit() ? KEY_WOW64_32KEY : 0); // 32 |
| 2971 |
else if (k == 1) ent.offsets[1]=add_intstring(is_target_64bit() ? 0 : KEY_WOW64_64KEY); // 64 |
| 2972 |
else if (k == 2) ent.offsets[1]=add_intstring(0); // default |
| 2973 |
else if (k == 3) ent.offsets[2]=1; // last used |
| 2974 |
else PRINTHELP() |
| 2975 |
SCRIPT_MSG(_T("SetRegView: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 2976 |
} |
| 2977 |
return add_entry(&ent); |
| 2978 |
case TOK_IFALTREGVIEW: |
| 2979 |
return add_flag_instruction_entry(which_token, EW_IFFLAG, line, FLAG_OFFSET(alter_reg_view), ~0); //new value mask - keep flag |
| 2980 |
case TOK_GETSHELLVARCONTEXT: |
| 2981 |
return add_flag_instruction_entry(which_token, EW_GETFLAG, line, FLAG_OFFSET(all_user_var)); |
| 2982 |
case TOK_SETSHELLVARCONTEXT: |
| 2983 |
ent.offsets[1] = line.gettoken_enum(1,_T("current\0all\0lastused\0")); |
| 2984 |
if (ent.offsets[1] < 0 ) PRINTHELP() |
| 2985 |
return add_flag_instruction_entry(which_token, EW_SETFLAG, line, FLAG_OFFSET(all_user_var), ent.offsets[1] != 2 ? add_intstring(ent.offsets[1]) : AFIE_LASTUSED); |
| 2986 |
case TOK_IFSHELLVARCONTEXTALL: |
| 2987 |
return add_flag_instruction_entry(which_token, EW_IFFLAG, line, FLAG_OFFSET(all_user_var), ~0); //new value mask - keep flag |
| 2988 |
case TOK_RET: |
| 2989 |
SCRIPT_MSG(_T("Return\n")); |
| 2990 |
ent.which=EW_RET; |
| 2991 |
return add_entry(&ent); |
| 2992 |
case TOK_CALL: |
| 2993 |
if (!line.gettoken_str(1)[0] || (line.gettoken_str(1)[0]==_T(':') && !line.gettoken_str(1)[1] )) PRINTHELP() |
| 2994 |
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT |
| 2995 |
if (uninstall_mode && _tcsnicmp(line.gettoken_str(1),_T("un."),3) |
| 2996 |
&& (GetUserVarIndex(line,1) < 0) && line.gettoken_str(1)[0]!=_T(':')) |
| 2997 |
{ |
| 2998 |
ERROR_MSG(_T("Call must be used with function names starting with \"un.\" in the uninstall section.\n")); |
| 2999 |
PRINTHELP() |
| 3000 |
} |
| 3001 |
if (!uninstall_mode && !_tcsnicmp(line.gettoken_str(1),_T("un."),3)) |
| 3002 |
{ |
| 3003 |
ERROR_MSG(_T("Call must not be used with functions starting with \"un.\" in the non-uninstall sections.\n")); |
| 3004 |
PRINTHELP() |
| 3005 |
} |
| 3006 |
#endif |
| 3007 |
ent.which=EW_CALL; |
| 3008 |
ent.offsets[1]=0; |
| 3009 |
{ |
| 3010 |
int v; |
| 3011 |
if ((v=GetUserVarIndex(line, 1))>=0) |
| 3012 |
{ |
| 3013 |
ent.offsets[0]=-v-2; |
| 3014 |
} |
| 3015 |
else |
| 3016 |
{ |
| 3017 |
if (line.gettoken_str(1)[0] == _T(':')) |
| 3018 |
{ |
| 3019 |
ent.offsets[1]=1; |
| 3020 |
ent.offsets[0]=ns_label.add(line.gettoken_str(1)+1,0); |
| 3021 |
} |
| 3022 |
else ent.offsets[0]=ns_func.add(line.gettoken_str(1),0); |
| 3023 |
} |
| 3024 |
} |
| 3025 |
SCRIPT_MSG(_T("Call \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 3026 |
return add_entry(&ent); |
| 3027 |
case TOK_SETOUTPATH: |
| 3028 |
{ |
| 3029 |
const TCHAR *op=line.gettoken_str(1), *cmdname=_T("SetOutPath"); |
| 3030 |
if (!_tcscmp(op,_T("-"))) op=_T("$INSTDIR"); |
| 3031 |
SCRIPT_MSG(_T("%") NPRIs _T(": \"%") NPRIs _T("\"\n"),cmdname,op); |
| 3032 |
ent.which=EW_CREATEDIR; |
| 3033 |
ent.offsets[0]=add_string(op); |
| 3034 |
ent.offsets[1]=1; |
| 3035 |
DefineInnerLangString(NLF_OUTPUT_DIR); |
| 3036 |
} |
| 3037 |
return add_entry(&ent); |
| 3038 |
case TOK_CREATEDIR: |
| 3039 |
{ |
| 3040 |
const TCHAR *cmdname=_T("CreateDirectory"); |
| 3041 |
TCHAR out_path[NSIS_MAX_STRLEN], *p=line.gettoken_str(1); |
| 3042 |
bool badpath=IsWindowsPathRelative(p) && _T('$') != *p; // ExeHead will have to deal with expanded $variables... |
| 3043 |
if (badpath) |
| 3044 |
ERROR_MSG(_T("%") NPRIs _T(": Relative paths not supported\n"),cmdname); |
| 3045 |
else |
| 3046 |
{ |
| 3047 |
my_strncpy(out_path,p,COUNTOF(out_path)); |
| 3048 |
p=CharPrev(out_path,out_path+_tcslen(out_path)); |
| 3049 |
if (IsAgnosticPathSeparator(*p)) *p=0; // remove trailing slash |
| 3050 |
} |
| 3051 |
if (badpath || !*out_path) PRINTHELP() |
| 3052 |
SCRIPT_MSG(_T("%") NPRIs _T(": \"%") NPRIs _T("\"\n"),cmdname,out_path); |
| 3053 |
ent.which=EW_CREATEDIR; |
| 3054 |
ent.offsets[0]=add_string(out_path); |
| 3055 |
DefineInnerLangString(NLF_CREATE_DIR); |
| 3056 |
} |
| 3057 |
return add_entry(&ent); |
| 3058 |
case TOK_EXEC: |
| 3059 |
case TOK_EXECWAIT: |
| 3060 |
#ifdef NSIS_SUPPORT_EXECUTE |
| 3061 |
ent.which=EW_EXECUTE; |
| 3062 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 3063 |
ent.offsets[2]=0; |
| 3064 |
if (which_token == TOK_EXECWAIT) |
| 3065 |
{ |
| 3066 |
ent.offsets[2]=1; |
| 3067 |
ent.offsets[1]=GetUserVarIndex(line, 2); |
| 3068 |
if (line.gettoken_str(2)[0] && ent.offsets[1]<0) PRINTHELP() |
| 3069 |
} |
| 3070 |
SCRIPT_MSG(_T("%") NPRIs _T(": \"%") NPRIs _T("\" (->%") NPRIs _T(")\n"),ent.offsets[2]?_T("ExecWait"):_T("Exec"),line.gettoken_str(1),line.gettoken_str(2)); |
| 3071 |
|
| 3072 |
DefineInnerLangString(NLF_EXEC); |
| 3073 |
return add_entry(&ent); |
| 3074 |
#else |
| 3075 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_EXECUTE not defined.\n"), line.gettoken_str(0)); |
| 3076 |
return PS_ERROR; |
| 3077 |
#endif //~ NSIS_SUPPORT_EXECUTE |
| 3078 |
case TOK_EXECSHELL: |
| 3079 |
case TOK_EXECSHELLWAIT: |
| 3080 |
#ifdef NSIS_SUPPORT_SHELLEXECUTE |
| 3081 |
{ |
| 3082 |
UINT to=0, xflags=0; |
| 3083 |
static const TCHAR*fn=_T("/INVOKEIDLIST\0/CONNECTNETDRV\0/DOENVSUBST\0/NOIDLIST\0/NOCONSOLE\0/NOZONECHECKS\0/WAITFORINPUTIDLE\0/LOGUSAGE\0/ASYNCOK\0/ALLOWERRORUI\0"); |
| 3084 |
static const UINT fv[]={ 0x0000000C, 0x00000080, 0x00000200, 0x00001000,0x00008000, 0x00800000, 0x02000000, 0x04000000,0x100000, 0x0100 }; |
| 3085 |
for (int k;;) if ((k = line.gettoken_enum(to+1,fn)) < 0) { if (line.gettoken_str(to+1)[0]=='/') PRINTHELP(); break; } else xflags|=fv[k], to++; |
| 3086 |
const TCHAR *verb=line.gettoken_str(to+1), *file=line.gettoken_str(to+2), *params=line.gettoken_str(to+3), *cnam=get_commandtoken_name(which_token); |
| 3087 |
ent.which=EW_SHELLEXEC; |
| 3088 |
ent.offsets[0]=add_string(verb), ent.offsets[1]=add_string(file); |
| 3089 |
ent.offsets[2]=add_string(params), ent.offsets[3]=SW_SHOWNORMAL; |
| 3090 |
ent.offsets[4]=SEE_MASK_FLAG_DDEWAIT|((xflags&0x0100)?0:SEE_MASK_FLAG_NO_UI)|xflags|(which_token==TOK_EXECSHELLWAIT ? SEE_MASK_NOCLOSEPROCESS : 0); |
| 3091 |
if (line.getnumtokens()-to > 4) |
| 3092 |
{ |
| 3093 |
int tab[8]={SW_SHOWDEFAULT,SW_SHOWNORMAL,SW_SHOWMAXIMIZED,SW_SHOWMINIMIZED,SW_HIDE,SW_SHOW,SW_SHOWNA,SW_SHOWMINNOACTIVE}; |
| 3094 |
int a=line.gettoken_enum(to+4,_T("SW_SHOWDEFAULT\0SW_SHOWNORMAL\0SW_SHOWMAXIMIZED\0SW_SHOWMINIMIZED\0SW_HIDE\0SW_SHOW\0SW_SHOWNA\0SW_SHOWMINNOACTIVE\0")); |
| 3095 |
if (a >= 0) ent.offsets[3]=tab[a]; else PRINTHELP() |
| 3096 |
} |
| 3097 |
tstring detail=tstring(verb) + (*verb ? _T(" ") : _T("")) + tstring(file); |
| 3098 |
ent.offsets[5]=add_string(detail.c_str()); |
| 3099 |
SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T(": \"%") NPRIs _T("\" \"%") NPRIs _T("\" %") NPRIs _T("\n"),cnam,verb,file,params,line.gettoken_str(to+4)); |
| 3100 |
DefineInnerLangString(NLF_EXEC_SHELL); |
| 3101 |
} |
| 3102 |
return add_entry(&ent); |
| 3103 |
#else |
| 3104 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_SHELLEXECUTE not defined.\n"), line.gettoken_str(0)); |
| 3105 |
return PS_ERROR; |
| 3106 |
#endif //~ NSIS_SUPPORT_SHELLEXECUTE |
| 3107 |
case TOK_CALLINSTDLL: |
| 3108 |
case TOK_REGDLL: |
| 3109 |
case TOK_UNREGDLL: |
| 3110 |
#ifndef NSIS_SUPPORT_ACTIVEXREG |
| 3111 |
ERROR_MSG(_T("%") NPRIs _T(": support not compiled in (NSIS_SUPPORT_ACTIVEXREG)\n"),line.gettoken_str(0)); |
| 3112 |
return PS_ERROR; |
| 3113 |
#else // NSIS_SUPPORT_ACTIVEXREG |
| 3114 |
ent.which=EW_REGISTERDLL; |
| 3115 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 3116 |
if (which_token == TOK_UNREGDLL) |
| 3117 |
{ |
| 3118 |
ent.offsets[1]=add_asciistring(_T("DllUnregisterServer")); |
| 3119 |
ent.offsets[2]=DefineInnerLangString(NLF_UNREGISTERING); |
| 3120 |
} |
| 3121 |
else if (which_token == TOK_CALLINSTDLL) |
| 3122 |
{ |
| 3123 |
int a = 2; |
| 3124 |
if (!_tcsicmp(line.gettoken_str(a), _T("/NOUNLOAD"))) { |
| 3125 |
ent.offsets[3]=1; |
| 3126 |
a++; |
| 3127 |
} |
| 3128 |
if (a+1 != line.getnumtokens()) PRINTHELP(); |
| 3129 |
ent.offsets[1]=add_string(line.gettoken_str(a)); |
| 3130 |
if (!ent.offsets[1]) PRINTHELP() |
| 3131 |
ent.offsets[2]=0; |
| 3132 |
} |
| 3133 |
else // Register DLL |
| 3134 |
{ |
| 3135 |
ent.offsets[1] = add_string(line.gettoken_str(2)); |
| 3136 |
if (!ent.offsets[1]) ent.offsets[1]=add_asciistring(_T("DllRegisterServer")); |
| 3137 |
ent.offsets[2]=DefineInnerLangString(NLF_REGISTERING); |
| 3138 |
} |
| 3139 |
|
| 3140 |
SCRIPT_MSG(_T("%") NPRIs _T(": \"%") NPRIs _T("\" %") NPRIs _T("\n"),line.gettoken_str(0),line.gettoken_str(1), line.gettoken_str(ent.offsets[3]?3:2)); |
| 3141 |
DefineInnerLangString(NLF_SYMBOL_NOT_FOUND); |
| 3142 |
DefineInnerLangString(NLF_COULD_NOT_LOAD); |
| 3143 |
DefineInnerLangString(NLF_NO_OLE); |
| 3144 |
// not used anywhere - DefineInnerLangString(NLF_ERR_REG_DLL); |
| 3145 |
return add_entry(&ent); |
| 3146 |
#endif //~ NSIS_SUPPORT_ACTIVEXREG |
| 3147 |
case TOK_RENAME: |
| 3148 |
#ifdef NSIS_SUPPORT_RENAME |
| 3149 |
{ |
| 3150 |
int a=1; |
| 3151 |
ent.which=EW_RENAME; |
| 3152 |
if (!_tcsicmp(line.gettoken_str(1),_T("/REBOOTOK"))) |
| 3153 |
{ |
| 3154 |
ent.offsets[2]=1; |
| 3155 |
a++; |
| 3156 |
#ifndef NSIS_SUPPORT_MOVEONREBOOT |
| 3157 |
ERROR_MSG(_T("Error: /REBOOTOK specified, NSIS_SUPPORT_MOVEONREBOOT not defined\n")); |
| 3158 |
PRINTHELP() |
| 3159 |
#endif |
| 3160 |
} |
| 3161 |
else if (line.gettoken_str(1)[0]==_T('/')) |
| 3162 |
{ |
| 3163 |
a=line.getnumtokens(); // cause usage to go here: |
| 3164 |
} |
| 3165 |
if (line.getnumtokens()!=a+2) PRINTHELP() |
| 3166 |
ent.offsets[0]=add_string(line.gettoken_str(a)); |
| 3167 |
ent.offsets[1]=add_string(line.gettoken_str(a+1)); |
| 3168 |
tstring print = tstring(line.gettoken_str(a)) + _T("->") + tstring(line.gettoken_str(a+1)); |
| 3169 |
ent.offsets[3]=add_string(print.c_str()); |
| 3170 |
SCRIPT_MSG(_T("Rename: %") NPRIs _T("%") NPRIs _T("->%") NPRIs _T("\n"),ent.offsets[2]?_T("/REBOOTOK "):_T(""),line.gettoken_str(a),line.gettoken_str(a+1)); |
| 3171 |
|
| 3172 |
DefineInnerLangString(NLF_RENAME); |
| 3173 |
#ifdef NSIS_SUPPORT_MOVEONREBOOT |
| 3174 |
DefineInnerLangString(NLF_RENAME_ON_REBOOT); |
| 3175 |
#endif |
| 3176 |
} |
| 3177 |
return add_entry(&ent); |
| 3178 |
#else |
| 3179 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_RENAME not defined.\n"), line.gettoken_str(0)); |
| 3180 |
return PS_ERROR; |
| 3181 |
#endif //~ NSIS_SUPPORT_RENAME |
| 3182 |
case TOK_MESSAGEBOX: |
| 3183 |
#ifdef NSIS_SUPPORT_MESSAGEBOX |
| 3184 |
{ |
| 3185 |
#define MBD(x) {x,_T(#x)}, |
| 3186 |
struct { int id; const TCHAR *str; } list[] = { |
| 3187 |
MBD(MB_ABORTRETRYIGNORE) |
| 3188 |
MBD(MB_OK) |
| 3189 |
MBD(MB_OKCANCEL) |
| 3190 |
MBD(MB_RETRYCANCEL) |
| 3191 |
MBD(MB_YESNO) |
| 3192 |
MBD(MB_YESNOCANCEL) |
| 3193 |
MBD(MB_ICONEXCLAMATION) |
| 3194 |
MBD(MB_ICONINFORMATION) |
| 3195 |
MBD(MB_ICONQUESTION) |
| 3196 |
MBD(MB_ICONSTOP) |
| 3197 |
MBD(MB_USERICON) |
| 3198 |
MBD(MB_TOPMOST) |
| 3199 |
MBD(MB_SETFOREGROUND) |
| 3200 |
MBD(MB_RIGHT) |
| 3201 |
MBD(MB_RTLREADING) |
| 3202 |
MBD(MB_DEFBUTTON1) |
| 3203 |
MBD(MB_DEFBUTTON2) |
| 3204 |
MBD(MB_DEFBUTTON3) |
| 3205 |
MBD(MB_DEFBUTTON4) |
| 3206 |
}; |
| 3207 |
#undef MBD |
| 3208 |
int r=0, x; |
| 3209 |
TCHAR *p=line.gettoken_str(1); |
| 3210 |
while (*p) |
| 3211 |
{ |
| 3212 |
TCHAR *np=p; |
| 3213 |
while (*np && *np != _T('|')) np++; |
| 3214 |
if (*np) *np++=0; |
| 3215 |
for (x = 0 ; (size_t) x < COUNTOF(list) && _tcsicmp(list[x].str, p); x++); |
| 3216 |
if ((size_t) x < COUNTOF(list)) |
| 3217 |
r |= list[x].id; |
| 3218 |
else |
| 3219 |
PRINTHELP() |
| 3220 |
p=np; |
| 3221 |
} |
| 3222 |
ent.which=EW_MESSAGEBOX; |
| 3223 |
ent.offsets[0]=r; |
| 3224 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 3225 |
static const int rettab[] = { 0,IDABORT,IDCANCEL,IDIGNORE,IDNO,IDOK,IDRETRY,IDYES }; |
| 3226 |
const TCHAR *retstr=_T("0\0IDABORT\0IDCANCEL\0IDIGNORE\0IDNO\0IDOK\0IDRETRY\0IDYES\0"); |
| 3227 |
int a=3; |
| 3228 |
if (line.getnumtokens() > 3) |
| 3229 |
{ |
| 3230 |
if (!_tcsicmp(line.gettoken_str(3),_T("/SD"))) |
| 3231 |
{ |
| 3232 |
int k=line.gettoken_enum(4,retstr); |
| 3233 |
if (k <= 0) PRINTHELP(); |
| 3234 |
ent.offsets[0] |= rettab[k]<<21; |
| 3235 |
a=5; |
| 3236 |
} |
| 3237 |
else if (line.getnumtokens() > 7) |
| 3238 |
PRINTHELP(); |
| 3239 |
|
| 3240 |
if (line.getnumtokens() > a) |
| 3241 |
{ |
| 3242 |
ent.offsets[2]=line.gettoken_enum(a,retstr); |
| 3243 |
if (ent.offsets[2] < 0) |
| 3244 |
PRINTHELP(); |
| 3245 |
ent.offsets[2] = rettab[ent.offsets[2]]; |
| 3246 |
if (process_jump(line,a+1,&ent.offsets[3])) |
| 3247 |
PRINTHELP(); |
| 3248 |
if (line.getnumtokens() > a+2) |
| 3249 |
{ |
| 3250 |
int v=line.gettoken_enum(a+2,retstr); |
| 3251 |
if (v < 0) |
| 3252 |
PRINTHELP(); |
| 3253 |
ent.offsets[4] = rettab[v]; |
| 3254 |
if (process_jump(line,a+3,&ent.offsets[5])) |
| 3255 |
PRINTHELP(); |
| 3256 |
} |
| 3257 |
} |
| 3258 |
} |
| 3259 |
SCRIPT_MSG(_T("MessageBox: %d: \"%") NPRIs _T("\""),r,line.gettoken_str(2)); |
| 3260 |
if (line.getnumtokens()>a+1) SCRIPT_MSG(_T(" (on %") NPRIs _T(" goto %") NPRIs _T(")"),line.gettoken_str(a),line.gettoken_str(a+1)); |
| 3261 |
SCRIPT_MSG(_T("\n")); |
| 3262 |
} |
| 3263 |
return add_entry(&ent); |
| 3264 |
#else |
| 3265 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_MESSAGEBOX not defined.\n"), line.gettoken_str(0)); |
| 3266 |
return PS_ERROR; |
| 3267 |
#endif //~ NSIS_SUPPORT_MESSAGEBOX |
| 3268 |
case TOK_CREATESHORTCUT: |
| 3269 |
#ifdef NSIS_SUPPORT_CREATESHORTCUT |
| 3270 |
{ |
| 3271 |
const TCHAR *cmdnam = line.gettoken_str(0); |
| 3272 |
ent.which=EW_CREATESHORTCUT; |
| 3273 |
int noLnkWorkDir=0, s; |
| 3274 |
if (!_tcsicmp(line.gettoken_str(1),_T("/NoWorkingDir"))) line.eattoken(), noLnkWorkDir++; |
| 3275 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 3276 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 3277 |
ent.offsets[2]=add_string(line.gettoken_str(3)); |
| 3278 |
ent.offsets[3]=add_string(line.gettoken_str(4)); |
| 3279 |
ent.offsets[5]=add_string(line.gettoken_str(8)); |
| 3280 |
ent.offsets[4]=(line.gettoken_int(5,&s) << CS_II_SHIFT) & CS_II_MASK; |
| 3281 |
if (!s || ent.offsets[4] < 0 || ent.offsets[4] > CS_II_MAX) |
| 3282 |
{ |
| 3283 |
if (line.getnumtokens() > 5 && *line.gettoken_str(5)) |
| 3284 |
{ |
| 3285 |
ERROR_MSG(_T("CreateShortcut: cannot interpret icon index\n")); |
| 3286 |
PRINTHELPEX(cmdnam) |
| 3287 |
} |
| 3288 |
} |
| 3289 |
if (noLnkWorkDir) ent.offsets[4] |= CS_NWD; |
| 3290 |
if (line.getnumtokens() > 6 && *line.gettoken_str(6)) |
| 3291 |
{ |
| 3292 |
const int tab[3]={SW_SHOWNORMAL,SW_SHOWMAXIMIZED,SW_SHOWMINNOACTIVE/*SW_SHOWMINIMIZED doesn't work*/}; |
| 3293 |
int a=line.gettoken_enum(6,_T("SW_SHOWNORMAL\0SW_SHOWMAXIMIZED\0SW_SHOWMINIMIZED\0")); |
| 3294 |
if (a < 0 || (tab[a] << CS_SC_SHIFT) & ~CS_SC_MASK) |
| 3295 |
{ |
| 3296 |
ERROR_MSG(_T("CreateShortcut: unknown show mode \"%") NPRIs _T("\"\n"),line.gettoken_str(6)); |
| 3297 |
PRINTHELPEX(cmdnam) |
| 3298 |
} |
| 3299 |
ent.offsets[4] |= tab[a] << CS_SC_SHIFT; |
| 3300 |
} |
| 3301 |
if (line.getnumtokens() > 7) |
| 3302 |
{ |
| 3303 |
TCHAR *s=line.gettoken_str(7), b[255]; |
| 3304 |
for (unsigned int spos=0; (spos <= _tcslen(s)) && (spos <= 255); spos++) |
| 3305 |
b[spos]=_totupper(*(s+spos)); |
| 3306 |
_tcscpy(s,b); |
| 3307 |
if (*s) |
| 3308 |
{ |
| 3309 |
int c=0; |
| 3310 |
if (_tcsstr(s,_T("ALT|"))) ent.offsets[4] |= HOTKEYF_ALT << (CS_HK_SHIFT+8); |
| 3311 |
if (_tcsstr(s,_T("CONTROL|"))) ent.offsets[4] |= HOTKEYF_CONTROL << (CS_HK_SHIFT+8); |
| 3312 |
if (_tcsstr(s,_T("EXT|"))) ent.offsets[4] |= HOTKEYF_EXT << (CS_HK_SHIFT+8); |
| 3313 |
if (_tcsstr(s,_T("SHIFT|"))) ent.offsets[4] |= HOTKEYF_SHIFT << (CS_HK_SHIFT+8); |
| 3314 |
while (_tcsstr(s,_T("|"))) |
| 3315 |
s=_tcsstr(s,_T("|"))+1; |
| 3316 |
if ((s[0] == _T('F')) && (s[1] >= _T('1') && s[1] <= _T('9'))) |
| 3317 |
{ |
| 3318 |
c=VK_F1-1+_ttoi(s+1); |
| 3319 |
if (_ttoi(s+1) < 1 || _ttoi(s+1) > 24) |
| 3320 |
warning_fl(DW_PARSE_LNK_HK, _T("CreateShortcut: F-key \"%") NPRIs _T("\" out of range"),s); |
| 3321 |
} |
| 3322 |
else if (((s[0] >= _T('A') && s[0] <= _T('Z')) || (s[0] >= _T('0') && s[0] <= _T('9'))) && !s[1]) |
| 3323 |
c=s[0]; |
| 3324 |
else |
| 3325 |
{ |
| 3326 |
c=s[0]; |
| 3327 |
warning_fl(DW_PARSE_LNK_HK, _T("CreateShortcut: unrecognized hotkey \"%") NPRIs _T("\""),s); |
| 3328 |
} |
| 3329 |
ent.offsets[4] |= ((c) << CS_HK_SHIFT) & CS_HK_MASK; |
| 3330 |
} |
| 3331 |
} |
| 3332 |
SCRIPT_MSG(_T("CreateShortcut: \"%") NPRIs _T("\"->\"%") NPRIs _T("\" %") NPRIs _T(" icon:%") NPRIs _T(",%d, nwd=%d, showmode=0x%X, hotkey=0x%X, comment=%") NPRIs _T("\n"), |
| 3333 |
line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(4),(ent.offsets[4]>>CS_II_SHIFT)&(CS_II_MASK>>CS_II_SHIFT),!!(ent.offsets[4]&CS_NWD), |
| 3334 |
(ent.offsets[4]>>CS_SC_SHIFT)&(CS_SC_MASK>>CS_SC_SHIFT),(ent.offsets[4]>>CS_HK_SHIFT)&(CS_HK_MASK>>CS_HK_SHIFT),line.gettoken_str(8)); |
| 3335 |
|
| 3336 |
DefineInnerLangString(NLF_CREATE_SHORTCUT); |
| 3337 |
DefineInnerLangString(NLF_ERR_CREATING_SHORTCUT); |
| 3338 |
} |
| 3339 |
return add_entry(&ent); |
| 3340 |
#else |
| 3341 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_CREATESHORTCUT not defined.\n"), line.gettoken_str(0)); |
| 3342 |
return PS_ERROR; |
| 3343 |
#endif //~ NSIS_SUPPORT_CREATESHORTCUT |
| 3344 |
#ifdef NSIS_SUPPORT_HWNDS |
| 3345 |
case TOK_FINDWINDOW: |
| 3346 |
ent.which=EW_FINDWINDOW; |
| 3347 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 3348 |
if (ent.offsets[0] < 0) PRINTHELP() |
| 3349 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 3350 |
ent.offsets[2]=add_string(line.gettoken_str(3)); |
| 3351 |
ent.offsets[3]=add_string(line.gettoken_str(4)); |
| 3352 |
ent.offsets[4]=add_string(line.gettoken_str(5)); |
| 3353 |
SCRIPT_MSG(_T("FindWindow: output=%") NPRIs _T(", class=\"%") NPRIs _T("\", text=\"%") NPRIs _T("\" hwndparent=\"%") NPRIs _T("\" hwndafter=\"%") NPRIs _T("\"\n"), |
| 3354 |
line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(4),line.gettoken_str(5)); |
| 3355 |
return add_entry(&ent); |
| 3356 |
case TOK_SENDMESSAGE: |
| 3357 |
{ |
| 3358 |
ent.which=EW_SENDMESSAGE; |
| 3359 |
if (line.gettoken_str(1)[0] == _T('/') || line.gettoken_str(2)[0] == _T('/') || |
| 3360 |
line.gettoken_str(3)[0] == _T('/') || line.gettoken_str(4)[0] == _T('/')) |
| 3361 |
PRINTHELP() |
| 3362 |
|
| 3363 |
SCRIPT_MSG(_T("SendMessage:")); |
| 3364 |
int a=5; |
| 3365 |
ent.offsets[0]=GetUserVarIndex(line,a); |
| 3366 |
if (ent.offsets[0]>=0) |
| 3367 |
SCRIPT_MSG(_T("(->%") NPRIs _T(")"),line.gettoken_str(a++)); |
| 3368 |
|
| 3369 |
if (!_tcsncicmp(line.gettoken_str(a),_T("/TIMEOUT="),9)) |
| 3370 |
{ |
| 3371 |
ent.offsets[5]|=_ttoi(line.gettoken_str(a++)+9)<<2; |
| 3372 |
SCRIPT_MSG(_T(" (timeout=%d)"),ent.offsets[5]>>2); |
| 3373 |
} |
| 3374 |
|
| 3375 |
if (line.getnumtokens()>a) |
| 3376 |
PRINTHELP() |
| 3377 |
|
| 3378 |
if (!_tcsncmp(line.gettoken_str(3),_T("STR:"),4)) |
| 3379 |
{ |
| 3380 |
ent.offsets[5]|=1; |
| 3381 |
ent.offsets[3]=add_string(line.gettoken_str(3)+4); |
| 3382 |
} |
| 3383 |
else |
| 3384 |
ent.offsets[3]=add_string(line.gettoken_str(3)); |
| 3385 |
if (!_tcsncmp(line.gettoken_str(4),_T("STR:"),4)) |
| 3386 |
{ |
| 3387 |
ent.offsets[5]|=2; |
| 3388 |
ent.offsets[4]=add_string(line.gettoken_str(4)+4); |
| 3389 |
} |
| 3390 |
else |
| 3391 |
ent.offsets[4]=add_string(line.gettoken_str(4)); |
| 3392 |
|
| 3393 |
ent.offsets[1]=add_string(line.gettoken_str(1)); |
| 3394 |
ent.offsets[2]=add_string(line.gettoken_str(2)); |
| 3395 |
SCRIPT_MSG(_T("(%") NPRIs _T(",%") NPRIs _T(",%") NPRIs _T(",%") NPRIs _T(")\n"),line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(4)); |
| 3396 |
} |
| 3397 |
return add_entry(&ent); |
| 3398 |
case TOK_ISWINDOW: |
| 3399 |
ent.which=EW_ISWINDOW; |
| 3400 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 3401 |
if (process_jump(line,2,&ent.offsets[1])|| |
| 3402 |
process_jump(line,3,&ent.offsets[2])) PRINTHELP() |
| 3403 |
SCRIPT_MSG(_T("IsWindow(%") NPRIs _T("): %") NPRIs _T(":%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3)); |
| 3404 |
return add_entry(&ent); |
| 3405 |
#ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT |
| 3406 |
case TOK_GETDLGITEM: |
| 3407 |
ent.which=EW_GETDLGITEM; |
| 3408 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 3409 |
if (ent.offsets[0]<0) PRINTHELP(); |
| 3410 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 3411 |
ent.offsets[2]=add_string(line.gettoken_str(3)); |
| 3412 |
SCRIPT_MSG(_T("GetDlgItem: output=%") NPRIs _T(" dialog=%") NPRIs _T(" item=%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3)); |
| 3413 |
return add_entry(&ent); |
| 3414 |
case TOK_SETCTLCOLORS: |
| 3415 |
{ |
| 3416 |
ent.which=EW_SETCTLCOLORS; |
| 3417 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 3418 |
ctlcolors c={0, }; |
| 3419 |
TCHAR *p; |
| 3420 |
int a = 2, ctok = line.getnumtokens(); |
| 3421 |
if (!_tcsicmp(line.gettoken_str(2),_T("/BRANDING"))) a+=1; |
| 3422 |
if (!_tcsicmp(line.gettoken_str(2),_T("/RESET"))) { if (ctok != 3) return PS_ERROR; else a+=2; } |
| 3423 |
if (a == 2 && ctok == 5) { |
| 3424 |
ERROR_MSG(_T("Error: SetCtlColors expected 3 parameters, got 4\n")); |
| 3425 |
return PS_ERROR; |
| 3426 |
} |
| 3427 |
if (!_tcsicmp(line.gettoken_str(a+1),_T("transparent"))) { |
| 3428 |
c.flags|=CC_BKB, c.lbStyle=BS_NULL, c.bkmode=TRANSPARENT; |
| 3429 |
} |
| 3430 |
else { // Parse background color |
| 3431 |
c.lbStyle=BS_SOLID, c.bkmode=OPAQUE; |
| 3432 |
if (*(p=line.gettoken_str(a+1))) |
| 3433 |
c.flags|=CC_BK|CC_BKB, c.bkc=ParseCtlColor(p, c.flags, CC_BK_SYS); |
| 3434 |
} |
| 3435 |
if (*(p=line.gettoken_str(a))) // Set text color? |
| 3436 |
c.flags|=CC_TEXT, c.text=ParseCtlColor(p, c.flags, CC_TEXT_SYS); |
| 3437 |
if (a == 3) { // Handle /BRANDING |
| 3438 |
c.flags|=CC_BK|CC_BKB; |
| 3439 |
c.lbStyle=BS_NULL; |
| 3440 |
if (!*line.gettoken_str(a+1)) c.bkc=COLOR_BTNFACE, c.flags|=CC_BK_SYS; |
| 3441 |
c.flags|=CC_TEXT; |
| 3442 |
if (!*line.gettoken_str(a)) c.text=COLOR_BTNFACE, c.flags|=CC_TEXT_SYS; |
| 3443 |
c.bkmode=OPAQUE; |
| 3444 |
} |
| 3445 |
if (a == 4) c.bkmode=OPAQUE, c.flags=0, c.bkb = 0; // Experimental and undocumented /RESET, a formal way of doing SetCtlColors $hCtl "" "" |
| 3446 |
assert(sizeof(ctlcolors64) > sizeof(ctlcolors)); |
| 3447 |
int i, l=cur_ctlcolors->getlen()/sizeof(ctlcolors), pad=is_target_64bit()?sizeof(ctlcolors64)-sizeof(ctlcolors):0; |
| 3448 |
for (i=0; i<l; i++) |
| 3449 |
if (!memcmp((ctlcolors*)cur_ctlcolors->get()+i,&c,sizeof(ctlcolors))) { |
| 3450 |
ent.offsets[1]=i*(sizeof(ctlcolors)+pad); |
| 3451 |
break; |
| 3452 |
} |
| 3453 |
if (i>=l) ent.offsets[1]=cur_ctlcolors->add(&c,sizeof(ctlcolors))+(l*pad); |
| 3454 |
SCRIPT_MSG(_T("SetCtlColors: hwnd=%") NPRIs _T(" %") NPRIs _T("text=%") NPRIs _T(" background=%") NPRIs _T("\n"),line.gettoken_str(1),a==2?_T(""):_T("/BRANDING "),line.gettoken_str(a),line.gettoken_str(a+1)); |
| 3455 |
} |
| 3456 |
return add_entry(&ent); |
| 3457 |
case TOK_CREATEFONT: |
| 3458 |
{ |
| 3459 |
ent.which=EW_CREATEFONT; |
| 3460 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 3461 |
if (ent.offsets[0] < 0) PRINTHELP() |
| 3462 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 3463 |
SCRIPT_MSG(_T("CreateFont: output=%") NPRIs _T(" \"%") NPRIs _T("\""),line.gettoken_str(1),line.gettoken_str(2)); |
| 3464 |
int height=0, weight=0, flags=0; |
| 3465 |
for (int i = 3; i < line.getnumtokens(); i++) { |
| 3466 |
TCHAR *tok=line.gettoken_str(i); |
| 3467 |
if (tok[0]=='/') { |
| 3468 |
if (!_tcsicmp(tok,_T("/ITALIC"))) { |
| 3469 |
SCRIPT_MSG(_T(" /ITALIC")); |
| 3470 |
flags|=1; |
| 3471 |
} |
| 3472 |
else if (!_tcsicmp(tok,_T("/UNDERLINE"))) { |
| 3473 |
SCRIPT_MSG(_T(" /UNDERLINE")); |
| 3474 |
flags|=2; |
| 3475 |
} |
| 3476 |
else if (!_tcsicmp(tok,_T("/STRIKE"))) { |
| 3477 |
SCRIPT_MSG(_T(" /STRIKE")); |
| 3478 |
flags|=4; |
| 3479 |
} |
| 3480 |
else { |
| 3481 |
SCRIPT_MSG(_T("\n")); |
| 3482 |
PRINTHELP(); |
| 3483 |
} |
| 3484 |
} |
| 3485 |
else { |
| 3486 |
if (!height) { |
| 3487 |
SCRIPT_MSG(_T(" height=%") NPRIs,tok); |
| 3488 |
height=add_string(tok); |
| 3489 |
} |
| 3490 |
else if (!weight) { |
| 3491 |
SCRIPT_MSG(_T(" weight=%") NPRIs,tok); |
| 3492 |
weight=add_string(tok); |
| 3493 |
} |
| 3494 |
else { |
| 3495 |
SCRIPT_MSG(_T("\n")); |
| 3496 |
PRINTHELP(); |
| 3497 |
} |
| 3498 |
} |
| 3499 |
ent.offsets[2]=height; |
| 3500 |
ent.offsets[3]=weight; |
| 3501 |
ent.offsets[4]=flags; |
| 3502 |
} |
| 3503 |
SCRIPT_MSG(_T("\n")); |
| 3504 |
} |
| 3505 |
return add_entry(&ent); |
| 3506 |
case TOK_ENABLEWINDOW: |
| 3507 |
ent.which=EW_SHOWWINDOW; |
| 3508 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 3509 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 3510 |
ent.offsets[3]=1; |
| 3511 |
SCRIPT_MSG(_T("EnableWindow: handle=%") NPRIs _T(" enable=%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 3512 |
return add_entry(&ent); |
| 3513 |
case TOK_SHOWWINDOW: |
| 3514 |
ent.which=EW_SHOWWINDOW; |
| 3515 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 3516 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 3517 |
SCRIPT_MSG(_T("ShowWindow: handle=%") NPRIs _T(" show state=%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 3518 |
return add_entry(&ent); |
| 3519 |
case TOK_HIDEWINDOW: |
| 3520 |
ent.which=EW_SHOWWINDOW; |
| 3521 |
ent.offsets[0]=add_asciistring(_T("$HWNDPARENT")); |
| 3522 |
ent.offsets[1]=add_asciistring(_T("0")/*SW_HIDE*/); |
| 3523 |
ent.offsets[2]=1; |
| 3524 |
SCRIPT_MSG(_T("HideWindow\n")); |
| 3525 |
return add_entry(&ent); |
| 3526 |
case TOK_BRINGTOFRONT: |
| 3527 |
{ |
| 3528 |
int ret; |
| 3529 |
ent.which=EW_SHOWWINDOW; |
| 3530 |
ent.offsets[0]=add_asciistring(_T("$HWNDPARENT")); |
| 3531 |
ent.offsets[1]=add_asciistring(_T("5")/*SW_SHOW*/); |
| 3532 |
if ((ret = add_entry(&ent)) != PS_OK) return ret; |
| 3533 |
ent.which=EW_BRINGTOFRONT; |
| 3534 |
ent.offsets[0]=0; |
| 3535 |
ent.offsets[1]=0; |
| 3536 |
SCRIPT_MSG(_T("BringToFront\n")); |
| 3537 |
} |
| 3538 |
return add_entry(&ent); |
| 3539 |
#else |
| 3540 |
case TOK_GETDLGITEM: |
| 3541 |
case TOK_SETCTLCOLORS: |
| 3542 |
case TOK_SHOWWINDOW: |
| 3543 |
case TOK_BRINGTOFRONT: |
| 3544 |
case TOK_CREATEFONT: |
| 3545 |
case TOK_HIDEWINDOW: |
| 3546 |
case TOK_ENABLEWINDOW: |
| 3547 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_ENHANCEDUI_SUPPORT not defined.\n"), line.gettoken_str(0)); |
| 3548 |
return PS_ERROR; |
| 3549 |
#endif //~ NSIS_CONFIG_ENHANCEDUI_SUPPORT |
| 3550 |
#else //! NSIS_SUPPORT_HWNDS |
| 3551 |
case TOK_ISWINDOW: |
| 3552 |
case TOK_SENDMESSAGE: |
| 3553 |
case TOK_FINDWINDOW: |
| 3554 |
case TOK_GETDLGITEM: |
| 3555 |
case TOK_SETCTLCOLORS: |
| 3556 |
case TOK_SHOWWINDOW: |
| 3557 |
case TOK_ENABLEWINDOW: |
| 3558 |
case TOK_CREATEFONT: |
| 3559 |
case TOK_HIDEWINDOW: |
| 3560 |
case TOK_BRINGTOFRONT: |
| 3561 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_HWNDS not defined.\n"), line.gettoken_str(0)); |
| 3562 |
return PS_ERROR; |
| 3563 |
#endif //~ NSIS_SUPPORT_HWNDS |
| 3564 |
case TOK_DELETE: |
| 3565 |
#ifdef NSIS_SUPPORT_DELETE |
| 3566 |
{ |
| 3567 |
int a=1; |
| 3568 |
ent.which=EW_DELETEFILE; |
| 3569 |
if (!_tcsicmp(line.gettoken_str(a),_T("/REBOOTOK"))) |
| 3570 |
{ |
| 3571 |
a++; |
| 3572 |
ent.offsets[1]=DEL_REBOOT; |
| 3573 |
#ifndef NSIS_SUPPORT_MOVEONREBOOT |
| 3574 |
ERROR_MSG(_T("Error: /REBOOTOK specified, NSIS_SUPPORT_MOVEONREBOOT not defined\n")); |
| 3575 |
PRINTHELP() |
| 3576 |
#endif |
| 3577 |
} |
| 3578 |
else if (line.gettoken_str(1)[0]==_T('/')) |
| 3579 |
{ |
| 3580 |
a=line.getnumtokens(); |
| 3581 |
} |
| 3582 |
if (line.getnumtokens() != a+1) PRINTHELP() |
| 3583 |
ent.offsets[0]=add_string(line.gettoken_str(a)); |
| 3584 |
SCRIPT_MSG(_T("Delete: %") NPRIs _T("\"%") NPRIs _T("\"\n"),ent.offsets[1]?_T("/REBOOTOK "):_T(""),line.gettoken_str(a)); |
| 3585 |
|
| 3586 |
DefineInnerLangString(NLF_DEL_FILE); |
| 3587 |
#ifdef NSIS_SUPPORT_MOVEONREBOOT |
| 3588 |
DefineInnerLangString(NLF_DEL_ON_REBOOT); |
| 3589 |
#endif |
| 3590 |
} |
| 3591 |
return add_entry(&ent); |
| 3592 |
#else |
| 3593 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_DELETE not defined.\n"), line.gettoken_str(0)); |
| 3594 |
return PS_ERROR; |
| 3595 |
#endif //~ NSIS_SUPPORT_DELETE |
| 3596 |
case TOK_RMDIR: |
| 3597 |
#ifdef NSIS_SUPPORT_RMDIR |
| 3598 |
{ |
| 3599 |
int a=1; |
| 3600 |
ent.which=EW_RMDIR; |
| 3601 |
ent.offsets[1]=DEL_DIR; |
| 3602 |
while (line.gettoken_str(a)[0]==_T('/')) |
| 3603 |
{ |
| 3604 |
if (!_tcsicmp(line.gettoken_str(a),_T("/r"))) |
| 3605 |
{ |
| 3606 |
if (a == 3) PRINTHELP(); |
| 3607 |
a++; |
| 3608 |
ent.offsets[1]|=DEL_RECURSE; |
| 3609 |
} |
| 3610 |
else if (!_tcsicmp(line.gettoken_str(a),_T("/REBOOTOK"))) |
| 3611 |
{ |
| 3612 |
if (a == 3) PRINTHELP(); |
| 3613 |
a++; |
| 3614 |
ent.offsets[1]|=DEL_REBOOT; |
| 3615 |
} |
| 3616 |
else PRINTHELP(); |
| 3617 |
} |
| 3618 |
if (a < line.getnumtokens() - 1) PRINTHELP(); |
| 3619 |
ent.offsets[0]=add_string(line.gettoken_str(a)); |
| 3620 |
SCRIPT_MSG(_T("RMDir: ")); |
| 3621 |
if (a>1) |
| 3622 |
SCRIPT_MSG(_T("%") NPRIs _T(" "),line.gettoken_str(1)); |
| 3623 |
if (a>2) |
| 3624 |
SCRIPT_MSG(_T("%") NPRIs _T(" "),line.gettoken_str(2)); |
| 3625 |
SCRIPT_MSG(_T("\"%") NPRIs _T("\"\n"),line.gettoken_str(a)); |
| 3626 |
|
| 3627 |
DefineInnerLangString(NLF_REMOVE_DIR); |
| 3628 |
DefineInnerLangString(NLF_DEL_FILE); |
| 3629 |
#ifdef NSIS_SUPPORT_MOVEONREBOOT |
| 3630 |
DefineInnerLangString(NLF_DEL_ON_REBOOT); |
| 3631 |
#endif |
| 3632 |
} |
| 3633 |
return add_entry(&ent); |
| 3634 |
#else |
| 3635 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_RMDIR not defined.\n"), line.gettoken_str(0)); |
| 3636 |
return PS_ERROR; |
| 3637 |
#endif //~ NSIS_SUPPORT_RMDIR |
| 3638 |
case TOK_RESERVEFILE: |
| 3639 |
case TOK_FILE: |
| 3640 |
#ifdef NSIS_SUPPORT_FILE |
| 3641 |
{ |
| 3642 |
set<tstring> excluded; |
| 3643 |
int a=1,attrib=0; |
| 3644 |
bool fatal=true,rec=false,reserveplugin=false; |
| 3645 |
if (!_tcsicmp(line.gettoken_str(a),_T("/nonfatal"))) |
| 3646 |
fatal=false, a++; |
| 3647 |
|
| 3648 |
if (which_token == TOK_RESERVEFILE && !_tcsicmp(line.gettoken_str(a),_T("/plugin"))) |
| 3649 |
reserveplugin=true, a++; |
| 3650 |
|
| 3651 |
if (which_token == TOK_FILE && !_tcsicmp(line.gettoken_str(a),_T("/a"))) |
| 3652 |
{ |
| 3653 |
#ifdef _WIN32 |
| 3654 |
attrib=1; |
| 3655 |
#else |
| 3656 |
warning_fl(DW_UNSUPP_STORE_FILE_ATT, _T("%") NPRIs _T("File /a is disabled for non Win32 platforms."),(which_token == TOK_FILE)?_T(""):_T("Reserve")); |
| 3657 |
#endif |
| 3658 |
a++; |
| 3659 |
} |
| 3660 |
if (!reserveplugin && !_tcsicmp(line.gettoken_str(a),_T("/r"))) |
| 3661 |
{ |
| 3662 |
rec=true, a++; |
| 3663 |
} |
| 3664 |
else if (which_token == TOK_FILE && !_tcsnicmp(line.gettoken_str(a),_T("/oname="),7)) |
| 3665 |
{ |
| 3666 |
TCHAR *on=line.gettoken_str(a)+7; |
| 3667 |
a++; |
| 3668 |
if (!*on||line.getnumtokens()!=a+1||_tcsstr(on,_T("*")) || _tcsstr(on,_T("?"))) PRINTHELP() |
| 3669 |
|
| 3670 |
if (on[0]==_T('"')) |
| 3671 |
{ |
| 3672 |
ERROR_MSG(_T("%") NPRIs _T("File: 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)); |
| 3673 |
PRINTHELP(); |
| 3674 |
} |
| 3675 |
|
| 3676 |
int tf=0; |
| 3677 |
TCHAR *fn = line.gettoken_str(a); |
| 3678 |
PATH_CONVERT(fn); |
| 3679 |
int v=do_add_file(fn, attrib, 0, &tf, on); |
| 3680 |
if (v != PS_OK) return v; |
| 3681 |
if (tf > 1) PRINTHELP() |
| 3682 |
if (!tf) |
| 3683 |
{ |
| 3684 |
if (fatal) |
| 3685 |
{ |
| 3686 |
ERROR_MSG(_T("%") NPRIs _T("File: \"%") NPRIs _T("\" -> no files found.\n"),(which_token == TOK_FILE)?_T(""):_T("Reserve"),line.gettoken_str(a)); |
| 3687 |
PRINTHELP() |
| 3688 |
} |
| 3689 |
else |
| 3690 |
{ |
| 3691 |
warning_fl(DW_FILE_NONFATAL_NOT_FOUND, _T("%") NPRIs _T("File: \"%") NPRIs _T("\" -> no files found"),(which_token == TOK_FILE)?_T(""):_T("Reserve"),line.gettoken_str(a)); |
| 3692 |
|
| 3693 |
// workaround for bug #1299100: add a nop opcode so relative jumps will work as expected |
| 3694 |
add_entry_direct(EW_NOP); |
| 3695 |
} |
| 3696 |
} |
| 3697 |
return PS_OK; |
| 3698 |
} |
| 3699 |
if (!_tcsnicmp(line.gettoken_str(a),_T("/x"),2)) |
| 3700 |
{ |
| 3701 |
while (!_tcsnicmp(line.gettoken_str(a),_T("/x"),2)) |
| 3702 |
{ |
| 3703 |
a++; |
| 3704 |
|
| 3705 |
if (line.getnumtokens() < a+1) PRINTHELP() |
| 3706 |
|
| 3707 |
excluded.insert(line.gettoken_str(a)); |
| 3708 |
a++; |
| 3709 |
} |
| 3710 |
} |
| 3711 |
#ifdef _WIN32 |
| 3712 |
if (line.gettoken_str(a)[0] == _T('/')) PRINTHELP() |
| 3713 |
#endif |
| 3714 |
if (line.getnumtokens()<a+1) PRINTHELP() |
| 3715 |
while (a < line.getnumtokens()) |
| 3716 |
{ |
| 3717 |
#ifdef _WIN32 |
| 3718 |
if (line.gettoken_str(a)[0]==_T('/')) PRINTHELP() |
| 3719 |
#endif |
| 3720 |
TCHAR buf[32]; |
| 3721 |
TCHAR *t=line.gettoken_str(a++); |
| 3722 |
if (t[0] && CharNext(t)[0] == _T(':') && CharNext(t)[1] == _T('\\') && !CharNext(t)[2]) |
| 3723 |
{ |
| 3724 |
_tcscpy(buf,_T("X:\\*.*")); |
| 3725 |
buf[0]=t[0]; |
| 3726 |
t=buf; |
| 3727 |
} |
| 3728 |
tstring pluginfullpath; |
| 3729 |
if (reserveplugin && get_file_name(t)==t) |
| 3730 |
{ |
| 3731 |
if (!m_pPlugins || !m_pPlugins->FindDllPath(t, pluginfullpath)) |
| 3732 |
{ |
| 3733 |
pluginfullpath = definedlist.find(_T("NSISDIR")); |
| 3734 |
pluginfullpath += tstring(PLATFORM_PATH_SEPARATOR_STR) + _T("Plugins"); |
| 3735 |
pluginfullpath += tstring(PLATFORM_PATH_SEPARATOR_STR) + get_target_suffix(); |
| 3736 |
pluginfullpath += tstring(PLATFORM_PATH_SEPARATOR_STR) + t; |
| 3737 |
} |
| 3738 |
t = (TCHAR*) pluginfullpath.c_str(); |
| 3739 |
} |
| 3740 |
int tf=0; |
| 3741 |
TCHAR *fn = my_convert(t); |
| 3742 |
int v=do_add_file(fn, attrib, rec, &tf, NULL, which_token == TOK_FILE, NULL, excluded); |
| 3743 |
my_convert_free(fn); |
| 3744 |
if (v != PS_OK) return v; |
| 3745 |
if (!tf) |
| 3746 |
{ |
| 3747 |
if (fatal) |
| 3748 |
{ |
| 3749 |
ERROR_MSG(_T("%") NPRIs _T("File: \"%") NPRIs _T("\" -> no files found.\n"),(which_token == TOK_FILE)?_T(""):_T("Reserve"),t); |
| 3750 |
PRINTHELP(); |
| 3751 |
} |
| 3752 |
else |
| 3753 |
{ |
| 3754 |
warning_fl(DW_FILE_NONFATAL_NOT_FOUND, _T("%") NPRIs _T("File: \"%") NPRIs _T("\" -> no files found."),(which_token == TOK_FILE)?_T(""):_T("Reserve"),t); |
| 3755 |
} |
| 3756 |
} |
| 3757 |
} |
| 3758 |
} |
| 3759 |
return PS_OK; |
| 3760 |
#else |
| 3761 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_FILE not defined.\n"), line.gettoken_str(0)); |
| 3762 |
return PS_ERROR; |
| 3763 |
#endif //~ NSIS_SUPPORT_FILE |
| 3764 |
#ifdef NSIS_SUPPORT_COPYFILES |
| 3765 |
case TOK_COPYFILES: |
| 3766 |
{ |
| 3767 |
ent.which=EW_COPYFILES; |
| 3768 |
ent.offsets[2]=FOF_NOCONFIRMATION|FOF_NOCONFIRMMKDIR|FOF_NOERRORUI|FOF_SIMPLEPROGRESS; |
| 3769 |
int a=1; |
| 3770 |
for (int x = 0; x < 2; x++) |
| 3771 |
{ |
| 3772 |
if (!_tcsicmp(line.gettoken_str(a),_T("/SILENT"))) |
| 3773 |
{ |
| 3774 |
a++; |
| 3775 |
ent.offsets[2]&=~FOF_SIMPLEPROGRESS; |
| 3776 |
ent.offsets[2]|=FOF_SILENT; |
| 3777 |
} |
| 3778 |
else if (!_tcsicmp(line.gettoken_str(a),_T("/FILESONLY"))) |
| 3779 |
{ |
| 3780 |
a++; |
| 3781 |
ent.offsets[2]|=FOF_FILESONLY; |
| 3782 |
} |
| 3783 |
else if (line.gettoken_str(a)[0]==_T('/')) PRINTHELP() |
| 3784 |
else break; |
| 3785 |
} |
| 3786 |
if (line.getnumtokens() < a+2) PRINTHELP() |
| 3787 |
ent.offsets[0]=add_string(line.gettoken_str(a)); |
| 3788 |
ent.offsets[1]=add_string(line.gettoken_str(a+1)); |
| 3789 |
tstring copy_to = tstring(_T("$(^CopyTo)")) + line.gettoken_str(a+1); |
| 3790 |
ent.offsets[3]=add_string(copy_to.c_str()); |
| 3791 |
int succ, size_kb=line.gettoken_int(a+2,&succ); |
| 3792 |
if (!succ && line.gettoken_str(a+2)[0]) PRINTHELP() |
| 3793 |
section_add_size_kb(size_kb); |
| 3794 |
SCRIPT_MSG(_T("CopyFiles: %") NPRIs _T("\"%") NPRIs _T("\" -> \"%") NPRIs _T("\", size=%iKB\n"),ent.offsets[2]&FOF_SILENT?_T("(silent) "):_T(""), line.gettoken_str(a),line.gettoken_str(a+1),size_kb); |
| 3795 |
DefineInnerLangString(NLF_COPY_FAILED); |
| 3796 |
DefineInnerLangString(NLF_COPY_TO); |
| 3797 |
} |
| 3798 |
return add_entry(&ent); |
| 3799 |
#else |
| 3800 |
case TOK_COPYFILES: |
| 3801 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_COPYFILES not defined.\n"), line.gettoken_str(0)); |
| 3802 |
return PS_ERROR; |
| 3803 |
#endif //~ NSIS_SUPPORT_COPYFILES |
| 3804 |
case TOK_SETFILEATTRIBUTES: |
| 3805 |
{ |
| 3806 |
#define MBD(x) {x,_T(#x)}, |
| 3807 |
struct { int id; const TCHAR *str; } list[] = { |
| 3808 |
MBD(FILE_ATTRIBUTE_NORMAL) {FILE_ATTRIBUTE_NORMAL,_T("NORMAL")}, // Short alias |
| 3809 |
MBD(FILE_ATTRIBUTE_ARCHIVE) {FILE_ATTRIBUTE_ARCHIVE,_T("ARCHIVE")}, |
| 3810 |
MBD(FILE_ATTRIBUTE_HIDDEN) {FILE_ATTRIBUTE_HIDDEN,_T("HIDDEN")}, |
| 3811 |
MBD(FILE_ATTRIBUTE_OFFLINE) {FILE_ATTRIBUTE_OFFLINE,_T("OFFLINE")}, |
| 3812 |
MBD(FILE_ATTRIBUTE_READONLY) {FILE_ATTRIBUTE_READONLY,_T("READONLY")}, |
| 3813 |
MBD(FILE_ATTRIBUTE_SYSTEM) {FILE_ATTRIBUTE_SYSTEM,_T("SYSTEM")}, |
| 3814 |
MBD(FILE_ATTRIBUTE_TEMPORARY) {FILE_ATTRIBUTE_TEMPORARY,_T("TEMPORARY")}, |
| 3815 |
MBD(FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) {FILE_ATTRIBUTE_NOT_CONTENT_INDEXED,_T("NOTINDEXED")}, |
| 3816 |
{FILE_ATTRIBUTE_NORMAL,_T("0")}, |
| 3817 |
}; |
| 3818 |
#undef MBD |
| 3819 |
int r=0, x; |
| 3820 |
TCHAR *p=line.gettoken_str(2); |
| 3821 |
while (*p) |
| 3822 |
{ |
| 3823 |
TCHAR *np=p; |
| 3824 |
while (*np && *np != _T('|')) np++; |
| 3825 |
if (*np) *np++=0; |
| 3826 |
for (x = 0 ; (unsigned) x < COUNTOF(list) && _tcsicmp(list[x].str,p); x++); |
| 3827 |
|
| 3828 |
if ((unsigned) x < COUNTOF(list)) |
| 3829 |
r |= list[x].id; |
| 3830 |
else |
| 3831 |
PRINTHELP() |
| 3832 |
p=np; |
| 3833 |
} |
| 3834 |
ent.which=EW_SETFILEATTRIBUTES; |
| 3835 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 3836 |
ent.offsets[1]=r; |
| 3837 |
} |
| 3838 |
return add_entry(&ent); |
| 3839 |
case TOK_SLEEP: |
| 3840 |
{ |
| 3841 |
ent.which=EW_SLEEP; |
| 3842 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 3843 |
SCRIPT_MSG(_T("Sleep: %") NPRIs _T(" ms\n"),line.gettoken_str(1)); |
| 3844 |
} |
| 3845 |
return add_entry(&ent); |
| 3846 |
case TOK_IFFILEEXISTS: |
| 3847 |
ent.which=EW_IFFILEEXISTS; |
| 3848 |
ent.offsets[0] = add_string(line.gettoken_str(1)); |
| 3849 |
if (process_jump(line,2,&ent.offsets[1]) || |
| 3850 |
process_jump(line,3,&ent.offsets[2])) PRINTHELP() |
| 3851 |
SCRIPT_MSG(_T("IfFileExists: \"%") NPRIs _T("\" ? %") NPRIs _T(" : %") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3)); |
| 3852 |
return add_entry(&ent); |
| 3853 |
case TOK_QUIT: |
| 3854 |
ent.which=EW_QUIT; |
| 3855 |
SCRIPT_MSG(_T("Quit\n")); |
| 3856 |
return add_entry(&ent); |
| 3857 |
case TOK_ABORT: |
| 3858 |
ent.which=EW_ABORT; |
| 3859 |
ent.offsets[0] = add_string(line.gettoken_str(1)); |
| 3860 |
SCRIPT_MSG(_T("Abort: \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 3861 |
return add_entry(&ent); |
| 3862 |
case TOK_SETDETAILSVIEW: |
| 3863 |
{ |
| 3864 |
int v=line.gettoken_enum(1,_T("hide\0show\0")); |
| 3865 |
if (v < 0) PRINTHELP() |
| 3866 |
ent.which=EW_CHDETAILSVIEW; |
| 3867 |
ent.offsets[0] = v?SW_SHOWNA:SW_HIDE; |
| 3868 |
ent.offsets[1] = v?SW_HIDE:SW_SHOWNA; |
| 3869 |
SCRIPT_MSG(_T("SetDetailsView: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 3870 |
} |
| 3871 |
return add_entry(&ent); |
| 3872 |
case TOK_SETDETAILSPRINT: |
| 3873 |
{ |
| 3874 |
ent.which=EW_SETFLAG; |
| 3875 |
ent.offsets[0]=FLAG_OFFSET(status_update); |
| 3876 |
int k=line.gettoken_enum(1,_T("both\0textonly\0listonly\0none\0lastused\0")); |
| 3877 |
if (k < 0) PRINTHELP() |
| 3878 |
if (k == 4) |
| 3879 |
ent.offsets[2]=1; // lastused |
| 3880 |
else |
| 3881 |
ent.offsets[1]=add_intstring(k*2); // both=0, textonly=2, listonly=4, none=6 |
| 3882 |
SCRIPT_MSG(_T("SetDetailsPrint: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 3883 |
} |
| 3884 |
return add_entry(&ent); |
| 3885 |
case TOK_SETAUTOCLOSE: |
| 3886 |
{ |
| 3887 |
ent.which=EW_SETFLAG; |
| 3888 |
ent.offsets[0]=FLAG_OFFSET(autoclose); |
| 3889 |
int k=line.gettoken_enum(1,_T("false\0true\0")); |
| 3890 |
if (k < 0) PRINTHELP() |
| 3891 |
ent.offsets[1]=add_intstring(k); |
| 3892 |
SCRIPT_MSG(_T("SetAutoClose: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 3893 |
} |
| 3894 |
return add_entry(&ent); |
| 3895 |
case TOK_IFERRORS: |
| 3896 |
return add_flag_instruction_entry(which_token, EW_IFFLAG, line, FLAG_OFFSET(exec_error), 0); //new value mask - clean error |
| 3897 |
case TOK_IFABORT: |
| 3898 |
return add_flag_instruction_entry(which_token, EW_IFFLAG, line, FLAG_OFFSET(abort), ~0); //new value mask - keep flag |
| 3899 |
case TOK_CLEARERRORS: |
| 3900 |
return add_flag_instruction_entry(which_token, EW_SETFLAG, line, FLAG_OFFSET(exec_error), add_intstring(0)); |
| 3901 |
case TOK_SETERRORS: |
| 3902 |
return add_flag_instruction_entry(which_token, EW_SETFLAG, line, FLAG_OFFSET(exec_error), add_intstring(1)); |
| 3903 |
case TOK_SETERRORLEVEL: |
| 3904 |
return add_flag_instruction_entry(which_token, EW_SETFLAG, line, FLAG_OFFSET(errlvl), add_string(line.gettoken_str(1))); |
| 3905 |
case TOK_GETERRORLEVEL: |
| 3906 |
return add_flag_instruction_entry(which_token, EW_GETFLAG, line, FLAG_OFFSET(errlvl)); |
| 3907 |
#ifdef NSIS_SUPPORT_STROPTS |
| 3908 |
case TOK_STRLEN: |
| 3909 |
ent.which=EW_STRLEN; |
| 3910 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 3911 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 3912 |
if (ent.offsets[0] < 0) PRINTHELP() |
| 3913 |
SCRIPT_MSG(_T("StrLen %") NPRIs _T(" \"%") NPRIs _T("\"\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 3914 |
return add_entry(&ent); |
| 3915 |
case TOK_STRCPY: |
| 3916 |
case TOK_UNSAFESTRCPY: |
| 3917 |
{ |
| 3918 |
ent.which = EW_ASSIGNVAR; |
| 3919 |
const TCHAR* msgprefix = _T(""); |
| 3920 |
int idx = -1; |
| 3921 |
if (TOK_STRCPY == which_token) |
| 3922 |
idx = GetUserVarIndex(line, 1); |
| 3923 |
else |
| 3924 |
idx = GetUnsafeUserVarIndex(line, 1), msgprefix = _T("Unsafe"); |
| 3925 |
if (idx < 0) PRINTHELP() |
| 3926 |
ent.offsets[0]=idx; // Destination variable |
| 3927 |
ent.offsets[1]=add_string(line.gettoken_str(2)); // Source string |
| 3928 |
ent.offsets[2]=add_string(line.gettoken_str(3)); // Optional MaxLen |
| 3929 |
ent.offsets[3]=add_string(line.gettoken_str(4)); // Optional StartOffset |
| 3930 |
SCRIPT_MSG(_T("%") NPRIs _T("StrCpy %") NPRIs _T(" \"%") NPRIs _T("\" (%") NPRIs _T(") (%") NPRIs _T(")\n"), |
| 3931 |
msgprefix,line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(4)); |
| 3932 |
return add_entry(&ent); |
| 3933 |
} |
| 3934 |
case TOK_GETFUNCTIONADDR: |
| 3935 |
ent.which=EW_GETFUNCTIONADDR; |
| 3936 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 3937 |
ent.offsets[1]=ns_func.add(line.gettoken_str(2),0); |
| 3938 |
ent.offsets[2]=0; |
| 3939 |
ent.offsets[3]=0; |
| 3940 |
if (ent.offsets[0] < 0) PRINTHELP() |
| 3941 |
SCRIPT_MSG(_T("GetFunctionAddress: %") NPRIs _T(" %") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 3942 |
return add_entry(&ent); |
| 3943 |
case TOK_GETLABELADDR: |
| 3944 |
ent.which=EW_GETLABELADDR; |
| 3945 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 3946 |
if (ent.offsets[0] < 0 || process_jump(line,2,&ent.offsets[1])) PRINTHELP() |
| 3947 |
ent.offsets[2]=0; |
| 3948 |
ent.offsets[3]=0; |
| 3949 |
SCRIPT_MSG(_T("GetLabelAddress: %") NPRIs _T(" %") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 3950 |
return add_entry(&ent); |
| 3951 |
case TOK_GETCURRENTADDR: |
| 3952 |
ent.which=EW_ASSIGNVAR; |
| 3953 |
if ((ent.offsets[0]=GetUserVarIndex(line, 1)) < 0) PRINTHELP() |
| 3954 |
ent.offsets[1]=add_intstring(1+(cur_header->blocks[NB_ENTRIES].num)); |
| 3955 |
ent.offsets[2]=ent.offsets[3]=0; |
| 3956 |
SCRIPT_MSG(_T("GetCurrentAddress: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 3957 |
return add_entry(&ent); |
| 3958 |
case TOK_STRCMP: |
| 3959 |
case TOK_STRCMPS: |
| 3960 |
ent.which=EW_STRCMP; |
| 3961 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 3962 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 3963 |
ent.offsets[4]=which_token == TOK_STRCMPS; |
| 3964 |
if (process_jump(line,3,&ent.offsets[2]) || |
| 3965 |
process_jump(line,4,&ent.offsets[3])) PRINTHELP() |
| 3966 |
SCRIPT_MSG(_T("%") NPRIs _T(" \"%") NPRIs _T("\" \"%") NPRIs _T("\" equal=%") NPRIs _T(", nonequal=%") NPRIs _T("\n"),line.gettoken_str(0),line.gettoken_str(1),line.gettoken_str(2), line.gettoken_str(3),line.gettoken_str(4)); |
| 3967 |
return add_entry(&ent); |
| 3968 |
case TOK_GETDLLVERSIONLOCAL: |
| 3969 |
{ |
| 3970 |
const TCHAR*cmdname=_T("GetDLLVersionLocal"); |
| 3971 |
DWORD low, high, prod = line.gettoken_enum(1, _T("/ProductVersion\0")) == 0 ? 2 : 0; |
| 3972 |
if (prod) line.eattoken(); |
| 3973 |
if (!GetDLLVersion(line.gettoken_str(1),high,low,!!prod)) |
| 3974 |
{ |
| 3975 |
ERROR_MSG(_T("%") NPRIs _T(": error reading version info from \"%") NPRIs _T("\"\n"),cmdname,line.gettoken_str(1)); |
| 3976 |
return PS_ERROR; |
| 3977 |
} |
| 3978 |
ent.which=EW_ASSIGNVAR; |
| 3979 |
if ((ent.offsets[0]=GetUserVarIndex(line, 2)) < 0) PRINTHELP() |
| 3980 |
ent.offsets[1]=add_intstring(high); |
| 3981 |
ent.offsets[2]=ent.offsets[3]=0; |
| 3982 |
if (PS_OK != add_entry(&ent)) return PS_ERROR; |
| 3983 |
if ((ent.offsets[0]=GetUserVarIndex(line, 3)) < 0) PRINTHELP() |
| 3984 |
ent.offsets[1]=add_intstring(low); |
| 3985 |
ent.offsets[2]=ent.offsets[3]=0; |
| 3986 |
SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T(" (%u,%u)->(%") NPRIs _T(",%") NPRIs _T(")\n"), |
| 3987 |
cmdname,line.gettoken_str(1),high,low,line.gettoken_str(2),line.gettoken_str(3)); |
| 3988 |
} |
| 3989 |
return add_entry(&ent); |
| 3990 |
case TOK_GETFILETIMELOCAL: |
| 3991 |
{ |
| 3992 |
TCHAR buf[129]; |
| 3993 |
DWORD high=0,low=0; |
| 3994 |
#ifdef _WIN32 |
| 3995 |
int flag=0; |
| 3996 |
HANDLE hFile=CreateFile(line.gettoken_str(1),0,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); |
| 3997 |
if (hFile != INVALID_HANDLE_VALUE) |
| 3998 |
{ |
| 3999 |
FILETIME ft; |
| 4000 |
if (GetFileTime(hFile,NULL,NULL,&ft)) |
| 4001 |
flag=1, high=ft.dwHighDateTime, low=ft.dwLowDateTime; |
| 4002 |
CloseHandle(hFile); |
| 4003 |
} |
| 4004 |
if (!flag) |
| 4005 |
{ |
| 4006 |
ERROR_MSG(_T("GetFileTimeLocal: error reading date from \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 4007 |
return PS_ERROR; |
| 4008 |
} |
| 4009 |
#else |
| 4010 |
struct stat st; |
| 4011 |
if (_tstat(line.gettoken_str(1), &st)) |
| 4012 |
{ |
| 4013 |
ERROR_MSG(_T("GetFileTimeLocal: error reading date from \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 4014 |
return PS_ERROR; |
| 4015 |
} |
| 4016 |
unsigned long long ll = (st.st_mtime * 10000000LL) + 116444736000000000LL; |
| 4017 |
high = (DWORD) (ll >> 32), low = (DWORD) ll; |
| 4018 |
#endif |
| 4019 |
ent.which=EW_ASSIGNVAR; |
| 4020 |
if ((ent.offsets[0]=GetUserVarIndex(line, 2)) < 0) PRINTHELP() |
| 4021 |
wsprintf(buf,_T("%u"),high); |
| 4022 |
ent.offsets[1]=add_string(buf); |
| 4023 |
ent.offsets[2]=ent.offsets[3]=0; |
| 4024 |
if (PS_OK != add_entry(&ent)) return PS_ERROR; |
| 4025 |
if ((ent.offsets[0]=GetUserVarIndex(line, 3)) < 0) PRINTHELP() |
| 4026 |
wsprintf(buf,_T("%u"),low); |
| 4027 |
ent.offsets[1]=add_string(buf); |
| 4028 |
ent.offsets[2]=ent.offsets[3]=0; |
| 4029 |
SCRIPT_MSG(_T("GetFileTimeLocal: %") NPRIs _T(" (%u,%u)->(%") NPRIs _T(",%") NPRIs _T(")\n"), |
| 4030 |
line.gettoken_str(1),high,low,line.gettoken_str(2),line.gettoken_str(3)); |
| 4031 |
} |
| 4032 |
return add_entry(&ent); |
| 4033 |
|
| 4034 |
#else |
| 4035 |
case TOK_GETDLLVERSIONLOCAL: |
| 4036 |
case TOK_GETFILETIMELOCAL: |
| 4037 |
case TOK_GETFUNCTIONADDR: |
| 4038 |
case TOK_GETLABELADDR: |
| 4039 |
case TOK_GETCURRENTADDR: |
| 4040 |
case TOK_STRLEN: |
| 4041 |
case TOK_STRCPY: |
| 4042 |
case TOK_STRCMP: |
| 4043 |
case TOK_STRCMPS: |
| 4044 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_STROPTS not defined.\n"), line.gettoken_str(0)); |
| 4045 |
return PS_ERROR; |
| 4046 |
#endif //~ NSIS_SUPPORT_STROPTS |
| 4047 |
#ifdef NSIS_SUPPORT_INIFILES |
| 4048 |
case TOK_DELETEINISEC: |
| 4049 |
case TOK_DELETEINISTR: |
| 4050 |
{ |
| 4051 |
const TCHAR *vname=_T(""), *space=_T(""); |
| 4052 |
ent.which=EW_WRITEINI; |
| 4053 |
ent.offsets[0]=add_string(line.gettoken_str(2)); // section name |
| 4054 |
if (line.getnumtokens() > 3) |
| 4055 |
{ |
| 4056 |
vname=line.gettoken_str(3); |
| 4057 |
ent.offsets[1]=add_string(vname); // value name |
| 4058 |
space=_T(" "); |
| 4059 |
} |
| 4060 |
else ent.offsets[1]=0; |
| 4061 |
ent.offsets[2]=0; |
| 4062 |
ent.offsets[3]=add_string(line.gettoken_str(1)); |
| 4063 |
SCRIPT_MSG(_T("DeleteINI%") NPRIs _T(": [%") NPRIs _T("] %") NPRIs _T("%") NPRIs _T("in %") NPRIs _T("\n"),*vname?_T("Str"):_T("Sec"), |
| 4064 |
line.gettoken_str(2),vname,space,line.gettoken_str(1)); |
| 4065 |
} |
| 4066 |
return add_entry(&ent); |
| 4067 |
case TOK_FLUSHINI: |
| 4068 |
ent.which=EW_WRITEINI; |
| 4069 |
ent.offsets[3]=add_string(line.gettoken_str(1)); |
| 4070 |
SCRIPT_MSG(_T("FlushINI: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 4071 |
return add_entry(&ent); |
| 4072 |
case TOK_WRITEINISTR: |
| 4073 |
ent.which=EW_WRITEINI; |
| 4074 |
ent.offsets[0]=add_string(line.gettoken_str(2)); |
| 4075 |
ent.offsets[1]=add_string(line.gettoken_str(3)); |
| 4076 |
ent.offsets[2]=add_string(line.gettoken_str(4)); |
| 4077 |
ent.offsets[3]=add_string(line.gettoken_str(1)); |
| 4078 |
ent.offsets[4]=1; // write |
| 4079 |
SCRIPT_MSG(_T("WriteINIStr: [%") NPRIs _T("] %") NPRIs _T("=%") NPRIs _T(" in %") NPRIs _T("\n"), |
| 4080 |
line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(4),line.gettoken_str(1)); |
| 4081 |
return add_entry(&ent); |
| 4082 |
case TOK_READINISTR: |
| 4083 |
ent.which=EW_READINISTR; |
| 4084 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 4085 |
if (ent.offsets[0] < 0) PRINTHELP() |
| 4086 |
ent.offsets[1]=add_string(line.gettoken_str(3)); |
| 4087 |
ent.offsets[2]=add_string(line.gettoken_str(4)); |
| 4088 |
ent.offsets[3]=add_string(line.gettoken_str(2)); |
| 4089 |
SCRIPT_MSG(_T("ReadINIStr %") NPRIs _T(" [%") NPRIs _T("]:%") NPRIs _T(" from %") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(3),line.gettoken_str(4),line.gettoken_str(2)); |
| 4090 |
return add_entry(&ent); |
| 4091 |
#else |
| 4092 |
case TOK_DELETEINISEC: |
| 4093 |
case TOK_DELETEINISTR: |
| 4094 |
case TOK_FLUSHINI: |
| 4095 |
case TOK_WRITEINISTR: |
| 4096 |
case TOK_READINISTR: |
| 4097 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_INIFILES not defined.\n"), line.gettoken_str(0)); |
| 4098 |
return PS_ERROR; |
| 4099 |
#endif //~ NSIS_SUPPORT_INIFILES |
| 4100 |
case TOK_DETAILPRINT: |
| 4101 |
ent.which=EW_UPDATETEXT; |
| 4102 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 4103 |
ent.offsets[1]=0; |
| 4104 |
SCRIPT_MSG(_T("DetailPrint: \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 4105 |
return add_entry(&ent); |
| 4106 |
#ifdef NSIS_SUPPORT_FNUTIL |
| 4107 |
case TOK_GETTEMPFILENAME: |
| 4108 |
ent.which=EW_GETTEMPFILENAME; |
| 4109 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 4110 |
if (line.getnumtokens() == 3) |
| 4111 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 4112 |
else |
| 4113 |
ent.offsets[1]=add_asciistring(_T("$TEMP")); |
| 4114 |
if (ent.offsets[0]<0) PRINTHELP() |
| 4115 |
SCRIPT_MSG(_T("GetTempFileName -> %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 4116 |
return add_entry(&ent); |
| 4117 |
case TOK_GETFULLPATHNAME: |
| 4118 |
{ |
| 4119 |
int a=0; |
| 4120 |
ent.which=EW_GETFULLPATHNAME; |
| 4121 |
if (line.getnumtokens()==4 && !_tcsicmp(line.gettoken_str(1),_T("/SHORT"))) a++; |
| 4122 |
else if (line.getnumtokens()==4 || *line.gettoken_str(1)==_T('/')) PRINTHELP() |
| 4123 |
ent.offsets[0]=add_string(line.gettoken_str(2+a)); |
| 4124 |
ent.offsets[1]=GetUserVarIndex(line, 1+a); |
| 4125 |
ent.offsets[2]=!a; |
| 4126 |
if (ent.offsets[1]<0) PRINTHELP() |
| 4127 |
SCRIPT_MSG(_T("GetFullPathName: %") NPRIs _T("->%") NPRIs _T(" (%d)\n"), |
| 4128 |
line.gettoken_str(2+a),line.gettoken_str(1+a),a?_T("sfn"):_T("lfn")); |
| 4129 |
} |
| 4130 |
return add_entry(&ent); |
| 4131 |
case TOK_GETKNOWNFOLDERPATH: |
| 4132 |
ent.which=EW_GETOSINFO; |
| 4133 |
ent.offsets[1]=GetUserVarIndex(line, 1); |
| 4134 |
ent.offsets[2]=add_string(line.gettoken_str(2)); |
| 4135 |
ent.offsets[3]=GETOSINFO_KNOWNFOLDER; |
| 4136 |
SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T("->%") NPRIs _T("\n"), get_commandtoken_name(which_token), line.gettoken_str(2), line.gettoken_str(1)); |
| 4137 |
return add_entry(&ent); |
| 4138 |
case TOK_GETWINVER: |
| 4139 |
{ |
| 4140 |
int k = line.gettoken_enum(2, _T("major\0minor\0build\0servicepack\0product\0ntddimajmin\0")), cb = 0, ofs = 0; |
| 4141 |
switch(k) |
| 4142 |
{ |
| 4143 |
case 0: cb = 1, ofs = ABI_OSINFOOFFSET + FIELD_OFFSET(osinfo, WVMaj); break; |
| 4144 |
case 1: cb = 1, ofs = ABI_OSINFOOFFSET + FIELD_OFFSET(osinfo, WVMin); break; |
| 4145 |
case 2: cb = 4, ofs = ABI_OSINFOOFFSET + FIELD_OFFSET(osinfo, WVBuild); break; |
| 4146 |
case 3: cb = 1, ofs = ABI_OSINFOOFFSET + FIELD_OFFSET(osinfo, WVSP); break; |
| 4147 |
case 4: cb = 1, ofs = ABI_OSINFOOFFSET + FIELD_OFFSET(osinfo, WVProd); break; |
| 4148 |
case 5: cb = 2, ofs = ABI_OSINFOOFFSET + FIELD_OFFSET(osinfo, WVMin); break; |
| 4149 |
default: PRINTHELP(); |
| 4150 |
} |
| 4151 |
ent.which=EW_GETOSINFO; |
| 4152 |
ent.offsets[1]=GetUserVarIndex(line, 1); |
| 4153 |
ent.offsets[2]=add_intstring(ABI_OSINFOADDRESS); |
| 4154 |
ent.offsets[3]=GETOSINFO_READMEMORY; |
| 4155 |
ent.offsets[4]=add_intstring((cb << 0) | (ofs << 24)); |
| 4156 |
SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T("=%") NPRIs _T("\n"), get_commandtoken_name(which_token), line.gettoken_str(1), line.gettoken_str(2)); |
| 4157 |
} |
| 4158 |
return add_entry(&ent); |
| 4159 |
case TOK_READMEMORY: |
| 4160 |
ent.which=EW_GETOSINFO; |
| 4161 |
ent.offsets[1]=GetUserVarIndex(line, 1); |
| 4162 |
ent.offsets[2]=add_string(line.gettoken_str(2)); |
| 4163 |
ent.offsets[3]=GETOSINFO_READMEMORY; |
| 4164 |
ent.offsets[4]=add_string(line.gettoken_str(3)); |
| 4165 |
SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T("=*%") NPRIs _T("\n"), get_commandtoken_name(which_token), line.gettoken_str(1), line.gettoken_str(2)); |
| 4166 |
return add_entry(&ent); |
| 4167 |
case TOK_SEARCHPATH: |
| 4168 |
ent.which=EW_SEARCHPATH; |
| 4169 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 4170 |
if (ent.offsets[0] < 0) PRINTHELP() |
| 4171 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 4172 |
SCRIPT_MSG(_T("SearchPath %") NPRIs _T(" %") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 4173 |
return add_entry(&ent); |
| 4174 |
#else |
| 4175 |
case TOK_SEARCHPATH: |
| 4176 |
case TOK_GETTEMPFILENAME: |
| 4177 |
case TOK_GETFULLPATHNAME: |
| 4178 |
case TOK_GETKNOWNFOLDERPATH: |
| 4179 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_FNUTIL not defined.\n"), line.gettoken_str(0)); |
| 4180 |
return PS_ERROR; |
| 4181 |
#endif //~ NSIS_SUPPORT_FNUTIL |
| 4182 |
case TOK_GETDLLVERSION: |
| 4183 |
#ifdef NSIS_SUPPORT_GETDLLVERSION |
| 4184 |
ent.which=EW_GETDLLVERSION; |
| 4185 |
if ((ent.offsets[3]=line.gettoken_enum(1, _T("/ProductVersion\0")) == 0 ? 2 : 0)) line.eattoken(); |
| 4186 |
ent.offsets[0]=GetUserVarIndex(line, 2); |
| 4187 |
ent.offsets[1]=GetUserVarIndex(line, 3); |
| 4188 |
ent.offsets[2]=add_string(line.gettoken_str(1)); |
| 4189 |
if (ent.offsets[0]<0 || ent.offsets[1]<0) PRINTHELP() |
| 4190 |
SCRIPT_MSG(_T("GetDLLVersion: %") NPRIs _T("->%") NPRIs _T(",%") NPRIs _T("\n"), |
| 4191 |
line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3)); |
| 4192 |
return add_entry(&ent); |
| 4193 |
#else |
| 4194 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_GETDLLVERSION not defined.\n"), line.gettoken_str(0)); |
| 4195 |
return PS_ERROR; |
| 4196 |
#endif //~ NSIS_SUPPORT_GETDLLVERSION |
| 4197 |
case TOK_GETFILETIME: |
| 4198 |
#ifdef NSIS_SUPPORT_GETFILETIME |
| 4199 |
ent.which=EW_GETFILETIME; |
| 4200 |
ent.offsets[0]=GetUserVarIndex(line, 2); |
| 4201 |
ent.offsets[1]=GetUserVarIndex(line, 3); |
| 4202 |
ent.offsets[2]=add_string(line.gettoken_str(1)); |
| 4203 |
if (ent.offsets[0]<0 || ent.offsets[1]<0) PRINTHELP() |
| 4204 |
SCRIPT_MSG(_T("GetFileTime: %") NPRIs _T("->%") NPRIs _T(",%") NPRIs _T("\n"), |
| 4205 |
line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3)); |
| 4206 |
return add_entry(&ent); |
| 4207 |
#else |
| 4208 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_GETFILETIME not defined.\n"), line.gettoken_str(0)); |
| 4209 |
return PS_ERROR; |
| 4210 |
#endif //~ NSIS_SUPPORT_GETFILETIME |
| 4211 |
#ifdef NSIS_SUPPORT_INTOPTS |
| 4212 |
case TOK_INTOP: case TOK_INTPTROP: |
| 4213 |
{ |
| 4214 |
const TCHAR *val1=line.gettoken_str(2), *opstr=0, *val2=0, *cmdname=get_commandtoken_name(which_token); |
| 4215 |
int t64 = is_target_64bit(), res; |
| 4216 |
ent.which=EW_INTOP; |
| 4217 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 4218 |
ent.offsets[3]=line.gettoken_enum(3,_T("+\0-\0*\0/\0|\0&\0^\0!\0||\0&&\0%\0<<\0>>\0>>>\0~\0")); |
| 4219 |
if (ent.offsets[0] < 0 || ent.offsets[3] < 0 || ((ent.offsets[3] == 7 || ent.offsets[3] == 14) && line.getnumtokens() > 4)) |
| 4220 |
PRINTHELP() |
| 4221 |
if (ent.offsets[3] != 7 && ent.offsets[3] != 14) val2=line.gettoken_str(4); |
| 4222 |
if (ent.offsets[3] == 14) val2=t64?_T("0xFFFFFFFFFFFFFFFF"):_T("0xFFFFFFFF"), ent.offsets[3]=6, opstr = _T("^"); // ~ using ^ |
| 4223 |
if (TOK_INTPTROP == which_token && t64) |
| 4224 |
{ |
| 4225 |
res = doParse(2, _T("System::Int64Op %") NPRIs _T(" %") NPRIs _T(" %") NPRIs _T("\n"), val1, opstr ? opstr : line.gettoken_str(3), val2 ? val2 : _T("")); |
| 4226 |
if (res != PS_OK) return res; |
| 4227 |
ent.which=EW_PUSHPOP, ent.offsets[1]=1, ent.offsets[3]=0; // Pop $result |
| 4228 |
} |
| 4229 |
else |
| 4230 |
{ |
| 4231 |
ent.offsets[1]=add_string(val1); |
| 4232 |
if (val2) ent.offsets[2]=add_string(val2); |
| 4233 |
} |
| 4234 |
SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T("=%") NPRIs _T("%") NPRIs _T("%") NPRIs _T("\n"),cmdname,line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(4)); |
| 4235 |
} |
| 4236 |
return add_entry(&ent); |
| 4237 |
case TOK_INTFMT: case TOK_INT64FMT: |
| 4238 |
ent.which=EW_INTFMT; |
| 4239 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 4240 |
if (ent.offsets[0]<0) PRINTHELP() |
| 4241 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 4242 |
ent.offsets[2]=add_string(line.gettoken_str(3)); |
| 4243 |
ent.offsets[3]=which_token == TOK_INT64FMT; |
| 4244 |
if (ent.offsets[3] && !is_target_64bit()) return (ERROR_MSG(_T("%") NPRIns _T("\n"), "Instruction only supported by 64-bit targets!"), PS_ERROR); |
| 4245 |
SCRIPT_MSG(_T("IntFmt: %") NPRIs _T("->%") NPRIs _T(" (fmt:%") NPRIs _T(")\n"),line.gettoken_str(3),line.gettoken_str(1),line.gettoken_str(2)); |
| 4246 |
return add_entry(&ent); |
| 4247 |
case TOK_INTCMP: case TOK_INTCMPU: case TOK_INT64CMP: case TOK_INT64CMPU: case TOK_INTPTRCMP: case TOK_INTPTRCMPU: |
| 4248 |
{ |
| 4249 |
int t64 = is_target_64bit(), o32 = TOK_INTCMP == which_token || TOK_INTCMPU == which_token, o64 = TOK_INT64CMP == which_token || TOK_INT64CMPU == which_token; |
| 4250 |
if (!t64 && o64) return (ERROR_MSG(_T("%") NPRIns _T("\n"), "Instruction only supported by 64-bit targets!"), PS_ERROR); |
| 4251 |
ent.which=EW_INTCMP; |
| 4252 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 4253 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 4254 |
ent.offsets[5]=(which_token == TOK_INTCMPU || which_token == TOK_INT64CMPU || which_token == TOK_INTPTRCMPU) | (t64 && !o32 ? 0x8000 : 0); |
| 4255 |
if (process_jump(line,3,&ent.offsets[2]) | process_jump(line,4,&ent.offsets[3]) | process_jump(line,5,&ent.offsets[4])) |
| 4256 |
PRINTHELP() |
| 4257 |
SCRIPT_MSG(_T("%") NPRIs _T(" %") NPRIs _T(":%") NPRIs _T(" equal=%") NPRIs _T(", < %") NPRIs _T(", > %") NPRIs _T("\n"),line.gettoken_str(0), |
| 4258 |
line.gettoken_str(1),line.gettoken_str(2), line.gettoken_str(3),line.gettoken_str(4),line.gettoken_str(5)); |
| 4259 |
return add_entry(&ent); |
| 4260 |
} |
| 4261 |
#else |
| 4262 |
case TOK_INTOP: case TOK_INTPTROP: |
| 4263 |
case TOK_INTFMT: case TOK_INT64FMT: |
| 4264 |
case TOK_INTCMP: case TOK_INTCMPU: case TOK_INT64CMP: case TOK_INT64CMPU: case TOK_INTPTRCMP: case TOK_INTPTRCMPU: |
| 4265 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_INTOPTS not defined.\n"), line.gettoken_str(0)); |
| 4266 |
return PS_ERROR; |
| 4267 |
#endif //~ NSIS_SUPPORT_INTOPTS |
| 4268 |
#ifdef NSIS_SUPPORT_REGISTRYFUNCTIONS |
| 4269 |
case TOK_READREGSTR: |
| 4270 |
case TOK_READREGDWORD: |
| 4271 |
{ |
| 4272 |
ent.which=EW_READREGSTR; |
| 4273 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 4274 |
HKEY hRK = ParseRegRootKey(line,2); |
| 4275 |
if (ent.offsets[0] == -1 || INVALIDREGROOT == hRK) PRINTHELP() |
| 4276 |
ent.offsets[1]=REGROOTKEYTOINT(hRK); |
| 4277 |
ent.offsets[2]=add_string(line.gettoken_str(3)); |
| 4278 |
ent.offsets[3]=add_string(line.gettoken_str(4)); |
| 4279 |
if (which_token == TOK_READREGDWORD) ent.offsets[4]=1; |
| 4280 |
else ent.offsets[4]=0; |
| 4281 |
if (line.gettoken_str(3)[0] == _T('\\')) |
| 4282 |
warning_fl(DW_PARSE_REGPATHPREFIX, _T("%") NPRIs _T(": registry path name begins with \'\\\', may cause problems"),line.gettoken_str(0)); |
| 4283 |
|
| 4284 |
SCRIPT_MSG(_T("%") NPRIs _T(" %") NPRIs _T(" %") NPRIs _T("\\%") NPRIs _T("\\%") NPRIs _T("\n"),line.gettoken_str(0), |
| 4285 |
line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(4)); |
| 4286 |
} |
| 4287 |
return add_entry(&ent); |
| 4288 |
case TOK_DELETEREGVALUE: |
| 4289 |
case TOK_DELETEREGKEY: |
| 4290 |
{ |
| 4291 |
int a=1, iskeyop; |
| 4292 |
if ((iskeyop = which_token == TOK_DELETEREGKEY)) |
| 4293 |
{ |
| 4294 |
for (;; ++a) |
| 4295 |
{ |
| 4296 |
switch(line.gettoken_enum(a,_T("/ifempty\0/ifnosubkeys\0/ifnovalues\0"))) |
| 4297 |
{ |
| 4298 |
case 0: ent.offsets[4]|=((DELREGKEY_ONLYIFNOSUBKEYS|DELREGKEY_ONLYIFNOVALUES)<<DELREGKEYFLAGSSHIFT); continue; |
| 4299 |
case 1: ent.offsets[4]|=((DELREGKEY_ONLYIFNOSUBKEYS )<<DELREGKEYFLAGSSHIFT); continue; |
| 4300 |
case 2: ent.offsets[4]|=(( DELREGKEY_ONLYIFNOVALUES)<<DELREGKEYFLAGSSHIFT); continue; |
| 4301 |
} |
| 4302 |
break; |
| 4303 |
} |
| 4304 |
if (line.gettoken_str(a+2)[0]) PRINTHELP() |
| 4305 |
} |
| 4306 |
HKEY hRK=ParseRegRootKey(line,a); |
| 4307 |
if (INVALIDREGROOT == hRK) PRINTHELP() |
| 4308 |
ent.which=EW_DELREG; |
| 4309 |
ent.offsets[1]=REGROOTKEYTOINTEX(hRK, iskeyop); // DELETEREGKEY needs the REGSAM view bits in parm4 and NOT in HKEY while DELETEREGVALUE needs them in HKEY. |
| 4310 |
ent.offsets[2]=add_string(line.gettoken_str(a+1)); |
| 4311 |
ent.offsets[3]=iskeyop ? 0 : add_string(line.gettoken_str(a+2)); |
| 4312 |
ent.offsets[4]|=iskeyop ? DELREG_KEY|(REGROOTVIEWTOSAMVIEW(hRK)<<DELREGKEYFLAGSSHIFT) : DELREG_VALUE; |
| 4313 |
if (line.gettoken_str(a+1)[0] == _T('\\')) |
| 4314 |
warning_fl(DW_PARSE_REGPATHPREFIX, _T("%") NPRIs _T(": registry path name begins with \'\\\', may cause problems"),line.gettoken_str(0)); |
| 4315 |
if (iskeyop) |
| 4316 |
SCRIPT_MSG(_T("DeleteRegKey: %") NPRIs _T("\\%") NPRIs _T("\n"),line.gettoken_str(a),line.gettoken_str(a+1)); |
| 4317 |
else |
| 4318 |
SCRIPT_MSG(_T("DeleteRegValue: %") NPRIs _T("\\%") NPRIs _T("\\%") NPRIs _T("\n"),line.gettoken_str(a),line.gettoken_str(a+1),line.gettoken_str(a+2)); |
| 4319 |
} |
| 4320 |
return add_entry(&ent); |
| 4321 |
case TOK_WRITEREGSTR: case TOK_WRITEREGEXPANDSTR: |
| 4322 |
case TOK_WRITEREGBIN: case TOK_WRITEREGNONE: |
| 4323 |
case TOK_WRITEREGMULTISZ: |
| 4324 |
case TOK_WRITEREGDWORD: |
| 4325 |
{ |
| 4326 |
const TCHAR*cmdname=get_commandtoken_name(which_token); |
| 4327 |
int reg5=0==line.gettoken_enum(1,_T("/REGEDIT5\0")), multisz=which_token == TOK_WRITEREGMULTISZ; |
| 4328 |
if (reg5) line.eattoken(); |
| 4329 |
HKEY hRK=ParseRegRootKey(line,1); |
| 4330 |
if (INVALIDREGROOT == hRK || reg5 != multisz) PRINTHELPEX(cmdname); // WriteRegMultiStr only supports the /REGEDIT5 serialized format right now but we really should allow variables at some point. |
| 4331 |
ent.which=EW_WRITEREG; |
| 4332 |
ent.offsets[0]=REGROOTKEYTOINT(hRK); |
| 4333 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 4334 |
if (line.gettoken_str(2)[0] == _T('\\')) |
| 4335 |
warning_fl(DW_PARSE_REGPATHPREFIX, _T("%") NPRIs _T(": registry path name begins with \'\\\', may cause problems"),cmdname); |
| 4336 |
ent.offsets[2]=add_string(line.gettoken_str(3)); |
| 4337 |
if (which_token == TOK_WRITEREGSTR || which_token == TOK_WRITEREGEXPANDSTR) |
| 4338 |
{ |
| 4339 |
SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T("\\%") NPRIs _T("\\%") NPRIs _T("=%") NPRIs _T("\n"), |
| 4340 |
cmdname,line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(4)); |
| 4341 |
ent.offsets[3]=add_string(line.gettoken_str(4)); |
| 4342 |
ent.offsets[4]=ent.offsets[5]=REG_SZ; |
| 4343 |
if (which_token == TOK_WRITEREGEXPANDSTR) |
| 4344 |
ent.offsets[5]=REG_EXPAND_SZ; |
| 4345 |
} |
| 4346 |
if (which_token == TOK_WRITEREGBIN || multisz || which_token == TOK_WRITEREGNONE) |
| 4347 |
{ |
| 4348 |
char data[3*NSIS_MAX_STRLEN]; |
| 4349 |
int data_len=line.gettoken_binstrdata(4, data, sizeof(data)), none=which_token == TOK_WRITEREGNONE; |
| 4350 |
if (data_len < 0) |
| 4351 |
{ |
| 4352 |
if (data_len == -2) PRINTHELPEX(cmdname); |
| 4353 |
ERROR_MSG(_T("%") NPRIs _T(": %d bytes of data exceeded\n"),cmdname,sizeof(data)); |
| 4354 |
return PS_ERROR; |
| 4355 |
} |
| 4356 |
if (multisz && (data_len < 4 || 0 != read_ptr_as<UINT32>(&data[data_len-4]))) PRINTHELPEX(cmdname); // Must end with 4 zero bytes |
| 4357 |
SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T("\\%") NPRIs _T("\\%") NPRIs _T("=%") NPRIs _T("\n"), |
| 4358 |
cmdname,line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(4)); |
| 4359 |
if (multisz && !build_unicode) for (int p1=0, p2=p1; p1 < data_len; data_len--) data[p1++]=data[p2], p2+=2; // BUGBUG: Should convert each string from UTF-16 to DBCS but only exehead knows the codepage, limited to ASCII for now. |
| 4360 |
ent.offsets[3]=add_db_data(data,data_len); |
| 4361 |
if (ent.offsets[3] < 0) return PS_ERROR; |
| 4362 |
ent.offsets[4]=REG_BINARY, ent.offsets[5]=none?REG_NONE:multisz?REG_MULTI_SZ:REG_BINARY; |
| 4363 |
} |
| 4364 |
if (which_token == TOK_WRITEREGDWORD) |
| 4365 |
{ |
| 4366 |
ent.offsets[3]=add_string(line.gettoken_str(4)); |
| 4367 |
ent.offsets[4]=ent.offsets[5]=REG_DWORD; |
| 4368 |
|
| 4369 |
SCRIPT_MSG(_T("WriteRegDWORD: %") NPRIs _T("\\%") NPRIs _T("\\%") NPRIs _T("=%") NPRIs _T("\n"), |
| 4370 |
line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(4)); |
| 4371 |
} |
| 4372 |
} |
| 4373 |
return add_entry(&ent); |
| 4374 |
case TOK_ENUMREGKEY: |
| 4375 |
case TOK_ENUMREGVAL: |
| 4376 |
{ |
| 4377 |
ent.which=EW_REGENUM; |
| 4378 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 4379 |
HKEY hRK=ParseRegRootKey(line,2); |
| 4380 |
if (ent.offsets[0] == -1 || INVALIDREGROOT == hRK) PRINTHELP() |
| 4381 |
ent.offsets[1]=REGROOTKEYTOINT(hRK); |
| 4382 |
ent.offsets[2]=add_string(line.gettoken_str(3)); |
| 4383 |
ent.offsets[3]=add_string(line.gettoken_str(4)); |
| 4384 |
ent.offsets[4]=which_token == TOK_ENUMREGKEY; |
| 4385 |
if (line.gettoken_str(3)[0] == _T('\\')) warning_fl(DW_PARSE_REGPATHPREFIX, _T("%") NPRIs _T(": registry path name begins with \'\\\', may cause problems"),line.gettoken_str(0)); |
| 4386 |
SCRIPT_MSG(_T("%") NPRIs _T(" %") NPRIs _T(" %") NPRIs _T("\\%") NPRIs _T("\\%") NPRIs _T("\n"),which_token == TOK_ENUMREGKEY ? _T("EnumRegKey") : _T("EnumRegValue"), |
| 4387 |
line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(4)); |
| 4388 |
} |
| 4389 |
return add_entry(&ent); |
| 4390 |
#else |
| 4391 |
case TOK_READREGSTR: |
| 4392 |
case TOK_READREGDWORD: |
| 4393 |
case TOK_DELETEREGVALUE: |
| 4394 |
case TOK_DELETEREGKEY: |
| 4395 |
case TOK_WRITEREGSTR: |
| 4396 |
case TOK_WRITEREGEXPANDSTR: |
| 4397 |
case TOK_WRITEREGBIN: |
| 4398 |
case TOK_WRITEREGMULTISZ: |
| 4399 |
case TOK_WRITEREGDWORD: |
| 4400 |
case TOK_ENUMREGKEY: |
| 4401 |
case TOK_ENUMREGVAL: |
| 4402 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_REGISTRYFUNCTIONS not defined.\n"), line.gettoken_str(0)); |
| 4403 |
return PS_ERROR; |
| 4404 |
#endif //~ NSIS_SUPPORT_REGISTRYFUNCTIONS |
| 4405 |
#ifdef NSIS_SUPPORT_STACK |
| 4406 |
case TOK_EXCH: |
| 4407 |
{ |
| 4408 |
int swapitem=1; |
| 4409 |
int save=GetUserVarIndex(line, 1); |
| 4410 |
ent.which=EW_PUSHPOP; |
| 4411 |
if (line.gettoken_str(1)[0] && save<0) |
| 4412 |
{ |
| 4413 |
int succ=0; |
| 4414 |
swapitem=line.gettoken_int(1,&succ); |
| 4415 |
if (!succ || swapitem <= 0) PRINTHELP() |
| 4416 |
} |
| 4417 |
if (save>=0) |
| 4418 |
{ |
| 4419 |
SCRIPT_MSG(_T("Exch(%") NPRIs _T(",0)\n"),line.gettoken_str(1)); |
| 4420 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 4421 |
ent.offsets[1]=0; |
| 4422 |
ent.offsets[2]=0; |
| 4423 |
add_entry(&ent); |
| 4424 |
} |
| 4425 |
else SCRIPT_MSG(_T("Exch(st(%d),0)\n"),swapitem); |
| 4426 |
|
| 4427 |
ent.offsets[0]=0; |
| 4428 |
ent.offsets[1]=0; |
| 4429 |
ent.offsets[2]=swapitem; |
| 4430 |
|
| 4431 |
if (save>=0) |
| 4432 |
{ |
| 4433 |
add_entry(&ent); |
| 4434 |
ent.offsets[0]=save; |
| 4435 |
ent.offsets[1]=1; |
| 4436 |
ent.offsets[2]=0; |
| 4437 |
} |
| 4438 |
|
| 4439 |
DefineInnerLangString(NLF_INST_CORRUPTED); |
| 4440 |
} |
| 4441 |
return add_entry(&ent); |
| 4442 |
case TOK_PUSH: |
| 4443 |
ent.which=EW_PUSHPOP; |
| 4444 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 4445 |
ent.offsets[1]=0; |
| 4446 |
SCRIPT_MSG(_T("Push: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 4447 |
return add_entry(&ent); |
| 4448 |
case TOK_POP: |
| 4449 |
ent.which=EW_PUSHPOP; |
| 4450 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 4451 |
ent.offsets[1]=1; |
| 4452 |
if (ent.offsets[0] < 0) PRINTHELP() |
| 4453 |
SCRIPT_MSG(_T("Pop: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 4454 |
return add_entry(&ent); |
| 4455 |
#else |
| 4456 |
case TOK_POP: |
| 4457 |
case TOK_PUSH: |
| 4458 |
case TOK_EXCH: |
| 4459 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_STACK not defined.\n"), line.gettoken_str(0)); |
| 4460 |
return PS_ERROR; |
| 4461 |
#endif //~ NSIS_SUPPORT_STACK |
| 4462 |
#ifdef NSIS_SUPPORT_ENVIRONMENT |
| 4463 |
case TOK_READENVSTR: |
| 4464 |
ent.which=EW_READENVSTR; |
| 4465 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 4466 |
{ |
| 4467 |
TCHAR str[NSIS_MAX_STRLEN]; |
| 4468 |
_tcscpy(str, _T("%")); |
| 4469 |
_tcscat(str, line.gettoken_str(2)); |
| 4470 |
_tcscat(str, _T("%")); |
| 4471 |
ent.offsets[1]=add_string(str); |
| 4472 |
if (ent.offsets[0] < 0 || _tcslen(line.gettoken_str(2))<1) PRINTHELP() |
| 4473 |
} |
| 4474 |
ent.offsets[2]=1; |
| 4475 |
SCRIPT_MSG(_T("ReadEnvStr: %") NPRIs _T("->%") NPRIs _T("\n"),line.gettoken_str(2),line.gettoken_str(1)); |
| 4476 |
return add_entry(&ent); |
| 4477 |
case TOK_EXPANDENVSTRS: |
| 4478 |
ent.which=EW_READENVSTR; |
| 4479 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 4480 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 4481 |
ent.offsets[2]=0; |
| 4482 |
if (ent.offsets[0] < 0) PRINTHELP() |
| 4483 |
SCRIPT_MSG(_T("ExpandEnvStrings: %") NPRIs _T("->%") NPRIs _T("\n"),line.gettoken_str(2),line.gettoken_str(1)); |
| 4484 |
return add_entry(&ent); |
| 4485 |
#else |
| 4486 |
case TOK_EXPANDENVSTRS: |
| 4487 |
case TOK_READENVSTR: |
| 4488 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_ENVIRONMENT not defined.\n"), line.gettoken_str(0)); |
| 4489 |
return PS_ERROR; |
| 4490 |
#endif //~ NSIS_SUPPORT_ENVIRONMENT |
| 4491 |
#ifdef NSIS_SUPPORT_FINDFIRST |
| 4492 |
case TOK_FINDFIRST: |
| 4493 |
ent.which=EW_FINDFIRST; |
| 4494 |
ent.offsets[0]=GetUserVarIndex(line, 2); // out |
| 4495 |
ent.offsets[1]=GetUserVarIndex(line, 1); // handleout |
| 4496 |
ent.offsets[2]=add_string(line.gettoken_str(3)); // filespec |
| 4497 |
if (ent.offsets[0] < 0 || ent.offsets[1] < 0) PRINTHELP() |
| 4498 |
SCRIPT_MSG(_T("FindFirst: spec=\"%") NPRIs _T("\" handle=%") NPRIs _T(" output=%") NPRIs _T("\n"),line.gettoken_str(3),line.gettoken_str(1),line.gettoken_str(2)); |
| 4499 |
return add_entry(&ent); |
| 4500 |
case TOK_FINDNEXT: |
| 4501 |
ent.which=EW_FINDNEXT; |
| 4502 |
ent.offsets[0]=GetUserVarIndex(line, 2); |
| 4503 |
ent.offsets[1]=GetUserVarIndex(line, 1); |
| 4504 |
if (ent.offsets[0] < 0 || ent.offsets[1] < 0) PRINTHELP() |
| 4505 |
SCRIPT_MSG(_T("FindNext: handle=%") NPRIs _T(" output=%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 4506 |
return add_entry(&ent); |
| 4507 |
case TOK_FINDCLOSE: |
| 4508 |
ent.which=EW_FINDCLOSE; |
| 4509 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 4510 |
if (ent.offsets[0] < 0) PRINTHELP() |
| 4511 |
SCRIPT_MSG(_T("FindClose: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 4512 |
return add_entry(&ent); |
| 4513 |
#else |
| 4514 |
case TOK_FINDCLOSE: |
| 4515 |
case TOK_FINDNEXT: |
| 4516 |
case TOK_FINDFIRST: |
| 4517 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_FINDFIRST not defined.\n"), line.gettoken_str(0)); |
| 4518 |
return PS_ERROR; |
| 4519 |
#endif //~ NSIS_SUPPORT_FINDFIRST |
| 4520 |
#ifdef NSIS_SUPPORT_FILEFUNCTIONS |
| 4521 |
case TOK_FILEOPEN: |
| 4522 |
{ |
| 4523 |
ent.which=EW_FOPEN; |
| 4524 |
ent.offsets[0]=GetUserVarIndex(line, 1); // file handle |
| 4525 |
ent.offsets[3]=add_string(line.gettoken_str(2)); |
| 4526 |
ent.offsets[1]=0; //openmode |
| 4527 |
if (!_tcsicmp(line.gettoken_str(3),_T("r"))) |
| 4528 |
{ |
| 4529 |
ent.offsets[1]=GENERIC_READ; |
| 4530 |
ent.offsets[2]=OPEN_EXISTING; |
| 4531 |
} |
| 4532 |
else if (!_tcsicmp(line.gettoken_str(3),_T("w"))) |
| 4533 |
{ |
| 4534 |
ent.offsets[1]=GENERIC_WRITE; |
| 4535 |
ent.offsets[2]=CREATE_ALWAYS; |
| 4536 |
} |
| 4537 |
else if (!_tcsicmp(line.gettoken_str(3),_T("a"))) |
| 4538 |
{ |
| 4539 |
ent.offsets[1]=GENERIC_WRITE|GENERIC_READ; |
| 4540 |
ent.offsets[2]=OPEN_ALWAYS; |
| 4541 |
} |
| 4542 |
|
| 4543 |
if (ent.offsets[0] < 0 || !ent.offsets[1]) PRINTHELP() |
| 4544 |
} |
| 4545 |
SCRIPT_MSG(_T("FileOpen: %") NPRIs _T(" as %") NPRIs _T(" -> %") NPRIs _T("\n"),line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(1)); |
| 4546 |
return add_entry(&ent); |
| 4547 |
case TOK_FILECLOSE: |
| 4548 |
ent.which=EW_FCLOSE; |
| 4549 |
ent.offsets[0]=GetUserVarIndex(line, 1); // file handle |
| 4550 |
if (ent.offsets[0] < 0) PRINTHELP() |
| 4551 |
SCRIPT_MSG(_T("FileClose: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 4552 |
return add_entry(&ent); |
| 4553 |
case TOK_FILEREAD: |
| 4554 |
ent.which=EW_FGETS; |
| 4555 |
ent.offsets[0]=GetUserVarIndex(line, 1); // file handle |
| 4556 |
ent.offsets[1]=GetUserVarIndex(line, 2); // output string |
| 4557 |
if (line.gettoken_str(3)[0]) |
| 4558 |
ent.offsets[2]=add_string(line.gettoken_str(3)); |
| 4559 |
else |
| 4560 |
ent.offsets[2]=add_intstring(NSIS_MAX_STRLEN-1); |
| 4561 |
if (ent.offsets[0]<0 || ent.offsets[1]<0) PRINTHELP() |
| 4562 |
SCRIPT_MSG(_T("FileRead: %") NPRIs _T("->%") NPRIs _T(" (max:%") NPRIs _T(")\n"),line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3)); |
| 4563 |
return add_entry(&ent); |
| 4564 |
case TOK_FILEWRITE: |
| 4565 |
ent.which=EW_FPUTS; |
| 4566 |
ent.offsets[0]=GetUserVarIndex(line, 1); // file handle |
| 4567 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 4568 |
if (ent.offsets[0]<0) PRINTHELP() |
| 4569 |
SCRIPT_MSG(_T("FileWrite: %") NPRIs _T("->%") NPRIs _T("\n"),line.gettoken_str(2),line.gettoken_str(1)); |
| 4570 |
return add_entry(&ent); |
| 4571 |
case TOK_FILEREADBYTE: |
| 4572 |
ent.which=EW_FGETS; |
| 4573 |
ent.offsets[0]=GetUserVarIndex(line, 1); // file handle |
| 4574 |
ent.offsets[1]=GetUserVarIndex(line, 2); // output string |
| 4575 |
ent.offsets[2]=add_asciistring(_T("1")); |
| 4576 |
ent.offsets[3]=1; |
| 4577 |
if (ent.offsets[0]<0 || ent.offsets[1]<0) PRINTHELP() |
| 4578 |
SCRIPT_MSG(_T("FileReadByte: %") NPRIs _T("->%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 4579 |
return add_entry(&ent); |
| 4580 |
case TOK_FILEWRITEBYTE: |
| 4581 |
ent.which=EW_FPUTS; |
| 4582 |
ent.offsets[0]=GetUserVarIndex(line, 1); // file handle |
| 4583 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 4584 |
ent.offsets[2]=1; |
| 4585 |
if (ent.offsets[0]<0) PRINTHELP() |
| 4586 |
SCRIPT_MSG(_T("FileWriteByte: %") NPRIs _T("->%") NPRIs _T("\n"),line.gettoken_str(2),line.gettoken_str(1)); |
| 4587 |
return add_entry(&ent); |
| 4588 |
#ifdef _UNICODE |
| 4589 |
case TOK_FILEREADUTF16LE: |
| 4590 |
if (!build_unicode) |
| 4591 |
{ |
| 4592 |
ERROR_MSG(_T("Error: %") NPRIs _T(" is only available when building a Unicode installer\n"), line.gettoken_str(0)); |
| 4593 |
return PS_ERROR; |
| 4594 |
} |
| 4595 |
ent.which=EW_FGETWS; |
| 4596 |
ent.offsets[0]=GetUserVarIndex(line, 1); // file handle |
| 4597 |
ent.offsets[1]=GetUserVarIndex(line, 2); // output string |
| 4598 |
if (line.gettoken_str(3)[0]) |
| 4599 |
ent.offsets[2]=add_string(line.gettoken_str(3)); |
| 4600 |
else |
| 4601 |
ent.offsets[2]=add_intstring(NSIS_MAX_STRLEN-1); |
| 4602 |
if (ent.offsets[0]<0 || ent.offsets[1]<0) PRINTHELP() |
| 4603 |
SCRIPT_MSG(_T("FileReadUTF16LE: %") NPRIs _T("->%") NPRIs _T(" (max:%") NPRIs _T(")\n"),line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3)); |
| 4604 |
return add_entry(&ent); |
| 4605 |
case TOK_FILEWRITEUTF16LE: |
| 4606 |
if (!build_unicode) |
| 4607 |
{ |
| 4608 |
ERROR_MSG(_T("Error: %") NPRIs _T(" is only available when building a Unicode installer\n"), line.gettoken_str(0)); |
| 4609 |
return PS_ERROR; |
| 4610 |
} |
| 4611 |
{ |
| 4612 |
UINT bom=0, swofs=0; |
| 4613 |
if (!_tcsicmp(_T("/BOM"),line.gettoken_str(swofs+1))) ++bom, ++swofs; |
| 4614 |
if (!_tcsicmp(_T("/NoBOM"),line.gettoken_str(swofs+1))) bom = 0, ++swofs; // Undocumented switch |
| 4615 |
ent.which=EW_FPUTWS; |
| 4616 |
ent.offsets[0]=GetUserVarIndex(line, swofs+1); // file handle |
| 4617 |
ent.offsets[1]=add_string(line.gettoken_str(swofs+2)); |
| 4618 |
ent.offsets[3]=bom; |
| 4619 |
if (ent.offsets[0]<0 || line.getnumtokens()-swofs != 3) PRINTHELP() |
| 4620 |
SCRIPT_MSG(_T("FileWriteUTF16LE: %") NPRIs _T("->%") NPRIs _T("\n"),line.gettoken_str(swofs+2),line.gettoken_str(swofs+1)); |
| 4621 |
} |
| 4622 |
return add_entry(&ent); |
| 4623 |
case TOK_FILEREADWORD: |
| 4624 |
if (!build_unicode) |
| 4625 |
{ |
| 4626 |
ERROR_MSG(_T("Error: %") NPRIs _T(" is only available when building a Unicode installer\n"), line.gettoken_str(0)); |
| 4627 |
return PS_ERROR; |
| 4628 |
} |
| 4629 |
ent.which=EW_FGETWS; |
| 4630 |
ent.offsets[0]=GetUserVarIndex(line, 1); // file handle |
| 4631 |
ent.offsets[1]=GetUserVarIndex(line, 2); // output string |
| 4632 |
ent.offsets[2]=add_asciistring(_T("1")); |
| 4633 |
ent.offsets[3]=1; |
| 4634 |
if (ent.offsets[0]<0 || ent.offsets[1]<0) PRINTHELP() |
| 4635 |
SCRIPT_MSG(_T("FileReadWord: %") NPRIs _T("->%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 4636 |
return add_entry(&ent); |
| 4637 |
case TOK_FILEWRITEWORD: |
| 4638 |
if (!build_unicode) |
| 4639 |
{ |
| 4640 |
ERROR_MSG(_T("Error: %") NPRIs _T(" is only available when building a Unicode installer\n"), line.gettoken_str(0)); |
| 4641 |
return PS_ERROR; |
| 4642 |
} |
| 4643 |
ent.which=EW_FPUTWS; |
| 4644 |
ent.offsets[0]=GetUserVarIndex(line, 1); // file handle |
| 4645 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 4646 |
ent.offsets[2]=1; |
| 4647 |
if (ent.offsets[0]<0) PRINTHELP() |
| 4648 |
SCRIPT_MSG(_T("FileWriteWord: %") NPRIs _T("->%") NPRIs _T("\n"),line.gettoken_str(2),line.gettoken_str(1)); |
| 4649 |
return add_entry(&ent); |
| 4650 |
#endif //~ _UNICODE |
| 4651 |
case TOK_FILESEEK: |
| 4652 |
{ |
| 4653 |
const TCHAR *modestr; |
| 4654 |
int tab[3]={FILE_BEGIN,FILE_CURRENT,FILE_END}; |
| 4655 |
int mode=line.gettoken_enum(3,_T("SET\0CUR\0END\0")); |
| 4656 |
ent.which=EW_FSEEK; |
| 4657 |
ent.offsets[0]=GetUserVarIndex(line, 1); |
| 4658 |
ent.offsets[1]=GetUserVarIndex(line, 4); |
| 4659 |
ent.offsets[2]=add_string(line.gettoken_str(2)); |
| 4660 |
|
| 4661 |
if (mode<0 && !line.gettoken_str(3)[0]) |
| 4662 |
{ |
| 4663 |
mode=0; |
| 4664 |
modestr=_T("SET"); |
| 4665 |
} |
| 4666 |
else modestr=line.gettoken_str(3); |
| 4667 |
|
| 4668 |
if (mode<0 || ent.offsets[0] < 0 || (ent.offsets[1]<0 && line.gettoken_str(4)[0])) PRINTHELP() |
| 4669 |
ent.offsets[3]=tab[mode]; |
| 4670 |
SCRIPT_MSG(_T("FileSeek: fp=%") NPRIs _T(", ofs=%") NPRIs _T(", mode=%") NPRIs _T(", output=%") NPRIs _T("\n"), |
| 4671 |
line.gettoken_str(1), |
| 4672 |
line.gettoken_str(2), |
| 4673 |
modestr, |
| 4674 |
line.gettoken_str(4)); |
| 4675 |
} |
| 4676 |
|
| 4677 |
return add_entry(&ent); |
| 4678 |
#else |
| 4679 |
case TOK_FILEOPEN: |
| 4680 |
case TOK_FILECLOSE: |
| 4681 |
case TOK_FILESEEK: |
| 4682 |
case TOK_FILEREAD: |
| 4683 |
case TOK_FILEWRITE: |
| 4684 |
case TOK_FILEREADBYTE: |
| 4685 |
case TOK_FILEWRITEBYTE: |
| 4686 |
#ifdef _UNICODE |
| 4687 |
case TOK_FILEREADUTF16LE: |
| 4688 |
case TOK_FILEWRITEUTF16LE: |
| 4689 |
case TOK_FILEREADWORD: |
| 4690 |
case TOK_FILEWRITEWORD: |
| 4691 |
#endif |
| 4692 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_FILEFUNCTIONS not defined.\n"), line.gettoken_str(0)); |
| 4693 |
return PS_ERROR; |
| 4694 |
#endif //~ NSIS_SUPPORT_FILEFUNCTIONS |
| 4695 |
#ifdef NSIS_SUPPORT_REBOOT |
| 4696 |
case TOK_REBOOT: |
| 4697 |
{ |
| 4698 |
int ret = add_entry_direct(EW_REBOOT, 0xbadf00d); |
| 4699 |
if (ret != PS_OK) return ret; |
| 4700 |
|
| 4701 |
ret = add_entry_direct(EW_QUIT); |
| 4702 |
if (ret != PS_OK) return ret; |
| 4703 |
|
| 4704 |
SCRIPT_MSG(_T("Reboot!\n")); |
| 4705 |
|
| 4706 |
DefineInnerLangString(NLF_INST_CORRUPTED); |
| 4707 |
} |
| 4708 |
return PS_OK; |
| 4709 |
case TOK_IFREBOOTFLAG: |
| 4710 |
return add_flag_instruction_entry(which_token, EW_IFFLAG, line, FLAG_OFFSET(exec_reboot), ~0); //new value mask - keep flag |
| 4711 |
case TOK_SETREBOOTFLAG: |
| 4712 |
ent.offsets[1] = line.gettoken_enum(1,_T("false\0true\0")); |
| 4713 |
if (ent.offsets[1] < 0) PRINTHELP() |
| 4714 |
return add_flag_instruction_entry(which_token, EW_SETFLAG, line, FLAG_OFFSET(exec_reboot), add_intstring(ent.offsets[1])); |
| 4715 |
#else |
| 4716 |
case TOK_REBOOT: |
| 4717 |
case TOK_IFREBOOTFLAG: |
| 4718 |
case TOK_SETREBOOTFLAG: |
| 4719 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_REBOOT not defined.\n"), line.gettoken_str(0)); |
| 4720 |
return PS_ERROR; |
| 4721 |
#endif //~ NSIS_SUPPORT_REBOOT |
| 4722 |
#ifdef NSIS_CONFIG_LOG |
| 4723 |
case TOK_LOGSET: |
| 4724 |
ent.which=EW_LOG; |
| 4725 |
ent.offsets[0]=1; |
| 4726 |
ent.offsets[1]=line.gettoken_enum(1,_T("off\0on\0")); |
| 4727 |
if (ent.offsets[1]<0) PRINTHELP() |
| 4728 |
SCRIPT_MSG(_T("LogSet: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 4729 |
return add_entry(&ent); |
| 4730 |
case TOK_LOGTEXT: |
| 4731 |
ent.which=EW_LOG; |
| 4732 |
ent.offsets[0]=0; |
| 4733 |
ent.offsets[1]=add_string(line.gettoken_str(1)); |
| 4734 |
SCRIPT_MSG(_T("LogText \"%") NPRIs _T("\"\n"),line.gettoken_str(1)); |
| 4735 |
return add_entry(&ent); |
| 4736 |
#else |
| 4737 |
case TOK_LOGSET: |
| 4738 |
case TOK_LOGTEXT: |
| 4739 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_LOG not defined.\n"), line.gettoken_str(0)); |
| 4740 |
return PS_ERROR; |
| 4741 |
#endif //~ NSIS_CONFIG_LOG |
| 4742 |
#ifdef NSIS_CONFIG_COMPONENTPAGE |
| 4743 |
case TOK_SECTIONSETTEXT: |
| 4744 |
ent.which=EW_SECTIONSET; |
| 4745 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 4746 |
ent.offsets[2]=SECTION_FIELD_SET(name_ptr); |
| 4747 |
ent.offsets[4]=add_string(line.gettoken_str(2)); |
| 4748 |
if (!IsIntOrUserVar(line,1)) PRINTHELP() |
| 4749 |
SCRIPT_MSG(_T("SectionSetText: %") NPRIs _T("=%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 4750 |
return add_entry(&ent); |
| 4751 |
case TOK_SECTIONGETTEXT: |
| 4752 |
ent.which=EW_SECTIONSET; |
| 4753 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 4754 |
ent.offsets[1]=GetUserVarIndex(line, 2); |
| 4755 |
ent.offsets[2]=SECTION_FIELD_GET(name_ptr); |
| 4756 |
if (!IsIntOrUserVar(line,1) || ent.offsets[1]<0) PRINTHELP() |
| 4757 |
SCRIPT_MSG(_T("SectionGetText: %") NPRIs _T("->%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 4758 |
return add_entry(&ent); |
| 4759 |
case TOK_SECTIONSETFLAGS: |
| 4760 |
{ |
| 4761 |
int num, conv; |
| 4762 |
ent.which=EW_SECTIONSET; |
| 4763 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 4764 |
ent.offsets[1]=(num=line.gettoken_intx(2,&conv), conv) ? add_intstring(num) : add_string(line.gettoken_str(2)); |
| 4765 |
ent.offsets[2]=SECTION_FIELD_SET(flags); |
| 4766 |
ent.offsets[3]=1; |
| 4767 |
if (!IsIntOrUserVar(line,1) || (!conv && !IsIntOrUserVar(line,2))) PRINTHELP() |
| 4768 |
SCRIPT_MSG(_T("SectionSetFlags: %") NPRIs _T("=%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 4769 |
return add_entry(&ent); |
| 4770 |
} |
| 4771 |
case TOK_SECTIONGETFLAGS: |
| 4772 |
ent.which=EW_SECTIONSET; |
| 4773 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 4774 |
ent.offsets[1]=GetUserVarIndex(line, 2); |
| 4775 |
ent.offsets[2]=SECTION_FIELD_GET(flags); |
| 4776 |
if (!IsIntOrUserVar(line,1) || ent.offsets[1]<0) PRINTHELP() |
| 4777 |
SCRIPT_MSG(_T("SectionGetFlags: %") NPRIs _T("->%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 4778 |
return add_entry(&ent); |
| 4779 |
case TOK_INSTTYPESETTEXT: |
| 4780 |
ent.which=EW_INSTTYPESET; |
| 4781 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 4782 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 4783 |
ent.offsets[2]=1; |
| 4784 |
SCRIPT_MSG(_T("InstTypeSetText: %") NPRIs _T("=%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 4785 |
return add_entry(&ent); |
| 4786 |
case TOK_INSTTYPEGETTEXT: |
| 4787 |
ent.which=EW_INSTTYPESET; |
| 4788 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 4789 |
ent.offsets[1]=GetUserVarIndex(line, 2); |
| 4790 |
ent.offsets[2]=0; |
| 4791 |
if (!IsIntOrUserVar(line,1) || ent.offsets[1]<0) PRINTHELP() |
| 4792 |
SCRIPT_MSG(_T("InstTypeGetText: %") NPRIs _T("->%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 4793 |
return add_entry(&ent); |
| 4794 |
case TOK_SECTIONSETINSTTYPES: |
| 4795 |
{ |
| 4796 |
int num, conv; |
| 4797 |
ent.which=EW_SECTIONSET; |
| 4798 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 4799 |
ent.offsets[1]=(num=line.gettoken_intx(2,&conv), conv) ? add_intstring(num) : add_string(line.gettoken_str(2)); |
| 4800 |
ent.offsets[2]=SECTION_FIELD_SET(install_types); |
| 4801 |
if (!IsIntOrUserVar(line,1) || (!conv && !IsIntOrUserVar(line,2))) PRINTHELP() |
| 4802 |
SCRIPT_MSG(_T("SectionSetInstTypes: %") NPRIs _T("=%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 4803 |
return add_entry(&ent); |
| 4804 |
} |
| 4805 |
case TOK_SECTIONGETINSTTYPES: |
| 4806 |
ent.which=EW_SECTIONSET; |
| 4807 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 4808 |
ent.offsets[1]=GetUserVarIndex(line, 2); |
| 4809 |
ent.offsets[2]=SECTION_FIELD_GET(install_types); |
| 4810 |
if (!IsIntOrUserVar(line,1) || ent.offsets[1]<0) PRINTHELP() |
| 4811 |
SCRIPT_MSG(_T("SectionGetInstTypes: %") NPRIs _T("->%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 4812 |
return add_entry(&ent); |
| 4813 |
case TOK_SECTIONSETSIZE: |
| 4814 |
ent.which=EW_SECTIONSET; |
| 4815 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 4816 |
ent.offsets[1]=add_string(line.gettoken_str(2)); |
| 4817 |
ent.offsets[2]=SECTION_FIELD_SET(size_kb); |
| 4818 |
SCRIPT_MSG(_T("SectionSetSize: %") NPRIs _T("=%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 4819 |
return add_entry(&ent); |
| 4820 |
case TOK_SECTIONGETSIZE: |
| 4821 |
ent.which=EW_SECTIONSET; |
| 4822 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 4823 |
ent.offsets[1]=GetUserVarIndex(line, 2); |
| 4824 |
ent.offsets[2]=SECTION_FIELD_GET(size_kb); |
| 4825 |
if (!IsIntOrUserVar(line,1) || ent.offsets[1]<0) PRINTHELP() |
| 4826 |
SCRIPT_MSG(_T("SectionGetSize: %") NPRIs _T("->%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2)); |
| 4827 |
return add_entry(&ent); |
| 4828 |
case TOK_SETCURINSTTYPE: |
| 4829 |
ent.which=EW_INSTTYPESET; |
| 4830 |
ent.offsets[0]=add_string(line.gettoken_str(1)); |
| 4831 |
ent.offsets[1]=0; |
| 4832 |
ent.offsets[2]=1; |
| 4833 |
ent.offsets[3]=1; |
| 4834 |
SCRIPT_MSG(_T("SetCurInstType: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 4835 |
return add_entry(&ent); |
| 4836 |
case TOK_GETCURINSTTYPE: |
| 4837 |
ent.which=EW_INSTTYPESET; |
| 4838 |
ent.offsets[0]=0; |
| 4839 |
ent.offsets[1]=GetUserVarIndex(line,1); |
| 4840 |
ent.offsets[2]=0; |
| 4841 |
ent.offsets[3]=1; |
| 4842 |
if (ent.offsets[1]<0) PRINTHELP() |
| 4843 |
SCRIPT_MSG(_T("GetCurInstType: %") NPRIs _T("\n"),line.gettoken_str(1)); |
| 4844 |
return add_entry(&ent); |
| 4845 |
#else |
| 4846 |
case TOK_SECTIONSETTEXT: |
| 4847 |
case TOK_SECTIONGETTEXT: |
| 4848 |
case TOK_SECTIONSETFLAGS: |
| 4849 |
case TOK_SECTIONGETFLAGS: |
| 4850 |
case TOK_SECTIONSETSIZE: |
| 4851 |
case TOK_SECTIONGETSIZE: |
| 4852 |
case TOK_SECTIONSETINSTTYPES: |
| 4853 |
case TOK_SECTIONGETINSTTYPES: |
| 4854 |
case TOK_SETCURINSTTYPE: |
| 4855 |
case TOK_GETCURINSTTYPE: |
| 4856 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_COMPONENTPAGE not defined.\n"), line.gettoken_str(0)); |
| 4857 |
return PS_ERROR; |
| 4858 |
#endif //~ NSIS_CONFIG_COMPONENTPAGE |
| 4859 |
#ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT |
| 4860 |
case TOK_SETBRANDINGIMAGE: |
| 4861 |
{ |
| 4862 |
SCRIPT_MSG(_T("SetBrandingImage: ")); |
| 4863 |
ent.which=EW_LOADANDSETIMAGE; |
| 4864 |
for (int i = 1; i < line.getnumtokens(); i++) |
| 4865 |
if (!_tcsnicmp(line.gettoken_str(i),_T("/IMGID="),7)) { |
| 4866 |
ent.offsets[2]=_ttoi(line.gettoken_str(i)+7); |
| 4867 |
SCRIPT_MSG(_T("/IMGID=%d "),ent.offsets[2]); |
| 4868 |
} |
| 4869 |
else if (!_tcsicmp(line.gettoken_str(i),_T("/RESIZETOFIT"))) { |
| 4870 |
ent.offsets[3]=LASIF_FITCTLW|LASIF_FITCTLH; |
| 4871 |
SCRIPT_MSG(_T("/RESIZETOFIT ")); |
| 4872 |
} |
| 4873 |
else if (!ent.offsets[1]) { |
| 4874 |
ent.offsets[1]=add_string(line.gettoken_str(i)); |
| 4875 |
SCRIPT_MSG(_T("\"%") NPRIs _T("\" "), line.gettoken_str(i)); |
| 4876 |
} |
| 4877 |
else { |
| 4878 |
SCRIPT_MSG(_T("\n")); |
| 4879 |
PRINTHELP(); |
| 4880 |
} |
| 4881 |
SCRIPT_MSG(_T("\n")); |
| 4882 |
if (!ent.offsets[2]) |
| 4883 |
{ |
| 4884 |
ent.offsets[2]=branding_image_id; |
| 4885 |
if (!branding_image_found) { |
| 4886 |
ERROR_MSG(_T("\nError: no branding image found in chosen UI!\n")); |
| 4887 |
return PS_ERROR; |
| 4888 |
} |
| 4889 |
} |
| 4890 |
ent.offsets[0]=-1; // Outvar |
| 4891 |
ent.offsets[3]|=LASIF_LR_LOADFROMFILE|LASIF_STRID; |
| 4892 |
} |
| 4893 |
return add_entry(&ent); |
| 4894 |
case TOK_LOADANDSETIMAGE: |
| 4895 |
{ |
| 4896 |
ent.which=EW_LOADANDSETIMAGE; |
| 4897 |
int tidx = 1, conv = 1, fail = 0; |
| 4898 |
unsigned int flags = LASIF_HWND, lrflagsin; |
| 4899 |
for (; tidx < line.getnumtokens(); tidx++) |
| 4900 |
{ |
| 4901 |
if (!_tcsicmp(line.gettoken_str(tidx),_T("/EXERESOURCE"))) flags |= LASIF_EXERES; |
| 4902 |
else if (!_tcsicmp(line.gettoken_str(tidx),_T("/STRINGID"))) flags |= LASIF_STRID; |
| 4903 |
else if (!_tcsicmp(line.gettoken_str(tidx),_T("/RESIZETOFIT"))) flags |= LASIF_FITCTLW|LASIF_FITCTLH; |
| 4904 |
else if (!_tcsicmp(line.gettoken_str(tidx),_T("/RESIZETOFITWIDTH"))) flags |= LASIF_FITCTLW; |
| 4905 |
else if (!_tcsicmp(line.gettoken_str(tidx),_T("/RESIZETOFITHEIGHT"))) flags |= LASIF_FITCTLH; |
| 4906 |
else if (!_tcsicmp(line.gettoken_str(tidx),_T("/GETDLGITEM"))) flags &= ~LASIF_HWND; // Reuses TOK_SETBRANDINGIMAGE functionality |
| 4907 |
else { if (line.gettoken_str(tidx)[0] == '/') ++fail; break; } |
| 4908 |
} |
| 4909 |
ent.offsets[2] = (flags & LASIF_HWND) ? add_string(line.gettoken_str(tidx+0)) : line.gettoken_int(tidx+0, &conv); fail |= !conv; // HWND/CtrlId |
| 4910 |
flags |= (line.gettoken_int(tidx+1, &conv) & LASIM_IMAGE); fail |= !conv; // IMAGE_* |
| 4911 |
flags |= ((lrflagsin = line.gettoken_intx(tidx+2, &conv)) & LASIM_LR); fail |= !conv; // LR_* |
| 4912 |
ent.offsets[1] = (flags & LASIF_STRID) ? add_string(line.gettoken_str(tidx+3)) : line.gettoken_int(tidx+3, &conv); fail |= !conv; // Image path/resid |
| 4913 |
ent.offsets[3] = flags; // Packed flags, IMAGE_* and LR_* |
| 4914 |
ent.offsets[0] = GetUserVarIndex(line, tidx+4); // Outvar |
| 4915 |
SCRIPT_MSG(_T("LoadAndSetImage %") NPRIs _T(" %#x \"%") NPRIs _T("\""), line.gettoken_str(tidx+0), flags, line.gettoken_str(tidx+3)); |
| 4916 |
if (ent.offsets[0] >= 0) SCRIPT_MSG(_T(" ->%") NPRIs _T(""), line.gettoken_str(tidx+4)); |
| 4917 |
SCRIPT_MSG(_T("\n")); |
| 4918 |
if ((lrflagsin & LASIM_LR) != lrflagsin) warning_fl(DW_PARSE_NUMBEROUTOFSPEC, _T("Out of spec: \"%") NPRIs _T("\""), line.gettoken_str(tidx+2)); |
| 4919 |
if (fail) PRINTHELP(); |
| 4920 |
} |
| 4921 |
return add_entry(&ent); |
| 4922 |
#else |
| 4923 |
case TOK_SETBRANDINGIMAGE: |
| 4924 |
case TOK_LOADANDSETIMAGE: |
| 4925 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_ENHANCEDUI_SUPPORT not defined.\n"),line.gettoken_str(0)); |
| 4926 |
return PS_ERROR; |
| 4927 |
#endif //~ NSIS_CONFIG_ENHANCEDUI_SUPPORT |
| 4928 |
case TOK_DEFVAR: |
| 4929 |
{ |
| 4930 |
int a=1; |
| 4931 |
if (!_tcsicmp(line.gettoken_str(1),_T("/GLOBAL"))) |
| 4932 |
a++; |
| 4933 |
else if (line.getnumtokens() == 3) |
| 4934 |
PRINTHELP(); |
| 4935 |
|
| 4936 |
if (build_cursection) |
| 4937 |
{ |
| 4938 |
if (a==1) |
| 4939 |
{ |
| 4940 |
ERROR_MSG(_T("Var: currently, only global variables can be defined.\n")); |
| 4941 |
PRINTHELP(); |
| 4942 |
} |
| 4943 |
} |
| 4944 |
SCRIPT_MSG(_T("Var: \"%") NPRIs _T("\"\n"),line.gettoken_str(a)); |
| 4945 |
return DeclaredUserVar(line.gettoken_str(a)); |
| 4946 |
} |
| 4947 |
return PS_OK; |
| 4948 |
#ifdef NSIS_SUPPORT_VERSION_INFO |
| 4949 |
case TOK_VI_ADDKEY: |
| 4950 |
{ |
| 4951 |
LANGID LangID=0; |
| 4952 |
int a = 1; |
| 4953 |
// Allow people to force Neutral (if /LANG=* is not present it uses the default) |
| 4954 |
const bool forceneutrallang = !_tcsicmp(line.gettoken_str(a),_T("/LANG=0")); |
| 4955 |
|
| 4956 |
if (!_tcsnicmp(line.gettoken_str(a),_T("/LANG="),6)) |
| 4957 |
LangID=ParseLangId(line.gettoken_str(a++)+6); |
| 4958 |
if (line.getnumtokens()!=a+2) PRINTHELP(); |
| 4959 |
TCHAR *pKey = line.gettoken_str(a); |
| 4960 |
TCHAR *pValue = line.gettoken_str(a+1); |
| 4961 |
if ( !(*pKey) ) |
| 4962 |
{ |
| 4963 |
ERROR_MSG(_T("Error: empty name for version info key!\n")); |
| 4964 |
return PS_ERROR; |
| 4965 |
} |
| 4966 |
else |
| 4967 |
{ |
| 4968 |
SCRIPT_MSG(_T("%") NPRIs _T(": \"%") NPRIs _T("\" \"%") NPRIs _T("\"\n"), line.gettoken_str(0), line.gettoken_str(a), line.gettoken_str(a+1)); |
| 4969 |
const bool allowdeflangfallback = a <= 1 && !forceneutrallang; |
| 4970 |
if ( a > 1 && 0 == LangID && !forceneutrallang) |
| 4971 |
{ |
| 4972 |
ERROR_MSG(_T("%") NPRIs _T(": \"%") NPRIs _T("\" is not a valid language code!\n"),line.gettoken_str(0), line.gettoken_str(1)); |
| 4973 |
return PS_ERROR; |
| 4974 |
} |
| 4975 |
|
| 4976 |
unsigned int codepage; |
| 4977 |
// We rely on GetLangNameAndCPForVersionResource to update LangID if required |
| 4978 |
const TCHAR *lang_name = GetLangNameAndCPForVersionResource(LangID, &codepage, allowdeflangfallback); |
| 4979 |
|
| 4980 |
if ( rVersionInfo.SetKeyValue(LangID, codepage, pKey, pValue) ) |
| 4981 |
{ |
| 4982 |
ERROR_MSG(_T("%") NPRIs _T(": \"%") NPRIs _T("\" \"%04d-%") NPRIs _T("\" already defined!\n"),line.gettoken_str(0), line.gettoken_str(2), LangID, lang_name); |
| 4983 |
return PS_ERROR; |
| 4984 |
} |
| 4985 |
|
| 4986 |
return PS_OK; |
| 4987 |
} |
| 4988 |
} |
| 4989 |
case TOK_VI_SETPRODUCTVERSION: |
| 4990 |
case TOK_VI_SETFILEVERSION: |
| 4991 |
// Probably not required, but this code retains the <= 2.46 behaviour and |
| 4992 |
// does not fail on bad product version number here, it "validates" in CEXEBuild::AddVersionInfo() |
| 4993 |
// |
| 4994 |
// It is ok for us to use rVersionInfo as storage since VIProductVersion is required by VIAddVersionKey |
| 4995 |
{ |
| 4996 |
const bool settingFileVer = TOK_VI_SETFILEVERSION == which_token; |
| 4997 |
const unsigned int reuseFlag = settingFileVer ? 4 : 1; |
| 4998 |
if (reuseFlag & version_fixedflags) |
| 4999 |
{ |
| 5000 |
ERROR_MSG(_T("Error: %") NPRIs _T(" already defined!\n"), line.gettoken_str(0)); |
| 5001 |
return PS_ERROR; |
| 5002 |
} |
| 5003 |
version_fixedflags |= reuseFlag; |
| 5004 |
int imm, iml, ilm, ill; |
| 5005 |
const bool validInput = _stscanf(line.gettoken_str(1), _T("%d.%d.%d.%d"), &imm, &iml, &ilm, &ill) == 4; |
| 5006 |
if (settingFileVer) |
| 5007 |
{ |
| 5008 |
if (!validInput) |
| 5009 |
{ |
| 5010 |
ERROR_MSG(_T("Error: invalid %") NPRIs _T(" format, should be X.X.X.X\n"),line.gettoken_str(0)); |
| 5011 |
return PS_ERROR; |
| 5012 |
} |
| 5013 |
rVersionInfo.SetFileVersion(MAKELONG(iml, imm),MAKELONG(ill, ilm)); |
| 5014 |
} |
| 5015 |
else |
| 5016 |
{ |
| 5017 |
if (validInput) |
| 5018 |
{ |
| 5019 |
version_fixedflags |= 2; |
| 5020 |
rVersionInfo.SetProductVersion(MAKELONG(iml, imm),MAKELONG(ill, ilm)); |
| 5021 |
// FileVersion defaults to ProductVersion |
| 5022 |
if (!(4 & version_fixedflags)) rVersionInfo.SetFileVersion(MAKELONG(iml, imm),MAKELONG(ill, ilm)); |
| 5023 |
} |
| 5024 |
} |
| 5025 |
} |
| 5026 |
return PS_OK; |
| 5027 |
#else |
| 5028 |
case TOK_VI_ADDKEY: |
| 5029 |
case TOK_VI_SETPRODUCTVERSION: |
| 5030 |
case TOK_VI_SETFILEVERSION: |
| 5031 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_SUPPORT_VERSION_INFO not defined.\n"),line.gettoken_str(0)); |
| 5032 |
return PS_ERROR; |
| 5033 |
#endif //~ NSIS_SUPPORT_VERSION_INFO |
| 5034 |
case TOK_LOCKWINDOW: |
| 5035 |
#ifdef NSIS_LOCKWINDOW_SUPPORT |
| 5036 |
SCRIPT_MSG(_T("LockWindow: lock state=%d\n"),line.gettoken_str(1)); |
| 5037 |
ent.which=EW_LOCKWINDOW; |
| 5038 |
ent.offsets[0]=line.gettoken_enum(1,_T("on\0off\0")); |
| 5039 |
if (ent.offsets[0] == -1) PRINTHELP(); |
| 5040 |
return add_entry(&ent); |
| 5041 |
#else |
| 5042 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_LOCKWINDOW_SUPPORT not defined.\n"),line.gettoken_str(0)); |
| 5043 |
return PS_ERROR; |
| 5044 |
#endif //~ NSIS_LOCKWINDOW_SUPPORT |
| 5045 |
|
| 5046 |
// end of instructions |
| 5047 |
/////////////////////////////////////////////////////////////////////////////// |
| 5048 |
|
| 5049 |
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT |
| 5050 |
case TOK_PLUGINDIR: |
| 5051 |
{ |
| 5052 |
CEXEBuild::TARGETTYPE tt = m_target_type; |
| 5053 |
int numtok = line.getnumtokens() - 1; |
| 5054 |
TCHAR *path = line.gettoken_str(numtok); |
| 5055 |
const TCHAR *cmdnam = get_commandtoken_name(which_token), *arcstr = 0; |
| 5056 |
if (2 == numtok) |
| 5057 |
{ |
| 5058 |
arcstr = line.gettoken_str(--numtok); |
| 5059 |
if (_T('/') != *arcstr || CEXEBuild::TARGET_UNKNOWN == (tt = get_target_type(++arcstr))) |
| 5060 |
{ |
| 5061 |
print_bad_targettype_parameter(cmdnam, _T("/")); |
| 5062 |
return PS_ERROR; |
| 5063 |
} |
| 5064 |
} |
| 5065 |
if (1 == numtok && *path) |
| 5066 |
{ |
| 5067 |
const TCHAR *fmtstr = _T("%") NPRIs _T(": \"%") NPRIs _T("\"%") NPRIs _T("%") NPRIs _T("%") NPRIs _T("\n"); |
| 5068 |
SCRIPT_MSG(fmtstr, cmdnam, path, arcstr ? _T(" (") : _T(""), arcstr ? arcstr : _T(""), arcstr ? _T(")") : _T("")); |
| 5069 |
PATH_CONVERT(path); |
| 5070 |
m_plugins[tt].AddPluginsDir(path, is_targettype_64bit(tt), !!display_script); |
| 5071 |
return PS_OK; |
| 5072 |
} |
| 5073 |
} |
| 5074 |
PRINTHELP(); |
| 5075 |
case TOK__PLUGINCOMMAND: |
| 5076 |
{ |
| 5077 |
tstring command, dllPath; |
| 5078 |
|
| 5079 |
if (!m_pPlugins->GetCommandInfo(line.gettoken_str(0), command, dllPath)) |
| 5080 |
{ |
| 5081 |
ERROR_MSG(_T("Plugin command %") NPRIs _T(" conflicts with a plugin in another directory!\n"),command.c_str()); |
| 5082 |
return PS_ERROR; |
| 5083 |
} |
| 5084 |
|
| 5085 |
tstring dllName = get_file_name(dllPath); |
| 5086 |
int data_handle = m_pPlugins->GetDllDataHandle(!!uninstall_mode, command), ret; |
| 5087 |
|
| 5088 |
if (uninstall_mode) uninst_plugin_used = true; else plugin_used = true; |
| 5089 |
|
| 5090 |
// Initialize $PLUGINSDIR |
| 5091 |
ent.which=EW_CALL; |
| 5092 |
ent.offsets[0]=ns_func.add(uninstall_mode?_T("un.Initialize_____Plugins"):_T("Initialize_____Plugins"),0); |
| 5093 |
if ((ret=add_entry(&ent)) != PS_OK) return ret; |
| 5094 |
|
| 5095 |
TCHAR tempDLL[NSIS_MAX_STRLEN]; |
| 5096 |
wsprintf(tempDLL, _T("$PLUGINSDIR\\%") NPRIs, dllName.c_str()); // DLL name on the end-users machine |
| 5097 |
|
| 5098 |
// Add the DLL to the installer |
| 5099 |
if (data_handle == -1) |
| 5100 |
{ |
| 5101 |
int files_added=0; |
| 5102 |
const int old_build_allowskipfiles=build_allowskipfiles; |
| 5103 |
build_allowskipfiles=1; // on |
| 5104 |
const int old_build_overwrite=build_overwrite; |
| 5105 |
build_overwrite=1; // off |
| 5106 |
const int old_build_datesave=build_datesave; |
| 5107 |
build_datesave=0; // off |
| 5108 |
|
| 5109 |
// Jim Park: While the code looks as if the same DLL is added multiple |
| 5110 |
// times for each command in the DLL, this is actually not the case |
| 5111 |
// because of CEXEBuild::datablock_optimize() that tries to discover |
| 5112 |
// duplicates and reuse them. |
| 5113 |
ret=do_add_file(dllPath.c_str(),0,0,&files_added,tempDLL,2,&data_handle); // 2 means no size add |
| 5114 |
if (ret != PS_OK || files_added == 0) { |
| 5115 |
return files_added ? ret : PS_ERROR; |
| 5116 |
} |
| 5117 |
m_pPlugins->SetDllDataHandle(!!uninstall_mode, command, data_handle); |
| 5118 |
build_overwrite=old_build_overwrite; |
| 5119 |
build_datesave=old_build_datesave; |
| 5120 |
build_allowskipfiles=old_build_allowskipfiles; |
| 5121 |
} |
| 5122 |
else |
| 5123 |
{ |
| 5124 |
ent.which=EW_EXTRACTFILE; |
| 5125 |
|
| 5126 |
DefineInnerLangString(NLF_SKIPPED); |
| 5127 |
DefineInnerLangString(NLF_ERR_DECOMPRESSING); |
| 5128 |
DefineInnerLangString(NLF_ERR_WRITING); |
| 5129 |
DefineInnerLangString(NLF_EXTRACT); |
| 5130 |
DefineInnerLangString(NLF_CANT_WRITE); |
| 5131 |
|
| 5132 |
ent.offsets[0]=1; // overwrite off |
| 5133 |
ent.offsets[0]|=(MB_RETRYCANCEL|MB_ICONSTOP|(IDCANCEL<<21))<<3; |
| 5134 |
ent.offsets[1]=add_string(tempDLL); |
| 5135 |
ent.offsets[2]=data_handle; |
| 5136 |
ent.offsets[3]=0xffffffff; |
| 5137 |
ent.offsets[4]=0xffffffff; |
| 5138 |
ent.offsets[5]=DefineInnerLangString(NLF_FILE_ERROR); |
| 5139 |
if ((ret=add_entry(&ent)) != PS_OK) return ret; |
| 5140 |
} |
| 5141 |
|
| 5142 |
// SetDetailsPrint lastused (special) |
| 5143 |
ret=add_entry_direct(EW_SETFLAG, FLAG_OFFSET(status_update), 0, 1, -1); |
| 5144 |
if (ret != PS_OK) return ret; |
| 5145 |
|
| 5146 |
// Call the DLL |
| 5147 |
tstring funcname = get_string_suffix(command, _T("::")); |
| 5148 |
SCRIPT_MSG(_T("Plugin command: %") NPRIs,funcname.c_str()); |
| 5149 |
|
| 5150 |
int i = 1; |
| 5151 |
int nounload = 0; |
| 5152 |
if (!_tcsicmp(line.gettoken_str(i), _T("/NOUNLOAD"))) { |
| 5153 |
i++, nounload++; |
| 5154 |
} |
| 5155 |
|
| 5156 |
// First push dll args |
| 5157 |
int parmst=i; // we push 'em in reverse order |
| 5158 |
int nounloadmisused=0; |
| 5159 |
for (; i < line.getnumtokens(); i++) { |
| 5160 |
int w=parmst + (line.getnumtokens()-i - 1); |
| 5161 |
ent.which=EW_PUSHPOP; |
| 5162 |
ent.offsets[0]=add_string(line.gettoken_str(w)); |
| 5163 |
if (!_tcsicmp(line.gettoken_str(w), _T("/NOUNLOAD"))) nounloadmisused=1; |
| 5164 |
ent.offsets[1]=0; |
| 5165 |
ent.offsets[2]=0; |
| 5166 |
if ((ret=add_entry(&ent)) != PS_OK) return ret; |
| 5167 |
SCRIPT_MSG(_T(" %") NPRIs,line.gettoken_str(i)); |
| 5168 |
} |
| 5169 |
SCRIPT_MSG(_T("\n")); |
| 5170 |
if (nounloadmisused) |
| 5171 |
warning_fl(DW_PLUGIN_NOUNLOAD_PLACEMENT, _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")); |
| 5172 |
|
| 5173 |
// next, call it |
| 5174 |
ent.which=EW_REGISTERDLL; |
| 5175 |
ent.offsets[0]=add_string(tempDLL); |
| 5176 |
ent.offsets[1]=add_string(funcname.c_str()); |
| 5177 |
ent.offsets[2]=0; |
| 5178 |
ent.offsets[3]=nounload|build_plugin_unload; |
| 5179 |
ent.offsets[4]=1; |
| 5180 |
if ((ret=add_entry(&ent)) != PS_OK) return ret; |
| 5181 |
|
| 5182 |
DefineInnerLangString(NLF_SYMBOL_NOT_FOUND); |
| 5183 |
DefineInnerLangString(NLF_COULD_NOT_LOAD); |
| 5184 |
DefineInnerLangString(NLF_NO_OLE); |
| 5185 |
// not used anywhere: DefineInnerLangString(NLF_ERR_REG_DLL); |
| 5186 |
return PS_OK; |
| 5187 |
} |
| 5188 |
case TOK_INITPLUGINSDIR: |
| 5189 |
{ |
| 5190 |
int ret; |
| 5191 |
SCRIPT_MSG(_T("%") NPRIs _T("\n"),line.gettoken_str(0)); |
| 5192 |
if (uninstall_mode) uninst_plugin_used = true; |
| 5193 |
else plugin_used = true; |
| 5194 |
// Call [un.]Initialize_____Plugins |
| 5195 |
ent.which=EW_CALL; |
| 5196 |
ent.offsets[0]=ns_func.add(uninstall_mode?_T("un.Initialize_____Plugins"):_T("Initialize_____Plugins"),0); |
| 5197 |
if ((ret=add_entry(&ent)) != PS_OK) return ret; |
| 5198 |
// SetDetailsPrint lastused |
| 5199 |
ret=add_entry_direct(EW_SETFLAG, FLAG_OFFSET(status_update), 0, 1); |
| 5200 |
if (ret != PS_OK) return ret; |
| 5201 |
} |
| 5202 |
return PS_OK; |
| 5203 |
#else |
| 5204 |
case TOK_PLUGINDIR: |
| 5205 |
case TOK__PLUGINCOMMAND: |
| 5206 |
case TOK_INITPLUGINSDIR: |
| 5207 |
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_PLUGIN_SUPPORT not defined.\n"),line.gettoken_str(0)); |
| 5208 |
return PS_ERROR; |
| 5209 |
#endif //~ NSIS_CONFIG_PLUGIN_SUPPORT |
| 5210 |
|
| 5211 |
default: |
| 5212 |
break; |
| 5213 |
} |
| 5214 |
ERROR_MSG(_T("Invalid command \"%") NPRIs _T("\"\n"),line.gettoken_str(0)); |
| 5215 |
return PS_ERROR; |
| 5216 |
} |
| 5217 |
|
| 5218 |
#ifdef NSIS_SUPPORT_FILE |
| 5219 |
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) |
| 5220 |
{ |
| 5221 |
assert(!name_override || !recurse); |
| 5222 |
|
| 5223 |
tstring dir = get_dir_name(lgss), spec; |
| 5224 |
|
| 5225 |
if (dir == lgss) |
| 5226 |
dir = _T("."), spec = lgss; |
| 5227 |
else |
| 5228 |
spec = tstring(lgss).substr(dir.length() + 1, tstring::npos); |
| 5229 |
|
| 5230 |
if (spec == _T("")) spec = _T("*"); |
| 5231 |
|
| 5232 |
if (basedir == _T("")) { |
| 5233 |
dir_created = true; |
| 5234 |
if (recurse) { |
| 5235 |
// save $OUTDIR into $_OUTDIR [StrCpy $_OUTDIR $OUTDIR] |
| 5236 |
if (add_entry_direct(EW_ASSIGNVAR, m_UserVarNames.get(_T("_OUTDIR")), add_asciistring(_T("$OUTDIR"))) != PS_OK) { |
| 5237 |
return PS_ERROR; |
| 5238 |
} |
| 5239 |
} |
| 5240 |
} |
| 5241 |
|
| 5242 |
boost::scoped_ptr<dir_reader> dr( new_dir_reader() ); |
| 5243 |
dr->exclude(excluded); |
| 5244 |
dr->read(dir); |
| 5245 |
|
| 5246 |
// add files in the current directory |
| 5247 |
for (dir_reader::iterator files_itr = dr->files().begin(); |
| 5248 |
files_itr != dr->files().end(); |
| 5249 |
files_itr++) |
| 5250 |
{ |
| 5251 |
if (!dir_reader::matches(*files_itr, spec)) |
| 5252 |
continue; |
| 5253 |
|
| 5254 |
if (!dir_created && generatecode) { |
| 5255 |
SCRIPT_MSG(_T("%") NPRIs _T("File: Descending to: \"%") NPRIs _T("\"\n"), generatecode ? _T("") : _T("Reserve"), dir.c_str()); |
| 5256 |
|
| 5257 |
if (do_add_file_create_dir(dir, basedir, attrib) != PS_OK) { |
| 5258 |
return PS_ERROR; |
| 5259 |
} |
| 5260 |
|
| 5261 |
dir_created = true; |
| 5262 |
} |
| 5263 |
|
| 5264 |
if (add_file(dir, *files_itr, attrib, name_override, generatecode, data_handle) != PS_OK) { |
| 5265 |
return PS_ERROR; |
| 5266 |
} |
| 5267 |
|
| 5268 |
(*total_files)++; |
| 5269 |
} |
| 5270 |
|
| 5271 |
if (!recurse) return PS_OK; |
| 5272 |
// recurse into directories |
| 5273 |
for (dir_reader::iterator dirs_itr = dr->dirs().begin(); |
| 5274 |
dirs_itr != dr->dirs().end(); |
| 5275 |
dirs_itr++) |
| 5276 |
{ |
| 5277 |
tstring new_dir; |
| 5278 |
bool created = false; |
| 5279 |
|
| 5280 |
if (basedir == _T("")) |
| 5281 |
new_dir = *dirs_itr; |
| 5282 |
else |
| 5283 |
new_dir = basedir + _T('\\') + *dirs_itr; |
| 5284 |
|
| 5285 |
tstring new_spec = dir + PLATFORM_PATH_SEPARATOR_STR + *dirs_itr + PLATFORM_PATH_SEPARATOR_STR; |
| 5286 |
|
| 5287 |
if (!dir_reader::matches(*dirs_itr, spec)) { |
| 5288 |
new_spec += spec; |
| 5289 |
} else if (generatecode) { |
| 5290 |
// always create directories that match |
| 5291 |
|
| 5292 |
SCRIPT_MSG(_T("%") NPRIs _T("File: Descending to: \"%") NPRIs _T("\"\n"), generatecode ? _T("") : _T("Reserve"), new_spec.c_str()); |
| 5293 |
|
| 5294 |
if (do_add_file_create_dir(dir + _T('\\') + *dirs_itr, new_dir, attrib) != PS_OK) { |
| 5295 |
return PS_ERROR; |
| 5296 |
} |
| 5297 |
|
| 5298 |
created = true; |
| 5299 |
} |
| 5300 |
|
| 5301 |
const TCHAR *new_spec_c = new_spec.c_str(); |
| 5302 |
int res = do_add_file(new_spec_c, attrib, 1, total_files, NULL, generatecode, NULL, excluded, new_dir, created); |
| 5303 |
if (res != PS_OK) { |
| 5304 |
return PS_ERROR; |
| 5305 |
} |
| 5306 |
} |
| 5307 |
|
| 5308 |
if (basedir == _T("")) { |
| 5309 |
SCRIPT_MSG(_T("%") NPRIs _T("File: Returning to: \"%") NPRIs _T("\"\n"), generatecode ? _T("") : _T("Reserve"), dir.c_str()); |
| 5310 |
|
| 5311 |
// restore $OUTDIR from $_OUTDIR [SetOutPath $_OUTDIR] |
| 5312 |
if (add_entry_direct(EW_CREATEDIR, add_asciistring(_T("$_OUTDIR")), 1) != PS_OK) { |
| 5313 |
return PS_ERROR; |
| 5314 |
} |
| 5315 |
} |
| 5316 |
|
| 5317 |
return PS_OK; |
| 5318 |
} |
| 5319 |
|
| 5320 |
int CEXEBuild::add_file(const tstring& dir, const tstring& file, int attrib, const TCHAR *name_override, int generatecode, int *data_handle) { |
| 5321 |
tstring newfn_s = dir + PLATFORM_PATH_SEPARATOR_C + file; |
| 5322 |
const TCHAR *newfn = newfn_s.c_str(); |
| 5323 |
const TCHAR *filename = file.c_str(); |
| 5324 |
MMapFile mmap; |
| 5325 |
UINT64 filesize; |
| 5326 |
|
| 5327 |
#ifdef _WIN32 |
| 5328 |
HANDLE hFile = mmap.openfilehelper(newfn, filesize); |
| 5329 |
if (hFile == INVALID_HANDLE_VALUE) |
| 5330 |
{ |
| 5331 |
ERROR_MSG(_T("%") NPRIs _T("File: failed opening file \"%") NPRIs _T("\"\n"),generatecode?_T(""):_T("Reserve"),newfn); |
| 5332 |
return PS_ERROR; |
| 5333 |
} |
| 5334 |
MANAGE_WITH(hFile, CloseHandle); |
| 5335 |
#else |
| 5336 |
FILE *hFile = mmap.openfilehelper(newfn, filesize); |
| 5337 |
if (!hFile) |
| 5338 |
{ |
| 5339 |
ERROR_MSG(_T("%") NPRIs _T("File: failed opening file \"%") NPRIs _T("\"\n"),generatecode?_T(""):_T("Reserve"),newfn); |
| 5340 |
return PS_ERROR; |
| 5341 |
} |
| 5342 |
MANAGE_WITH(hFile, fclose); |
| 5343 |
const int fd = fileno(hFile); |
| 5344 |
#endif |
| 5345 |
if (!mmap.setfile(hFile, filesize) && filesize) |
| 5346 |
{ |
| 5347 |
ERROR_MSG(_T("%") NPRIs _T("File: failed creating mmap of \"%") NPRIs _T("\"\n"),generatecode?_T(""):_T("Reserve"),newfn); |
| 5348 |
return PS_ERROR; |
| 5349 |
} |
| 5350 |
DWORD len = (DWORD) filesize; |
| 5351 |
if (len != filesize) len = 0xffffffffUL - 1024; // truncate_cast but as large as possible |
| 5352 |
|
| 5353 |
if (generatecode&1) |
| 5354 |
section_add_size_kb((len+1023)/1024); |
| 5355 |
if (name_override) SCRIPT_MSG(_T("%") NPRIs _T("File: \"%") NPRIs _T("\"->\"%") NPRIs _T("\""),generatecode?_T(""):_T("Reserve"),filename,name_override); |
| 5356 |
else SCRIPT_MSG(_T("%") NPRIs _T("File: \"%") NPRIs _T("\""),generatecode?_T(""):_T("Reserve"),filename); |
| 5357 |
if (!build_compress_whole) |
| 5358 |
if (build_compress) SCRIPT_MSG(_T(" [compress]")); |
| 5359 |
fflush(stdout); |
| 5360 |
TCHAR buf[1024]; |
| 5361 |
int last_build_datablock_used=getcurdbsize(); |
| 5362 |
entry ent={0,}; |
| 5363 |
if (generatecode) |
| 5364 |
{ |
| 5365 |
ent.which=EW_EXTRACTFILE; |
| 5366 |
|
| 5367 |
DefineInnerLangString(NLF_SKIPPED); |
| 5368 |
DefineInnerLangString(NLF_ERR_DECOMPRESSING); |
| 5369 |
DefineInnerLangString(NLF_ERR_WRITING); |
| 5370 |
DefineInnerLangString(NLF_EXTRACT); |
| 5371 |
DefineInnerLangString(NLF_CANT_WRITE); |
| 5372 |
|
| 5373 |
ent.offsets[0]=build_overwrite; |
| 5374 |
if (name_override) |
| 5375 |
{ |
| 5376 |
ent.offsets[1]=add_string(name_override); |
| 5377 |
} |
| 5378 |
else |
| 5379 |
{ |
| 5380 |
const TCHAR *i=filename; |
| 5381 |
TCHAR *o=buf; |
| 5382 |
while (*i) |
| 5383 |
{ |
| 5384 |
const TCHAR c=*i++; |
| 5385 |
*o++=c; |
| 5386 |
if (c == _T('$')) *o++=_T('$'); // BUGBUG: We could overflow buf here |
| 5387 |
} |
| 5388 |
*o=0; |
| 5389 |
ent.offsets[1]=add_string(buf); |
| 5390 |
} |
| 5391 |
} |
| 5392 |
ent.offsets[2]=add_db_data(&mmap); |
| 5393 |
|
| 5394 |
mmap.clear(); |
| 5395 |
|
| 5396 |
if (ent.offsets[2] < 0) |
| 5397 |
return PS_ERROR; |
| 5398 |
|
| 5399 |
if (data_handle) |
| 5400 |
*data_handle=ent.offsets[2]; |
| 5401 |
|
| 5402 |
{ |
| 5403 |
DWORD s=getcurdbsize()-last_build_datablock_used; |
| 5404 |
if (s) s-=4; |
| 5405 |
if (s != len) |
| 5406 |
SCRIPT_MSG(_T(" %u/%u bytes\n"),s,len); |
| 5407 |
else |
| 5408 |
SCRIPT_MSG(_T(" %u bytes\n"),len); |
| 5409 |
} |
| 5410 |
|
| 5411 |
if (generatecode) |
| 5412 |
{ |
| 5413 |
if (build_datesave || build_overwrite>=0x3 /*ifnewer or ifdiff*/) |
| 5414 |
{ |
| 5415 |
#ifdef _WIN32 |
| 5416 |
FILETIME ft; |
| 5417 |
if (GetFileTime(hFile,NULL,NULL,&ft)) |
| 5418 |
{ |
| 5419 |
PULONGLONG fti = (PULONGLONG) &ft; |
| 5420 |
*fti -= *fti % 20000000; // FAT write time has a resolution of 2 seconds |
| 5421 |
ent.offsets[3]=ft.dwLowDateTime, ent.offsets[4]=ft.dwHighDateTime; |
| 5422 |
} |
| 5423 |
#else |
| 5424 |
struct stat st; |
| 5425 |
if (!fstat(fd, &st)) |
| 5426 |
{ |
| 5427 |
unsigned long long ll = (st.st_mtime * 10000000LL) + 116444736000000000LL; |
| 5428 |
ll -= ll % 20000000; // FAT write time has a resolution of 2 seconds |
| 5429 |
ent.offsets[3] = (int) ll, ent.offsets[4] = (int) (ll >> 32); |
| 5430 |
} |
| 5431 |
#endif |
| 5432 |
else |
| 5433 |
{ |
| 5434 |
ERROR_MSG(_T("%") NPRIs _T("File: failed getting file date from \"%") NPRIs _T("\"\n"),generatecode?_T(""):_T("Reserve"),newfn); |
| 5435 |
return PS_ERROR; |
| 5436 |
} |
| 5437 |
} |
| 5438 |
else |
| 5439 |
{ |
| 5440 |
ent.offsets[3]=0xffffffff, ent.offsets[4]=0xffffffff; |
| 5441 |
} |
| 5442 |
|
| 5443 |
// overwrite flag can be 0, 1, 2 or 3. in all cases, 2 bits |
| 5444 |
int mb = 0; |
| 5445 |
if (build_allowskipfiles) |
| 5446 |
{ |
| 5447 |
mb = MB_ABORTRETRYIGNORE | MB_ICONSTOP; |
| 5448 |
mb |= IDIGNORE << 21; // default for silent installers |
| 5449 |
} |
| 5450 |
else |
| 5451 |
{ |
| 5452 |
mb = MB_RETRYCANCEL | MB_ICONSTOP; |
| 5453 |
mb |= IDCANCEL << 21; // default for silent installers |
| 5454 |
} |
| 5455 |
ent.offsets[0] |= mb << 3; |
| 5456 |
ent.offsets[5] = DefineInnerLangString(build_allowskipfiles ? NLF_FILE_ERROR : NLF_FILE_ERROR_NOIGNORE); |
| 5457 |
} |
| 5458 |
|
| 5459 |
if (generatecode) |
| 5460 |
{ |
| 5461 |
int a=add_entry(&ent); |
| 5462 |
if (a != PS_OK) |
| 5463 |
return a; |
| 5464 |
if (attrib) |
| 5465 |
{ |
| 5466 |
#ifdef _WIN32 |
| 5467 |
ent.which=EW_SETFILEATTRIBUTES; |
| 5468 |
// $OUTDIR is the working directory |
| 5469 |
ent.offsets[0]=add_string(name_override?name_override:buf); |
| 5470 |
ent.offsets[1]=GetFileAttributes(newfn); |
| 5471 |
ent.offsets[2]=0; |
| 5472 |
ent.offsets[3]=0; |
| 5473 |
ent.offsets[4]=0; |
| 5474 |
ent.offsets[5]=0; |
| 5475 |
|
| 5476 |
if (INVALID_FILE_ATTRIBUTES != (DWORD)ent.offsets[1]) |
| 5477 |
{ |
| 5478 |
a=add_entry(&ent); |
| 5479 |
if (a != PS_OK) |
| 5480 |
return a; |
| 5481 |
} |
| 5482 |
#endif |
| 5483 |
} |
| 5484 |
} |
| 5485 |
return PS_OK; |
| 5486 |
} |
| 5487 |
|
| 5488 |
int CEXEBuild::do_add_file_create_dir(const tstring& local_dir, const tstring& dir, int attrib) { |
| 5489 |
tstring outdir_s = _T("$_OUTDIR\\") + dir; |
| 5490 |
|
| 5491 |
tstring::size_type pos = 1; |
| 5492 |
pos = outdir_s.find(_T('$'), pos); |
| 5493 |
while (pos != tstring::npos) { |
| 5494 |
outdir_s = outdir_s.insert(pos, _T("$")); |
| 5495 |
pos = outdir_s.find(_T('$'), pos + 2); |
| 5496 |
} |
| 5497 |
|
| 5498 |
int outdir = add_string(outdir_s.c_str()); |
| 5499 |
if (add_entry_direct(EW_CREATEDIR, outdir, 1) != PS_OK) { |
| 5500 |
return PS_ERROR; |
| 5501 |
} |
| 5502 |
|
| 5503 |
#ifdef _WIN32 |
| 5504 |
if (attrib) { |
| 5505 |
int ndc = add_asciistring(_T(".")); |
| 5506 |
DWORD attr = GetFileAttributes(local_dir.c_str()); |
| 5507 |
if (attr != INVALID_FILE_ATTRIBUTES) |
| 5508 |
{ |
| 5509 |
if (add_entry_direct(EW_SETFILEATTRIBUTES, ndc, attr) != PS_OK) |
| 5510 |
{ |
| 5511 |
return PS_ERROR; |
| 5512 |
} |
| 5513 |
} |
| 5514 |
} |
| 5515 |
#endif |
| 5516 |
return PS_OK; |
| 5517 |
} |
| 5518 |
#endif |