source: josm/trunk/windows/plugins/stdutils/Include/StdUtils.nsh@ 15250

Last change on this file since 15250 was 13470, checked in by Don-vip, 7 years ago

re-add stdutils nsis plugin binaries from https://github.com/lordmulder/stdutils/releases/download/1.12/StdUtils.2017-12-12.zip (binaries no longer in git)

File size: 15.4 KB
Line 
1#################################################################################
2# StdUtils plug-in for NSIS
3# Copyright (C) 2004-2017 LoRd_MuldeR <MuldeR2@GMX.de>
4#
5# This library is free software; you can redistribute it and/or
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
9#
10# This library is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public
16# License along with this library; if not, write to the Free Software
17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18#
19# http://www.gnu.org/licenses/lgpl-2.1.txt
20#################################################################################
21
22# DEVELOPER NOTES:
23# - Please see "https://github.com/lordmulder/stdutils/" for news and updates!
24# - Please see "Docs\StdUtils\StdUtils.html" for detailed function descriptions!
25# - Please see "Examples\StdUtils\StdUtilsTest.nsi" for usage examples!
26
27#################################################################################
28# FUNCTION DECLARTIONS
29#################################################################################
30
31!ifndef ___STDUTILS__NSH___
32!define ___STDUTILS__NSH___
33
34!define StdUtils.Time '!insertmacro _StdUtils_Time' #time(), as in C standard library
35!define StdUtils.GetMinutes '!insertmacro _StdUtils_GetMinutes' #GetSystemTimeAsFileTime(), returns the number of minutes
36!define StdUtils.GetHours '!insertmacro _StdUtils_GetHours' #GetSystemTimeAsFileTime(), returns the number of hours
37!define StdUtils.GetDays '!insertmacro _StdUtils_GetDays' #GetSystemTimeAsFileTime(), returns the number of days
38!define StdUtils.Rand '!insertmacro _StdUtils_Rand' #rand(), as in C standard library
39!define StdUtils.RandMax '!insertmacro _StdUtils_RandMax' #rand(), as in C standard library, with maximum value
40!define StdUtils.RandMinMax '!insertmacro _StdUtils_RandMinMax' #rand(), as in C standard library, with minimum/maximum value
41!define StdUtils.RandList '!insertmacro _StdUtils_RandList' #rand(), as in C standard library, with list support
42!define StdUtils.FormatStr '!insertmacro _StdUtils_FormatStr' #sprintf(), as in C standard library, one '%d' placeholder
43!define StdUtils.FormatStr2 '!insertmacro _StdUtils_FormatStr2' #sprintf(), as in C standard library, two '%d' placeholders
44!define StdUtils.FormatStr3 '!insertmacro _StdUtils_FormatStr3' #sprintf(), as in C standard library, three '%d' placeholders
45!define StdUtils.ScanStr '!insertmacro _StdUtils_ScanStr' #sscanf(), as in C standard library, one '%d' placeholder
46!define StdUtils.ScanStr2 '!insertmacro _StdUtils_ScanStr2' #sscanf(), as in C standard library, two '%d' placeholders
47!define StdUtils.ScanStr3 '!insertmacro _StdUtils_ScanStr3' #sscanf(), as in C standard library, three '%d' placeholders
48!define StdUtils.TrimStr '!insertmacro _StdUtils_TrimStr' #Remove whitspaces from string, left and right
49!define StdUtils.TrimStrLeft '!insertmacro _StdUtils_TrimStrLeft' #Remove whitspaces from string, left side only
50!define StdUtils.TrimStrRight '!insertmacro _StdUtils_TrimStrRight' #Remove whitspaces from string, right side only
51!define StdUtils.RevStr '!insertmacro _StdUtils_RevStr' #Reverse a string, e.g. "reverse me" <-> "em esrever"
52!define StdUtils.ValidFileName '!insertmacro _StdUtils_ValidFileName' #Test whether string is a valid file name - no paths allowed
53!define StdUtils.ValidPathSpec '!insertmacro _StdUtils_ValidPathSpec' #Test whether string is a valid full(!) path specification
54!define StdUtils.SHFileMove '!insertmacro _StdUtils_SHFileMove' #SHFileOperation(), using the FO_MOVE operation
55!define StdUtils.SHFileCopy '!insertmacro _StdUtils_SHFileCopy' #SHFileOperation(), using the FO_COPY operation
56!define StdUtils.AppendToFile '!insertmacro _StdUtils_AppendToFile' #Append contents of an existing file to another file
57!define StdUtils.ExecShellAsUser '!insertmacro _StdUtils_ExecShlUser' #ShellExecute() as NON-elevated user from elevated installer
58!define StdUtils.InvokeShellVerb '!insertmacro _StdUtils_InvkeShlVrb' #Invokes a "shell verb", e.g. for pinning items to the taskbar
59!define StdUtils.ExecShellWaitEx '!insertmacro _StdUtils_ExecShlWaitEx' #ShellExecuteEx(), returns the handle of the new process
60!define StdUtils.WaitForProcEx '!insertmacro _StdUtils_WaitForProcEx' #WaitForSingleObject(), e.g. to wait for a running process
61!define StdUtils.GetParameter '!insertmacro _StdUtils_GetParameter' #Get the value of a specific command-line option
62!define StdUtils.TestParameter '!insertmacro _StdUtils_TestParameter' #Test whether a specific command-line option has been set
63!define StdUtils.ParameterCnt '!insertmacro _StdUtils_ParameterCnt' #Get number of command-line tokens, similar to argc in main()
64!define StdUtils.ParameterStr '!insertmacro _StdUtils_ParameterStr' #Get the n-th command-line token, similar to argv[i] in main()
65!define StdUtils.GetAllParameters '!insertmacro _StdUtils_GetAllParams' #Get complete command-line, but without executable name
66!define StdUtils.GetRealOSVersion '!insertmacro _StdUtils_GetRealOSVer' #Get the *real* Windows version number, even on Windows 8.1+
67!define StdUtils.GetRealOSBuildNo '!insertmacro _StdUtils_GetRealOSBld' #Get the *real* Windows build number, even on Windows 8.1+
68!define StdUtils.GetRealOSName '!insertmacro _StdUtils_GetRealOSStr' #Get the *real* Windows version, as a "friendly" name
69!define StdUtils.GetOSEdition '!insertmacro _StdUtils_GetOSEdition' #Get the Windows edition, i.e. "workstation" or "server"
70!define StdUtils.GetOSReleaseId '!insertmacro _StdUtils_GetOSRelIdNo' #Get the Windows release identifier (on Windows 10)
71!define StdUtils.VerifyOSVersion '!insertmacro _StdUtils_VrfyRealOSVer' #Compare *real* operating system to an expected version number
72!define StdUtils.VerifyOSBuildNo '!insertmacro _StdUtils_VrfyRealOSBld' #Compare *real* operating system to an expected build number
73!define StdUtils.HashText '!insertmacro _StdUtils_HashText' #Compute hash from text string (CRC32, MD5, SHA1/2/3, BLAKE2)
74!define StdUtils.HashFile '!insertmacro _StdUtils_HashFile' #Compute hash from file (CRC32, MD5, SHA1/2/3, BLAKE2)
75!define StdUtils.NormalizePath '!insertmacro _StdUtils_NormalizePath' #Simplifies the path to produce a direct, well-formed path
76!define StdUtils.GetParentPath '!insertmacro _StdUtils_GetParentPath' #Get parent path by removing the last component from the path
77!define StdUtils.SplitPath '!insertmacro _StdUtils_SplitPath' #Split the components of the given path
78!define StdUtils.GetDrivePart '!insertmacro _StdUtils_GetDrivePart' #Get drive component of path
79!define StdUtils.GetDirectoryPart '!insertmacro _StdUtils_GetDirPart' #Get directory component of path
80!define StdUtils.GetFileNamePart '!insertmacro _StdUtils_GetFNamePart' #Get file name component of path
81!define StdUtils.GetExtensionPart '!insertmacro _StdUtils_GetExtnPart' #Get file extension component of path
82!define StdUtils.TimerCreate '!insertmacro _StdUtils_TimerCreate' #Create a new event-timer that will be triggered periodically
83!define StdUtils.TimerDestroy '!insertmacro _StdUtils_TimerDestroy' #Destroy a running timer created with TimerCreate()
84!define StdUtils.GetLibVersion '!insertmacro _StdUtils_GetLibVersion' #Get the current StdUtils library version (for debugging)
85!define StdUtils.SetVerbose '!insertmacro _StdUtils_SetVerbose' #Enable or disable "verbose" mode (for debugging)
86
87
88#################################################################################
89# MACRO DEFINITIONS
90#################################################################################
91
92!macro _StdUtils_Time out
93 StdUtils::Time /NOUNLOAD
94 pop ${out}
95!macroend
96
97!macro _StdUtils_GetMinutes out
98 StdUtils::GetMinutes /NOUNLOAD
99 pop ${out}
100!macroend
101
102!macro _StdUtils_GetHours out
103 StdUtils::GetHours /NOUNLOAD
104 pop ${out}
105!macroend
106
107!macro _StdUtils_GetDays out
108 StdUtils::GetDays /NOUNLOAD
109 pop ${out}
110!macroend
111
112!macro _StdUtils_Rand out
113 StdUtils::Rand /NOUNLOAD
114 pop ${out}
115!macroend
116
117!macro _StdUtils_RandMax out max
118 push ${max}
119 StdUtils::RandMax /NOUNLOAD
120 pop ${out}
121!macroend
122
123!macro _StdUtils_RandMinMax out min max
124 push ${min}
125 push ${max}
126 StdUtils::RandMinMax /NOUNLOAD
127 pop ${out}
128!macroend
129
130!macro _StdUtils_RandList count max
131 push ${max}
132 push ${count}
133 StdUtils::RandList /NOUNLOAD
134!macroend
135
136!macro _StdUtils_FormatStr out format val
137 push '${format}'
138 push ${val}
139 StdUtils::FormatStr /NOUNLOAD
140 pop ${out}
141!macroend
142
143!macro _StdUtils_FormatStr2 out format val1 val2
144 push '${format}'
145 push ${val1}
146 push ${val2}
147 StdUtils::FormatStr2 /NOUNLOAD
148 pop ${out}
149!macroend
150
151!macro _StdUtils_FormatStr3 out format val1 val2 val3
152 push '${format}'
153 push ${val1}
154 push ${val2}
155 push ${val3}
156 StdUtils::FormatStr3 /NOUNLOAD
157 pop ${out}
158!macroend
159
160!macro _StdUtils_ScanStr out format input default
161 push '${format}'
162 push '${input}'
163 push ${default}
164 StdUtils::ScanStr /NOUNLOAD
165 pop ${out}
166!macroend
167
168!macro _StdUtils_ScanStr2 out1 out2 format input default1 default2
169 push '${format}'
170 push '${input}'
171 push ${default1}
172 push ${default2}
173 StdUtils::ScanStr2 /NOUNLOAD
174 pop ${out1}
175 pop ${out2}
176!macroend
177
178!macro _StdUtils_ScanStr3 out1 out2 out3 format input default1 default2 default3
179 push '${format}'
180 push '${input}'
181 push ${default1}
182 push ${default2}
183 push ${default3}
184 StdUtils::ScanStr3 /NOUNLOAD
185 pop ${out1}
186 pop ${out2}
187 pop ${out3}
188!macroend
189
190!macro _StdUtils_TrimStr var
191 push ${var}
192 StdUtils::TrimStr /NOUNLOAD
193 pop ${var}
194!macroend
195
196!macro _StdUtils_TrimStrLeft var
197 push ${var}
198 StdUtils::TrimStrLeft /NOUNLOAD
199 pop ${var}
200!macroend
201
202!macro _StdUtils_TrimStrRight var
203 push ${var}
204 StdUtils::TrimStrRight /NOUNLOAD
205 pop ${var}
206!macroend
207
208!macro _StdUtils_RevStr var
209 push ${var}
210 StdUtils::RevStr /NOUNLOAD
211 pop ${var}
212!macroend
213
214!macro _StdUtils_ValidFileName out test
215 push '${test}'
216 StdUtils::ValidFileName /NOUNLOAD
217 pop ${out}
218!macroend
219
220!macro _StdUtils_ValidPathSpec out test
221 push '${test}'
222 StdUtils::ValidPathSpec /NOUNLOAD
223 pop ${out}
224!macroend
225
226!macro _StdUtils_SHFileMove out from to hwnd
227 push '${from}'
228 push '${to}'
229 push ${hwnd}
230 StdUtils::SHFileMove /NOUNLOAD
231 pop ${out}
232!macroend
233
234!macro _StdUtils_SHFileCopy out from to hwnd
235 push '${from}'
236 push '${to}'
237 push ${hwnd}
238 StdUtils::SHFileCopy /NOUNLOAD
239 pop ${out}
240!macroend
241
242!macro _StdUtils_AppendToFile out from dest offset maxlen
243 push '${from}'
244 push '${dest}'
245 push ${offset}
246 push ${maxlen}
247 StdUtils::AppendToFile /NOUNLOAD
248 pop ${out}
249!macroend
250
251!macro _StdUtils_ExecShlUser out file verb args
252 push '${file}'
253 push '${verb}'
254 push '${args}'
255 StdUtils::ExecShellAsUser /NOUNLOAD
256 pop ${out}
257!macroend
258
259!macro _StdUtils_InvkeShlVrb out path file verb_id
260 push "${path}"
261 push "${file}"
262 push ${verb_id}
263 StdUtils::InvokeShellVerb /NOUNLOAD
264 pop ${out}
265!macroend
266
267!macro _StdUtils_ExecShlWaitEx out_res out_val file verb args
268 push '${file}'
269 push '${verb}'
270 push '${args}'
271 StdUtils::ExecShellWaitEx /NOUNLOAD
272 pop ${out_res}
273 pop ${out_val}
274!macroend
275
276!macro _StdUtils_WaitForProcEx out handle
277 push '${handle}'
278 StdUtils::WaitForProcEx /NOUNLOAD
279 pop ${out}
280!macroend
281
282!macro _StdUtils_GetParameter out name default
283 push '${name}'
284 push '${default}'
285 StdUtils::GetParameter /NOUNLOAD
286 pop ${out}
287!macroend
288
289!macro _StdUtils_TestParameter out name
290 push '${name}'
291 StdUtils::TestParameter /NOUNLOAD
292 pop ${out}
293!macroend
294
295!macro _StdUtils_ParameterCnt out
296 StdUtils::ParameterCnt /NOUNLOAD
297 pop ${out}
298!macroend
299
300!macro _StdUtils_ParameterStr out index
301 push ${index}
302 StdUtils::ParameterStr /NOUNLOAD
303 pop ${out}
304!macroend
305
306!macro _StdUtils_GetAllParams out truncate
307 push '${truncate}'
308 StdUtils::GetAllParameters /NOUNLOAD
309 pop ${out}
310!macroend
311
312!macro _StdUtils_GetRealOSVer out_major out_minor out_spack
313 StdUtils::GetRealOsVersion /NOUNLOAD
314 pop ${out_major}
315 pop ${out_minor}
316 pop ${out_spack}
317!macroend
318
319!macro _StdUtils_GetRealOSBld out
320 StdUtils::GetRealOsBuildNo /NOUNLOAD
321 pop ${out}
322!macroend
323
324!macro _StdUtils_GetRealOSStr out
325 StdUtils::GetRealOsName /NOUNLOAD
326 pop ${out}
327!macroend
328
329!macro _StdUtils_VrfyRealOSVer out major minor spack
330 push '${major}'
331 push '${minor}'
332 push '${spack}'
333 StdUtils::VerifyRealOsVersion /NOUNLOAD
334 pop ${out}
335!macroend
336
337!macro _StdUtils_VrfyRealOSBld out build
338 push '${build}'
339 StdUtils::VerifyRealOsBuildNo /NOUNLOAD
340 pop ${out}
341!macroend
342
343!macro _StdUtils_GetOSEdition out
344 StdUtils::GetOsEdition /NOUNLOAD
345 pop ${out}
346!macroend
347
348
349!macro _StdUtils_GetOSRelIdNo out
350 StdUtils::GetOsReleaseId /NOUNLOAD
351 pop ${out}
352!macroend
353
354!macro _StdUtils_HashText out type text
355 push '${type}'
356 push '${text}'
357 StdUtils::HashText /NOUNLOAD
358 pop ${out}
359!macroend
360
361!macro _StdUtils_HashFile out type file
362 push '${type}'
363 push '${file}'
364 StdUtils::HashFile /NOUNLOAD
365 pop ${out}
366!macroend
367
368!macro _StdUtils_NormalizePath out path
369 push '${path}'
370 StdUtils::NormalizePath /NOUNLOAD
371 pop ${out}
372!macroend
373
374!macro _StdUtils_GetParentPath out path
375 push '${path}'
376 StdUtils::GetParentPath /NOUNLOAD
377 pop ${out}
378!macroend
379
380!macro _StdUtils_SplitPath out_drive out_dir out_fname out_ext path
381 push '${path}'
382 StdUtils::SplitPath /NOUNLOAD
383 pop ${out_drive}
384 pop ${out_dir}
385 pop ${out_fname}
386 pop ${out_ext}
387!macroend
388
389!macro _StdUtils_GetDrivePart out path
390 push '${path}'
391 StdUtils::GetDrivePart /NOUNLOAD
392 pop ${out}
393!macroend
394
395!macro _StdUtils_GetDirPart out path
396 push '${path}'
397 StdUtils::GetDirectoryPart /NOUNLOAD
398 pop ${out}
399!macroend
400
401!macro _StdUtils_GetFNamePart out path
402 push '${path}'
403 StdUtils::GetFileNamePart /NOUNLOAD
404 pop ${out}
405!macroend
406
407!macro _StdUtils_GetExtnPart out path
408 push '${path}'
409 StdUtils::GetExtensionPart /NOUNLOAD
410 pop ${out}
411!macroend
412
413!macro _StdUtils_TimerCreate out callback interval
414 GetFunctionAddress ${out} ${callback}
415 push ${out}
416 push ${interval}
417 StdUtils::TimerCreate /NOUNLOAD
418 pop ${out}
419!macroend
420
421!macro _StdUtils_TimerDestroy out timer_id
422 push ${timer_id}
423 StdUtils::TimerDestroy /NOUNLOAD
424 pop ${out}
425!macroend
426
427!macro _StdUtils_GetLibVersion out_ver out_tst
428 StdUtils::GetLibVersion /NOUNLOAD
429 pop ${out_ver}
430 pop ${out_tst}
431!macroend
432
433!macro _StdUtils_SetVerbose on
434 !if "${on}" != "0"
435 StdUtils::EnableVerboseMode /NOUNLOAD
436 !else
437 StdUtils::DisableVerboseMode /NOUNLOAD
438 !endif
439!macroend
440
441
442#################################################################################
443# MAGIC NUMBERS
444#################################################################################
445
446!define StdUtils.Const.ShellVerb.PinToTaskbar 0
447!define StdUtils.Const.ShellVerb.UnpinFromTaskbar 1
448!define StdUtils.Const.ShellVerb.PinToStart 2
449!define StdUtils.Const.ShellVerb.UnpinFromStart 3
450
451!endif # !___STDUTILS__NSH___
Note: See TracBrowser for help on using the repository browser.