2 Copyright © 2006, The AROS Development Team. All rights reserved.
7 #include <aros/debug.h>
11 #include <proto/dos.h>
16 struct Setup oldsetup
;
57 // must be same order than previous enum
58 static CONST_STRPTR opts
[] =
97 static void setup_write_parameter(BPTR fh
, int argindex
, int value
)
99 static char buffer
[50];
100 sprintf(buffer
, "%s %d\n", opts
[argindex
], value
);
101 FPuts(fh
, (STRPTR
)buffer
);
104 void setup_init(void)
110 void setup_reset(void)
112 setup
.onlyShowFails
= FALSE
;
113 setup
.useDevNames
= FALSE
;
114 setup
.showPaths
= FALSE
;
115 setup
.showCliNr
= FALSE
;
116 setup
.ignoreWB
= FALSE
;
118 setup
.enableChangeDir
= FALSE
;
119 setup
.enableDelete
= FALSE
;
120 setup
.enableExecute
= FALSE
;
121 setup
.enableGetVar
= FALSE
;
122 setup
.enableLoadSeg
= FALSE
;
123 setup
.enableLock
= FALSE
;
124 setup
.enableMakeDir
= FALSE
;
125 setup
.enableMakeLink
= FALSE
;
126 setup
.enableOpen
= TRUE
;
127 setup
.enableRename
= FALSE
;
128 setup
.enableRunCommand
= FALSE
;
129 setup
.enableSetVar
= FALSE
;
130 setup
.enableSystem
= FALSE
;
132 setup
.enableFindPort
= FALSE
;
133 setup
.enableFindResident
= FALSE
;
134 setup
.enableFindSemaphore
= FALSE
;
135 setup
.enableFindTask
= FALSE
;
136 setup
.enableLockScreen
= FALSE
;
137 setup
.enableOpenDevice
= FALSE
;
138 setup
.enableOpenFont
= FALSE
;
139 setup
.enableOpenLibrary
= TRUE
;
140 setup
.enableOpenResource
= FALSE
;
141 setup
.enableReadToolTypes
= FALSE
;
144 setup
.actionLen
= 15;
145 setup
.targetLen
= 40;
146 setup
.optionLen
= 15;
151 BOOL
setup_save(void)
153 BPTR fh
= Open(PREFFILE
, MODE_NEWFILE
);
154 if (!fh
) return FALSE
;
156 setup_write_parameter(fh
, onlyShowFailsOpt
, setup
.onlyShowFails
);
157 setup_write_parameter(fh
, useDevNamesOpt
, setup
.useDevNames
);
158 setup_write_parameter(fh
, showPathsOpt
, setup
.showPaths
);
159 setup_write_parameter(fh
, showCliNrOpt
, setup
.showCliNr
);
160 setup_write_parameter(fh
, ignoreWBOpt
, setup
.ignoreWB
);
162 setup_write_parameter(fh
, ChangeDirOpt
, setup
.enableChangeDir
);
163 setup_write_parameter(fh
, DeleteOpt
, setup
.enableDelete
);
164 setup_write_parameter(fh
, ExecuteOpt
, setup
.enableExecute
);
165 setup_write_parameter(fh
, GetVarOpt
, setup
.enableGetVar
);
166 setup_write_parameter(fh
, LoadSegOpt
, setup
.enableLoadSeg
);
167 setup_write_parameter(fh
, LockOpt
, setup
.enableLock
);
168 setup_write_parameter(fh
, MakeDirOpt
, setup
.enableMakeDir
);
169 setup_write_parameter(fh
, MakeLinkOpt
, setup
.enableMakeLink
);
170 setup_write_parameter(fh
, OpenOpt
, setup
.enableOpen
);
171 setup_write_parameter(fh
, RenameOpt
, setup
.enableRename
);
172 setup_write_parameter(fh
, RunCommandOpt
, setup
.enableRunCommand
);
173 setup_write_parameter(fh
, SetVarOpt
, setup
.enableSetVar
);
174 setup_write_parameter(fh
, SystemOpt
, setup
.enableSystem
);
176 setup_write_parameter(fh
, FindPortOpt
, setup
.enableFindPort
);
177 setup_write_parameter(fh
, FindResidentOpt
, setup
.enableFindResident
);
178 setup_write_parameter(fh
, FindSemaphoreOpt
, setup
.enableFindSemaphore
);
179 setup_write_parameter(fh
, FindTaskOpt
, setup
.enableFindTask
);
180 setup_write_parameter(fh
, LockScreenOpt
, setup
.enableLockScreen
);
181 setup_write_parameter(fh
, OpenDeviceOpt
, setup
.enableOpenDevice
);
182 setup_write_parameter(fh
, OpenFontOpt
, setup
.enableOpenFont
);
183 setup_write_parameter(fh
, OpenLibraryOpt
, setup
.enableOpenLibrary
);
184 setup_write_parameter(fh
, OpenResourceOpt
, setup
.enableOpenResource
);
185 setup_write_parameter(fh
, ReadToolTypesOpt
, setup
.enableReadToolTypes
);
187 setup_write_parameter(fh
, nameLenOpt
, setup
.nameLen
);
188 setup_write_parameter(fh
, actionLenOpt
, setup
.actionLen
);
189 setup_write_parameter(fh
, targetLenOpt
, setup
.targetLen
);
190 setup_write_parameter(fh
, optionLenOpt
, setup
.optionLen
);
196 BOOL
setup_open(void)
202 BPTR fh
= Open(PREFFILE
, MODE_OLDFILE
);
203 if (!fh
) return FALSE
;
204 D(bug("Snoopy: File open\n"));
205 while (FGets(fh
, buffer
, sizeof(buffer
)))
207 D(bug("Snoopy: %s read\n", buffer
));
208 if (sscanf(buffer
,"%59s %d", option
, &value
) == 2)
210 D(bug("Snoopy: %s | %d\n", option
, value
));
211 if ( ! stricmp(option
, opts
[onlyShowFailsOpt
]))
212 setup
.onlyShowFails
= value
;
213 else if ( ! stricmp(option
, opts
[useDevNamesOpt
]))
214 setup
.useDevNames
= value
;
215 else if ( ! stricmp(option
, opts
[showPathsOpt
]))
216 setup
.showPaths
= value
;
217 else if ( ! stricmp(option
, opts
[showCliNrOpt
]))
218 setup
.showCliNr
= value
;
219 else if ( ! stricmp(option
, opts
[ignoreWBOpt
]))
220 setup
.ignoreWB
= value
;
221 else if ( ! stricmp(option
, opts
[ChangeDirOpt
]))
222 setup
.enableChangeDir
= value
;
223 else if ( ! stricmp(option
, opts
[DeleteOpt
]))
224 setup
.enableDelete
= value
;
225 else if ( ! stricmp(option
, opts
[ExecuteOpt
]))
226 setup
.enableExecute
= value
;
227 else if ( ! stricmp(option
, opts
[GetVarOpt
]))
228 setup
.enableGetVar
= value
;
229 else if ( ! stricmp(option
, opts
[LoadSegOpt
]))
230 setup
.enableLoadSeg
= value
;
231 else if ( ! stricmp(option
, opts
[LockOpt
]))
232 setup
.enableLock
= value
;
233 else if ( ! stricmp(option
, opts
[MakeDirOpt
]))
234 setup
.enableMakeDir
= value
;
235 else if ( ! stricmp(option
, opts
[MakeLinkOpt
]))
236 setup
.enableMakeLink
= value
;
237 else if ( ! stricmp(option
, opts
[OpenOpt
]))
238 setup
.enableOpen
= value
;
239 else if ( ! stricmp(option
, opts
[RenameOpt
]))
240 setup
.enableRename
= value
;
241 else if ( ! stricmp(option
, opts
[RunCommandOpt
]))
242 setup
.enableRunCommand
= value
;
243 else if ( ! stricmp(option
, opts
[SetVarOpt
]))
244 setup
.enableSetVar
= value
;
245 else if ( ! stricmp(option
, opts
[SystemOpt
]))
246 setup
.enableSystem
= value
;
247 else if ( ! stricmp(option
, opts
[FindPortOpt
]))
248 setup
.enableFindPort
= value
;
249 else if ( ! stricmp(option
, opts
[FindResidentOpt
]))
250 setup
.enableFindResident
= value
;
251 else if ( ! stricmp(option
, opts
[FindSemaphoreOpt
]))
252 setup
.enableFindSemaphore
= value
;
253 else if ( ! stricmp(option
, opts
[FindTaskOpt
]))
254 setup
.enableFindTask
= value
;
255 else if ( ! stricmp(option
, opts
[LockScreenOpt
]))
256 setup
.enableLockScreen
= value
;
257 else if ( ! stricmp(option
, opts
[OpenDeviceOpt
]))
258 setup
.enableOpenDevice
= value
;
259 else if ( ! stricmp(option
, opts
[OpenFontOpt
]))
260 setup
.enableOpenFont
= value
;
261 else if ( ! stricmp(option
, opts
[OpenLibraryOpt
]))
262 setup
.enableOpenLibrary
= value
;
263 else if ( ! stricmp(option
, opts
[OpenResourceOpt
]))
264 setup
.enableOpenResource
= value
;
265 else if ( ! stricmp(option
, opts
[ReadToolTypesOpt
]))
266 setup
.enableReadToolTypes
= value
;
267 else if ( ! stricmp(option
, opts
[nameLenOpt
]))
268 setup
.nameLen
= value
;
269 else if ( ! stricmp(option
, opts
[actionLenOpt
]))
270 setup
.actionLen
= value
;
271 else if ( ! stricmp(option
, opts
[targetLenOpt
]))
272 setup
.targetLen
= value
;
273 else if ( ! stricmp(option
, opts
[optionLenOpt
]))
274 setup
.optionLen
= value
;
276 else if ((buffer
[0] != '\0') && (buffer
[0] != '\n'))