(core_info) Do same here

This commit is contained in:
twinaphex 2014-06-01 02:29:19 +02:00
parent a0bbb144be
commit 06ee8f1bc6
4 changed files with 68 additions and 29 deletions

View File

@ -27,9 +27,13 @@
static core_info_list_t* global_core_list = 0; static core_info_list_t* global_core_list = 0;
static char core_config_path[PATH_MAX]; static char core_config_path[PATH_MAX];
static void core_info_list_resolve_all_extensions(core_info_list_t *core_info_list) static void core_info_list_resolve_all_extensions(void *data)
{ {
size_t i, all_ext_len = 0; size_t i, all_ext_len = 0;
core_info_list_t *core_info_list = (core_info_list_t*)data;
if (!core_info_list)
return;
for (i = 0; i < core_info_list->count; i++) for (i = 0; i < core_info_list->count; i++)
{ {
all_ext_len += core_info_list->list[i].supported_extensions ? all_ext_len += core_info_list->list[i].supported_extensions ?
@ -56,10 +60,13 @@ static void core_info_list_resolve_all_extensions(core_info_list_t *core_info_li
} }
} }
static void core_info_list_resolve_all_firmware(core_info_list_t *core_info_list) static void core_info_list_resolve_all_firmware(void *data)
{ {
size_t i; size_t i;
unsigned c; unsigned c;
core_info_list_t *core_info_list = (core_info_list_t*)data;
if (!core_info_list)
return;
for (i = 0; i < core_info_list->count; i++) for (i = 0; i < core_info_list->count; i++)
{ {
@ -176,9 +183,10 @@ error:
return NULL; return NULL;
} }
void core_info_list_free(core_info_list_t *core_info_list) void core_info_list_free(void *data)
{ {
size_t i, j; size_t i, j;
core_info_list_t *core_info_list = (core_info_list_t*)data;
if (!core_info_list) if (!core_info_list)
return; return;
@ -212,18 +220,26 @@ void core_info_list_free(core_info_list_t *core_info_list)
free(core_info_list); free(core_info_list);
} }
size_t core_info_list_num_info_files(core_info_list_t *core_info_list) size_t core_info_list_num_info_files(void *data)
{ {
size_t i, num; size_t i, num;
core_info_list_t *core_info_list = (core_info_list_t*)data;
if (!core_info_list)
return 0;
num = 0; num = 0;
for (i = 0; i < core_info_list->count; i++) for (i = 0; i < core_info_list->count; i++)
num += !!core_info_list->list[i].data; num += !!core_info_list->list[i].data;
return num; return num;
} }
bool core_info_list_get_display_name(core_info_list_t *core_info_list, const char *path, char *buf, size_t size) bool core_info_list_get_display_name(void *data, const char *path, char *buf, size_t size)
{ {
size_t i; size_t i;
core_info_list_t *core_info_list = (core_info_list_t*)data;
if (!core_info_list)
return false;
for (i = 0; i < core_info_list->count; i++) for (i = 0; i < core_info_list->count; i++)
{ {
const core_info_t *info = &core_info_list->list[i]; const core_info_t *info = &core_info_list->list[i];
@ -237,11 +253,12 @@ bool core_info_list_get_display_name(core_info_list_t *core_info_list, const cha
return false; return false;
} }
bool core_info_list_get_info(void *data, core_info_t *out_info, const char *path) bool core_info_list_get_info(void *data1, void *data2, const char *path)
{ {
size_t i; size_t i;
core_info_list_t *core_info_list = (core_info_list_t*)data; core_info_list_t *core_info_list = (core_info_list_t*)data1;
if (!core_info_list) core_info_t *out_info = (core_info_t*)data2;
if (!core_info_list || !out_info)
return false; return false;
memset(out_info, 0, sizeof(*out_info)); memset(out_info, 0, sizeof(*out_info));
@ -259,9 +276,11 @@ bool core_info_list_get_info(void *data, core_info_t *out_info, const char *path
return false; return false;
} }
bool core_info_does_support_any_file(const core_info_t *core, const struct string_list *list) bool core_info_does_support_any_file(const void *data1, const void *data2)
{ {
size_t i; size_t i;
const core_info_t *core = (const core_info_t*)data1;
const struct string_list *list = (const struct string_list*)data2;
if (!list || !core || !core->supported_extensions_list) if (!list || !core || !core->supported_extensions_list)
return false; return false;
@ -271,17 +290,21 @@ bool core_info_does_support_any_file(const core_info_t *core, const struct strin
return false; return false;
} }
bool core_info_does_support_file(const core_info_t *core, const char *path) bool core_info_does_support_file(const void *data, const char *path)
{ {
const core_info_t *core = (const core_info_t*)data;
if (!path || !core || !core->supported_extensions_list) if (!path || !core || !core->supported_extensions_list)
return false; return false;
return string_list_find_elem_prefix(core->supported_extensions_list, ".", path_get_extension(path)); return string_list_find_elem_prefix(core->supported_extensions_list, ".", path_get_extension(path));
} }
const char *core_info_list_get_all_extensions(core_info_list_t *core_info_list) const char *core_info_list_get_all_extensions(void *data)
{ {
return core_info_list->all_ext; core_info_list_t *core_info_list = (core_info_list_t*)data;
if (core_info_list)
return core_info_list->all_ext;
return "";
} }
// qsort_r() is not in standard C, sadly. // qsort_r() is not in standard C, sadly.
@ -304,9 +327,13 @@ static int core_info_qsort_cmp(const void *a_, const void *b_)
return strcasecmp(a->display_name, b->display_name); return strcasecmp(a->display_name, b->display_name);
} }
void core_info_list_get_supported_cores(core_info_list_t *core_info_list, const char *path, void core_info_list_get_supported_cores(void *data, const char *path,
const core_info_t **infos, size_t *num_infos) const core_info_t **infos, size_t *num_infos)
{ {
core_info_list_t *core_info_list = (core_info_list_t*)data;
if (!core_info_list)
return;
core_info_tmp_path = path; core_info_tmp_path = path;
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
@ -341,9 +368,14 @@ void core_info_list_get_supported_cores(core_info_list_t *core_info_list, const
*num_infos = supported; *num_infos = supported;
} }
static core_info_t *find_core_info(core_info_list_t *list, const char *core) static core_info_t *find_core_info(void *data, const char *core)
{ {
size_t i; size_t i;
core_info_list_t *list = (core_info_list_t*)data;
if (!list)
return NULL;
for (i = 0; i < list->count; i++) for (i = 0; i < list->count; i++)
{ {
core_info_t *info = &list->list[i]; core_info_t *info = &list->list[i];
@ -365,11 +397,14 @@ static int core_info_firmware_cmp(const void *a_, const void *b_)
return strcasecmp(a->path, b->path); return strcasecmp(a->path, b->path);
} }
void core_info_list_update_missing_firmware(core_info_list_t *core_info_list, void core_info_list_update_missing_firmware(void *data,
const char *core, const char *systemdir) const char *core, const char *systemdir)
{ {
size_t i; size_t i;
char path[PATH_MAX]; char path[PATH_MAX];
core_info_list_t *core_info_list = (core_info_list_t*)data;
if (!core_info_list)
return;
core_info_t *info = find_core_info(core_info_list, core); core_info_t *info = find_core_info(core_info_list, core);
if (!info) if (!info)
@ -385,12 +420,15 @@ void core_info_list_update_missing_firmware(core_info_list_t *core_info_list,
} }
} }
void core_info_list_get_missing_firmware(core_info_list_t *core_info_list, void core_info_list_get_missing_firmware(void *data,
const char *core, const char *systemdir, const char *core, const char *systemdir,
const core_info_firmware_t **firmware, size_t *num_firmware) const core_info_firmware_t **firmware, size_t *num_firmware)
{ {
size_t i; size_t i;
char path[PATH_MAX]; char path[PATH_MAX];
core_info_list_t *core_info_list = (core_info_list_t*)data;
if (!core_info_list)
return;
*firmware = NULL; *firmware = NULL;
*num_firmware = 0; *num_firmware = 0;

View File

@ -60,31 +60,31 @@ typedef struct
} core_info_list_t; } core_info_list_t;
core_info_list_t *core_info_list_new(const char *modules_path); core_info_list_t *core_info_list_new(const char *modules_path);
void core_info_list_free(core_info_list_t *core_info_list); void core_info_list_free(void *data);
size_t core_info_list_num_info_files(core_info_list_t *core_info_list); size_t core_info_list_num_info_files(void *data);
bool core_info_does_support_file(const core_info_t *core, const char *path); bool core_info_does_support_file(const void *data, const char *path);
bool core_info_does_support_any_file(const core_info_t *core, const struct string_list *list); bool core_info_does_support_any_file(const void *data, const void *list);
// Non-reentrant, does not allocate. Returns pointer to internal state. // Non-reentrant, does not allocate. Returns pointer to internal state.
void core_info_list_get_supported_cores(core_info_list_t *core_info_list, const char *path, void core_info_list_get_supported_cores(void *data, const char *path,
const core_info_t **infos, size_t *num_infos); const core_info_t **infos, size_t *num_infos);
// Non-reentrant, does not allocate. Returns pointer to internal state. // Non-reentrant, does not allocate. Returns pointer to internal state.
void core_info_list_get_missing_firmware(core_info_list_t *core_info_list, void core_info_list_get_missing_firmware(void *data,
const char *core, const char *systemdir, const char *core, const char *systemdir,
const core_info_firmware_t **firmware, size_t *num_firmware); const core_info_firmware_t **firmware, size_t *num_firmware);
void core_info_list_update_missing_firmware(core_info_list_t *core_info_list, void core_info_list_update_missing_firmware(void *data,
const char *core, const char *systemdir); const char *core, const char *systemdir);
// Shallow-copies internal state. Data in *info is invalidated when the core_info_list is freed. // Shallow-copies internal state. Data in *info is invalidated when the core_info_list is freed.
bool core_info_list_get_info(void *data, core_info_t *info, const char *path); bool core_info_list_get_info(void *data1, void *data2, const char *path);
const char *core_info_list_get_all_extensions(core_info_list_t *core_info_list); const char *core_info_list_get_all_extensions(void *data);
bool core_info_list_get_display_name(core_info_list_t *core_info_list, const char *path, char *buf, size_t size); bool core_info_list_get_display_name(void *data, const char *path, char *buf, size_t size);
void core_info_set_core_path(const char* core_path); void core_info_set_core_path(const char* core_path);
void core_info_set_config_path(const char* config_path); void core_info_set_config_path(const char* config_path);

View File

@ -903,13 +903,14 @@ static inline bool menu_list_elem_is_dir(file_list_t *buf, unsigned offset)
return type != RGUI_FILE_PLAIN; return type != RGUI_FILE_PLAIN;
} }
void menu_build_scroll_indices(file_list_t *buf) void menu_build_scroll_indices(void *data)
{ {
size_t i; size_t i;
int current; int current;
bool current_is_dir; bool current_is_dir;
file_list_t *buf = (file_list_t*)data;
if (!driver.menu) if (!driver.menu || !buf)
return; return;
driver.menu->scroll_indices_size = 0; driver.menu->scroll_indices_size = 0;

View File

@ -121,7 +121,7 @@ uint64_t menu_input(void);
void menu_flush_stack_type(unsigned final_type); void menu_flush_stack_type(unsigned final_type);
void menu_update_system_info(void *data, bool *load_no_rom); void menu_update_system_info(void *data, bool *load_no_rom);
void menu_build_scroll_indices(file_list_t *buf); void menu_build_scroll_indices(void *data);
#ifdef __cplusplus #ifdef __cplusplus
} }