diff --git a/cmake/FindMSVCRedist.cmake b/cmake/FindMSVCRedist.cmake new file mode 100644 index 00000000000..d707c849915 --- /dev/null +++ b/cmake/FindMSVCRedist.cmake @@ -0,0 +1,27 @@ +if(WIN32) + include(InstallRequiredSystemLibraries) + + # Determine architecture + # if(CMAKE_CL_64) + set(MSVC_ARCH x64) + # else() + # set(MSVC_ARCH x86) + # endif() + + # Attempt to find the vcredist executable + find_program(MSVC_REDIST_EXE + NAMES vc_redist.${MSVC_ARCH}.exe + PATHS + "${MSVC_REDIST_DIR}" # If set by InstallRequiredSystemLibraries + "$ENV{VCINSTALLDIR}Redist/MSVC/v143/" # For VS 2022 + "C:/Program Files (x86)/Microsoft Visual Studio/*/VC/Redist/MSVC/*/" + "C:/Program Files/Microsoft Visual Studio/*/*/VC/Redist/MSVC/*/" + NO_DEFAULT_PATH + ) + + if(MSVC_REDIST_EXE) + message(STATUS "Found VC Redistributable: ${MSVC_REDIST_EXE}") + else() + message(WARNING "VC Redistributable not found.") + endif() +endif() diff --git a/companion/src/CMakeLists.txt b/companion/src/CMakeLists.txt index 28d2bee2e2f..e9149d2e6a4 100644 --- a/companion/src/CMakeLists.txt +++ b/companion/src/CMakeLists.txt @@ -407,6 +407,13 @@ elseif(WIN32) DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}) endif() + include(FindMSVCRedist) + + if(MSVC_REDIST_EXE) + install(FILES ${MSVC_REDIST_EXE} + DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}) + endif() + elseif(APPLE) # Qt + Cmake + Mac is poorly documented. A lot of this is guesswork # and trial and error. Do not hesitate to fix it for the better @@ -514,6 +521,7 @@ if(WIN32) cmake_path(NATIVE_PATH CMAKE_INSTALL_PREFIX NORMALIZE NSIS_DISTRO) # all files in here will be included in installer cmake_path(NATIVE_PATH COMPANION_TARGETS_DIR NORMALIZE NSIS_TARGETS_DIR) # all files in here will be included in installer + cmake_path(GET MSVC_REDIST_EXE FILENAME NSIS_MSVC_REDIST_EXE) set(NSI_FILE "${PROJECT_BINARY_DIR}/companion/companion.nsi") configure_file("${COMPANION_TARGETS_DIR}/companion.nsi.in" "${NSI_FILE}" @ONLY) diff --git a/companion/targets/windows/FileFunc.nsh b/companion/targets/windows/FileFunc.nsh new file mode 100644 index 00000000000..fce91057f47 --- /dev/null +++ b/companion/targets/windows/FileFunc.nsh @@ -0,0 +1,3458 @@ +/* +_____________________________________________________________________________ + + File Functions Header v3.3 +_____________________________________________________________________________ + + 2006 Shengalts Aleksander aka Instructor (Shengalts@mail.ru) + + Copy "FileFunc.nsh" to NSIS include directory + Usually "C:\Program Files\NSIS\Include" + + Usage in script: + 1. !include "FileFunc.nsh" + 2. !insertmacro FileFunction + 3. [Section|Function] + ${FileFunction} "Param1" "Param2" "..." $var + [SectionEnd|FunctionEnd] + + + FileFunction=[Locate|GetSize|DriveSpace|GetDrives|GetTime|GetFileAttributes| + GetFileVersion|GetExeName|GetExePath|GetParameters|GetOptions| + GetOptionsS|GetRoot|GetParent|GetFileName|GetBaseName|GetFileExt| + BannerTrimPath|DirState|RefreshShellIcons] + + un.FileFunction=[un.Locate|un.GetSize|un.DriveSpace|un.GetDrives|un.GetTime| + un.GetFileAttributes|un.GetFileVersion|un.GetExeName| + un.GetExePath|un.GetParameters|un.GetOptions|un.GetOptionsS| + un.GetRoot|un.GetParent|un.GetFileName|un.GetBaseName| + un.GetFileExt|un.BannerTrimPath|un.DirState|un.RefreshShellIcons] + +____________________________________________________________________________ + + Locate v1.8 +____________________________________________________________________________ + + +Find files, directories and empty directories with mask and size options. + + +Syntax: +${Locate} "[Path]" "[Options]" "Function" + +"[Path]" ; Disk or Directory + ; +"[Options]" ; /L=[FD|F|D|DE|FDE] + ; /L=FD - Locate Files and Directories (default) + ; /L=F - Locate Files only + ; /L=D - Locate Directories only + ; /L=DE - Locate Empty Directories only + ; /L=FDE - Locate Files and Empty Directories + ; /M=[mask] + ; /M=*.* - Locate all (default) + ; /M=*.doc - Locate Work.doc, 1.doc ... + ; /M=Pho* - Locate PHOTOS, phone.txt ... + ; /M=win???.exe - Locate winamp.exe, winver.exe ... + ; /M=winamp.exe - Locate winamp.exe only + ; /S=No:No[B|K|M|G] + ; /S= - Don't locate file size (faster) (default) + ; /S=0:0B - Locate only files of 0 Bytes exactly + ; /S=5:9K - Locate only files of 5 to 9 Kilobytes + ; /S=:10M - Locate only files of 10 Megabyte or less + ; /S=1G - Locate only files of 1 Gigabyte or more + ; /G=[1|0] + ; /G=1 - Locate with subdirectories (default) + ; /G=0 - Locate without subdirectories + ; /B=[0|1] + ; /B=0 - Banner isn't used (default) + ; /B=1 - Banner is used. Callback when function + ; start to search in new directory +"Function" ; Callback function when found + +Function "Function" + ; $R9 "path\name" + ; $R8 "path" + ; $R7 "name" + ; $R6 "size" ($R6="" if directory, $R6="0" if file with /S=) + + ; $R0-$R5 are not used (save data in them). + ; ... + + + Push $var ; If $var="StopLocate" Then exit from function +FunctionEnd + + +Note: +- Error flag if disk or directory isn't exist +- Error flag if syntax error + + + +Example (Find one file): +Section + ${Locate} "C:\ftp" "/L=F /M=RPC DCOM.rar /S=1K" "Example1" + ; 'RPC DCOM.rar' file in 'C:\ftp' with size 1 Kb or more + + IfErrors 0 +2 + MessageBox MB_OK "Error" IDOK +2 + MessageBox MB_OK "$$R0=$R0" +SectionEnd + +Function Example1 + StrCpy $R0 $R9 + ; $R0="C:\ftp\files\RPC DCOM.rar" + + MessageBox MB_YESNO '$R0$\n$\nFind next?' IDYES +2 + StrCpy $0 StopLocate + + Push $0 +FunctionEnd + + + +Example (Write founded in text file): +Section + GetTempFileName $R0 + FileOpen $R1 $R0 w + ${Locate} "C:\ftp" "/S=:2M /G=0" "Example2" + ; folders and all files with size 2 Mb or less + ; don't scan subdirectories + FileClose $R1 + + IfErrors 0 +2 + MessageBox MB_OK "Error" IDOK +2 + Exec '"notepad.exe" "$R0"' +SectionEnd + +Function Example2 + StrCmp $R6 '' 0 +3 + FileWrite $R1 "Directory=$R9$\r$\n" + goto +2 + FileWrite $R1 "File=$R9 Size=$R6 Mb$\r$\n" + + Push $0 +FunctionEnd + + + +Example (Write founded in INI file): +Section + GetTempFileName $R0 + ${Locate} "C:\ftp" "/L=F /S=0K" "Example3" + ; all files in 'C:\ftp' with size detect in Kb + + IfErrors 0 +2 + MessageBox MB_OK "Error" IDOK +2 + Exec '"notepad.exe" "$R0"' +SectionEnd + +Function Example3 + WriteINIStr $R0 "$R8" "$R7" "$R6 Kb" + + Push $0 +FunctionEnd + + + +Example (Delete empty directories): +Section + StrCpy $R2 0 + StrCpy $R3 0 + + loop: + StrCpy $R1 0 + ${Locate} "C:\ftp" "/L=DE" "Example4" + IntOp $R3 $R3 + 1 + IntOp $R2 $R2 + $R1 + StrCmp $R0 StopLocate +2 + StrCmp $R1 0 0 loop + + IfErrors 0 +2 + MessageBox MB_OK 'error' IDOK +2 + MessageBox MB_OK '$R2 directories were removed$\n$R3 loops' +SectionEnd + +Function Example4 + MessageBox MB_YESNOCANCEL 'Delete empty "$R9"?' IDNO end IDCANCEL cancel + RMDir $R9 + IntOp $R1 $R1 + 1 + goto end + + cancel: + StrCpy $R0 StopLocate + + end: + Push $R0 +FunctionEnd + + + +Example (Move all files into one folder): +Section + StrCpy $R0 "C:\ftp" ;Directory move from + StrCpy $R1 "C:\ftp2" ;Directory move into + + StrCpy $R2 0 + StrCpy $R3 0 + ${Locate} "$R0" "/L=F" "Example5" + + IfErrors 0 +2 + MessageBox MB_OK 'error' IDOK +4 + StrCmp $R3 0 0 +2 + MessageBox MB_OK '$R2 files were moved' IDOK +2 + MessageBox MB_OK '$R2 files were moved$\n$R3 files were NOT moved' +SectionEnd + +Function Example5 + StrCmp $R8 $R1 +6 + IfFileExists '$R1\$R7' +4 + Rename $R9 '$R1\$R7' + IntOp $R2 $R2 + 1 + goto +2 + IntOp $R3 $R3 + 1 + + Push $0 +FunctionEnd + + + +Example (Copy files with log): +Section + StrCpy $R0 "C:\ftp" ;Directory copy from + StrCpy $R1 "C:\ftp2" ;Directory copy into + StrLen $R2 $R0 + + GetTempFileName $0 + FileOpen $R3 $0 w + ${Locate} "$R0" "/L=FDE" "Example6" + FileClose $R3 + + IfErrors 0 +2 + MessageBox MB_OK 'error' + + Exec '"notepad.exe" "$0"' ;view log +SectionEnd + +Function Example6 + StrCpy $1 $R8 '' $R2 + + StrCmp $R6 '' 0 +3 + CreateDirectory '$R1$1\$R7' + goto end + CreateDirectory '$R1$1' + CopyFiles /SILENT $R9 '$R1$1' + + IfFileExists '$R1$1\$R7' 0 +3 + FileWrite $R3 "-old:$R9 -new:$R1$1\$R7 -success$\r$\n" + goto +2 + FileWrite $R3 "-old:$R9 -new:$R1$1\$R7 -failed$\r$\n" + + end: + Push $0 +FunctionEnd + + + +Example (Recreate directory structure): +Section + StrCpy $R0 "C:\ftp" ;Directory structure from + StrCpy $R1 "C:\ftp2" ;Directory structure into + StrLen $R2 $R0 + + ${Locate} "$R0" "/L=D" "Example7" + + IfErrors 0 +2 + MessageBox MB_OK 'error' +SectionEnd + +Function Example7 + StrCpy $1 $R9 '' $R2 + CreateDirectory '$R1$1' + + Push $0 +FunctionEnd + + + +Example (Locate with banner - "NxS" plugin required): +Section + nxs::Show /NOUNLOAD `$(^Name) Setup` /top `Setup searching something$\r$\nPlease wait... If you can..` /h 1 /can 1 /end + ${Locate} "C:\WINDOWS" "/L=F /M=*.inf /B=1" "Example8" + nxs::Destroy +SectionEnd + +Function Example8 + StrCmp $R0 $R8 abortcheck + StrCpy $R0 $R8 + nxs::Update /NOUNLOAD /sub "$R8" /pos 78 /end + + abortcheck: + nxs::HasUserAborted /NOUNLOAD + Pop $0 + StrCmp $0 1 0 +2 + StrCpy $0 StopLocate + + StrCmp $R9 '' end + ;... + + end: + Push $0 +FunctionEnd + +____________________________________________________________________________ + + GetSize v2.0 +____________________________________________________________________________ + +Thanks KiCHiK (Function "FindFiles") + + +Features: +1. Find the size of a file, files mask or directory. +2. Find the sum of the files, directories and subdirectories. + + +Syntax: +${GetSize} "[Path]" "[Options]" $var1 $var2 $var3 + +"[Path]" ; Disk or Directory + ; +"[Options]" ; /M=[mask] + ; /M=*.* - Find all (default) + ; /M=*.doc - Find Work.doc, 1.doc ... + ; /M=Pho* - Find PHOTOS, phone.txt ... + ; /M=win???.exe - Find winamp.exe, winver.exe ... + ; /M=winamp.exe - Find winamp.exe only + ; /S=No:No[B|K|M|G] + ; /S= - Don't find file size (faster) (default) + ; /S=0:0B - Find only files of 0 Bytes exactly + ; /S=5:9K - Find only files of 5 to 9 Kilobytes + ; /S=:10M - Find only files of 10 Megabyte or less + ; /S=1G - Find only files of 1 Gigabyte or more + ; /G=[1|0] + ; /G=1 - Find with subdirectories (default) + ; /G=0 - Find without subdirectories + ; +$var1 ; Result1: Size +$var2 ; Result2: Sum of files +$var3 ; Result3: Sum of directories + + +Note: +- Error flag if disk or directory isn't exist +- Error flag if syntax error + + + +Example (1): +Section + ; Find file size "C:\WINDOWS\Explorer.exe" in kilobytes + + ${GetSize} "C:\WINDOWS" "/M=Explorer.exe /S=0K /G=0" $0 $1 $2 + ; $0="220" Kb + ; $1="1" files + ; $2="" directories + + IfErrors 0 +2 + MessageBox MB_OK "Error" +SectionEnd + +Example (2): +Section + ; Find folder size "C:\Installs\Reanimator\Drivers" in megabytes + + ${GetSize} "C:\Installs\Reanimator\Drivers" "/S=0M" $0 $1 $2 + ; $0="132" Mb + ; $1="555" files + ; $2="55" directories + + IfErrors 0 +2 + MessageBox MB_OK "Error" +SectionEnd + +Example (3): +Section + ; Find sum of files and folders "C:\WINDOWS" (no subfolders) + + ${GetSize} "C:\WINDOWS" "/G=0" $0 $1 $2 + ; $0="" size + ; $1="253" files + ; $2="46" directories + + IfErrors 0 +2 + MessageBox MB_OK "Error" +SectionEnd + +____________________________________________________________________________ + + DriveSpace v1.2 +____________________________________________________________________________ + +Thanks sunjammer (Function "CheckSpaceFree") + + +Get total, occupied or free space of the drive. + + +Syntax: +${GetSize} "[Drive]" "[Options]" $var + +"[Drive]" ; Disk to check + ; +"[Options]" ; /D=[T|O|F] + ; /D=T - Total space (default) + ; /D=O - Occupied space + ; /D=F - Free space + ; /S=[B|K|M|G] + ; /S=B - size in Bytes (default) + ; /S=K - size in Kilobytes + ; /S=M - size in Megabytes + ; /S=G - size in Gigabytes + ; +$var ; Result: Size + + +Note: +- Error flag if disk isn't exist or not ready +- Error flag if syntax error + + + +Example: +Section + ${DriveSpace} "C:\" "/D=F /S=M" $R0 + ; $R0="2530" megabytes free on drive C: +SectionEnd + +____________________________________________________________________________ + + GetDrives v1.5 +____________________________________________________________________________ + +Thanks deguix (Based on his idea of Function "DetectDrives") + + +Find all available drives in the system. + + +Syntax: +${GetDrives} "[Option]" "Function" + +"[Option]" ; [FDD+HDD+CDROM+NET+RAM] + ; FDD Floppy Disk Drives + ; HDD Hard Disk Drives + ; CDROM CD-ROM Drives + ; NET Network Drives + ; RAM RAM Disk Drives + ; + ; [ALL] + ; Find all drives by letter (default) + ; +"Function" ; Callback function when found + +Function "Function" + ; $9 "drive letter" (a:\ c:\ ...) + ; $8 "drive type" (FDD HDD ...) + + + ; $R0-$R9 are not used (save data in them). + ; ... + + + Push $var ; If $var="StopGetDrives" Then exit from function +FunctionEnd + + + +Example1: +Section + ${GetDrives} "FDD+CDROM" "Example1" +SectionEnd + +Function Example1 + MessageBox MB_OK "$9 ($8 Drive)" + + Push $0 +FunctionEnd + + + +Example2: +Section + ${GetDrives} "ALL" "Example2" +SectionEnd + +Function Example2 + MessageBox MB_OK "$9 ($8 Drive)" + + Push $0 +FunctionEnd + + + +Example3 (Get type of drive): +Section + StrCpy $R0 "D:\" ;Drive letter + StrCpy $R1 "invalid" + + ${GetDrives} "ALL" "Example3" + + MessageBox MB_OK "Type of drive $R0 is $R1" +SectionEnd + +Function Example3 + StrCmp $9 $R0 0 +3 + StrCpy $R1 $8 + StrCpy $0 StopGetDrives + + Push $0 +FunctionEnd + +____________________________________________________________________________ + + GetTime v1.5 +____________________________________________________________________________ + +Thanks Takhir (Script "StatTest") and deguix (Function "FileModifiedDate") + + +Features: +1. Get local or system time. +2. Get file time (access, creation and modification). + + +Syntax: +${GetTime} "[File]" "[Option]" $var1 $var2 $var3 $var4 $var5 $var6 $var7 + +"[File]" ; Ignored if "L" or "LS" + ; +"[Option]" ; [Options] + ; L Local time + ; A last Access file time + ; C Creation file time + ; M Modification file time + ; LS System time (UTC) + ; AS last Access file time (UTC) + ; CS Creation file time (UTC) + ; MS Modification file time (UTC) + ; +$var1 ; Result1: day +$var2 ; Result2: month +$var3 ; Result3: year +$var4 ; Result4: day of week name +$var5 ; Result5: hour +$var6 ; Result6: minute +$var7 ; Result7: seconds + + +Note: +- Error flag if file isn't exist +- Error flag if syntax error + + + +Example (Get local time): +Section + ${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6 + ; $0="01" day + ; $1="04" month + ; $2="2005" year + ; $3="Friday" day of week name + ; $4="16" hour + ; $5="05" minute + ; $6="50" seconds + + MessageBox MB_OK 'Date=$0/$1/$2 ($3)$\nTime=$4:$5:$6' +SectionEnd + + +Example (Get file time): +Section + ${GetTime} "$WINDIR\Explorer.exe" "C" $0 $1 $2 $3 $4 $5 $6 + ; $0="12" day + ; $1="10" month + ; $2="2004" year + ; $3="Tuesday" day of week name + ; $4="2" hour + ; $5="32" minute + ; $6="03" seconds + + IfErrors 0 +2 + MessageBox MB_OK "Error" IDOK +2 + MessageBox MB_OK 'Date=$0/$1/$2 ($3)$\nTime=$4:$5:$6' +SectionEnd + + +Example (Get system time): +Section + ${GetTime} "" "LS" $0 $1 $2 $3 $4 $5 $6 + ; $0="01" day + ; $1="04" month + ; $2="2005" year + ; $3="Friday" day of week name + ; $4="11" hour + ; $5="05" minute + ; $6="50" seconds + + MessageBox MB_OK 'Date=$0/$1/$2 ($3)$\nTime=$4:$5:$6' +SectionEnd + + +Example (Convert time to 12-hour format AM/PM): +Section + ${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6 + + StrCmp $4 0 0 +3 + StrCpy $4 12 + goto +3 + StrCmp $4 12 +5 + IntCmp $4 12 0 0 +3 + StrCpy $7 AM + goto +3 + IntOp $4 $4 - 12 + StrCpy $7 PM + + MessageBox MB_OK 'Date=$0/$1/$2 ($3)$\nTime=$4:$5:$6 $7' +SectionEnd + +____________________________________________________________________________ + + GetFileAttributes v1.2 +____________________________________________________________________________ + + +Get attributes of file or directory. + + +Syntax: +${GetFileAttributes} "[File]" "[Attributes]" $var + +"[File]" ; File or directory + ; +"[Attributes]" ; "ALL" (default) + ; -all attributes of file combined with "|" to output + ; + ; "READONLY|HIDDEN|SYSTEM|DIRECTORY|ARCHIVE| + ; DEVICE|NORMAL|TEMPORARY|SPARSE_FILE|REPARSE_POINT| + ; COMPRESSED|OFFLINE|NOT_CONTENT_INDEXED|ENCRYPTED" + ; -file must have specified attributes + ; +$var ; Result: + ; $var=attr1|attr2|... (if used "ALL") + ; $var=1 file has specified attributes + ; $var=0 file has no specified attributes + + +Note: +- Error flag if file isn't exist + + + +Example1: +Section + ${GetFileAttributes} "C:\MSDOS.SYS" "ALL" $R0 + ; $R0=READONLY|HIDDEN|SYSTEM|ARCHIVE +SectionEnd + +Example2: +Section + ${GetFileAttributes} "C:\MSDOS.SYS" "SYSTEM|HIDDEN" $R0 + ; $R0=1 +SectionEnd + +Example3: +Section + ${GetFileAttributes} "C:\MSDOS.SYS" "NORMAL" $R0 + ; $R0=0 +SectionEnd + +____________________________________________________________________________ + + GetFileVersion +____________________________________________________________________________ + +Thanks KiCHiK (Based on his example for command "GetDLLVersion") + + +Get version information from executable file. + + +Syntax: +${GetFileVersion} "[Executable]" $var + +"[Executable]" ; Executable file (*.exe *.dll ...) +$var ; Result: Version number + + +Note: +- Error flag if file isn't exist +- Error flag if file isn't contain version information + + + +Example: +Section + ${GetFileVersion} "C:\ftp\program.exe" $R0 + ; $R0="1.1.0.12" +SectionEnd + +____________________________________________________________________________ + + GetExeName +____________________________________________________________________________ + + +Get installer filename (with valid case for Windows 98/Me). + + +Syntax: +${GetExeName} $var + + +Example: +Section + ${GetExeName} $R0 + ; $R0="C:\ftp\program.exe" +SectionEnd + +____________________________________________________________________________ + + GetExePath +____________________________________________________________________________ + + +Get installer pathname ($EXEDIR with valid case for Windows 98/Me). + + +Syntax: +${GetExePath} $var + + +Example: +Section + ${GetExePath} $R0 + ; $R0="C:\ftp" +SectionEnd + +____________________________________________________________________________ + + GetParameters +____________________________________________________________________________ + +Thanks sunjammer (Based on his Function "GetParameters") + + +Get command line parameters. + + +Syntax: +${GetParameters} $var + + +Example: +Section + ${GetParameters} $R0 + ; $R0="[parameters]" +SectionEnd + +____________________________________________________________________________ + + GetOptions +____________________________________________________________________________ + + +Get options from command line parameters. + + +Syntax: +${GetOptions} "[Parameters]" "[Option]" $var + +"[Parameters]" ; command line parameters + ; +"[Option]" ; option name + ; +$var ; Result: option string + + +Note: +- Error flag if option not found +- First option symbol it is delimiter + + + +Example1: +Section + ${GetOptions} "/S /T" "/T" $R0 + + IfErrors 0 +2 + MessageBox MB_OK "Not found" IDOK +2 + MessageBox MB_OK "Found" +SectionEnd + +Example2: +Section + ${GetOptions} "-INSTDIR=C:\Program Files\Common Files -SILENT=yes" "-INSTDIR=" $R0 + ;$R0=C:\Program Files\Common Files +SectionEnd + +Example3: +Section + ${GetOptions} '/SILENT=yes /INSTDIR="C:/Program Files/Common Files" /ADMIN=password' "/INSTDIR=" $R0 + ;$R0=C:/Program Files/Common Files +SectionEnd + +Example4: +Section + ${GetOptions} `-SILENT=yes -INSTDIR='"C:/Program Files/Common Files"' -ADMIN=password` "-INSTDIR=" $R0 + ;$R0="C:/Program Files/Common Files" +SectionEnd + +____________________________________________________________________________ + + GetOptionsS +____________________________________________________________________________ + +Same as GetOptions, but case sensitive. + +____________________________________________________________________________ + + GetRoot (not like in NSIS CVS) +____________________________________________________________________________ + +Thanks KiCHiK (Based on his Function "GetRoot") + + +Get root directory. + + +Syntax: +${GetRoot} "[FullPath]" $var + + +Example1: +Section + ${GetRoot} "C:\Program Files\NSIS" $R0 + ; $R0="C:" +SectionEnd + +Example2: +Section + ${GetRoot} "\\SuperPimp\NSIS\Source\exehead\Ui.c" $R0 + ; $R0="\\SuperPimp\NSIS" +SectionEnd + +Example3: +Section + ${GetRoot} "NSIS\Source\exehead\Ui.c" $R0 + ; $R0="NSIS" +SectionEnd + +____________________________________________________________________________ + + GetParent +____________________________________________________________________________ + +Thanks sunjammer (Based on his Function "GetParent") + + +Get parent directory. + + +Syntax: +${GetParent} "[PathString]" $var + + +Example: +Section + ${GetParent} "C:\Program Files\Winamp\uninstwa.exe" $R0 + ; $R0="C:\Program Files\Winamp" +SectionEnd + +____________________________________________________________________________ + + GetFileName +____________________________________________________________________________ + +Thanks KiCHiK (Based on his Function "GetFileName") + + +Get last part from directory path. + + +Syntax: +${GetFileName} "[PathString]" $var + + +Example: +Section + ${GetFileName} "C:\Program Files\Winamp\uninstwa.exe" $R0 + ; $R0="uninstwa.exe" +SectionEnd + +____________________________________________________________________________ + + GetBaseName +____________________________________________________________________________ + +Thanks comperio (Based on his idea of Function "GetBaseName") + + +Get file name without extension. + + +Syntax: +${GetBaseName} "[FileString]" $var + + +Example: +Section + ${GetBaseName} "C:\ftp\program.exe" $R0 + ; $R0="program" +SectionEnd + +____________________________________________________________________________ + + GetFileExt +____________________________________________________________________________ + +Written by opher + + +Get extention of file. + + +Syntax: +${GetFileExt} "[FileString]" $var + + +Example: +Section + ${GetFileExt} "C:\ftp\program.exe" $R0 + ; $R0="exe" +SectionEnd + +____________________________________________________________________________ + + BannerTrimPath +____________________________________________________________________________ + + +Trim string path for banner. + + +Syntax: +${BannerTrimPath} "[PathString]" "[Option]" $var + +"[PathString]" ; + ; +"[Option]" ; [Length][A|B|C|D] + ; + ; Length -Maximum string length + ; A -Trim center path (default) + ; (C:\root\...\third path) + ; If A mode not possible Then will be used B mode + ; B -Trim right path + ; (C:\root\second path\...) + ; If B mode not possible Then will be used C mode + ; C -Trim right string + ; (C:\root\second path\third p...) + ; D -Trim right string + filename + ; (C:\root\second p...\third path) + ; If D mode not possible Then will be used C mode + ; +$var ; Result: Trimmed path + + +Example: +Section + ${BannerTrimPath} "C:\Server\Documents\Terminal\license.htm" "34A" $R0 + ;$R0=C:\Server\...\Terminal\license.htm +SectionEnd + + + +Example (Banner plugin): +!include "WinMessages.nsh" +!include "FileFunc.nsh" +!insertmacro Locate + +Section + Banner::show /NOUNLOAD "Starting..." + Banner::getWindow /NOUNLOAD + Pop $R1 + ${Locate} "$WINDIR" "/L=F /M=*.* /B=1" "LocateCallback" + Banner::destroy +SectionEnd + +Function LocateCallback + StrCmp $R0 $R8 code + StrCpy $R0 $R8 + ${BannerTrimPath} "$R8" "38B" $R8 + GetDlgItem $1 $R1 1030 + SendMessage $1 ${WM_SETTEXT} 0 "STR:$R8" + + code: + StrCmp $R9 '' end + ;... + + end: + Push $0 +FunctionEnd + + + +Example (nxs plugin): +!include "FileFunc.nsh" +!insertmacro Locate + +Section + nxs::Show /NOUNLOAD `$(^Name) Setup`\ + /top `Setup searching something$\nPlease wait$\nIf you can...`\ + /h 1 /can 1 /end + ${Locate} "$WINDIR" "/L=F /M=*.* /B=1" "LocateCallback" + nxs::Destroy +SectionEnd + +Function LocateCallback + StrCmp $R0 $R8 abortcheck + StrCpy $R0 $R8 + ${BannerTrimPath} "$R8" "55A" $R8 + nxs::Update /NOUNLOAD /sub "$R8" /pos 78 /end + + abortcheck: + nxs::HasUserAborted /NOUNLOAD + Pop $0 + StrCmp $0 1 0 +2 + StrCpy $0 StopLocate + + StrCmp $R9 '' end + ;... + + end: + Push $0 +FunctionEnd + +____________________________________________________________________________ + + DirState +____________________________________________________________________________ + + +Check directory full, empty or not exist. + + +Syntax: +${DirState} "[path]" $var + +"[path]" ; Directory +$var ; Result: + ; $var=0 (empty) + ; $var=1 (full) + ; $var=-1 (directory not found) + + +Example: +Section + ${DirState} "$TEMP" $R0 + ; $R0="1" directory is full +SectionEnd + +____________________________________________________________________________ + + RefreshShellIcons +____________________________________________________________________________ + +Written by jerome tremblay + + +After changing file associations, you can call this function +to refresh the shell immediately. + + +Syntax: +${RefreshShellIcons} + + +Example: +Section + WriteRegStr HKCR "Winamp.File\DefaultIcon" "" "$PROGRAMFILES\Winamp\WINAMP.EXE,2" + + ${RefreshShellIcons} +SectionEnd +*/ + + +;_____________________________________________________________________________ +; +; Macros +;_____________________________________________________________________________ +; +; Change log window verbosity (default: 3=no script) +; +; Example: +; !include "FileFunc.nsh" +; !insertmacro Locate +; ${FILEFUNC_VERBOSE} 4 # all verbosity +; !insertmacro VersionCompare +; ${FILEFUNC_VERBOSE} 3 # no script + +!ifndef FILEFUNC_INCLUDED +!define FILEFUNC_INCLUDED + +!verbose push +!verbose 3 +!ifndef _FILEFUNC_VERBOSE + !define _FILEFUNC_VERBOSE 3 +!endif +!verbose ${_FILEFUNC_VERBOSE} +!define FILEFUNC_VERBOSE `!insertmacro FILEFUNC_VERBOSE` +!define _FILEFUNC_UN +!define _FILEFUNC_S +!verbose pop + +!macro FILEFUNC_VERBOSE _VERBOSE + !verbose push + !verbose 3 + !undef _FILEFUNC_VERBOSE + !define _FILEFUNC_VERBOSE ${_VERBOSE} + !verbose pop +!macroend + + +# Install. Case insensitive. # + +!macro LocateCall _PATH _OPTIONS _FUNC + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push $0 + Push `${_PATH}` + Push `${_OPTIONS}` + GetFunctionAddress $0 `${_FUNC}` + Push `$0` + Call Locate + Pop $0 + !verbose pop +!macroend + +!macro GetSizeCall _PATH _OPTIONS _RESULT1 _RESULT2 _RESULT3 + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PATH}` + Push `${_OPTIONS}` + Call GetSize + Pop ${_RESULT1} + Pop ${_RESULT2} + Pop ${_RESULT3} + !verbose pop +!macroend + +!macro DriveSpaceCall _DRIVE _OPTIONS _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_DRIVE}` + Push `${_OPTIONS}` + Call DriveSpace + Pop ${_RESULT} + !verbose pop +!macroend + +!macro GetDrivesCall _DRV _FUNC + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push $0 + Push `${_DRV}` + GetFunctionAddress $0 `${_FUNC}` + Push `$0` + Call GetDrives + Pop $0 + !verbose pop +!macroend + +!macro GetTimeCall _FILE _OPTION _RESULT1 _RESULT2 _RESULT3 _RESULT4 _RESULT5 _RESULT6 _RESULT7 + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_FILE}` + Push `${_OPTION}` + Call GetTime + Pop ${_RESULT1} + Pop ${_RESULT2} + Pop ${_RESULT3} + Pop ${_RESULT4} + Pop ${_RESULT5} + Pop ${_RESULT6} + Pop ${_RESULT7} + !verbose pop +!macroend + +!macro GetFileAttributesCall _PATH _ATTR _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PATH}` + Push `${_ATTR}` + Call GetFileAttributes + Pop ${_RESULT} + !verbose pop +!macroend + +!macro GetFileVersionCall _FILE _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_FILE}` + Call GetFileVersion + Pop ${_RESULT} + !verbose pop +!macroend + +!macro GetExeNameCall _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Call GetExeName + Pop ${_RESULT} + !verbose pop +!macroend + +!macro GetExePathCall _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Call GetExePath + Pop ${_RESULT} + !verbose pop +!macroend + +!macro GetParametersCall _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Call GetParameters + Pop ${_RESULT} + !verbose pop +!macroend + +!macro GetOptionsCall _PARAMETERS _OPTION _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PARAMETERS}` + Push `${_OPTION}` + Call GetOptions + Pop ${_RESULT} + !verbose pop +!macroend + +!macro GetRootCall _FULLPATH _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_FULLPATH}` + Call GetRoot + Pop ${_RESULT} + !verbose pop +!macroend + +!macro GetParentCall _PATHSTRING _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PATHSTRING}` + Call GetParent + Pop ${_RESULT} + !verbose pop +!macroend + +!macro GetFileNameCall _PATHSTRING _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PATHSTRING}` + Call GetFileName + Pop ${_RESULT} + !verbose pop +!macroend + +!macro GetBaseNameCall _FILESTRING _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_FILESTRING}` + Call GetBaseName + Pop ${_RESULT} + !verbose pop +!macroend + +!macro GetFileExtCall _FILESTRING _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_FILESTRING}` + Call GetFileExt + Pop ${_RESULT} + !verbose pop +!macroend + +!macro BannerTrimPathCall _PATH _LENGHT _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PATH}` + Push `${_LENGHT}` + Call BannerTrimPath + Pop ${_RESULT} + !verbose pop +!macroend + +!macro DirStateCall _PATH _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PATH}` + Call DirState + Pop ${_RESULT} + !verbose pop +!macroend + +!macro RefreshShellIconsCall + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Call RefreshShellIcons + !verbose pop +!macroend + +!macro Locate + !ifndef ${_FILEFUNC_UN}Locate + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}Locate `!insertmacro ${_FILEFUNC_UN}LocateCall` + + Function ${_FILEFUNC_UN}Locate + Exch $2 + Exch + Exch $1 + Exch + Exch 2 + Exch $0 + Exch 2 + Push $3 + Push $4 + Push $5 + Push $6 + Push $7 + Push $8 + Push $9 + Push $R6 + Push $R7 + Push $R8 + Push $R9 + ClearErrors + + StrCpy $3 '' + StrCpy $4 '' + StrCpy $5 '' + StrCpy $6 '' + StrCpy $7 '' + StrCpy $8 0 + StrCpy $R7 '' + + StrCpy $R9 $0 1 -1 + StrCmp $R9 '\' 0 +3 + StrCpy $0 $0 -1 + goto -3 + IfFileExists '$0\*.*' 0 error + + option: + StrCpy $R9 $1 1 + StrCpy $1 $1 '' 1 + StrCmp $R9 ' ' -2 + StrCmp $R9 '' sizeset + StrCmp $R9 '/' 0 -4 + StrCpy $9 -1 + IntOp $9 $9 + 1 + StrCpy $R9 $1 1 $9 + StrCmp $R9 '' +2 + StrCmp $R9 '/' 0 -3 + StrCpy $R8 $1 $9 + StrCpy $R8 $R8 '' 2 + StrCpy $R9 $R8 '' -1 + StrCmp $R9 ' ' 0 +3 + StrCpy $R8 $R8 -1 + goto -3 + StrCpy $R9 $1 2 + StrCpy $1 $1 '' $9 + + StrCmp $R9 'L=' 0 mask + StrCpy $3 $R8 + StrCmp $3 '' +6 + StrCmp $3 'FD' +5 + StrCmp $3 'F' +4 + StrCmp $3 'D' +3 + StrCmp $3 'DE' +2 + StrCmp $3 'FDE' 0 error + goto option + + mask: + StrCmp $R9 'M=' 0 size + StrCpy $4 $R8 + goto option + + size: + StrCmp $R9 'S=' 0 gotosubdir + StrCpy $6 $R8 + goto option + + gotosubdir: + StrCmp $R9 'G=' 0 banner + StrCpy $7 $R8 + StrCmp $7 '' +3 + StrCmp $7 '1' +2 + StrCmp $7 '0' 0 error + goto option + + banner: + StrCmp $R9 'B=' 0 error + StrCpy $R7 $R8 + StrCmp $R7 '' +3 + StrCmp $R7 '1' +2 + StrCmp $R7 '0' 0 error + goto option + + sizeset: + StrCmp $6 '' default + StrCpy $9 0 + StrCpy $R9 $6 1 $9 + StrCmp $R9 '' +4 + StrCmp $R9 ':' +3 + IntOp $9 $9 + 1 + goto -4 + StrCpy $5 $6 $9 + IntOp $9 $9 + 1 + StrCpy $1 $6 1 -1 + StrCpy $6 $6 -1 $9 + StrCmp $5 '' +2 + IntOp $5 $5 + 0 + StrCmp $6 '' +2 + IntOp $6 $6 + 0 + + StrCmp $1 'B' 0 +3 + StrCpy $1 1 + goto default + StrCmp $1 'K' 0 +3 + StrCpy $1 1024 + goto default + StrCmp $1 'M' 0 +3 + StrCpy $1 1048576 + goto default + StrCmp $1 'G' 0 error + StrCpy $1 1073741824 + + default: + StrCmp $3 '' 0 +2 + StrCpy $3 'FD' + StrCmp $4 '' 0 +2 + StrCpy $4 '*.*' + StrCmp $7 '' 0 +2 + StrCpy $7 '1' + StrCmp $R7 '' 0 +2 + StrCpy $R7 '0' + StrCpy $7 'G$7B$R7' + + StrCpy $8 1 + Push $0 + SetDetailsPrint textonly + + nextdir: + IntOp $8 $8 - 1 + Pop $R8 + + StrCpy $9 $7 2 2 + StrCmp $9 'B0' +3 + GetLabelAddress $9 findfirst + goto call + DetailPrint 'Search in: $R8' + + findfirst: + FindFirst $0 $R7 '$R8\$4' + IfErrors subdir + StrCmp $R7 '.' 0 dir + FindNext $0 $R7 + StrCmp $R7 '..' 0 dir + FindNext $0 $R7 + IfErrors 0 dir + FindClose $0 + goto subdir + + dir: + IfFileExists '$R8\$R7\*.*' 0 file + StrCpy $R6 '' + StrCmp $3 'DE' +4 + StrCmp $3 'FDE' +3 + StrCmp $3 'FD' precall + StrCmp $3 'F' findnext precall + FindFirst $9 $R9 '$R8\$R7\*.*' + StrCmp $R9 '.' 0 +4 + FindNext $9 $R9 + StrCmp $R9 '..' 0 +2 + FindNext $9 $R9 + FindClose $9 + IfErrors precall findnext + + file: + StrCmp $3 'FDE' +3 + StrCmp $3 'FD' +2 + StrCmp $3 'F' 0 findnext + StrCpy $R6 0 + StrCmp $5$6 '' precall + FileOpen $9 '$R8\$R7' r + IfErrors +3 + FileSeek $9 0 END $R6 + FileClose $9 + System::Int64Op $R6 / $1 + Pop $R6 + StrCmp $5 '' +2 + IntCmp $R6 $5 0 findnext + StrCmp $6 '' +2 + IntCmp $R6 $6 0 0 findnext + + precall: + StrCpy $9 0 + StrCpy $R9 '$R8\$R7' + + call: + Push $0 + Push $1 + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + Push $7 + Push $8 + Push $9 + Push $R7 + Push $R8 + StrCmp $9 0 +4 + StrCpy $R6 '' + StrCpy $R7 '' + StrCpy $R9 '' + Call $2 + Pop $R9 + Pop $R8 + Pop $R7 + Pop $9 + Pop $8 + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 + IfErrors error + + StrCmp $R9 'StopLocate' clearstack + goto $9 + + findnext: + FindNext $0 $R7 + IfErrors 0 dir + FindClose $0 + + subdir: + StrCpy $9 $7 2 + StrCmp $9 'G0' end + FindFirst $0 $R7 '$R8\*.*' + StrCmp $R7 '.' 0 pushdir + FindNext $0 $R7 + StrCmp $R7 '..' 0 pushdir + FindNext $0 $R7 + IfErrors 0 pushdir + FindClose $0 + goto +7 + + pushdir: + IfFileExists '$R8\$R7\*.*' 0 +3 + Push '$R8\$R7' + IntOp $8 $8 + 1 + FindNext $0 $R7 + IfErrors 0 -4 + FindClose $0 + StrCmp $8 0 end nextdir + + error: + SetErrors + + clearstack: + StrCmp $8 0 end + IntOp $8 $8 - 1 + Pop $R8 + goto clearstack + + end: + SetDetailsPrint both + Pop $R9 + Pop $R8 + Pop $R7 + Pop $R6 + Pop $9 + Pop $8 + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro GetSize + !ifndef ${_FILEFUNC_UN}GetSize + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}GetSize `!insertmacro ${_FILEFUNC_UN}GetSizeCall` + + Function ${_FILEFUNC_UN}GetSize + Exch $1 + Exch + Exch $0 + Exch + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + Push $7 + Push $8 + Push $9 + Push $R3 + Push $R4 + Push $R5 + Push $R6 + Push $R7 + Push $R8 + Push $R9 + ClearErrors + + StrCpy $R9 $0 1 -1 + StrCmp $R9 '\' 0 +3 + StrCpy $0 $0 -1 + goto -3 + IfFileExists '$0\*.*' 0 error + + StrCpy $3 '' + StrCpy $4 '' + StrCpy $5 '' + StrCpy $6 '' + StrCpy $8 0 + StrCpy $R3 '' + StrCpy $R4 '' + StrCpy $R5 '' + + option: + StrCpy $R9 $1 1 + StrCpy $1 $1 '' 1 + StrCmp $R9 ' ' -2 + StrCmp $R9 '' sizeset + StrCmp $R9 '/' 0 -4 + + StrCpy $9 -1 + IntOp $9 $9 + 1 + StrCpy $R9 $1 1 $9 + StrCmp $R9 '' +2 + StrCmp $R9 '/' 0 -3 + StrCpy $8 $1 $9 + StrCpy $8 $8 '' 2 + StrCpy $R9 $8 '' -1 + StrCmp $R9 ' ' 0 +3 + StrCpy $8 $8 -1 + goto -3 + StrCpy $R9 $1 2 + StrCpy $1 $1 '' $9 + + StrCmp $R9 'M=' 0 size + StrCpy $4 $8 + goto option + + size: + StrCmp $R9 'S=' 0 gotosubdir + StrCpy $6 $8 + goto option + + gotosubdir: + StrCmp $R9 'G=' 0 error + StrCpy $7 $8 + StrCmp $7 '' +3 + StrCmp $7 '1' +2 + StrCmp $7 '0' 0 error + goto option + + sizeset: + StrCmp $6 '' default + StrCpy $9 0 + StrCpy $R9 $6 1 $9 + StrCmp $R9 '' +4 + StrCmp $R9 ':' +3 + IntOp $9 $9 + 1 + goto -4 + StrCpy $5 $6 $9 + IntOp $9 $9 + 1 + StrCpy $1 $6 1 -1 + StrCpy $6 $6 -1 $9 + StrCmp $5 '' +2 + IntOp $5 $5 + 0 + StrCmp $6 '' +2 + IntOp $6 $6 + 0 + + StrCmp $1 'B' 0 +4 + StrCpy $1 1 + StrCpy $2 bytes + goto default + StrCmp $1 'K' 0 +4 + StrCpy $1 1024 + StrCpy $2 Kb + goto default + StrCmp $1 'M' 0 +4 + StrCpy $1 1048576 + StrCpy $2 Mb + goto default + StrCmp $1 'G' 0 error + StrCpy $1 1073741824 + StrCpy $2 Gb + + default: + StrCmp $4 '' 0 +2 + StrCpy $4 '*.*' + StrCmp $7 '' 0 +2 + StrCpy $7 '1' + + StrCpy $8 1 + Push $0 + SetDetailsPrint textonly + + nextdir: + IntOp $8 $8 - 1 + Pop $R8 + FindFirst $0 $R7 '$R8\$4' + IfErrors show + StrCmp $R7 '.' 0 dir + FindNext $0 $R7 + StrCmp $R7 '..' 0 dir + FindNext $0 $R7 + IfErrors 0 dir + FindClose $0 + goto show + + dir: + IfFileExists '$R8\$R7\*.*' 0 file + IntOp $R5 $R5 + 1 + goto findnext + + file: + StrCpy $R6 0 + StrCmp $5$6 '' 0 +3 + IntOp $R4 $R4 + 1 + goto findnext + FileOpen $9 '$R8\$R7' r + IfErrors +3 + FileSeek $9 0 END $R6 + FileClose $9 + StrCmp $5 '' +2 + IntCmp $R6 $5 0 findnext + StrCmp $6 '' +2 + IntCmp $R6 $6 0 0 findnext + IntOp $R4 $R4 + 1 + System::Int64Op /NOUNLOAD $R3 + $R6 + Pop $R3 + + findnext: + FindNext $0 $R7 + IfErrors 0 dir + FindClose $0 + + show: + StrCmp $5$6 '' nosize + System::Int64Op /NOUNLOAD $R3 / $1 + Pop $9 + DetailPrint 'Size:$9 $2 Files:$R4 Folders:$R5' + goto subdir + nosize: + DetailPrint 'Files:$R4 Folders:$R5' + + subdir: + StrCmp $7 0 preend + FindFirst $0 $R7 '$R8\*.*' + StrCmp $R7 '.' 0 pushdir + FindNext $0 $R7 + StrCmp $R7 '..' 0 pushdir + FindNext $0 $R7 + IfErrors 0 pushdir + FindClose $0 + goto +7 + + pushdir: + IfFileExists '$R8\$R7\*.*' 0 +3 + Push '$R8\$R7' + IntOp $8 $8 + 1 + FindNext $0 $R7 + IfErrors 0 -4 + FindClose $0 + StrCmp $8 0 0 nextdir + + preend: + StrCmp $R3 '' nosizeend + System::Int64Op $R3 / $1 + Pop $R3 + nosizeend: + StrCpy $2 $R4 + StrCpy $1 $R5 + StrCpy $0 $R3 + goto end + + error: + SetErrors + StrCpy $0 '' + StrCpy $1 '' + StrCpy $2 '' + + end: + SetDetailsPrint both + Pop $R9 + Pop $R8 + Pop $R7 + Pop $R6 + Pop $R5 + Pop $R4 + Pop $R3 + Pop $9 + Pop $8 + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Exch $2 + Exch + Exch $1 + Exch 2 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro DriveSpace + !ifndef ${_FILEFUNC_UN}DriveSpace + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}DriveSpace `!insertmacro ${_FILEFUNC_UN}DriveSpaceCall` + + Function ${_FILEFUNC_UN}DriveSpace + Exch $1 + Exch + Exch $0 + Exch + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + ClearErrors + + StrCpy $2 $0 1 -1 + StrCmp $2 '\' 0 +3 + StrCpy $0 $0 -1 + goto -3 + IfFileExists '$0\NUL' 0 error + + StrCpy $5 '' + StrCpy $6 '' + + option: + StrCpy $2 $1 1 + StrCpy $1 $1 '' 1 + StrCmp $2 ' ' -2 + StrCmp $2 '' default + StrCmp $2 '/' 0 -4 + StrCpy $3 -1 + IntOp $3 $3 + 1 + StrCpy $2 $1 1 $3 + StrCmp $2 '' +2 + StrCmp $2 '/' 0 -3 + StrCpy $4 $1 $3 + StrCpy $4 $4 '' 2 + StrCpy $2 $4 1 -1 + StrCmp $2 ' ' 0 +3 + StrCpy $4 $4 -1 + goto -3 + StrCpy $2 $1 2 + StrCpy $1 $1 '' $3 + + StrCmp $2 'D=' 0 unit + StrCpy $5 $4 + StrCmp $5 '' +4 + StrCmp $5 'T' +3 + StrCmp $5 'O' +2 + StrCmp $5 'F' 0 error + goto option + + unit: + StrCmp $2 'S=' 0 error + StrCpy $6 $4 + goto option + + default: + StrCmp $5 '' 0 +2 + StrCpy $5 'T' + StrCmp $6 '' 0 +3 + StrCpy $6 '1' + goto getspace + + StrCmp $6 'B' 0 +3 + StrCpy $6 1 + goto getspace + StrCmp $6 'K' 0 +3 + StrCpy $6 1024 + goto getspace + StrCmp $6 'M' 0 +3 + StrCpy $6 1048576 + goto getspace + StrCmp $6 'G' 0 error + StrCpy $6 1073741824 + + getspace: + System::Call /NOUNLOAD 'kernel32::GetDiskFreeSpaceExA(t, *l, *l, *l)i(r0,.r2,.r3,.)' + + StrCmp $5 T 0 +3 + StrCpy $0 $3 + goto getsize + StrCmp $5 O 0 +4 + System::Int64Op /NOUNLOAD $3 - $2 + Pop $0 + goto getsize + StrCmp $5 F 0 +2 + StrCpy $0 $2 + + getsize: + System::Int64Op $0 / $6 + Pop $0 + goto end + + error: + SetErrors + StrCpy $0 '' + + end: + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro GetDrives + !ifndef ${_FILEFUNC_UN}GetDrives + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}GetDrives `!insertmacro ${_FILEFUNC_UN}GetDrivesCall` + + Function ${_FILEFUNC_UN}GetDrives + Exch $1 + Exch + Exch $0 + Exch + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + Push $8 + Push $9 + + System::Alloc /NOUNLOAD 1024 + Pop $2 + System::Call /NOUNLOAD 'kernel32::GetLogicalDriveStringsA(i,i) i(1024, r2)' + + StrCmp $0 ALL drivestring + StrCmp $0 '' 0 typeset + StrCpy $0 ALL + goto drivestring + + typeset: + StrCpy $6 -1 + IntOp $6 $6 + 1 + StrCpy $8 $0 1 $6 + StrCmp $8$0 '' enumex + StrCmp $8 '' +2 + StrCmp $8 '+' 0 -4 + StrCpy $8 $0 $6 + IntOp $6 $6 + 1 + StrCpy $0 $0 '' $6 + + StrCmp $8 'FDD' 0 +3 + StrCpy $6 2 + goto drivestring + StrCmp $8 'HDD' 0 +3 + StrCpy $6 3 + goto drivestring + StrCmp $8 'NET' 0 +3 + StrCpy $6 4 + goto drivestring + StrCmp $8 'CDROM' 0 +3 + StrCpy $6 5 + goto drivestring + StrCmp $8 'RAM' 0 typeset + StrCpy $6 6 + + drivestring: + StrCpy $3 $2 + + enumok: + System::Call /NOUNLOAD 'kernel32::lstrlenA(t) i(i r3) .r4' + StrCmp $4$0 '0ALL' enumex + StrCmp $4 0 typeset + System::Call /NOUNLOAD 'kernel32::GetDriveTypeA(t) i(i r3) .r5' + + StrCmp $0 ALL +2 + StrCmp $5 $6 letter enumnext + StrCmp $5 2 0 +3 + StrCpy $8 FDD + goto letter + StrCmp $5 3 0 +3 + StrCpy $8 HDD + goto letter + StrCmp $5 4 0 +3 + StrCpy $8 NET + goto letter + StrCmp $5 5 0 +3 + StrCpy $8 CDROM + goto letter + StrCmp $5 6 0 enumex + StrCpy $8 RAM + + letter: + System::Call /NOUNLOAD '*$3(&t1024 .r9)' + + Push $0 + Push $1 + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + Push $8 + Call $1 + Pop $9 + Pop $8 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 + StrCmp $9 'StopGetDrives' enumex + + enumnext: + IntOp $3 $3 + $4 + IntOp $3 $3 + 1 + goto enumok + + enumex: + System::Free $2 + + Pop $9 + Pop $8 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro GetTime + !ifndef ${_FILEFUNC_UN}GetTime + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}GetTime `!insertmacro ${_FILEFUNC_UN}GetTimeCall` + + Function ${_FILEFUNC_UN}GetTime + Exch $1 + Exch + Exch $0 + Exch + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + Push $7 + ClearErrors + + StrCmp $1 'L' gettime + StrCmp $1 'A' getfile + StrCmp $1 'C' getfile + StrCmp $1 'M' getfile + StrCmp $1 'LS' gettime + StrCmp $1 'AS' getfile + StrCmp $1 'CS' getfile + StrCmp $1 'MS' getfile + goto error + + getfile: + IfFileExists $0 0 error + System::Call /NOUNLOAD '*(i,l,l,l,i,i,i,i,&t260,&t14) i .r6' + System::Call /NOUNLOAD 'kernel32::FindFirstFileA(t,i)i(r0,r6) .r2' + System::Call /NOUNLOAD 'kernel32::FindClose(i)i(r2)' + + gettime: + System::Call /NOUNLOAD '*(&i2,&i2,&i2,&i2,&i2,&i2,&i2,&i2) i .r7' + StrCmp $1 'L' 0 systemtime + System::Call /NOUNLOAD 'kernel32::GetLocalTime(i)i(r7)' + goto convert + systemtime: + StrCmp $1 'LS' 0 filetime + System::Call /NOUNLOAD 'kernel32::GetSystemTime(i)i(r7)' + goto convert + + filetime: + System::Call /NOUNLOAD '*$6(i,l,l,l,i,i,i,i,&t260,&t14)i(,.r4,.r3,.r2)' + System::Free /NOUNLOAD $6 + StrCmp $1 'A' 0 +3 + StrCpy $2 $3 + goto tolocal + StrCmp $1 'C' 0 +3 + StrCpy $2 $4 + goto tolocal + StrCmp $1 'M' tolocal + + StrCmp $1 'AS' tosystem + StrCmp $1 'CS' 0 +3 + StrCpy $3 $4 + goto tosystem + StrCmp $1 'MS' 0 +3 + StrCpy $3 $2 + goto tosystem + + tolocal: + System::Call /NOUNLOAD 'kernel32::FileTimeToLocalFileTime(*l,*l)i(r2,.r3)' + tosystem: + System::Call /NOUNLOAD 'kernel32::FileTimeToSystemTime(*l,i)i(r3,r7)' + + convert: + System::Call /NOUNLOAD '*$7(&i2,&i2,&i2,&i2,&i2,&i2,&i2,&i2)i(.r5,.r6,.r4,.r0,.r3,.r2,.r1,)' + System::Free $7 + + IntCmp $0 9 0 0 +2 + StrCpy $0 '0$0' + IntCmp $1 9 0 0 +2 + StrCpy $1 '0$1' + IntCmp $2 9 0 0 +2 + StrCpy $2 '0$2' + IntCmp $6 9 0 0 +2 + StrCpy $6 '0$6' + + StrCmp $4 0 0 +3 + StrCpy $4 Sunday + goto end + StrCmp $4 1 0 +3 + StrCpy $4 Monday + goto end + StrCmp $4 2 0 +3 + StrCpy $4 Tuesday + goto end + StrCmp $4 3 0 +3 + StrCpy $4 Wednesday + goto end + StrCmp $4 4 0 +3 + StrCpy $4 Thursday + goto end + StrCmp $4 5 0 +3 + StrCpy $4 Friday + goto end + StrCmp $4 6 0 error + StrCpy $4 Saturday + goto end + + error: + SetErrors + StrCpy $0 '' + StrCpy $1 '' + StrCpy $2 '' + StrCpy $3 '' + StrCpy $4 '' + StrCpy $5 '' + StrCpy $6 '' + + end: + Pop $7 + Exch $6 + Exch + Exch $5 + Exch 2 + Exch $4 + Exch 3 + Exch $3 + Exch 4 + Exch $2 + Exch 5 + Exch $1 + Exch 6 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro GetFileAttributes + !ifndef ${_FILEFUNC_UN}GetFileAttributes + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}GetFileAttributes `!insertmacro ${_FILEFUNC_UN}GetFileAttributesCall` + + Function ${_FILEFUNC_UN}GetFileAttributes + Exch $1 + Exch + Exch $0 + Exch + Push $2 + Push $3 + Push $4 + Push $5 + + System::Call 'kernel32::GetFileAttributes(t r0)i .r2' + StrCmp $2 -1 error + StrCpy $3 '' + + IntOp $0 $2 & 0x4000 + IntCmp $0 0 +2 + StrCpy $3 'ENCRYPTED|' + + IntOp $0 $2 & 0x2000 + IntCmp $0 0 +2 + StrCpy $3 'NOT_CONTENT_INDEXED|$3' + + IntOp $0 $2 & 0x1000 + IntCmp $0 0 +2 + StrCpy $3 'OFFLINE|$3' + + IntOp $0 $2 & 0x0800 + IntCmp $0 0 +2 + StrCpy $3 'COMPRESSED|$3' + + IntOp $0 $2 & 0x0400 + IntCmp $0 0 +2 + StrCpy $3 'REPARSE_POINT|$3' + + IntOp $0 $2 & 0x0200 + IntCmp $0 0 +2 + StrCpy $3 'SPARSE_FILE|$3' + + IntOp $0 $2 & 0x0100 + IntCmp $0 0 +2 + StrCpy $3 'TEMPORARY|$3' + + IntOp $0 $2 & 0x0080 + IntCmp $0 0 +2 + StrCpy $3 'NORMAL|$3' + + IntOp $0 $2 & 0x0040 + IntCmp $0 0 +2 + StrCpy $3 'DEVICE|$3' + + IntOp $0 $2 & 0x0020 + IntCmp $0 0 +2 + StrCpy $3 'ARCHIVE|$3' + + IntOp $0 $2 & 0x0010 + IntCmp $0 0 +2 + StrCpy $3 'DIRECTORY|$3' + + IntOp $0 $2 & 0x0004 + IntCmp $0 0 +2 + StrCpy $3 'SYSTEM|$3' + + IntOp $0 $2 & 0x0002 + IntCmp $0 0 +2 + StrCpy $3 'HIDDEN|$3' + + IntOp $0 $2 & 0x0001 + IntCmp $0 0 +2 + StrCpy $3 'READONLY|$3' + + StrCpy $0 $3 -1 + StrCmp $1 '' end + StrCmp $1 'ALL' end + + attrcmp: + StrCpy $5 0 + IntOp $5 $5 + 1 + StrCpy $4 $1 1 $5 + StrCmp $4 '' +2 + StrCmp $4 '|' 0 -3 + StrCpy $2 $1 $5 + IntOp $5 $5 + 1 + StrCpy $1 $1 '' $5 + StrLen $3 $2 + StrCpy $5 -1 + IntOp $5 $5 + 1 + StrCpy $4 $0 $3 $5 + StrCmp $4 '' notfound + StrCmp $4 $2 0 -3 + StrCmp $1 '' 0 attrcmp + StrCpy $0 1 + goto end + + notfound: + StrCpy $0 0 + goto end + + error: + SetErrors + StrCpy $0 '' + + end: + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro GetFileVersion + !ifndef ${_FILEFUNC_UN}GetFileVersion + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}GetFileVersion `!insertmacro ${_FILEFUNC_UN}GetFileVersionCall` + + Function ${_FILEFUNC_UN}GetFileVersion + Exch $0 + Push $1 + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + ClearErrors + + GetDllVersion '$0' $1 $2 + IfErrors error + IntOp $3 $1 / 0x00010000 + IntOp $4 $1 & 0x0000FFFF + IntOp $5 $2 / 0x00010000 + IntOp $6 $2 & 0x0000FFFF + StrCpy $0 '$3.$4.$5.$6' + goto end + + error: + SetErrors + StrCpy $0 '' + + end: + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro GetExeName + !ifndef ${_FILEFUNC_UN}GetExeName + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}GetExeName `!insertmacro ${_FILEFUNC_UN}GetExeNameCall` + + Function ${_FILEFUNC_UN}GetExeName + Push $0 + Push $1 + Push $2 + System::Call /NOUNLOAD 'kernel32::GetModuleFileNameA(i 0, t .r0, i 1024)' + System::Call 'kernel32::GetLongPathNameA(t r0, t .r1, i 1024)i .r2' + StrCmp $2 error +2 + StrCpy $0 $1 + Pop $2 + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro GetExePath + !ifndef ${_FILEFUNC_UN}GetExePath + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}GetExePath `!insertmacro ${_FILEFUNC_UN}GetExePathCall` + + Function ${_FILEFUNC_UN}GetExePath + Push $0 + Push $1 + Push $2 + StrCpy $0 $EXEDIR + System::Call 'kernel32::GetLongPathNameA(t r0, t .r1, i 1024)i .r2' + StrCmp $2 error +2 + StrCpy $0 $1 + Pop $2 + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro GetParameters + !ifndef ${_FILEFUNC_UN}GetParameters + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}GetParameters `!insertmacro ${_FILEFUNC_UN}GetParametersCall` + + Function ${_FILEFUNC_UN}GetParameters + Push $0 + Push $1 + Push $2 + + StrCpy $1 1 + StrCpy $0 $CMDLINE 1 + StrCmp $0 '"' 0 +3 + StrCpy $2 '"' + goto +2 + StrCpy $2 ' ' + + IntOp $1 $1 + 1 + StrCpy $0 $CMDLINE 1 $1 + StrCmp $0 $2 +2 + StrCmp $0 '' end -3 + + IntOp $1 $1 + 1 + StrCpy $0 $CMDLINE 1 $1 + StrCmp $0 ' ' -2 + StrCpy $0 $CMDLINE '' $1 + + StrCpy $1 $0 1 -1 + StrCmp $1 ' ' 0 +3 + StrCpy $0 $0 -1 + goto -3 + + end: + Pop $2 + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro GetOptions + !ifndef ${_FILEFUNC_UN}GetOptions${_FILEFUNC_S} + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}GetOptions${_FILEFUNC_S} `!insertmacro ${_FILEFUNC_UN}GetOptions${_FILEFUNC_S}Call` + + Function ${_FILEFUNC_UN}GetOptions${_FILEFUNC_S} + Exch $1 + Exch + Exch $0 + Exch + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + Push $7 + ClearErrors + + StrCpy $2 $1 '' 1 + StrCpy $1 $1 1 + StrLen $3 $2 + StrCpy $7 0 + + begin: + StrCpy $4 -1 + StrCpy $6 '' + + quote: + IntOp $4 $4 + 1 + StrCpy $5 $0 1 $4 + StrCmp${_FILEFUNC_S} $5$7 '0' notfound + StrCmp${_FILEFUNC_S} $5 '' trimright + StrCmp${_FILEFUNC_S} $5 '"' 0 +7 + StrCmp${_FILEFUNC_S} $6 '' 0 +3 + StrCpy $6 '"' + goto quote + StrCmp${_FILEFUNC_S} $6 '"' 0 +3 + StrCpy $6 '' + goto quote + StrCmp${_FILEFUNC_S} $5 `'` 0 +7 + StrCmp${_FILEFUNC_S} $6 `` 0 +3 + StrCpy $6 `'` + goto quote + StrCmp${_FILEFUNC_S} $6 `'` 0 +3 + StrCpy $6 `` + goto quote + StrCmp${_FILEFUNC_S} $5 '`' 0 +7 + StrCmp${_FILEFUNC_S} $6 '' 0 +3 + StrCpy $6 '`' + goto quote + StrCmp${_FILEFUNC_S} $6 '`' 0 +3 + StrCpy $6 '' + goto quote + StrCmp${_FILEFUNC_S} $6 '"' quote + StrCmp${_FILEFUNC_S} $6 `'` quote + StrCmp${_FILEFUNC_S} $6 '`' quote + StrCmp${_FILEFUNC_S} $5 $1 0 quote + StrCmp${_FILEFUNC_S} $7 0 trimleft trimright + + trimleft: + IntOp $4 $4 + 1 + StrCpy $5 $0 $3 $4 + StrCmp${_FILEFUNC_S} $5 '' notfound + StrCmp${_FILEFUNC_S} $5 $2 0 quote + IntOp $4 $4 + $3 + StrCpy $0 $0 '' $4 + StrCpy $4 $0 1 + StrCmp${_FILEFUNC_S} $4 ' ' 0 +3 + StrCpy $0 $0 '' 1 + goto -3 + StrCpy $7 1 + goto begin + + trimright: + StrCpy $0 $0 $4 + StrCpy $4 $0 1 -1 + StrCmp${_FILEFUNC_S} $4 ' ' 0 +3 + StrCpy $0 $0 -1 + goto -3 + StrCpy $3 $0 1 + StrCpy $4 $0 1 -1 + StrCmp${_FILEFUNC_S} $3 $4 0 end + StrCmp${_FILEFUNC_S} $3 '"' +3 + StrCmp${_FILEFUNC_S} $3 `'` +2 + StrCmp${_FILEFUNC_S} $3 '`' 0 end + StrCpy $0 $0 -1 1 + goto end + + notfound: + SetErrors + StrCpy $0 '' + + end: + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + + +!macro GetRoot + !ifndef ${_FILEFUNC_UN}GetRoot + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}GetRoot `!insertmacro ${_FILEFUNC_UN}GetRootCall` + + Function ${_FILEFUNC_UN}GetRoot + Exch $0 + Push $1 + Push $2 + Push $3 + + StrCpy $1 $0 2 + StrCmp $1 '\\' UNC + StrCpy $1 0 + IntOp $1 $1 + 1 + StrCpy $2 $0 1 $1 + StrCmp $2 '' end + StrCmp $2 '\' 0 -3 + StrCpy $0 $0 $1 + goto end + + UNC: + StrCpy $2 2 + StrCpy $3 '' + StrCpy $1 $0 1 $2 + StrCmp $1 '\' empty + + loop: + IntOp $2 $2 + 1 + StrCpy $1 $0 1 $2 + StrCmp $1$3 '' empty + StrCmp $1 '' +5 + StrCmp $1 '\' 0 loop + StrCmp $3 '1' +3 + StrCpy $3 '1' + goto loop + StrCpy $0 $0 $2 + StrCpy $2 $0 1 -1 + StrCmp $2 '\' empty end + + empty: + StrCpy $0 '' + + end: + Pop $3 + Pop $2 + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro GetParent + !ifndef ${_FILEFUNC_UN}GetParent + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}GetParent `!insertmacro ${_FILEFUNC_UN}GetParentCall` + + Function ${_FILEFUNC_UN}GetParent + Exch $0 + Push $1 + Push $2 + + StrCpy $2 $0 1 -1 + StrCmp $2 '\' 0 +3 + StrCpy $0 $0 -1 + goto -3 + + StrCpy $1 0 + IntOp $1 $1 - 1 + StrCpy $2 $0 1 $1 + StrCmp $2 '\' +2 + StrCmp $2 '' 0 -3 + StrCpy $0 $0 $1 + + Pop $2 + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro GetFileName + !ifndef ${_FILEFUNC_UN}GetFileName + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}GetFileName `!insertmacro ${_FILEFUNC_UN}GetFileNameCall` + + Function ${_FILEFUNC_UN}GetFileName + Exch $0 + Push $1 + Push $2 + + StrCpy $2 $0 1 -1 + StrCmp $2 '\' 0 +3 + StrCpy $0 $0 -1 + goto -3 + + StrCpy $1 0 + IntOp $1 $1 - 1 + StrCpy $2 $0 1 $1 + StrCmp $2 '' end + StrCmp $2 '\' 0 -3 + IntOp $1 $1 + 1 + StrCpy $0 $0 '' $1 + + end: + Pop $2 + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro GetBaseName + !ifndef ${_FILEFUNC_UN}GetBaseName + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}GetBaseName `!insertmacro ${_FILEFUNC_UN}GetBaseNameCall` + + Function ${_FILEFUNC_UN}GetBaseName + Exch $0 + Push $1 + Push $2 + Push $3 + + StrCpy $1 0 + StrCpy $3 '' + + loop: + IntOp $1 $1 - 1 + StrCpy $2 $0 1 $1 + StrCmp $2 '' trimpath + StrCmp $2 '\' trimpath + StrCmp $3 'noext' loop + StrCmp $2 '.' 0 loop + StrCpy $0 $0 $1 + StrCpy $3 'noext' + StrCpy $1 0 + goto loop + + trimpath: + StrCmp $1 -1 empty + IntOp $1 $1 + 1 + StrCpy $0 $0 '' $1 + goto end + + empty: + StrCpy $0 '' + + end: + Pop $3 + Pop $2 + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro GetFileExt + !ifndef ${_FILEFUNC_UN}GetFileExt + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}GetFileExt `!insertmacro ${_FILEFUNC_UN}GetFileExtCall` + + Function ${_FILEFUNC_UN}GetFileExt + Exch $0 + Push $1 + Push $2 + + StrCpy $1 0 + + loop: + IntOp $1 $1 - 1 + StrCpy $2 $0 1 $1 + StrCmp $2 '' empty + StrCmp $2 '\' empty + StrCmp $2 '.' 0 loop + + StrCmp $1 -1 empty + IntOp $1 $1 + 1 + StrCpy $0 $0 '' $1 + goto end + + empty: + StrCpy $0 '' + + end: + Pop $2 + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro BannerTrimPath + !ifndef ${_FILEFUNC_UN}BannerTrimPath + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}BannerTrimPath `!insertmacro ${_FILEFUNC_UN}BannerTrimPathCall` + + Function ${_FILEFUNC_UN}BannerTrimPath + Exch $1 + Exch + Exch $0 + Exch + Push $2 + Push $3 + Push $4 + + StrCpy $3 $1 1 -1 + IntOp $1 $1 + 0 + StrLen $2 $0 + IntCmp $2 $1 end end + IntOp $1 $1 - 3 + IntCmp $1 0 empty empty + StrCmp $3 'A' A-trim + StrCmp $3 'B' B-trim + StrCmp $3 'C' C-trim + StrCmp $3 'D' D-trim + + A-trim: + StrCpy $3 $0 1 1 + StrCpy $2 0 + StrCmp $3 ':' 0 +2 + IntOp $2 $2 + 2 + + loopleft: + IntOp $2 $2 + 1 + StrCpy $3 $0 1 $2 + StrCmp $2 $1 C-trim + StrCmp $3 '\' 0 loopleft + StrCpy $3 $0 $2 + IntOp $2 $2 - $1 + IntCmp $2 0 B-trim 0 B-trim + + loopright: + IntOp $2 $2 + 1 + StrCpy $4 $0 1 $2 + StrCmp $2 0 B-trim + StrCmp $4 '\' 0 loopright + StrCpy $4 $0 '' $2 + StrCpy $0 '$3\...$4' + goto end + + B-trim: + StrCpy $2 $1 + IntOp $2 $2 - 1 + StrCmp $2 -1 C-trim + StrCpy $3 $0 1 $2 + StrCmp $3 '\' 0 -3 + StrCpy $0 $0 $2 + StrCpy $0 '$0\...' + goto end + + C-trim: + StrCpy $0 $0 $1 + StrCpy $0 '$0...' + goto end + + D-trim: + StrCpy $3 -1 + IntOp $3 $3 - 1 + StrCmp $3 -$2 C-trim + StrCpy $4 $0 1 $3 + StrCmp $4 '\' 0 -3 + StrCpy $4 $0 '' $3 + IntOp $3 $1 + $3 + IntCmp $3 2 C-trim C-trim + StrCpy $0 $0 $3 + StrCpy $0 '$0...$4' + goto end + + empty: + StrCpy $0 '' + + end: + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro DirState + !ifndef ${_FILEFUNC_UN}DirState + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}DirState `!insertmacro ${_FILEFUNC_UN}DirStateCall` + + Function ${_FILEFUNC_UN}DirState + Exch $0 + Push $1 + ClearErrors + + FindFirst $1 $0 '$0\*.*' + IfErrors 0 +3 + StrCpy $0 -1 + goto end + StrCmp $0 '.' 0 +4 + FindNext $1 $0 + StrCmp $0 '..' 0 +2 + FindNext $1 $0 + FindClose $1 + IfErrors 0 +3 + StrCpy $0 0 + goto end + StrCpy $0 1 + + end: + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro RefreshShellIcons + !ifndef ${_FILEFUNC_UN}RefreshShellIcons + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !define ${_FILEFUNC_UN}RefreshShellIcons `!insertmacro ${_FILEFUNC_UN}RefreshShellIconsCall` + + Function ${_FILEFUNC_UN}RefreshShellIcons + System::Call 'shell32::SHChangeNotify(i 0x08000000, i 0, i 0, i 0)' + FunctionEnd + + !verbose pop + !endif +!macroend + + +# Uninstall. Case insensitive. # + +!macro un.LocateCall _PATH _OPTIONS _FUNC + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push $0 + Push `${_PATH}` + Push `${_OPTIONS}` + GetFunctionAddress $0 `${_FUNC}` + Push `$0` + Call un.Locate + Pop $0 + !verbose pop +!macroend + +!macro un.GetSizeCall _PATH _OPTIONS _RESULT1 _RESULT2 _RESULT3 + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PATH}` + Push `${_OPTIONS}` + Call un.GetSize + Pop ${_RESULT1} + Pop ${_RESULT2} + Pop ${_RESULT3} + !verbose pop +!macroend + +!macro un.DriveSpaceCall _DRIVE _OPTIONS _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_DRIVE}` + Push `${_OPTIONS}` + Call un.DriveSpace + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.GetDrivesCall _DRV _FUNC + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push $0 + Push `${_DRV}` + GetFunctionAddress $0 `${_FUNC}` + Push `$0` + Call un.GetDrives + Pop $0 + !verbose pop +!macroend + +!macro un.GetTimeCall _FILE _OPTION _RESULT1 _RESULT2 _RESULT3 _RESULT4 _RESULT5 _RESULT6 _RESULT7 + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_FILE}` + Push `${_OPTION}` + Call un.GetTime + Pop ${_RESULT1} + Pop ${_RESULT2} + Pop ${_RESULT3} + Pop ${_RESULT4} + Pop ${_RESULT5} + Pop ${_RESULT6} + Pop ${_RESULT7} + !verbose pop +!macroend + +!macro un.GetFileAttributesCall _PATH _ATTR _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PATH}` + Push `${_ATTR}` + Call un.GetFileAttributes + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.GetFileVersionCall _FILE _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_FILE}` + Call un.GetFileVersion + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.GetExeNameCall _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Call un.GetExeName + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.GetExePathCall _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Call un.GetExePath + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.GetParametersCall _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Call un.GetParameters + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.GetOptionsCall _PARAMETERS _OPTION _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PARAMETERS}` + Push `${_OPTION}` + Call un.GetOptions + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.GetRootCall _FULLPATH _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_FULLPATH}` + Call un.GetRoot + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.GetParentCall _PATHSTRING _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PATHSTRING}` + Call un.GetParent + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.GetFileNameCall _PATHSTRING _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PATHSTRING}` + Call un.GetFileName + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.GetBaseNameCall _FILESTRING _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_FILESTRING}` + Call un.GetBaseName + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.GetFileExtCall _FILESTRING _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_FILESTRING}` + Call un.GetFileExt + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.BannerTrimPathCall _PATH _LENGHT _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PATH}` + Push `${_LENGHT}` + Call un.BannerTrimPath + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.DirStateCall _PATH _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PATH}` + Call un.DirState + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.RefreshShellIconsCall + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Call un.RefreshShellIcons + !verbose pop +!macroend + +!macro un.Locate + !ifndef un.Locate + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro Locate + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.GetSize + !ifndef un.GetSize + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro GetSize + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.DriveSpace + !ifndef un.DriveSpace + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro DriveSpace + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.GetDrives + !ifndef un.GetDrives + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro GetDrives + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.GetTime + !ifndef un.GetTime + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro GetTime + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.GetFileAttributes + !ifndef un.GetFileAttributes + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro GetFileAttributes + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.GetFileVersion + !ifndef un.GetFileVersion + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro GetFileVersion + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.GetExeName + !ifndef un.GetExeName + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro GetExeName + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.GetExePath + !ifndef un.GetExePath + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro GetExePath + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.GetParameters + !ifndef un.GetParameters + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro GetParameters + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.GetOptions + !ifndef un.GetOptions + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro GetOptions + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.GetRoot + !ifndef un.GetRoot + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro GetRoot + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.GetParent + !ifndef un.GetParent + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro GetParent + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.GetFileName + !ifndef un.GetFileName + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro GetFileName + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.GetBaseName + !ifndef un.GetBaseName + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro GetBaseName + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.GetFileExt + !ifndef un.GetFileExt + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro GetFileExt + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.BannerTrimPath + !ifndef un.BannerTrimPath + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro BannerTrimPath + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.DirState + !ifndef un.DirState + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro DirState + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.RefreshShellIcons + !ifndef un.RefreshShellIcons + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + + !insertmacro RefreshShellIcons + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !verbose pop + !endif +!macroend + + +# Install. Case sensitive. # + +!macro GetOptionsSCall _PARAMETERS _OPTION _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PARAMETERS}` + Push `${_OPTION}` + Call GetOptionsS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro GetOptionsS + !ifndef GetOptionsS + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_S + !define _FILEFUNC_S `S` + + !insertmacro GetOptions + + !undef _FILEFUNC_S + !define _FILEFUNC_S + !verbose pop + !endif +!macroend + + +# Uninstall. Case sensitive. # + +!macro un.GetOptionsSCall _PARAMETERS _OPTION _RESULT + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + Push `${_PARAMETERS}` + Push `${_OPTION}` + Call un.GetOptionsS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.GetOptionsS + !ifndef un.GetOptionsS + !verbose push + !verbose ${_FILEFUNC_VERBOSE} + !undef _FILEFUNC_UN + !define _FILEFUNC_UN `un.` + !undef _FILEFUNC_S + !define _FILEFUNC_S `S` + + !insertmacro GetOptions + + !undef _FILEFUNC_UN + !define _FILEFUNC_UN + !undef _FILEFUNC_S + !define _FILEFUNC_S + !verbose pop + !endif +!macroend + +!endif diff --git a/companion/targets/windows/WordFunc.nsh b/companion/targets/windows/WordFunc.nsh new file mode 100644 index 00000000000..4a7dc10447b --- /dev/null +++ b/companion/targets/windows/WordFunc.nsh @@ -0,0 +1,2157 @@ +/* + + 2006 Shengalts Aleksander aka Instructor (Shengalts@mail.ru) + + Note: header stripped out to avoid errors + +*/ + + +!ifndef WORDFUNC_INCLUDED +!define WORDFUNC_INCLUDED + +!verbose push +!verbose 3 +!ifndef _WORDFUNC_VERBOSE + !define _WORDFUNC_VERBOSE 3 +!endif +!verbose ${_WORDFUNC_VERBOSE} +!define WORDFUNC_VERBOSE `!insertmacro WORDFUNC_VERBOSE` +!define _WORDFUNC_UN +!define _WORDFUNC_S +!verbose pop + +!macro WORDFUNC_VERBOSE _VERBOSE + !verbose push + !verbose 3 + !undef _WORDFUNC_VERBOSE + !define _WORDFUNC_VERBOSE ${_VERBOSE} + !verbose pop +!macroend + + +# Install. Case insensitive. # + +!macro WordFindCall _STRING _DELIMITER _OPTION _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER}` + Push `${_OPTION}` + Call WordFind + Pop ${_RESULT} + !verbose pop +!macroend + +!macro WordFind2XCall _STRING _DELIMITER1 _DELIMITER2 _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER1}` + Push `${_DELIMITER2}` + Push `${_NUMBER}` + Call WordFind2X + Pop ${_RESULT} + !verbose pop +!macroend + +!macro WordFind3XCall _STRING _DELIMITER1 _CENTER _DELIMITER2 _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER1}` + Push `${_CENTER}` + Push `${_DELIMITER2}` + Push `${_NUMBER}` + Call WordFind3X + Pop ${_RESULT} + !verbose pop +!macroend + +!macro WordReplaceCall _STRING _WORD1 _WORD2 _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_WORD1}` + Push `${_WORD2}` + Push `${_NUMBER}` + Call WordReplace + Pop ${_RESULT} + !verbose pop +!macroend + +!macro WordAddCall _STRING1 _DELIMITER _STRING2 _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING1}` + Push `${_DELIMITER}` + Push `${_STRING2}` + Call WordAdd + Pop ${_RESULT} + !verbose pop +!macroend + +!macro WordInsertCall _STRING _DELIMITER _WORD _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER}` + Push `${_WORD}` + Push `${_NUMBER}` + Call WordInsert + Pop ${_RESULT} + !verbose pop +!macroend + +!macro StrFilterCall _STRING _FILTER _INCLUDE _EXCLUDE _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_FILTER}` + Push `${_INCLUDE}` + Push `${_EXCLUDE}` + Call StrFilter + Pop ${_RESULT} + !verbose pop +!macroend + +!macro VersionCompareCall _VER1 _VER2 _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_VER1}` + Push `${_VER2}` + Call VersionCompare + Pop ${_RESULT} + !verbose pop +!macroend + +!macro VersionConvertCall _VERSION _CHARLIST _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_VERSION}` + Push `${_CHARLIST}` + Call VersionConvert + Pop ${_RESULT} + !verbose pop +!macroend + +!macro WordFind + !ifndef ${_WORDFUNC_UN}WordFind${_WORDFUNC_S} + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !define ${_WORDFUNC_UN}WordFind${_WORDFUNC_S} `!insertmacro ${_WORDFUNC_UN}WordFind${_WORDFUNC_S}Call` + + Function ${_WORDFUNC_UN}WordFind${_WORDFUNC_S} + Exch $1 + Exch + Exch $0 + Exch + Exch 2 + Exch $R0 + Exch 2 + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + Push $7 + Push $8 + Push $9 + Push $R1 + ClearErrors + + StrCpy $9 '' + StrCpy $2 $1 1 + StrCpy $1 $1 '' 1 + StrCmp $2 'E' 0 +3 + StrCpy $9 E + goto -4 + + StrCpy $3 '' + StrCmp${_WORDFUNC_S} $2 '+' +6 + StrCmp${_WORDFUNC_S} $2 '-' +5 + StrCmp${_WORDFUNC_S} $2 '/' restart + StrCmp${_WORDFUNC_S} $2 '#' restart + StrCmp${_WORDFUNC_S} $2 '*' restart + goto error3 + + StrCpy $4 $1 1 -1 + StrCmp${_WORDFUNC_S} $4 '*' +4 + StrCmp${_WORDFUNC_S} $4 '}' +3 + StrCmp${_WORDFUNC_S} $4 '{' +2 + goto +4 + StrCpy $1 $1 -1 + StrCpy $3 '$4$3' + goto -7 + StrCmp${_WORDFUNC_S} $3 '*' error3 + StrCmp${_WORDFUNC_S} $3 '**' error3 + StrCmp${_WORDFUNC_S} $3 '}{' error3 + IntOp $1 $1 + 0 + StrCmp${_WORDFUNC_S} $1 0 error2 + + restart: + StrCmp${_WORDFUNC_S} $R0 '' error1 + StrCpy $4 0 + StrCpy $5 0 + StrCpy $6 0 + StrLen $7 $0 + goto loop + + preloop: + IntOp $6 $6 + 1 + + loop: + StrCpy $8 $R0 $7 $6 + StrCmp${_WORDFUNC_S} $8$5 0 error1 + StrCmp${_WORDFUNC_S} $8 '' +2 + StrCmp${_WORDFUNC_S} $8 $0 +5 preloop + StrCmp${_WORDFUNC_S} $3 '{' minus + StrCmp${_WORDFUNC_S} $3 '}' minus + StrCmp${_WORDFUNC_S} $2 '*' minus + StrCmp${_WORDFUNC_S} $5 $6 minus +5 + StrCmp${_WORDFUNC_S} $3 '{' +4 + StrCmp${_WORDFUNC_S} $3 '}' +3 + StrCmp${_WORDFUNC_S} $2 '*' +2 + StrCmp${_WORDFUNC_S} $5 $6 nextword + IntOp $4 $4 + 1 + StrCmp${_WORDFUNC_S} $2$4 +$1 plus + StrCmp${_WORDFUNC_S} $2 '/' 0 nextword + IntOp $8 $6 - $5 + StrCpy $8 $R0 $8 $5 + StrCmp${_WORDFUNC_S} $1 $8 0 nextword + StrCpy $R1 $4 + goto end + nextword: + IntOp $6 $6 + $7 + StrCpy $5 $6 + goto loop + + minus: + StrCmp${_WORDFUNC_S} $2 '-' 0 sum + StrCpy $2 '+' + IntOp $1 $4 - $1 + IntOp $1 $1 + 1 + IntCmp $1 0 error2 error2 restart + sum: + StrCmp${_WORDFUNC_S} $2 '#' 0 sumdelim + StrCpy $R1 $4 + goto end + sumdelim: + StrCmp${_WORDFUNC_S} $2 '*' 0 error2 + StrCpy $R1 $4 + goto end + + plus: + StrCmp${_WORDFUNC_S} $3 '' 0 +4 + IntOp $6 $6 - $5 + StrCpy $R1 $R0 $6 $5 + goto end + StrCmp${_WORDFUNC_S} $3 '{' 0 +3 + StrCpy $R1 $R0 $6 + goto end + StrCmp${_WORDFUNC_S} $3 '}' 0 +4 + IntOp $6 $6 + $7 + StrCpy $R1 $R0 '' $6 + goto end + StrCmp${_WORDFUNC_S} $3 '{*' +2 + StrCmp${_WORDFUNC_S} $3 '*{' 0 +3 + StrCpy $R1 $R0 $6 + goto end + StrCmp${_WORDFUNC_S} $3 '*}' +2 + StrCmp${_WORDFUNC_S} $3 '}*' 0 +3 + StrCpy $R1 $R0 '' $5 + goto end + StrCmp${_WORDFUNC_S} $3 '}}' 0 +3 + StrCpy $R1 $R0 '' $6 + goto end + StrCmp${_WORDFUNC_S} $3 '{{' 0 +3 + StrCpy $R1 $R0 $5 + goto end + StrCmp${_WORDFUNC_S} $3 '{}' 0 error3 + StrLen $3 $R0 + StrCmp${_WORDFUNC_S} $3 $6 0 +3 + StrCpy $0 '' + goto +2 + IntOp $6 $6 + $7 + StrCpy $8 $R0 '' $6 + StrCmp${_WORDFUNC_S} $4$8 1 +6 + StrCmp${_WORDFUNC_S} $4 1 +2 +7 + IntOp $6 $6 + $7 + StrCpy $3 $R0 $7 $6 + StrCmp${_WORDFUNC_S} $3 '' +2 + StrCmp${_WORDFUNC_S} $3 $0 -3 +3 + StrCpy $R1 '' + goto end + StrCmp${_WORDFUNC_S} $5 0 0 +3 + StrCpy $0 '' + goto +2 + IntOp $5 $5 - $7 + StrCpy $3 $R0 $5 + StrCpy $R1 '$3$0$8' + goto end + + error3: + StrCpy $R1 3 + goto error + error2: + StrCpy $R1 2 + goto error + error1: + StrCpy $R1 1 + error: + StrCmp $9 'E' 0 +3 + SetErrors + + end: + StrCpy $R0 $R1 + + Pop $R1 + Pop $9 + Pop $8 + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 + Exch $R0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro WordFind2X + !ifndef ${_WORDFUNC_UN}WordFind2X${_WORDFUNC_S} + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !define ${_WORDFUNC_UN}WordFind2X${_WORDFUNC_S} `!insertmacro ${_WORDFUNC_UN}WordFind2X${_WORDFUNC_S}Call` + + Function ${_WORDFUNC_UN}WordFind2X${_WORDFUNC_S} + Exch $2 + Exch + Exch $1 + Exch + Exch 2 + Exch $0 + Exch 2 + Exch 3 + Exch $R0 + Exch 3 + Push $3 + Push $4 + Push $5 + Push $6 + Push $7 + Push $8 + Push $9 + Push $R1 + Push $R2 + ClearErrors + + StrCpy $R2 '' + StrCpy $3 $2 1 + StrCpy $2 $2 '' 1 + StrCmp $3 'E' 0 +3 + StrCpy $R2 E + goto -4 + + StrCmp${_WORDFUNC_S} $3 '+' +5 + StrCmp${_WORDFUNC_S} $3 '-' +4 + StrCmp${_WORDFUNC_S} $3 '#' restart + StrCmp${_WORDFUNC_S} $3 '/' restart + goto error3 + + StrCpy $4 $2 2 -2 + StrCmp${_WORDFUNC_S} $4 '{{' +9 + StrCmp${_WORDFUNC_S} $4 '}}' +8 + StrCmp${_WORDFUNC_S} $4 '{*' +7 + StrCmp${_WORDFUNC_S} $4 '*{' +6 + StrCmp${_WORDFUNC_S} $4 '*}' +5 + StrCmp${_WORDFUNC_S} $4 '}*' +4 + StrCmp${_WORDFUNC_S} $4 '{}' +3 + StrCpy $4 '' + goto +2 + StrCpy $2 $2 -2 + IntOp $2 $2 + 0 + StrCmp${_WORDFUNC_S} $2 0 error2 + + restart: + StrCmp${_WORDFUNC_S} $R0 '' error1 + StrCpy $5 -1 + StrCpy $6 0 + StrCpy $7 '' + StrLen $8 $0 + StrLen $9 $1 + + loop: + IntOp $5 $5 + 1 + + delim1: + StrCpy $R1 $R0 $8 $5 + StrCmp${_WORDFUNC_S} $R1$6 0 error1 + StrCmp${_WORDFUNC_S} $R1 '' minus + StrCmp${_WORDFUNC_S} $R1 $0 +2 + StrCmp${_WORDFUNC_S} $7 '' loop delim2 + StrCmp${_WORDFUNC_S} $0 $1 0 +2 + StrCmp${_WORDFUNC_S} $7 '' 0 delim2 + IntOp $7 $5 + $8 + StrCpy $5 $7 + goto delim1 + + delim2: + StrCpy $R1 $R0 $9 $5 + StrCmp${_WORDFUNC_S} $R1 $1 0 loop + IntOp $6 $6 + 1 + StrCmp${_WORDFUNC_S} $3$6 '+$2' plus + StrCmp${_WORDFUNC_S} $3 '/' 0 nextword + IntOp $R1 $5 - $7 + StrCpy $R1 $R0 $R1 $7 + StrCmp${_WORDFUNC_S} $R1 $2 0 +3 + StrCpy $R1 $6 + goto end + nextword: + IntOp $5 $5 + $9 + StrCpy $7 '' + goto delim1 + + minus: + StrCmp${_WORDFUNC_S} $3 '-' 0 sum + StrCpy $3 + + IntOp $2 $6 - $2 + IntOp $2 $2 + 1 + IntCmp $2 0 error2 error2 restart + sum: + StrCmp${_WORDFUNC_S} $3 '#' 0 error2 + StrCpy $R1 $6 + goto end + + plus: + StrCmp${_WORDFUNC_S} $4 '' 0 +4 + IntOp $R1 $5 - $7 + StrCpy $R1 $R0 $R1 $7 + goto end + IntOp $5 $5 + $9 + IntOp $7 $7 - $8 + StrCmp${_WORDFUNC_S} $4 '{*' +2 + StrCmp${_WORDFUNC_S} $4 '*{' 0 +3 + StrCpy $R1 $R0 $5 + goto end + StrCmp${_WORDFUNC_S} $4 '*}' +2 + StrCmp${_WORDFUNC_S} $4 '}*' 0 +3 + StrCpy $R1 $R0 '' $7 + goto end + StrCmp${_WORDFUNC_S} $4 '}}' 0 +3 + StrCpy $R1 $R0 '' $5 + goto end + StrCmp${_WORDFUNC_S} $4 '{{' 0 +3 + StrCpy $R1 $R0 $7 + goto end + StrCmp${_WORDFUNC_S} $4 '{}' 0 error3 + StrCpy $5 $R0 '' $5 + StrCpy $7 $R0 $7 + StrCpy $R1 '$7$5' + goto end + + error3: + StrCpy $R1 3 + goto error + error2: + StrCpy $R1 2 + goto error + error1: + StrCpy $R1 1 + error: + StrCmp $R2 'E' 0 +3 + SetErrors + + end: + StrCpy $R0 $R1 + + Pop $R2 + Pop $R1 + Pop $9 + Pop $8 + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 + Exch $R0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro WordFind3X + !ifndef ${_WORDFUNC_UN}WordFind3X${_WORDFUNC_S} + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !define ${_WORDFUNC_UN}WordFind3X${_WORDFUNC_S} `!insertmacro ${_WORDFUNC_UN}WordFind3X${_WORDFUNC_S}Call` + + Function ${_WORDFUNC_UN}WordFind3X${_WORDFUNC_S} + Exch $3 + Exch + Exch $2 + Exch + Exch 2 + Exch $1 + Exch 2 + Exch 3 + Exch $0 + Exch 3 + Exch 4 + Exch $R0 + Exch 4 + Push $4 + Push $5 + Push $6 + Push $7 + Push $8 + Push $9 + Push $R1 + Push $R2 + Push $R3 + Push $R4 + Push $R5 + ClearErrors + + StrCpy $R5 '' + StrCpy $4 $3 1 + StrCpy $3 $3 '' 1 + StrCmp $4 'E' 0 +3 + StrCpy $R5 E + goto -4 + + StrCmp${_WORDFUNC_S} $4 '+' +5 + StrCmp${_WORDFUNC_S} $4 '-' +4 + StrCmp${_WORDFUNC_S} $4 '#' restart + StrCmp${_WORDFUNC_S} $4 '/' restart + goto error3 + + StrCpy $5 $3 2 -2 + StrCmp${_WORDFUNC_S} $5 '{{' +9 + StrCmp${_WORDFUNC_S} $5 '}}' +8 + StrCmp${_WORDFUNC_S} $5 '{*' +7 + StrCmp${_WORDFUNC_S} $5 '*{' +6 + StrCmp${_WORDFUNC_S} $5 '*}' +5 + StrCmp${_WORDFUNC_S} $5 '}*' +4 + StrCmp${_WORDFUNC_S} $5 '{}' +3 + StrCpy $5 '' + goto +2 + StrCpy $3 $3 -2 + IntOp $3 $3 + 0 + StrCmp${_WORDFUNC_S} $3 0 error2 + + restart: + StrCmp${_WORDFUNC_S} $R0 '' error1 + StrCpy $6 -1 + StrCpy $7 0 + StrCpy $8 '' + StrCpy $9 '' + StrLen $R1 $0 + StrLen $R2 $1 + StrLen $R3 $2 + + loop: + IntOp $6 $6 + 1 + + delim1: + StrCpy $R4 $R0 $R1 $6 + StrCmp${_WORDFUNC_S} $R4$7 0 error1 + StrCmp${_WORDFUNC_S} $R4 '' minus + StrCmp${_WORDFUNC_S} $R4 $0 +2 + StrCmp${_WORDFUNC_S} $8 '' loop center + StrCmp${_WORDFUNC_S} $0 $1 +2 + StrCmp${_WORDFUNC_S} $0 $2 0 +2 + StrCmp${_WORDFUNC_S} $8 '' 0 center + IntOp $8 $6 + $R1 + StrCpy $6 $8 + goto delim1 + + center: + StrCmp${_WORDFUNC_S} $9 '' 0 delim2 + StrCpy $R4 $R0 $R2 $6 + StrCmp${_WORDFUNC_S} $R4 $1 0 loop + IntOp $9 $6 + $R2 + StrCpy $6 $9 + goto delim1 + + delim2: + StrCpy $R4 $R0 $R3 $6 + StrCmp${_WORDFUNC_S} $R4 $2 0 loop + IntOp $7 $7 + 1 + StrCmp${_WORDFUNC_S} $4$7 '+$3' plus + StrCmp${_WORDFUNC_S} $4 '/' 0 nextword + IntOp $R4 $6 - $8 + StrCpy $R4 $R0 $R4 $8 + StrCmp${_WORDFUNC_S} $R4 $3 0 +3 + StrCpy $R4 $7 + goto end + nextword: + IntOp $6 $6 + $R3 + StrCpy $8 '' + StrCpy $9 '' + goto delim1 + + minus: + StrCmp${_WORDFUNC_S} $4 '-' 0 sum + StrCpy $4 + + IntOp $3 $7 - $3 + IntOp $3 $3 + 1 + IntCmp $3 0 error2 error2 restart + sum: + StrCmp${_WORDFUNC_S} $4 '#' 0 error2 + StrCpy $R4 $7 + goto end + + plus: + StrCmp${_WORDFUNC_S} $5 '' 0 +4 + IntOp $R4 $6 - $8 + StrCpy $R4 $R0 $R4 $8 + goto end + IntOp $6 $6 + $R3 + IntOp $8 $8 - $R1 + StrCmp${_WORDFUNC_S} $5 '{*' +2 + StrCmp${_WORDFUNC_S} $5 '*{' 0 +3 + StrCpy $R4 $R0 $6 + goto end + StrCmp${_WORDFUNC_S} $5 '*}' +2 + StrCmp${_WORDFUNC_S} $5 '}*' 0 +3 + StrCpy $R4 $R0 '' $8 + goto end + StrCmp${_WORDFUNC_S} $5 '}}' 0 +3 + StrCpy $R4 $R0 '' $6 + goto end + StrCmp${_WORDFUNC_S} $5 '{{' 0 +3 + StrCpy $R4 $R0 $8 + goto end + StrCmp${_WORDFUNC_S} $5 '{}' 0 error3 + StrCpy $6 $R0 '' $6 + StrCpy $8 $R0 $8 + StrCpy $R4 '$8$6' + goto end + + error3: + StrCpy $R4 3 + goto error + error2: + StrCpy $R4 2 + goto error + error1: + StrCpy $R4 1 + error: + StrCmp $R5 'E' 0 +3 + SetErrors + + end: + StrCpy $R0 $R4 + Pop $R5 + Pop $R4 + Pop $R3 + Pop $R2 + Pop $R1 + Pop $9 + Pop $8 + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 + Exch $R0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro WordReplace + !ifndef ${_WORDFUNC_UN}WordReplace${_WORDFUNC_S} + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !define ${_WORDFUNC_UN}WordReplace${_WORDFUNC_S} `!insertmacro ${_WORDFUNC_UN}WordReplace${_WORDFUNC_S}Call` + + Function ${_WORDFUNC_UN}WordReplace${_WORDFUNC_S} + Exch $2 + Exch + Exch $1 + Exch + Exch 2 + Exch $0 + Exch 2 + Exch 3 + Exch $R0 + Exch 3 + Push $3 + Push $4 + Push $5 + Push $6 + Push $7 + Push $8 + Push $9 + Push $R1 + ClearErrors + + StrCpy $R1 $R0 + StrCpy $9 '' + StrCpy $3 $2 1 + StrCpy $2 $2 '' 1 + StrCmp $3 'E' 0 +3 + StrCpy $9 E + goto -4 + + StrCpy $4 $2 1 -1 + StrCpy $5 '' + StrCpy $6 '' + StrLen $7 $0 + + StrCmp${_WORDFUNC_S} $7 0 error1 + StrCmp${_WORDFUNC_S} $R0 '' error1 + StrCmp${_WORDFUNC_S} $3 '{' beginning + StrCmp${_WORDFUNC_S} $3 '}' ending errorchk + + beginning: + StrCpy $8 $R0 $7 + StrCmp${_WORDFUNC_S} $8 $0 0 +4 + StrCpy $R0 $R0 '' $7 + StrCpy $5 '$5$1' + goto -4 + StrCpy $3 $2 1 + StrCmp${_WORDFUNC_S} $3 '}' 0 merge + + ending: + StrCpy $8 $R0 '' -$7 + StrCmp${_WORDFUNC_S} $8 $0 0 +4 + StrCpy $R0 $R0 -$7 + StrCpy $6 '$6$1' + goto -4 + + merge: + StrCmp${_WORDFUNC_S} $4 '*' 0 +5 + StrCmp${_WORDFUNC_S} $5 '' +2 + StrCpy $5 $1 + StrCmp${_WORDFUNC_S} $6 '' +2 + StrCpy $6 $1 + StrCpy $R0 '$5$R0$6' + goto end + + errorchk: + StrCmp${_WORDFUNC_S} $3 '+' +2 + StrCmp${_WORDFUNC_S} $3 '-' 0 error3 + + StrCpy $5 $2 1 + IntOp $2 $2 + 0 + StrCmp${_WORDFUNC_S} $2 0 0 one + StrCmp${_WORDFUNC_S} $5 0 error2 + StrCpy $3 '' + + all: + StrCpy $5 0 + StrCpy $2 $R0 $7 $5 + StrCmp${_WORDFUNC_S} $2 '' +4 + StrCmp${_WORDFUNC_S} $2 $0 +6 + IntOp $5 $5 + 1 + goto -4 + StrCmp${_WORDFUNC_S} $R0 $R1 error1 + StrCpy $R0 '$3$R0' + goto end + StrCpy $2 $R0 $5 + IntOp $5 $5 + $7 + StrCmp${_WORDFUNC_S} $4 '*' 0 +3 + StrCpy $6 $R0 $7 $5 + StrCmp${_WORDFUNC_S} $6 $0 -3 + StrCpy $R0 $R0 '' $5 + StrCpy $3 '$3$2$1' + goto all + + one: + StrCpy $5 0 + StrCpy $8 0 + goto loop + + preloop: + IntOp $5 $5 + 1 + + loop: + StrCpy $6 $R0 $7 $5 + StrCmp${_WORDFUNC_S} $6$8 0 error1 + StrCmp${_WORDFUNC_S} $6 '' minus + StrCmp${_WORDFUNC_S} $6 $0 0 preloop + IntOp $8 $8 + 1 + StrCmp${_WORDFUNC_S} $3$8 +$2 found + IntOp $5 $5 + $7 + goto loop + + minus: + StrCmp${_WORDFUNC_S} $3 '-' 0 error2 + StrCpy $3 + + IntOp $2 $8 - $2 + IntOp $2 $2 + 1 + IntCmp $2 0 error2 error2 one + + found: + StrCpy $3 $R0 $5 + StrCmp${_WORDFUNC_S} $4 '*' 0 +5 + StrCpy $6 $3 '' -$7 + StrCmp${_WORDFUNC_S} $6 $0 0 +3 + StrCpy $3 $3 -$7 + goto -3 + IntOp $5 $5 + $7 + StrCmp${_WORDFUNC_S} $4 '*' 0 +3 + StrCpy $6 $R0 $7 $5 + StrCmp${_WORDFUNC_S} $6 $0 -3 + StrCpy $R0 $R0 '' $5 + StrCpy $R0 '$3$1$R0' + goto end + + error3: + StrCpy $R0 3 + goto error + error2: + StrCpy $R0 2 + goto error + error1: + StrCpy $R0 1 + error: + StrCmp $9 'E' +3 + StrCpy $R0 $R1 + goto +2 + SetErrors + + end: + Pop $R1 + Pop $9 + Pop $8 + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 + Exch $R0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro WordAdd + !ifndef ${_WORDFUNC_UN}WordAdd${_WORDFUNC_S} + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !insertmacro WordFind + + !define ${_WORDFUNC_UN}WordAdd${_WORDFUNC_S} `!insertmacro ${_WORDFUNC_UN}WordAdd${_WORDFUNC_S}Call` + + Function ${_WORDFUNC_UN}WordAdd${_WORDFUNC_S} + Exch $1 + Exch + Exch $0 + Exch + Exch 2 + Exch $R0 + Exch 2 + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + Push $7 + Push $R1 + ClearErrors + + StrCpy $7 '' + StrCpy $2 $1 1 + StrCmp $2 'E' 0 +4 + StrCpy $7 E + StrCpy $1 $1 '' 1 + goto -4 + + StrCpy $5 0 + StrCpy $R1 $R0 + StrCpy $2 $1 '' 1 + StrCpy $1 $1 1 + StrCmp${_WORDFUNC_S} $1 '+' +2 + StrCmp${_WORDFUNC_S} $1 '-' 0 error3 + + StrCmp${_WORDFUNC_S} $0 '' error1 + StrCmp${_WORDFUNC_S} $2 '' end + StrCmp${_WORDFUNC_S} $R0 '' 0 +5 + StrCmp${_WORDFUNC_S} $1 '-' end + StrCmp${_WORDFUNC_S} $1 '+' 0 +3 + StrCpy $R0 $2 + goto end + + loop: + IntOp $5 $5 + 1 + Push `$2` + Push `$0` + Push `E+$5` + Call ${_WORDFUNC_UN}WordFind${_WORDFUNC_S} + Pop $3 + IfErrors 0 /word + StrCmp${_WORDFUNC_S} $3 2 +4 + StrCmp${_WORDFUNC_S} $3$5 11 0 +3 + StrCpy $3 $2 + goto /word + StrCmp${_WORDFUNC_S} $1 '-' end preend + + /word: + Push `$R0` + Push `$0` + Push `E/$3` + Call ${_WORDFUNC_UN}WordFind${_WORDFUNC_S} + Pop $4 + IfErrors +2 + StrCmp${_WORDFUNC_S} $1 '-' delete loop + StrCmp${_WORDFUNC_S} $1$4 '-1' +2 + StrCmp${_WORDFUNC_S} $1 '-' loop +4 + StrCmp${_WORDFUNC_S} $R0 $3 0 loop + StrCpy $R0 '' + goto end + StrCmp${_WORDFUNC_S} $1$4 '+1' 0 +2 + StrCmp${_WORDFUNC_S} $R0 $3 loop + StrCmp${_WORDFUNC_S} $R0 $R1 +3 + StrCpy $R1 '$R1$0$3' + goto loop + StrLen $6 $0 + StrCpy $6 $R0 '' -$6 + StrCmp${_WORDFUNC_S} $6 $0 0 -4 + StrCpy $R1 '$R1$3' + goto loop + + delete: + Push `$R0` + Push `$0` + Push `E+$4{}` + Call ${_WORDFUNC_UN}WordFind${_WORDFUNC_S} + Pop $R0 + goto /word + + error3: + StrCpy $R1 3 + goto error + error1: + StrCpy $R1 1 + error: + StrCmp $7 'E' 0 end + SetErrors + + preend: + StrCpy $R0 $R1 + + end: + Pop $R1 + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 + Exch $R0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro WordInsert + !ifndef ${_WORDFUNC_UN}WordInsert${_WORDFUNC_S} + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !insertmacro WordFind + + !define ${_WORDFUNC_UN}WordInsert${_WORDFUNC_S} `!insertmacro ${_WORDFUNC_UN}WordInsert${_WORDFUNC_S}Call` + + Function ${_WORDFUNC_UN}WordInsert${_WORDFUNC_S} + Exch $2 + Exch + Exch $1 + Exch + Exch 2 + Exch $0 + Exch 2 + Exch 3 + Exch $R0 + Exch 3 + Push $3 + Push $4 + Push $5 + Push $6 + Push $7 + Push $8 + Push $9 + Push $R1 + ClearErrors + + StrCpy $5 '' + StrCpy $6 $0 + StrCpy $7 } + + StrCpy $9 '' + StrCpy $R1 $R0 + StrCpy $3 $2 1 + StrCpy $2 $2 '' 1 + StrCmp $3 'E' 0 +3 + StrCpy $9 'E' + goto -4 + + StrCmp${_WORDFUNC_S} $3 '+' +2 + StrCmp${_WORDFUNC_S} $3 '-' 0 error3 + IntOp $2 $2 + 0 + StrCmp${_WORDFUNC_S} $2 0 error2 + StrCmp${_WORDFUNC_S} $0 '' error1 + + StrCmp${_WORDFUNC_S} $2 1 0 two + GetLabelAddress $8 oneback + StrCmp${_WORDFUNC_S} $3 '+' call + StrCpy $7 { + goto call + oneback: + IfErrors 0 +2 + StrCpy $4 $R0 + StrCmp${_WORDFUNC_S} $3 '+' 0 +3 + StrCpy $R0 '$1$0$4' + goto end + StrCpy $R0 '$4$0$1' + goto end + + two: + IntOp $2 $2 - 1 + GetLabelAddress $8 twoback + StrCmp${_WORDFUNC_S} $3 '+' 0 call + StrCpy $7 { + goto call + twoback: + IfErrors 0 tree + StrCmp${_WORDFUNC_S} $2$4 11 0 error2 + StrCmp${_WORDFUNC_S} $3 '+' 0 +3 + StrCpy $R0 '$R0$0$1' + goto end + StrCpy $R0 '$1$0$R0' + goto end + + tree: + StrCpy $7 } + StrCpy $5 $4 + IntOp $2 $2 + 1 + GetLabelAddress $8 treeback + StrCmp${_WORDFUNC_S} $3 '+' call + StrCpy $7 { + goto call + treeback: + IfErrors 0 +3 + StrCpy $4 '' + StrCpy $6 '' + StrCmp${_WORDFUNC_S} $3 '+' 0 +3 + StrCpy $R0 '$5$0$1$6$4' + goto end + StrCpy $R0 '$4$6$1$0$5' + goto end + + call: + Push '$R0' + Push '$0' + Push 'E$3$2*$7' + Call ${_WORDFUNC_UN}WordFind${_WORDFUNC_S} + Pop $4 + goto $8 + + error3: + StrCpy $R0 3 + goto error + error2: + StrCpy $R0 2 + goto error + error1: + StrCpy $R0 1 + error: + StrCmp $9 'E' +3 + StrCpy $R0 $R1 + goto +2 + SetErrors + + end: + Pop $R1 + Pop $9 + Pop $8 + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 + Exch $R0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro StrFilter + !ifndef ${_WORDFUNC_UN}StrFilter${_WORDFUNC_S} + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !define ${_WORDFUNC_UN}StrFilter${_WORDFUNC_S} `!insertmacro ${_WORDFUNC_UN}StrFilter${_WORDFUNC_S}Call` + + Function ${_WORDFUNC_UN}StrFilter${_WORDFUNC_S} + Exch $2 + Exch + Exch $1 + Exch + Exch 2 + Exch $0 + Exch 2 + Exch 3 + Exch $R0 + Exch 3 + Push $3 + Push $4 + Push $5 + Push $6 + Push $7 + Push $R1 + Push $R2 + Push $R3 + Push $R4 + Push $R5 + Push $R6 + Push $R7 + Push $R8 + ClearErrors + + StrCpy $R2 $0 '' -3 + StrCmp $R2 eng eng + StrCmp $R2 rus rus + eng: + StrCpy $4 65 + StrCpy $5 90 + StrCpy $6 97 + StrCpy $7 122 + goto langend + rus: + StrCpy $4 192 + StrCpy $5 223 + StrCpy $6 224 + StrCpy $7 255 + goto langend + ;... + + langend: + StrCpy $R7 '' + StrCpy $R8 '' + + StrCmp${_WORDFUNC_S} $2 '' 0 begin + + restart1: + StrCpy $2 '' + StrCpy $3 $0 1 + StrCmp${_WORDFUNC_S} $3 '+' +2 + StrCmp${_WORDFUNC_S} $3 '-' 0 +3 + StrCpy $0 $0 '' 1 + goto +2 + StrCpy $3 '' + + IntOp $0 $0 + 0 + StrCmp${_WORDFUNC_S} $0 0 +5 + StrCpy $R7 $0 1 0 + StrCpy $R8 $0 1 1 + StrCpy $R2 $0 1 2 + StrCmp${_WORDFUNC_S} $R2 '' filter error + + restart2: + StrCmp${_WORDFUNC_S} $3 '' end + StrCpy $R7 '' + StrCpy $R8 '+-' + goto begin + + filter: + StrCmp${_WORDFUNC_S} $R7 '1' +3 + StrCmp${_WORDFUNC_S} $R7 '2' +2 + StrCmp${_WORDFUNC_S} $R7 '3' 0 error + + StrCmp${_WORDFUNC_S} $R8 '' begin + StrCmp${_WORDFUNC_S} $R7$R8 '23' +2 + StrCmp${_WORDFUNC_S} $R7$R8 '32' 0 +3 + StrCpy $R7 -1 + goto begin + StrCmp${_WORDFUNC_S} $R7$R8 '13' +2 + StrCmp${_WORDFUNC_S} $R7$R8 '31' 0 +3 + StrCpy $R7 -2 + goto begin + StrCmp${_WORDFUNC_S} $R7$R8 '12' +2 + StrCmp${_WORDFUNC_S} $R7$R8 '21' 0 error + StrCpy $R7 -3 + + begin: + StrCpy $R6 0 + StrCpy $R1 '' + + loop: + StrCpy $R2 $R0 1 $R6 + StrCmp${_WORDFUNC_S} $R2 '' restartchk + + StrCmp${_WORDFUNC_S} $2 '' +7 + StrCpy $R4 0 + StrCpy $R5 $2 1 $R4 + StrCmp${_WORDFUNC_S} $R5 '' addsymbol + StrCmp${_WORDFUNC_S} $R5 $R2 skipsymbol + IntOp $R4 $R4 + 1 + goto -4 + + StrCmp${_WORDFUNC_S} $1 '' +7 + StrCpy $R4 0 + StrCpy $R5 $1 1 $R4 + StrCmp${_WORDFUNC_S} $R5 '' +4 + StrCmp${_WORDFUNC_S} $R5 $R2 addsymbol + IntOp $R4 $R4 + 1 + goto -4 + + StrCmp${_WORDFUNC_S} $R7 '1' +2 + StrCmp${_WORDFUNC_S} $R7 '-1' 0 +4 + StrCpy $R4 48 + StrCpy $R5 57 + goto loop2 + StrCmp${_WORDFUNC_S} $R8 '+-' 0 +2 + StrCmp${_WORDFUNC_S} $3 '+' 0 +4 + StrCpy $R4 $4 + StrCpy $R5 $5 + goto loop2 + StrCpy $R4 $6 + StrCpy $R5 $7 + + loop2: + IntFmt $R3 '%c' $R4 + StrCmp $R2 $R3 found + StrCmp $R4 $R5 notfound + IntOp $R4 $R4 + 1 + goto loop2 + + found: + StrCmp${_WORDFUNC_S} $R8 '+-' setcase + StrCmp${_WORDFUNC_S} $R7 '3' skipsymbol + StrCmp${_WORDFUNC_S} $R7 '-3' addsymbol + StrCmp${_WORDFUNC_S} $R8 '' addsymbol skipsymbol + + notfound: + StrCmp${_WORDFUNC_S} $R8 '+-' addsymbol + StrCmp${_WORDFUNC_S} $R7 '3' 0 +2 + StrCmp${_WORDFUNC_S} $R5 57 addsymbol +3 + StrCmp${_WORDFUNC_S} $R7 '-3' 0 +5 + StrCmp${_WORDFUNC_S} $R5 57 skipsymbol + StrCpy $R4 48 + StrCpy $R5 57 + goto loop2 + StrCmp${_WORDFUNC_S} $R8 '' skipsymbol addsymbol + + setcase: + StrCpy $R2 $R3 + addsymbol: + StrCpy $R1 $R1$R2 + skipsymbol: + IntOp $R6 $R6 + 1 + goto loop + + error: + SetErrors + StrCpy $R0 '' + goto end + + restartchk: + StrCpy $R0 $R1 + StrCmp${_WORDFUNC_S} $2 '' 0 restart1 + StrCmp${_WORDFUNC_S} $R8 '+-' 0 restart2 + + end: + Pop $R8 + Pop $R7 + Pop $R6 + Pop $R5 + Pop $R4 + Pop $R3 + Pop $R2 + Pop $R1 + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 + Exch $R0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro VersionCompare + !ifndef ${_WORDFUNC_UN}VersionCompare + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !define ${_WORDFUNC_UN}VersionCompare `!insertmacro ${_WORDFUNC_UN}VersionCompareCall` + + Function ${_WORDFUNC_UN}VersionCompare + Exch $1 + Exch + Exch $0 + Exch + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + Push $7 + + begin: + StrCpy $2 -1 + IntOp $2 $2 + 1 + StrCpy $3 $0 1 $2 + StrCmp $3 '' +2 + StrCmp $3 '.' 0 -3 + StrCpy $4 $0 $2 + IntOp $2 $2 + 1 + StrCpy $0 $0 '' $2 + + StrCpy $2 -1 + IntOp $2 $2 + 1 + StrCpy $3 $1 1 $2 + StrCmp $3 '' +2 + StrCmp $3 '.' 0 -3 + StrCpy $5 $1 $2 + IntOp $2 $2 + 1 + StrCpy $1 $1 '' $2 + + StrCmp $4$5 '' equal + + StrCpy $6 -1 + IntOp $6 $6 + 1 + StrCpy $3 $4 1 $6 + StrCmp $3 '0' -2 + StrCmp $3 '' 0 +2 + StrCpy $4 0 + + StrCpy $7 -1 + IntOp $7 $7 + 1 + StrCpy $3 $5 1 $7 + StrCmp $3 '0' -2 + StrCmp $3 '' 0 +2 + StrCpy $5 0 + + StrCmp $4 0 0 +2 + StrCmp $5 0 begin newer2 + StrCmp $5 0 newer1 + IntCmp $6 $7 0 newer1 newer2 + + StrCpy $4 '1$4' + StrCpy $5 '1$5' + IntCmp $4 $5 begin newer2 newer1 + + equal: + StrCpy $0 0 + goto end + newer1: + StrCpy $0 1 + goto end + newer2: + StrCpy $0 2 + + end: + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro VersionConvert + !ifndef ${_WORDFUNC_UN}VersionConvert + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !define ${_WORDFUNC_UN}VersionConvert `!insertmacro ${_WORDFUNC_UN}VersionConvertCall` + + Function ${_WORDFUNC_UN}VersionConvert + Exch $1 + Exch + Exch $0 + Exch + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + Push $7 + + StrCmp $1 '' 0 +2 + StrCpy $1 'abcdefghijklmnopqrstuvwxyz' + StrCpy $1 $1 99 + + StrCpy $2 0 + StrCpy $7 'dot' + goto loop + + preloop: + IntOp $2 $2 + 1 + + loop: + StrCpy $3 $0 1 $2 + StrCmp $3 '' endcheck + StrCmp $3 '.' dot + StrCmp $3 '0' digit + IntCmp $3 '0' letter letter digit + + dot: + StrCmp $7 'dot' replacespecial + StrCpy $7 'dot' + goto preloop + + digit: + StrCmp $7 'letter' insertdot + StrCpy $7 'digit' + goto preloop + + letter: + StrCpy $5 0 + StrCpy $4 $1 1 $5 + IntOp $5 $5 + 1 + StrCmp $4 '' replacespecial + StrCmp $4 $3 0 -3 + IntCmp $5 9 0 0 +2 + StrCpy $5 '0$5' + + StrCmp $7 'letter' +2 + StrCmp $7 'dot' 0 +3 + StrCpy $6 '' + goto +2 + StrCpy $6 '.' + + StrCpy $4 $0 $2 + IntOp $2 $2 + 1 + StrCpy $0 $0 '' $2 + StrCpy $0 '$4$6$5$0' + StrLen $4 '$6$5' + IntOp $2 $2 + $4 + IntOp $2 $2 - 1 + StrCpy $7 'letter' + goto loop + + replacespecial: + StrCmp $7 'dot' 0 +3 + StrCpy $6 '' + goto +2 + StrCpy $6 '.' + + StrCpy $4 $0 $2 + IntOp $2 $2 + 1 + StrCpy $0 $0 '' $2 + StrCpy $0 '$4$6$0' + StrLen $4 $6 + IntOp $2 $2 + $4 + IntOp $2 $2 - 1 + StrCpy $7 'dot' + goto loop + + insertdot: + StrCpy $4 $0 $2 + StrCpy $0 $0 '' $2 + StrCpy $0 '$4.$0' + StrCpy $7 'dot' + goto preloop + + endcheck: + StrCpy $4 $0 1 -1 + StrCmp $4 '.' 0 end + StrCpy $0 $0 -1 + goto -3 + + end: + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Exch $0 + FunctionEnd + + !verbose pop + !endif +!macroend + + +# Uninstall. Case insensitive. # + +!macro un.WordFindCall _STRING _DELIMITER _OPTION _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER}` + Push `${_OPTION}` + Call un.WordFind + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.WordFind2XCall _STRING _DELIMITER1 _DELIMITER2 _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER1}` + Push `${_DELIMITER2}` + Push `${_NUMBER}` + Call un.WordFind2X + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.WordFind3XCall _STRING _DELIMITER1 _CENTER _DELIMITER2 _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER1}` + Push `${_CENTER}` + Push `${_DELIMITER2}` + Push `${_NUMBER}` + Call un.WordFind3X + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.WordReplaceCall _STRING _WORD1 _WORD2 _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_WORD1}` + Push `${_WORD2}` + Push `${_NUMBER}` + Call un.WordReplace + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.WordAddCall _STRING1 _DELIMITER _STRING2 _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING1}` + Push `${_DELIMITER}` + Push `${_STRING2}` + Call un.WordAdd + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.WordInsertCall _STRING _DELIMITER _WORD _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER}` + Push `${_WORD}` + Push `${_NUMBER}` + Call un.WordInsert + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.StrFilterCall _STRING _FILTER _INCLUDE _EXCLUDE _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_FILTER}` + Push `${_INCLUDE}` + Push `${_EXCLUDE}` + Call un.StrFilter + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.VersionCompareCall _VER1 _VER2 _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_VER1}` + Push `${_VER2}` + Call un.VersionCompare + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.VersionConvertCall _VERSION _CHARLIST _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_VERSION}` + Push `${_CHARLIST}` + Call un.VersionConvert + Pop ${_RESULT} + !verbose pop +!macroend + + +!macro un.WordFind + !ifndef un.WordFind + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + + !insertmacro WordFind + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.WordFind2X + !ifndef un.WordFind2X + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + + !insertmacro WordFind2X + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.WordFind3X + !ifndef un.WordFind3X + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + + !insertmacro WordFind3X + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.WordReplace + !ifndef un.WordReplace + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + + !insertmacro WordReplace + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.WordAdd + !ifndef un.WordAdd + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + + !insertmacro WordAdd + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.WordInsert + !ifndef un.WordInsert + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + + !insertmacro WordInsert + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.StrFilter + !ifndef un.StrFilter + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + + !insertmacro StrFilter + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.VersionCompare + !ifndef un.VersionCompare + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + + !insertmacro VersionCompare + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !verbose pop + !endif +!macroend + +!macro un.VersionConvert + !ifndef un.VersionConvert + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + + !insertmacro VersionConvert + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !verbose pop + !endif +!macroend + + +# Install. Case sensitive. # + +!macro WordFindSCall _STRING _DELIMITER _OPTION _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER}` + Push `${_OPTION}` + Call WordFindS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro WordFind2XSCall _STRING _DELIMITER1 _DELIMITER2 _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER1}` + Push `${_DELIMITER2}` + Push `${_NUMBER}` + Call WordFind2XS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro WordFind3XSCall _STRING _DELIMITER1 _CENTER _DELIMITER2 _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER1}` + Push `${_CENTER}` + Push `${_DELIMITER2}` + Push `${_NUMBER}` + Call WordFind3XS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro WordReplaceSCall _STRING _WORD1 _WORD2 _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_WORD1}` + Push `${_WORD2}` + Push `${_NUMBER}` + Call WordReplaceS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro WordAddSCall _STRING1 _DELIMITER _STRING2 _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING1}` + Push `${_DELIMITER}` + Push `${_STRING2}` + Call WordAddS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro WordInsertSCall _STRING _DELIMITER _WORD _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER}` + Push `${_WORD}` + Push `${_NUMBER}` + Call WordInsertS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro StrFilterSCall _STRING _FILTER _INCLUDE _EXCLUDE _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_FILTER}` + Push `${_INCLUDE}` + Push `${_EXCLUDE}` + Call StrFilterS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro WordFindS + !ifndef WordFindS + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_S + !define _WORDFUNC_S `S` + + !insertmacro WordFind + + !undef _WORDFUNC_S + !define _WORDFUNC_S + !verbose pop + !endif +!macroend + +!macro WordFind2XS + !ifndef WordFind2XS + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_S + !define _WORDFUNC_S `S` + + !insertmacro WordFind2X + + !undef _WORDFUNC_S + !define _WORDFUNC_S + !verbose pop + !endif +!macroend + +!macro WordFind3XS + !ifndef WordFind3XS + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_S + !define _WORDFUNC_S `S` + + !insertmacro WordFind3X + + !undef _WORDFUNC_S + !define _WORDFUNC_S + !verbose pop + !endif +!macroend + +!macro WordReplaceS + !ifndef WordReplaceS + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_S + !define _WORDFUNC_S `S` + + !insertmacro WordReplace + + !undef _WORDFUNC_S + !define _WORDFUNC_S + !verbose pop + !endif +!macroend + +!macro WordAddS + !ifndef WordAddS + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_S + !define _WORDFUNC_S `S` + + !insertmacro WordAdd + + !undef _WORDFUNC_S + !define _WORDFUNC_S + !verbose pop + !endif +!macroend + +!macro WordInsertS + !ifndef WordInsertS + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_S + !define _WORDFUNC_S `S` + + !insertmacro WordInsert + + !undef _WORDFUNC_S + !define _WORDFUNC_S + !verbose pop + !endif +!macroend + +!macro StrFilterS + !ifndef StrFilterS + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_S + !define _WORDFUNC_S `S` + + !insertmacro StrFilter + + !undef _WORDFUNC_S + !define _WORDFUNC_S + !verbose pop + !endif +!macroend + + +# Uninstall. Case sensitive. # + +!macro un.WordFindSCall _STRING _DELIMITER _OPTION _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER}` + Push `${_OPTION}` + Call un.WordFindS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.WordFind2XSCall _STRING _DELIMITER1 _DELIMITER2 _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER1}` + Push `${_DELIMITER2}` + Push `${_NUMBER}` + Call un.WordFind2XS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.WordFind3XSCall _STRING _DELIMITER1 _CENTER _DELIMITER2 _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER1}` + Push `${_CENTER}` + Push `${_DELIMITER2}` + Push `${_NUMBER}` + Call un.WordFind3XS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.WordReplaceSCall _STRING _WORD1 _WORD2 _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_WORD1}` + Push `${_WORD2}` + Push `${_NUMBER}` + Call un.WordReplaceS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.WordAddSCall _STRING1 _DELIMITER _STRING2 _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING1}` + Push `${_DELIMITER}` + Push `${_STRING2}` + Call un.WordAddS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.WordInsertSCall _STRING _DELIMITER _WORD _NUMBER _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_DELIMITER}` + Push `${_WORD}` + Push `${_NUMBER}` + Call un.WordInsertS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.StrFilterSCall _STRING _FILTER _INCLUDE _EXCLUDE _RESULT + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + Push `${_STRING}` + Push `${_FILTER}` + Push `${_INCLUDE}` + Push `${_EXCLUDE}` + Call un.StrFilterS + Pop ${_RESULT} + !verbose pop +!macroend + +!macro un.WordFindS + !ifndef un.WordFindS + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_S + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + !define _WORDFUNC_S `S` + + !insertmacro WordFind + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !undef _WORDFUNC_S + !define _WORDFUNC_S + !verbose pop + !endif +!macroend + +!macro un.WordFind2XS + !ifndef un.WordFind2XS + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + !undef _WORDFUNC_S + !define _WORDFUNC_S `S` + + !insertmacro WordFind2X + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !undef _WORDFUNC_S + !define _WORDFUNC_S + !verbose pop + !endif +!macroend + +!macro un.WordFind3XS + !ifndef un.WordFind3XS + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + !undef _WORDFUNC_S + !define _WORDFUNC_S `S` + + !insertmacro WordFind3X + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !undef _WORDFUNC_S + !define _WORDFUNC_S + !verbose pop + !endif +!macroend + +!macro un.WordReplaceS + !ifndef un.WordReplaceS + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + !undef _WORDFUNC_S + !define _WORDFUNC_S `S` + + !insertmacro WordReplace + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !undef _WORDFUNC_S + !define _WORDFUNC_S + !verbose pop + !endif +!macroend + +!macro un.WordAddS + !ifndef un.WordAddS + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + !undef _WORDFUNC_S + !define _WORDFUNC_S `S` + + !insertmacro WordAdd + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !undef _WORDFUNC_S + !define _WORDFUNC_S + !verbose pop + !endif +!macroend + +!macro un.WordInsertS + !ifndef un.WordInsertS + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + !undef _WORDFUNC_S + !define _WORDFUNC_S `S` + + !insertmacro WordInsert + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !undef _WORDFUNC_S + !define _WORDFUNC_S + !verbose pop + !endif +!macroend + +!macro un.StrFilterS + !ifndef un.StrFilterS + !verbose push + !verbose ${_WORDFUNC_VERBOSE} + !undef _WORDFUNC_UN + !define _WORDFUNC_UN `un.` + !undef _WORDFUNC_S + !define _WORDFUNC_S `S` + + !insertmacro StrFilter + + !undef _WORDFUNC_UN + !define _WORDFUNC_UN + !undef _WORDFUNC_S + !define _WORDFUNC_S + !verbose pop + !endif +!macroend + +!endif diff --git a/companion/targets/windows/companion.nsi.in b/companion/targets/windows/companion.nsi.in index 23c3d19a930..2a9b1ee5b2b 100644 --- a/companion/targets/windows/companion.nsi.in +++ b/companion/targets/windows/companion.nsi.in @@ -7,8 +7,10 @@ !include "MUI2.nsh" !include "nsDialogs.nsh" + !include "LogicLib.nsh" !include "@NSIS_TARGETS_DIR@\FileAssociation.nsh" - + !include "@NSIS_TARGETS_DIR@\FileFunc.nsh" + !include "@NSIS_TARGETS_DIR@\WordFunc.nsh" ;-------------------------------- ;General @@ -23,6 +25,7 @@ InstallDirRegKey HKCU "Software\@PROJECT_NAME@\Companion @VERSION_FAMILY@" "" ;Compressor options + ;SetCompress off SetCompressor /FINAL /SOLID lzma SetCompressorDictSize 64 @@ -102,7 +105,75 @@ ;-------------------------------- ;Installer Sections -Section "@PROJECT_NAME@ Companion @VERSION_FAMILY@" SecDummy +; Visual C++ Redistributable (x64) is a required dependency +; + +!macro GetInstalledVCVersionCall _RESULT + Call GetInstalledVCVersion + Pop ${_RESULT} +!macroend + +!macro GetInstalledVCVersion + !ifndef GetInstalledVCVersion + !define GetInstalledVCVersion `!insertmacro GetInstalledVCVersionCall` + + Function GetInstalledVCVersion + ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Version" + StrCpy $R1 "$R0" 1 # get first character + ${If} $R1 == "v" + StrCpy $R1 "$R0" "" 1 # strip off v prefix + ${EndIf} + + Push $R1 + FunctionEnd + !endif +!macroend + +!define VCREDISTNAME "Microsoft Visual C++ 2015-2022 Redistributable" +!define VCREDISTFILE "@NSIS_DISTRO@\bin\@NSIS_MSVC_REDIST_EXE@" +!define VCREDISTEXE "@NSIS_MSVC_REDIST_EXE@" +Var VCRedistExeVers +Var VCInstVers + +!insertmacro GetFileVersion +!insertmacro VersionCompare +!insertmacro GetInstalledVCVersion + +Section "${VCREDISTNAME}" SecMSVC + Push $0 + Push $1 + SetOutPath "$TEMP" + File "${VCREDISTFILE}" + ${GetFileVersion} "$TEMP\${VCREDISTEXE}" $VCRedistExeVers + ${GetInstalledVCVersion} $VCInstVers + ${VersionCompare} "$VCInstVers" "$VCRedistExeVers" $R0 + DetailPrint "VC++ Installed: $VCInstVers Redist: $VCRedistExeVers Result: $R0" + ${If} $R0 == "2" + DetailPrint "Installing ${VCREDISTNAME}..." + ExecWait "$TEMP\${VCREDISTEXE} /install /passive /norestart" + ;IfErrors InstallError ContinueInstall ; vc_redist exit code is unreliable + ${GetInstalledVCVersion} $VCInstVers + ${VersionCompare} "$VCInstVers" "$VCRedistExeVers" $R0 + ${If} $R0 == "0" + Goto ContinueInstall + ${EndIf} + + MessageBox MB_ICONSTOP "\ + There was an unexpected error installing$\r$\n\ + ${VCREDISTNAME}.$\r$\n\ + The installation of @PROJECT_NAME@ cannot continue." + Abort + ${EndIf} + + ContinueInstall: + Delete "$TEMP\${VCREDISTEXE}" + SetOutPath "$INSTDIR" ; Restore original output path + Pop $1 + Pop $0 + +SectionEnd + +Section "@PROJECT_NAME@ Companion @VERSION_FAMILY@" SecCpn SetOutPath "$INSTDIR" @@ -147,8 +218,11 @@ SectionEnd ;Descriptions ;Language strings - LangString DESC_SecDummy ${LANG_ENGLISH} "Models and settings editor for @PROJECT_NAME@" - LangString DESC_SecDummy ${LANG_FRENCH} "Editeur de r�glages et mod�les pour @PROJECT_NAME@" + LangString DESC_SecCpn ${LANG_ENGLISH} "Models and settings editor for @PROJECT_NAME@" + LangString DESC_SecCpn ${LANG_FRENCH} "Editeur de r glages et mod les pour @PROJECT_NAME@" + LangString DESC_SecMSVC ${LANG_ENGLISH} "Install or update runtime library support files necessary for Companion" + LangString DESC_SecMSVC ${LANG_FRENCH} "Fichiers de support de bibliothèque d'exécution nécessaires pour Companion" + LangString SML_SubTitle ${LANG_ENGLISH} "Choose a location for the Start Menu shortcuts" LangString SML_SubTitle ${LANG_FRENCH} "Choisissez un emplacement pour les raccourcis de l'application" LangString SML_MainLabel ${LANG_ENGLISH} "Create start menu shortcuts for:" @@ -160,12 +234,17 @@ SectionEnd ;Assign language strings to sections !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN - !insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy) + !insertmacro MUI_DESCRIPTION_TEXT ${SecCpn} $(DESC_SecCpn) + !insertmacro MUI_DESCRIPTION_TEXT ${SecMSVC} $(DESC_SecMSVC) !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- ;Uninstaller Section +Section "un.${VCREDISTNAME}" + +SectionEnd + Section "un.@PROJECT_NAME@ Companion @VERSION_FAMILY@" SectionIn RO ; Not deselectable