{ Copyright (C) 2002-2020 Massimo Melina (www.rejetto.com) This file is part of HFS ~ HTTP File Server. HFS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. HFS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with HFS; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA } unit scriptLib; interface uses main, classesLib, iniFiles, types; type TmacroData = record cd: TconnData; tpl: Ttpl; folder, f: Tfile; afterTheList, archiveAvailable, hideExt, breaking: boolean; aliases, tempVars: THashedStringList; table: TStringDynArray; logTS: boolean; end; var defaultAlias: THashedStringList; staticVars : THashedStringList; // these scripting variables are held for the whole run-time eventScripts: Ttpl; function tryApplyMacrosAndSymbols(var txt:string; var md:TmacroData; removeQuotings:boolean=true):boolean; function macroQuote(s:string):string; function runScript(script:string; table:TstringDynArray=NIL; tpl_:Ttpl=NIL; f:Tfile=NIL; folder:Tfile=NIL; cd:TconnData=NIL):string; function runEventScript(event:string; table:TStringDynArray=NIL; cd:TconnData=NIL):string; procedure resetLog(); implementation uses windows, utilLib, trayLib, parserLib, graphics, classes, sysutils, StrUtils, hslib, comctrls, math, controls, forms, clipbrd, MMsystem; const HEADER = '
'; var stopOnMacroRename: boolean; // this ugly global var is used to avoid endless recursion on a renaming rename event. this method won't work on a multithreaded system, but i opted for it because otherwise the changes would have been big. cachedTpls: TcachedTpls; function macrosLog(textIn, textOut:string; ts:boolean=FALSE):boolean; var s: string; begin s:=''; if ts then s:='