2 Copyright © 2006-2008, The AROS Development Team. All rights reserved.
7 #include <aros/debug.h>
11 #include <proto/dos.h>
16 struct Setup oldsetup
;
58 // must be same order than previous enum
59 static CONST_STRPTR opts
[] =
99 static void setup_write_parameter(BPTR fh
, int argindex
, int value
)
101 static char buffer
[50];
102 sprintf(buffer
, "%s %d\n", opts
[argindex
], value
);
103 FPuts(fh
, (STRPTR
)buffer
);
106 void setup_init(void)
112 void setup_reset(void)
114 setup
.onlyShowFails
= FALSE
;
115 setup
.useDevNames
= FALSE
;
116 setup
.showPaths
= FALSE
;
117 setup
.showCliNr
= FALSE
;
118 setup
.ignoreWB
= FALSE
;
119 setup
.breakPoint
= FALSE
;
122 setup
.pattern
= NULL
;
123 setup
.parsedpattern
[0] = '\0';
125 setup
.enableChangeDir
= FALSE
;
126 setup
.enableDelete
= FALSE
;
127 setup
.enableExecute
= FALSE
;
128 setup
.enableGetVar
= FALSE
;
129 setup
.enableLoadSeg
= FALSE
;
130 setup
.enableLock
= FALSE
;
131 setup
.enableMakeDir
= FALSE
;
132 setup
.enableMakeLink
= FALSE
;
133 setup
.enableOpen
= TRUE
;
134 setup
.enableRename
= FALSE
;
135 setup
.enableRunCommand
= FALSE
;
136 setup
.enableSetVar
= FALSE
;
137 setup
.enableSystem
= FALSE
;
139 setup
.enableFindPort
= FALSE
;
140 setup
.enableFindResident
= FALSE
;
141 setup
.enableFindSemaphore
= FALSE
;
142 setup
.enableFindTask
= FALSE
;
143 setup
.enableLockScreen
= FALSE
;
144 setup
.enableOpenDevice
= FALSE
;
145 setup
.enableOpenFont
= FALSE
;
146 setup
.enableOpenLibrary
= TRUE
;
147 setup
.enableOpenResource
= FALSE
;
148 setup
.enableReadToolTypes
= FALSE
;
151 setup
.actionLen
= 15;
152 setup
.targetLen
= 40;
153 setup
.optionLen
= 15;
158 BOOL
setup_save(void)
160 // temporary disable breakpoint option to ensure that
161 // a) Open() and other functions aren't interrupted while saving the prefs file
162 // b) the breakpoint option is always saved as "FALSE" to the prefs file
163 BOOL breakPoint
= setup
.breakPoint
;
164 setup
.breakPoint
= FALSE
;
166 BOOL retvalue
= FALSE
;
168 BPTR fh
= Open(PREFFILE
, MODE_NEWFILE
);
171 setup_write_parameter(fh
, onlyShowFailsOpt
, setup
.onlyShowFails
);
172 setup_write_parameter(fh
, useDevNamesOpt
, setup
.useDevNames
);
173 setup_write_parameter(fh
, showPathsOpt
, setup
.showPaths
);
174 setup_write_parameter(fh
, showCliNrOpt
, setup
.showCliNr
);
175 setup_write_parameter(fh
, ignoreWBOpt
, setup
.ignoreWB
);
176 setup_write_parameter(fh
, breakPointOpt
, setup
.breakPoint
);
178 // TODO: write pattern
180 setup_write_parameter(fh
, ChangeDirOpt
, setup
.enableChangeDir
);
181 setup_write_parameter(fh
, DeleteOpt
, setup
.enableDelete
);
182 setup_write_parameter(fh
, ExecuteOpt
, setup
.enableExecute
);
183 setup_write_parameter(fh
, GetVarOpt
, setup
.enableGetVar
);
184 setup_write_parameter(fh
, LoadSegOpt
, setup
.enableLoadSeg
);
185 setup_write_parameter(fh
, LockOpt
, setup
.enableLock
);
186 setup_write_parameter(fh
, MakeDirOpt
, setup
.enableMakeDir
);
187 setup_write_parameter(fh
, MakeLinkOpt
, setup
.enableMakeLink
);
188 setup_write_parameter(fh
, OpenOpt
, setup
.enableOpen
);
189 setup_write_parameter(fh
, RenameOpt
, setup
.enableRename
);
190 setup_write_parameter(fh
, RunCommandOpt
, setup
.enableRunCommand
);
191 setup_write_parameter(fh
, SetVarOpt
, setup
.enableSetVar
);
192 setup_write_parameter(fh
, SystemOpt
, setup
.enableSystem
);
194 setup_write_parameter(fh
, FindPortOpt
, setup
.enableFindPort
);
195 setup_write_parameter(fh
, FindResidentOpt
, setup
.enableFindResident
);
196 setup_write_parameter(fh
, FindSemaphoreOpt
, setup
.enableFindSemaphore
);
197 setup_write_parameter(fh
, FindTaskOpt
, setup
.enableFindTask
);
198 setup_write_parameter(fh
, LockScreenOpt
, setup
.enableLockScreen
);
199 setup_write_parameter(fh
, OpenDeviceOpt
, setup
.enableOpenDevice
);
200 setup_write_parameter(fh
, OpenFontOpt
, setup
.enableOpenFont
);
201 setup_write_parameter(fh
, OpenLibraryOpt
, setup
.enableOpenLibrary
);
202 setup_write_parameter(fh
, OpenResourceOpt
, setup
.enableOpenResource
);
203 setup_write_parameter(fh
, ReadToolTypesOpt
, setup
.enableReadToolTypes
);
205 setup_write_parameter(fh
, nameLenOpt
, setup
.nameLen
);
206 setup_write_parameter(fh
, actionLenOpt
, setup
.actionLen
);
207 setup_write_parameter(fh
, targetLenOpt
, setup
.targetLen
);
208 setup_write_parameter(fh
, optionLenOpt
, setup
.optionLen
);
214 // restore breakpoint option
215 setup
.breakPoint
= breakPoint
;
220 BOOL
setup_open(void)
222 // temporary disable breakpoint option
223 BOOL breakPoint
= setup
.breakPoint
;
224 setup
.breakPoint
= FALSE
;
231 BPTR fh
= Open(PREFFILE
, MODE_OLDFILE
);
234 D(bug("Snoopy: File open\n"));
235 while (FGets(fh
, buffer
, sizeof(buffer
)))
237 // TODO: read pattern
238 D(bug("Snoopy: %s read\n", buffer
));
239 if (sscanf(buffer
,"%59s %d", option
, &value
) == 2)
241 D(bug("Snoopy: %s | %d\n", option
, value
));
242 if ( ! stricmp(option
, opts
[onlyShowFailsOpt
]))
243 setup
.onlyShowFails
= value
;
244 else if ( ! stricmp(option
, opts
[useDevNamesOpt
]))
245 setup
.useDevNames
= value
;
246 else if ( ! stricmp(option
, opts
[showPathsOpt
]))
247 setup
.showPaths
= value
;
248 else if ( ! stricmp(option
, opts
[showCliNrOpt
]))
249 setup
.showCliNr
= value
;
250 else if ( ! stricmp(option
, opts
[ignoreWBOpt
]))
251 setup
.ignoreWB
= value
;
252 else if ( ! stricmp(option
, opts
[breakPointOpt
]))
253 breakPoint
= value
; // use temp variable
254 else if ( ! stricmp(option
, opts
[ChangeDirOpt
]))
255 setup
.enableChangeDir
= value
;
256 else if ( ! stricmp(option
, opts
[DeleteOpt
]))
257 setup
.enableDelete
= value
;
258 else if ( ! stricmp(option
, opts
[ExecuteOpt
]))
259 setup
.enableExecute
= value
;
260 else if ( ! stricmp(option
, opts
[GetVarOpt
]))
261 setup
.enableGetVar
= value
;
262 else if ( ! stricmp(option
, opts
[LoadSegOpt
]))
263 setup
.enableLoadSeg
= value
;
264 else if ( ! stricmp(option
, opts
[LockOpt
]))
265 setup
.enableLock
= value
;
266 else if ( ! stricmp(option
, opts
[MakeDirOpt
]))
267 setup
.enableMakeDir
= value
;
268 else if ( ! stricmp(option
, opts
[MakeLinkOpt
]))
269 setup
.enableMakeLink
= value
;
270 else if ( ! stricmp(option
, opts
[OpenOpt
]))
271 setup
.enableOpen
= value
;
272 else if ( ! stricmp(option
, opts
[RenameOpt
]))
273 setup
.enableRename
= value
;
274 else if ( ! stricmp(option
, opts
[RunCommandOpt
]))
275 setup
.enableRunCommand
= value
;
276 else if ( ! stricmp(option
, opts
[SetVarOpt
]))
277 setup
.enableSetVar
= value
;
278 else if ( ! stricmp(option
, opts
[SystemOpt
]))
279 setup
.enableSystem
= value
;
280 else if ( ! stricmp(option
, opts
[FindPortOpt
]))
281 setup
.enableFindPort
= value
;
282 else if ( ! stricmp(option
, opts
[FindResidentOpt
]))
283 setup
.enableFindResident
= value
;
284 else if ( ! stricmp(option
, opts
[FindSemaphoreOpt
]))
285 setup
.enableFindSemaphore
= value
;
286 else if ( ! stricmp(option
, opts
[FindTaskOpt
]))
287 setup
.enableFindTask
= value
;
288 else if ( ! stricmp(option
, opts
[LockScreenOpt
]))
289 setup
.enableLockScreen
= value
;
290 else if ( ! stricmp(option
, opts
[OpenDeviceOpt
]))
291 setup
.enableOpenDevice
= value
;
292 else if ( ! stricmp(option
, opts
[OpenFontOpt
]))
293 setup
.enableOpenFont
= value
;
294 else if ( ! stricmp(option
, opts
[OpenLibraryOpt
]))
295 setup
.enableOpenLibrary
= value
;
296 else if ( ! stricmp(option
, opts
[OpenResourceOpt
]))
297 setup
.enableOpenResource
= value
;
298 else if ( ! stricmp(option
, opts
[ReadToolTypesOpt
]))
299 setup
.enableReadToolTypes
= value
;
300 else if ( ! stricmp(option
, opts
[nameLenOpt
]))
301 setup
.nameLen
= value
;
302 else if ( ! stricmp(option
, opts
[actionLenOpt
]))
303 setup
.actionLen
= value
;
304 else if ( ! stricmp(option
, opts
[targetLenOpt
]))
305 setup
.targetLen
= value
;
306 else if ( ! stricmp(option
, opts
[optionLenOpt
]))
307 setup
.optionLen
= value
;
309 else if ((buffer
[0] != '\0') && (buffer
[0] != '\n'))
321 // restore breakpoint option
322 setup
.breakPoint
= breakPoint
;