25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: settings.c,v 1.5 2006/05/16 03:15:14 debug Exp $ |
* $Id: settings.c,v 1.7 2006/07/15 10:06:11 debug Exp $ |
29 |
* |
* |
30 |
* A generic settings object. (This module should be 100% indepedent of GXemul |
* A generic settings object. (This module should be 100% indepedent of GXemul |
31 |
* and hence easily reusable.) It is basically a tree structure of nodes, |
* and hence easily reusable.) It is basically a tree structure of nodes, |
38 |
* presented (e.g. it may be an int value in memory, but it should be |
* presented (e.g. it may be an int value in memory, but it should be |
39 |
* presented as a boolean "true/false" value), and a flag which tells us |
* presented as a boolean "true/false" value), and a flag which tells us |
40 |
* whether the setting is directly writable or not. |
* whether the setting is directly writable or not. |
41 |
|
* |
42 |
|
* If UNSTABLE_DEVEL is defined, then warnings are printed when |
43 |
|
* settings_destroy() is called if individual settings have not yet been |
44 |
|
* deleted. (This is to help making sure that code which uses the settings |
45 |
|
* subsystem correctly un-initializes stuff.) |
46 |
|
* |
47 |
|
* |
48 |
|
* TODO: |
49 |
|
* Remove a setting |
50 |
|
* Read/write settings |
51 |
*/ |
*/ |
52 |
|
|
53 |
#include <stdio.h> |
#include <stdio.h> |
120 |
exit(1); |
exit(1); |
121 |
} |
} |
122 |
|
|
123 |
|
#ifdef UNSTABLE_DEVEL |
124 |
|
if (settings->n_settings > 0) |
125 |
|
printf("settings_destroy(): there are remaining settings!\n"); |
126 |
|
#endif |
127 |
|
|
128 |
if (settings->name != NULL) { |
if (settings->name != NULL) { |
129 |
for (i=0; i<settings->n_settings; i++) { |
for (i=0; i<settings->n_settings; i++) { |
130 |
if (settings->name[i] != NULL) |
if (settings->name[i] != NULL) { |
131 |
|
#ifdef UNSTABLE_DEVEL |
132 |
|
printf("settings_destroy(): setting '%s'" |
133 |
|
" was not properly deleted before " |
134 |
|
"exiting!\n", settings->name[i]); |
135 |
|
#endif |
136 |
free(settings->name[i]); |
free(settings->name[i]); |
137 |
|
} |
138 |
} |
} |
139 |
|
|
140 |
free(settings->name); |
free(settings->name); |
141 |
|
} else if (settings->n_settings != 0) { |
142 |
|
fprintf(stderr, "settings_destroy(): internal error, " |
143 |
|
"settings->name = NULL, but there were settings?" |
144 |
|
" (n_settings = %i)\n", settings->n_settings); |
145 |
|
exit(1); |
146 |
} |
} |
147 |
|
|
148 |
if (settings->writable != NULL) |
if (settings->writable != NULL) |