50enum fcdb_option_source {
57 enum fcdb_option_source
source;
61#define SPECHASH_TAG fcdb_option
62#define SPECHASH_ASTR_KEY_TYPE
63#define SPECHASH_IDATA_TYPE struct fcdb_option *
65#define fcdb_option_hash_data_iterate(phash, data) \
66 TYPED_HASH_DATA_ITERATE(struct fcdb_option *, phash, data)
67#define fcdb_option_hash_data_iterate_end HASH_DATA_ITERATE_END
68#define fcdb_option_hash_keys_iterate(phash, key) \
69 TYPED_HASH_KEYS_ITERATE(char *, phash, key)
70#define fcdb_option_hash_keys_iterate_end HASH_KEYS_ITERATE_END
71#define fcdb_option_hash_iterate(phash, key, data) \
72 TYPED_HASH_ITERATE(char *, struct fcdb_option *, phash, key, data)
73#define fcdb_option_hash_iterate_end HASH_ITERATE_END
75struct fcdb_option_hash *fcdb_config = NULL;
77char *fcdb_script = NULL;
79static bool fcdb_set_option(
const char *key,
const char *value,
80 enum fcdb_option_source
source);
81static bool fcdb_load_config(
const char *filename);
88static bool fcdb_set_option(
const char *key,
const char *value,
89 enum fcdb_option_source
source)
91 struct fcdb_option *oldopt = NULL;
95 struct fcdb_option *newopt =
fc_malloc(
sizeof(*newopt));
99 removed = fcdb_option_hash_replace_full(fcdb_config, key, newopt,
102 removed = fcdb_option_hash_remove_full(fcdb_config, key, NULL, &oldopt);
120static bool fcdb_load_config(
const char *filename)
128 log_error(
_(
"Cannot load fcdb config file '%s':\n%s"), filename,
143#ifndef FREECIV_NDEBUG
144 bool entry_str_get_success =
150 fcdb_set_option(
entry_name(pentry), value, AOS_FILE);
152 log_error(
"Value for '%s' in '%s' is not of string type, ignoring",
170 fcdb_config = fcdb_option_hash_new();
172 if (conf_file && strcmp(conf_file,
"-")) {
173 if (!fcdb_load_config(conf_file)) {
188 struct fcdb_option *opt;
190 if (fcdb_option_hash_lookup(fcdb_config,
type, &opt)) {
204 fcdb_option_hash_data_iterate(fcdb_config, popt) {
207 } fcdb_option_hash_data_iterate_end;
209 fcdb_option_hash_destroy(fcdb_config);
bool fcdb_init(const char *conf_file)
const char * fcdb_option_get(const char *type)
static GtkWidget * source
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
#define log_error(message,...)
struct section_file * secfile_load(const char *filename, bool allow_duplicates)
const char * secfile_error(void)
void secfile_destroy(struct section_file *secfile)
const struct entry_list * section_entries(const struct section *psection)
const char * entry_name(const struct entry *pentry)
bool entry_str_get(const struct entry *pentry, const char **value)
struct section * secfile_section_by_name(const struct section_file *secfile, const char *name)
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
enum entry_type entry_type_get(const struct entry *pentry)
#define entry_list_iterate_end
#define entry_list_iterate(entlist, pentry)
void script_fcdb_free(void)
bool script_fcdb_init(const char *fcdb_luafile)