]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/params.nsh
Apply Thorsten's bugfix for vss_generic.cpp
[bacula/bacula] / bacula / src / win32 / params.nsh
1 ;
2 ; -- written by Alexis de Valence --
3 ; GetONEParameter
4
5 ; Usage:
6 ;   Push 3                 ; to get the 3rd parameter of the command line
7 ;   Call GetONEParameter
8 ;   Pop $R0                ; saves the result in $R0
9 ; returns an empty string if not found
10
11 Function GetONEParameter
12    Exch $R0
13    Push $R1
14    Push $R2
15    Push $R3
16    Push $R4
17    Push $R5
18    Push $R6
19
20 ; init variables
21    IntOp $R5 $R0 + 1
22    StrCpy $R2 0
23    StrCpy $R4 1
24    StrCpy $R6 0
25
26    loop3: ; looking for a char that's not a space
27      IntOp $R2 $R2 + 1
28      StrCpy $R0 $CMDLINE 1 $R2
29      StrCmp $R0 " " loop3
30      StrCpy $R3 $R2   ; found the begining of the current parameter
31
32
33    loop:          ; scanning for the end of the current parameter
34
35      StrCpy $R0 $CMDLINE 1 $R2
36      StrCmp $R0 " " loop2
37      StrCmp $R0 "" last
38      IntOp $R2 $R2 + 1
39      Goto loop
40
41    last: ; there will be no other parameter to extract
42    StrCpy $R6 1
43
44    loop2: ; found the end of the current parameter
45
46    IntCmp $R4 $R5 0 NextParam end
47    StrCpy $R6 1 ; to quit after this process
48
49    IntOp $R1 $R2 - $R3 ;number of letter of current parameter
50    StrCpy $R0 $CMDLINE $R1 $R3        ; stores the result in R0
51
52    NextParam:
53    IntCmp $R6 1 end ; leave if found or if not enough parameters
54
55    ; process the next parameter
56    IntOp $R4 $R4 + 1
57
58    Goto loop3
59
60    end:
61
62    Pop $R6  ; restore R0 - R6 to their initial value
63    Pop $R5
64    Pop $R4
65    Pop $R3
66    Pop $R2
67    Pop $R1
68
69    Exch $R0    ;Puts the result on the stack
70
71  FunctionEnd
72
73 ; -- written by Michel Meyers --
74 ; ParameterGiven - checks first 9 parameters on the command line
75 ; Usage:
76 ;   Push "/parameter"                 ; to check command line for /parameter
77 ;   Call ParameterGiven
78 ;   Pop $R0                ; saves the result in $R0 (result = true or false)
79
80  Function ParameterGiven
81    Exch $R0
82    Push $R1
83    Push $R2
84    Push $R3
85    
86    StrCpy $R1 0
87    StrCpy $R3 0
88    loopme:
89    StrCmp $R1 9 AllChecked
90    IntOp $R1 $R1 + 1
91    Push $R1
92    Call GetONEParameter
93    Pop $R2                ; saves the result in $R2
94    StrCmp $R0 $R2 Found
95    Goto loopme
96    
97    Found:
98    StrCpy $R3 1
99    Goto loopme
100    
101    AllChecked:
102    Exch $R3
103   
104 FunctionEnd