1 /* settings.c: Handling configuration settings
2    Copyright (c) 2002 Philip Kendall
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2 of the License, or
7    (at your option) any later version.
8 
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License along
15    with this program; if not, write to the Free Software Foundation, Inc.,
16    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 
18    Author contact information:
19 
20    E-mail: philip-fuse@shadowmagic.org.uk
21 
22 */
23 #line 63"../settings.pl"
24 
25 /* This file is autogenerated from settings.dat by settings.pl.
26    Do not edit unless you know what will happen! */
27 
28 #include <config.h>
29 
30 #include <errno.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <unistd.h>
37 
38 #ifdef HAVE_GETOPT_LONG		/* Did our libc include getopt_long? */
39 #include <getopt.h>
40 #elif defined AMIGA || defined __MORPHOS__            /* #ifdef HAVE_GETOPT_LONG */
41 /* The platform uses GNU getopt, but not getopt_long, so we get
42    symbol clashes on this platform. Just use getopt */
43 #else				/* #ifdef HAVE_GETOPT_LONG */
44 #include "compat.h"		/* If not, use ours */
45 #endif				/* #ifdef HAVE_GETOPT_LONG */
46 
47 #ifdef HAVE_LIB_XML2
48 #include <libxml/xmlmemory.h>
49 #include <libxml/parser.h>
50 #endif				/* #ifdef HAVE_LIB_XML2 */
51 
52 #include "fuse.h"
53 #include "machine.h"
54 #include "settings.h"
55 #include "spectrum.h"
56 #include "ui/ui.h"
57 #include "utils.h"
58 
59 /* The name of our configuration file */
60 #if defined (WIN32) || defined (__CELLOS_LV2__)
61 #define CONFIG_FILE_NAME "fuse.cfg"
62 #else				/* #ifdef WIN32 */
63 #define CONFIG_FILE_NAME ".fuserc"
64 #endif				/* #ifdef WIN32 */
65 
66 #define getopt_long(argc, argv, optstring, longopts, longindex) (-1)
67 
68 /* The current settings of options, etc */
69 settings_info settings_current;
70 
71 /* The default settings of options, etc */
72 settings_info settings_default = {
73   /* accelerate_loader */ 1,
74   /* aspect_hint */ 1,
75   /* auto_load */ 1,
76   /* autosave_settings */ 0,
77   /* beta128 */ 0,
78   /* beta128_48boot */ 1,
79   /* betadisk_file */ NULL,
80   /* bw_tv */ 0,
81   /* competition_code */ 0,
82   /* competition_mode */ 0,
83   /* confirm_actions */ 1,
84   /* dck_file */ NULL,
85   /* debugger_command */ NULL,
86   /* detect_loader */ 1,
87   /* disciple */ 0,
88   /* discipledisk_file */ NULL,
89   /* disk_ask_merge */ 1,
90   /* disk_try_merge */ NULL,
91   /* divide_enabled */ 0,
92   /* divide_master_file */ NULL,
93   /* divide_slave_file */ NULL,
94   /* divide_wp */ 0,
95   /* doublescan_mode */ 1,
96   /* drive_40_max_track */ 42,
97   /* drive_80_max_track */ 84,
98   /* drive_beta128a_type */ NULL,
99   /* drive_beta128b_type */ NULL,
100   /* drive_beta128c_type */ NULL,
101   /* drive_beta128d_type */ NULL,
102   /* drive_disciple1_type */ NULL,
103   /* drive_disciple2_type */ NULL,
104   /* drive_opus1_type */ NULL,
105   /* drive_opus2_type */ NULL,
106   /* drive_plus3a_type */ NULL,
107   /* drive_plus3b_type */ NULL,
108   /* drive_plusd1_type */ NULL,
109   /* drive_plusd2_type */ NULL,
110   /* embed_snapshot */ 1,
111   /* emulation_speed */ 100,
112   /* fastload */ 1,
113   /* fb_mode */ 320,
114   /* frame_rate */ 1,
115   /* full_screen */ 0,
116   /* fuller */ 0,
117   /* if2_file */ NULL,
118   /* interface1 */ 0,
119   /* interface2 */ 1,
120   /* issue2 */ 0,
121   /* joy_kempston */ 0,
122   /* joy_prompt */ 0,
123   /* joystick_1 */ NULL,
124   /* joystick_1_fire_1 */ 4096,
125   /* joystick_1_fire_10 */ 4096,
126   /* joystick_1_fire_11 */ 4096,
127   /* joystick_1_fire_12 */ 4096,
128   /* joystick_1_fire_13 */ 4096,
129   /* joystick_1_fire_14 */ 4096,
130   /* joystick_1_fire_15 */ 4096,
131   /* joystick_1_fire_2 */ 4096,
132   /* joystick_1_fire_3 */ 4096,
133   /* joystick_1_fire_4 */ 4096,
134   /* joystick_1_fire_5 */ 4096,
135   /* joystick_1_fire_6 */ 4096,
136   /* joystick_1_fire_7 */ 4096,
137   /* joystick_1_fire_8 */ 4096,
138   /* joystick_1_fire_9 */ 4096,
139   /* joystick_1_output */ 0,
140   /* joystick_2 */ NULL,
141   /* joystick_2_fire_1 */ 4096,
142   /* joystick_2_fire_10 */ 4096,
143   /* joystick_2_fire_11 */ 4096,
144   /* joystick_2_fire_12 */ 4096,
145   /* joystick_2_fire_13 */ 4096,
146   /* joystick_2_fire_14 */ 4096,
147   /* joystick_2_fire_15 */ 4096,
148   /* joystick_2_fire_2 */ 4096,
149   /* joystick_2_fire_3 */ 4096,
150   /* joystick_2_fire_4 */ 4096,
151   /* joystick_2_fire_5 */ 4096,
152   /* joystick_2_fire_6 */ 4096,
153   /* joystick_2_fire_7 */ 4096,
154   /* joystick_2_fire_8 */ 4096,
155   /* joystick_2_fire_9 */ 4096,
156   /* joystick_2_output */ 0,
157   /* joystick_keyboard_down */ 97,
158   /* joystick_keyboard_fire */ 32,
159   /* joystick_keyboard_left */ 111,
160   /* joystick_keyboard_output */ 0,
161   /* joystick_keyboard_right */ 112,
162   /* joystick_keyboard_up */ 113,
163   /* kempston_mouse */ 0,
164   /* late_timings */ 0,
165   /* mdr_file */ NULL,
166   /* mdr_file2 */ NULL,
167   /* mdr_file3 */ NULL,
168   /* mdr_file4 */ NULL,
169   /* mdr_file5 */ NULL,
170   /* mdr_file6 */ NULL,
171   /* mdr_file7 */ NULL,
172   /* mdr_file8 */ NULL,
173   /* mdr_len */ 180,
174   /* mdr_random_len */ 1,
175   /* melodik */ 0,
176   /* mouse_swap_buttons */ 0,
177   /* movie_compr */ NULL,
178   /* movie_start */ NULL,
179   /* movie_stop_after_rzx */ 1,
180   /* opus */ 0,
181   /* opusdisk_file */ NULL,
182   /* pal_tv2x */ 0,
183   /* playback_file */ NULL,
184   /* plus3_detect_speedlock */ 1,
185   /* plus3disk_file */ NULL,
186   /* plusd */ 0,
187   /* plusddisk_file */ NULL,
188   /* printer */ 0,
189   /* printer_graphics_filename */ "printout.pbm",
190   /* printer_text_filename */ "printout.txt",
191   /* raw_s_net */ 0,
192   /* record_file */ NULL,
193   /* rom_128_0 */ "128-0.rom",
194   /* rom_128_1 */ "128-1.rom",
195   /* rom_16 */ "48.rom",
196   /* rom_48 */ "48.rom",
197   /* rom_beta128 */ "trdos.rom",
198   /* rom_disciple */ "disciple.rom",
199   /* rom_interface_i */ "if1-2.rom",
200   /* rom_opus */ "opus.rom",
201   /* rom_pentagon1024_0 */ "128p-0.rom",
202   /* rom_pentagon1024_1 */ "128p-1.rom",
203   /* rom_pentagon1024_2 */ "trdos.rom",
204   /* rom_pentagon1024_3 */ "gluck.rom",
205   /* rom_pentagon512_0 */ "128p-0.rom",
206   /* rom_pentagon512_1 */ "128p-1.rom",
207   /* rom_pentagon512_2 */ "trdos.rom",
208   /* rom_pentagon512_3 */ "gluck.rom",
209   /* rom_pentagon_0 */ "128p-0.rom",
210   /* rom_pentagon_1 */ "128p-1.rom",
211   /* rom_pentagon_2 */ "trdos.rom",
212   /* rom_plus2_0 */ "plus2-0.rom",
213   /* rom_plus2_1 */ "plus2-1.rom",
214   /* rom_plus2a_0 */ "plus3-0.rom",
215   /* rom_plus2a_1 */ "plus3-1.rom",
216   /* rom_plus2a_2 */ "plus3-2.rom",
217   /* rom_plus2a_3 */ "plus3-3.rom",
218   /* rom_plus3_0 */ "plus3-0.rom",
219   /* rom_plus3_1 */ "plus3-1.rom",
220   /* rom_plus3_2 */ "plus3-2.rom",
221   /* rom_plus3_3 */ "plus3-3.rom",
222   /* rom_plus3e_0 */ "plus3e-0.rom",
223   /* rom_plus3e_1 */ "plus3e-1.rom",
224   /* rom_plus3e_2 */ "plus3e-2.rom",
225   /* rom_plus3e_3 */ "plus3e-3.rom",
226   /* rom_plusd */ "plusd.rom",
227   /* rom_scorpion_0 */ "256s-0.rom",
228   /* rom_scorpion_1 */ "256s-1.rom",
229   /* rom_scorpion_2 */ "256s-2.rom",
230   /* rom_scorpion_3 */ "256s-3.rom",
231   /* rom_spec_se_0 */ "se-0.rom",
232   /* rom_spec_se_1 */ "se-1.rom",
233   /* rom_speccyboot */ "speccyboot-1.4.rom",
234   /* rom_tc2048 */ "tc2048.rom",
235   /* rom_tc2068_0 */ "tc2068-0.rom",
236   /* rom_tc2068_1 */ "tc2068-1.rom",
237   /* rom_ts2068_0 */ "tc2068-0.rom",
238   /* rom_ts2068_1 */ "tc2068-1.rom",
239   /* rs232_handshake */ 0,
240   /* rs232_rx */ NULL,
241   /* rs232_tx */ NULL,
242   /* rzx_autosaves */ 1,
243   /* rzx_compression */ 1,
244   /* simpleide_active */ 0,
245   /* simpleide_master_file */ NULL,
246   /* simpleide_slave_file */ NULL,
247   /* slt_traps */ 1,
248   /* snapshot */ NULL,
249   /* snet */ NULL,
250   /* sound */ 1,
251   /* sound_device */ NULL,
252   /* sound_force_8bit */ 0,
253   /* sound_freq */ 32000,
254   /* sound_load */ 1,
255   /* speaker_type */ NULL,
256   /* speccyboot */ 0,
257   /* speccyboot_tap */ "tap0",
258   /* specdrum */ 0,
259   /* spectranet */ 0,
260   /* spectranet_disable */ 0,
261   /* start_machine */ "48",
262   /* start_scaler_mode */ "normal",
263   /* statusbar */ 1,
264   /* stereo_ay */ NULL,
265   /* strict_aspect_hint */ 0,
266   /* svga_modes */ NULL,
267   /* tape_file */ NULL,
268   /* tape_traps */ 1,
269   /* unittests */ 0,
270   /* volume_ay */ 100,
271   /* volume_beeper */ 100,
272   /* volume_specdrum */ 100,
273   /* writable_roms */ 0,
274   /* zxatasp_active */ 0,
275   /* zxatasp_master_file */ NULL,
276   /* zxatasp_slave_file */ NULL,
277   /* zxatasp_upload */ 0,
278   /* zxatasp_wp */ 0,
279   /* zxcf_active */ 0,
280   /* zxcf_pri_file */ NULL,
281   /* zxcf_upload */ 0,
282   /* zxprinter */ 1,
283 #line 118"../settings.pl"
284   /* show_help */ 0,
285   /* show_version */ 0,
286 };
287 
288 static int read_config_file( settings_info *settings );
289 
290 #ifdef HAVE_LIB_XML2
291 static int parse_xml( xmlDocPtr doc, settings_info *settings );
292 #else				/* #ifdef HAVE_LIB_XML2 */
293 static int parse_ini( utils_file *file, settings_info *settings );
294 #endif				/* #ifdef HAVE_LIB_XML2 */
295 
296 static int settings_command_line( settings_info *settings, int *first_arg,
297 				  int argc, char **argv );
298 
299 static void settings_copy_internal( settings_info *dest, settings_info *src );
300 
301 /* Called on emulator startup */
302 int
settings_init(int * first_arg,int argc,char ** argv)303 settings_init( int *first_arg, int argc, char **argv )
304 {
305   int error;
306 
307   settings_defaults( &settings_current );
308 
309   error = read_config_file( &settings_current );
310   if( error ) return error;
311 
312   error = settings_command_line( &settings_current, first_arg, argc, argv );
313   if( error ) return error;
314 
315   return 0;
316 }
317 
318 /* Fill the settings structure with sensible defaults */
settings_defaults(settings_info * settings)319 void settings_defaults( settings_info *settings )
320 {
321   settings_copy_internal( settings, &settings_default );
322 }
323 
324 #ifdef HAVE_LIB_XML2
325 
326 /* Read options from the config file (if libxml2 is available) */
327 
328 static int
read_config_file(settings_info * settings)329 read_config_file( settings_info *settings )
330 {
331   const char *home; char path[ PATH_MAX ];
332   struct stat stat_info;
333 
334   xmlDocPtr doc;
335 
336   home = compat_get_home_path(); if( !home ) return 1;
337 
338   snprintf( path, PATH_MAX, "%s/%s", home, CONFIG_FILE_NAME );
339 
340   /* See if the file exists; if doesn't, it's not a problem */
341   if( stat( path, &stat_info ) ) {
342     if( errno == ENOENT ) {
343       return 0;
344     } else {
345       ui_error( UI_ERROR_ERROR, "couldn't stat '%s': %s", path,
346 		strerror( errno ) );
347       return 1;
348     }
349   }
350 
351   doc = xmlParseFile( path );
352   if( !doc ) {
353     ui_error( UI_ERROR_ERROR, "error reading config file" );
354     return 1;
355   }
356 
357   if( parse_xml( doc, settings ) ) {
358     xmlFreeDoc( doc );
359     return 1;
360   }
361 
362   xmlFreeDoc( doc );
363 
364   return 0;
365 }
366 
367 static int
parse_xml(xmlDocPtr doc,settings_info * settings)368 parse_xml( xmlDocPtr doc, settings_info *settings )
369 {
370   xmlNodePtr node;
371   xmlChar *xmlstring;
372 
373   node = xmlDocGetRootElement( doc );
374   if( xmlStrcmp( node->name, (const xmlChar*)"settings" ) ) {
375     ui_error( UI_ERROR_ERROR, "config file's root node is not 'settings'" );
376     return 1;
377   }
378 
379   node = node->xmlChildrenNode;
380   while( node ) {
381 
382     if( !strcmp( (const char*)node->name, "accelerateloader" ) ) {
383       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
384       if( xmlstring ) {
385         settings->accelerate_loader = atoi( (char*)xmlstring );
386         xmlFree( xmlstring );
387       }
388     } else
389     if( !strcmp( (const char*)node->name, "aspecthint" ) ) {
390       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
391       if( xmlstring ) {
392         settings->aspect_hint = atoi( (char*)xmlstring );
393         xmlFree( xmlstring );
394       }
395     } else
396     if( !strcmp( (const char*)node->name, "autoload" ) ) {
397       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
398       if( xmlstring ) {
399         settings->auto_load = atoi( (char*)xmlstring );
400         xmlFree( xmlstring );
401       }
402     } else
403     if( !strcmp( (const char*)node->name, "autosavesettings" ) ) {
404       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
405       if( xmlstring ) {
406         settings->autosave_settings = atoi( (char*)xmlstring );
407         xmlFree( xmlstring );
408       }
409     } else
410     if( !strcmp( (const char*)node->name, "beta128" ) ) {
411       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
412       if( xmlstring ) {
413         settings->beta128 = atoi( (char*)xmlstring );
414         xmlFree( xmlstring );
415       }
416     } else
417     if( !strcmp( (const char*)node->name, "beta12848boot" ) ) {
418       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
419       if( xmlstring ) {
420         settings->beta128_48boot = atoi( (char*)xmlstring );
421         xmlFree( xmlstring );
422       }
423     } else
424     if( !strcmp( (const char*)node->name, "betadisk" ) ) {
425       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
426       if( xmlstring ) {
427         libspectrum_free( settings->betadisk_file );
428         settings->betadisk_file = utils_safe_strdup( (char*)xmlstring );
429         xmlFree( xmlstring );
430       }
431     } else
432     if( !strcmp( (const char*)node->name, "bwtv" ) ) {
433       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
434       if( xmlstring ) {
435         settings->bw_tv = atoi( (char*)xmlstring );
436         xmlFree( xmlstring );
437       }
438     } else
439     if( !strcmp( (const char*)node->name, "competitioncode" ) ) {
440       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
441       if( xmlstring ) {
442         settings->competition_code = atoi( (char*)xmlstring );
443         xmlFree( xmlstring );
444       }
445     } else
446     if( !strcmp( (const char*)node->name, "competitionmode" ) ) {
447       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
448       if( xmlstring ) {
449         settings->competition_mode = atoi( (char*)xmlstring );
450         xmlFree( xmlstring );
451       }
452     } else
453     if( !strcmp( (const char*)node->name, "confirmactions" ) ) {
454       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
455       if( xmlstring ) {
456         settings->confirm_actions = atoi( (char*)xmlstring );
457         xmlFree( xmlstring );
458       }
459     } else
460     if( !strcmp( (const char*)node->name, "dock" ) ) {
461       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
462       if( xmlstring ) {
463         libspectrum_free( settings->dck_file );
464         settings->dck_file = utils_safe_strdup( (char*)xmlstring );
465         xmlFree( xmlstring );
466       }
467     } else
468     if( !strcmp( (const char*)node->name, "debuggercommand" ) ) {
469       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
470       if( xmlstring ) {
471         libspectrum_free( settings->debugger_command );
472         settings->debugger_command = utils_safe_strdup( (char*)xmlstring );
473         xmlFree( xmlstring );
474       }
475     } else
476     if( !strcmp( (const char*)node->name, "detectloader" ) ) {
477       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
478       if( xmlstring ) {
479         settings->detect_loader = atoi( (char*)xmlstring );
480         xmlFree( xmlstring );
481       }
482     } else
483     if( !strcmp( (const char*)node->name, "disciple" ) ) {
484       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
485       if( xmlstring ) {
486         settings->disciple = atoi( (char*)xmlstring );
487         xmlFree( xmlstring );
488       }
489     } else
490     if( !strcmp( (const char*)node->name, "discipledisk" ) ) {
491       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
492       if( xmlstring ) {
493         libspectrum_free( settings->discipledisk_file );
494         settings->discipledisk_file = utils_safe_strdup( (char*)xmlstring );
495         xmlFree( xmlstring );
496       }
497     } else
498     if( !strcmp( (const char*)node->name, "diskaskmerge" ) ) {
499       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
500       if( xmlstring ) {
501         settings->disk_ask_merge = atoi( (char*)xmlstring );
502         xmlFree( xmlstring );
503       }
504     } else
505     if( !strcmp( (const char*)node->name, "disktrymerge" ) ) {
506       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
507       if( xmlstring ) {
508         libspectrum_free( settings->disk_try_merge );
509         settings->disk_try_merge = utils_safe_strdup( (char*)xmlstring );
510         xmlFree( xmlstring );
511       }
512     } else
513     if( !strcmp( (const char*)node->name, "divide" ) ) {
514       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
515       if( xmlstring ) {
516         settings->divide_enabled = atoi( (char*)xmlstring );
517         xmlFree( xmlstring );
518       }
519     } else
520     if( !strcmp( (const char*)node->name, "dividemasterfile" ) ) {
521       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
522       if( xmlstring ) {
523         libspectrum_free( settings->divide_master_file );
524         settings->divide_master_file = utils_safe_strdup( (char*)xmlstring );
525         xmlFree( xmlstring );
526       }
527     } else
528     if( !strcmp( (const char*)node->name, "divideslavefile" ) ) {
529       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
530       if( xmlstring ) {
531         libspectrum_free( settings->divide_slave_file );
532         settings->divide_slave_file = utils_safe_strdup( (char*)xmlstring );
533         xmlFree( xmlstring );
534       }
535     } else
536     if( !strcmp( (const char*)node->name, "dividewriteprotect" ) ) {
537       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
538       if( xmlstring ) {
539         settings->divide_wp = atoi( (char*)xmlstring );
540         xmlFree( xmlstring );
541       }
542     } else
543     if( !strcmp( (const char*)node->name, "doublescreen" ) ) {
544       /* Do nothing */
545     } else
546     if( !strcmp( (const char*)node->name, "doublescanmode" ) ) {
547       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
548       if( xmlstring ) {
549         settings->doublescan_mode = atoi( (char*)xmlstring );
550         xmlFree( xmlstring );
551       }
552     } else
553     if( !strcmp( (const char*)node->name, "drive40maxtrack" ) ) {
554       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
555       if( xmlstring ) {
556         settings->drive_40_max_track = atoi( (char*)xmlstring );
557         xmlFree( xmlstring );
558       }
559     } else
560     if( !strcmp( (const char*)node->name, "drive80maxtrack" ) ) {
561       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
562       if( xmlstring ) {
563         settings->drive_80_max_track = atoi( (char*)xmlstring );
564         xmlFree( xmlstring );
565       }
566     } else
567     if( !strcmp( (const char*)node->name, "drivebeta128atype" ) ) {
568       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
569       if( xmlstring ) {
570         libspectrum_free( settings->drive_beta128a_type );
571         settings->drive_beta128a_type = utils_safe_strdup( (char*)xmlstring );
572         xmlFree( xmlstring );
573       }
574     } else
575     if( !strcmp( (const char*)node->name, "drivebeta128btype" ) ) {
576       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
577       if( xmlstring ) {
578         libspectrum_free( settings->drive_beta128b_type );
579         settings->drive_beta128b_type = utils_safe_strdup( (char*)xmlstring );
580         xmlFree( xmlstring );
581       }
582     } else
583     if( !strcmp( (const char*)node->name, "drivebeta128ctype" ) ) {
584       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
585       if( xmlstring ) {
586         libspectrum_free( settings->drive_beta128c_type );
587         settings->drive_beta128c_type = utils_safe_strdup( (char*)xmlstring );
588         xmlFree( xmlstring );
589       }
590     } else
591     if( !strcmp( (const char*)node->name, "drivebeta128dtype" ) ) {
592       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
593       if( xmlstring ) {
594         libspectrum_free( settings->drive_beta128d_type );
595         settings->drive_beta128d_type = utils_safe_strdup( (char*)xmlstring );
596         xmlFree( xmlstring );
597       }
598     } else
599     if( !strcmp( (const char*)node->name, "drivedisciple1type" ) ) {
600       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
601       if( xmlstring ) {
602         libspectrum_free( settings->drive_disciple1_type );
603         settings->drive_disciple1_type = utils_safe_strdup( (char*)xmlstring );
604         xmlFree( xmlstring );
605       }
606     } else
607     if( !strcmp( (const char*)node->name, "drivedisciple2type" ) ) {
608       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
609       if( xmlstring ) {
610         libspectrum_free( settings->drive_disciple2_type );
611         settings->drive_disciple2_type = utils_safe_strdup( (char*)xmlstring );
612         xmlFree( xmlstring );
613       }
614     } else
615     if( !strcmp( (const char*)node->name, "driveopus1type" ) ) {
616       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
617       if( xmlstring ) {
618         libspectrum_free( settings->drive_opus1_type );
619         settings->drive_opus1_type = utils_safe_strdup( (char*)xmlstring );
620         xmlFree( xmlstring );
621       }
622     } else
623     if( !strcmp( (const char*)node->name, "driveopus2type" ) ) {
624       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
625       if( xmlstring ) {
626         libspectrum_free( settings->drive_opus2_type );
627         settings->drive_opus2_type = utils_safe_strdup( (char*)xmlstring );
628         xmlFree( xmlstring );
629       }
630     } else
631     if( !strcmp( (const char*)node->name, "driveplus3atype" ) ) {
632       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
633       if( xmlstring ) {
634         libspectrum_free( settings->drive_plus3a_type );
635         settings->drive_plus3a_type = utils_safe_strdup( (char*)xmlstring );
636         xmlFree( xmlstring );
637       }
638     } else
639     if( !strcmp( (const char*)node->name, "driveplus3btype" ) ) {
640       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
641       if( xmlstring ) {
642         libspectrum_free( settings->drive_plus3b_type );
643         settings->drive_plus3b_type = utils_safe_strdup( (char*)xmlstring );
644         xmlFree( xmlstring );
645       }
646     } else
647     if( !strcmp( (const char*)node->name, "driveplusd1type" ) ) {
648       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
649       if( xmlstring ) {
650         libspectrum_free( settings->drive_plusd1_type );
651         settings->drive_plusd1_type = utils_safe_strdup( (char*)xmlstring );
652         xmlFree( xmlstring );
653       }
654     } else
655     if( !strcmp( (const char*)node->name, "driveplusd2type" ) ) {
656       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
657       if( xmlstring ) {
658         libspectrum_free( settings->drive_plusd2_type );
659         settings->drive_plusd2_type = utils_safe_strdup( (char*)xmlstring );
660         xmlFree( xmlstring );
661       }
662     } else
663     if( !strcmp( (const char*)node->name, "embedsnapshot" ) ) {
664       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
665       if( xmlstring ) {
666         settings->embed_snapshot = atoi( (char*)xmlstring );
667         xmlFree( xmlstring );
668       }
669     } else
670     if( !strcmp( (const char*)node->name, "speed" ) ) {
671       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
672       if( xmlstring ) {
673         settings->emulation_speed = atoi( (char*)xmlstring );
674         xmlFree( xmlstring );
675       }
676     } else
677     if( !strcmp( (const char*)node->name, "fastload" ) ) {
678       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
679       if( xmlstring ) {
680         settings->fastload = atoi( (char*)xmlstring );
681         xmlFree( xmlstring );
682       }
683     } else
684     if( !strcmp( (const char*)node->name, "fbmode" ) ) {
685       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
686       if( xmlstring ) {
687         settings->fb_mode = atoi( (char*)xmlstring );
688         xmlFree( xmlstring );
689       }
690     } else
691     if( !strcmp( (const char*)node->name, "rate" ) ) {
692       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
693       if( xmlstring ) {
694         settings->frame_rate = atoi( (char*)xmlstring );
695         xmlFree( xmlstring );
696       }
697     } else
698     if( !strcmp( (const char*)node->name, "fullscreen" ) ) {
699       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
700       if( xmlstring ) {
701         settings->full_screen = atoi( (char*)xmlstring );
702         xmlFree( xmlstring );
703       }
704     } else
705     if( !strcmp( (const char*)node->name, "fuller" ) ) {
706       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
707       if( xmlstring ) {
708         settings->fuller = atoi( (char*)xmlstring );
709         xmlFree( xmlstring );
710       }
711     } else
712     if( !strcmp( (const char*)node->name, "if2cart" ) ) {
713       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
714       if( xmlstring ) {
715         libspectrum_free( settings->if2_file );
716         settings->if2_file = utils_safe_strdup( (char*)xmlstring );
717         xmlFree( xmlstring );
718       }
719     } else
720     if( !strcmp( (const char*)node->name, "interface1" ) ) {
721       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
722       if( xmlstring ) {
723         settings->interface1 = atoi( (char*)xmlstring );
724         xmlFree( xmlstring );
725       }
726     } else
727     if( !strcmp( (const char*)node->name, "interface2" ) ) {
728       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
729       if( xmlstring ) {
730         settings->interface2 = atoi( (char*)xmlstring );
731         xmlFree( xmlstring );
732       }
733     } else
734     if( !strcmp( (const char*)node->name, "issue2" ) ) {
735       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
736       if( xmlstring ) {
737         settings->issue2 = atoi( (char*)xmlstring );
738         xmlFree( xmlstring );
739       }
740     } else
741     if( !strcmp( (const char*)node->name, "kempston" ) ) {
742       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
743       if( xmlstring ) {
744         settings->joy_kempston = atoi( (char*)xmlstring );
745         xmlFree( xmlstring );
746       }
747     } else
748     if( !strcmp( (const char*)node->name, "joystickprompt" ) ) {
749       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
750       if( xmlstring ) {
751         settings->joy_prompt = atoi( (char*)xmlstring );
752         xmlFree( xmlstring );
753       }
754     } else
755     if( !strcmp( (const char*)node->name, "joystick1" ) ) {
756       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
757       if( xmlstring ) {
758         libspectrum_free( settings->joystick_1 );
759         settings->joystick_1 = utils_safe_strdup( (char*)xmlstring );
760         xmlFree( xmlstring );
761       }
762     } else
763     if( !strcmp( (const char*)node->name, "joystick1fire1" ) ) {
764       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
765       if( xmlstring ) {
766         settings->joystick_1_fire_1 = atoi( (char*)xmlstring );
767         xmlFree( xmlstring );
768       }
769     } else
770     if( !strcmp( (const char*)node->name, "joystick1fire10" ) ) {
771       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
772       if( xmlstring ) {
773         settings->joystick_1_fire_10 = atoi( (char*)xmlstring );
774         xmlFree( xmlstring );
775       }
776     } else
777     if( !strcmp( (const char*)node->name, "joystick1fire11" ) ) {
778       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
779       if( xmlstring ) {
780         settings->joystick_1_fire_11 = atoi( (char*)xmlstring );
781         xmlFree( xmlstring );
782       }
783     } else
784     if( !strcmp( (const char*)node->name, "joystick1fire12" ) ) {
785       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
786       if( xmlstring ) {
787         settings->joystick_1_fire_12 = atoi( (char*)xmlstring );
788         xmlFree( xmlstring );
789       }
790     } else
791     if( !strcmp( (const char*)node->name, "joystick1fire13" ) ) {
792       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
793       if( xmlstring ) {
794         settings->joystick_1_fire_13 = atoi( (char*)xmlstring );
795         xmlFree( xmlstring );
796       }
797     } else
798     if( !strcmp( (const char*)node->name, "joystick1fire14" ) ) {
799       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
800       if( xmlstring ) {
801         settings->joystick_1_fire_14 = atoi( (char*)xmlstring );
802         xmlFree( xmlstring );
803       }
804     } else
805     if( !strcmp( (const char*)node->name, "joystick1fire15" ) ) {
806       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
807       if( xmlstring ) {
808         settings->joystick_1_fire_15 = atoi( (char*)xmlstring );
809         xmlFree( xmlstring );
810       }
811     } else
812     if( !strcmp( (const char*)node->name, "joystick1fire2" ) ) {
813       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
814       if( xmlstring ) {
815         settings->joystick_1_fire_2 = atoi( (char*)xmlstring );
816         xmlFree( xmlstring );
817       }
818     } else
819     if( !strcmp( (const char*)node->name, "joystick1fire3" ) ) {
820       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
821       if( xmlstring ) {
822         settings->joystick_1_fire_3 = atoi( (char*)xmlstring );
823         xmlFree( xmlstring );
824       }
825     } else
826     if( !strcmp( (const char*)node->name, "joystick1fire4" ) ) {
827       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
828       if( xmlstring ) {
829         settings->joystick_1_fire_4 = atoi( (char*)xmlstring );
830         xmlFree( xmlstring );
831       }
832     } else
833     if( !strcmp( (const char*)node->name, "joystick1fire5" ) ) {
834       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
835       if( xmlstring ) {
836         settings->joystick_1_fire_5 = atoi( (char*)xmlstring );
837         xmlFree( xmlstring );
838       }
839     } else
840     if( !strcmp( (const char*)node->name, "joystick1fire6" ) ) {
841       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
842       if( xmlstring ) {
843         settings->joystick_1_fire_6 = atoi( (char*)xmlstring );
844         xmlFree( xmlstring );
845       }
846     } else
847     if( !strcmp( (const char*)node->name, "joystick1fire7" ) ) {
848       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
849       if( xmlstring ) {
850         settings->joystick_1_fire_7 = atoi( (char*)xmlstring );
851         xmlFree( xmlstring );
852       }
853     } else
854     if( !strcmp( (const char*)node->name, "joystick1fire8" ) ) {
855       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
856       if( xmlstring ) {
857         settings->joystick_1_fire_8 = atoi( (char*)xmlstring );
858         xmlFree( xmlstring );
859       }
860     } else
861     if( !strcmp( (const char*)node->name, "joystick1fire9" ) ) {
862       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
863       if( xmlstring ) {
864         settings->joystick_1_fire_9 = atoi( (char*)xmlstring );
865         xmlFree( xmlstring );
866       }
867     } else
868     if( !strcmp( (const char*)node->name, "joystick1output" ) ) {
869       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
870       if( xmlstring ) {
871         settings->joystick_1_output = atoi( (char*)xmlstring );
872         xmlFree( xmlstring );
873       }
874     } else
875     if( !strcmp( (const char*)node->name, "joystick2" ) ) {
876       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
877       if( xmlstring ) {
878         libspectrum_free( settings->joystick_2 );
879         settings->joystick_2 = utils_safe_strdup( (char*)xmlstring );
880         xmlFree( xmlstring );
881       }
882     } else
883     if( !strcmp( (const char*)node->name, "joystick2fire1" ) ) {
884       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
885       if( xmlstring ) {
886         settings->joystick_2_fire_1 = atoi( (char*)xmlstring );
887         xmlFree( xmlstring );
888       }
889     } else
890     if( !strcmp( (const char*)node->name, "joystick2fire10" ) ) {
891       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
892       if( xmlstring ) {
893         settings->joystick_2_fire_10 = atoi( (char*)xmlstring );
894         xmlFree( xmlstring );
895       }
896     } else
897     if( !strcmp( (const char*)node->name, "joystick2fire11" ) ) {
898       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
899       if( xmlstring ) {
900         settings->joystick_2_fire_11 = atoi( (char*)xmlstring );
901         xmlFree( xmlstring );
902       }
903     } else
904     if( !strcmp( (const char*)node->name, "joystick2fire12" ) ) {
905       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
906       if( xmlstring ) {
907         settings->joystick_2_fire_12 = atoi( (char*)xmlstring );
908         xmlFree( xmlstring );
909       }
910     } else
911     if( !strcmp( (const char*)node->name, "joystick2fire13" ) ) {
912       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
913       if( xmlstring ) {
914         settings->joystick_2_fire_13 = atoi( (char*)xmlstring );
915         xmlFree( xmlstring );
916       }
917     } else
918     if( !strcmp( (const char*)node->name, "joystick2fire14" ) ) {
919       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
920       if( xmlstring ) {
921         settings->joystick_2_fire_14 = atoi( (char*)xmlstring );
922         xmlFree( xmlstring );
923       }
924     } else
925     if( !strcmp( (const char*)node->name, "joystick2fire15" ) ) {
926       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
927       if( xmlstring ) {
928         settings->joystick_2_fire_15 = atoi( (char*)xmlstring );
929         xmlFree( xmlstring );
930       }
931     } else
932     if( !strcmp( (const char*)node->name, "joystick2fire2" ) ) {
933       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
934       if( xmlstring ) {
935         settings->joystick_2_fire_2 = atoi( (char*)xmlstring );
936         xmlFree( xmlstring );
937       }
938     } else
939     if( !strcmp( (const char*)node->name, "joystick2fire3" ) ) {
940       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
941       if( xmlstring ) {
942         settings->joystick_2_fire_3 = atoi( (char*)xmlstring );
943         xmlFree( xmlstring );
944       }
945     } else
946     if( !strcmp( (const char*)node->name, "joystick2fire4" ) ) {
947       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
948       if( xmlstring ) {
949         settings->joystick_2_fire_4 = atoi( (char*)xmlstring );
950         xmlFree( xmlstring );
951       }
952     } else
953     if( !strcmp( (const char*)node->name, "joystick2fire5" ) ) {
954       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
955       if( xmlstring ) {
956         settings->joystick_2_fire_5 = atoi( (char*)xmlstring );
957         xmlFree( xmlstring );
958       }
959     } else
960     if( !strcmp( (const char*)node->name, "joystick2fire6" ) ) {
961       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
962       if( xmlstring ) {
963         settings->joystick_2_fire_6 = atoi( (char*)xmlstring );
964         xmlFree( xmlstring );
965       }
966     } else
967     if( !strcmp( (const char*)node->name, "joystick2fire7" ) ) {
968       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
969       if( xmlstring ) {
970         settings->joystick_2_fire_7 = atoi( (char*)xmlstring );
971         xmlFree( xmlstring );
972       }
973     } else
974     if( !strcmp( (const char*)node->name, "joystick2fire8" ) ) {
975       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
976       if( xmlstring ) {
977         settings->joystick_2_fire_8 = atoi( (char*)xmlstring );
978         xmlFree( xmlstring );
979       }
980     } else
981     if( !strcmp( (const char*)node->name, "joystick2fire9" ) ) {
982       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
983       if( xmlstring ) {
984         settings->joystick_2_fire_9 = atoi( (char*)xmlstring );
985         xmlFree( xmlstring );
986       }
987     } else
988     if( !strcmp( (const char*)node->name, "joystick2output" ) ) {
989       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
990       if( xmlstring ) {
991         settings->joystick_2_output = atoi( (char*)xmlstring );
992         xmlFree( xmlstring );
993       }
994     } else
995     if( !strcmp( (const char*)node->name, "joystickkeyboarddown" ) ) {
996       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
997       if( xmlstring ) {
998         settings->joystick_keyboard_down = atoi( (char*)xmlstring );
999         xmlFree( xmlstring );
1000       }
1001     } else
1002     if( !strcmp( (const char*)node->name, "joystickkeyboardfire" ) ) {
1003       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1004       if( xmlstring ) {
1005         settings->joystick_keyboard_fire = atoi( (char*)xmlstring );
1006         xmlFree( xmlstring );
1007       }
1008     } else
1009     if( !strcmp( (const char*)node->name, "joystickkeyboardleft" ) ) {
1010       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1011       if( xmlstring ) {
1012         settings->joystick_keyboard_left = atoi( (char*)xmlstring );
1013         xmlFree( xmlstring );
1014       }
1015     } else
1016     if( !strcmp( (const char*)node->name, "joystickkeyboardoutput" ) ) {
1017       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1018       if( xmlstring ) {
1019         settings->joystick_keyboard_output = atoi( (char*)xmlstring );
1020         xmlFree( xmlstring );
1021       }
1022     } else
1023     if( !strcmp( (const char*)node->name, "joystickkeyboardright" ) ) {
1024       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1025       if( xmlstring ) {
1026         settings->joystick_keyboard_right = atoi( (char*)xmlstring );
1027         xmlFree( xmlstring );
1028       }
1029     } else
1030     if( !strcmp( (const char*)node->name, "joystickkeyboardup" ) ) {
1031       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1032       if( xmlstring ) {
1033         settings->joystick_keyboard_up = atoi( (char*)xmlstring );
1034         xmlFree( xmlstring );
1035       }
1036     } else
1037     if( !strcmp( (const char*)node->name, "kempstonmouse" ) ) {
1038       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1039       if( xmlstring ) {
1040         settings->kempston_mouse = atoi( (char*)xmlstring );
1041         xmlFree( xmlstring );
1042       }
1043     } else
1044     if( !strcmp( (const char*)node->name, "latetimings" ) ) {
1045       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1046       if( xmlstring ) {
1047         settings->late_timings = atoi( (char*)xmlstring );
1048         xmlFree( xmlstring );
1049       }
1050     } else
1051     if( !strcmp( (const char*)node->name, "microdrivefile" ) ) {
1052       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1053       if( xmlstring ) {
1054         libspectrum_free( settings->mdr_file );
1055         settings->mdr_file = utils_safe_strdup( (char*)xmlstring );
1056         xmlFree( xmlstring );
1057       }
1058     } else
1059     if( !strcmp( (const char*)node->name, "microdrive2file" ) ) {
1060       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1061       if( xmlstring ) {
1062         libspectrum_free( settings->mdr_file2 );
1063         settings->mdr_file2 = utils_safe_strdup( (char*)xmlstring );
1064         xmlFree( xmlstring );
1065       }
1066     } else
1067     if( !strcmp( (const char*)node->name, "microdrive3file" ) ) {
1068       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1069       if( xmlstring ) {
1070         libspectrum_free( settings->mdr_file3 );
1071         settings->mdr_file3 = utils_safe_strdup( (char*)xmlstring );
1072         xmlFree( xmlstring );
1073       }
1074     } else
1075     if( !strcmp( (const char*)node->name, "microdrive4file" ) ) {
1076       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1077       if( xmlstring ) {
1078         libspectrum_free( settings->mdr_file4 );
1079         settings->mdr_file4 = utils_safe_strdup( (char*)xmlstring );
1080         xmlFree( xmlstring );
1081       }
1082     } else
1083     if( !strcmp( (const char*)node->name, "microdrive5file" ) ) {
1084       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1085       if( xmlstring ) {
1086         libspectrum_free( settings->mdr_file5 );
1087         settings->mdr_file5 = utils_safe_strdup( (char*)xmlstring );
1088         xmlFree( xmlstring );
1089       }
1090     } else
1091     if( !strcmp( (const char*)node->name, "microdrive6file" ) ) {
1092       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1093       if( xmlstring ) {
1094         libspectrum_free( settings->mdr_file6 );
1095         settings->mdr_file6 = utils_safe_strdup( (char*)xmlstring );
1096         xmlFree( xmlstring );
1097       }
1098     } else
1099     if( !strcmp( (const char*)node->name, "microdrive7file" ) ) {
1100       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1101       if( xmlstring ) {
1102         libspectrum_free( settings->mdr_file7 );
1103         settings->mdr_file7 = utils_safe_strdup( (char*)xmlstring );
1104         xmlFree( xmlstring );
1105       }
1106     } else
1107     if( !strcmp( (const char*)node->name, "microdrive8file" ) ) {
1108       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1109       if( xmlstring ) {
1110         libspectrum_free( settings->mdr_file8 );
1111         settings->mdr_file8 = utils_safe_strdup( (char*)xmlstring );
1112         xmlFree( xmlstring );
1113       }
1114     } else
1115     if( !strcmp( (const char*)node->name, "mdrlen" ) ) {
1116       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1117       if( xmlstring ) {
1118         settings->mdr_len = atoi( (char*)xmlstring );
1119         xmlFree( xmlstring );
1120       }
1121     } else
1122     if( !strcmp( (const char*)node->name, "mdrrandomlen" ) ) {
1123       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1124       if( xmlstring ) {
1125         settings->mdr_random_len = atoi( (char*)xmlstring );
1126         xmlFree( xmlstring );
1127       }
1128     } else
1129     if( !strcmp( (const char*)node->name, "melodik" ) ) {
1130       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1131       if( xmlstring ) {
1132         settings->melodik = atoi( (char*)xmlstring );
1133         xmlFree( xmlstring );
1134       }
1135     } else
1136     if( !strcmp( (const char*)node->name, "mouseswapbuttons" ) ) {
1137       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1138       if( xmlstring ) {
1139         settings->mouse_swap_buttons = atoi( (char*)xmlstring );
1140         xmlFree( xmlstring );
1141       }
1142     } else
1143     if( !strcmp( (const char*)node->name, "moviecompr" ) ) {
1144       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1145       if( xmlstring ) {
1146         libspectrum_free( settings->movie_compr );
1147         settings->movie_compr = utils_safe_strdup( (char*)xmlstring );
1148         xmlFree( xmlstring );
1149       }
1150     } else
1151     if( !strcmp( (const char*)node->name, "moviestart" ) ) {
1152       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1153       if( xmlstring ) {
1154         libspectrum_free( settings->movie_start );
1155         settings->movie_start = utils_safe_strdup( (char*)xmlstring );
1156         xmlFree( xmlstring );
1157       }
1158     } else
1159     if( !strcmp( (const char*)node->name, "moviestopafterrzx" ) ) {
1160       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1161       if( xmlstring ) {
1162         settings->movie_stop_after_rzx = atoi( (char*)xmlstring );
1163         xmlFree( xmlstring );
1164       }
1165     } else
1166     if( !strcmp( (const char*)node->name, "opus" ) ) {
1167       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1168       if( xmlstring ) {
1169         settings->opus = atoi( (char*)xmlstring );
1170         xmlFree( xmlstring );
1171       }
1172     } else
1173     if( !strcmp( (const char*)node->name, "opusdisk" ) ) {
1174       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1175       if( xmlstring ) {
1176         libspectrum_free( settings->opusdisk_file );
1177         settings->opusdisk_file = utils_safe_strdup( (char*)xmlstring );
1178         xmlFree( xmlstring );
1179       }
1180     } else
1181     if( !strcmp( (const char*)node->name, "paltv2x" ) ) {
1182       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1183       if( xmlstring ) {
1184         settings->pal_tv2x = atoi( (char*)xmlstring );
1185         xmlFree( xmlstring );
1186       }
1187     } else
1188     if( !strcmp( (const char*)node->name, "playbackfile" ) ) {
1189       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1190       if( xmlstring ) {
1191         libspectrum_free( settings->playback_file );
1192         settings->playback_file = utils_safe_strdup( (char*)xmlstring );
1193         xmlFree( xmlstring );
1194       }
1195     } else
1196     if( !strcmp( (const char*)node->name, "plus3detectspeedlock" ) ) {
1197       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1198       if( xmlstring ) {
1199         settings->plus3_detect_speedlock = atoi( (char*)xmlstring );
1200         xmlFree( xmlstring );
1201       }
1202     } else
1203     if( !strcmp( (const char*)node->name, "plus3disk" ) ) {
1204       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1205       if( xmlstring ) {
1206         libspectrum_free( settings->plus3disk_file );
1207         settings->plus3disk_file = utils_safe_strdup( (char*)xmlstring );
1208         xmlFree( xmlstring );
1209       }
1210     } else
1211     if( !strcmp( (const char*)node->name, "plusd" ) ) {
1212       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1213       if( xmlstring ) {
1214         settings->plusd = atoi( (char*)xmlstring );
1215         xmlFree( xmlstring );
1216       }
1217     } else
1218     if( !strcmp( (const char*)node->name, "plusddisk" ) ) {
1219       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1220       if( xmlstring ) {
1221         libspectrum_free( settings->plusddisk_file );
1222         settings->plusddisk_file = utils_safe_strdup( (char*)xmlstring );
1223         xmlFree( xmlstring );
1224       }
1225     } else
1226     if( !strcmp( (const char*)node->name, "printer" ) ) {
1227       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1228       if( xmlstring ) {
1229         settings->printer = atoi( (char*)xmlstring );
1230         xmlFree( xmlstring );
1231       }
1232     } else
1233     if( !strcmp( (const char*)node->name, "graphicsfile" ) ) {
1234       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1235       if( xmlstring ) {
1236         libspectrum_free( settings->printer_graphics_filename );
1237         settings->printer_graphics_filename = utils_safe_strdup( (char*)xmlstring );
1238         xmlFree( xmlstring );
1239       }
1240     } else
1241     if( !strcmp( (const char*)node->name, "textfile" ) ) {
1242       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1243       if( xmlstring ) {
1244         libspectrum_free( settings->printer_text_filename );
1245         settings->printer_text_filename = utils_safe_strdup( (char*)xmlstring );
1246         xmlFree( xmlstring );
1247       }
1248     } else
1249     if( !strcmp( (const char*)node->name, "rawrs232" ) ) {
1250       /* Do nothing */
1251     } else
1252     if( !strcmp( (const char*)node->name, "rawsnet" ) ) {
1253       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1254       if( xmlstring ) {
1255         settings->raw_s_net = atoi( (char*)xmlstring );
1256         xmlFree( xmlstring );
1257       }
1258     } else
1259     if( !strcmp( (const char*)node->name, "recordfile" ) ) {
1260       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1261       if( xmlstring ) {
1262         libspectrum_free( settings->record_file );
1263         settings->record_file = utils_safe_strdup( (char*)xmlstring );
1264         xmlFree( xmlstring );
1265       }
1266     } else
1267     if( !strcmp( (const char*)node->name, "rom1280" ) ) {
1268       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1269       if( xmlstring ) {
1270         libspectrum_free( settings->rom_128_0 );
1271         settings->rom_128_0 = utils_safe_strdup( (char*)xmlstring );
1272         xmlFree( xmlstring );
1273       }
1274     } else
1275     if( !strcmp( (const char*)node->name, "rom1281" ) ) {
1276       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1277       if( xmlstring ) {
1278         libspectrum_free( settings->rom_128_1 );
1279         settings->rom_128_1 = utils_safe_strdup( (char*)xmlstring );
1280         xmlFree( xmlstring );
1281       }
1282     } else
1283     if( !strcmp( (const char*)node->name, "rom16" ) ) {
1284       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1285       if( xmlstring ) {
1286         libspectrum_free( settings->rom_16 );
1287         settings->rom_16 = utils_safe_strdup( (char*)xmlstring );
1288         xmlFree( xmlstring );
1289       }
1290     } else
1291     if( !strcmp( (const char*)node->name, "rom48" ) ) {
1292       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1293       if( xmlstring ) {
1294         libspectrum_free( settings->rom_48 );
1295         settings->rom_48 = utils_safe_strdup( (char*)xmlstring );
1296         xmlFree( xmlstring );
1297       }
1298     } else
1299     if( !strcmp( (const char*)node->name, "rombeta128" ) ) {
1300       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1301       if( xmlstring ) {
1302         libspectrum_free( settings->rom_beta128 );
1303         settings->rom_beta128 = utils_safe_strdup( (char*)xmlstring );
1304         xmlFree( xmlstring );
1305       }
1306     } else
1307     if( !strcmp( (const char*)node->name, "romdisciple" ) ) {
1308       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1309       if( xmlstring ) {
1310         libspectrum_free( settings->rom_disciple );
1311         settings->rom_disciple = utils_safe_strdup( (char*)xmlstring );
1312         xmlFree( xmlstring );
1313       }
1314     } else
1315     if( !strcmp( (const char*)node->name, "rominterfacei" ) ) {
1316       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1317       if( xmlstring ) {
1318         libspectrum_free( settings->rom_interface_i );
1319         settings->rom_interface_i = utils_safe_strdup( (char*)xmlstring );
1320         xmlFree( xmlstring );
1321       }
1322     } else
1323     if( !strcmp( (const char*)node->name, "romopus" ) ) {
1324       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1325       if( xmlstring ) {
1326         libspectrum_free( settings->rom_opus );
1327         settings->rom_opus = utils_safe_strdup( (char*)xmlstring );
1328         xmlFree( xmlstring );
1329       }
1330     } else
1331     if( !strcmp( (const char*)node->name, "rompentagon10240" ) ) {
1332       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1333       if( xmlstring ) {
1334         libspectrum_free( settings->rom_pentagon1024_0 );
1335         settings->rom_pentagon1024_0 = utils_safe_strdup( (char*)xmlstring );
1336         xmlFree( xmlstring );
1337       }
1338     } else
1339     if( !strcmp( (const char*)node->name, "rompentagon10241" ) ) {
1340       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1341       if( xmlstring ) {
1342         libspectrum_free( settings->rom_pentagon1024_1 );
1343         settings->rom_pentagon1024_1 = utils_safe_strdup( (char*)xmlstring );
1344         xmlFree( xmlstring );
1345       }
1346     } else
1347     if( !strcmp( (const char*)node->name, "rompentagon10242" ) ) {
1348       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1349       if( xmlstring ) {
1350         libspectrum_free( settings->rom_pentagon1024_2 );
1351         settings->rom_pentagon1024_2 = utils_safe_strdup( (char*)xmlstring );
1352         xmlFree( xmlstring );
1353       }
1354     } else
1355     if( !strcmp( (const char*)node->name, "rompentagon10243" ) ) {
1356       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1357       if( xmlstring ) {
1358         libspectrum_free( settings->rom_pentagon1024_3 );
1359         settings->rom_pentagon1024_3 = utils_safe_strdup( (char*)xmlstring );
1360         xmlFree( xmlstring );
1361       }
1362     } else
1363     if( !strcmp( (const char*)node->name, "rompentagon5120" ) ) {
1364       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1365       if( xmlstring ) {
1366         libspectrum_free( settings->rom_pentagon512_0 );
1367         settings->rom_pentagon512_0 = utils_safe_strdup( (char*)xmlstring );
1368         xmlFree( xmlstring );
1369       }
1370     } else
1371     if( !strcmp( (const char*)node->name, "rompentagon5121" ) ) {
1372       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1373       if( xmlstring ) {
1374         libspectrum_free( settings->rom_pentagon512_1 );
1375         settings->rom_pentagon512_1 = utils_safe_strdup( (char*)xmlstring );
1376         xmlFree( xmlstring );
1377       }
1378     } else
1379     if( !strcmp( (const char*)node->name, "rompentagon5122" ) ) {
1380       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1381       if( xmlstring ) {
1382         libspectrum_free( settings->rom_pentagon512_2 );
1383         settings->rom_pentagon512_2 = utils_safe_strdup( (char*)xmlstring );
1384         xmlFree( xmlstring );
1385       }
1386     } else
1387     if( !strcmp( (const char*)node->name, "rompentagon5123" ) ) {
1388       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1389       if( xmlstring ) {
1390         libspectrum_free( settings->rom_pentagon512_3 );
1391         settings->rom_pentagon512_3 = utils_safe_strdup( (char*)xmlstring );
1392         xmlFree( xmlstring );
1393       }
1394     } else
1395     if( !strcmp( (const char*)node->name, "rompentagon0" ) ) {
1396       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1397       if( xmlstring ) {
1398         libspectrum_free( settings->rom_pentagon_0 );
1399         settings->rom_pentagon_0 = utils_safe_strdup( (char*)xmlstring );
1400         xmlFree( xmlstring );
1401       }
1402     } else
1403     if( !strcmp( (const char*)node->name, "rompentagon1" ) ) {
1404       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1405       if( xmlstring ) {
1406         libspectrum_free( settings->rom_pentagon_1 );
1407         settings->rom_pentagon_1 = utils_safe_strdup( (char*)xmlstring );
1408         xmlFree( xmlstring );
1409       }
1410     } else
1411     if( !strcmp( (const char*)node->name, "rompentagon2" ) ) {
1412       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1413       if( xmlstring ) {
1414         libspectrum_free( settings->rom_pentagon_2 );
1415         settings->rom_pentagon_2 = utils_safe_strdup( (char*)xmlstring );
1416         xmlFree( xmlstring );
1417       }
1418     } else
1419     if( !strcmp( (const char*)node->name, "romplus20" ) ) {
1420       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1421       if( xmlstring ) {
1422         libspectrum_free( settings->rom_plus2_0 );
1423         settings->rom_plus2_0 = utils_safe_strdup( (char*)xmlstring );
1424         xmlFree( xmlstring );
1425       }
1426     } else
1427     if( !strcmp( (const char*)node->name, "romplus21" ) ) {
1428       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1429       if( xmlstring ) {
1430         libspectrum_free( settings->rom_plus2_1 );
1431         settings->rom_plus2_1 = utils_safe_strdup( (char*)xmlstring );
1432         xmlFree( xmlstring );
1433       }
1434     } else
1435     if( !strcmp( (const char*)node->name, "romplus2a0" ) ) {
1436       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1437       if( xmlstring ) {
1438         libspectrum_free( settings->rom_plus2a_0 );
1439         settings->rom_plus2a_0 = utils_safe_strdup( (char*)xmlstring );
1440         xmlFree( xmlstring );
1441       }
1442     } else
1443     if( !strcmp( (const char*)node->name, "romplus2a1" ) ) {
1444       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1445       if( xmlstring ) {
1446         libspectrum_free( settings->rom_plus2a_1 );
1447         settings->rom_plus2a_1 = utils_safe_strdup( (char*)xmlstring );
1448         xmlFree( xmlstring );
1449       }
1450     } else
1451     if( !strcmp( (const char*)node->name, "romplus2a2" ) ) {
1452       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1453       if( xmlstring ) {
1454         libspectrum_free( settings->rom_plus2a_2 );
1455         settings->rom_plus2a_2 = utils_safe_strdup( (char*)xmlstring );
1456         xmlFree( xmlstring );
1457       }
1458     } else
1459     if( !strcmp( (const char*)node->name, "romplus2a3" ) ) {
1460       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1461       if( xmlstring ) {
1462         libspectrum_free( settings->rom_plus2a_3 );
1463         settings->rom_plus2a_3 = utils_safe_strdup( (char*)xmlstring );
1464         xmlFree( xmlstring );
1465       }
1466     } else
1467     if( !strcmp( (const char*)node->name, "romplus30" ) ) {
1468       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1469       if( xmlstring ) {
1470         libspectrum_free( settings->rom_plus3_0 );
1471         settings->rom_plus3_0 = utils_safe_strdup( (char*)xmlstring );
1472         xmlFree( xmlstring );
1473       }
1474     } else
1475     if( !strcmp( (const char*)node->name, "romplus31" ) ) {
1476       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1477       if( xmlstring ) {
1478         libspectrum_free( settings->rom_plus3_1 );
1479         settings->rom_plus3_1 = utils_safe_strdup( (char*)xmlstring );
1480         xmlFree( xmlstring );
1481       }
1482     } else
1483     if( !strcmp( (const char*)node->name, "romplus32" ) ) {
1484       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1485       if( xmlstring ) {
1486         libspectrum_free( settings->rom_plus3_2 );
1487         settings->rom_plus3_2 = utils_safe_strdup( (char*)xmlstring );
1488         xmlFree( xmlstring );
1489       }
1490     } else
1491     if( !strcmp( (const char*)node->name, "romplus33" ) ) {
1492       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1493       if( xmlstring ) {
1494         libspectrum_free( settings->rom_plus3_3 );
1495         settings->rom_plus3_3 = utils_safe_strdup( (char*)xmlstring );
1496         xmlFree( xmlstring );
1497       }
1498     } else
1499     if( !strcmp( (const char*)node->name, "romplus3e0" ) ) {
1500       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1501       if( xmlstring ) {
1502         libspectrum_free( settings->rom_plus3e_0 );
1503         settings->rom_plus3e_0 = utils_safe_strdup( (char*)xmlstring );
1504         xmlFree( xmlstring );
1505       }
1506     } else
1507     if( !strcmp( (const char*)node->name, "romplus3e1" ) ) {
1508       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1509       if( xmlstring ) {
1510         libspectrum_free( settings->rom_plus3e_1 );
1511         settings->rom_plus3e_1 = utils_safe_strdup( (char*)xmlstring );
1512         xmlFree( xmlstring );
1513       }
1514     } else
1515     if( !strcmp( (const char*)node->name, "romplus3e2" ) ) {
1516       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1517       if( xmlstring ) {
1518         libspectrum_free( settings->rom_plus3e_2 );
1519         settings->rom_plus3e_2 = utils_safe_strdup( (char*)xmlstring );
1520         xmlFree( xmlstring );
1521       }
1522     } else
1523     if( !strcmp( (const char*)node->name, "romplus3e3" ) ) {
1524       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1525       if( xmlstring ) {
1526         libspectrum_free( settings->rom_plus3e_3 );
1527         settings->rom_plus3e_3 = utils_safe_strdup( (char*)xmlstring );
1528         xmlFree( xmlstring );
1529       }
1530     } else
1531     if( !strcmp( (const char*)node->name, "romplusd" ) ) {
1532       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1533       if( xmlstring ) {
1534         libspectrum_free( settings->rom_plusd );
1535         settings->rom_plusd = utils_safe_strdup( (char*)xmlstring );
1536         xmlFree( xmlstring );
1537       }
1538     } else
1539     if( !strcmp( (const char*)node->name, "romscorpion0" ) ) {
1540       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1541       if( xmlstring ) {
1542         libspectrum_free( settings->rom_scorpion_0 );
1543         settings->rom_scorpion_0 = utils_safe_strdup( (char*)xmlstring );
1544         xmlFree( xmlstring );
1545       }
1546     } else
1547     if( !strcmp( (const char*)node->name, "romscorpion1" ) ) {
1548       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1549       if( xmlstring ) {
1550         libspectrum_free( settings->rom_scorpion_1 );
1551         settings->rom_scorpion_1 = utils_safe_strdup( (char*)xmlstring );
1552         xmlFree( xmlstring );
1553       }
1554     } else
1555     if( !strcmp( (const char*)node->name, "romscorpion2" ) ) {
1556       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1557       if( xmlstring ) {
1558         libspectrum_free( settings->rom_scorpion_2 );
1559         settings->rom_scorpion_2 = utils_safe_strdup( (char*)xmlstring );
1560         xmlFree( xmlstring );
1561       }
1562     } else
1563     if( !strcmp( (const char*)node->name, "romscorpion3" ) ) {
1564       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1565       if( xmlstring ) {
1566         libspectrum_free( settings->rom_scorpion_3 );
1567         settings->rom_scorpion_3 = utils_safe_strdup( (char*)xmlstring );
1568         xmlFree( xmlstring );
1569       }
1570     } else
1571     if( !strcmp( (const char*)node->name, "romspecse0" ) ) {
1572       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1573       if( xmlstring ) {
1574         libspectrum_free( settings->rom_spec_se_0 );
1575         settings->rom_spec_se_0 = utils_safe_strdup( (char*)xmlstring );
1576         xmlFree( xmlstring );
1577       }
1578     } else
1579     if( !strcmp( (const char*)node->name, "romspecse1" ) ) {
1580       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1581       if( xmlstring ) {
1582         libspectrum_free( settings->rom_spec_se_1 );
1583         settings->rom_spec_se_1 = utils_safe_strdup( (char*)xmlstring );
1584         xmlFree( xmlstring );
1585       }
1586     } else
1587     if( !strcmp( (const char*)node->name, "romspeccyboot" ) ) {
1588       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1589       if( xmlstring ) {
1590         libspectrum_free( settings->rom_speccyboot );
1591         settings->rom_speccyboot = utils_safe_strdup( (char*)xmlstring );
1592         xmlFree( xmlstring );
1593       }
1594     } else
1595     if( !strcmp( (const char*)node->name, "romtc2048" ) ) {
1596       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1597       if( xmlstring ) {
1598         libspectrum_free( settings->rom_tc2048 );
1599         settings->rom_tc2048 = utils_safe_strdup( (char*)xmlstring );
1600         xmlFree( xmlstring );
1601       }
1602     } else
1603     if( !strcmp( (const char*)node->name, "romtc20680" ) ) {
1604       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1605       if( xmlstring ) {
1606         libspectrum_free( settings->rom_tc2068_0 );
1607         settings->rom_tc2068_0 = utils_safe_strdup( (char*)xmlstring );
1608         xmlFree( xmlstring );
1609       }
1610     } else
1611     if( !strcmp( (const char*)node->name, "romtc20681" ) ) {
1612       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1613       if( xmlstring ) {
1614         libspectrum_free( settings->rom_tc2068_1 );
1615         settings->rom_tc2068_1 = utils_safe_strdup( (char*)xmlstring );
1616         xmlFree( xmlstring );
1617       }
1618     } else
1619     if( !strcmp( (const char*)node->name, "romts20680" ) ) {
1620       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1621       if( xmlstring ) {
1622         libspectrum_free( settings->rom_ts2068_0 );
1623         settings->rom_ts2068_0 = utils_safe_strdup( (char*)xmlstring );
1624         xmlFree( xmlstring );
1625       }
1626     } else
1627     if( !strcmp( (const char*)node->name, "romts20681" ) ) {
1628       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1629       if( xmlstring ) {
1630         libspectrum_free( settings->rom_ts2068_1 );
1631         settings->rom_ts2068_1 = utils_safe_strdup( (char*)xmlstring );
1632         xmlFree( xmlstring );
1633       }
1634     } else
1635     if( !strcmp( (const char*)node->name, "rs232handshake" ) ) {
1636       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1637       if( xmlstring ) {
1638         settings->rs232_handshake = atoi( (char*)xmlstring );
1639         xmlFree( xmlstring );
1640       }
1641     } else
1642     if( !strcmp( (const char*)node->name, "rs232rx" ) ) {
1643       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1644       if( xmlstring ) {
1645         libspectrum_free( settings->rs232_rx );
1646         settings->rs232_rx = utils_safe_strdup( (char*)xmlstring );
1647         xmlFree( xmlstring );
1648       }
1649     } else
1650     if( !strcmp( (const char*)node->name, "rs232tx" ) ) {
1651       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1652       if( xmlstring ) {
1653         libspectrum_free( settings->rs232_tx );
1654         settings->rs232_tx = utils_safe_strdup( (char*)xmlstring );
1655         xmlFree( xmlstring );
1656       }
1657     } else
1658     if( !strcmp( (const char*)node->name, "rzxautosaves" ) ) {
1659       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1660       if( xmlstring ) {
1661         settings->rzx_autosaves = atoi( (char*)xmlstring );
1662         xmlFree( xmlstring );
1663       }
1664     } else
1665     if( !strcmp( (const char*)node->name, "compressrzx" ) ) {
1666       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1667       if( xmlstring ) {
1668         settings->rzx_compression = atoi( (char*)xmlstring );
1669         xmlFree( xmlstring );
1670       }
1671     } else
1672     if( !strcmp( (const char*)node->name, "simpleide" ) ) {
1673       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1674       if( xmlstring ) {
1675         settings->simpleide_active = atoi( (char*)xmlstring );
1676         xmlFree( xmlstring );
1677       }
1678     } else
1679     if( !strcmp( (const char*)node->name, "simpleidemasterfile" ) ) {
1680       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1681       if( xmlstring ) {
1682         libspectrum_free( settings->simpleide_master_file );
1683         settings->simpleide_master_file = utils_safe_strdup( (char*)xmlstring );
1684         xmlFree( xmlstring );
1685       }
1686     } else
1687     if( !strcmp( (const char*)node->name, "simpleideslavefile" ) ) {
1688       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1689       if( xmlstring ) {
1690         libspectrum_free( settings->simpleide_slave_file );
1691         settings->simpleide_slave_file = utils_safe_strdup( (char*)xmlstring );
1692         xmlFree( xmlstring );
1693       }
1694     } else
1695     if( !strcmp( (const char*)node->name, "slttraps" ) ) {
1696       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1697       if( xmlstring ) {
1698         settings->slt_traps = atoi( (char*)xmlstring );
1699         xmlFree( xmlstring );
1700       }
1701     } else
1702     if( !strcmp( (const char*)node->name, "snapsasz80" ) ) {
1703       /* Do nothing */
1704     } else
1705     if( !strcmp( (const char*)node->name, "snapshot" ) ) {
1706       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1707       if( xmlstring ) {
1708         libspectrum_free( settings->snapshot );
1709         settings->snapshot = utils_safe_strdup( (char*)xmlstring );
1710         xmlFree( xmlstring );
1711       }
1712     } else
1713     if( !strcmp( (const char*)node->name, "snet" ) ) {
1714       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1715       if( xmlstring ) {
1716         libspectrum_free( settings->snet );
1717         settings->snet = utils_safe_strdup( (char*)xmlstring );
1718         xmlFree( xmlstring );
1719       }
1720     } else
1721     if( !strcmp( (const char*)node->name, "sound" ) ) {
1722       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1723       if( xmlstring ) {
1724         settings->sound = atoi( (char*)xmlstring );
1725         xmlFree( xmlstring );
1726       }
1727     } else
1728     if( !strcmp( (const char*)node->name, "sounddevice" ) ) {
1729       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1730       if( xmlstring ) {
1731         libspectrum_free( settings->sound_device );
1732         settings->sound_device = utils_safe_strdup( (char*)xmlstring );
1733         xmlFree( xmlstring );
1734       }
1735     } else
1736     if( !strcmp( (const char*)node->name, "soundforce8bit" ) ) {
1737       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1738       if( xmlstring ) {
1739         settings->sound_force_8bit = atoi( (char*)xmlstring );
1740         xmlFree( xmlstring );
1741       }
1742     } else
1743     if( !strcmp( (const char*)node->name, "soundfreq" ) ) {
1744       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1745       if( xmlstring ) {
1746         settings->sound_freq = atoi( (char*)xmlstring );
1747         xmlFree( xmlstring );
1748       }
1749     } else
1750     if( !strcmp( (const char*)node->name, "loadingsound" ) ) {
1751       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1752       if( xmlstring ) {
1753         settings->sound_load = atoi( (char*)xmlstring );
1754         xmlFree( xmlstring );
1755       }
1756     } else
1757     if( !strcmp( (const char*)node->name, "speakertype" ) ) {
1758       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1759       if( xmlstring ) {
1760         libspectrum_free( settings->speaker_type );
1761         settings->speaker_type = utils_safe_strdup( (char*)xmlstring );
1762         xmlFree( xmlstring );
1763       }
1764     } else
1765     if( !strcmp( (const char*)node->name, "speccyboot" ) ) {
1766       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1767       if( xmlstring ) {
1768         settings->speccyboot = atoi( (char*)xmlstring );
1769         xmlFree( xmlstring );
1770       }
1771     } else
1772     if( !strcmp( (const char*)node->name, "speccyboottap" ) ) {
1773       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1774       if( xmlstring ) {
1775         libspectrum_free( settings->speccyboot_tap );
1776         settings->speccyboot_tap = utils_safe_strdup( (char*)xmlstring );
1777         xmlFree( xmlstring );
1778       }
1779     } else
1780     if( !strcmp( (const char*)node->name, "specdrum" ) ) {
1781       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1782       if( xmlstring ) {
1783         settings->specdrum = atoi( (char*)xmlstring );
1784         xmlFree( xmlstring );
1785       }
1786     } else
1787     if( !strcmp( (const char*)node->name, "spectranet" ) ) {
1788       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1789       if( xmlstring ) {
1790         settings->spectranet = atoi( (char*)xmlstring );
1791         xmlFree( xmlstring );
1792       }
1793     } else
1794     if( !strcmp( (const char*)node->name, "spectranetdisable" ) ) {
1795       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1796       if( xmlstring ) {
1797         settings->spectranet_disable = atoi( (char*)xmlstring );
1798         xmlFree( xmlstring );
1799       }
1800     } else
1801     if( !strcmp( (const char*)node->name, "machine" ) ) {
1802       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1803       if( xmlstring ) {
1804         libspectrum_free( settings->start_machine );
1805         settings->start_machine = utils_safe_strdup( (char*)xmlstring );
1806         xmlFree( xmlstring );
1807       }
1808     } else
1809     if( !strcmp( (const char*)node->name, "graphicsfilter" ) ) {
1810       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1811       if( xmlstring ) {
1812         libspectrum_free( settings->start_scaler_mode );
1813         settings->start_scaler_mode = utils_safe_strdup( (char*)xmlstring );
1814         xmlFree( xmlstring );
1815       }
1816     } else
1817     if( !strcmp( (const char*)node->name, "statusbar" ) ) {
1818       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1819       if( xmlstring ) {
1820         settings->statusbar = atoi( (char*)xmlstring );
1821         xmlFree( xmlstring );
1822       }
1823     } else
1824     if( !strcmp( (const char*)node->name, "separation" ) ) {
1825       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1826       if( xmlstring ) {
1827         libspectrum_free( settings->stereo_ay );
1828         settings->stereo_ay = utils_safe_strdup( (char*)xmlstring );
1829         xmlFree( xmlstring );
1830       }
1831     } else
1832     if( !strcmp( (const char*)node->name, "strictaspecthint" ) ) {
1833       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1834       if( xmlstring ) {
1835         settings->strict_aspect_hint = atoi( (char*)xmlstring );
1836         xmlFree( xmlstring );
1837       }
1838     } else
1839     if( !strcmp( (const char*)node->name, "svgamodes" ) ) {
1840       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1841       if( xmlstring ) {
1842         libspectrum_free( settings->svga_modes );
1843         settings->svga_modes = utils_safe_strdup( (char*)xmlstring );
1844         xmlFree( xmlstring );
1845       }
1846     } else
1847     if( !strcmp( (const char*)node->name, "tapefile" ) ) {
1848       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1849       if( xmlstring ) {
1850         libspectrum_free( settings->tape_file );
1851         settings->tape_file = utils_safe_strdup( (char*)xmlstring );
1852         xmlFree( xmlstring );
1853       }
1854     } else
1855     if( !strcmp( (const char*)node->name, "tapetraps" ) ) {
1856       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1857       if( xmlstring ) {
1858         settings->tape_traps = atoi( (char*)xmlstring );
1859         xmlFree( xmlstring );
1860       }
1861     } else
1862     if( !strcmp( (const char*)node->name, "unittests" ) ) {
1863       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1864       if( xmlstring ) {
1865         settings->unittests = atoi( (char*)xmlstring );
1866         xmlFree( xmlstring );
1867       }
1868     } else
1869     if( !strcmp( (const char*)node->name, "volumeay" ) ) {
1870       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1871       if( xmlstring ) {
1872         settings->volume_ay = atoi( (char*)xmlstring );
1873         xmlFree( xmlstring );
1874       }
1875     } else
1876     if( !strcmp( (const char*)node->name, "volumebeeper" ) ) {
1877       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1878       if( xmlstring ) {
1879         settings->volume_beeper = atoi( (char*)xmlstring );
1880         xmlFree( xmlstring );
1881       }
1882     } else
1883     if( !strcmp( (const char*)node->name, "volumespecdrum" ) ) {
1884       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1885       if( xmlstring ) {
1886         settings->volume_specdrum = atoi( (char*)xmlstring );
1887         xmlFree( xmlstring );
1888       }
1889     } else
1890     if( !strcmp( (const char*)node->name, "writableroms" ) ) {
1891       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1892       if( xmlstring ) {
1893         settings->writable_roms = atoi( (char*)xmlstring );
1894         xmlFree( xmlstring );
1895       }
1896     } else
1897     if( !strcmp( (const char*)node->name, "zxatasp" ) ) {
1898       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1899       if( xmlstring ) {
1900         settings->zxatasp_active = atoi( (char*)xmlstring );
1901         xmlFree( xmlstring );
1902       }
1903     } else
1904     if( !strcmp( (const char*)node->name, "zxataspmasterfile" ) ) {
1905       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1906       if( xmlstring ) {
1907         libspectrum_free( settings->zxatasp_master_file );
1908         settings->zxatasp_master_file = utils_safe_strdup( (char*)xmlstring );
1909         xmlFree( xmlstring );
1910       }
1911     } else
1912     if( !strcmp( (const char*)node->name, "zxataspslavefile" ) ) {
1913       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1914       if( xmlstring ) {
1915         libspectrum_free( settings->zxatasp_slave_file );
1916         settings->zxatasp_slave_file = utils_safe_strdup( (char*)xmlstring );
1917         xmlFree( xmlstring );
1918       }
1919     } else
1920     if( !strcmp( (const char*)node->name, "zxataspupload" ) ) {
1921       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1922       if( xmlstring ) {
1923         settings->zxatasp_upload = atoi( (char*)xmlstring );
1924         xmlFree( xmlstring );
1925       }
1926     } else
1927     if( !strcmp( (const char*)node->name, "zxataspwriteprotect" ) ) {
1928       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1929       if( xmlstring ) {
1930         settings->zxatasp_wp = atoi( (char*)xmlstring );
1931         xmlFree( xmlstring );
1932       }
1933     } else
1934     if( !strcmp( (const char*)node->name, "zxcf" ) ) {
1935       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1936       if( xmlstring ) {
1937         settings->zxcf_active = atoi( (char*)xmlstring );
1938         xmlFree( xmlstring );
1939       }
1940     } else
1941     if( !strcmp( (const char*)node->name, "zxcfcffile" ) ) {
1942       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1943       if( xmlstring ) {
1944         libspectrum_free( settings->zxcf_pri_file );
1945         settings->zxcf_pri_file = utils_safe_strdup( (char*)xmlstring );
1946         xmlFree( xmlstring );
1947       }
1948     } else
1949     if( !strcmp( (const char*)node->name, "zxcfupload" ) ) {
1950       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1951       if( xmlstring ) {
1952         settings->zxcf_upload = atoi( (char*)xmlstring );
1953         xmlFree( xmlstring );
1954       }
1955     } else
1956     if( !strcmp( (const char*)node->name, "zxprinter" ) ) {
1957       xmlstring = xmlNodeListGetString( doc, node->xmlChildrenNode, 1 );
1958       if( xmlstring ) {
1959         settings->zxprinter = atoi( (char*)xmlstring );
1960         xmlFree( xmlstring );
1961       }
1962     } else
1963 #line 261"../settings.pl"
1964     if( !strcmp( (const char*)node->name, "text" ) ) {
1965       /* Do nothing */
1966     } else {
1967       ui_error( UI_ERROR_WARNING, "Unknown setting '%s' in config file",
1968 		node->name );
1969     }
1970 
1971     node = node->next;
1972   }
1973 
1974   return 0;
1975 }
1976 
1977 int
settings_write_config(settings_info * settings)1978 settings_write_config( settings_info *settings )
1979 {
1980   const char *home; char path[ PATH_MAX ], buffer[80];
1981 
1982   xmlDocPtr doc; xmlNodePtr root;
1983 
1984   home = compat_get_home_path(); if( !home ) return 1;
1985 
1986   snprintf( path, PATH_MAX, "%s/%s", home, CONFIG_FILE_NAME );
1987 
1988   /* Create the XML document */
1989   doc = xmlNewDoc( (const xmlChar*)"1.0" );
1990 
1991   root = xmlNewNode( NULL, (const xmlChar*)"settings" );
1992   xmlDocSetRootElement( doc, root );
1993   xmlNewTextChild( root, NULL, (const xmlChar*)"accelerateloader", (const xmlChar*)(settings->accelerate_loader ? "1" : "0") );
1994   xmlNewTextChild( root, NULL, (const xmlChar*)"aspecthint", (const xmlChar*)(settings->aspect_hint ? "1" : "0") );
1995   xmlNewTextChild( root, NULL, (const xmlChar*)"autoload", (const xmlChar*)(settings->auto_load ? "1" : "0") );
1996   xmlNewTextChild( root, NULL, (const xmlChar*)"autosavesettings", (const xmlChar*)(settings->autosave_settings ? "1" : "0") );
1997   xmlNewTextChild( root, NULL, (const xmlChar*)"beta128", (const xmlChar*)(settings->beta128 ? "1" : "0") );
1998   xmlNewTextChild( root, NULL, (const xmlChar*)"beta12848boot", (const xmlChar*)(settings->beta128_48boot ? "1" : "0") );
1999   if( settings->betadisk_file )
2000     xmlNewTextChild( root, NULL, (const xmlChar*)"betadisk", (const xmlChar*)settings->betadisk_file );
2001   xmlNewTextChild( root, NULL, (const xmlChar*)"bwtv", (const xmlChar*)(settings->bw_tv ? "1" : "0") );
2002   snprintf( buffer, 80, "%d", settings->competition_code );
2003   xmlNewTextChild( root, NULL, (const xmlChar*)"competitioncode", (const xmlChar*)buffer );
2004   xmlNewTextChild( root, NULL, (const xmlChar*)"competitionmode", (const xmlChar*)(settings->competition_mode ? "1" : "0") );
2005   xmlNewTextChild( root, NULL, (const xmlChar*)"confirmactions", (const xmlChar*)(settings->confirm_actions ? "1" : "0") );
2006   if( settings->dck_file )
2007     xmlNewTextChild( root, NULL, (const xmlChar*)"dock", (const xmlChar*)settings->dck_file );
2008   if( settings->debugger_command )
2009     xmlNewTextChild( root, NULL, (const xmlChar*)"debuggercommand", (const xmlChar*)settings->debugger_command );
2010   xmlNewTextChild( root, NULL, (const xmlChar*)"detectloader", (const xmlChar*)(settings->detect_loader ? "1" : "0") );
2011   xmlNewTextChild( root, NULL, (const xmlChar*)"disciple", (const xmlChar*)(settings->disciple ? "1" : "0") );
2012   if( settings->discipledisk_file )
2013     xmlNewTextChild( root, NULL, (const xmlChar*)"discipledisk", (const xmlChar*)settings->discipledisk_file );
2014   xmlNewTextChild( root, NULL, (const xmlChar*)"diskaskmerge", (const xmlChar*)(settings->disk_ask_merge ? "1" : "0") );
2015   if( settings->disk_try_merge )
2016     xmlNewTextChild( root, NULL, (const xmlChar*)"disktrymerge", (const xmlChar*)settings->disk_try_merge );
2017   xmlNewTextChild( root, NULL, (const xmlChar*)"divide", (const xmlChar*)(settings->divide_enabled ? "1" : "0") );
2018   if( settings->divide_master_file )
2019     xmlNewTextChild( root, NULL, (const xmlChar*)"dividemasterfile", (const xmlChar*)settings->divide_master_file );
2020   if( settings->divide_slave_file )
2021     xmlNewTextChild( root, NULL, (const xmlChar*)"divideslavefile", (const xmlChar*)settings->divide_slave_file );
2022   xmlNewTextChild( root, NULL, (const xmlChar*)"dividewriteprotect", (const xmlChar*)(settings->divide_wp ? "1" : "0") );
2023   snprintf( buffer, 80, "%d", settings->doublescan_mode );
2024   xmlNewTextChild( root, NULL, (const xmlChar*)"doublescanmode", (const xmlChar*)buffer );
2025   snprintf( buffer, 80, "%d", settings->drive_40_max_track );
2026   xmlNewTextChild( root, NULL, (const xmlChar*)"drive40maxtrack", (const xmlChar*)buffer );
2027   snprintf( buffer, 80, "%d", settings->drive_80_max_track );
2028   xmlNewTextChild( root, NULL, (const xmlChar*)"drive80maxtrack", (const xmlChar*)buffer );
2029   if( settings->drive_beta128a_type )
2030     xmlNewTextChild( root, NULL, (const xmlChar*)"drivebeta128atype", (const xmlChar*)settings->drive_beta128a_type );
2031   if( settings->drive_beta128b_type )
2032     xmlNewTextChild( root, NULL, (const xmlChar*)"drivebeta128btype", (const xmlChar*)settings->drive_beta128b_type );
2033   if( settings->drive_beta128c_type )
2034     xmlNewTextChild( root, NULL, (const xmlChar*)"drivebeta128ctype", (const xmlChar*)settings->drive_beta128c_type );
2035   if( settings->drive_beta128d_type )
2036     xmlNewTextChild( root, NULL, (const xmlChar*)"drivebeta128dtype", (const xmlChar*)settings->drive_beta128d_type );
2037   if( settings->drive_disciple1_type )
2038     xmlNewTextChild( root, NULL, (const xmlChar*)"drivedisciple1type", (const xmlChar*)settings->drive_disciple1_type );
2039   if( settings->drive_disciple2_type )
2040     xmlNewTextChild( root, NULL, (const xmlChar*)"drivedisciple2type", (const xmlChar*)settings->drive_disciple2_type );
2041   if( settings->drive_opus1_type )
2042     xmlNewTextChild( root, NULL, (const xmlChar*)"driveopus1type", (const xmlChar*)settings->drive_opus1_type );
2043   if( settings->drive_opus2_type )
2044     xmlNewTextChild( root, NULL, (const xmlChar*)"driveopus2type", (const xmlChar*)settings->drive_opus2_type );
2045   if( settings->drive_plus3a_type )
2046     xmlNewTextChild( root, NULL, (const xmlChar*)"driveplus3atype", (const xmlChar*)settings->drive_plus3a_type );
2047   if( settings->drive_plus3b_type )
2048     xmlNewTextChild( root, NULL, (const xmlChar*)"driveplus3btype", (const xmlChar*)settings->drive_plus3b_type );
2049   if( settings->drive_plusd1_type )
2050     xmlNewTextChild( root, NULL, (const xmlChar*)"driveplusd1type", (const xmlChar*)settings->drive_plusd1_type );
2051   if( settings->drive_plusd2_type )
2052     xmlNewTextChild( root, NULL, (const xmlChar*)"driveplusd2type", (const xmlChar*)settings->drive_plusd2_type );
2053   xmlNewTextChild( root, NULL, (const xmlChar*)"embedsnapshot", (const xmlChar*)(settings->embed_snapshot ? "1" : "0") );
2054   snprintf( buffer, 80, "%d", settings->emulation_speed );
2055   xmlNewTextChild( root, NULL, (const xmlChar*)"speed", (const xmlChar*)buffer );
2056   xmlNewTextChild( root, NULL, (const xmlChar*)"fastload", (const xmlChar*)(settings->fastload ? "1" : "0") );
2057   snprintf( buffer, 80, "%d", settings->fb_mode );
2058   xmlNewTextChild( root, NULL, (const xmlChar*)"fbmode", (const xmlChar*)buffer );
2059   snprintf( buffer, 80, "%d", settings->frame_rate );
2060   xmlNewTextChild( root, NULL, (const xmlChar*)"rate", (const xmlChar*)buffer );
2061   xmlNewTextChild( root, NULL, (const xmlChar*)"fullscreen", (const xmlChar*)(settings->full_screen ? "1" : "0") );
2062   xmlNewTextChild( root, NULL, (const xmlChar*)"fuller", (const xmlChar*)(settings->fuller ? "1" : "0") );
2063   if( settings->if2_file )
2064     xmlNewTextChild( root, NULL, (const xmlChar*)"if2cart", (const xmlChar*)settings->if2_file );
2065   xmlNewTextChild( root, NULL, (const xmlChar*)"interface1", (const xmlChar*)(settings->interface1 ? "1" : "0") );
2066   xmlNewTextChild( root, NULL, (const xmlChar*)"interface2", (const xmlChar*)(settings->interface2 ? "1" : "0") );
2067   xmlNewTextChild( root, NULL, (const xmlChar*)"issue2", (const xmlChar*)(settings->issue2 ? "1" : "0") );
2068   xmlNewTextChild( root, NULL, (const xmlChar*)"kempston", (const xmlChar*)(settings->joy_kempston ? "1" : "0") );
2069   xmlNewTextChild( root, NULL, (const xmlChar*)"joystickprompt", (const xmlChar*)(settings->joy_prompt ? "1" : "0") );
2070   if( settings->joystick_1 )
2071     xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1", (const xmlChar*)settings->joystick_1 );
2072   snprintf( buffer, 80, "%d", settings->joystick_1_fire_1 );
2073   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1fire1", (const xmlChar*)buffer );
2074   snprintf( buffer, 80, "%d", settings->joystick_1_fire_10 );
2075   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1fire10", (const xmlChar*)buffer );
2076   snprintf( buffer, 80, "%d", settings->joystick_1_fire_11 );
2077   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1fire11", (const xmlChar*)buffer );
2078   snprintf( buffer, 80, "%d", settings->joystick_1_fire_12 );
2079   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1fire12", (const xmlChar*)buffer );
2080   snprintf( buffer, 80, "%d", settings->joystick_1_fire_13 );
2081   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1fire13", (const xmlChar*)buffer );
2082   snprintf( buffer, 80, "%d", settings->joystick_1_fire_14 );
2083   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1fire14", (const xmlChar*)buffer );
2084   snprintf( buffer, 80, "%d", settings->joystick_1_fire_15 );
2085   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1fire15", (const xmlChar*)buffer );
2086   snprintf( buffer, 80, "%d", settings->joystick_1_fire_2 );
2087   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1fire2", (const xmlChar*)buffer );
2088   snprintf( buffer, 80, "%d", settings->joystick_1_fire_3 );
2089   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1fire3", (const xmlChar*)buffer );
2090   snprintf( buffer, 80, "%d", settings->joystick_1_fire_4 );
2091   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1fire4", (const xmlChar*)buffer );
2092   snprintf( buffer, 80, "%d", settings->joystick_1_fire_5 );
2093   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1fire5", (const xmlChar*)buffer );
2094   snprintf( buffer, 80, "%d", settings->joystick_1_fire_6 );
2095   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1fire6", (const xmlChar*)buffer );
2096   snprintf( buffer, 80, "%d", settings->joystick_1_fire_7 );
2097   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1fire7", (const xmlChar*)buffer );
2098   snprintf( buffer, 80, "%d", settings->joystick_1_fire_8 );
2099   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1fire8", (const xmlChar*)buffer );
2100   snprintf( buffer, 80, "%d", settings->joystick_1_fire_9 );
2101   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1fire9", (const xmlChar*)buffer );
2102   snprintf( buffer, 80, "%d", settings->joystick_1_output );
2103   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick1output", (const xmlChar*)buffer );
2104   if( settings->joystick_2 )
2105     xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2", (const xmlChar*)settings->joystick_2 );
2106   snprintf( buffer, 80, "%d", settings->joystick_2_fire_1 );
2107   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2fire1", (const xmlChar*)buffer );
2108   snprintf( buffer, 80, "%d", settings->joystick_2_fire_10 );
2109   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2fire10", (const xmlChar*)buffer );
2110   snprintf( buffer, 80, "%d", settings->joystick_2_fire_11 );
2111   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2fire11", (const xmlChar*)buffer );
2112   snprintf( buffer, 80, "%d", settings->joystick_2_fire_12 );
2113   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2fire12", (const xmlChar*)buffer );
2114   snprintf( buffer, 80, "%d", settings->joystick_2_fire_13 );
2115   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2fire13", (const xmlChar*)buffer );
2116   snprintf( buffer, 80, "%d", settings->joystick_2_fire_14 );
2117   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2fire14", (const xmlChar*)buffer );
2118   snprintf( buffer, 80, "%d", settings->joystick_2_fire_15 );
2119   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2fire15", (const xmlChar*)buffer );
2120   snprintf( buffer, 80, "%d", settings->joystick_2_fire_2 );
2121   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2fire2", (const xmlChar*)buffer );
2122   snprintf( buffer, 80, "%d", settings->joystick_2_fire_3 );
2123   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2fire3", (const xmlChar*)buffer );
2124   snprintf( buffer, 80, "%d", settings->joystick_2_fire_4 );
2125   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2fire4", (const xmlChar*)buffer );
2126   snprintf( buffer, 80, "%d", settings->joystick_2_fire_5 );
2127   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2fire5", (const xmlChar*)buffer );
2128   snprintf( buffer, 80, "%d", settings->joystick_2_fire_6 );
2129   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2fire6", (const xmlChar*)buffer );
2130   snprintf( buffer, 80, "%d", settings->joystick_2_fire_7 );
2131   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2fire7", (const xmlChar*)buffer );
2132   snprintf( buffer, 80, "%d", settings->joystick_2_fire_8 );
2133   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2fire8", (const xmlChar*)buffer );
2134   snprintf( buffer, 80, "%d", settings->joystick_2_fire_9 );
2135   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2fire9", (const xmlChar*)buffer );
2136   snprintf( buffer, 80, "%d", settings->joystick_2_output );
2137   xmlNewTextChild( root, NULL, (const xmlChar*)"joystick2output", (const xmlChar*)buffer );
2138   snprintf( buffer, 80, "%d", settings->joystick_keyboard_down );
2139   xmlNewTextChild( root, NULL, (const xmlChar*)"joystickkeyboarddown", (const xmlChar*)buffer );
2140   snprintf( buffer, 80, "%d", settings->joystick_keyboard_fire );
2141   xmlNewTextChild( root, NULL, (const xmlChar*)"joystickkeyboardfire", (const xmlChar*)buffer );
2142   snprintf( buffer, 80, "%d", settings->joystick_keyboard_left );
2143   xmlNewTextChild( root, NULL, (const xmlChar*)"joystickkeyboardleft", (const xmlChar*)buffer );
2144   snprintf( buffer, 80, "%d", settings->joystick_keyboard_output );
2145   xmlNewTextChild( root, NULL, (const xmlChar*)"joystickkeyboardoutput", (const xmlChar*)buffer );
2146   snprintf( buffer, 80, "%d", settings->joystick_keyboard_right );
2147   xmlNewTextChild( root, NULL, (const xmlChar*)"joystickkeyboardright", (const xmlChar*)buffer );
2148   snprintf( buffer, 80, "%d", settings->joystick_keyboard_up );
2149   xmlNewTextChild( root, NULL, (const xmlChar*)"joystickkeyboardup", (const xmlChar*)buffer );
2150   xmlNewTextChild( root, NULL, (const xmlChar*)"kempstonmouse", (const xmlChar*)(settings->kempston_mouse ? "1" : "0") );
2151   xmlNewTextChild( root, NULL, (const xmlChar*)"latetimings", (const xmlChar*)(settings->late_timings ? "1" : "0") );
2152   if( settings->mdr_file )
2153     xmlNewTextChild( root, NULL, (const xmlChar*)"microdrivefile", (const xmlChar*)settings->mdr_file );
2154   if( settings->mdr_file2 )
2155     xmlNewTextChild( root, NULL, (const xmlChar*)"microdrive2file", (const xmlChar*)settings->mdr_file2 );
2156   if( settings->mdr_file3 )
2157     xmlNewTextChild( root, NULL, (const xmlChar*)"microdrive3file", (const xmlChar*)settings->mdr_file3 );
2158   if( settings->mdr_file4 )
2159     xmlNewTextChild( root, NULL, (const xmlChar*)"microdrive4file", (const xmlChar*)settings->mdr_file4 );
2160   if( settings->mdr_file5 )
2161     xmlNewTextChild( root, NULL, (const xmlChar*)"microdrive5file", (const xmlChar*)settings->mdr_file5 );
2162   if( settings->mdr_file6 )
2163     xmlNewTextChild( root, NULL, (const xmlChar*)"microdrive6file", (const xmlChar*)settings->mdr_file6 );
2164   if( settings->mdr_file7 )
2165     xmlNewTextChild( root, NULL, (const xmlChar*)"microdrive7file", (const xmlChar*)settings->mdr_file7 );
2166   if( settings->mdr_file8 )
2167     xmlNewTextChild( root, NULL, (const xmlChar*)"microdrive8file", (const xmlChar*)settings->mdr_file8 );
2168   snprintf( buffer, 80, "%d", settings->mdr_len );
2169   xmlNewTextChild( root, NULL, (const xmlChar*)"mdrlen", (const xmlChar*)buffer );
2170   xmlNewTextChild( root, NULL, (const xmlChar*)"mdrrandomlen", (const xmlChar*)(settings->mdr_random_len ? "1" : "0") );
2171   xmlNewTextChild( root, NULL, (const xmlChar*)"melodik", (const xmlChar*)(settings->melodik ? "1" : "0") );
2172   xmlNewTextChild( root, NULL, (const xmlChar*)"mouseswapbuttons", (const xmlChar*)(settings->mouse_swap_buttons ? "1" : "0") );
2173   if( settings->movie_compr )
2174     xmlNewTextChild( root, NULL, (const xmlChar*)"moviecompr", (const xmlChar*)settings->movie_compr );
2175   if( settings->movie_start )
2176     xmlNewTextChild( root, NULL, (const xmlChar*)"moviestart", (const xmlChar*)settings->movie_start );
2177   xmlNewTextChild( root, NULL, (const xmlChar*)"moviestopafterrzx", (const xmlChar*)(settings->movie_stop_after_rzx ? "1" : "0") );
2178   xmlNewTextChild( root, NULL, (const xmlChar*)"opus", (const xmlChar*)(settings->opus ? "1" : "0") );
2179   if( settings->opusdisk_file )
2180     xmlNewTextChild( root, NULL, (const xmlChar*)"opusdisk", (const xmlChar*)settings->opusdisk_file );
2181   xmlNewTextChild( root, NULL, (const xmlChar*)"paltv2x", (const xmlChar*)(settings->pal_tv2x ? "1" : "0") );
2182   if( settings->playback_file )
2183     xmlNewTextChild( root, NULL, (const xmlChar*)"playbackfile", (const xmlChar*)settings->playback_file );
2184   xmlNewTextChild( root, NULL, (const xmlChar*)"plus3detectspeedlock", (const xmlChar*)(settings->plus3_detect_speedlock ? "1" : "0") );
2185   if( settings->plus3disk_file )
2186     xmlNewTextChild( root, NULL, (const xmlChar*)"plus3disk", (const xmlChar*)settings->plus3disk_file );
2187   xmlNewTextChild( root, NULL, (const xmlChar*)"plusd", (const xmlChar*)(settings->plusd ? "1" : "0") );
2188   if( settings->plusddisk_file )
2189     xmlNewTextChild( root, NULL, (const xmlChar*)"plusddisk", (const xmlChar*)settings->plusddisk_file );
2190   xmlNewTextChild( root, NULL, (const xmlChar*)"printer", (const xmlChar*)(settings->printer ? "1" : "0") );
2191   if( settings->printer_graphics_filename )
2192     xmlNewTextChild( root, NULL, (const xmlChar*)"graphicsfile", (const xmlChar*)settings->printer_graphics_filename );
2193   if( settings->printer_text_filename )
2194     xmlNewTextChild( root, NULL, (const xmlChar*)"textfile", (const xmlChar*)settings->printer_text_filename );
2195   xmlNewTextChild( root, NULL, (const xmlChar*)"rawsnet", (const xmlChar*)(settings->raw_s_net ? "1" : "0") );
2196   if( settings->record_file )
2197     xmlNewTextChild( root, NULL, (const xmlChar*)"recordfile", (const xmlChar*)settings->record_file );
2198   if( settings->rom_128_0 )
2199     xmlNewTextChild( root, NULL, (const xmlChar*)"rom1280", (const xmlChar*)settings->rom_128_0 );
2200   if( settings->rom_128_1 )
2201     xmlNewTextChild( root, NULL, (const xmlChar*)"rom1281", (const xmlChar*)settings->rom_128_1 );
2202   if( settings->rom_16 )
2203     xmlNewTextChild( root, NULL, (const xmlChar*)"rom16", (const xmlChar*)settings->rom_16 );
2204   if( settings->rom_48 )
2205     xmlNewTextChild( root, NULL, (const xmlChar*)"rom48", (const xmlChar*)settings->rom_48 );
2206   if( settings->rom_beta128 )
2207     xmlNewTextChild( root, NULL, (const xmlChar*)"rombeta128", (const xmlChar*)settings->rom_beta128 );
2208   if( settings->rom_disciple )
2209     xmlNewTextChild( root, NULL, (const xmlChar*)"romdisciple", (const xmlChar*)settings->rom_disciple );
2210   if( settings->rom_interface_i )
2211     xmlNewTextChild( root, NULL, (const xmlChar*)"rominterfacei", (const xmlChar*)settings->rom_interface_i );
2212   if( settings->rom_opus )
2213     xmlNewTextChild( root, NULL, (const xmlChar*)"romopus", (const xmlChar*)settings->rom_opus );
2214   if( settings->rom_pentagon1024_0 )
2215     xmlNewTextChild( root, NULL, (const xmlChar*)"rompentagon10240", (const xmlChar*)settings->rom_pentagon1024_0 );
2216   if( settings->rom_pentagon1024_1 )
2217     xmlNewTextChild( root, NULL, (const xmlChar*)"rompentagon10241", (const xmlChar*)settings->rom_pentagon1024_1 );
2218   if( settings->rom_pentagon1024_2 )
2219     xmlNewTextChild( root, NULL, (const xmlChar*)"rompentagon10242", (const xmlChar*)settings->rom_pentagon1024_2 );
2220   if( settings->rom_pentagon1024_3 )
2221     xmlNewTextChild( root, NULL, (const xmlChar*)"rompentagon10243", (const xmlChar*)settings->rom_pentagon1024_3 );
2222   if( settings->rom_pentagon512_0 )
2223     xmlNewTextChild( root, NULL, (const xmlChar*)"rompentagon5120", (const xmlChar*)settings->rom_pentagon512_0 );
2224   if( settings->rom_pentagon512_1 )
2225     xmlNewTextChild( root, NULL, (const xmlChar*)"rompentagon5121", (const xmlChar*)settings->rom_pentagon512_1 );
2226   if( settings->rom_pentagon512_2 )
2227     xmlNewTextChild( root, NULL, (const xmlChar*)"rompentagon5122", (const xmlChar*)settings->rom_pentagon512_2 );
2228   if( settings->rom_pentagon512_3 )
2229     xmlNewTextChild( root, NULL, (const xmlChar*)"rompentagon5123", (const xmlChar*)settings->rom_pentagon512_3 );
2230   if( settings->rom_pentagon_0 )
2231     xmlNewTextChild( root, NULL, (const xmlChar*)"rompentagon0", (const xmlChar*)settings->rom_pentagon_0 );
2232   if( settings->rom_pentagon_1 )
2233     xmlNewTextChild( root, NULL, (const xmlChar*)"rompentagon1", (const xmlChar*)settings->rom_pentagon_1 );
2234   if( settings->rom_pentagon_2 )
2235     xmlNewTextChild( root, NULL, (const xmlChar*)"rompentagon2", (const xmlChar*)settings->rom_pentagon_2 );
2236   if( settings->rom_plus2_0 )
2237     xmlNewTextChild( root, NULL, (const xmlChar*)"romplus20", (const xmlChar*)settings->rom_plus2_0 );
2238   if( settings->rom_plus2_1 )
2239     xmlNewTextChild( root, NULL, (const xmlChar*)"romplus21", (const xmlChar*)settings->rom_plus2_1 );
2240   if( settings->rom_plus2a_0 )
2241     xmlNewTextChild( root, NULL, (const xmlChar*)"romplus2a0", (const xmlChar*)settings->rom_plus2a_0 );
2242   if( settings->rom_plus2a_1 )
2243     xmlNewTextChild( root, NULL, (const xmlChar*)"romplus2a1", (const xmlChar*)settings->rom_plus2a_1 );
2244   if( settings->rom_plus2a_2 )
2245     xmlNewTextChild( root, NULL, (const xmlChar*)"romplus2a2", (const xmlChar*)settings->rom_plus2a_2 );
2246   if( settings->rom_plus2a_3 )
2247     xmlNewTextChild( root, NULL, (const xmlChar*)"romplus2a3", (const xmlChar*)settings->rom_plus2a_3 );
2248   if( settings->rom_plus3_0 )
2249     xmlNewTextChild( root, NULL, (const xmlChar*)"romplus30", (const xmlChar*)settings->rom_plus3_0 );
2250   if( settings->rom_plus3_1 )
2251     xmlNewTextChild( root, NULL, (const xmlChar*)"romplus31", (const xmlChar*)settings->rom_plus3_1 );
2252   if( settings->rom_plus3_2 )
2253     xmlNewTextChild( root, NULL, (const xmlChar*)"romplus32", (const xmlChar*)settings->rom_plus3_2 );
2254   if( settings->rom_plus3_3 )
2255     xmlNewTextChild( root, NULL, (const xmlChar*)"romplus33", (const xmlChar*)settings->rom_plus3_3 );
2256   if( settings->rom_plus3e_0 )
2257     xmlNewTextChild( root, NULL, (const xmlChar*)"romplus3e0", (const xmlChar*)settings->rom_plus3e_0 );
2258   if( settings->rom_plus3e_1 )
2259     xmlNewTextChild( root, NULL, (const xmlChar*)"romplus3e1", (const xmlChar*)settings->rom_plus3e_1 );
2260   if( settings->rom_plus3e_2 )
2261     xmlNewTextChild( root, NULL, (const xmlChar*)"romplus3e2", (const xmlChar*)settings->rom_plus3e_2 );
2262   if( settings->rom_plus3e_3 )
2263     xmlNewTextChild( root, NULL, (const xmlChar*)"romplus3e3", (const xmlChar*)settings->rom_plus3e_3 );
2264   if( settings->rom_plusd )
2265     xmlNewTextChild( root, NULL, (const xmlChar*)"romplusd", (const xmlChar*)settings->rom_plusd );
2266   if( settings->rom_scorpion_0 )
2267     xmlNewTextChild( root, NULL, (const xmlChar*)"romscorpion0", (const xmlChar*)settings->rom_scorpion_0 );
2268   if( settings->rom_scorpion_1 )
2269     xmlNewTextChild( root, NULL, (const xmlChar*)"romscorpion1", (const xmlChar*)settings->rom_scorpion_1 );
2270   if( settings->rom_scorpion_2 )
2271     xmlNewTextChild( root, NULL, (const xmlChar*)"romscorpion2", (const xmlChar*)settings->rom_scorpion_2 );
2272   if( settings->rom_scorpion_3 )
2273     xmlNewTextChild( root, NULL, (const xmlChar*)"romscorpion3", (const xmlChar*)settings->rom_scorpion_3 );
2274   if( settings->rom_spec_se_0 )
2275     xmlNewTextChild( root, NULL, (const xmlChar*)"romspecse0", (const xmlChar*)settings->rom_spec_se_0 );
2276   if( settings->rom_spec_se_1 )
2277     xmlNewTextChild( root, NULL, (const xmlChar*)"romspecse1", (const xmlChar*)settings->rom_spec_se_1 );
2278   if( settings->rom_speccyboot )
2279     xmlNewTextChild( root, NULL, (const xmlChar*)"romspeccyboot", (const xmlChar*)settings->rom_speccyboot );
2280   if( settings->rom_tc2048 )
2281     xmlNewTextChild( root, NULL, (const xmlChar*)"romtc2048", (const xmlChar*)settings->rom_tc2048 );
2282   if( settings->rom_tc2068_0 )
2283     xmlNewTextChild( root, NULL, (const xmlChar*)"romtc20680", (const xmlChar*)settings->rom_tc2068_0 );
2284   if( settings->rom_tc2068_1 )
2285     xmlNewTextChild( root, NULL, (const xmlChar*)"romtc20681", (const xmlChar*)settings->rom_tc2068_1 );
2286   if( settings->rom_ts2068_0 )
2287     xmlNewTextChild( root, NULL, (const xmlChar*)"romts20680", (const xmlChar*)settings->rom_ts2068_0 );
2288   if( settings->rom_ts2068_1 )
2289     xmlNewTextChild( root, NULL, (const xmlChar*)"romts20681", (const xmlChar*)settings->rom_ts2068_1 );
2290   xmlNewTextChild( root, NULL, (const xmlChar*)"rs232handshake", (const xmlChar*)(settings->rs232_handshake ? "1" : "0") );
2291   if( settings->rs232_rx )
2292     xmlNewTextChild( root, NULL, (const xmlChar*)"rs232rx", (const xmlChar*)settings->rs232_rx );
2293   if( settings->rs232_tx )
2294     xmlNewTextChild( root, NULL, (const xmlChar*)"rs232tx", (const xmlChar*)settings->rs232_tx );
2295   xmlNewTextChild( root, NULL, (const xmlChar*)"rzxautosaves", (const xmlChar*)(settings->rzx_autosaves ? "1" : "0") );
2296   xmlNewTextChild( root, NULL, (const xmlChar*)"compressrzx", (const xmlChar*)(settings->rzx_compression ? "1" : "0") );
2297   xmlNewTextChild( root, NULL, (const xmlChar*)"simpleide", (const xmlChar*)(settings->simpleide_active ? "1" : "0") );
2298   if( settings->simpleide_master_file )
2299     xmlNewTextChild( root, NULL, (const xmlChar*)"simpleidemasterfile", (const xmlChar*)settings->simpleide_master_file );
2300   if( settings->simpleide_slave_file )
2301     xmlNewTextChild( root, NULL, (const xmlChar*)"simpleideslavefile", (const xmlChar*)settings->simpleide_slave_file );
2302   xmlNewTextChild( root, NULL, (const xmlChar*)"slttraps", (const xmlChar*)(settings->slt_traps ? "1" : "0") );
2303   if( settings->snapshot )
2304     xmlNewTextChild( root, NULL, (const xmlChar*)"snapshot", (const xmlChar*)settings->snapshot );
2305   if( settings->snet )
2306     xmlNewTextChild( root, NULL, (const xmlChar*)"snet", (const xmlChar*)settings->snet );
2307   xmlNewTextChild( root, NULL, (const xmlChar*)"sound", (const xmlChar*)(settings->sound ? "1" : "0") );
2308   if( settings->sound_device )
2309     xmlNewTextChild( root, NULL, (const xmlChar*)"sounddevice", (const xmlChar*)settings->sound_device );
2310   xmlNewTextChild( root, NULL, (const xmlChar*)"soundforce8bit", (const xmlChar*)(settings->sound_force_8bit ? "1" : "0") );
2311   snprintf( buffer, 80, "%d", settings->sound_freq );
2312   xmlNewTextChild( root, NULL, (const xmlChar*)"soundfreq", (const xmlChar*)buffer );
2313   xmlNewTextChild( root, NULL, (const xmlChar*)"loadingsound", (const xmlChar*)(settings->sound_load ? "1" : "0") );
2314   if( settings->speaker_type )
2315     xmlNewTextChild( root, NULL, (const xmlChar*)"speakertype", (const xmlChar*)settings->speaker_type );
2316   xmlNewTextChild( root, NULL, (const xmlChar*)"speccyboot", (const xmlChar*)(settings->speccyboot ? "1" : "0") );
2317   if( settings->speccyboot_tap )
2318     xmlNewTextChild( root, NULL, (const xmlChar*)"speccyboottap", (const xmlChar*)settings->speccyboot_tap );
2319   xmlNewTextChild( root, NULL, (const xmlChar*)"specdrum", (const xmlChar*)(settings->specdrum ? "1" : "0") );
2320   xmlNewTextChild( root, NULL, (const xmlChar*)"spectranet", (const xmlChar*)(settings->spectranet ? "1" : "0") );
2321   xmlNewTextChild( root, NULL, (const xmlChar*)"spectranetdisable", (const xmlChar*)(settings->spectranet_disable ? "1" : "0") );
2322   if( settings->start_machine )
2323     xmlNewTextChild( root, NULL, (const xmlChar*)"machine", (const xmlChar*)settings->start_machine );
2324   if( settings->start_scaler_mode )
2325     xmlNewTextChild( root, NULL, (const xmlChar*)"graphicsfilter", (const xmlChar*)settings->start_scaler_mode );
2326   xmlNewTextChild( root, NULL, (const xmlChar*)"statusbar", (const xmlChar*)(settings->statusbar ? "1" : "0") );
2327   if( settings->stereo_ay )
2328     xmlNewTextChild( root, NULL, (const xmlChar*)"separation", (const xmlChar*)settings->stereo_ay );
2329   xmlNewTextChild( root, NULL, (const xmlChar*)"strictaspecthint", (const xmlChar*)(settings->strict_aspect_hint ? "1" : "0") );
2330   if( settings->svga_modes )
2331     xmlNewTextChild( root, NULL, (const xmlChar*)"svgamodes", (const xmlChar*)settings->svga_modes );
2332   if( settings->tape_file )
2333     xmlNewTextChild( root, NULL, (const xmlChar*)"tapefile", (const xmlChar*)settings->tape_file );
2334   xmlNewTextChild( root, NULL, (const xmlChar*)"tapetraps", (const xmlChar*)(settings->tape_traps ? "1" : "0") );
2335   xmlNewTextChild( root, NULL, (const xmlChar*)"unittests", (const xmlChar*)(settings->unittests ? "1" : "0") );
2336   snprintf( buffer, 80, "%d", settings->volume_ay );
2337   xmlNewTextChild( root, NULL, (const xmlChar*)"volumeay", (const xmlChar*)buffer );
2338   snprintf( buffer, 80, "%d", settings->volume_beeper );
2339   xmlNewTextChild( root, NULL, (const xmlChar*)"volumebeeper", (const xmlChar*)buffer );
2340   snprintf( buffer, 80, "%d", settings->volume_specdrum );
2341   xmlNewTextChild( root, NULL, (const xmlChar*)"volumespecdrum", (const xmlChar*)buffer );
2342   xmlNewTextChild( root, NULL, (const xmlChar*)"writableroms", (const xmlChar*)(settings->writable_roms ? "1" : "0") );
2343   xmlNewTextChild( root, NULL, (const xmlChar*)"zxatasp", (const xmlChar*)(settings->zxatasp_active ? "1" : "0") );
2344   if( settings->zxatasp_master_file )
2345     xmlNewTextChild( root, NULL, (const xmlChar*)"zxataspmasterfile", (const xmlChar*)settings->zxatasp_master_file );
2346   if( settings->zxatasp_slave_file )
2347     xmlNewTextChild( root, NULL, (const xmlChar*)"zxataspslavefile", (const xmlChar*)settings->zxatasp_slave_file );
2348   xmlNewTextChild( root, NULL, (const xmlChar*)"zxataspupload", (const xmlChar*)(settings->zxatasp_upload ? "1" : "0") );
2349   xmlNewTextChild( root, NULL, (const xmlChar*)"zxataspwriteprotect", (const xmlChar*)(settings->zxatasp_wp ? "1" : "0") );
2350   xmlNewTextChild( root, NULL, (const xmlChar*)"zxcf", (const xmlChar*)(settings->zxcf_active ? "1" : "0") );
2351   if( settings->zxcf_pri_file )
2352     xmlNewTextChild( root, NULL, (const xmlChar*)"zxcfcffile", (const xmlChar*)settings->zxcf_pri_file );
2353   xmlNewTextChild( root, NULL, (const xmlChar*)"zxcfupload", (const xmlChar*)(settings->zxcf_upload ? "1" : "0") );
2354   xmlNewTextChild( root, NULL, (const xmlChar*)"zxprinter", (const xmlChar*)(settings->zxprinter ? "1" : "0") );
2355 #line 318"../settings.pl"
2356 
2357   xmlSaveFormatFile( path, doc, 1 );
2358 
2359   xmlFreeDoc( doc );
2360 
2361   return 0;
2362 }
2363 
2364 #else				/* #ifdef HAVE_LIB_XML2 */
2365 
2366 /* Read options from the config file as ini file (if libxml2 is not available) */
2367 
2368 static int
read_config_file(settings_info * settings)2369 read_config_file( settings_info *settings )
2370 {
2371   const char *home; char path[ PATH_MAX ];
2372   struct stat stat_info;
2373   int error;
2374 
2375   utils_file file;
2376 
2377   home = compat_get_home_path(); if( !home ) return 1;
2378 
2379   snprintf( path, PATH_MAX, "%s/%s", home, CONFIG_FILE_NAME );
2380 
2381   /* See if the file exists; if doesn't, it's not a problem */
2382   if( stat( path, &stat_info ) ) {
2383 #if defined(VITA) || defined (__CELLOS_LV2__)
2384     return 0;
2385 #else
2386     if( errno == ENOENT ) {
2387       return 0;
2388     } else {
2389       ui_error( UI_ERROR_ERROR, "couldn't stat '%s': %s", path,
2390 		strerror( errno ) );
2391       return 1;
2392     }
2393 #endif
2394   }
2395 
2396   error = utils_read_file( path, &file );
2397   if( error ) {
2398     ui_error( UI_ERROR_ERROR, "error reading config file" );
2399     return 1;
2400   }
2401 
2402   if( parse_ini( &file, settings ) ) { utils_close_file( &file ); return 1; }
2403 
2404   utils_close_file( &file );
2405 
2406   return 0;
2407 }
2408 
2409 static int
settings_var(settings_info * settings,unsigned char * name,unsigned char * last,int ** val_int,char *** val_char,unsigned char ** next)2410 settings_var( settings_info *settings, unsigned char *name, unsigned char *last,
2411               int **val_int, char ***val_char, unsigned char **next  )
2412 {
2413   unsigned char* cpos;
2414   size_t n;
2415 
2416   *val_int = NULL;
2417   *val_char = NULL;
2418 
2419   *next = name;
2420   while( name < last && ( *name == ' ' || *name == '\t' || *name == '\r' ||
2421                           *name == '\n' ) ) {
2422     *next = ++name;					/* seek to first char */
2423   }
2424   cpos = name;
2425 
2426   while( cpos < last && ( *cpos != '=' && *cpos != ' ' && *cpos != '\t' &&
2427                           *cpos != '\r' && *cpos != '\n' ) ) cpos++;
2428   *next = cpos;
2429   n = cpos - name;		/* length of name */
2430 
2431   while( *next < last && **next != '=' ) {		/* search for '=' */
2432     if( **next != ' ' && **next != '\t' && **next != '\r' && **next != '\n' )
2433       return 1;	/* error in value */
2434     (*next)++;
2435   }
2436   if( *next < last) (*next)++;		/* set after '=' */
2437 /*  ui_error( UI_ERROR_WARNING, "Config: (%5s): ", name ); */
2438 
2439   if( n == 16 && !strncmp( (const char *)name, "accelerateloader", n ) ) {
2440     *val_int = &settings->accelerate_loader;
2441     return 0;
2442   }
2443   if( n == 10 && !strncmp( (const char *)name, "aspecthint", n ) ) {
2444     *val_int = &settings->aspect_hint;
2445     return 0;
2446   }
2447   if( n == 8 && !strncmp( (const char *)name, "autoload", n ) ) {
2448     *val_int = &settings->auto_load;
2449     return 0;
2450   }
2451   if( n == 16 && !strncmp( (const char *)name, "autosavesettings", n ) ) {
2452     *val_int = &settings->autosave_settings;
2453     return 0;
2454   }
2455   if( n == 7 && !strncmp( (const char *)name, "beta128", n ) ) {
2456     *val_int = &settings->beta128;
2457     return 0;
2458   }
2459   if( n == 13 && !strncmp( (const char *)name, "beta12848boot", n ) ) {
2460     *val_int = &settings->beta128_48boot;
2461     return 0;
2462   }
2463   if( n == 8 && !strncmp( (const char *)name, "betadisk", n ) ) {
2464     *val_char = &settings->betadisk_file;
2465     return 0;
2466   }
2467   if( n == 4 && !strncmp( (const char *)name, "bwtv", n ) ) {
2468     *val_int = &settings->bw_tv;
2469     return 0;
2470   }
2471   if( n == 15 && !strncmp( (const char *)name, "competitioncode", n ) ) {
2472     *val_int = &settings->competition_code;
2473     return 0;
2474   }
2475   if( n == 15 && !strncmp( (const char *)name, "competitionmode", n ) ) {
2476     *val_int = &settings->competition_mode;
2477     return 0;
2478   }
2479   if( n == 14 && !strncmp( (const char *)name, "confirmactions", n ) ) {
2480     *val_int = &settings->confirm_actions;
2481     return 0;
2482   }
2483   if( n == 4 && !strncmp( (const char *)name, "dock", n ) ) {
2484     *val_char = &settings->dck_file;
2485     return 0;
2486   }
2487   if( n == 15 && !strncmp( (const char *)name, "debuggercommand", n ) ) {
2488     *val_char = &settings->debugger_command;
2489     return 0;
2490   }
2491   if( n == 12 && !strncmp( (const char *)name, "detectloader", n ) ) {
2492     *val_int = &settings->detect_loader;
2493     return 0;
2494   }
2495   if( n == 8 && !strncmp( (const char *)name, "disciple", n ) ) {
2496     *val_int = &settings->disciple;
2497     return 0;
2498   }
2499   if( n == 12 && !strncmp( (const char *)name, "discipledisk", n ) ) {
2500     *val_char = &settings->discipledisk_file;
2501     return 0;
2502   }
2503   if( n == 12 && !strncmp( (const char *)name, "diskaskmerge", n ) ) {
2504     *val_int = &settings->disk_ask_merge;
2505     return 0;
2506   }
2507   if( n == 12 && !strncmp( (const char *)name, "disktrymerge", n ) ) {
2508     *val_char = &settings->disk_try_merge;
2509     return 0;
2510   }
2511   if( n == 6 && !strncmp( (const char *)name, "divide", n ) ) {
2512     *val_int = &settings->divide_enabled;
2513     return 0;
2514   }
2515   if( n == 16 && !strncmp( (const char *)name, "dividemasterfile", n ) ) {
2516     *val_char = &settings->divide_master_file;
2517     return 0;
2518   }
2519   if( n == 15 && !strncmp( (const char *)name, "divideslavefile", n ) ) {
2520     *val_char = &settings->divide_slave_file;
2521     return 0;
2522   }
2523   if( n == 18 && !strncmp( (const char *)name, "dividewriteprotect", n ) ) {
2524     *val_int = &settings->divide_wp;
2525     return 0;
2526   }
2527   if( n == 12 && !strncmp( (const char *)name, "doublescreen", n ) ) {
2528 /*    *val_null = &settings->double_screen; */
2529     return 0;
2530   }
2531   if( n == 14 && !strncmp( (const char *)name, "doublescanmode", n ) ) {
2532     *val_int = &settings->doublescan_mode;
2533     return 0;
2534   }
2535   if( n == 15 && !strncmp( (const char *)name, "drive40maxtrack", n ) ) {
2536     *val_int = &settings->drive_40_max_track;
2537     return 0;
2538   }
2539   if( n == 15 && !strncmp( (const char *)name, "drive80maxtrack", n ) ) {
2540     *val_int = &settings->drive_80_max_track;
2541     return 0;
2542   }
2543   if( n == 17 && !strncmp( (const char *)name, "drivebeta128atype", n ) ) {
2544     *val_char = &settings->drive_beta128a_type;
2545     return 0;
2546   }
2547   if( n == 17 && !strncmp( (const char *)name, "drivebeta128btype", n ) ) {
2548     *val_char = &settings->drive_beta128b_type;
2549     return 0;
2550   }
2551   if( n == 17 && !strncmp( (const char *)name, "drivebeta128ctype", n ) ) {
2552     *val_char = &settings->drive_beta128c_type;
2553     return 0;
2554   }
2555   if( n == 17 && !strncmp( (const char *)name, "drivebeta128dtype", n ) ) {
2556     *val_char = &settings->drive_beta128d_type;
2557     return 0;
2558   }
2559   if( n == 18 && !strncmp( (const char *)name, "drivedisciple1type", n ) ) {
2560     *val_char = &settings->drive_disciple1_type;
2561     return 0;
2562   }
2563   if( n == 18 && !strncmp( (const char *)name, "drivedisciple2type", n ) ) {
2564     *val_char = &settings->drive_disciple2_type;
2565     return 0;
2566   }
2567   if( n == 14 && !strncmp( (const char *)name, "driveopus1type", n ) ) {
2568     *val_char = &settings->drive_opus1_type;
2569     return 0;
2570   }
2571   if( n == 14 && !strncmp( (const char *)name, "driveopus2type", n ) ) {
2572     *val_char = &settings->drive_opus2_type;
2573     return 0;
2574   }
2575   if( n == 15 && !strncmp( (const char *)name, "driveplus3atype", n ) ) {
2576     *val_char = &settings->drive_plus3a_type;
2577     return 0;
2578   }
2579   if( n == 15 && !strncmp( (const char *)name, "driveplus3btype", n ) ) {
2580     *val_char = &settings->drive_plus3b_type;
2581     return 0;
2582   }
2583   if( n == 15 && !strncmp( (const char *)name, "driveplusd1type", n ) ) {
2584     *val_char = &settings->drive_plusd1_type;
2585     return 0;
2586   }
2587   if( n == 15 && !strncmp( (const char *)name, "driveplusd2type", n ) ) {
2588     *val_char = &settings->drive_plusd2_type;
2589     return 0;
2590   }
2591   if( n == 13 && !strncmp( (const char *)name, "embedsnapshot", n ) ) {
2592     *val_int = &settings->embed_snapshot;
2593     return 0;
2594   }
2595   if( n == 5 && !strncmp( (const char *)name, "speed", n ) ) {
2596     *val_int = &settings->emulation_speed;
2597     return 0;
2598   }
2599   if( n == 8 && !strncmp( (const char *)name, "fastload", n ) ) {
2600     *val_int = &settings->fastload;
2601     return 0;
2602   }
2603   if( n == 6 && !strncmp( (const char *)name, "fbmode", n ) ) {
2604     *val_int = &settings->fb_mode;
2605     return 0;
2606   }
2607   if( n == 4 && !strncmp( (const char *)name, "rate", n ) ) {
2608     *val_int = &settings->frame_rate;
2609     return 0;
2610   }
2611   if( n == 10 && !strncmp( (const char *)name, "fullscreen", n ) ) {
2612     *val_int = &settings->full_screen;
2613     return 0;
2614   }
2615   if( n == 6 && !strncmp( (const char *)name, "fuller", n ) ) {
2616     *val_int = &settings->fuller;
2617     return 0;
2618   }
2619   if( n == 7 && !strncmp( (const char *)name, "if2cart", n ) ) {
2620     *val_char = &settings->if2_file;
2621     return 0;
2622   }
2623   if( n == 10 && !strncmp( (const char *)name, "interface1", n ) ) {
2624     *val_int = &settings->interface1;
2625     return 0;
2626   }
2627   if( n == 10 && !strncmp( (const char *)name, "interface2", n ) ) {
2628     *val_int = &settings->interface2;
2629     return 0;
2630   }
2631   if( n == 6 && !strncmp( (const char *)name, "issue2", n ) ) {
2632     *val_int = &settings->issue2;
2633     return 0;
2634   }
2635   if( n == 8 && !strncmp( (const char *)name, "kempston", n ) ) {
2636     *val_int = &settings->joy_kempston;
2637     return 0;
2638   }
2639   if( n == 14 && !strncmp( (const char *)name, "joystickprompt", n ) ) {
2640     *val_int = &settings->joy_prompt;
2641     return 0;
2642   }
2643   if( n == 9 && !strncmp( (const char *)name, "joystick1", n ) ) {
2644     *val_char = &settings->joystick_1;
2645     return 0;
2646   }
2647   if( n == 14 && !strncmp( (const char *)name, "joystick1fire1", n ) ) {
2648     *val_int = &settings->joystick_1_fire_1;
2649     return 0;
2650   }
2651   if( n == 15 && !strncmp( (const char *)name, "joystick1fire10", n ) ) {
2652     *val_int = &settings->joystick_1_fire_10;
2653     return 0;
2654   }
2655   if( n == 15 && !strncmp( (const char *)name, "joystick1fire11", n ) ) {
2656     *val_int = &settings->joystick_1_fire_11;
2657     return 0;
2658   }
2659   if( n == 15 && !strncmp( (const char *)name, "joystick1fire12", n ) ) {
2660     *val_int = &settings->joystick_1_fire_12;
2661     return 0;
2662   }
2663   if( n == 15 && !strncmp( (const char *)name, "joystick1fire13", n ) ) {
2664     *val_int = &settings->joystick_1_fire_13;
2665     return 0;
2666   }
2667   if( n == 15 && !strncmp( (const char *)name, "joystick1fire14", n ) ) {
2668     *val_int = &settings->joystick_1_fire_14;
2669     return 0;
2670   }
2671   if( n == 15 && !strncmp( (const char *)name, "joystick1fire15", n ) ) {
2672     *val_int = &settings->joystick_1_fire_15;
2673     return 0;
2674   }
2675   if( n == 14 && !strncmp( (const char *)name, "joystick1fire2", n ) ) {
2676     *val_int = &settings->joystick_1_fire_2;
2677     return 0;
2678   }
2679   if( n == 14 && !strncmp( (const char *)name, "joystick1fire3", n ) ) {
2680     *val_int = &settings->joystick_1_fire_3;
2681     return 0;
2682   }
2683   if( n == 14 && !strncmp( (const char *)name, "joystick1fire4", n ) ) {
2684     *val_int = &settings->joystick_1_fire_4;
2685     return 0;
2686   }
2687   if( n == 14 && !strncmp( (const char *)name, "joystick1fire5", n ) ) {
2688     *val_int = &settings->joystick_1_fire_5;
2689     return 0;
2690   }
2691   if( n == 14 && !strncmp( (const char *)name, "joystick1fire6", n ) ) {
2692     *val_int = &settings->joystick_1_fire_6;
2693     return 0;
2694   }
2695   if( n == 14 && !strncmp( (const char *)name, "joystick1fire7", n ) ) {
2696     *val_int = &settings->joystick_1_fire_7;
2697     return 0;
2698   }
2699   if( n == 14 && !strncmp( (const char *)name, "joystick1fire8", n ) ) {
2700     *val_int = &settings->joystick_1_fire_8;
2701     return 0;
2702   }
2703   if( n == 14 && !strncmp( (const char *)name, "joystick1fire9", n ) ) {
2704     *val_int = &settings->joystick_1_fire_9;
2705     return 0;
2706   }
2707   if( n == 15 && !strncmp( (const char *)name, "joystick1output", n ) ) {
2708     *val_int = &settings->joystick_1_output;
2709     return 0;
2710   }
2711   if( n == 9 && !strncmp( (const char *)name, "joystick2", n ) ) {
2712     *val_char = &settings->joystick_2;
2713     return 0;
2714   }
2715   if( n == 14 && !strncmp( (const char *)name, "joystick2fire1", n ) ) {
2716     *val_int = &settings->joystick_2_fire_1;
2717     return 0;
2718   }
2719   if( n == 15 && !strncmp( (const char *)name, "joystick2fire10", n ) ) {
2720     *val_int = &settings->joystick_2_fire_10;
2721     return 0;
2722   }
2723   if( n == 15 && !strncmp( (const char *)name, "joystick2fire11", n ) ) {
2724     *val_int = &settings->joystick_2_fire_11;
2725     return 0;
2726   }
2727   if( n == 15 && !strncmp( (const char *)name, "joystick2fire12", n ) ) {
2728     *val_int = &settings->joystick_2_fire_12;
2729     return 0;
2730   }
2731   if( n == 15 && !strncmp( (const char *)name, "joystick2fire13", n ) ) {
2732     *val_int = &settings->joystick_2_fire_13;
2733     return 0;
2734   }
2735   if( n == 15 && !strncmp( (const char *)name, "joystick2fire14", n ) ) {
2736     *val_int = &settings->joystick_2_fire_14;
2737     return 0;
2738   }
2739   if( n == 15 && !strncmp( (const char *)name, "joystick2fire15", n ) ) {
2740     *val_int = &settings->joystick_2_fire_15;
2741     return 0;
2742   }
2743   if( n == 14 && !strncmp( (const char *)name, "joystick2fire2", n ) ) {
2744     *val_int = &settings->joystick_2_fire_2;
2745     return 0;
2746   }
2747   if( n == 14 && !strncmp( (const char *)name, "joystick2fire3", n ) ) {
2748     *val_int = &settings->joystick_2_fire_3;
2749     return 0;
2750   }
2751   if( n == 14 && !strncmp( (const char *)name, "joystick2fire4", n ) ) {
2752     *val_int = &settings->joystick_2_fire_4;
2753     return 0;
2754   }
2755   if( n == 14 && !strncmp( (const char *)name, "joystick2fire5", n ) ) {
2756     *val_int = &settings->joystick_2_fire_5;
2757     return 0;
2758   }
2759   if( n == 14 && !strncmp( (const char *)name, "joystick2fire6", n ) ) {
2760     *val_int = &settings->joystick_2_fire_6;
2761     return 0;
2762   }
2763   if( n == 14 && !strncmp( (const char *)name, "joystick2fire7", n ) ) {
2764     *val_int = &settings->joystick_2_fire_7;
2765     return 0;
2766   }
2767   if( n == 14 && !strncmp( (const char *)name, "joystick2fire8", n ) ) {
2768     *val_int = &settings->joystick_2_fire_8;
2769     return 0;
2770   }
2771   if( n == 14 && !strncmp( (const char *)name, "joystick2fire9", n ) ) {
2772     *val_int = &settings->joystick_2_fire_9;
2773     return 0;
2774   }
2775   if( n == 15 && !strncmp( (const char *)name, "joystick2output", n ) ) {
2776     *val_int = &settings->joystick_2_output;
2777     return 0;
2778   }
2779   if( n == 20 && !strncmp( (const char *)name, "joystickkeyboarddown", n ) ) {
2780     *val_int = &settings->joystick_keyboard_down;
2781     return 0;
2782   }
2783   if( n == 20 && !strncmp( (const char *)name, "joystickkeyboardfire", n ) ) {
2784     *val_int = &settings->joystick_keyboard_fire;
2785     return 0;
2786   }
2787   if( n == 20 && !strncmp( (const char *)name, "joystickkeyboardleft", n ) ) {
2788     *val_int = &settings->joystick_keyboard_left;
2789     return 0;
2790   }
2791   if( n == 22 && !strncmp( (const char *)name, "joystickkeyboardoutput", n ) ) {
2792     *val_int = &settings->joystick_keyboard_output;
2793     return 0;
2794   }
2795   if( n == 21 && !strncmp( (const char *)name, "joystickkeyboardright", n ) ) {
2796     *val_int = &settings->joystick_keyboard_right;
2797     return 0;
2798   }
2799   if( n == 18 && !strncmp( (const char *)name, "joystickkeyboardup", n ) ) {
2800     *val_int = &settings->joystick_keyboard_up;
2801     return 0;
2802   }
2803   if( n == 13 && !strncmp( (const char *)name, "kempstonmouse", n ) ) {
2804     *val_int = &settings->kempston_mouse;
2805     return 0;
2806   }
2807   if( n == 11 && !strncmp( (const char *)name, "latetimings", n ) ) {
2808     *val_int = &settings->late_timings;
2809     return 0;
2810   }
2811   if( n == 14 && !strncmp( (const char *)name, "microdrivefile", n ) ) {
2812     *val_char = &settings->mdr_file;
2813     return 0;
2814   }
2815   if( n == 15 && !strncmp( (const char *)name, "microdrive2file", n ) ) {
2816     *val_char = &settings->mdr_file2;
2817     return 0;
2818   }
2819   if( n == 15 && !strncmp( (const char *)name, "microdrive3file", n ) ) {
2820     *val_char = &settings->mdr_file3;
2821     return 0;
2822   }
2823   if( n == 15 && !strncmp( (const char *)name, "microdrive4file", n ) ) {
2824     *val_char = &settings->mdr_file4;
2825     return 0;
2826   }
2827   if( n == 15 && !strncmp( (const char *)name, "microdrive5file", n ) ) {
2828     *val_char = &settings->mdr_file5;
2829     return 0;
2830   }
2831   if( n == 15 && !strncmp( (const char *)name, "microdrive6file", n ) ) {
2832     *val_char = &settings->mdr_file6;
2833     return 0;
2834   }
2835   if( n == 15 && !strncmp( (const char *)name, "microdrive7file", n ) ) {
2836     *val_char = &settings->mdr_file7;
2837     return 0;
2838   }
2839   if( n == 15 && !strncmp( (const char *)name, "microdrive8file", n ) ) {
2840     *val_char = &settings->mdr_file8;
2841     return 0;
2842   }
2843   if( n == 6 && !strncmp( (const char *)name, "mdrlen", n ) ) {
2844     *val_int = &settings->mdr_len;
2845     return 0;
2846   }
2847   if( n == 12 && !strncmp( (const char *)name, "mdrrandomlen", n ) ) {
2848     *val_int = &settings->mdr_random_len;
2849     return 0;
2850   }
2851   if( n == 7 && !strncmp( (const char *)name, "melodik", n ) ) {
2852     *val_int = &settings->melodik;
2853     return 0;
2854   }
2855   if( n == 16 && !strncmp( (const char *)name, "mouseswapbuttons", n ) ) {
2856     *val_int = &settings->mouse_swap_buttons;
2857     return 0;
2858   }
2859   if( n == 10 && !strncmp( (const char *)name, "moviecompr", n ) ) {
2860     *val_char = &settings->movie_compr;
2861     return 0;
2862   }
2863   if( n == 10 && !strncmp( (const char *)name, "moviestart", n ) ) {
2864     *val_char = &settings->movie_start;
2865     return 0;
2866   }
2867   if( n == 17 && !strncmp( (const char *)name, "moviestopafterrzx", n ) ) {
2868     *val_int = &settings->movie_stop_after_rzx;
2869     return 0;
2870   }
2871   if( n == 4 && !strncmp( (const char *)name, "opus", n ) ) {
2872     *val_int = &settings->opus;
2873     return 0;
2874   }
2875   if( n == 8 && !strncmp( (const char *)name, "opusdisk", n ) ) {
2876     *val_char = &settings->opusdisk_file;
2877     return 0;
2878   }
2879   if( n == 7 && !strncmp( (const char *)name, "paltv2x", n ) ) {
2880     *val_int = &settings->pal_tv2x;
2881     return 0;
2882   }
2883   if( n == 12 && !strncmp( (const char *)name, "playbackfile", n ) ) {
2884     *val_char = &settings->playback_file;
2885     return 0;
2886   }
2887   if( n == 20 && !strncmp( (const char *)name, "plus3detectspeedlock", n ) ) {
2888     *val_int = &settings->plus3_detect_speedlock;
2889     return 0;
2890   }
2891   if( n == 9 && !strncmp( (const char *)name, "plus3disk", n ) ) {
2892     *val_char = &settings->plus3disk_file;
2893     return 0;
2894   }
2895   if( n == 5 && !strncmp( (const char *)name, "plusd", n ) ) {
2896     *val_int = &settings->plusd;
2897     return 0;
2898   }
2899   if( n == 9 && !strncmp( (const char *)name, "plusddisk", n ) ) {
2900     *val_char = &settings->plusddisk_file;
2901     return 0;
2902   }
2903   if( n == 7 && !strncmp( (const char *)name, "printer", n ) ) {
2904     *val_int = &settings->printer;
2905     return 0;
2906   }
2907   if( n == 12 && !strncmp( (const char *)name, "graphicsfile", n ) ) {
2908     *val_char = &settings->printer_graphics_filename;
2909     return 0;
2910   }
2911   if( n == 8 && !strncmp( (const char *)name, "textfile", n ) ) {
2912     *val_char = &settings->printer_text_filename;
2913     return 0;
2914   }
2915   if( n == 8 && !strncmp( (const char *)name, "rawrs232", n ) ) {
2916 /*    *val_null = &settings->raw_rs232; */
2917     return 0;
2918   }
2919   if( n == 7 && !strncmp( (const char *)name, "rawsnet", n ) ) {
2920     *val_int = &settings->raw_s_net;
2921     return 0;
2922   }
2923   if( n == 10 && !strncmp( (const char *)name, "recordfile", n ) ) {
2924     *val_char = &settings->record_file;
2925     return 0;
2926   }
2927   if( n == 7 && !strncmp( (const char *)name, "rom1280", n ) ) {
2928     *val_char = &settings->rom_128_0;
2929     return 0;
2930   }
2931   if( n == 7 && !strncmp( (const char *)name, "rom1281", n ) ) {
2932     *val_char = &settings->rom_128_1;
2933     return 0;
2934   }
2935   if( n == 5 && !strncmp( (const char *)name, "rom16", n ) ) {
2936     *val_char = &settings->rom_16;
2937     return 0;
2938   }
2939   if( n == 5 && !strncmp( (const char *)name, "rom48", n ) ) {
2940     *val_char = &settings->rom_48;
2941     return 0;
2942   }
2943   if( n == 10 && !strncmp( (const char *)name, "rombeta128", n ) ) {
2944     *val_char = &settings->rom_beta128;
2945     return 0;
2946   }
2947   if( n == 11 && !strncmp( (const char *)name, "romdisciple", n ) ) {
2948     *val_char = &settings->rom_disciple;
2949     return 0;
2950   }
2951   if( n == 13 && !strncmp( (const char *)name, "rominterfacei", n ) ) {
2952     *val_char = &settings->rom_interface_i;
2953     return 0;
2954   }
2955   if( n == 7 && !strncmp( (const char *)name, "romopus", n ) ) {
2956     *val_char = &settings->rom_opus;
2957     return 0;
2958   }
2959   if( n == 16 && !strncmp( (const char *)name, "rompentagon10240", n ) ) {
2960     *val_char = &settings->rom_pentagon1024_0;
2961     return 0;
2962   }
2963   if( n == 16 && !strncmp( (const char *)name, "rompentagon10241", n ) ) {
2964     *val_char = &settings->rom_pentagon1024_1;
2965     return 0;
2966   }
2967   if( n == 16 && !strncmp( (const char *)name, "rompentagon10242", n ) ) {
2968     *val_char = &settings->rom_pentagon1024_2;
2969     return 0;
2970   }
2971   if( n == 16 && !strncmp( (const char *)name, "rompentagon10243", n ) ) {
2972     *val_char = &settings->rom_pentagon1024_3;
2973     return 0;
2974   }
2975   if( n == 15 && !strncmp( (const char *)name, "rompentagon5120", n ) ) {
2976     *val_char = &settings->rom_pentagon512_0;
2977     return 0;
2978   }
2979   if( n == 15 && !strncmp( (const char *)name, "rompentagon5121", n ) ) {
2980     *val_char = &settings->rom_pentagon512_1;
2981     return 0;
2982   }
2983   if( n == 15 && !strncmp( (const char *)name, "rompentagon5122", n ) ) {
2984     *val_char = &settings->rom_pentagon512_2;
2985     return 0;
2986   }
2987   if( n == 15 && !strncmp( (const char *)name, "rompentagon5123", n ) ) {
2988     *val_char = &settings->rom_pentagon512_3;
2989     return 0;
2990   }
2991   if( n == 12 && !strncmp( (const char *)name, "rompentagon0", n ) ) {
2992     *val_char = &settings->rom_pentagon_0;
2993     return 0;
2994   }
2995   if( n == 12 && !strncmp( (const char *)name, "rompentagon1", n ) ) {
2996     *val_char = &settings->rom_pentagon_1;
2997     return 0;
2998   }
2999   if( n == 12 && !strncmp( (const char *)name, "rompentagon2", n ) ) {
3000     *val_char = &settings->rom_pentagon_2;
3001     return 0;
3002   }
3003   if( n == 9 && !strncmp( (const char *)name, "romplus20", n ) ) {
3004     *val_char = &settings->rom_plus2_0;
3005     return 0;
3006   }
3007   if( n == 9 && !strncmp( (const char *)name, "romplus21", n ) ) {
3008     *val_char = &settings->rom_plus2_1;
3009     return 0;
3010   }
3011   if( n == 10 && !strncmp( (const char *)name, "romplus2a0", n ) ) {
3012     *val_char = &settings->rom_plus2a_0;
3013     return 0;
3014   }
3015   if( n == 10 && !strncmp( (const char *)name, "romplus2a1", n ) ) {
3016     *val_char = &settings->rom_plus2a_1;
3017     return 0;
3018   }
3019   if( n == 10 && !strncmp( (const char *)name, "romplus2a2", n ) ) {
3020     *val_char = &settings->rom_plus2a_2;
3021     return 0;
3022   }
3023   if( n == 10 && !strncmp( (const char *)name, "romplus2a3", n ) ) {
3024     *val_char = &settings->rom_plus2a_3;
3025     return 0;
3026   }
3027   if( n == 9 && !strncmp( (const char *)name, "romplus30", n ) ) {
3028     *val_char = &settings->rom_plus3_0;
3029     return 0;
3030   }
3031   if( n == 9 && !strncmp( (const char *)name, "romplus31", n ) ) {
3032     *val_char = &settings->rom_plus3_1;
3033     return 0;
3034   }
3035   if( n == 9 && !strncmp( (const char *)name, "romplus32", n ) ) {
3036     *val_char = &settings->rom_plus3_2;
3037     return 0;
3038   }
3039   if( n == 9 && !strncmp( (const char *)name, "romplus33", n ) ) {
3040     *val_char = &settings->rom_plus3_3;
3041     return 0;
3042   }
3043   if( n == 10 && !strncmp( (const char *)name, "romplus3e0", n ) ) {
3044     *val_char = &settings->rom_plus3e_0;
3045     return 0;
3046   }
3047   if( n == 10 && !strncmp( (const char *)name, "romplus3e1", n ) ) {
3048     *val_char = &settings->rom_plus3e_1;
3049     return 0;
3050   }
3051   if( n == 10 && !strncmp( (const char *)name, "romplus3e2", n ) ) {
3052     *val_char = &settings->rom_plus3e_2;
3053     return 0;
3054   }
3055   if( n == 10 && !strncmp( (const char *)name, "romplus3e3", n ) ) {
3056     *val_char = &settings->rom_plus3e_3;
3057     return 0;
3058   }
3059   if( n == 8 && !strncmp( (const char *)name, "romplusd", n ) ) {
3060     *val_char = &settings->rom_plusd;
3061     return 0;
3062   }
3063   if( n == 12 && !strncmp( (const char *)name, "romscorpion0", n ) ) {
3064     *val_char = &settings->rom_scorpion_0;
3065     return 0;
3066   }
3067   if( n == 12 && !strncmp( (const char *)name, "romscorpion1", n ) ) {
3068     *val_char = &settings->rom_scorpion_1;
3069     return 0;
3070   }
3071   if( n == 12 && !strncmp( (const char *)name, "romscorpion2", n ) ) {
3072     *val_char = &settings->rom_scorpion_2;
3073     return 0;
3074   }
3075   if( n == 12 && !strncmp( (const char *)name, "romscorpion3", n ) ) {
3076     *val_char = &settings->rom_scorpion_3;
3077     return 0;
3078   }
3079   if( n == 10 && !strncmp( (const char *)name, "romspecse0", n ) ) {
3080     *val_char = &settings->rom_spec_se_0;
3081     return 0;
3082   }
3083   if( n == 10 && !strncmp( (const char *)name, "romspecse1", n ) ) {
3084     *val_char = &settings->rom_spec_se_1;
3085     return 0;
3086   }
3087   if( n == 13 && !strncmp( (const char *)name, "romspeccyboot", n ) ) {
3088     *val_char = &settings->rom_speccyboot;
3089     return 0;
3090   }
3091   if( n == 9 && !strncmp( (const char *)name, "romtc2048", n ) ) {
3092     *val_char = &settings->rom_tc2048;
3093     return 0;
3094   }
3095   if( n == 10 && !strncmp( (const char *)name, "romtc20680", n ) ) {
3096     *val_char = &settings->rom_tc2068_0;
3097     return 0;
3098   }
3099   if( n == 10 && !strncmp( (const char *)name, "romtc20681", n ) ) {
3100     *val_char = &settings->rom_tc2068_1;
3101     return 0;
3102   }
3103   if( n == 10 && !strncmp( (const char *)name, "romts20680", n ) ) {
3104     *val_char = &settings->rom_ts2068_0;
3105     return 0;
3106   }
3107   if( n == 10 && !strncmp( (const char *)name, "romts20681", n ) ) {
3108     *val_char = &settings->rom_ts2068_1;
3109     return 0;
3110   }
3111   if( n == 14 && !strncmp( (const char *)name, "rs232handshake", n ) ) {
3112     *val_int = &settings->rs232_handshake;
3113     return 0;
3114   }
3115   if( n == 7 && !strncmp( (const char *)name, "rs232rx", n ) ) {
3116     *val_char = &settings->rs232_rx;
3117     return 0;
3118   }
3119   if( n == 7 && !strncmp( (const char *)name, "rs232tx", n ) ) {
3120     *val_char = &settings->rs232_tx;
3121     return 0;
3122   }
3123   if( n == 12 && !strncmp( (const char *)name, "rzxautosaves", n ) ) {
3124     *val_int = &settings->rzx_autosaves;
3125     return 0;
3126   }
3127   if( n == 11 && !strncmp( (const char *)name, "compressrzx", n ) ) {
3128     *val_int = &settings->rzx_compression;
3129     return 0;
3130   }
3131   if( n == 9 && !strncmp( (const char *)name, "simpleide", n ) ) {
3132     *val_int = &settings->simpleide_active;
3133     return 0;
3134   }
3135   if( n == 19 && !strncmp( (const char *)name, "simpleidemasterfile", n ) ) {
3136     *val_char = &settings->simpleide_master_file;
3137     return 0;
3138   }
3139   if( n == 18 && !strncmp( (const char *)name, "simpleideslavefile", n ) ) {
3140     *val_char = &settings->simpleide_slave_file;
3141     return 0;
3142   }
3143   if( n == 8 && !strncmp( (const char *)name, "slttraps", n ) ) {
3144     *val_int = &settings->slt_traps;
3145     return 0;
3146   }
3147   if( n == 10 && !strncmp( (const char *)name, "snapsasz80", n ) ) {
3148 /*    *val_null = &settings->snapsasz80; */
3149     return 0;
3150   }
3151   if( n == 8 && !strncmp( (const char *)name, "snapshot", n ) ) {
3152     *val_char = &settings->snapshot;
3153     return 0;
3154   }
3155   if( n == 4 && !strncmp( (const char *)name, "snet", n ) ) {
3156     *val_char = &settings->snet;
3157     return 0;
3158   }
3159   if( n == 5 && !strncmp( (const char *)name, "sound", n ) ) {
3160     *val_int = &settings->sound;
3161     return 0;
3162   }
3163   if( n == 11 && !strncmp( (const char *)name, "sounddevice", n ) ) {
3164     *val_char = &settings->sound_device;
3165     return 0;
3166   }
3167   if( n == 14 && !strncmp( (const char *)name, "soundforce8bit", n ) ) {
3168     *val_int = &settings->sound_force_8bit;
3169     return 0;
3170   }
3171   if( n == 9 && !strncmp( (const char *)name, "soundfreq", n ) ) {
3172     *val_int = &settings->sound_freq;
3173     return 0;
3174   }
3175   if( n == 12 && !strncmp( (const char *)name, "loadingsound", n ) ) {
3176     *val_int = &settings->sound_load;
3177     return 0;
3178   }
3179   if( n == 11 && !strncmp( (const char *)name, "speakertype", n ) ) {
3180     *val_char = &settings->speaker_type;
3181     return 0;
3182   }
3183   if( n == 10 && !strncmp( (const char *)name, "speccyboot", n ) ) {
3184     *val_int = &settings->speccyboot;
3185     return 0;
3186   }
3187   if( n == 13 && !strncmp( (const char *)name, "speccyboottap", n ) ) {
3188     *val_char = &settings->speccyboot_tap;
3189     return 0;
3190   }
3191   if( n == 8 && !strncmp( (const char *)name, "specdrum", n ) ) {
3192     *val_int = &settings->specdrum;
3193     return 0;
3194   }
3195   if( n == 10 && !strncmp( (const char *)name, "spectranet", n ) ) {
3196     *val_int = &settings->spectranet;
3197     return 0;
3198   }
3199   if( n == 17 && !strncmp( (const char *)name, "spectranetdisable", n ) ) {
3200     *val_int = &settings->spectranet_disable;
3201     return 0;
3202   }
3203   if( n == 7 && !strncmp( (const char *)name, "machine", n ) ) {
3204     *val_char = &settings->start_machine;
3205     return 0;
3206   }
3207   if( n == 14 && !strncmp( (const char *)name, "graphicsfilter", n ) ) {
3208     *val_char = &settings->start_scaler_mode;
3209     return 0;
3210   }
3211   if( n == 9 && !strncmp( (const char *)name, "statusbar", n ) ) {
3212     *val_int = &settings->statusbar;
3213     return 0;
3214   }
3215   if( n == 10 && !strncmp( (const char *)name, "separation", n ) ) {
3216     *val_char = &settings->stereo_ay;
3217     return 0;
3218   }
3219   if( n == 16 && !strncmp( (const char *)name, "strictaspecthint", n ) ) {
3220     *val_int = &settings->strict_aspect_hint;
3221     return 0;
3222   }
3223   if( n == 9 && !strncmp( (const char *)name, "svgamodes", n ) ) {
3224     *val_char = &settings->svga_modes;
3225     return 0;
3226   }
3227   if( n == 8 && !strncmp( (const char *)name, "tapefile", n ) ) {
3228     *val_char = &settings->tape_file;
3229     return 0;
3230   }
3231   if( n == 9 && !strncmp( (const char *)name, "tapetraps", n ) ) {
3232     *val_int = &settings->tape_traps;
3233     return 0;
3234   }
3235   if( n == 9 && !strncmp( (const char *)name, "unittests", n ) ) {
3236     *val_int = &settings->unittests;
3237     return 0;
3238   }
3239   if( n == 8 && !strncmp( (const char *)name, "volumeay", n ) ) {
3240     *val_int = &settings->volume_ay;
3241     return 0;
3242   }
3243   if( n == 12 && !strncmp( (const char *)name, "volumebeeper", n ) ) {
3244     *val_int = &settings->volume_beeper;
3245     return 0;
3246   }
3247   if( n == 14 && !strncmp( (const char *)name, "volumespecdrum", n ) ) {
3248     *val_int = &settings->volume_specdrum;
3249     return 0;
3250   }
3251   if( n == 12 && !strncmp( (const char *)name, "writableroms", n ) ) {
3252     *val_int = &settings->writable_roms;
3253     return 0;
3254   }
3255   if( n == 7 && !strncmp( (const char *)name, "zxatasp", n ) ) {
3256     *val_int = &settings->zxatasp_active;
3257     return 0;
3258   }
3259   if( n == 17 && !strncmp( (const char *)name, "zxataspmasterfile", n ) ) {
3260     *val_char = &settings->zxatasp_master_file;
3261     return 0;
3262   }
3263   if( n == 16 && !strncmp( (const char *)name, "zxataspslavefile", n ) ) {
3264     *val_char = &settings->zxatasp_slave_file;
3265     return 0;
3266   }
3267   if( n == 13 && !strncmp( (const char *)name, "zxataspupload", n ) ) {
3268     *val_int = &settings->zxatasp_upload;
3269     return 0;
3270   }
3271   if( n == 19 && !strncmp( (const char *)name, "zxataspwriteprotect", n ) ) {
3272     *val_int = &settings->zxatasp_wp;
3273     return 0;
3274   }
3275   if( n == 4 && !strncmp( (const char *)name, "zxcf", n ) ) {
3276     *val_int = &settings->zxcf_active;
3277     return 0;
3278   }
3279   if( n == 10 && !strncmp( (const char *)name, "zxcfcffile", n ) ) {
3280     *val_char = &settings->zxcf_pri_file;
3281     return 0;
3282   }
3283   if( n == 10 && !strncmp( (const char *)name, "zxcfupload", n ) ) {
3284     *val_int = &settings->zxcf_upload;
3285     return 0;
3286   }
3287   if( n == 9 && !strncmp( (const char *)name, "zxprinter", n ) ) {
3288     *val_int = &settings->zxprinter;
3289     return 0;
3290   }
3291   return 1;
3292 }
3293 
3294 static int
parse_ini(utils_file * file,settings_info * settings)3295 parse_ini( utils_file *file, settings_info *settings )
3296 {
3297   unsigned char *cpos, *cpos_new;
3298   int *val_int;
3299   char **val_char;
3300 
3301   cpos = file->buffer;
3302 
3303   /* Read until the end of file */
3304   while( cpos < file->buffer + file->length ) {
3305     if( settings_var( settings, cpos, file->buffer + file->length, &val_int,
3306                       &val_char, &cpos_new ) ) {
3307       /* error in name or something else ... */
3308       cpos = cpos_new + 1;
3309       ui_error( UI_ERROR_WARNING,
3310                 "Unknown and/or invalid setting '%s' in config file", cpos );
3311       continue;
3312     }
3313     cpos = cpos_new;
3314     if( val_int ) {
3315 	*val_int = atoi( (char *)cpos );
3316 	while( cpos < file->buffer + file->length &&
3317 		( *cpos != '\0' && *cpos != '\r' && *cpos != '\n' ) ) cpos++;
3318     } else if( val_char ) {
3319 	char *value = (char *)cpos;
3320 	size_t n = 0;
3321 	while( cpos < file->buffer + file->length &&
3322 		( *cpos != '\0' && *cpos != '\r' && *cpos != '\n' ) ) cpos++;
3323 	n = (char *)cpos - value;
3324 	if( n > 0 ) {
3325 	  if( *val_char != NULL ) {
3326 	    libspectrum_free( *val_char );
3327 	    *val_char = NULL;
3328 	  }
3329 	  *val_char = libspectrum_malloc( n + 1 );
3330 	  (*val_char)[n] = '\0';
3331 	  memcpy( *val_char, value, n );
3332 	}
3333     }
3334     /* skip 'new line' like chars */
3335     while( ( cpos < ( file->buffer + file->length ) ) &&
3336            ( *cpos == '\r' || *cpos == '\n' ) ) cpos++;
3337 
3338 #line 463"../settings.pl"
3339   }
3340 
3341   return 0;
3342 }
3343 
3344 static int
settings_file_write(compat_fd fd,const char * buffer,size_t length)3345 settings_file_write( compat_fd fd, const char *buffer, size_t length )
3346 {
3347   return compat_file_write( fd, (const unsigned char *)buffer, length );
3348 }
3349 
3350 static int
settings_string_write(compat_fd doc,const char * name,const char * config)3351 settings_string_write( compat_fd doc, const char* name, const char* config )
3352 {
3353   if( config != NULL &&
3354       ( settings_file_write( doc, name, strlen( name ) ) ||
3355         settings_file_write( doc, "=", 1 ) ||
3356         settings_file_write( doc, config, strlen( config ) ) ||
3357         settings_file_write( doc, "\n", 1 ) ) )
3358     return 1;
3359   return 0;
3360 }
3361 
3362 static int
settings_boolean_write(compat_fd doc,const char * name,int config)3363 settings_boolean_write( compat_fd doc, const char* name, int config )
3364 {
3365   return settings_string_write( doc, name, config ? "1" : "0" );
3366 }
3367 
3368 static int
settings_numeric_write(compat_fd doc,const char * name,int config)3369 settings_numeric_write( compat_fd doc, const char* name, int config )
3370 {
3371   char buffer[80];
3372   snprintf( buffer, sizeof( buffer ), "%d", config );
3373   return settings_string_write( doc, name, buffer );
3374 }
3375 
3376 int
settings_write_config(settings_info * settings)3377 settings_write_config( settings_info *settings )
3378 {
3379   const char *home; char path[ PATH_MAX ];
3380 
3381   compat_fd doc;
3382 
3383   home = compat_get_home_path(); if( !home ) return 1;
3384 
3385   snprintf( path, PATH_MAX, "%s/%s", home, CONFIG_FILE_NAME );
3386 
3387   doc = compat_file_open( path, 1 );
3388   if( doc == COMPAT_FILE_OPEN_FAILED ) {
3389     ui_error( UI_ERROR_ERROR, "couldn't open `%s' for writing: %s\n",
3390 	      path, strerror( errno ) );
3391     return 1;
3392   }
3393 
3394   if( settings_boolean_write( doc, "accelerateloader",
3395                               settings->accelerate_loader ) )
3396     goto error;
3397   if( settings_boolean_write( doc, "aspecthint",
3398                               settings->aspect_hint ) )
3399     goto error;
3400   if( settings_boolean_write( doc, "autoload",
3401                               settings->auto_load ) )
3402     goto error;
3403   if( settings_boolean_write( doc, "autosavesettings",
3404                               settings->autosave_settings ) )
3405     goto error;
3406   if( settings_boolean_write( doc, "beta128",
3407                               settings->beta128 ) )
3408     goto error;
3409   if( settings_boolean_write( doc, "beta12848boot",
3410                               settings->beta128_48boot ) )
3411     goto error;
3412   if( settings_string_write( doc, "betadisk",
3413                              settings->betadisk_file ) )
3414     goto error;
3415   if( settings_boolean_write( doc, "bwtv",
3416                               settings->bw_tv ) )
3417     goto error;
3418   if( settings_numeric_write( doc, "competitioncode",
3419                               settings->competition_code ) )
3420     goto error;
3421   if( settings_boolean_write( doc, "competitionmode",
3422                               settings->competition_mode ) )
3423     goto error;
3424   if( settings_boolean_write( doc, "confirmactions",
3425                               settings->confirm_actions ) )
3426     goto error;
3427   if( settings_string_write( doc, "dock",
3428                              settings->dck_file ) )
3429     goto error;
3430   if( settings_string_write( doc, "debuggercommand",
3431                              settings->debugger_command ) )
3432     goto error;
3433   if( settings_boolean_write( doc, "detectloader",
3434                               settings->detect_loader ) )
3435     goto error;
3436   if( settings_boolean_write( doc, "disciple",
3437                               settings->disciple ) )
3438     goto error;
3439   if( settings_string_write( doc, "discipledisk",
3440                              settings->discipledisk_file ) )
3441     goto error;
3442   if( settings_boolean_write( doc, "diskaskmerge",
3443                               settings->disk_ask_merge ) )
3444     goto error;
3445   if( settings_string_write( doc, "disktrymerge",
3446                              settings->disk_try_merge ) )
3447     goto error;
3448   if( settings_boolean_write( doc, "divide",
3449                               settings->divide_enabled ) )
3450     goto error;
3451   if( settings_string_write( doc, "dividemasterfile",
3452                              settings->divide_master_file ) )
3453     goto error;
3454   if( settings_string_write( doc, "divideslavefile",
3455                              settings->divide_slave_file ) )
3456     goto error;
3457   if( settings_boolean_write( doc, "dividewriteprotect",
3458                               settings->divide_wp ) )
3459     goto error;
3460   if( settings_numeric_write( doc, "doublescanmode",
3461                               settings->doublescan_mode ) )
3462     goto error;
3463   if( settings_numeric_write( doc, "drive40maxtrack",
3464                               settings->drive_40_max_track ) )
3465     goto error;
3466   if( settings_numeric_write( doc, "drive80maxtrack",
3467                               settings->drive_80_max_track ) )
3468     goto error;
3469   if( settings_string_write( doc, "drivebeta128atype",
3470                              settings->drive_beta128a_type ) )
3471     goto error;
3472   if( settings_string_write( doc, "drivebeta128btype",
3473                              settings->drive_beta128b_type ) )
3474     goto error;
3475   if( settings_string_write( doc, "drivebeta128ctype",
3476                              settings->drive_beta128c_type ) )
3477     goto error;
3478   if( settings_string_write( doc, "drivebeta128dtype",
3479                              settings->drive_beta128d_type ) )
3480     goto error;
3481   if( settings_string_write( doc, "drivedisciple1type",
3482                              settings->drive_disciple1_type ) )
3483     goto error;
3484   if( settings_string_write( doc, "drivedisciple2type",
3485                              settings->drive_disciple2_type ) )
3486     goto error;
3487   if( settings_string_write( doc, "driveopus1type",
3488                              settings->drive_opus1_type ) )
3489     goto error;
3490   if( settings_string_write( doc, "driveopus2type",
3491                              settings->drive_opus2_type ) )
3492     goto error;
3493   if( settings_string_write( doc, "driveplus3atype",
3494                              settings->drive_plus3a_type ) )
3495     goto error;
3496   if( settings_string_write( doc, "driveplus3btype",
3497                              settings->drive_plus3b_type ) )
3498     goto error;
3499   if( settings_string_write( doc, "driveplusd1type",
3500                              settings->drive_plusd1_type ) )
3501     goto error;
3502   if( settings_string_write( doc, "driveplusd2type",
3503                              settings->drive_plusd2_type ) )
3504     goto error;
3505   if( settings_boolean_write( doc, "embedsnapshot",
3506                               settings->embed_snapshot ) )
3507     goto error;
3508   if( settings_numeric_write( doc, "speed",
3509                               settings->emulation_speed ) )
3510     goto error;
3511   if( settings_boolean_write( doc, "fastload",
3512                               settings->fastload ) )
3513     goto error;
3514   if( settings_numeric_write( doc, "fbmode",
3515                               settings->fb_mode ) )
3516     goto error;
3517   if( settings_numeric_write( doc, "rate",
3518                               settings->frame_rate ) )
3519     goto error;
3520   if( settings_boolean_write( doc, "fullscreen",
3521                               settings->full_screen ) )
3522     goto error;
3523   if( settings_boolean_write( doc, "fuller",
3524                               settings->fuller ) )
3525     goto error;
3526   if( settings_string_write( doc, "if2cart",
3527                              settings->if2_file ) )
3528     goto error;
3529   if( settings_boolean_write( doc, "interface1",
3530                               settings->interface1 ) )
3531     goto error;
3532   if( settings_boolean_write( doc, "interface2",
3533                               settings->interface2 ) )
3534     goto error;
3535   if( settings_boolean_write( doc, "issue2",
3536                               settings->issue2 ) )
3537     goto error;
3538   if( settings_boolean_write( doc, "kempston",
3539                               settings->joy_kempston ) )
3540     goto error;
3541   if( settings_boolean_write( doc, "joystickprompt",
3542                               settings->joy_prompt ) )
3543     goto error;
3544   if( settings_string_write( doc, "joystick1",
3545                              settings->joystick_1 ) )
3546     goto error;
3547   if( settings_numeric_write( doc, "joystick1fire1",
3548                               settings->joystick_1_fire_1 ) )
3549     goto error;
3550   if( settings_numeric_write( doc, "joystick1fire10",
3551                               settings->joystick_1_fire_10 ) )
3552     goto error;
3553   if( settings_numeric_write( doc, "joystick1fire11",
3554                               settings->joystick_1_fire_11 ) )
3555     goto error;
3556   if( settings_numeric_write( doc, "joystick1fire12",
3557                               settings->joystick_1_fire_12 ) )
3558     goto error;
3559   if( settings_numeric_write( doc, "joystick1fire13",
3560                               settings->joystick_1_fire_13 ) )
3561     goto error;
3562   if( settings_numeric_write( doc, "joystick1fire14",
3563                               settings->joystick_1_fire_14 ) )
3564     goto error;
3565   if( settings_numeric_write( doc, "joystick1fire15",
3566                               settings->joystick_1_fire_15 ) )
3567     goto error;
3568   if( settings_numeric_write( doc, "joystick1fire2",
3569                               settings->joystick_1_fire_2 ) )
3570     goto error;
3571   if( settings_numeric_write( doc, "joystick1fire3",
3572                               settings->joystick_1_fire_3 ) )
3573     goto error;
3574   if( settings_numeric_write( doc, "joystick1fire4",
3575                               settings->joystick_1_fire_4 ) )
3576     goto error;
3577   if( settings_numeric_write( doc, "joystick1fire5",
3578                               settings->joystick_1_fire_5 ) )
3579     goto error;
3580   if( settings_numeric_write( doc, "joystick1fire6",
3581                               settings->joystick_1_fire_6 ) )
3582     goto error;
3583   if( settings_numeric_write( doc, "joystick1fire7",
3584                               settings->joystick_1_fire_7 ) )
3585     goto error;
3586   if( settings_numeric_write( doc, "joystick1fire8",
3587                               settings->joystick_1_fire_8 ) )
3588     goto error;
3589   if( settings_numeric_write( doc, "joystick1fire9",
3590                               settings->joystick_1_fire_9 ) )
3591     goto error;
3592   if( settings_numeric_write( doc, "joystick1output",
3593                               settings->joystick_1_output ) )
3594     goto error;
3595   if( settings_string_write( doc, "joystick2",
3596                              settings->joystick_2 ) )
3597     goto error;
3598   if( settings_numeric_write( doc, "joystick2fire1",
3599                               settings->joystick_2_fire_1 ) )
3600     goto error;
3601   if( settings_numeric_write( doc, "joystick2fire10",
3602                               settings->joystick_2_fire_10 ) )
3603     goto error;
3604   if( settings_numeric_write( doc, "joystick2fire11",
3605                               settings->joystick_2_fire_11 ) )
3606     goto error;
3607   if( settings_numeric_write( doc, "joystick2fire12",
3608                               settings->joystick_2_fire_12 ) )
3609     goto error;
3610   if( settings_numeric_write( doc, "joystick2fire13",
3611                               settings->joystick_2_fire_13 ) )
3612     goto error;
3613   if( settings_numeric_write( doc, "joystick2fire14",
3614                               settings->joystick_2_fire_14 ) )
3615     goto error;
3616   if( settings_numeric_write( doc, "joystick2fire15",
3617                               settings->joystick_2_fire_15 ) )
3618     goto error;
3619   if( settings_numeric_write( doc, "joystick2fire2",
3620                               settings->joystick_2_fire_2 ) )
3621     goto error;
3622   if( settings_numeric_write( doc, "joystick2fire3",
3623                               settings->joystick_2_fire_3 ) )
3624     goto error;
3625   if( settings_numeric_write( doc, "joystick2fire4",
3626                               settings->joystick_2_fire_4 ) )
3627     goto error;
3628   if( settings_numeric_write( doc, "joystick2fire5",
3629                               settings->joystick_2_fire_5 ) )
3630     goto error;
3631   if( settings_numeric_write( doc, "joystick2fire6",
3632                               settings->joystick_2_fire_6 ) )
3633     goto error;
3634   if( settings_numeric_write( doc, "joystick2fire7",
3635                               settings->joystick_2_fire_7 ) )
3636     goto error;
3637   if( settings_numeric_write( doc, "joystick2fire8",
3638                               settings->joystick_2_fire_8 ) )
3639     goto error;
3640   if( settings_numeric_write( doc, "joystick2fire9",
3641                               settings->joystick_2_fire_9 ) )
3642     goto error;
3643   if( settings_numeric_write( doc, "joystick2output",
3644                               settings->joystick_2_output ) )
3645     goto error;
3646   if( settings_numeric_write( doc, "joystickkeyboarddown",
3647                               settings->joystick_keyboard_down ) )
3648     goto error;
3649   if( settings_numeric_write( doc, "joystickkeyboardfire",
3650                               settings->joystick_keyboard_fire ) )
3651     goto error;
3652   if( settings_numeric_write( doc, "joystickkeyboardleft",
3653                               settings->joystick_keyboard_left ) )
3654     goto error;
3655   if( settings_numeric_write( doc, "joystickkeyboardoutput",
3656                               settings->joystick_keyboard_output ) )
3657     goto error;
3658   if( settings_numeric_write( doc, "joystickkeyboardright",
3659                               settings->joystick_keyboard_right ) )
3660     goto error;
3661   if( settings_numeric_write( doc, "joystickkeyboardup",
3662                               settings->joystick_keyboard_up ) )
3663     goto error;
3664   if( settings_boolean_write( doc, "kempstonmouse",
3665                               settings->kempston_mouse ) )
3666     goto error;
3667   if( settings_boolean_write( doc, "latetimings",
3668                               settings->late_timings ) )
3669     goto error;
3670   if( settings_string_write( doc, "microdrivefile",
3671                              settings->mdr_file ) )
3672     goto error;
3673   if( settings_string_write( doc, "microdrive2file",
3674                              settings->mdr_file2 ) )
3675     goto error;
3676   if( settings_string_write( doc, "microdrive3file",
3677                              settings->mdr_file3 ) )
3678     goto error;
3679   if( settings_string_write( doc, "microdrive4file",
3680                              settings->mdr_file4 ) )
3681     goto error;
3682   if( settings_string_write( doc, "microdrive5file",
3683                              settings->mdr_file5 ) )
3684     goto error;
3685   if( settings_string_write( doc, "microdrive6file",
3686                              settings->mdr_file6 ) )
3687     goto error;
3688   if( settings_string_write( doc, "microdrive7file",
3689                              settings->mdr_file7 ) )
3690     goto error;
3691   if( settings_string_write( doc, "microdrive8file",
3692                              settings->mdr_file8 ) )
3693     goto error;
3694   if( settings_numeric_write( doc, "mdrlen",
3695                               settings->mdr_len ) )
3696     goto error;
3697   if( settings_boolean_write( doc, "mdrrandomlen",
3698                               settings->mdr_random_len ) )
3699     goto error;
3700   if( settings_boolean_write( doc, "melodik",
3701                               settings->melodik ) )
3702     goto error;
3703   if( settings_boolean_write( doc, "mouseswapbuttons",
3704                               settings->mouse_swap_buttons ) )
3705     goto error;
3706   if( settings_string_write( doc, "moviecompr",
3707                              settings->movie_compr ) )
3708     goto error;
3709   if( settings_string_write( doc, "moviestart",
3710                              settings->movie_start ) )
3711     goto error;
3712   if( settings_boolean_write( doc, "moviestopafterrzx",
3713                               settings->movie_stop_after_rzx ) )
3714     goto error;
3715   if( settings_boolean_write( doc, "opus",
3716                               settings->opus ) )
3717     goto error;
3718   if( settings_string_write( doc, "opusdisk",
3719                              settings->opusdisk_file ) )
3720     goto error;
3721   if( settings_boolean_write( doc, "paltv2x",
3722                               settings->pal_tv2x ) )
3723     goto error;
3724   if( settings_string_write( doc, "playbackfile",
3725                              settings->playback_file ) )
3726     goto error;
3727   if( settings_boolean_write( doc, "plus3detectspeedlock",
3728                               settings->plus3_detect_speedlock ) )
3729     goto error;
3730   if( settings_string_write( doc, "plus3disk",
3731                              settings->plus3disk_file ) )
3732     goto error;
3733   if( settings_boolean_write( doc, "plusd",
3734                               settings->plusd ) )
3735     goto error;
3736   if( settings_string_write( doc, "plusddisk",
3737                              settings->plusddisk_file ) )
3738     goto error;
3739   if( settings_boolean_write( doc, "printer",
3740                               settings->printer ) )
3741     goto error;
3742   if( settings_string_write( doc, "graphicsfile",
3743                              settings->printer_graphics_filename ) )
3744     goto error;
3745   if( settings_string_write( doc, "textfile",
3746                              settings->printer_text_filename ) )
3747     goto error;
3748   if( settings_boolean_write( doc, "rawsnet",
3749                               settings->raw_s_net ) )
3750     goto error;
3751   if( settings_string_write( doc, "recordfile",
3752                              settings->record_file ) )
3753     goto error;
3754   if( settings_string_write( doc, "rom1280",
3755                              settings->rom_128_0 ) )
3756     goto error;
3757   if( settings_string_write( doc, "rom1281",
3758                              settings->rom_128_1 ) )
3759     goto error;
3760   if( settings_string_write( doc, "rom16",
3761                              settings->rom_16 ) )
3762     goto error;
3763   if( settings_string_write( doc, "rom48",
3764                              settings->rom_48 ) )
3765     goto error;
3766   if( settings_string_write( doc, "rombeta128",
3767                              settings->rom_beta128 ) )
3768     goto error;
3769   if( settings_string_write( doc, "romdisciple",
3770                              settings->rom_disciple ) )
3771     goto error;
3772   if( settings_string_write( doc, "rominterfacei",
3773                              settings->rom_interface_i ) )
3774     goto error;
3775   if( settings_string_write( doc, "romopus",
3776                              settings->rom_opus ) )
3777     goto error;
3778   if( settings_string_write( doc, "rompentagon10240",
3779                              settings->rom_pentagon1024_0 ) )
3780     goto error;
3781   if( settings_string_write( doc, "rompentagon10241",
3782                              settings->rom_pentagon1024_1 ) )
3783     goto error;
3784   if( settings_string_write( doc, "rompentagon10242",
3785                              settings->rom_pentagon1024_2 ) )
3786     goto error;
3787   if( settings_string_write( doc, "rompentagon10243",
3788                              settings->rom_pentagon1024_3 ) )
3789     goto error;
3790   if( settings_string_write( doc, "rompentagon5120",
3791                              settings->rom_pentagon512_0 ) )
3792     goto error;
3793   if( settings_string_write( doc, "rompentagon5121",
3794                              settings->rom_pentagon512_1 ) )
3795     goto error;
3796   if( settings_string_write( doc, "rompentagon5122",
3797                              settings->rom_pentagon512_2 ) )
3798     goto error;
3799   if( settings_string_write( doc, "rompentagon5123",
3800                              settings->rom_pentagon512_3 ) )
3801     goto error;
3802   if( settings_string_write( doc, "rompentagon0",
3803                              settings->rom_pentagon_0 ) )
3804     goto error;
3805   if( settings_string_write( doc, "rompentagon1",
3806                              settings->rom_pentagon_1 ) )
3807     goto error;
3808   if( settings_string_write( doc, "rompentagon2",
3809                              settings->rom_pentagon_2 ) )
3810     goto error;
3811   if( settings_string_write( doc, "romplus20",
3812                              settings->rom_plus2_0 ) )
3813     goto error;
3814   if( settings_string_write( doc, "romplus21",
3815                              settings->rom_plus2_1 ) )
3816     goto error;
3817   if( settings_string_write( doc, "romplus2a0",
3818                              settings->rom_plus2a_0 ) )
3819     goto error;
3820   if( settings_string_write( doc, "romplus2a1",
3821                              settings->rom_plus2a_1 ) )
3822     goto error;
3823   if( settings_string_write( doc, "romplus2a2",
3824                              settings->rom_plus2a_2 ) )
3825     goto error;
3826   if( settings_string_write( doc, "romplus2a3",
3827                              settings->rom_plus2a_3 ) )
3828     goto error;
3829   if( settings_string_write( doc, "romplus30",
3830                              settings->rom_plus3_0 ) )
3831     goto error;
3832   if( settings_string_write( doc, "romplus31",
3833                              settings->rom_plus3_1 ) )
3834     goto error;
3835   if( settings_string_write( doc, "romplus32",
3836                              settings->rom_plus3_2 ) )
3837     goto error;
3838   if( settings_string_write( doc, "romplus33",
3839                              settings->rom_plus3_3 ) )
3840     goto error;
3841   if( settings_string_write( doc, "romplus3e0",
3842                              settings->rom_plus3e_0 ) )
3843     goto error;
3844   if( settings_string_write( doc, "romplus3e1",
3845                              settings->rom_plus3e_1 ) )
3846     goto error;
3847   if( settings_string_write( doc, "romplus3e2",
3848                              settings->rom_plus3e_2 ) )
3849     goto error;
3850   if( settings_string_write( doc, "romplus3e3",
3851                              settings->rom_plus3e_3 ) )
3852     goto error;
3853   if( settings_string_write( doc, "romplusd",
3854                              settings->rom_plusd ) )
3855     goto error;
3856   if( settings_string_write( doc, "romscorpion0",
3857                              settings->rom_scorpion_0 ) )
3858     goto error;
3859   if( settings_string_write( doc, "romscorpion1",
3860                              settings->rom_scorpion_1 ) )
3861     goto error;
3862   if( settings_string_write( doc, "romscorpion2",
3863                              settings->rom_scorpion_2 ) )
3864     goto error;
3865   if( settings_string_write( doc, "romscorpion3",
3866                              settings->rom_scorpion_3 ) )
3867     goto error;
3868   if( settings_string_write( doc, "romspecse0",
3869                              settings->rom_spec_se_0 ) )
3870     goto error;
3871   if( settings_string_write( doc, "romspecse1",
3872                              settings->rom_spec_se_1 ) )
3873     goto error;
3874   if( settings_string_write( doc, "romspeccyboot",
3875                              settings->rom_speccyboot ) )
3876     goto error;
3877   if( settings_string_write( doc, "romtc2048",
3878                              settings->rom_tc2048 ) )
3879     goto error;
3880   if( settings_string_write( doc, "romtc20680",
3881                              settings->rom_tc2068_0 ) )
3882     goto error;
3883   if( settings_string_write( doc, "romtc20681",
3884                              settings->rom_tc2068_1 ) )
3885     goto error;
3886   if( settings_string_write( doc, "romts20680",
3887                              settings->rom_ts2068_0 ) )
3888     goto error;
3889   if( settings_string_write( doc, "romts20681",
3890                              settings->rom_ts2068_1 ) )
3891     goto error;
3892   if( settings_boolean_write( doc, "rs232handshake",
3893                               settings->rs232_handshake ) )
3894     goto error;
3895   if( settings_string_write( doc, "rs232rx",
3896                              settings->rs232_rx ) )
3897     goto error;
3898   if( settings_string_write( doc, "rs232tx",
3899                              settings->rs232_tx ) )
3900     goto error;
3901   if( settings_boolean_write( doc, "rzxautosaves",
3902                               settings->rzx_autosaves ) )
3903     goto error;
3904   if( settings_boolean_write( doc, "compressrzx",
3905                               settings->rzx_compression ) )
3906     goto error;
3907   if( settings_boolean_write( doc, "simpleide",
3908                               settings->simpleide_active ) )
3909     goto error;
3910   if( settings_string_write( doc, "simpleidemasterfile",
3911                              settings->simpleide_master_file ) )
3912     goto error;
3913   if( settings_string_write( doc, "simpleideslavefile",
3914                              settings->simpleide_slave_file ) )
3915     goto error;
3916   if( settings_boolean_write( doc, "slttraps",
3917                               settings->slt_traps ) )
3918     goto error;
3919   if( settings_string_write( doc, "snapshot",
3920                              settings->snapshot ) )
3921     goto error;
3922   if( settings_string_write( doc, "snet",
3923                              settings->snet ) )
3924     goto error;
3925   if( settings_boolean_write( doc, "sound",
3926                               settings->sound ) )
3927     goto error;
3928   if( settings_string_write( doc, "sounddevice",
3929                              settings->sound_device ) )
3930     goto error;
3931   if( settings_boolean_write( doc, "soundforce8bit",
3932                               settings->sound_force_8bit ) )
3933     goto error;
3934   if( settings_numeric_write( doc, "soundfreq",
3935                               settings->sound_freq ) )
3936     goto error;
3937   if( settings_boolean_write( doc, "loadingsound",
3938                               settings->sound_load ) )
3939     goto error;
3940   if( settings_string_write( doc, "speakertype",
3941                              settings->speaker_type ) )
3942     goto error;
3943   if( settings_boolean_write( doc, "speccyboot",
3944                               settings->speccyboot ) )
3945     goto error;
3946   if( settings_string_write( doc, "speccyboottap",
3947                              settings->speccyboot_tap ) )
3948     goto error;
3949   if( settings_boolean_write( doc, "specdrum",
3950                               settings->specdrum ) )
3951     goto error;
3952   if( settings_boolean_write( doc, "spectranet",
3953                               settings->spectranet ) )
3954     goto error;
3955   if( settings_boolean_write( doc, "spectranetdisable",
3956                               settings->spectranet_disable ) )
3957     goto error;
3958   if( settings_string_write( doc, "machine",
3959                              settings->start_machine ) )
3960     goto error;
3961   if( settings_string_write( doc, "graphicsfilter",
3962                              settings->start_scaler_mode ) )
3963     goto error;
3964   if( settings_boolean_write( doc, "statusbar",
3965                               settings->statusbar ) )
3966     goto error;
3967   if( settings_string_write( doc, "separation",
3968                              settings->stereo_ay ) )
3969     goto error;
3970   if( settings_boolean_write( doc, "strictaspecthint",
3971                               settings->strict_aspect_hint ) )
3972     goto error;
3973   if( settings_string_write( doc, "svgamodes",
3974                              settings->svga_modes ) )
3975     goto error;
3976   if( settings_string_write( doc, "tapefile",
3977                              settings->tape_file ) )
3978     goto error;
3979   if( settings_boolean_write( doc, "tapetraps",
3980                               settings->tape_traps ) )
3981     goto error;
3982   if( settings_boolean_write( doc, "unittests",
3983                               settings->unittests ) )
3984     goto error;
3985   if( settings_numeric_write( doc, "volumeay",
3986                               settings->volume_ay ) )
3987     goto error;
3988   if( settings_numeric_write( doc, "volumebeeper",
3989                               settings->volume_beeper ) )
3990     goto error;
3991   if( settings_numeric_write( doc, "volumespecdrum",
3992                               settings->volume_specdrum ) )
3993     goto error;
3994   if( settings_boolean_write( doc, "writableroms",
3995                               settings->writable_roms ) )
3996     goto error;
3997   if( settings_boolean_write( doc, "zxatasp",
3998                               settings->zxatasp_active ) )
3999     goto error;
4000   if( settings_string_write( doc, "zxataspmasterfile",
4001                              settings->zxatasp_master_file ) )
4002     goto error;
4003   if( settings_string_write( doc, "zxataspslavefile",
4004                              settings->zxatasp_slave_file ) )
4005     goto error;
4006   if( settings_boolean_write( doc, "zxataspupload",
4007                               settings->zxatasp_upload ) )
4008     goto error;
4009   if( settings_boolean_write( doc, "zxataspwriteprotect",
4010                               settings->zxatasp_wp ) )
4011     goto error;
4012   if( settings_boolean_write( doc, "zxcf",
4013                               settings->zxcf_active ) )
4014     goto error;
4015   if( settings_string_write( doc, "zxcfcffile",
4016                              settings->zxcf_pri_file ) )
4017     goto error;
4018   if( settings_boolean_write( doc, "zxcfupload",
4019                               settings->zxcf_upload ) )
4020     goto error;
4021   if( settings_boolean_write( doc, "zxprinter",
4022                               settings->zxprinter ) )
4023     goto error;
4024 #line 555"../settings.pl"
4025 
4026   compat_file_close( doc );
4027 
4028   return 0;
4029 error:
4030   compat_file_close( doc );
4031 
4032   return 1;
4033 }
4034 
4035 #endif				/* #ifdef HAVE_LIB_XML2 */
4036 
4037 /* Read options from the command line */
4038 static int
settings_command_line(settings_info * settings,int * first_arg,int argc,char ** argv)4039 settings_command_line( settings_info *settings, int *first_arg,
4040                        int argc, char **argv )
4041 {
4042 #ifdef GEKKO
4043   /* No argv on the Wii. Just return */
4044   return 0;
4045 #endif
4046 
4047 #if !defined AMIGA && !defined __MORPHOS__
4048 
4049   struct option long_options[] = {
4050 
4051     {    "accelerate-loader", 0, &(settings->accelerate_loader), 1 },
4052     { "no-accelerate-loader", 0, &(settings->accelerate_loader), 0 },
4053     {    "aspect-hint", 0, &(settings->aspect_hint), 1 },
4054     { "no-aspect-hint", 0, &(settings->aspect_hint), 0 },
4055     {    "auto-load", 0, &(settings->auto_load), 1 },
4056     { "no-auto-load", 0, &(settings->auto_load), 0 },
4057     {    "autosave-settings", 0, &(settings->autosave_settings), 1 },
4058     { "no-autosave-settings", 0, &(settings->autosave_settings), 0 },
4059     {    "beta128", 0, &(settings->beta128), 1 },
4060     { "no-beta128", 0, &(settings->beta128), 0 },
4061     {    "beta128-48boot", 0, &(settings->beta128_48boot), 1 },
4062     { "no-beta128-48boot", 0, &(settings->beta128_48boot), 0 },
4063     { "betadisk", 1, NULL, 256 },
4064     {    "bw-tv", 0, &(settings->bw_tv), 1 },
4065     { "no-bw-tv", 0, &(settings->bw_tv), 0 },
4066     { "competition-code", 1, NULL, 257 },
4067     {    "competition-mode", 0, &(settings->competition_mode), 1 },
4068     { "no-competition-mode", 0, &(settings->competition_mode), 0 },
4069     {    "confirm-actions", 0, &(settings->confirm_actions), 1 },
4070     { "no-confirm-actions", 0, &(settings->confirm_actions), 0 },
4071     { "dock", 1, NULL, 258 },
4072     { "debugger-command", 1, NULL, 259 },
4073     {    "detect-loader", 0, &(settings->detect_loader), 1 },
4074     { "no-detect-loader", 0, &(settings->detect_loader), 0 },
4075     {    "disciple", 0, &(settings->disciple), 1 },
4076     { "no-disciple", 0, &(settings->disciple), 0 },
4077     { "discipledisk", 1, NULL, 260 },
4078     {    "disk-ask-merge", 0, &(settings->disk_ask_merge), 1 },
4079     { "no-disk-ask-merge", 0, &(settings->disk_ask_merge), 0 },
4080     { "disk-try-merge", 1, NULL, 261 },
4081     {    "divide", 0, &(settings->divide_enabled), 1 },
4082     { "no-divide", 0, &(settings->divide_enabled), 0 },
4083     { "divide-masterfile", 1, NULL, 262 },
4084     { "divide-slavefile", 1, NULL, 263 },
4085     {    "divide-write-protect", 0, &(settings->divide_wp), 1 },
4086     { "no-divide-write-protect", 0, &(settings->divide_wp), 0 },
4087     { "doublescan-mode", 1, NULL, 'D' },
4088     { "drive-40-max-track", 1, NULL, 265 },
4089     { "drive-80-max-track", 1, NULL, 266 },
4090     { "drive-beta128a-type", 1, NULL, 267 },
4091     { "drive-beta128b-type", 1, NULL, 268 },
4092     { "drive-beta128c-type", 1, NULL, 269 },
4093     { "drive-beta128d-type", 1, NULL, 270 },
4094     { "drive-disciple1-type", 1, NULL, 271 },
4095     { "drive-disciple2-type", 1, NULL, 272 },
4096     { "drive-opus1-type", 1, NULL, 273 },
4097     { "drive-opus2-type", 1, NULL, 274 },
4098     { "drive-plus3a-type", 1, NULL, 275 },
4099     { "drive-plus3b-type", 1, NULL, 276 },
4100     { "drive-plusd1-type", 1, NULL, 277 },
4101     { "drive-plusd2-type", 1, NULL, 278 },
4102     {    "embed-snapshot", 0, &(settings->embed_snapshot), 1 },
4103     { "no-embed-snapshot", 0, &(settings->embed_snapshot), 0 },
4104     { "speed", 1, NULL, 279 },
4105     {    "fastload", 0, &(settings->fastload), 1 },
4106     { "no-fastload", 0, &(settings->fastload), 0 },
4107     { "fbmode", 1, NULL, 'v' },
4108     { "rate", 1, NULL, 280 },
4109     {    "full-screen", 0, &(settings->full_screen), 1 },
4110     { "no-full-screen", 0, &(settings->full_screen), 0 },
4111     {    "fuller", 0, &(settings->fuller), 1 },
4112     { "no-fuller", 0, &(settings->fuller), 0 },
4113     { "if2cart", 1, NULL, 281 },
4114     {    "interface1", 0, &(settings->interface1), 1 },
4115     { "no-interface1", 0, &(settings->interface1), 0 },
4116     {    "interface2", 0, &(settings->interface2), 1 },
4117     { "no-interface2", 0, &(settings->interface2), 0 },
4118     {    "issue2", 0, &(settings->issue2), 1 },
4119     { "no-issue2", 0, &(settings->issue2), 0 },
4120     {    "kempston", 0, &(settings->joy_kempston), 1 },
4121     { "no-kempston", 0, &(settings->joy_kempston), 0 },
4122     {    "joystick-prompt", 0, &(settings->joy_prompt), 1 },
4123     { "no-joystick-prompt", 0, &(settings->joy_prompt), 0 },
4124     { "joystick-1", 1, NULL, 'j' },
4125     { "joystick-1-fire-1", 1, NULL, 282 },
4126     { "joystick-1-fire-10", 1, NULL, 283 },
4127     { "joystick-1-fire-11", 1, NULL, 284 },
4128     { "joystick-1-fire-12", 1, NULL, 285 },
4129     { "joystick-1-fire-13", 1, NULL, 286 },
4130     { "joystick-1-fire-14", 1, NULL, 287 },
4131     { "joystick-1-fire-15", 1, NULL, 288 },
4132     { "joystick-1-fire-2", 1, NULL, 289 },
4133     { "joystick-1-fire-3", 1, NULL, 290 },
4134     { "joystick-1-fire-4", 1, NULL, 291 },
4135     { "joystick-1-fire-5", 1, NULL, 292 },
4136     { "joystick-1-fire-6", 1, NULL, 293 },
4137     { "joystick-1-fire-7", 1, NULL, 294 },
4138     { "joystick-1-fire-8", 1, NULL, 295 },
4139     { "joystick-1-fire-9", 1, NULL, 296 },
4140     { "joystick-1-output", 1, NULL, 297 },
4141     { "joystick-2", 1, NULL, 298 },
4142     { "joystick-2-fire-1", 1, NULL, 299 },
4143     { "joystick-2-fire-10", 1, NULL, 300 },
4144     { "joystick-2-fire-11", 1, NULL, 301 },
4145     { "joystick-2-fire-12", 1, NULL, 302 },
4146     { "joystick-2-fire-13", 1, NULL, 303 },
4147     { "joystick-2-fire-14", 1, NULL, 304 },
4148     { "joystick-2-fire-15", 1, NULL, 305 },
4149     { "joystick-2-fire-2", 1, NULL, 306 },
4150     { "joystick-2-fire-3", 1, NULL, 307 },
4151     { "joystick-2-fire-4", 1, NULL, 308 },
4152     { "joystick-2-fire-5", 1, NULL, 309 },
4153     { "joystick-2-fire-6", 1, NULL, 310 },
4154     { "joystick-2-fire-7", 1, NULL, 311 },
4155     { "joystick-2-fire-8", 1, NULL, 312 },
4156     { "joystick-2-fire-9", 1, NULL, 313 },
4157     { "joystick-2-output", 1, NULL, 314 },
4158     { "joystick-keyboard-down", 1, NULL, 315 },
4159     { "joystick-keyboard-fire", 1, NULL, 316 },
4160     { "joystick-keyboard-left", 1, NULL, 317 },
4161     { "joystick-keyboard-output", 1, NULL, 318 },
4162     { "joystick-keyboard-right", 1, NULL, 319 },
4163     { "joystick-keyboard-up", 1, NULL, 320 },
4164     {    "kempston-mouse", 0, &(settings->kempston_mouse), 1 },
4165     { "no-kempston-mouse", 0, &(settings->kempston_mouse), 0 },
4166     {    "late-timings", 0, &(settings->late_timings), 1 },
4167     { "no-late-timings", 0, &(settings->late_timings), 0 },
4168     { "microdrive-file", 1, NULL, 321 },
4169     { "microdrive-2-file", 1, NULL, 322 },
4170     { "microdrive-3-file", 1, NULL, 323 },
4171     { "microdrive-4-file", 1, NULL, 324 },
4172     { "microdrive-5-file", 1, NULL, 325 },
4173     { "microdrive-6-file", 1, NULL, 326 },
4174     { "microdrive-7-file", 1, NULL, 327 },
4175     { "microdrive-8-file", 1, NULL, 328 },
4176     { "mdr-len", 1, NULL, 329 },
4177     {    "mdr-random-len", 0, &(settings->mdr_random_len), 1 },
4178     { "no-mdr-random-len", 0, &(settings->mdr_random_len), 0 },
4179     {    "melodik", 0, &(settings->melodik), 1 },
4180     { "no-melodik", 0, &(settings->melodik), 0 },
4181     {    "mouse-swap-buttons", 0, &(settings->mouse_swap_buttons), 1 },
4182     { "no-mouse-swap-buttons", 0, &(settings->mouse_swap_buttons), 0 },
4183     { "movie-compr", 1, NULL, 330 },
4184     { "movie-start", 1, NULL, 331 },
4185     {    "movie-stop-after-rzx", 0, &(settings->movie_stop_after_rzx), 1 },
4186     { "no-movie-stop-after-rzx", 0, &(settings->movie_stop_after_rzx), 0 },
4187     {    "opus", 0, &(settings->opus), 1 },
4188     { "no-opus", 0, &(settings->opus), 0 },
4189     { "opusdisk", 1, NULL, 332 },
4190     {    "pal-tv2x", 0, &(settings->pal_tv2x), 1 },
4191     { "no-pal-tv2x", 0, &(settings->pal_tv2x), 0 },
4192     { "playback", 1, NULL, 'p' },
4193     {    "plus3-detect-speedlock", 0, &(settings->plus3_detect_speedlock), 1 },
4194     { "no-plus3-detect-speedlock", 0, &(settings->plus3_detect_speedlock), 0 },
4195     { "plus3disk", 1, NULL, 333 },
4196     {    "plusd", 0, &(settings->plusd), 1 },
4197     { "no-plusd", 0, &(settings->plusd), 0 },
4198     { "plusddisk", 1, NULL, 334 },
4199     {    "printer", 0, &(settings->printer), 1 },
4200     { "no-printer", 0, &(settings->printer), 0 },
4201     { "graphicsfile", 1, NULL, 335 },
4202     { "textfile", 1, NULL, 336 },
4203     {    "raw-s-net", 0, &(settings->raw_s_net), 1 },
4204     { "no-raw-s-net", 0, &(settings->raw_s_net), 0 },
4205     { "record", 1, NULL, 'r' },
4206     { "rom-128-0", 1, NULL, 338 },
4207     { "rom-128-1", 1, NULL, 339 },
4208     { "rom-16", 1, NULL, 340 },
4209     { "rom-48", 1, NULL, 341 },
4210     { "rom-beta128", 1, NULL, 342 },
4211     { "rom-disciple", 1, NULL, 343 },
4212     { "rom-interface-i", 1, NULL, 344 },
4213     { "rom-opus", 1, NULL, 345 },
4214     { "rom-pentagon1024-0", 1, NULL, 346 },
4215     { "rom-pentagon1024-1", 1, NULL, 347 },
4216     { "rom-pentagon1024-2", 1, NULL, 348 },
4217     { "rom-pentagon1024-3", 1, NULL, 349 },
4218     { "rom-pentagon512-0", 1, NULL, 350 },
4219     { "rom-pentagon512-1", 1, NULL, 351 },
4220     { "rom-pentagon512-2", 1, NULL, 352 },
4221     { "rom-pentagon512-3", 1, NULL, 353 },
4222     { "rom-pentagon-0", 1, NULL, 354 },
4223     { "rom-pentagon-1", 1, NULL, 355 },
4224     { "rom-pentagon-2", 1, NULL, 356 },
4225     { "rom-plus2-0", 1, NULL, 357 },
4226     { "rom-plus2-1", 1, NULL, 358 },
4227     { "rom-plus2a-0", 1, NULL, 359 },
4228     { "rom-plus2a-1", 1, NULL, 360 },
4229     { "rom-plus2a-2", 1, NULL, 361 },
4230     { "rom-plus2a-3", 1, NULL, 362 },
4231     { "rom-plus3-0", 1, NULL, 363 },
4232     { "rom-plus3-1", 1, NULL, 364 },
4233     { "rom-plus3-2", 1, NULL, 365 },
4234     { "rom-plus3-3", 1, NULL, 366 },
4235     { "rom-plus3e-0", 1, NULL, 367 },
4236     { "rom-plus3e-1", 1, NULL, 368 },
4237     { "rom-plus3e-2", 1, NULL, 369 },
4238     { "rom-plus3e-3", 1, NULL, 370 },
4239     { "rom-plusd", 1, NULL, 371 },
4240     { "rom-scorpion-0", 1, NULL, 372 },
4241     { "rom-scorpion-1", 1, NULL, 373 },
4242     { "rom-scorpion-2", 1, NULL, 374 },
4243     { "rom-scorpion-3", 1, NULL, 375 },
4244     { "rom-spec-se-0", 1, NULL, 376 },
4245     { "rom-spec-se-1", 1, NULL, 377 },
4246     { "rom-speccyboot", 1, NULL, 378 },
4247     { "rom-tc2048", 1, NULL, 379 },
4248     { "rom-tc2068-0", 1, NULL, 380 },
4249     { "rom-tc2068-1", 1, NULL, 381 },
4250     { "rom-ts2068-0", 1, NULL, 382 },
4251     { "rom-ts2068-1", 1, NULL, 383 },
4252     {    "rs232-handshake", 0, &(settings->rs232_handshake), 1 },
4253     { "no-rs232-handshake", 0, &(settings->rs232_handshake), 0 },
4254     { "rs232-rx", 1, NULL, 384 },
4255     { "rs232-tx", 1, NULL, 385 },
4256     {    "rzx-autosaves", 0, &(settings->rzx_autosaves), 1 },
4257     { "no-rzx-autosaves", 0, &(settings->rzx_autosaves), 0 },
4258     {    "compress-rzx", 0, &(settings->rzx_compression), 1 },
4259     { "no-compress-rzx", 0, &(settings->rzx_compression), 0 },
4260     {    "simpleide", 0, &(settings->simpleide_active), 1 },
4261     { "no-simpleide", 0, &(settings->simpleide_active), 0 },
4262     { "simpleide-masterfile", 1, NULL, 386 },
4263     { "simpleide-slavefile", 1, NULL, 387 },
4264     {    "slt", 0, &(settings->slt_traps), 1 },
4265     { "no-slt", 0, &(settings->slt_traps), 0 },
4266     { "snapshot", 1, NULL, 's' },
4267     { "snet", 1, NULL, 389 },
4268     {    "sound", 0, &(settings->sound), 1 },
4269     { "no-sound", 0, &(settings->sound), 0 },
4270     { "sound-device", 1, NULL, 'd' },
4271     {    "sound-force-8bit", 0, &(settings->sound_force_8bit), 1 },
4272     { "no-sound-force-8bit", 0, &(settings->sound_force_8bit), 0 },
4273     { "sound-freq", 1, NULL, 'f' },
4274     {    "loading-sound", 0, &(settings->sound_load), 1 },
4275     { "no-loading-sound", 0, &(settings->sound_load), 0 },
4276     { "speaker-type", 1, NULL, 390 },
4277     {    "speccyboot", 0, &(settings->speccyboot), 1 },
4278     { "no-speccyboot", 0, &(settings->speccyboot), 0 },
4279     { "speccyboot-tap", 1, NULL, 391 },
4280     {    "specdrum", 0, &(settings->specdrum), 1 },
4281     { "no-specdrum", 0, &(settings->specdrum), 0 },
4282     {    "spectranet", 0, &(settings->spectranet), 1 },
4283     { "no-spectranet", 0, &(settings->spectranet), 0 },
4284     {    "spectranet-disable", 0, &(settings->spectranet_disable), 1 },
4285     { "no-spectranet-disable", 0, &(settings->spectranet_disable), 0 },
4286     { "machine", 1, NULL, 'm' },
4287     { "graphics-filter", 1, NULL, 'g' },
4288     {    "statusbar", 0, &(settings->statusbar), 1 },
4289     { "no-statusbar", 0, &(settings->statusbar), 0 },
4290     { "separation", 1, NULL, 392 },
4291     {    "strict-aspect-hint", 0, &(settings->strict_aspect_hint), 1 },
4292     { "no-strict-aspect-hint", 0, &(settings->strict_aspect_hint), 0 },
4293     { "svga-modes", 1, NULL, 393 },
4294     { "tape", 1, NULL, 't' },
4295     {    "traps", 0, &(settings->tape_traps), 1 },
4296     { "no-traps", 0, &(settings->tape_traps), 0 },
4297     {    "unittests", 0, &(settings->unittests), 1 },
4298     { "no-unittests", 0, &(settings->unittests), 0 },
4299     { "volume-ay", 1, NULL, 394 },
4300     { "volume-beeper", 1, NULL, 395 },
4301     { "volume-specdrum", 1, NULL, 396 },
4302     {    "writable-roms", 0, &(settings->writable_roms), 1 },
4303     { "no-writable-roms", 0, &(settings->writable_roms), 0 },
4304     {    "zxatasp", 0, &(settings->zxatasp_active), 1 },
4305     { "no-zxatasp", 0, &(settings->zxatasp_active), 0 },
4306     { "zxatasp-masterfile", 1, NULL, 397 },
4307     { "zxatasp-slavefile", 1, NULL, 398 },
4308     {    "zxatasp-upload", 0, &(settings->zxatasp_upload), 1 },
4309     { "no-zxatasp-upload", 0, &(settings->zxatasp_upload), 0 },
4310     {    "zxatasp-write-protect", 0, &(settings->zxatasp_wp), 1 },
4311     { "no-zxatasp-write-protect", 0, &(settings->zxatasp_wp), 0 },
4312     {    "zxcf", 0, &(settings->zxcf_active), 1 },
4313     { "no-zxcf", 0, &(settings->zxcf_active), 0 },
4314     { "zxcf-cffile", 1, NULL, 399 },
4315     {    "zxcf-upload", 0, &(settings->zxcf_upload), 1 },
4316     { "no-zxcf-upload", 0, &(settings->zxcf_upload), 0 },
4317     {    "zxprinter", 0, &(settings->zxprinter), 1 },
4318     { "no-zxprinter", 0, &(settings->zxprinter), 0 },
4319 #line 610"../settings.pl"
4320 
4321     { "help", 0, NULL, 'h' },
4322     { "version", 0, NULL, 'V' },
4323 
4324     { 0, 0, 0, 0 }		/* End marker: DO NOT REMOVE */
4325   };
4326 
4327 #endif      /* #ifndef AMIGA */
4328 
4329   while( 1 ) {
4330 
4331     int c;
4332 
4333 #if defined AMIGA || defined __MORPHOS__
4334     c = getopt( argc, argv, "d:hm:o:p:f:r:s:t:v:g:j:V" );
4335 #else                    /* #ifdef AMIGA */
4336     c = getopt_long( argc, argv, "d:hm:o:p:f:r:s:t:v:g:j:V", long_options, NULL );
4337 #endif                   /* #ifdef AMIGA */
4338 
4339     if( c == -1 ) break;	/* End of option list */
4340 
4341     switch( c ) {
4342 
4343     case 0: break;	/* Used for long option returns */
4344 
4345     case 256: settings_set_string( &settings->betadisk_file, optarg ); break;
4346     case 257: settings->competition_code = atoi( optarg ); break;
4347     case 258: settings_set_string( &settings->dck_file, optarg ); break;
4348     case 259: settings_set_string( &settings->debugger_command, optarg ); break;
4349     case 260: settings_set_string( &settings->discipledisk_file, optarg ); break;
4350     case 261: settings_set_string( &settings->disk_try_merge, optarg ); break;
4351     case 262: settings_set_string( &settings->divide_master_file, optarg ); break;
4352     case 263: settings_set_string( &settings->divide_slave_file, optarg ); break;
4353     case 'D': settings->doublescan_mode = atoi( optarg ); break;
4354     case 265: settings->drive_40_max_track = atoi( optarg ); break;
4355     case 266: settings->drive_80_max_track = atoi( optarg ); break;
4356     case 267: settings_set_string( &settings->drive_beta128a_type, optarg ); break;
4357     case 268: settings_set_string( &settings->drive_beta128b_type, optarg ); break;
4358     case 269: settings_set_string( &settings->drive_beta128c_type, optarg ); break;
4359     case 270: settings_set_string( &settings->drive_beta128d_type, optarg ); break;
4360     case 271: settings_set_string( &settings->drive_disciple1_type, optarg ); break;
4361     case 272: settings_set_string( &settings->drive_disciple2_type, optarg ); break;
4362     case 273: settings_set_string( &settings->drive_opus1_type, optarg ); break;
4363     case 274: settings_set_string( &settings->drive_opus2_type, optarg ); break;
4364     case 275: settings_set_string( &settings->drive_plus3a_type, optarg ); break;
4365     case 276: settings_set_string( &settings->drive_plus3b_type, optarg ); break;
4366     case 277: settings_set_string( &settings->drive_plusd1_type, optarg ); break;
4367     case 278: settings_set_string( &settings->drive_plusd2_type, optarg ); break;
4368     case 279: settings->emulation_speed = atoi( optarg ); break;
4369     case 'v': settings->fb_mode = atoi( optarg ); break;
4370     case 280: settings->frame_rate = atoi( optarg ); break;
4371     case 281: settings_set_string( &settings->if2_file, optarg ); break;
4372     case 'j': settings_set_string( &settings->joystick_1, optarg ); break;
4373     case 282: settings->joystick_1_fire_1 = atoi( optarg ); break;
4374     case 283: settings->joystick_1_fire_10 = atoi( optarg ); break;
4375     case 284: settings->joystick_1_fire_11 = atoi( optarg ); break;
4376     case 285: settings->joystick_1_fire_12 = atoi( optarg ); break;
4377     case 286: settings->joystick_1_fire_13 = atoi( optarg ); break;
4378     case 287: settings->joystick_1_fire_14 = atoi( optarg ); break;
4379     case 288: settings->joystick_1_fire_15 = atoi( optarg ); break;
4380     case 289: settings->joystick_1_fire_2 = atoi( optarg ); break;
4381     case 290: settings->joystick_1_fire_3 = atoi( optarg ); break;
4382     case 291: settings->joystick_1_fire_4 = atoi( optarg ); break;
4383     case 292: settings->joystick_1_fire_5 = atoi( optarg ); break;
4384     case 293: settings->joystick_1_fire_6 = atoi( optarg ); break;
4385     case 294: settings->joystick_1_fire_7 = atoi( optarg ); break;
4386     case 295: settings->joystick_1_fire_8 = atoi( optarg ); break;
4387     case 296: settings->joystick_1_fire_9 = atoi( optarg ); break;
4388     case 297: settings->joystick_1_output = atoi( optarg ); break;
4389     case 298: settings_set_string( &settings->joystick_2, optarg ); break;
4390     case 299: settings->joystick_2_fire_1 = atoi( optarg ); break;
4391     case 300: settings->joystick_2_fire_10 = atoi( optarg ); break;
4392     case 301: settings->joystick_2_fire_11 = atoi( optarg ); break;
4393     case 302: settings->joystick_2_fire_12 = atoi( optarg ); break;
4394     case 303: settings->joystick_2_fire_13 = atoi( optarg ); break;
4395     case 304: settings->joystick_2_fire_14 = atoi( optarg ); break;
4396     case 305: settings->joystick_2_fire_15 = atoi( optarg ); break;
4397     case 306: settings->joystick_2_fire_2 = atoi( optarg ); break;
4398     case 307: settings->joystick_2_fire_3 = atoi( optarg ); break;
4399     case 308: settings->joystick_2_fire_4 = atoi( optarg ); break;
4400     case 309: settings->joystick_2_fire_5 = atoi( optarg ); break;
4401     case 310: settings->joystick_2_fire_6 = atoi( optarg ); break;
4402     case 311: settings->joystick_2_fire_7 = atoi( optarg ); break;
4403     case 312: settings->joystick_2_fire_8 = atoi( optarg ); break;
4404     case 313: settings->joystick_2_fire_9 = atoi( optarg ); break;
4405     case 314: settings->joystick_2_output = atoi( optarg ); break;
4406     case 315: settings->joystick_keyboard_down = atoi( optarg ); break;
4407     case 316: settings->joystick_keyboard_fire = atoi( optarg ); break;
4408     case 317: settings->joystick_keyboard_left = atoi( optarg ); break;
4409     case 318: settings->joystick_keyboard_output = atoi( optarg ); break;
4410     case 319: settings->joystick_keyboard_right = atoi( optarg ); break;
4411     case 320: settings->joystick_keyboard_up = atoi( optarg ); break;
4412     case 321: settings_set_string( &settings->mdr_file, optarg ); break;
4413     case 322: settings_set_string( &settings->mdr_file2, optarg ); break;
4414     case 323: settings_set_string( &settings->mdr_file3, optarg ); break;
4415     case 324: settings_set_string( &settings->mdr_file4, optarg ); break;
4416     case 325: settings_set_string( &settings->mdr_file5, optarg ); break;
4417     case 326: settings_set_string( &settings->mdr_file6, optarg ); break;
4418     case 327: settings_set_string( &settings->mdr_file7, optarg ); break;
4419     case 328: settings_set_string( &settings->mdr_file8, optarg ); break;
4420     case 329: settings->mdr_len = atoi( optarg ); break;
4421     case 330: settings_set_string( &settings->movie_compr, optarg ); break;
4422     case 331: settings_set_string( &settings->movie_start, optarg ); break;
4423     case 332: settings_set_string( &settings->opusdisk_file, optarg ); break;
4424     case 'p': settings_set_string( &settings->playback_file, optarg ); break;
4425     case 333: settings_set_string( &settings->plus3disk_file, optarg ); break;
4426     case 334: settings_set_string( &settings->plusddisk_file, optarg ); break;
4427     case 335: settings_set_string( &settings->printer_graphics_filename, optarg ); break;
4428     case 336: settings_set_string( &settings->printer_text_filename, optarg ); break;
4429     case 'r': settings_set_string( &settings->record_file, optarg ); break;
4430     case 338: settings_set_string( &settings->rom_128_0, optarg ); break;
4431     case 339: settings_set_string( &settings->rom_128_1, optarg ); break;
4432     case 340: settings_set_string( &settings->rom_16, optarg ); break;
4433     case 341: settings_set_string( &settings->rom_48, optarg ); break;
4434     case 342: settings_set_string( &settings->rom_beta128, optarg ); break;
4435     case 343: settings_set_string( &settings->rom_disciple, optarg ); break;
4436     case 344: settings_set_string( &settings->rom_interface_i, optarg ); break;
4437     case 345: settings_set_string( &settings->rom_opus, optarg ); break;
4438     case 346: settings_set_string( &settings->rom_pentagon1024_0, optarg ); break;
4439     case 347: settings_set_string( &settings->rom_pentagon1024_1, optarg ); break;
4440     case 348: settings_set_string( &settings->rom_pentagon1024_2, optarg ); break;
4441     case 349: settings_set_string( &settings->rom_pentagon1024_3, optarg ); break;
4442     case 350: settings_set_string( &settings->rom_pentagon512_0, optarg ); break;
4443     case 351: settings_set_string( &settings->rom_pentagon512_1, optarg ); break;
4444     case 352: settings_set_string( &settings->rom_pentagon512_2, optarg ); break;
4445     case 353: settings_set_string( &settings->rom_pentagon512_3, optarg ); break;
4446     case 354: settings_set_string( &settings->rom_pentagon_0, optarg ); break;
4447     case 355: settings_set_string( &settings->rom_pentagon_1, optarg ); break;
4448     case 356: settings_set_string( &settings->rom_pentagon_2, optarg ); break;
4449     case 357: settings_set_string( &settings->rom_plus2_0, optarg ); break;
4450     case 358: settings_set_string( &settings->rom_plus2_1, optarg ); break;
4451     case 359: settings_set_string( &settings->rom_plus2a_0, optarg ); break;
4452     case 360: settings_set_string( &settings->rom_plus2a_1, optarg ); break;
4453     case 361: settings_set_string( &settings->rom_plus2a_2, optarg ); break;
4454     case 362: settings_set_string( &settings->rom_plus2a_3, optarg ); break;
4455     case 363: settings_set_string( &settings->rom_plus3_0, optarg ); break;
4456     case 364: settings_set_string( &settings->rom_plus3_1, optarg ); break;
4457     case 365: settings_set_string( &settings->rom_plus3_2, optarg ); break;
4458     case 366: settings_set_string( &settings->rom_plus3_3, optarg ); break;
4459     case 367: settings_set_string( &settings->rom_plus3e_0, optarg ); break;
4460     case 368: settings_set_string( &settings->rom_plus3e_1, optarg ); break;
4461     case 369: settings_set_string( &settings->rom_plus3e_2, optarg ); break;
4462     case 370: settings_set_string( &settings->rom_plus3e_3, optarg ); break;
4463     case 371: settings_set_string( &settings->rom_plusd, optarg ); break;
4464     case 372: settings_set_string( &settings->rom_scorpion_0, optarg ); break;
4465     case 373: settings_set_string( &settings->rom_scorpion_1, optarg ); break;
4466     case 374: settings_set_string( &settings->rom_scorpion_2, optarg ); break;
4467     case 375: settings_set_string( &settings->rom_scorpion_3, optarg ); break;
4468     case 376: settings_set_string( &settings->rom_spec_se_0, optarg ); break;
4469     case 377: settings_set_string( &settings->rom_spec_se_1, optarg ); break;
4470     case 378: settings_set_string( &settings->rom_speccyboot, optarg ); break;
4471     case 379: settings_set_string( &settings->rom_tc2048, optarg ); break;
4472     case 380: settings_set_string( &settings->rom_tc2068_0, optarg ); break;
4473     case 381: settings_set_string( &settings->rom_tc2068_1, optarg ); break;
4474     case 382: settings_set_string( &settings->rom_ts2068_0, optarg ); break;
4475     case 383: settings_set_string( &settings->rom_ts2068_1, optarg ); break;
4476     case 384: settings_set_string( &settings->rs232_rx, optarg ); break;
4477     case 385: settings_set_string( &settings->rs232_tx, optarg ); break;
4478     case 386: settings_set_string( &settings->simpleide_master_file, optarg ); break;
4479     case 387: settings_set_string( &settings->simpleide_slave_file, optarg ); break;
4480     case 's': settings_set_string( &settings->snapshot, optarg ); break;
4481     case 389: settings_set_string( &settings->snet, optarg ); break;
4482     case 'd': settings_set_string( &settings->sound_device, optarg ); break;
4483     case 'f': settings->sound_freq = atoi( optarg ); break;
4484     case 390: settings_set_string( &settings->speaker_type, optarg ); break;
4485     case 391: settings_set_string( &settings->speccyboot_tap, optarg ); break;
4486     case 'm': settings_set_string( &settings->start_machine, optarg ); break;
4487     case 'g': settings_set_string( &settings->start_scaler_mode, optarg ); break;
4488     case 392: settings_set_string( &settings->stereo_ay, optarg ); break;
4489     case 393: settings_set_string( &settings->svga_modes, optarg ); break;
4490     case 't': settings_set_string( &settings->tape_file, optarg ); break;
4491     case 394: settings->volume_ay = atoi( optarg ); break;
4492     case 395: settings->volume_beeper = atoi( optarg ); break;
4493     case 396: settings->volume_specdrum = atoi( optarg ); break;
4494     case 397: settings_set_string( &settings->zxatasp_master_file, optarg ); break;
4495     case 398: settings_set_string( &settings->zxatasp_slave_file, optarg ); break;
4496     case 399: settings_set_string( &settings->zxcf_pri_file, optarg ); break;
4497 #line 660"../settings.pl"
4498 
4499     case 'h': settings->show_help = 1; break;
4500     case 'V': settings->show_version = 1; break;
4501 
4502     case ':':
4503     case '?':
4504       break;
4505 
4506     default:
4507       fprintf( stderr, "%s: getopt_long returned `%c'\n",
4508 	       fuse_progname, (char)c );
4509       break;
4510 
4511     }
4512   }
4513 
4514   /* Store the location of the first non-option argument */
4515   *first_arg = optind;
4516 
4517   return 0;
4518 }
4519 
4520 /* Copy one settings object to another */
4521 static void
settings_copy_internal(settings_info * dest,settings_info * src)4522 settings_copy_internal( settings_info *dest, settings_info *src )
4523 {
4524   settings_free( dest );
4525 
4526   dest->accelerate_loader = src->accelerate_loader;
4527   dest->aspect_hint = src->aspect_hint;
4528   dest->auto_load = src->auto_load;
4529   dest->autosave_settings = src->autosave_settings;
4530   dest->beta128 = src->beta128;
4531   dest->beta128_48boot = src->beta128_48boot;
4532   dest->betadisk_file = NULL;
4533   if( src->betadisk_file ) {
4534     dest->betadisk_file = utils_safe_strdup( src->betadisk_file );
4535   }
4536   dest->bw_tv = src->bw_tv;
4537   dest->competition_code = src->competition_code;
4538   dest->competition_mode = src->competition_mode;
4539   dest->confirm_actions = src->confirm_actions;
4540   dest->dck_file = NULL;
4541   if( src->dck_file ) {
4542     dest->dck_file = utils_safe_strdup( src->dck_file );
4543   }
4544   dest->debugger_command = NULL;
4545   if( src->debugger_command ) {
4546     dest->debugger_command = utils_safe_strdup( src->debugger_command );
4547   }
4548   dest->detect_loader = src->detect_loader;
4549   dest->disciple = src->disciple;
4550   dest->discipledisk_file = NULL;
4551   if( src->discipledisk_file ) {
4552     dest->discipledisk_file = utils_safe_strdup( src->discipledisk_file );
4553   }
4554   dest->disk_ask_merge = src->disk_ask_merge;
4555   dest->disk_try_merge = NULL;
4556   if( src->disk_try_merge ) {
4557     dest->disk_try_merge = utils_safe_strdup( src->disk_try_merge );
4558   }
4559   dest->divide_enabled = src->divide_enabled;
4560   dest->divide_master_file = NULL;
4561   if( src->divide_master_file ) {
4562     dest->divide_master_file = utils_safe_strdup( src->divide_master_file );
4563   }
4564   dest->divide_slave_file = NULL;
4565   if( src->divide_slave_file ) {
4566     dest->divide_slave_file = utils_safe_strdup( src->divide_slave_file );
4567   }
4568   dest->divide_wp = src->divide_wp;
4569   dest->doublescan_mode = src->doublescan_mode;
4570   dest->drive_40_max_track = src->drive_40_max_track;
4571   dest->drive_80_max_track = src->drive_80_max_track;
4572   dest->drive_beta128a_type = NULL;
4573   if( src->drive_beta128a_type ) {
4574     dest->drive_beta128a_type = utils_safe_strdup( src->drive_beta128a_type );
4575   }
4576   dest->drive_beta128b_type = NULL;
4577   if( src->drive_beta128b_type ) {
4578     dest->drive_beta128b_type = utils_safe_strdup( src->drive_beta128b_type );
4579   }
4580   dest->drive_beta128c_type = NULL;
4581   if( src->drive_beta128c_type ) {
4582     dest->drive_beta128c_type = utils_safe_strdup( src->drive_beta128c_type );
4583   }
4584   dest->drive_beta128d_type = NULL;
4585   if( src->drive_beta128d_type ) {
4586     dest->drive_beta128d_type = utils_safe_strdup( src->drive_beta128d_type );
4587   }
4588   dest->drive_disciple1_type = NULL;
4589   if( src->drive_disciple1_type ) {
4590     dest->drive_disciple1_type = utils_safe_strdup( src->drive_disciple1_type );
4591   }
4592   dest->drive_disciple2_type = NULL;
4593   if( src->drive_disciple2_type ) {
4594     dest->drive_disciple2_type = utils_safe_strdup( src->drive_disciple2_type );
4595   }
4596   dest->drive_opus1_type = NULL;
4597   if( src->drive_opus1_type ) {
4598     dest->drive_opus1_type = utils_safe_strdup( src->drive_opus1_type );
4599   }
4600   dest->drive_opus2_type = NULL;
4601   if( src->drive_opus2_type ) {
4602     dest->drive_opus2_type = utils_safe_strdup( src->drive_opus2_type );
4603   }
4604   dest->drive_plus3a_type = NULL;
4605   if( src->drive_plus3a_type ) {
4606     dest->drive_plus3a_type = utils_safe_strdup( src->drive_plus3a_type );
4607   }
4608   dest->drive_plus3b_type = NULL;
4609   if( src->drive_plus3b_type ) {
4610     dest->drive_plus3b_type = utils_safe_strdup( src->drive_plus3b_type );
4611   }
4612   dest->drive_plusd1_type = NULL;
4613   if( src->drive_plusd1_type ) {
4614     dest->drive_plusd1_type = utils_safe_strdup( src->drive_plusd1_type );
4615   }
4616   dest->drive_plusd2_type = NULL;
4617   if( src->drive_plusd2_type ) {
4618     dest->drive_plusd2_type = utils_safe_strdup( src->drive_plusd2_type );
4619   }
4620   dest->embed_snapshot = src->embed_snapshot;
4621   dest->emulation_speed = src->emulation_speed;
4622   dest->fastload = src->fastload;
4623   dest->fb_mode = src->fb_mode;
4624   dest->frame_rate = src->frame_rate;
4625   dest->full_screen = src->full_screen;
4626   dest->fuller = src->fuller;
4627   dest->if2_file = NULL;
4628   if( src->if2_file ) {
4629     dest->if2_file = utils_safe_strdup( src->if2_file );
4630   }
4631   dest->interface1 = src->interface1;
4632   dest->interface2 = src->interface2;
4633   dest->issue2 = src->issue2;
4634   dest->joy_kempston = src->joy_kempston;
4635   dest->joy_prompt = src->joy_prompt;
4636   dest->joystick_1 = NULL;
4637   if( src->joystick_1 ) {
4638     dest->joystick_1 = utils_safe_strdup( src->joystick_1 );
4639   }
4640   dest->joystick_1_fire_1 = src->joystick_1_fire_1;
4641   dest->joystick_1_fire_10 = src->joystick_1_fire_10;
4642   dest->joystick_1_fire_11 = src->joystick_1_fire_11;
4643   dest->joystick_1_fire_12 = src->joystick_1_fire_12;
4644   dest->joystick_1_fire_13 = src->joystick_1_fire_13;
4645   dest->joystick_1_fire_14 = src->joystick_1_fire_14;
4646   dest->joystick_1_fire_15 = src->joystick_1_fire_15;
4647   dest->joystick_1_fire_2 = src->joystick_1_fire_2;
4648   dest->joystick_1_fire_3 = src->joystick_1_fire_3;
4649   dest->joystick_1_fire_4 = src->joystick_1_fire_4;
4650   dest->joystick_1_fire_5 = src->joystick_1_fire_5;
4651   dest->joystick_1_fire_6 = src->joystick_1_fire_6;
4652   dest->joystick_1_fire_7 = src->joystick_1_fire_7;
4653   dest->joystick_1_fire_8 = src->joystick_1_fire_8;
4654   dest->joystick_1_fire_9 = src->joystick_1_fire_9;
4655   dest->joystick_1_output = src->joystick_1_output;
4656   dest->joystick_2 = NULL;
4657   if( src->joystick_2 ) {
4658     dest->joystick_2 = utils_safe_strdup( src->joystick_2 );
4659   }
4660   dest->joystick_2_fire_1 = src->joystick_2_fire_1;
4661   dest->joystick_2_fire_10 = src->joystick_2_fire_10;
4662   dest->joystick_2_fire_11 = src->joystick_2_fire_11;
4663   dest->joystick_2_fire_12 = src->joystick_2_fire_12;
4664   dest->joystick_2_fire_13 = src->joystick_2_fire_13;
4665   dest->joystick_2_fire_14 = src->joystick_2_fire_14;
4666   dest->joystick_2_fire_15 = src->joystick_2_fire_15;
4667   dest->joystick_2_fire_2 = src->joystick_2_fire_2;
4668   dest->joystick_2_fire_3 = src->joystick_2_fire_3;
4669   dest->joystick_2_fire_4 = src->joystick_2_fire_4;
4670   dest->joystick_2_fire_5 = src->joystick_2_fire_5;
4671   dest->joystick_2_fire_6 = src->joystick_2_fire_6;
4672   dest->joystick_2_fire_7 = src->joystick_2_fire_7;
4673   dest->joystick_2_fire_8 = src->joystick_2_fire_8;
4674   dest->joystick_2_fire_9 = src->joystick_2_fire_9;
4675   dest->joystick_2_output = src->joystick_2_output;
4676   dest->joystick_keyboard_down = src->joystick_keyboard_down;
4677   dest->joystick_keyboard_fire = src->joystick_keyboard_fire;
4678   dest->joystick_keyboard_left = src->joystick_keyboard_left;
4679   dest->joystick_keyboard_output = src->joystick_keyboard_output;
4680   dest->joystick_keyboard_right = src->joystick_keyboard_right;
4681   dest->joystick_keyboard_up = src->joystick_keyboard_up;
4682   dest->kempston_mouse = src->kempston_mouse;
4683   dest->late_timings = src->late_timings;
4684   dest->mdr_file = NULL;
4685   if( src->mdr_file ) {
4686     dest->mdr_file = utils_safe_strdup( src->mdr_file );
4687   }
4688   dest->mdr_file2 = NULL;
4689   if( src->mdr_file2 ) {
4690     dest->mdr_file2 = utils_safe_strdup( src->mdr_file2 );
4691   }
4692   dest->mdr_file3 = NULL;
4693   if( src->mdr_file3 ) {
4694     dest->mdr_file3 = utils_safe_strdup( src->mdr_file3 );
4695   }
4696   dest->mdr_file4 = NULL;
4697   if( src->mdr_file4 ) {
4698     dest->mdr_file4 = utils_safe_strdup( src->mdr_file4 );
4699   }
4700   dest->mdr_file5 = NULL;
4701   if( src->mdr_file5 ) {
4702     dest->mdr_file5 = utils_safe_strdup( src->mdr_file5 );
4703   }
4704   dest->mdr_file6 = NULL;
4705   if( src->mdr_file6 ) {
4706     dest->mdr_file6 = utils_safe_strdup( src->mdr_file6 );
4707   }
4708   dest->mdr_file7 = NULL;
4709   if( src->mdr_file7 ) {
4710     dest->mdr_file7 = utils_safe_strdup( src->mdr_file7 );
4711   }
4712   dest->mdr_file8 = NULL;
4713   if( src->mdr_file8 ) {
4714     dest->mdr_file8 = utils_safe_strdup( src->mdr_file8 );
4715   }
4716   dest->mdr_len = src->mdr_len;
4717   dest->mdr_random_len = src->mdr_random_len;
4718   dest->melodik = src->melodik;
4719   dest->mouse_swap_buttons = src->mouse_swap_buttons;
4720   dest->movie_compr = NULL;
4721   if( src->movie_compr ) {
4722     dest->movie_compr = utils_safe_strdup( src->movie_compr );
4723   }
4724   dest->movie_start = NULL;
4725   if( src->movie_start ) {
4726     dest->movie_start = utils_safe_strdup( src->movie_start );
4727   }
4728   dest->movie_stop_after_rzx = src->movie_stop_after_rzx;
4729   dest->opus = src->opus;
4730   dest->opusdisk_file = NULL;
4731   if( src->opusdisk_file ) {
4732     dest->opusdisk_file = utils_safe_strdup( src->opusdisk_file );
4733   }
4734   dest->pal_tv2x = src->pal_tv2x;
4735   dest->playback_file = NULL;
4736   if( src->playback_file ) {
4737     dest->playback_file = utils_safe_strdup( src->playback_file );
4738   }
4739   dest->plus3_detect_speedlock = src->plus3_detect_speedlock;
4740   dest->plus3disk_file = NULL;
4741   if( src->plus3disk_file ) {
4742     dest->plus3disk_file = utils_safe_strdup( src->plus3disk_file );
4743   }
4744   dest->plusd = src->plusd;
4745   dest->plusddisk_file = NULL;
4746   if( src->plusddisk_file ) {
4747     dest->plusddisk_file = utils_safe_strdup( src->plusddisk_file );
4748   }
4749   dest->printer = src->printer;
4750   dest->printer_graphics_filename = NULL;
4751   if( src->printer_graphics_filename ) {
4752     dest->printer_graphics_filename = utils_safe_strdup( src->printer_graphics_filename );
4753   }
4754   dest->printer_text_filename = NULL;
4755   if( src->printer_text_filename ) {
4756     dest->printer_text_filename = utils_safe_strdup( src->printer_text_filename );
4757   }
4758   dest->raw_s_net = src->raw_s_net;
4759   dest->record_file = NULL;
4760   if( src->record_file ) {
4761     dest->record_file = utils_safe_strdup( src->record_file );
4762   }
4763   dest->rom_128_0 = NULL;
4764   if( src->rom_128_0 ) {
4765     dest->rom_128_0 = utils_safe_strdup( src->rom_128_0 );
4766   }
4767   dest->rom_128_1 = NULL;
4768   if( src->rom_128_1 ) {
4769     dest->rom_128_1 = utils_safe_strdup( src->rom_128_1 );
4770   }
4771   dest->rom_16 = NULL;
4772   if( src->rom_16 ) {
4773     dest->rom_16 = utils_safe_strdup( src->rom_16 );
4774   }
4775   dest->rom_48 = NULL;
4776   if( src->rom_48 ) {
4777     dest->rom_48 = utils_safe_strdup( src->rom_48 );
4778   }
4779   dest->rom_beta128 = NULL;
4780   if( src->rom_beta128 ) {
4781     dest->rom_beta128 = utils_safe_strdup( src->rom_beta128 );
4782   }
4783   dest->rom_disciple = NULL;
4784   if( src->rom_disciple ) {
4785     dest->rom_disciple = utils_safe_strdup( src->rom_disciple );
4786   }
4787   dest->rom_interface_i = NULL;
4788   if( src->rom_interface_i ) {
4789     dest->rom_interface_i = utils_safe_strdup( src->rom_interface_i );
4790   }
4791   dest->rom_opus = NULL;
4792   if( src->rom_opus ) {
4793     dest->rom_opus = utils_safe_strdup( src->rom_opus );
4794   }
4795   dest->rom_pentagon1024_0 = NULL;
4796   if( src->rom_pentagon1024_0 ) {
4797     dest->rom_pentagon1024_0 = utils_safe_strdup( src->rom_pentagon1024_0 );
4798   }
4799   dest->rom_pentagon1024_1 = NULL;
4800   if( src->rom_pentagon1024_1 ) {
4801     dest->rom_pentagon1024_1 = utils_safe_strdup( src->rom_pentagon1024_1 );
4802   }
4803   dest->rom_pentagon1024_2 = NULL;
4804   if( src->rom_pentagon1024_2 ) {
4805     dest->rom_pentagon1024_2 = utils_safe_strdup( src->rom_pentagon1024_2 );
4806   }
4807   dest->rom_pentagon1024_3 = NULL;
4808   if( src->rom_pentagon1024_3 ) {
4809     dest->rom_pentagon1024_3 = utils_safe_strdup( src->rom_pentagon1024_3 );
4810   }
4811   dest->rom_pentagon512_0 = NULL;
4812   if( src->rom_pentagon512_0 ) {
4813     dest->rom_pentagon512_0 = utils_safe_strdup( src->rom_pentagon512_0 );
4814   }
4815   dest->rom_pentagon512_1 = NULL;
4816   if( src->rom_pentagon512_1 ) {
4817     dest->rom_pentagon512_1 = utils_safe_strdup( src->rom_pentagon512_1 );
4818   }
4819   dest->rom_pentagon512_2 = NULL;
4820   if( src->rom_pentagon512_2 ) {
4821     dest->rom_pentagon512_2 = utils_safe_strdup( src->rom_pentagon512_2 );
4822   }
4823   dest->rom_pentagon512_3 = NULL;
4824   if( src->rom_pentagon512_3 ) {
4825     dest->rom_pentagon512_3 = utils_safe_strdup( src->rom_pentagon512_3 );
4826   }
4827   dest->rom_pentagon_0 = NULL;
4828   if( src->rom_pentagon_0 ) {
4829     dest->rom_pentagon_0 = utils_safe_strdup( src->rom_pentagon_0 );
4830   }
4831   dest->rom_pentagon_1 = NULL;
4832   if( src->rom_pentagon_1 ) {
4833     dest->rom_pentagon_1 = utils_safe_strdup( src->rom_pentagon_1 );
4834   }
4835   dest->rom_pentagon_2 = NULL;
4836   if( src->rom_pentagon_2 ) {
4837     dest->rom_pentagon_2 = utils_safe_strdup( src->rom_pentagon_2 );
4838   }
4839   dest->rom_plus2_0 = NULL;
4840   if( src->rom_plus2_0 ) {
4841     dest->rom_plus2_0 = utils_safe_strdup( src->rom_plus2_0 );
4842   }
4843   dest->rom_plus2_1 = NULL;
4844   if( src->rom_plus2_1 ) {
4845     dest->rom_plus2_1 = utils_safe_strdup( src->rom_plus2_1 );
4846   }
4847   dest->rom_plus2a_0 = NULL;
4848   if( src->rom_plus2a_0 ) {
4849     dest->rom_plus2a_0 = utils_safe_strdup( src->rom_plus2a_0 );
4850   }
4851   dest->rom_plus2a_1 = NULL;
4852   if( src->rom_plus2a_1 ) {
4853     dest->rom_plus2a_1 = utils_safe_strdup( src->rom_plus2a_1 );
4854   }
4855   dest->rom_plus2a_2 = NULL;
4856   if( src->rom_plus2a_2 ) {
4857     dest->rom_plus2a_2 = utils_safe_strdup( src->rom_plus2a_2 );
4858   }
4859   dest->rom_plus2a_3 = NULL;
4860   if( src->rom_plus2a_3 ) {
4861     dest->rom_plus2a_3 = utils_safe_strdup( src->rom_plus2a_3 );
4862   }
4863   dest->rom_plus3_0 = NULL;
4864   if( src->rom_plus3_0 ) {
4865     dest->rom_plus3_0 = utils_safe_strdup( src->rom_plus3_0 );
4866   }
4867   dest->rom_plus3_1 = NULL;
4868   if( src->rom_plus3_1 ) {
4869     dest->rom_plus3_1 = utils_safe_strdup( src->rom_plus3_1 );
4870   }
4871   dest->rom_plus3_2 = NULL;
4872   if( src->rom_plus3_2 ) {
4873     dest->rom_plus3_2 = utils_safe_strdup( src->rom_plus3_2 );
4874   }
4875   dest->rom_plus3_3 = NULL;
4876   if( src->rom_plus3_3 ) {
4877     dest->rom_plus3_3 = utils_safe_strdup( src->rom_plus3_3 );
4878   }
4879   dest->rom_plus3e_0 = NULL;
4880   if( src->rom_plus3e_0 ) {
4881     dest->rom_plus3e_0 = utils_safe_strdup( src->rom_plus3e_0 );
4882   }
4883   dest->rom_plus3e_1 = NULL;
4884   if( src->rom_plus3e_1 ) {
4885     dest->rom_plus3e_1 = utils_safe_strdup( src->rom_plus3e_1 );
4886   }
4887   dest->rom_plus3e_2 = NULL;
4888   if( src->rom_plus3e_2 ) {
4889     dest->rom_plus3e_2 = utils_safe_strdup( src->rom_plus3e_2 );
4890   }
4891   dest->rom_plus3e_3 = NULL;
4892   if( src->rom_plus3e_3 ) {
4893     dest->rom_plus3e_3 = utils_safe_strdup( src->rom_plus3e_3 );
4894   }
4895   dest->rom_plusd = NULL;
4896   if( src->rom_plusd ) {
4897     dest->rom_plusd = utils_safe_strdup( src->rom_plusd );
4898   }
4899   dest->rom_scorpion_0 = NULL;
4900   if( src->rom_scorpion_0 ) {
4901     dest->rom_scorpion_0 = utils_safe_strdup( src->rom_scorpion_0 );
4902   }
4903   dest->rom_scorpion_1 = NULL;
4904   if( src->rom_scorpion_1 ) {
4905     dest->rom_scorpion_1 = utils_safe_strdup( src->rom_scorpion_1 );
4906   }
4907   dest->rom_scorpion_2 = NULL;
4908   if( src->rom_scorpion_2 ) {
4909     dest->rom_scorpion_2 = utils_safe_strdup( src->rom_scorpion_2 );
4910   }
4911   dest->rom_scorpion_3 = NULL;
4912   if( src->rom_scorpion_3 ) {
4913     dest->rom_scorpion_3 = utils_safe_strdup( src->rom_scorpion_3 );
4914   }
4915   dest->rom_spec_se_0 = NULL;
4916   if( src->rom_spec_se_0 ) {
4917     dest->rom_spec_se_0 = utils_safe_strdup( src->rom_spec_se_0 );
4918   }
4919   dest->rom_spec_se_1 = NULL;
4920   if( src->rom_spec_se_1 ) {
4921     dest->rom_spec_se_1 = utils_safe_strdup( src->rom_spec_se_1 );
4922   }
4923   dest->rom_speccyboot = NULL;
4924   if( src->rom_speccyboot ) {
4925     dest->rom_speccyboot = utils_safe_strdup( src->rom_speccyboot );
4926   }
4927   dest->rom_tc2048 = NULL;
4928   if( src->rom_tc2048 ) {
4929     dest->rom_tc2048 = utils_safe_strdup( src->rom_tc2048 );
4930   }
4931   dest->rom_tc2068_0 = NULL;
4932   if( src->rom_tc2068_0 ) {
4933     dest->rom_tc2068_0 = utils_safe_strdup( src->rom_tc2068_0 );
4934   }
4935   dest->rom_tc2068_1 = NULL;
4936   if( src->rom_tc2068_1 ) {
4937     dest->rom_tc2068_1 = utils_safe_strdup( src->rom_tc2068_1 );
4938   }
4939   dest->rom_ts2068_0 = NULL;
4940   if( src->rom_ts2068_0 ) {
4941     dest->rom_ts2068_0 = utils_safe_strdup( src->rom_ts2068_0 );
4942   }
4943   dest->rom_ts2068_1 = NULL;
4944   if( src->rom_ts2068_1 ) {
4945     dest->rom_ts2068_1 = utils_safe_strdup( src->rom_ts2068_1 );
4946   }
4947   dest->rs232_handshake = src->rs232_handshake;
4948   dest->rs232_rx = NULL;
4949   if( src->rs232_rx ) {
4950     dest->rs232_rx = utils_safe_strdup( src->rs232_rx );
4951   }
4952   dest->rs232_tx = NULL;
4953   if( src->rs232_tx ) {
4954     dest->rs232_tx = utils_safe_strdup( src->rs232_tx );
4955   }
4956   dest->rzx_autosaves = src->rzx_autosaves;
4957   dest->rzx_compression = src->rzx_compression;
4958   dest->simpleide_active = src->simpleide_active;
4959   dest->simpleide_master_file = NULL;
4960   if( src->simpleide_master_file ) {
4961     dest->simpleide_master_file = utils_safe_strdup( src->simpleide_master_file );
4962   }
4963   dest->simpleide_slave_file = NULL;
4964   if( src->simpleide_slave_file ) {
4965     dest->simpleide_slave_file = utils_safe_strdup( src->simpleide_slave_file );
4966   }
4967   dest->slt_traps = src->slt_traps;
4968   dest->snapshot = NULL;
4969   if( src->snapshot ) {
4970     dest->snapshot = utils_safe_strdup( src->snapshot );
4971   }
4972   dest->snet = NULL;
4973   if( src->snet ) {
4974     dest->snet = utils_safe_strdup( src->snet );
4975   }
4976   dest->sound = src->sound;
4977   dest->sound_device = NULL;
4978   if( src->sound_device ) {
4979     dest->sound_device = utils_safe_strdup( src->sound_device );
4980   }
4981   dest->sound_force_8bit = src->sound_force_8bit;
4982   dest->sound_freq = src->sound_freq;
4983   dest->sound_load = src->sound_load;
4984   dest->speaker_type = NULL;
4985   if( src->speaker_type ) {
4986     dest->speaker_type = utils_safe_strdup( src->speaker_type );
4987   }
4988   dest->speccyboot = src->speccyboot;
4989   dest->speccyboot_tap = NULL;
4990   if( src->speccyboot_tap ) {
4991     dest->speccyboot_tap = utils_safe_strdup( src->speccyboot_tap );
4992   }
4993   dest->specdrum = src->specdrum;
4994   dest->spectranet = src->spectranet;
4995   dest->spectranet_disable = src->spectranet_disable;
4996   dest->start_machine = NULL;
4997   if( src->start_machine ) {
4998     dest->start_machine = utils_safe_strdup( src->start_machine );
4999   }
5000   dest->start_scaler_mode = NULL;
5001   if( src->start_scaler_mode ) {
5002     dest->start_scaler_mode = utils_safe_strdup( src->start_scaler_mode );
5003   }
5004   dest->statusbar = src->statusbar;
5005   dest->stereo_ay = NULL;
5006   if( src->stereo_ay ) {
5007     dest->stereo_ay = utils_safe_strdup( src->stereo_ay );
5008   }
5009   dest->strict_aspect_hint = src->strict_aspect_hint;
5010   dest->svga_modes = NULL;
5011   if( src->svga_modes ) {
5012     dest->svga_modes = utils_safe_strdup( src->svga_modes );
5013   }
5014   dest->tape_file = NULL;
5015   if( src->tape_file ) {
5016     dest->tape_file = utils_safe_strdup( src->tape_file );
5017   }
5018   dest->tape_traps = src->tape_traps;
5019   dest->unittests = src->unittests;
5020   dest->volume_ay = src->volume_ay;
5021   dest->volume_beeper = src->volume_beeper;
5022   dest->volume_specdrum = src->volume_specdrum;
5023   dest->writable_roms = src->writable_roms;
5024   dest->zxatasp_active = src->zxatasp_active;
5025   dest->zxatasp_master_file = NULL;
5026   if( src->zxatasp_master_file ) {
5027     dest->zxatasp_master_file = utils_safe_strdup( src->zxatasp_master_file );
5028   }
5029   dest->zxatasp_slave_file = NULL;
5030   if( src->zxatasp_slave_file ) {
5031     dest->zxatasp_slave_file = utils_safe_strdup( src->zxatasp_slave_file );
5032   }
5033   dest->zxatasp_upload = src->zxatasp_upload;
5034   dest->zxatasp_wp = src->zxatasp_wp;
5035   dest->zxcf_active = src->zxcf_active;
5036   dest->zxcf_pri_file = NULL;
5037   if( src->zxcf_pri_file ) {
5038     dest->zxcf_pri_file = utils_safe_strdup( src->zxcf_pri_file );
5039   }
5040   dest->zxcf_upload = src->zxcf_upload;
5041   dest->zxprinter = src->zxprinter;
5042 #line 707"../settings.pl"
5043 }
5044 
5045 /* Copy one settings object to another */
settings_copy(settings_info * dest,settings_info * src)5046 void settings_copy( settings_info *dest, settings_info *src )
5047 {
5048   settings_defaults( dest );
5049   settings_copy_internal( dest, src );
5050 }
5051 
5052 char **
settings_get_rom_setting(settings_info * settings,size_t which)5053 settings_get_rom_setting( settings_info *settings, size_t which )
5054 {
5055   switch( which ) {
5056   case  0: return &( settings->rom_16       );
5057   case  1: return &( settings->rom_48       );
5058   case  2: return &( settings->rom_128_0    );
5059   case  3: return &( settings->rom_128_1    );
5060   case  4: return &( settings->rom_plus2_0  );
5061   case  5: return &( settings->rom_plus2_1  );
5062   case  6: return &( settings->rom_plus2a_0 );
5063   case  7: return &( settings->rom_plus2a_1 );
5064   case  8: return &( settings->rom_plus2a_2 );
5065   case  9: return &( settings->rom_plus2a_3 );
5066   case 10: return &( settings->rom_plus3_0  );
5067   case 11: return &( settings->rom_plus3_1  );
5068   case 12: return &( settings->rom_plus3_2  );
5069   case 13: return &( settings->rom_plus3_3  );
5070   case 14: return &( settings->rom_plus3e_0 );
5071   case 15: return &( settings->rom_plus3e_1 );
5072   case 16: return &( settings->rom_plus3e_2 );
5073   case 17: return &( settings->rom_plus3e_3 );
5074   case 18: return &( settings->rom_tc2048   );
5075   case 19: return &( settings->rom_tc2068_0 );
5076   case 20: return &( settings->rom_tc2068_1 );
5077   case 21: return &( settings->rom_ts2068_0 );
5078   case 22: return &( settings->rom_ts2068_1 );
5079   case 23: return &( settings->rom_pentagon_0 );
5080   case 24: return &( settings->rom_pentagon_1 );
5081   case 25: return &( settings->rom_pentagon_2 );
5082   case 26: return &( settings->rom_pentagon512_0 );
5083   case 27: return &( settings->rom_pentagon512_1 );
5084   case 28: return &( settings->rom_pentagon512_2 );
5085   case 29: return &( settings->rom_pentagon512_3 );
5086   case 30: return &( settings->rom_pentagon1024_0 );
5087   case 31: return &( settings->rom_pentagon1024_1 );
5088   case 32: return &( settings->rom_pentagon1024_2 );
5089   case 33: return &( settings->rom_pentagon1024_3 );
5090   case 34: return &( settings->rom_scorpion_0 );
5091   case 35: return &( settings->rom_scorpion_1 );
5092   case 36: return &( settings->rom_scorpion_2 );
5093   case 37: return &( settings->rom_scorpion_3 );
5094   case 38: return &( settings->rom_spec_se_0 );
5095   case 39: return &( settings->rom_spec_se_1 );
5096   case 40: return &( settings->rom_interface_i );
5097   case 41: return &( settings->rom_beta128 );
5098   case 42: return &( settings->rom_plusd );
5099   case 43: return &( settings->rom_disciple );
5100   case 44: return &( settings->rom_opus );
5101   case 45: return &( settings->rom_speccyboot );
5102   default: return NULL;
5103   }
5104 }
5105 
5106 void
settings_set_string(char ** string_setting,const char * value)5107 settings_set_string( char **string_setting, const char *value )
5108 {
5109   /* No need to do anything if the two strings are in fact the
5110      same pointer */
5111   if( *string_setting == value ) return;
5112 
5113   if( *string_setting ) libspectrum_free( *string_setting );
5114   *string_setting = utils_safe_strdup( value );
5115 }
5116 
5117 int
settings_free(settings_info * settings)5118 settings_free( settings_info *settings )
5119 {
5120   if( settings->betadisk_file ) libspectrum_free( settings->betadisk_file );
5121   if( settings->dck_file ) libspectrum_free( settings->dck_file );
5122   if( settings->debugger_command ) libspectrum_free( settings->debugger_command );
5123   if( settings->discipledisk_file ) libspectrum_free( settings->discipledisk_file );
5124   if( settings->disk_try_merge ) libspectrum_free( settings->disk_try_merge );
5125   if( settings->divide_master_file ) libspectrum_free( settings->divide_master_file );
5126   if( settings->divide_slave_file ) libspectrum_free( settings->divide_slave_file );
5127   if( settings->drive_beta128a_type ) libspectrum_free( settings->drive_beta128a_type );
5128   if( settings->drive_beta128b_type ) libspectrum_free( settings->drive_beta128b_type );
5129   if( settings->drive_beta128c_type ) libspectrum_free( settings->drive_beta128c_type );
5130   if( settings->drive_beta128d_type ) libspectrum_free( settings->drive_beta128d_type );
5131   if( settings->drive_disciple1_type ) libspectrum_free( settings->drive_disciple1_type );
5132   if( settings->drive_disciple2_type ) libspectrum_free( settings->drive_disciple2_type );
5133   if( settings->drive_opus1_type ) libspectrum_free( settings->drive_opus1_type );
5134   if( settings->drive_opus2_type ) libspectrum_free( settings->drive_opus2_type );
5135   if( settings->drive_plus3a_type ) libspectrum_free( settings->drive_plus3a_type );
5136   if( settings->drive_plus3b_type ) libspectrum_free( settings->drive_plus3b_type );
5137   if( settings->drive_plusd1_type ) libspectrum_free( settings->drive_plusd1_type );
5138   if( settings->drive_plusd2_type ) libspectrum_free( settings->drive_plusd2_type );
5139   if( settings->if2_file ) libspectrum_free( settings->if2_file );
5140   if( settings->joystick_1 ) libspectrum_free( settings->joystick_1 );
5141   if( settings->joystick_2 ) libspectrum_free( settings->joystick_2 );
5142   if( settings->mdr_file ) libspectrum_free( settings->mdr_file );
5143   if( settings->mdr_file2 ) libspectrum_free( settings->mdr_file2 );
5144   if( settings->mdr_file3 ) libspectrum_free( settings->mdr_file3 );
5145   if( settings->mdr_file4 ) libspectrum_free( settings->mdr_file4 );
5146   if( settings->mdr_file5 ) libspectrum_free( settings->mdr_file5 );
5147   if( settings->mdr_file6 ) libspectrum_free( settings->mdr_file6 );
5148   if( settings->mdr_file7 ) libspectrum_free( settings->mdr_file7 );
5149   if( settings->mdr_file8 ) libspectrum_free( settings->mdr_file8 );
5150   if( settings->movie_compr ) libspectrum_free( settings->movie_compr );
5151   if( settings->movie_start ) libspectrum_free( settings->movie_start );
5152   if( settings->opusdisk_file ) libspectrum_free( settings->opusdisk_file );
5153   if( settings->playback_file ) libspectrum_free( settings->playback_file );
5154   if( settings->plus3disk_file ) libspectrum_free( settings->plus3disk_file );
5155   if( settings->plusddisk_file ) libspectrum_free( settings->plusddisk_file );
5156   if( settings->printer_graphics_filename ) libspectrum_free( settings->printer_graphics_filename );
5157   if( settings->printer_text_filename ) libspectrum_free( settings->printer_text_filename );
5158   if( settings->record_file ) libspectrum_free( settings->record_file );
5159   if( settings->rom_128_0 ) libspectrum_free( settings->rom_128_0 );
5160   if( settings->rom_128_1 ) libspectrum_free( settings->rom_128_1 );
5161   if( settings->rom_16 ) libspectrum_free( settings->rom_16 );
5162   if( settings->rom_48 ) libspectrum_free( settings->rom_48 );
5163   if( settings->rom_beta128 ) libspectrum_free( settings->rom_beta128 );
5164   if( settings->rom_disciple ) libspectrum_free( settings->rom_disciple );
5165   if( settings->rom_interface_i ) libspectrum_free( settings->rom_interface_i );
5166   if( settings->rom_opus ) libspectrum_free( settings->rom_opus );
5167   if( settings->rom_pentagon1024_0 ) libspectrum_free( settings->rom_pentagon1024_0 );
5168   if( settings->rom_pentagon1024_1 ) libspectrum_free( settings->rom_pentagon1024_1 );
5169   if( settings->rom_pentagon1024_2 ) libspectrum_free( settings->rom_pentagon1024_2 );
5170   if( settings->rom_pentagon1024_3 ) libspectrum_free( settings->rom_pentagon1024_3 );
5171   if( settings->rom_pentagon512_0 ) libspectrum_free( settings->rom_pentagon512_0 );
5172   if( settings->rom_pentagon512_1 ) libspectrum_free( settings->rom_pentagon512_1 );
5173   if( settings->rom_pentagon512_2 ) libspectrum_free( settings->rom_pentagon512_2 );
5174   if( settings->rom_pentagon512_3 ) libspectrum_free( settings->rom_pentagon512_3 );
5175   if( settings->rom_pentagon_0 ) libspectrum_free( settings->rom_pentagon_0 );
5176   if( settings->rom_pentagon_1 ) libspectrum_free( settings->rom_pentagon_1 );
5177   if( settings->rom_pentagon_2 ) libspectrum_free( settings->rom_pentagon_2 );
5178   if( settings->rom_plus2_0 ) libspectrum_free( settings->rom_plus2_0 );
5179   if( settings->rom_plus2_1 ) libspectrum_free( settings->rom_plus2_1 );
5180   if( settings->rom_plus2a_0 ) libspectrum_free( settings->rom_plus2a_0 );
5181   if( settings->rom_plus2a_1 ) libspectrum_free( settings->rom_plus2a_1 );
5182   if( settings->rom_plus2a_2 ) libspectrum_free( settings->rom_plus2a_2 );
5183   if( settings->rom_plus2a_3 ) libspectrum_free( settings->rom_plus2a_3 );
5184   if( settings->rom_plus3_0 ) libspectrum_free( settings->rom_plus3_0 );
5185   if( settings->rom_plus3_1 ) libspectrum_free( settings->rom_plus3_1 );
5186   if( settings->rom_plus3_2 ) libspectrum_free( settings->rom_plus3_2 );
5187   if( settings->rom_plus3_3 ) libspectrum_free( settings->rom_plus3_3 );
5188   if( settings->rom_plus3e_0 ) libspectrum_free( settings->rom_plus3e_0 );
5189   if( settings->rom_plus3e_1 ) libspectrum_free( settings->rom_plus3e_1 );
5190   if( settings->rom_plus3e_2 ) libspectrum_free( settings->rom_plus3e_2 );
5191   if( settings->rom_plus3e_3 ) libspectrum_free( settings->rom_plus3e_3 );
5192   if( settings->rom_plusd ) libspectrum_free( settings->rom_plusd );
5193   if( settings->rom_scorpion_0 ) libspectrum_free( settings->rom_scorpion_0 );
5194   if( settings->rom_scorpion_1 ) libspectrum_free( settings->rom_scorpion_1 );
5195   if( settings->rom_scorpion_2 ) libspectrum_free( settings->rom_scorpion_2 );
5196   if( settings->rom_scorpion_3 ) libspectrum_free( settings->rom_scorpion_3 );
5197   if( settings->rom_spec_se_0 ) libspectrum_free( settings->rom_spec_se_0 );
5198   if( settings->rom_spec_se_1 ) libspectrum_free( settings->rom_spec_se_1 );
5199   if( settings->rom_speccyboot ) libspectrum_free( settings->rom_speccyboot );
5200   if( settings->rom_tc2048 ) libspectrum_free( settings->rom_tc2048 );
5201   if( settings->rom_tc2068_0 ) libspectrum_free( settings->rom_tc2068_0 );
5202   if( settings->rom_tc2068_1 ) libspectrum_free( settings->rom_tc2068_1 );
5203   if( settings->rom_ts2068_0 ) libspectrum_free( settings->rom_ts2068_0 );
5204   if( settings->rom_ts2068_1 ) libspectrum_free( settings->rom_ts2068_1 );
5205   if( settings->rs232_rx ) libspectrum_free( settings->rs232_rx );
5206   if( settings->rs232_tx ) libspectrum_free( settings->rs232_tx );
5207   if( settings->simpleide_master_file ) libspectrum_free( settings->simpleide_master_file );
5208   if( settings->simpleide_slave_file ) libspectrum_free( settings->simpleide_slave_file );
5209   if( settings->snapshot ) libspectrum_free( settings->snapshot );
5210   if( settings->snet ) libspectrum_free( settings->snet );
5211   if( settings->sound_device ) libspectrum_free( settings->sound_device );
5212   if( settings->speaker_type ) libspectrum_free( settings->speaker_type );
5213   if( settings->speccyboot_tap ) libspectrum_free( settings->speccyboot_tap );
5214   if( settings->start_machine ) libspectrum_free( settings->start_machine );
5215   if( settings->start_scaler_mode ) libspectrum_free( settings->start_scaler_mode );
5216   if( settings->stereo_ay ) libspectrum_free( settings->stereo_ay );
5217   if( settings->svga_modes ) libspectrum_free( settings->svga_modes );
5218   if( settings->tape_file ) libspectrum_free( settings->tape_file );
5219   if( settings->zxatasp_master_file ) libspectrum_free( settings->zxatasp_master_file );
5220   if( settings->zxatasp_slave_file ) libspectrum_free( settings->zxatasp_slave_file );
5221   if( settings->zxcf_pri_file ) libspectrum_free( settings->zxcf_pri_file );
5222 #line 793"../settings.pl"
5223 
5224   return 0;
5225 }
5226 
5227 int
settings_end(void)5228 settings_end( void )
5229 {
5230   if( settings_current.autosave_settings )
5231     settings_write_config( &settings_current );
5232 
5233   settings_free( &settings_current );
5234 
5235 #ifdef HAVE_LIB_XML2
5236   xmlCleanupParser();
5237 #endif				/* #ifdef HAVE_LIB_XML2 */
5238 
5239   return 0;
5240 }
5241