Cleanups
This commit is contained in:
parent
1f6e41755b
commit
96ba8b6928
60
core_info.c
60
core_info.c
|
@ -37,8 +37,10 @@
|
||||||
#include "uwp/uwp_func.h"
|
#include "uwp/uwp_func.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char *core_info_tmp_path = NULL;
|
#ifdef HAVE_COMPRESSION
|
||||||
static const struct string_list *core_info_tmp_list = NULL;
|
static const struct string_list *core_info_tmp_list = NULL;
|
||||||
|
#endif
|
||||||
|
static const char *core_info_tmp_path = NULL;
|
||||||
static core_info_t *core_info_current = NULL;
|
static core_info_t *core_info_current = NULL;
|
||||||
static core_info_list_t *core_info_curr_list = NULL;
|
static core_info_list_t *core_info_curr_list = NULL;
|
||||||
|
|
||||||
|
@ -507,6 +509,7 @@ bool core_info_list_get_info(core_info_list_t *core_info_list,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_COMPRESSION
|
||||||
static bool core_info_does_support_any_file(const core_info_t *core,
|
static bool core_info_does_support_any_file(const core_info_t *core,
|
||||||
const struct string_list *list)
|
const struct string_list *list)
|
||||||
{
|
{
|
||||||
|
@ -520,6 +523,7 @@ static bool core_info_does_support_any_file(const core_info_t *core,
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool core_info_does_support_file(
|
static bool core_info_does_support_file(
|
||||||
const core_info_t *core, const char *path)
|
const core_info_t *core, const char *path)
|
||||||
|
@ -539,12 +543,14 @@ static int core_info_qsort_cmp(const void *a_, const void *b_)
|
||||||
{
|
{
|
||||||
const core_info_t *a = (const core_info_t*)a_;
|
const core_info_t *a = (const core_info_t*)a_;
|
||||||
const core_info_t *b = (const core_info_t*)b_;
|
const core_info_t *b = (const core_info_t*)b_;
|
||||||
int support_a =
|
int support_a = core_info_does_support_file(a, core_info_tmp_path);
|
||||||
core_info_does_support_any_file(a, core_info_tmp_list)
|
int support_b = core_info_does_support_file(b, core_info_tmp_path);
|
||||||
|| core_info_does_support_file(a, core_info_tmp_path);
|
#ifdef HAVE_COMPRESSION
|
||||||
int support_b =
|
support_a = support_a ||
|
||||||
core_info_does_support_any_file(b, core_info_tmp_list)
|
core_info_does_support_any_file(a, core_info_tmp_list);
|
||||||
|| core_info_does_support_file(b, core_info_tmp_path);
|
support_b = support_b ||
|
||||||
|
core_info_does_support_any_file(b, core_info_tmp_list);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (support_a != support_b)
|
if (support_a != support_b)
|
||||||
return support_b - support_a;
|
return support_b - support_a;
|
||||||
|
@ -725,8 +731,10 @@ void core_info_list_get_supported_cores(core_info_list_t *core_info_list,
|
||||||
const char *path, const core_info_t **infos, size_t *num_infos)
|
const char *path, const core_info_t **infos, size_t *num_infos)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
struct string_list *list = NULL;
|
|
||||||
size_t supported = 0;
|
size_t supported = 0;
|
||||||
|
#ifdef HAVE_COMPRESSION
|
||||||
|
struct string_list *list = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!core_info_list)
|
if (!core_info_list)
|
||||||
return;
|
return;
|
||||||
|
@ -759,8 +767,10 @@ void core_info_list_get_supported_cores(core_info_list_t *core_info_list,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_COMPRESSION
|
||||||
if (list)
|
if (list)
|
||||||
string_list_free(list);
|
string_list_free(list);
|
||||||
|
#endif
|
||||||
|
|
||||||
*infos = core_info_list->list;
|
*infos = core_info_list->list;
|
||||||
*num_infos = supported;
|
*num_infos = supported;
|
||||||
|
@ -869,7 +879,8 @@ error:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool core_info_database_supports_content_path(const char *database_path, const char *path)
|
bool core_info_database_supports_content_path(
|
||||||
|
const char *database_path, const char *path)
|
||||||
{
|
{
|
||||||
char *database = NULL;
|
char *database = NULL;
|
||||||
const char *new_path = path_basename(database_path);
|
const char *new_path = path_basename(database_path);
|
||||||
|
@ -1001,7 +1012,8 @@ static int core_info_qsort_func_system_name(const core_info_t *a,
|
||||||
return strcasecmp(a->systemname, b->systemname);
|
return strcasecmp(a->systemname, b->systemname);
|
||||||
}
|
}
|
||||||
|
|
||||||
void core_info_qsort(core_info_list_t *core_info_list, enum core_info_list_qsort_type qsort_type)
|
void core_info_qsort(core_info_list_t *core_info_list,
|
||||||
|
enum core_info_list_qsort_type qsort_type)
|
||||||
{
|
{
|
||||||
if (!core_info_list)
|
if (!core_info_list)
|
||||||
return;
|
return;
|
||||||
|
@ -1012,20 +1024,32 @@ void core_info_qsort(core_info_list_t *core_info_list, enum core_info_list_qsort
|
||||||
switch (qsort_type)
|
switch (qsort_type)
|
||||||
{
|
{
|
||||||
case CORE_INFO_LIST_SORT_PATH:
|
case CORE_INFO_LIST_SORT_PATH:
|
||||||
qsort(core_info_list->list, core_info_list->count, sizeof(core_info_t),
|
qsort(core_info_list->list,
|
||||||
(int (*)(const void *, const void *))core_info_qsort_func_path);
|
core_info_list->count,
|
||||||
|
sizeof(core_info_t),
|
||||||
|
(int (*)(const void *, const void *))
|
||||||
|
core_info_qsort_func_path);
|
||||||
break;
|
break;
|
||||||
case CORE_INFO_LIST_SORT_DISPLAY_NAME:
|
case CORE_INFO_LIST_SORT_DISPLAY_NAME:
|
||||||
qsort(core_info_list->list, core_info_list->count, sizeof(core_info_t),
|
qsort(core_info_list->list,
|
||||||
(int (*)(const void *, const void *))core_info_qsort_func_display_name);
|
core_info_list->count,
|
||||||
|
sizeof(core_info_t),
|
||||||
|
(int (*)(const void *, const void *))
|
||||||
|
core_info_qsort_func_display_name);
|
||||||
break;
|
break;
|
||||||
case CORE_INFO_LIST_SORT_CORE_NAME:
|
case CORE_INFO_LIST_SORT_CORE_NAME:
|
||||||
qsort(core_info_list->list, core_info_list->count, sizeof(core_info_t),
|
qsort(core_info_list->list,
|
||||||
(int (*)(const void *, const void *))core_info_qsort_func_core_name);
|
core_info_list->count,
|
||||||
|
sizeof(core_info_t),
|
||||||
|
(int (*)(const void *, const void *))
|
||||||
|
core_info_qsort_func_core_name);
|
||||||
break;
|
break;
|
||||||
case CORE_INFO_LIST_SORT_SYSTEM_NAME:
|
case CORE_INFO_LIST_SORT_SYSTEM_NAME:
|
||||||
qsort(core_info_list->list, core_info_list->count, sizeof(core_info_t),
|
qsort(core_info_list->list,
|
||||||
(int (*)(const void *, const void *))core_info_qsort_func_system_name);
|
core_info_list->count,
|
||||||
|
sizeof(core_info_t),
|
||||||
|
(int (*)(const void *, const void *))
|
||||||
|
core_info_qsort_func_system_name);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue