Replace 'devel' with 'master'
[msysgit.git] / share / InnoSetup / ISPPBuiltins.iss
blobd8d0aa8ca7bb8efbdfa00f2d906fb546c5790fc2
1 ; BEGIN ISPPBUILTINS.ISS
2 //
3 // Inno Setup Preprocessor 5
4 //
5 // Copyright (C) 2001-2004 Alex Yackimoff. All Rights Reserved.
6 // Portions by Martijn Laan.
7 // http://ispp.sourceforge.net
8 //
9 // Inno Setup (C) 1997-2009 Jordan Russell. All Rights Reserved.
10 // Portions by Martijn Laan.
12 // $Id: ISPPBuiltins.iss,v 1.3 2010/12/29 15:20:26 mlaan Exp $
14 #if defined(ISPP_INVOKED) && !defined(_BUILTINS_ISS_)
16 #if PREPROCVER < 0x01000000
17 # error Inno Setup Preprocessor version is outdated
18 #endif
20 #define _BUILTINS_ISS_
22 // ===========================================================================
24 // Default states for options.
26 //#pragma parseroption -b+ ; short circuit boolean evaluation: on
27 //#pragma parseroption -m- ; short circuit multiplication evaluation (0 * A will not eval A): off
28 //#pragma parseroption -p+ ; string literals without escape sequences: on
29 //#pragma parseroption -u- ; allow undeclared identifiers: off
30 //#pragma option -c+ ; pass script to the compiler: on
31 //#pragma option -e- ; emit empty lines to translation: off
32 //#pragma option -v- ; verbose mode: off
34 // ---------------------------------------------------------------------------
36 // Verbose levels:
37 // 0 - #include and #file acknowledgements
38 // 1 - information about any temp files created by #file
39 // 2 - #insert and #append acknowledgements
40 // 3 - reserved
41 // 4 - #dim, #define and #undef acknowledgements
42 // 5 - reserved
43 // 6 - conditional inclusion acknowledgements
44 // 7 - reserved
45 // 8 - show strings emitted with #emit directive
46 // 9 - macro and functions successfull call acknowledgements
47 //10 - Local macro array allocation acknowledgements
49 //#pragma verboselevel 0
51 #ifndef __POPT_P__
52 # define private CStrings
53 # pragma parseroption -p+
54 #endif
56 #pragma spansymbol "\"
58 #define True 1
59 #define False 0
60 #define Yes True
61 #define No False
63 #define MaxInt 0x7FFFFFFFL
64 #define MinInt 0x80000000L
66 #define NULL
67 #define void
69 // TypeOf constants
71 #define TYPE_ERROR 0
72 #define TYPE_NULL 1
73 #define TYPE_INTEGER 2
74 #define TYPE_STRING 3
75 #define TYPE_MACRO 4
76 #define TYPE_FUNC 5
77 #define TYPE_ARRAY 6
79 // Helper macro to find out the type of an array element or expression. TypeOf
80 // standard function only allows identifier as its parameter. Use this macro
81 // to convert an expression to identifier.
83 #define TypeOf2(any Expr) TypeOf(Expr)
85 // ReadReg constants
87 #define HKEY_CLASSES_ROOT 0x80000000UL
88 #define HKEY_CURRENT_USER 0x80000001UL
89 #define HKEY_LOCAL_MACHINE 0x80000002UL
90 #define HKEY_USERS 0x80000003UL
92 #define HKCR HKEY_CLASSES_ROOT
93 #define HKCU HKEY_CURRENT_USER
94 #define HKLM HKEY_LOCAL_MACHINE
95 #define HKU HKEY_USERS
97 // Exec constants
99 #define SW_HIDE 0
100 #define SW_SHOWNORMAL 1
101 #define SW_NORMAL 1
102 #define SW_SHOWMINIMIZED 2
103 #define SW_SHOWMAXIMIZED 3
104 #define SW_MAXIMIZE 3
105 #define SW_SHOWNOACTIVATE 4
106 #define SW_SHOW 5
107 #define SW_MINIMIZE 6
108 #define SW_SHOWMINNOACTIVE 7
109 #define SW_SHOWNA 8
110 #define SW_RESTORE 9
111 #define SW_SHOWDEFAULT 10
112 #define SW_MAX 10
114 // Find constants
116 #define FIND_MATCH 0x00
117 #define FIND_BEGINS 0x01
118 #define FIND_ENDS 0x02
119 #define FIND_CONTAINS 0x03
120 #define FIND_CASESENSITIVE 0x04
121 #define FIND_SENSITIVE FIND_CASESENSITIVE
122 #define FIND_AND 0x00
123 #define FIND_OR 0x08
124 #define FIND_NOT 0x10
125 #define FIND_TRIM 0x20
127 // FindFirst constants
129 #define faReadOnly 0x00000001
130 #define faHidden 0x00000002
131 #define faSysFile 0x00000004
132 #define faVolumeID 0x00000008
133 #define faDirectory 0x00000010
134 #define faArchive 0x00000020
135 #define faSymLink 0x00000040
136 #define faAnyFile 0x0000003F
138 // GetStringFileInfo standard names
140 #define COMPANY_NAME "CompanyName"
141 #define FILE_DESCRIPTION "FileDescription"
142 #define FILE_VERSION "FileVersion"
143 #define INTERNAL_NAME "InternalName"
144 #define LEGAL_COPYRIGHT "LegalCopyright"
145 #define ORIGINAL_FILENAME "OriginalFilename"
146 #define PRODUCT_NAME "ProductName"
147 #define PRODUCT_VERSION "ProductVersion"
149 // GetStringFileInfo helpers
151 #define GetFileCompany(str FileName) GetStringFileInfo(FileName, COMPANY_NAME)
152 #define GetFileCopyright(str FileName) GetStringFileInfo(FileName, LEGAL_COPYRIGHT)
153 #define GetFileDescription(str FileName) GetStringFileInfo(FileName, FILE_DESCRIPTION)
154 #define GetFileProductVersion(str FileName) GetStringFileInfo(FileName, PRODUCT_VERSION)
155 #define GetFileVersionString(str FileName) GetStringFileInfo(FileName, FILE_VERSION)
157 // ParseVersion
159 // Macro internally calls GetFileVersion function and parses string returned
160 // by that function (in form "0.0.0.0"). All four version elements are stored
161 // in by-reference parameters Major, Minor, Rev, and Build. Macro returns
162 // string returned by GetFileVersion.
164 #define DeleteToFirstPeriod(str *S) \
165 Local[1] = Copy(S, 1, (Local[0] = Pos(".", S)) - 1), \
166 S = Copy(S, Local[0] + 1), \
167 Local[1]
169 #define ParseVersion(str FileName, *Major, *Minor, *Rev, *Build) \
170 Local[1] = Local[0] = GetFileVersion(FileName), \
171 Local[1] == "" ? "" : ( \
172 Major = Int(DeleteToFirstPeriod(Local[1])), \
173 Minor = Int(DeleteToFirstPeriod(Local[1])), \
174 Rev = Int(DeleteToFirstPeriod(Local[1])), \
175 Build = Int(Local[1]), \
176 Local[0])
178 // EncodeVer
180 // Encodes given four version elements to a 32 bit integer number (8 bits for
181 // each element, i.e. elements must be within 0...255 range).
183 #define EncodeVer(int Major, int Minor, int Revision = 0, int Build = -1) \
184 Major << 24 | (Minor & 0xFF) << 16 | (Revision & 0xFF) << 8 | (Build >= 0 ? Build & 0xFF : 0)
186 // DecodeVer
188 // Decodes given 32 bit integer encoded version to its string representation,
189 // Digits parameter indicates how many elements to show (if the fourth element
190 // is 0, it won't be shown anyway).
192 #define DecodeVer(int Ver, int Digits = 3) \
193 Str(Ver >> 0x18 & 0xFF) + (Digits > 1 ? "." : "") + \
194 (Digits > 1 ? \
195 Str(Ver >> 0x10 & 0xFF) + (Digits > 2 ? "." : "") : "") + \
196 (Digits > 2 ? \
197 Str(Ver >> 0x08 & 0xFF) + (Digits > 3 && (Local = Ver & 0xFF) ? "." : "") : "") + \
198 (Digits > 3 && Local ? \
199 Str(Ver & 0xFF) : "")
201 // FindSection
203 // Returns index of the line following the header of the section. This macro
204 // is intended to be used with #insert directive.
206 #define FindSection(str Section = "Files") \
207 Find(0, "[" + Section + "]", FIND_MATCH | FIND_TRIM) + 1
209 // FindSectionEnd
211 // Returns index of the line following last entry of the section. This macro
212 // is intended to be used with #insert directive.
214 #if VER >= 0x03000000
215 # define FindNextSection(int Line) \
216 Find(Line, "[", FIND_BEGINS | FIND_TRIM, "]", FIND_ENDS | FIND_AND)
217 # define FindSectionEnd(str Section = "Files") \
218 FindNextSection(FindSection(Section))
219 #else
220 # define FindSectionEnd(str Section = "Files") \
221 FindSection(Section) + EntryCount(Section)
222 #endif
224 // FindCode
226 // Returns index of the line (of translation) following either [Code] section
227 // header, or "program" keyword, if any.
229 #define FindCode() \
230 Local[1] = FindSection("Code"), \
231 Local[0] = Find(Local[1] - 1, "program", FIND_BEGINS, ";", FIND_ENDS | FIND_AND), \
232 (Local[0] < 0 ? Local[1] : Local[0] + 1)
234 // ExtractFilePath
236 // Returns directory portion of the given filename without backslash (unless
237 // it is a root directory). If PathName doesn't contain directory portion,
238 // the result is an empty string.
240 #define ExtractFilePath(str PathName) \
241 (Local[0] = \
242 !(Local[1] = RPos("\", PathName)) ? \
243 "" : \
244 Copy(PathName, 1, Local[1] - 1)), \
245 Local[0] + \
246 ((Local[2] = Len(Local[0])) == 2 && Copy(Local[0], Local[2]) == ":" ? \
247 "\" : \
249 #define ExtractFileDir(str PathName) \
250 RemoveBackslash(ExtractFilePath(PathName))
252 #define ExtractFileExt(str PathName) \
253 Local[0] = RPos(".", PathName), \
254 Copy(PathName, Local[0] + 1)
256 // ExtractFileName
258 // Returns name portion of the given filename. If PathName ends with
259 // a backslash, the result is an empty string.
261 #define ExtractFileName(str PathName) \
262 !(Local[0] = RPos("\", PathName)) ? \
263 PathName : \
264 Copy(PathName, Local[0] + 1)
266 // ChangeFileExt
268 // Changes extension in FileName with NewExt. NewExt must not contain
269 // period.
271 #define ChangeFileExt(str FileName, str NewExt) \
272 !(Local[0] = RPos(".", FileName)) ? \
273 FileName + "." + NewExt : \
274 Copy(FileName, 1, Local[0]) + NewExt
276 // AddBackslash
278 // Adds a backslash to the string, if it's not already there.
280 #define AddBackslash(str S) \
281 Copy(S, Len(S)) == "\" ? S : S + "\"
283 // RemoveBackslash
285 // Removes trailing backslash from the string unless the string points to
286 // a root directory.
288 #define RemoveBackslash(str S) \
289 Local[0] = Len(S), \
290 Local[0] > 0 ? \
291 Copy(S, Local[0]) == "\" ? \
292 (Local[0] == 3 && Copy(S, 2, 1) == ":" ? \
293 S : \
294 Copy(S, 1, Local[0] - 1)) : \
295 S : \
298 // Delete
300 // Deletes specified number of characters beginning with Index from S. S is
301 // passed by reference (therefore is modified). Acts like Delete function in
302 // Delphi (from System unit).
304 #define Delete(str *S, int Index, int Count = MaxInt) \
305 S = Copy(S, 1, Index - 1) + Copy(S, Index + Count)
307 // Insert
309 // Inserts specified Substr at Index'th character into S. S is passed by
310 // reference (therefore is modified).
312 #define Insert(str *S, int Index, str Substr) \
313 Index > Len(S) + 1 ? \
314 S : \
315 S = Copy(S, 1, Index - 1) + SubStr + Copy(S, Index)
317 // YesNo, IsDirSet
319 // Returns nonzero value if given string is "yes", "true" or "1". Intended to
320 // be used with SetupSetting function. This macro replaces YesNo function
321 // available in previous releases.
323 #define YesNo(str S) \
324 (S = LowerCase(S)) == "yes" || S == "true" || S == "1"
326 #define IsDirSet(str SetupDirective) \
327 YesNo(SetupSetting(SetupDirective))
330 #define Power(int X, int P = 2) \
331 !P ? 1 : X * Power(X, P - 1)
333 #define Min(int A, int B, int C = MaxInt) \
334 A < B ? A < C ? Int(A) : Int(C) : Int(B)
336 #define Max(int A, int B, int C = MinInt) \
337 A > B ? A > C ? Int(A) : Int(C) : Int(B)
340 #ifdef CStrings
341 # pragma parseroption -p-
342 #endif
343 #endif
344 ; END ISPPBUILTINS.ISS