Statistiques
| Révision :

root / tmp / org.txm.setups / nsis / Include / InstallOptions.nsh @ 3144

Historique | Voir | Annoter | Télécharger (4,71 ko)

1 728 mdecorde
/*
2 728 mdecorde
3 728 mdecorde
InstallOptions.nsh
4 728 mdecorde
Macros and conversion functions for InstallOptions
5 728 mdecorde
6 728 mdecorde
*/
7 728 mdecorde
8 728 mdecorde
!ifndef ___NSIS__INSTALL_OPTIONS__NSH___
9 728 mdecorde
!define ___NSIS__INSTALL_OPTIONS__NSH___
10 728 mdecorde
11 728 mdecorde
!include LogicLib.nsh
12 728 mdecorde
13 728 mdecorde
!macro INSTALLOPTIONS_FUNCTION_READ_CONVERT
14 728 mdecorde
  !insertmacro INSTALLOPTIONS_FUNCTION_IO2NSIS ""
15 728 mdecorde
!macroend
16 728 mdecorde
17 728 mdecorde
!macro INSTALLOPTIONS_UNFUNCTION_READ_CONVERT
18 728 mdecorde
  !insertmacro INSTALLOPTIONS_FUNCTION_IO2NSIS un.
19 728 mdecorde
!macroend
20 728 mdecorde
21 728 mdecorde
!macro INSTALLOPTIONS_FUNCTION_WRITE_CONVERT
22 728 mdecorde
  !insertmacro INSTALLOPTIONS_FUNCTION_NSIS2IO ""
23 728 mdecorde
!macroend
24 728 mdecorde
25 728 mdecorde
!macro INSTALLOPTIONS_UNFUNCTION_WRITE_CONVERT
26 728 mdecorde
  !insertmacro INSTALLOPTIONS_FUNCTION_NSIS2IO un.
27 728 mdecorde
!macroend
28 728 mdecorde
29 728 mdecorde
!macro INSTALLOPTIONS_FUNCTION_NSIS2IO UNINSTALLER_FUNCPREFIX
30 728 mdecorde
31 728 mdecorde
  ; Convert an NSIS string to a form suitable for use by InstallOptions
32 728 mdecorde
  ; Usage:
33 728 mdecorde
  ;   Push <NSIS-string>
34 728 mdecorde
  ;   Call Nsis2Io
35 728 mdecorde
  ;   Pop <IO-string>
36 728 mdecorde
37 728 mdecorde
  Function ${UNINSTALLER_FUNCPREFIX}Nsis2Io
38 728 mdecorde
39 728 mdecorde
    Exch $0 ; The source
40 728 mdecorde
    Push $1 ; The output
41 728 mdecorde
    Push $2 ; Temporary char
42 728 mdecorde
    Push $3 ; Length
43 728 mdecorde
    Push $4 ; Loop index
44 728 mdecorde
    StrCpy $1 "" ; Initialise the output
45 728 mdecorde
46 728 mdecorde
    StrLen $3 $0
47 728 mdecorde
    IntOp $3 $3 - 1
48 728 mdecorde
49 728 mdecorde
    ${For} $4 0 $3
50 728 mdecorde
      StrCpy $2 $0 1 $4
51 728 mdecorde
      ${If}     $2 == '\'
52 728 mdecorde
        StrCpy $2 '\\'
53 728 mdecorde
      ${ElseIf} $2 == '$\r'
54 728 mdecorde
        StrCpy $2 '\r'
55 728 mdecorde
      ${ElseIf} $2 == '$\n'
56 728 mdecorde
        StrCpy $2 '\n'
57 728 mdecorde
      ${ElseIf} $2 == '$\t'
58 728 mdecorde
        StrCpy $2 '\t'
59 728 mdecorde
      ${EndIf}
60 728 mdecorde
      StrCpy $1 $1$2
61 728 mdecorde
    ${Next}
62 728 mdecorde
63 728 mdecorde
    StrCpy $0 $1
64 728 mdecorde
    Pop $4
65 728 mdecorde
    Pop $3
66 728 mdecorde
    Pop $2
67 728 mdecorde
    Pop $1
68 728 mdecorde
    Exch $0
69 728 mdecorde
70 728 mdecorde
  FunctionEnd
71 728 mdecorde
72 728 mdecorde
!macroend
73 728 mdecorde
74 728 mdecorde
!macro INSTALLOPTIONS_FUNCTION_IO2NSIS UNINSTALLER_FUNCPREFIX
75 728 mdecorde
76 728 mdecorde
  ; Convert an InstallOptions string to a form suitable for use by NSIS
77 728 mdecorde
  ; Usage:
78 728 mdecorde
  ;   Push <IO-string>
79 728 mdecorde
  ;   Call Io2Nsis
80 728 mdecorde
  ;   Pop <NSIS-string>
81 728 mdecorde
82 728 mdecorde
  Function ${UNINSTALLER_FUNCPREFIX}Io2Nsis
83 728 mdecorde
84 728 mdecorde
    Exch $0 ; The source
85 728 mdecorde
    Push $1 ; The output
86 728 mdecorde
    Push $2 ; Temporary char
87 728 mdecorde
    Push $3 ; Length
88 728 mdecorde
    Push $4 ; Loop index
89 728 mdecorde
    StrCpy $1 "" ; Initialise the output
90 728 mdecorde
91 728 mdecorde
    StrLen $3 $0
92 728 mdecorde
    IntOp $3 $3 - 1
93 728 mdecorde
94 728 mdecorde
    ${For} $4 0 $3
95 728 mdecorde
      StrCpy $2 $0 2 $4
96 728 mdecorde
      ${If}     $2 == '\\'
97 728 mdecorde
        StrCpy $2 '\'
98 728 mdecorde
        IntOp $4 $4 + 1
99 728 mdecorde
      ${ElseIf} $2 == '\r'
100 728 mdecorde
        StrCpy $2 '$\r'
101 728 mdecorde
        IntOp $4 $4 + 1
102 728 mdecorde
      ${ElseIf} $2 == '\n'
103 728 mdecorde
        StrCpy $2 '$\n'
104 728 mdecorde
        IntOp $4 $4 + 1
105 728 mdecorde
      ${ElseIf} $2 == '\t'
106 728 mdecorde
        StrCpy $2 '$\t'
107 728 mdecorde
        IntOp $4 $4 + 1
108 728 mdecorde
      ${EndIf}
109 728 mdecorde
      StrCpy $2 $2 1
110 728 mdecorde
      StrCpy $1 $1$2
111 728 mdecorde
    ${Next}
112 728 mdecorde
113 728 mdecorde
    StrCpy $0 $1
114 728 mdecorde
    Pop $4
115 728 mdecorde
    Pop $3
116 728 mdecorde
    Pop $2
117 728 mdecorde
    Pop $1
118 728 mdecorde
    Exch $0
119 728 mdecorde
120 728 mdecorde
  FunctionEnd
121 728 mdecorde
122 728 mdecorde
!macroend
123 728 mdecorde
124 728 mdecorde
!macro INSTALLOPTIONS_EXTRACT FILE
125 728 mdecorde
126 728 mdecorde
  InitPluginsDir
127 728 mdecorde
  File "/oname=$PLUGINSDIR\${FILE}" "${FILE}"
128 2956 mdecorde
!ifdef NSIS_UNICODE
129 2956 mdecorde
  InstallOptions::make_unicode "$PLUGINSDIR\${FILE}"
130 2956 mdecorde
!endif
131 728 mdecorde
  !insertmacro INSTALLOPTIONS_WRITE "${FILE}" "Settings" "RTL" "$(^RTL)"
132 728 mdecorde
133 728 mdecorde
!macroend
134 728 mdecorde
135 728 mdecorde
!macro INSTALLOPTIONS_EXTRACT_AS FILE FILENAME
136 728 mdecorde
137 728 mdecorde
  InitPluginsDir
138 728 mdecorde
  File "/oname=$PLUGINSDIR\${FILENAME}" "${FILE}"
139 2956 mdecorde
!ifdef NSIS_UNICODE
140 2956 mdecorde
  InstallOptions::make_unicode "$PLUGINSDIR\${FILENAME}"
141 2956 mdecorde
!endif
142 728 mdecorde
  !insertmacro INSTALLOPTIONS_WRITE "${FILENAME}" "Settings" "RTL" "$(^RTL)"
143 728 mdecorde
144 728 mdecorde
!macroend
145 728 mdecorde
146 728 mdecorde
!macro INSTALLOPTIONS_DISPLAY FILE
147 728 mdecorde
148 728 mdecorde
  Push $0
149 728 mdecorde
150 728 mdecorde
  InstallOptions::dialog "$PLUGINSDIR\${FILE}"
151 728 mdecorde
  Pop $0
152 728 mdecorde
153 728 mdecorde
  Pop $0
154 728 mdecorde
155 728 mdecorde
!macroend
156 728 mdecorde
157 728 mdecorde
!macro INSTALLOPTIONS_DISPLAY_RETURN FILE
158 728 mdecorde
159 728 mdecorde
  InstallOptions::dialog "$PLUGINSDIR\${FILE}"
160 728 mdecorde
161 728 mdecorde
!macroend
162 728 mdecorde
163 728 mdecorde
!macro INSTALLOPTIONS_INITDIALOG FILE
164 728 mdecorde
165 728 mdecorde
  InstallOptions::initDialog "$PLUGINSDIR\${FILE}"
166 728 mdecorde
167 728 mdecorde
!macroend
168 728 mdecorde
169 728 mdecorde
!macro INSTALLOPTIONS_SHOW
170 728 mdecorde
171 728 mdecorde
  Push $0
172 728 mdecorde
173 728 mdecorde
  InstallOptions::show
174 728 mdecorde
  Pop $0
175 728 mdecorde
176 728 mdecorde
  Pop $0
177 728 mdecorde
178 728 mdecorde
!macroend
179 728 mdecorde
180 728 mdecorde
!macro INSTALLOPTIONS_SHOW_RETURN
181 728 mdecorde
182 728 mdecorde
  InstallOptions::show
183 728 mdecorde
184 728 mdecorde
!macroend
185 728 mdecorde
186 728 mdecorde
!macro INSTALLOPTIONS_READ VAR FILE SECTION KEY
187 728 mdecorde
188 728 mdecorde
  ReadIniStr ${VAR} "$PLUGINSDIR\${FILE}" "${SECTION}" "${KEY}"
189 728 mdecorde
190 728 mdecorde
!macroend
191 728 mdecorde
192 728 mdecorde
!macro INSTALLOPTIONS_WRITE FILE SECTION KEY VALUE
193 728 mdecorde
194 728 mdecorde
  WriteIniStr "$PLUGINSDIR\${FILE}" "${SECTION}" "${KEY}" "${VALUE}"
195 728 mdecorde
196 728 mdecorde
!macroend
197 728 mdecorde
198 728 mdecorde
!macro INSTALLOPTIONS_READ_CONVERT VAR FILE SECTION KEY
199 728 mdecorde
200 728 mdecorde
  ReadIniStr ${VAR} "$PLUGINSDIR\${FILE}" "${SECTION}" "${KEY}"
201 728 mdecorde
  Push ${VAR}
202 728 mdecorde
  Call Io2Nsis
203 728 mdecorde
  Pop ${VAR}
204 728 mdecorde
205 728 mdecorde
!macroend
206 728 mdecorde
207 728 mdecorde
!macro INSTALLOPTIONS_READ_UNCONVERT VAR FILE SECTION KEY
208 728 mdecorde
209 728 mdecorde
  ReadIniStr ${VAR} "$PLUGINSDIR\${FILE}" "${SECTION}" "${KEY}"
210 728 mdecorde
  Push ${VAR}
211 728 mdecorde
  Call un.Io2Nsis
212 728 mdecorde
  Pop ${VAR}
213 728 mdecorde
214 728 mdecorde
!macroend
215 728 mdecorde
216 728 mdecorde
!macro INSTALLOPTIONS_WRITE_CONVERT FILE SECTION KEY VALUE
217 728 mdecorde
218 728 mdecorde
  Push $0
219 728 mdecorde
  StrCpy $0 "${VALUE}"
220 728 mdecorde
  Push $0
221 728 mdecorde
  Call Nsis2Io
222 728 mdecorde
  Pop $0
223 728 mdecorde
224 728 mdecorde
  WriteIniStr "$PLUGINSDIR\${FILE}" "${SECTION}" "${KEY}" $0
225 728 mdecorde
226 728 mdecorde
  Pop $0
227 728 mdecorde
228 728 mdecorde
!macroend
229 728 mdecorde
230 728 mdecorde
!macro INSTALLOPTIONS_WRITE_UNCONVERT FILE SECTION KEY VALUE
231 728 mdecorde
232 728 mdecorde
  Push $0
233 728 mdecorde
  StrCpy $0 "${VALUE}"
234 728 mdecorde
  Push $0
235 728 mdecorde
  Call un.Nsis2Io
236 728 mdecorde
  Pop $0
237 728 mdecorde
238 728 mdecorde
  WriteIniStr "$PLUGINSDIR\${FILE}" "${SECTION}" "${KEY}" $0
239 728 mdecorde
240 728 mdecorde
  Pop $0
241 728 mdecorde
242 728 mdecorde
!macroend
243 728 mdecorde
244 728 mdecorde
!endif # ___NSIS__INSTALL_OPTIONS__NSH___