mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
Revert "Revert this - was getting crashes in both OSX and MSVC 2003"
This reverts commit 7d0dba3007
.
This commit is contained in:
parent
0782c3c820
commit
c443d6b475
@ -66,7 +66,7 @@ struct config_include_list
|
||||
};
|
||||
|
||||
static config_file_t *config_file_new_internal(
|
||||
const char *path, unsigned depth);
|
||||
const char *path, unsigned depth, config_file_cb_t *cb);
|
||||
|
||||
static int config_sort_compare_func(struct config_entry_list *a,
|
||||
struct config_entry_list *b)
|
||||
@ -267,7 +267,7 @@ static void add_child_list(config_file_t *parent, config_file_t *child)
|
||||
parent->tail = NULL;
|
||||
}
|
||||
|
||||
static void add_sub_conf(config_file_t *conf, char *path)
|
||||
static void add_sub_conf(config_file_t *conf, char *path, config_file_cb_t *cb)
|
||||
{
|
||||
char real_path[PATH_MAX_LENGTH];
|
||||
config_file_t *sub_conf = NULL;
|
||||
@ -314,7 +314,7 @@ static void add_sub_conf(config_file_t *conf, char *path)
|
||||
#endif
|
||||
|
||||
sub_conf = (config_file_t*)
|
||||
config_file_new_internal(real_path, conf->include_depth + 1);
|
||||
config_file_new_internal(real_path, conf->include_depth + 1, cb);
|
||||
if (!sub_conf)
|
||||
return;
|
||||
|
||||
@ -324,7 +324,7 @@ static void add_sub_conf(config_file_t *conf, char *path)
|
||||
}
|
||||
|
||||
static bool parse_line(config_file_t *conf,
|
||||
struct config_entry_list *list, char *line)
|
||||
struct config_entry_list *list, char *line, config_file_cb_t *cb)
|
||||
{
|
||||
char *comment = NULL;
|
||||
char *key_tmp = NULL;
|
||||
@ -351,7 +351,7 @@ static bool parse_line(config_file_t *conf,
|
||||
if (conf->include_depth >= MAX_INCLUDE_DEPTH)
|
||||
fprintf(stderr, "!!! #include depth exceeded for config. Might be a cycle.\n");
|
||||
else
|
||||
add_sub_conf(conf, path);
|
||||
add_sub_conf(conf, path, cb);
|
||||
free(path);
|
||||
}
|
||||
goto error;
|
||||
@ -396,18 +396,19 @@ error:
|
||||
}
|
||||
|
||||
static config_file_t *config_file_new_internal(
|
||||
const char *path, unsigned depth)
|
||||
const char *path, unsigned depth, config_file_cb_t *cb)
|
||||
{
|
||||
RFILE *file = NULL;
|
||||
struct config_file *conf = (struct config_file*)malloc(sizeof(*conf));
|
||||
if (!conf)
|
||||
return NULL;
|
||||
|
||||
conf->path = NULL;
|
||||
conf->entries = NULL;
|
||||
conf->tail = NULL;
|
||||
conf->includes = NULL;
|
||||
conf->include_depth = 0;
|
||||
conf->path = NULL;
|
||||
conf->entries = NULL;
|
||||
conf->tail = NULL;
|
||||
conf->includes = NULL;
|
||||
conf->include_depth = 0;
|
||||
conf->guaranteed_no_duplicates = false ;
|
||||
|
||||
if (!path || !*path)
|
||||
return conf;
|
||||
@ -455,7 +456,7 @@ static config_file_t *config_file_new_internal(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*line && parse_line(conf, list, line))
|
||||
if (*line && parse_line(conf, list, line, cb))
|
||||
{
|
||||
if (conf->entries)
|
||||
conf->tail->next = list;
|
||||
@ -463,6 +464,9 @@ static config_file_t *config_file_new_internal(
|
||||
conf->entries = list;
|
||||
|
||||
conf->tail = list;
|
||||
|
||||
if (cb != NULL && list->key != NULL && list->value != NULL)
|
||||
cb->config_file_new_entry_cb(list->key, list->value) ;
|
||||
}
|
||||
|
||||
free(line);
|
||||
@ -551,11 +555,12 @@ config_file_t *config_file_new_from_string(const char *from_string)
|
||||
if (!from_string)
|
||||
return conf;
|
||||
|
||||
conf->path = NULL;
|
||||
conf->entries = NULL;
|
||||
conf->tail = NULL;
|
||||
conf->includes = NULL;
|
||||
conf->include_depth = 0;
|
||||
conf->path = NULL;
|
||||
conf->entries = NULL;
|
||||
conf->tail = NULL;
|
||||
conf->includes = NULL;
|
||||
conf->include_depth = 0;
|
||||
conf->guaranteed_no_duplicates = false ;
|
||||
|
||||
lines = string_split(from_string, "\n");
|
||||
if (!lines)
|
||||
@ -580,7 +585,7 @@ config_file_t *config_file_new_from_string(const char *from_string)
|
||||
|
||||
if (line && conf)
|
||||
{
|
||||
if (*line && parse_line(conf, list, line))
|
||||
if (*line && parse_line(conf, list, line, NULL))
|
||||
{
|
||||
if (conf->entries)
|
||||
conf->tail->next = list;
|
||||
@ -600,9 +605,13 @@ config_file_t *config_file_new_from_string(const char *from_string)
|
||||
return conf;
|
||||
}
|
||||
|
||||
config_file_t *config_file_new_with_callback(const char *path, config_file_cb_t *cb)
|
||||
{
|
||||
return config_file_new_internal(path, 0, cb);
|
||||
}
|
||||
config_file_t *config_file_new(const char *path)
|
||||
{
|
||||
return config_file_new_internal(path, 0);
|
||||
return config_file_new_internal(path, 0, NULL);
|
||||
}
|
||||
|
||||
static struct config_entry_list *config_get_entry(const config_file_t *conf,
|
||||
@ -834,7 +843,7 @@ bool config_get_bool(config_file_t *conf, const char *key, bool *in)
|
||||
void config_set_string(config_file_t *conf, const char *key, const char *val)
|
||||
{
|
||||
struct config_entry_list *last = conf->entries;
|
||||
struct config_entry_list *entry = config_get_entry(conf, key, &last);
|
||||
struct config_entry_list *entry = conf->guaranteed_no_duplicates?NULL:config_get_entry(conf, key, &last);
|
||||
|
||||
if (entry && !entry->readonly)
|
||||
{
|
||||
|
@ -58,6 +58,7 @@ struct config_file
|
||||
struct config_entry_list *entries;
|
||||
struct config_entry_list *tail;
|
||||
unsigned include_depth;
|
||||
bool guaranteed_no_duplicates;
|
||||
|
||||
struct config_include_list *includes;
|
||||
};
|
||||
@ -65,6 +66,13 @@ struct config_file
|
||||
|
||||
typedef struct config_file config_file_t;
|
||||
|
||||
struct config_file_cb
|
||||
{
|
||||
void (*config_file_new_entry_cb)(char*, char*);
|
||||
};
|
||||
|
||||
typedef struct config_file_cb config_file_cb_t ;
|
||||
|
||||
/* Config file format
|
||||
* - # are treated as comments. Rest of the line is ignored.
|
||||
* - Format is: key = value. There can be as many spaces as you like in-between.
|
||||
@ -79,6 +87,11 @@ typedef struct config_file config_file_t;
|
||||
* NULL path will create an empty config file. */
|
||||
config_file_t *config_file_new(const char *path);
|
||||
|
||||
/* Loads a config file. Returns NULL if file doesn't exist.
|
||||
* NULL path will create an empty config file.
|
||||
* Includes cb callbacks to run custom code during config file processing.*/
|
||||
config_file_t *config_file_new_with_callback(const char *path, config_file_cb_t *cb);
|
||||
|
||||
/* Load a config file from a string. */
|
||||
config_file_t *config_file_new_from_string(const char *from_string);
|
||||
|
||||
@ -178,3 +191,4 @@ bool config_file_exists(const char *path);
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -77,7 +77,8 @@ enum cheat_rumble_type
|
||||
RUMBLE_TYPE_LT_VALUE,
|
||||
RUMBLE_TYPE_GT_VALUE,
|
||||
RUMBLE_TYPE_INCREASE_BY_VALUE,
|
||||
RUMBLE_TYPE_DECREASE_BY_VALUE
|
||||
RUMBLE_TYPE_DECREASE_BY_VALUE,
|
||||
RUMBLE_TYPE_END_LIST
|
||||
};
|
||||
|
||||
/* Some codes are ridiculously large - over 10000 bytes */
|
||||
@ -178,6 +179,8 @@ struct cheat_manager
|
||||
unsigned browse_address;
|
||||
char working_desc[CHEAT_DESC_SCRATCH_SIZE] ;
|
||||
char working_code[CHEAT_CODE_SCRATCH_SIZE] ;
|
||||
unsigned int loading_cheat_size;
|
||||
unsigned int loading_cheat_offset;
|
||||
};
|
||||
|
||||
typedef struct cheat_manager cheat_manager_t;
|
||||
|
@ -45,7 +45,7 @@ RETRO_BEGIN_DECLS
|
||||
#endif
|
||||
|
||||
#ifndef MAX_CHEAT_COUNTERS
|
||||
#define MAX_CHEAT_COUNTERS 100
|
||||
#define MAX_CHEAT_COUNTERS 6000
|
||||
#endif
|
||||
|
||||
#define MENU_SETTINGS_CORE_INFO_NONE 0xffff
|
||||
|
@ -4745,7 +4745,7 @@ static bool setting_append_list(
|
||||
config_uint_cbs(cheat_manager_state.working_cheat.rumble_type, CHEAT_RUMBLE_TYPE,
|
||||
setting_uint_action_left_default,setting_uint_action_right_default,
|
||||
MENU_ENUM_LABEL_RUMBLE_TYPE_DISABLED,&setting_get_string_representation_uint_as_enum,
|
||||
RUMBLE_TYPE_DISABLED,RUMBLE_TYPE_GT_VALUE,1) ;
|
||||
RUMBLE_TYPE_DISABLED,RUMBLE_TYPE_END_LIST-1,1) ;
|
||||
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
|
||||
|
||||
config_uint_cbs(cheat_manager_state.working_cheat.rumble_value, CHEAT_RUMBLE_VALUE,
|
||||
|
Loading…
Reference in New Issue
Block a user