2013-06-24 11:52:14 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2017-03-22 02:09:18 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2019-02-22 21:31:54 +00:00
|
|
|
* Copyright (C) 2016-2019 - Brad Parker
|
2016-10-10 08:49:09 +00:00
|
|
|
*
|
2013-06-24 11:52:14 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-09-08 04:07:43 +00:00
|
|
|
#include <compat/strl.h>
|
|
|
|
#include <string/stdstring.h>
|
2018-04-10 01:02:10 +00:00
|
|
|
#include <file/config_file.h>
|
2014-10-21 22:23:06 +00:00
|
|
|
#include <file/file_path.h>
|
2016-03-20 13:53:54 +00:00
|
|
|
#include <lists/dir_list.h>
|
2016-03-20 15:14:40 +00:00
|
|
|
#include <file/archive_file.h>
|
2015-09-04 19:11:00 +00:00
|
|
|
|
2016-09-08 04:07:43 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2016-01-20 03:07:24 +00:00
|
|
|
|
2019-07-24 02:44:45 +00:00
|
|
|
#include "retroarch.h"
|
2016-11-28 01:24:23 +00:00
|
|
|
|
2015-12-11 12:56:00 +00:00
|
|
|
#include "core_info.h"
|
2018-04-09 20:20:51 +00:00
|
|
|
#include "file_path_special.h"
|
2013-10-05 16:33:22 +00:00
|
|
|
|
2019-01-02 12:30:58 +00:00
|
|
|
#if defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
2019-01-01 13:47:41 +00:00
|
|
|
#include "uwp/uwp_func.h"
|
|
|
|
#endif
|
|
|
|
|
2019-07-24 02:44:45 +00:00
|
|
|
enum compare_op
|
|
|
|
{
|
2020-02-16 19:27:22 +00:00
|
|
|
COMPARE_OP_EQUAL = 0,
|
2019-07-24 02:44:45 +00:00
|
|
|
COMPARE_OP_NOT_EQUAL,
|
|
|
|
COMPARE_OP_LESS,
|
|
|
|
COMPARE_OP_LESS_EQUAL,
|
|
|
|
COMPARE_OP_GREATER,
|
|
|
|
COMPARE_OP_GREATER_EQUAL
|
|
|
|
};
|
|
|
|
|
2020-03-06 17:13:36 +00:00
|
|
|
struct core_info_state
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPRESSION
|
|
|
|
const struct string_list *tmp_list;
|
|
|
|
#endif
|
|
|
|
const char *tmp_path;
|
|
|
|
core_info_t *current;
|
|
|
|
core_info_list_t *curr_list;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct core_info_state core_info_state_t;
|
|
|
|
|
|
|
|
static core_info_state_t core_info_st;
|
|
|
|
|
|
|
|
static core_info_state_t *coreinfo_get_ptr(void)
|
|
|
|
{
|
|
|
|
return &core_info_st;
|
|
|
|
}
|
|
|
|
|
2014-09-02 03:10:54 +00:00
|
|
|
static void core_info_list_resolve_all_extensions(
|
|
|
|
core_info_list_t *core_info_list)
|
2013-11-21 22:48:31 +00:00
|
|
|
{
|
2016-12-25 00:46:32 +00:00
|
|
|
size_t i = 0;
|
2019-05-10 06:31:18 +00:00
|
|
|
size_t all_ext_len = 0;
|
|
|
|
char *all_ext = NULL;
|
2015-01-09 14:33:58 +00:00
|
|
|
|
2019-05-10 06:31:18 +00:00
|
|
|
for (i = 0; i < core_info_list->count; i++)
|
|
|
|
{
|
|
|
|
if (core_info_list->list[i].supported_extensions)
|
|
|
|
all_ext_len +=
|
|
|
|
(strlen(core_info_list->list[i].supported_extensions) + 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
all_ext_len += STRLEN_CONST("7z|") + STRLEN_CONST("zip|");
|
|
|
|
|
|
|
|
all_ext = (char*)calloc(1, all_ext_len);
|
|
|
|
|
|
|
|
if (!all_ext)
|
|
|
|
return;
|
|
|
|
|
|
|
|
core_info_list->all_ext = all_ext;
|
2016-12-25 00:46:32 +00:00
|
|
|
|
2015-02-05 17:34:31 +00:00
|
|
|
for (i = 0; i < core_info_list->count; i++)
|
2013-11-21 22:48:31 +00:00
|
|
|
{
|
2015-02-05 17:34:31 +00:00
|
|
|
if (!core_info_list->list[i].supported_extensions)
|
|
|
|
continue;
|
2015-01-12 03:19:57 +00:00
|
|
|
|
2019-09-22 22:18:29 +00:00
|
|
|
strlcat(core_info_list->all_ext,
|
2019-05-10 06:31:18 +00:00
|
|
|
core_info_list->list[i].supported_extensions, all_ext_len);
|
2019-09-22 22:18:29 +00:00
|
|
|
strlcat(core_info_list->all_ext, "|", all_ext_len);
|
2013-11-21 22:48:31 +00:00
|
|
|
}
|
2017-02-11 04:58:40 +00:00
|
|
|
#ifdef HAVE_7ZIP
|
2019-09-22 22:18:29 +00:00
|
|
|
strlcat(core_info_list->all_ext, "7z|", all_ext_len);
|
2017-02-11 04:58:40 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_ZLIB
|
2019-09-22 22:18:29 +00:00
|
|
|
strlcat(core_info_list->all_ext, "zip|", all_ext_len);
|
2017-02-11 04:58:40 +00:00
|
|
|
#endif
|
2013-11-21 22:48:31 +00:00
|
|
|
}
|
|
|
|
|
2014-09-02 03:10:54 +00:00
|
|
|
static void core_info_list_resolve_all_firmware(
|
|
|
|
core_info_list_t *core_info_list)
|
2013-11-21 22:48:31 +00:00
|
|
|
{
|
2013-11-24 01:08:20 +00:00
|
|
|
size_t i;
|
|
|
|
unsigned c;
|
2015-01-09 14:33:58 +00:00
|
|
|
|
2013-11-22 16:43:49 +00:00
|
|
|
for (i = 0; i < core_info_list->count; i++)
|
2013-11-21 22:48:31 +00:00
|
|
|
{
|
2016-12-25 00:46:32 +00:00
|
|
|
unsigned count = 0;
|
|
|
|
core_info_firmware_t *firmware = NULL;
|
|
|
|
core_info_t *info = (core_info_t*)&core_info_list->list[i];
|
|
|
|
config_file_t *config = (config_file_t*)info->config_data;
|
2013-11-21 22:48:31 +00:00
|
|
|
|
2016-12-14 10:47:04 +00:00
|
|
|
if (!config || !config_get_uint(config, "firmware_count", &count))
|
2013-11-21 22:48:31 +00:00
|
|
|
continue;
|
|
|
|
|
2016-12-25 00:46:32 +00:00
|
|
|
firmware = (core_info_firmware_t*)calloc(count, sizeof(*firmware));
|
2014-09-02 03:10:54 +00:00
|
|
|
|
2016-12-25 00:46:32 +00:00
|
|
|
if (!firmware)
|
2013-11-21 22:48:31 +00:00
|
|
|
continue;
|
2014-03-03 09:11:07 +00:00
|
|
|
|
2016-12-25 00:46:32 +00:00
|
|
|
info->firmware = firmware;
|
|
|
|
|
2013-11-22 16:43:49 +00:00
|
|
|
for (c = 0; c < count; c++)
|
2013-11-21 22:48:31 +00:00
|
|
|
{
|
2016-12-14 10:47:04 +00:00
|
|
|
char path_key[64];
|
|
|
|
char desc_key[64];
|
|
|
|
char opt_key[64];
|
2016-12-14 12:15:23 +00:00
|
|
|
bool tmp_bool = false;
|
|
|
|
char *tmp = NULL;
|
|
|
|
path_key[0] = desc_key[0] = opt_key[0] = '\0';
|
2014-03-04 08:34:34 +00:00
|
|
|
|
2013-11-21 22:48:31 +00:00
|
|
|
snprintf(path_key, sizeof(path_key), "firmware%u_path", c);
|
|
|
|
snprintf(desc_key, sizeof(desc_key), "firmware%u_desc", c);
|
2016-06-20 02:23:00 +00:00
|
|
|
snprintf(opt_key, sizeof(opt_key), "firmware%u_opt", c);
|
2013-11-21 22:48:31 +00:00
|
|
|
|
2017-01-11 06:25:42 +00:00
|
|
|
if (config_get_string(config, path_key, &tmp) && !string_is_empty(tmp))
|
2016-12-14 12:15:23 +00:00
|
|
|
{
|
|
|
|
info->firmware[c].path = strdup(tmp);
|
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
2017-01-11 06:25:42 +00:00
|
|
|
if (config_get_string(config, desc_key, &tmp) && !string_is_empty(tmp))
|
2016-12-14 12:15:23 +00:00
|
|
|
{
|
|
|
|
info->firmware[c].desc = strdup(tmp);
|
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
2017-01-13 17:24:24 +00:00
|
|
|
if (tmp)
|
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
2016-12-14 12:15:23 +00:00
|
|
|
if (config_get_bool(config, opt_key , &tmp_bool))
|
|
|
|
info->firmware[c].optional = tmp_bool;
|
2013-11-21 22:48:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-07 11:51:45 +00:00
|
|
|
static void core_info_list_free(core_info_list_t *core_info_list)
|
|
|
|
{
|
|
|
|
size_t i, j;
|
|
|
|
|
|
|
|
if (!core_info_list)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < core_info_list->count; i++)
|
|
|
|
{
|
|
|
|
core_info_t *info = (core_info_t*)&core_info_list->list[i];
|
|
|
|
|
|
|
|
free(info->path);
|
|
|
|
free(info->core_name);
|
|
|
|
free(info->systemname);
|
2018-08-21 14:41:16 +00:00
|
|
|
free(info->system_id);
|
2016-02-07 11:51:45 +00:00
|
|
|
free(info->system_manufacturer);
|
|
|
|
free(info->display_name);
|
2018-04-30 18:33:05 +00:00
|
|
|
free(info->display_version);
|
2016-02-07 11:51:45 +00:00
|
|
|
free(info->supported_extensions);
|
|
|
|
free(info->authors);
|
|
|
|
free(info->permissions);
|
|
|
|
free(info->licenses);
|
|
|
|
free(info->categories);
|
|
|
|
free(info->databases);
|
|
|
|
free(info->notes);
|
2019-07-24 02:44:45 +00:00
|
|
|
free(info->required_hw_api);
|
2016-12-14 15:10:48 +00:00
|
|
|
string_list_free(info->supported_extensions_list);
|
2016-02-07 11:51:45 +00:00
|
|
|
string_list_free(info->authors_list);
|
|
|
|
string_list_free(info->note_list);
|
|
|
|
string_list_free(info->permissions_list);
|
|
|
|
string_list_free(info->licenses_list);
|
|
|
|
string_list_free(info->categories_list);
|
|
|
|
string_list_free(info->databases_list);
|
2019-07-24 02:44:45 +00:00
|
|
|
string_list_free(info->required_hw_api_list);
|
2016-02-07 11:51:45 +00:00
|
|
|
config_file_free((config_file_t*)info->config_data);
|
|
|
|
|
|
|
|
for (j = 0; j < info->firmware_count; j++)
|
|
|
|
{
|
|
|
|
free(info->firmware[j].path);
|
|
|
|
free(info->firmware[j].desc);
|
|
|
|
}
|
|
|
|
free(info->firmware);
|
|
|
|
}
|
|
|
|
|
2019-05-10 06:31:18 +00:00
|
|
|
free(core_info_list->all_ext);
|
2016-02-07 11:51:45 +00:00
|
|
|
free(core_info_list->list);
|
|
|
|
free(core_info_list);
|
|
|
|
}
|
|
|
|
|
2019-04-28 03:15:21 +00:00
|
|
|
static config_file_t *core_info_list_iterate(
|
|
|
|
const char *current_path,
|
|
|
|
const char *path_basedir)
|
2016-02-07 17:32:56 +00:00
|
|
|
{
|
2017-09-09 19:55:35 +00:00
|
|
|
size_t info_path_base_size = PATH_MAX_LENGTH * sizeof(char);
|
2018-02-02 20:48:55 +00:00
|
|
|
char *info_path_base = NULL;
|
2019-04-28 03:15:21 +00:00
|
|
|
char *info_path = NULL;
|
|
|
|
config_file_t *conf = NULL;
|
2018-02-02 20:48:55 +00:00
|
|
|
|
|
|
|
if (!current_path)
|
2019-04-28 03:15:21 +00:00
|
|
|
return NULL;
|
2018-02-02 20:48:55 +00:00
|
|
|
|
2019-01-10 21:24:43 +00:00
|
|
|
info_path_base = (char*)malloc(info_path_base_size);
|
2016-02-07 17:32:56 +00:00
|
|
|
|
2016-12-14 10:47:04 +00:00
|
|
|
info_path_base[0] = '\0';
|
|
|
|
|
2017-09-09 19:55:35 +00:00
|
|
|
fill_pathname_base_noext(info_path_base,
|
2018-02-01 10:28:45 +00:00
|
|
|
current_path,
|
2017-09-09 19:55:35 +00:00
|
|
|
info_path_base_size);
|
2016-02-07 17:32:56 +00:00
|
|
|
|
2018-09-18 06:08:06 +00:00
|
|
|
#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP) && !defined(_3DS) && !defined(VITA) && !defined(PS2) && !defined(HW_WUP))
|
2019-04-30 09:38:47 +00:00
|
|
|
{
|
|
|
|
char *substr = strrchr(info_path_base, '_');
|
|
|
|
if (substr)
|
|
|
|
*substr = '\0';
|
|
|
|
}
|
2016-02-07 17:32:56 +00:00
|
|
|
#endif
|
|
|
|
|
2019-09-18 16:12:57 +00:00
|
|
|
strlcat(info_path_base, ".info", info_path_base_size);
|
2016-02-07 17:32:56 +00:00
|
|
|
|
2019-04-28 03:15:21 +00:00
|
|
|
info_path = (char*)malloc(info_path_base_size);
|
|
|
|
fill_pathname_join(info_path,
|
2018-02-01 10:28:45 +00:00
|
|
|
path_basedir,
|
2019-04-28 03:15:21 +00:00
|
|
|
info_path_base, info_path_base_size);
|
2017-09-09 19:55:35 +00:00
|
|
|
free(info_path_base);
|
2019-04-28 08:17:03 +00:00
|
|
|
info_path_base = NULL;
|
2019-04-28 03:15:21 +00:00
|
|
|
|
|
|
|
if (path_is_valid(info_path))
|
2019-07-18 10:03:50 +00:00
|
|
|
conf = config_file_new_from_path_to_string(info_path);
|
2019-04-28 03:15:21 +00:00
|
|
|
free(info_path);
|
|
|
|
|
|
|
|
return conf;
|
2016-02-07 17:32:56 +00:00
|
|
|
}
|
|
|
|
|
2018-04-10 02:31:19 +00:00
|
|
|
static core_info_list_t *core_info_list_new(const char *path,
|
|
|
|
const char *libretro_info_dir,
|
|
|
|
const char *exts,
|
2019-01-10 21:24:43 +00:00
|
|
|
bool dir_show_hidden_files)
|
2013-06-24 01:18:23 +00:00
|
|
|
{
|
2013-11-21 22:48:31 +00:00
|
|
|
size_t i;
|
2016-02-07 18:01:17 +00:00
|
|
|
core_info_t *core_info = NULL;
|
2013-10-05 11:37:38 +00:00
|
|
|
core_info_list_t *core_info_list = NULL;
|
2018-04-10 01:02:10 +00:00
|
|
|
const char *path_basedir = libretro_info_dir;
|
2019-01-01 13:47:41 +00:00
|
|
|
struct string_list *contents = string_list_new();
|
2019-01-10 21:24:43 +00:00
|
|
|
bool ok = dir_list_append(contents, path, exts,
|
|
|
|
false, dir_show_hidden_files, false, false);
|
2019-01-01 13:47:41 +00:00
|
|
|
|
2019-01-02 12:30:58 +00:00
|
|
|
#if defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
2019-01-01 13:47:41 +00:00
|
|
|
/* UWP: browse the optional packages for additional cores */
|
|
|
|
struct string_list *core_packages = string_list_new();
|
|
|
|
uwp_fill_installed_core_packages(core_packages);
|
|
|
|
for (i = 0; i < core_packages->size; i++)
|
|
|
|
dir_list_append(contents, core_packages->elems[i].data, exts,
|
2019-01-10 21:24:43 +00:00
|
|
|
false, dir_show_hidden_files, false, false);
|
2019-01-01 13:47:41 +00:00
|
|
|
string_list_free(core_packages);
|
|
|
|
#else
|
|
|
|
/* Keep the old 'directory not found' behavior */
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
string_list_free(contents);
|
2019-04-28 03:15:21 +00:00
|
|
|
return NULL;
|
2019-01-01 13:47:41 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-06-26 00:57:19 +00:00
|
|
|
if (!contents)
|
2013-06-24 01:18:23 +00:00
|
|
|
return NULL;
|
|
|
|
|
2013-10-05 11:37:38 +00:00
|
|
|
core_info_list = (core_info_list_t*)calloc(1, sizeof(*core_info_list));
|
|
|
|
if (!core_info_list)
|
2019-04-28 03:15:21 +00:00
|
|
|
{
|
|
|
|
string_list_free(contents);
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-10-05 11:37:38 +00:00
|
|
|
|
|
|
|
core_info = (core_info_t*)calloc(contents->size, sizeof(*core_info));
|
|
|
|
if (!core_info)
|
2019-04-28 03:15:21 +00:00
|
|
|
{
|
|
|
|
core_info_list_free(core_info_list);
|
|
|
|
string_list_free(contents);
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-06-24 01:18:23 +00:00
|
|
|
|
2016-12-14 00:16:10 +00:00
|
|
|
core_info_list->list = core_info;
|
2016-02-11 02:50:54 +00:00
|
|
|
core_info_list->count = contents->size;
|
2013-06-24 01:18:23 +00:00
|
|
|
|
2013-10-22 13:08:17 +00:00
|
|
|
for (i = 0; i < contents->size; i++)
|
2013-06-24 01:18:23 +00:00
|
|
|
{
|
2019-07-18 17:07:27 +00:00
|
|
|
const char *base_path = contents->elems[i].data;
|
|
|
|
config_file_t *conf = core_info_list_iterate(base_path,
|
2019-04-28 03:15:21 +00:00
|
|
|
path_basedir);
|
2016-12-13 23:55:05 +00:00
|
|
|
|
2019-04-28 03:15:21 +00:00
|
|
|
if (conf)
|
2013-06-24 01:18:23 +00:00
|
|
|
{
|
2016-12-14 12:15:23 +00:00
|
|
|
char *tmp = NULL;
|
2016-12-14 11:55:12 +00:00
|
|
|
|
2017-12-12 07:55:31 +00:00
|
|
|
if (config_get_string(conf, "display_name", &tmp)
|
2017-09-09 19:55:35 +00:00
|
|
|
&& !string_is_empty(tmp))
|
2016-12-14 12:15:23 +00:00
|
|
|
{
|
|
|
|
core_info[i].display_name = strdup(tmp);
|
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
2018-04-30 18:33:05 +00:00
|
|
|
if (config_get_string(conf, "display_version", &tmp)
|
|
|
|
&& !string_is_empty(tmp))
|
|
|
|
{
|
|
|
|
core_info[i].display_version = strdup(tmp);
|
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
2017-12-12 07:55:31 +00:00
|
|
|
if (config_get_string(conf, "corename", &tmp)
|
2017-09-09 19:55:35 +00:00
|
|
|
&& !string_is_empty(tmp))
|
2016-12-14 12:15:23 +00:00
|
|
|
{
|
|
|
|
core_info[i].core_name = strdup(tmp);
|
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
|
|
|
|
2017-12-12 07:55:31 +00:00
|
|
|
if (config_get_string(conf, "systemname", &tmp)
|
2017-09-09 19:55:35 +00:00
|
|
|
&& !string_is_empty(tmp))
|
2016-12-14 12:15:23 +00:00
|
|
|
{
|
|
|
|
core_info[i].systemname = strdup(tmp);
|
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
|
|
|
|
2018-08-21 14:41:16 +00:00
|
|
|
if (config_get_string(conf, "systemid", &tmp)
|
2018-08-21 01:55:44 +00:00
|
|
|
&& !string_is_empty(tmp))
|
|
|
|
{
|
2018-08-21 14:41:16 +00:00
|
|
|
core_info[i].system_id = strdup(tmp);
|
2018-08-21 01:55:44 +00:00
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
|
|
|
|
2017-12-12 07:55:31 +00:00
|
|
|
if (config_get_string(conf, "manufacturer", &tmp)
|
2017-09-09 19:55:35 +00:00
|
|
|
&& !string_is_empty(tmp))
|
2016-12-14 12:15:23 +00:00
|
|
|
{
|
|
|
|
core_info[i].system_manufacturer = strdup(tmp);
|
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
|
|
|
|
2019-04-28 03:15:21 +00:00
|
|
|
{
|
|
|
|
unsigned count = 0;
|
|
|
|
config_get_uint(conf, "firmware_count", &count);
|
|
|
|
core_info[i].firmware_count = count;
|
|
|
|
}
|
2016-12-14 12:15:23 +00:00
|
|
|
|
2017-12-12 07:55:31 +00:00
|
|
|
if (config_get_string(conf, "supported_extensions", &tmp)
|
2017-09-09 19:55:35 +00:00
|
|
|
&& !string_is_empty(tmp))
|
2016-12-14 12:15:23 +00:00
|
|
|
{
|
|
|
|
core_info[i].supported_extensions = strdup(tmp);
|
2014-09-02 03:10:54 +00:00
|
|
|
core_info[i].supported_extensions_list =
|
|
|
|
string_split(core_info[i].supported_extensions, "|");
|
2013-11-07 23:30:00 +00:00
|
|
|
|
2016-12-14 12:15:23 +00:00
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
|
|
|
|
2017-12-12 07:55:31 +00:00
|
|
|
if (config_get_string(conf, "authors", &tmp)
|
2017-09-09 19:55:35 +00:00
|
|
|
&& !string_is_empty(tmp))
|
2016-12-14 12:15:23 +00:00
|
|
|
{
|
|
|
|
core_info[i].authors = strdup(tmp);
|
2014-09-02 03:10:54 +00:00
|
|
|
core_info[i].authors_list =
|
|
|
|
string_split(core_info[i].authors, "|");
|
2013-12-14 18:29:14 +00:00
|
|
|
|
2016-12-14 12:15:23 +00:00
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
|
|
|
|
2017-12-12 07:55:31 +00:00
|
|
|
if (config_get_string(conf, "permissions", &tmp)
|
2017-09-09 19:55:35 +00:00
|
|
|
&& !string_is_empty(tmp))
|
2016-12-14 12:15:23 +00:00
|
|
|
{
|
|
|
|
core_info[i].permissions = strdup(tmp);
|
2014-09-02 03:10:54 +00:00
|
|
|
core_info[i].permissions_list =
|
|
|
|
string_split(core_info[i].permissions, "|");
|
|
|
|
|
2016-12-14 12:15:23 +00:00
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
|
|
|
|
2017-12-12 07:55:31 +00:00
|
|
|
if (config_get_string(conf, "license", &tmp)
|
2017-09-09 19:55:35 +00:00
|
|
|
&& !string_is_empty(tmp))
|
2016-12-14 12:15:23 +00:00
|
|
|
{
|
|
|
|
core_info[i].licenses = strdup(tmp);
|
2014-09-08 18:18:36 +00:00
|
|
|
core_info[i].licenses_list =
|
|
|
|
string_split(core_info[i].licenses, "|");
|
|
|
|
|
2016-12-14 12:15:23 +00:00
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
|
|
|
|
2017-12-12 07:55:31 +00:00
|
|
|
if (config_get_string(conf, "categories", &tmp)
|
2017-09-09 19:55:35 +00:00
|
|
|
&& !string_is_empty(tmp))
|
2016-12-14 12:15:23 +00:00
|
|
|
{
|
|
|
|
core_info[i].categories = strdup(tmp);
|
2014-12-14 19:51:53 +00:00
|
|
|
core_info[i].categories_list =
|
|
|
|
string_split(core_info[i].categories, "|");
|
|
|
|
|
2016-12-14 12:15:23 +00:00
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
|
|
|
|
2017-12-12 07:55:31 +00:00
|
|
|
if (config_get_string(conf, "database", &tmp)
|
2017-09-09 19:55:35 +00:00
|
|
|
&& !string_is_empty(tmp))
|
2016-12-14 12:15:23 +00:00
|
|
|
{
|
|
|
|
core_info[i].databases = strdup(tmp);
|
2015-01-25 07:21:02 +00:00
|
|
|
core_info[i].databases_list =
|
|
|
|
string_split(core_info[i].databases, "|");
|
|
|
|
|
2016-12-14 12:15:23 +00:00
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
|
|
|
|
2017-12-12 07:55:31 +00:00
|
|
|
if (config_get_string(conf, "notes", &tmp)
|
2017-09-09 19:55:35 +00:00
|
|
|
&& !string_is_empty(tmp))
|
2016-12-14 12:15:23 +00:00
|
|
|
{
|
|
|
|
core_info[i].notes = strdup(tmp);
|
2014-03-03 09:11:07 +00:00
|
|
|
core_info[i].note_list = string_split(core_info[i].notes, "|");
|
2014-09-09 23:49:51 +00:00
|
|
|
|
2016-12-14 12:15:23 +00:00
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
|
|
|
|
2019-07-24 02:44:45 +00:00
|
|
|
if (config_get_string(conf, "required_hw_api", &tmp)
|
|
|
|
&& !string_is_empty(tmp))
|
|
|
|
{
|
|
|
|
core_info[i].required_hw_api = strdup(tmp);
|
|
|
|
core_info[i].required_hw_api_list = string_split(core_info[i].required_hw_api, "|");
|
|
|
|
|
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
|
|
|
|
2017-01-13 17:35:20 +00:00
|
|
|
if (tmp)
|
|
|
|
free(tmp);
|
|
|
|
tmp = NULL;
|
|
|
|
|
2019-04-28 03:15:21 +00:00
|
|
|
{
|
|
|
|
bool tmp_bool = false;
|
|
|
|
if (config_get_bool(conf, "supports_no_game",
|
|
|
|
&tmp_bool))
|
|
|
|
core_info[i].supports_no_game = tmp_bool;
|
|
|
|
|
|
|
|
if (config_get_bool(conf, "database_match_archive_member",
|
|
|
|
&tmp_bool))
|
|
|
|
core_info[i].database_match_archive_member = tmp_bool;
|
|
|
|
}
|
2017-11-09 00:59:52 +00:00
|
|
|
|
2015-12-06 19:44:21 +00:00
|
|
|
core_info[i].config_data = conf;
|
2013-06-24 01:18:23 +00:00
|
|
|
}
|
2013-06-26 00:57:19 +00:00
|
|
|
|
2019-07-18 17:07:27 +00:00
|
|
|
if (!string_is_empty(base_path))
|
|
|
|
core_info[i].path = strdup(base_path);
|
2016-02-07 17:27:27 +00:00
|
|
|
|
2013-06-26 00:57:19 +00:00
|
|
|
if (!core_info[i].display_name)
|
2016-10-10 08:49:09 +00:00
|
|
|
core_info[i].display_name =
|
2016-02-07 00:15:10 +00:00
|
|
|
strdup(path_basename(core_info[i].path));
|
2013-06-24 01:18:23 +00:00
|
|
|
}
|
|
|
|
|
2016-12-25 00:46:32 +00:00
|
|
|
if (core_info_list)
|
2017-09-29 20:03:26 +00:00
|
|
|
{
|
|
|
|
core_info_list_resolve_all_extensions(core_info_list);
|
2016-12-25 00:46:32 +00:00
|
|
|
core_info_list_resolve_all_firmware(core_info_list);
|
2017-09-29 20:03:26 +00:00
|
|
|
}
|
2013-10-05 15:07:56 +00:00
|
|
|
|
2019-01-01 13:47:41 +00:00
|
|
|
string_list_free(contents);
|
2013-06-24 01:18:23 +00:00
|
|
|
return core_info_list;
|
|
|
|
}
|
|
|
|
|
2016-10-10 08:49:09 +00:00
|
|
|
/* Shallow-copies internal state.
|
2016-02-07 16:34:22 +00:00
|
|
|
*
|
|
|
|
* Data in *info is invalidated when the
|
|
|
|
* core_info_list is freed. */
|
2019-07-24 02:44:45 +00:00
|
|
|
bool core_info_list_get_info(core_info_list_t *core_info_list,
|
2014-09-02 03:10:54 +00:00
|
|
|
core_info_t *out_info, const char *path)
|
2014-03-02 13:07:07 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
2014-06-01 00:29:19 +00:00
|
|
|
if (!core_info_list || !out_info)
|
2014-06-01 00:16:48 +00:00
|
|
|
return false;
|
|
|
|
|
2014-03-02 13:07:07 +00:00
|
|
|
memset(out_info, 0, sizeof(*out_info));
|
|
|
|
|
|
|
|
for (i = 0; i < core_info_list->count; i++)
|
|
|
|
{
|
|
|
|
const core_info_t *info = &core_info_list->list[i];
|
2016-01-20 03:07:24 +00:00
|
|
|
|
2016-10-10 08:49:09 +00:00
|
|
|
if (string_is_equal(path_basename(info->path),
|
2016-02-07 00:15:10 +00:00
|
|
|
path_basename(path)))
|
2014-03-02 13:07:07 +00:00
|
|
|
{
|
|
|
|
*out_info = *info;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-08-10 02:34:15 +00:00
|
|
|
#ifdef HAVE_COMPRESSION
|
2016-02-07 11:59:50 +00:00
|
|
|
static bool core_info_does_support_any_file(const core_info_t *core,
|
2014-09-02 03:10:54 +00:00
|
|
|
const struct string_list *list)
|
2013-10-05 16:33:22 +00:00
|
|
|
{
|
2013-10-22 13:08:17 +00:00
|
|
|
size_t i;
|
2013-10-05 16:33:22 +00:00
|
|
|
if (!list || !core || !core->supported_extensions_list)
|
|
|
|
return false;
|
|
|
|
|
2013-10-22 13:08:17 +00:00
|
|
|
for (i = 0; i < list->size; i++)
|
2014-09-02 03:10:54 +00:00
|
|
|
if (string_list_find_elem_prefix(core->supported_extensions_list,
|
|
|
|
".", path_get_extension(list->elems[i].data)))
|
2013-10-05 16:33:22 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2019-08-10 02:34:15 +00:00
|
|
|
#endif
|
2013-10-05 16:33:22 +00:00
|
|
|
|
2016-02-07 11:53:45 +00:00
|
|
|
static bool core_info_does_support_file(
|
|
|
|
const core_info_t *core, const char *path)
|
2013-06-26 00:57:19 +00:00
|
|
|
{
|
2016-12-14 12:47:22 +00:00
|
|
|
if (!core || !core->supported_extensions_list)
|
2013-06-26 00:57:19 +00:00
|
|
|
return false;
|
2016-12-14 12:47:22 +00:00
|
|
|
if (string_is_empty(path))
|
|
|
|
return false;
|
|
|
|
|
2014-09-02 03:10:54 +00:00
|
|
|
return string_list_find_elem_prefix(
|
|
|
|
core->supported_extensions_list, ".", path_get_extension(path));
|
2013-06-26 00:57:19 +00:00
|
|
|
}
|
|
|
|
|
2014-12-12 19:25:57 +00:00
|
|
|
/* qsort_r() is not in standard C, sadly. */
|
|
|
|
|
|
|
|
static int core_info_qsort_cmp(const void *a_, const void *b_)
|
|
|
|
{
|
2020-03-06 17:13:36 +00:00
|
|
|
core_info_state_t *p_coreinfo = coreinfo_get_ptr();
|
|
|
|
const core_info_t *a = (const core_info_t*)a_;
|
|
|
|
const core_info_t *b = (const core_info_t*)b_;
|
|
|
|
int support_a = core_info_does_support_file(a,
|
|
|
|
p_coreinfo->tmp_path);
|
|
|
|
int support_b = core_info_does_support_file(b,
|
|
|
|
p_coreinfo->tmp_path);
|
2019-08-10 02:34:15 +00:00
|
|
|
#ifdef HAVE_COMPRESSION
|
|
|
|
support_a = support_a ||
|
2020-03-06 17:13:36 +00:00
|
|
|
core_info_does_support_any_file(a, p_coreinfo->tmp_list);
|
2019-08-10 02:34:15 +00:00
|
|
|
support_b = support_b ||
|
2020-03-06 17:13:36 +00:00
|
|
|
core_info_does_support_any_file(b, p_coreinfo->tmp_list);
|
2019-08-10 02:34:15 +00:00
|
|
|
#endif
|
2014-12-12 19:25:57 +00:00
|
|
|
|
|
|
|
if (support_a != support_b)
|
|
|
|
return support_b - support_a;
|
|
|
|
return strcasecmp(a->display_name, b->display_name);
|
2013-10-05 15:07:56 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 16:11:17 +00:00
|
|
|
static core_info_t *core_info_find_internal(
|
|
|
|
core_info_list_t *list,
|
2014-09-02 03:10:54 +00:00
|
|
|
const char *core)
|
2013-11-21 22:48:31 +00:00
|
|
|
{
|
2013-11-22 16:43:49 +00:00
|
|
|
size_t i;
|
2019-03-06 16:38:55 +00:00
|
|
|
const char *core_path_basename = path_basename(core);
|
2014-06-01 00:29:19 +00:00
|
|
|
|
2013-11-22 16:43:49 +00:00
|
|
|
for (i = 0; i < list->count; i++)
|
2013-11-21 22:48:31 +00:00
|
|
|
{
|
2016-02-07 16:39:10 +00:00
|
|
|
core_info_t *info = core_info_get(list, i);
|
2015-01-11 06:37:02 +00:00
|
|
|
|
2016-12-14 12:47:22 +00:00
|
|
|
if (!info || !info->path)
|
2015-01-11 06:37:02 +00:00
|
|
|
continue;
|
2019-03-06 16:38:55 +00:00
|
|
|
if (string_is_equal(path_basename(info->path), core_path_basename))
|
2013-11-21 22:48:31 +00:00
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-05-09 16:11:17 +00:00
|
|
|
static bool core_info_list_update_missing_firmware_internal(
|
2016-02-07 00:15:10 +00:00
|
|
|
core_info_list_t *core_info_list,
|
2016-05-09 16:11:17 +00:00
|
|
|
const char *core,
|
2018-04-10 02:00:01 +00:00
|
|
|
const char *systemdir,
|
|
|
|
bool *set_missing_bios)
|
2014-03-03 06:02:29 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
2017-09-09 19:55:35 +00:00
|
|
|
core_info_t *info = NULL;
|
2018-02-04 22:07:24 +00:00
|
|
|
char *path = NULL;
|
2017-09-09 19:55:35 +00:00
|
|
|
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
2014-08-02 12:01:35 +00:00
|
|
|
|
|
|
|
if (!core_info_list || !core)
|
2018-02-04 22:07:24 +00:00
|
|
|
return false;
|
2014-03-03 06:02:29 +00:00
|
|
|
|
2018-02-04 22:07:24 +00:00
|
|
|
info = core_info_find_internal(core_info_list, core);
|
2016-02-07 18:02:09 +00:00
|
|
|
|
|
|
|
if (!info)
|
2018-02-04 22:07:24 +00:00
|
|
|
return false;
|
2016-12-14 10:47:04 +00:00
|
|
|
|
2019-01-10 21:24:43 +00:00
|
|
|
path = (char*)malloc(path_size);
|
|
|
|
|
|
|
|
if (!path)
|
|
|
|
return false;
|
|
|
|
|
2018-02-04 22:07:24 +00:00
|
|
|
path[0] = '\0';
|
|
|
|
|
2014-03-03 06:02:29 +00:00
|
|
|
for (i = 0; i < info->firmware_count; i++)
|
|
|
|
{
|
2016-12-14 10:47:04 +00:00
|
|
|
if (string_is_empty(info->firmware[i].path))
|
2015-01-11 06:37:02 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
fill_pathname_join(path, systemdir,
|
2017-09-09 19:55:35 +00:00
|
|
|
info->firmware[i].path, path_size);
|
2019-04-27 12:01:50 +00:00
|
|
|
info->firmware[i].missing = !path_is_valid(path);
|
2016-11-28 00:50:41 +00:00
|
|
|
if (info->firmware[i].missing && !info->firmware[i].optional)
|
2018-04-10 02:00:01 +00:00
|
|
|
*set_missing_bios = true;
|
2014-03-03 06:02:29 +00:00
|
|
|
}
|
2016-02-07 15:19:02 +00:00
|
|
|
|
2017-09-09 19:55:35 +00:00
|
|
|
free(path);
|
2016-02-07 15:19:02 +00:00
|
|
|
return true;
|
2014-03-03 06:02:29 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 16:11:17 +00:00
|
|
|
void core_info_free_current_core(void)
|
|
|
|
{
|
2020-03-06 17:13:36 +00:00
|
|
|
core_info_state_t *p_coreinfo = coreinfo_get_ptr();
|
|
|
|
if (p_coreinfo->current)
|
|
|
|
free(p_coreinfo->current);
|
|
|
|
p_coreinfo->current = NULL;
|
2016-05-09 16:11:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool core_info_init_current_core(void)
|
2016-02-07 01:18:26 +00:00
|
|
|
{
|
2020-03-06 17:13:36 +00:00
|
|
|
core_info_state_t *p_coreinfo = coreinfo_get_ptr();
|
|
|
|
core_info_t *current = (core_info_t*)calloc(1, sizeof(*current));
|
|
|
|
if (!current)
|
2016-05-09 16:11:17 +00:00
|
|
|
return false;
|
2020-03-06 17:13:36 +00:00
|
|
|
p_coreinfo->current = current;
|
2016-05-09 16:11:17 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-02-07 01:24:08 +00:00
|
|
|
|
2016-05-09 16:11:17 +00:00
|
|
|
bool core_info_get_current_core(core_info_t **core)
|
|
|
|
{
|
2020-03-06 17:13:36 +00:00
|
|
|
core_info_state_t *p_coreinfo = coreinfo_get_ptr();
|
2016-05-09 16:11:17 +00:00
|
|
|
if (!core)
|
|
|
|
return false;
|
2020-03-06 17:13:36 +00:00
|
|
|
*core = p_coreinfo->current;
|
2016-05-09 16:11:17 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void core_info_deinit_list(void)
|
|
|
|
{
|
2020-03-06 17:13:36 +00:00
|
|
|
core_info_state_t *p_coreinfo = coreinfo_get_ptr();
|
|
|
|
if (p_coreinfo->curr_list)
|
|
|
|
core_info_list_free(p_coreinfo->curr_list);
|
|
|
|
p_coreinfo->curr_list = NULL;
|
2016-05-09 16:11:17 +00:00
|
|
|
}
|
|
|
|
|
2018-04-10 02:31:19 +00:00
|
|
|
bool core_info_init_list(const char *path_info, const char *dir_cores,
|
2019-01-10 21:24:43 +00:00
|
|
|
const char *exts, bool dir_show_hidden_files)
|
2016-05-09 16:11:17 +00:00
|
|
|
{
|
2020-03-06 17:13:36 +00:00
|
|
|
core_info_state_t *p_coreinfo = coreinfo_get_ptr();
|
|
|
|
if (!(p_coreinfo->curr_list = core_info_list_new(dir_cores,
|
2018-04-10 02:31:19 +00:00
|
|
|
!string_is_empty(path_info) ? path_info : dir_cores,
|
|
|
|
exts,
|
2019-01-10 21:24:43 +00:00
|
|
|
dir_show_hidden_files)))
|
2016-05-09 16:11:17 +00:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool core_info_get_list(core_info_list_t **core)
|
|
|
|
{
|
2020-03-06 17:13:36 +00:00
|
|
|
core_info_state_t *p_coreinfo = coreinfo_get_ptr();
|
2016-05-09 16:11:17 +00:00
|
|
|
if (!core)
|
|
|
|
return false;
|
2020-03-06 17:13:36 +00:00
|
|
|
*core = p_coreinfo->curr_list;
|
2016-05-09 16:11:17 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-04-10 02:00:01 +00:00
|
|
|
bool core_info_list_update_missing_firmware(core_info_ctx_firmware_t *info,
|
|
|
|
bool *set_missing_bios)
|
2016-05-09 16:11:17 +00:00
|
|
|
{
|
2020-03-06 17:13:36 +00:00
|
|
|
core_info_state_t *p_coreinfo = coreinfo_get_ptr();
|
2016-05-09 16:11:17 +00:00
|
|
|
if (!info)
|
|
|
|
return false;
|
|
|
|
return core_info_list_update_missing_firmware_internal(
|
2020-03-06 17:13:36 +00:00
|
|
|
p_coreinfo->curr_list,
|
2018-04-10 02:00:01 +00:00
|
|
|
info->path, info->directory.system,
|
|
|
|
set_missing_bios);
|
2016-05-09 16:11:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool core_info_load(core_info_ctx_find_t *info)
|
|
|
|
{
|
2020-03-06 17:13:36 +00:00
|
|
|
core_info_t *core_info = NULL;
|
|
|
|
core_info_state_t *p_coreinfo = coreinfo_get_ptr();
|
2016-05-09 16:11:17 +00:00
|
|
|
|
|
|
|
if (!info)
|
|
|
|
return false;
|
|
|
|
|
2020-03-06 17:13:36 +00:00
|
|
|
if (!p_coreinfo->current)
|
2018-08-15 20:10:52 +00:00
|
|
|
core_info_init_current_core();
|
|
|
|
|
2016-05-09 16:11:17 +00:00
|
|
|
core_info_get_current_core(&core_info);
|
|
|
|
|
2020-03-06 17:13:36 +00:00
|
|
|
if (!p_coreinfo->curr_list)
|
2016-05-09 16:11:17 +00:00
|
|
|
return false;
|
|
|
|
|
2020-03-06 17:13:36 +00:00
|
|
|
if (!core_info_list_get_info(p_coreinfo->curr_list,
|
2016-05-09 16:11:17 +00:00
|
|
|
core_info, info->path))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-07-09 19:50:20 +00:00
|
|
|
bool core_info_find(core_info_ctx_find_t *info, const char *core_path)
|
2016-05-09 16:11:17 +00:00
|
|
|
{
|
2020-03-06 17:13:36 +00:00
|
|
|
core_info_state_t *p_coreinfo = coreinfo_get_ptr();
|
|
|
|
if (!info || !p_coreinfo->curr_list)
|
2016-05-09 16:11:17 +00:00
|
|
|
return false;
|
2020-03-06 17:13:36 +00:00
|
|
|
info->inf = core_info_find_internal(p_coreinfo->curr_list, core_path);
|
2016-05-09 16:11:17 +00:00
|
|
|
if (!info->inf)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
core_info_t *core_info_get(core_info_list_t *list, size_t i)
|
|
|
|
{
|
|
|
|
core_info_t *info = NULL;
|
|
|
|
|
|
|
|
if (!list)
|
|
|
|
return NULL;
|
|
|
|
info = (core_info_t*)&list->list[i];
|
|
|
|
if (!info || !info->path)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2016-09-19 01:54:57 +00:00
|
|
|
size_t i;
|
2020-03-06 17:13:36 +00:00
|
|
|
size_t supported = 0;
|
2019-08-10 02:34:15 +00:00
|
|
|
#ifdef HAVE_COMPRESSION
|
2020-03-06 17:13:36 +00:00
|
|
|
struct string_list *list = NULL;
|
2019-08-10 02:34:15 +00:00
|
|
|
#endif
|
2020-03-06 17:13:36 +00:00
|
|
|
core_info_state_t *p_coreinfo = coreinfo_get_ptr();
|
2016-05-09 16:11:17 +00:00
|
|
|
|
|
|
|
if (!core_info_list)
|
|
|
|
return;
|
|
|
|
|
2020-03-06 17:13:36 +00:00
|
|
|
p_coreinfo->tmp_path = path;
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2016-10-13 19:04:26 +00:00
|
|
|
#ifdef HAVE_COMPRESSION
|
|
|
|
if (path_is_compressed_file(path))
|
2016-05-09 16:11:17 +00:00
|
|
|
list = file_archive_get_file_list(path, NULL);
|
2020-03-06 17:13:36 +00:00
|
|
|
p_coreinfo->tmp_list = list;
|
2016-05-09 16:11:17 +00:00
|
|
|
#endif
|
|
|
|
|
2016-10-10 08:49:09 +00:00
|
|
|
/* Let supported core come first in list so we can return
|
2016-05-09 16:11:17 +00:00
|
|
|
* a pointer to them. */
|
|
|
|
qsort(core_info_list->list, core_info_list->count,
|
|
|
|
sizeof(core_info_t), core_info_qsort_cmp);
|
|
|
|
|
|
|
|
for (i = 0; i < core_info_list->count; i++, supported++)
|
|
|
|
{
|
|
|
|
const core_info_t *core = &core_info_list->list[i];
|
|
|
|
|
|
|
|
if (core_info_does_support_file(core, path))
|
|
|
|
continue;
|
|
|
|
|
2016-10-13 19:04:26 +00:00
|
|
|
#ifdef HAVE_COMPRESSION
|
2016-05-09 16:11:17 +00:00
|
|
|
if (core_info_does_support_any_file(core, list))
|
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-08-10 02:34:15 +00:00
|
|
|
#ifdef HAVE_COMPRESSION
|
2016-05-09 16:11:17 +00:00
|
|
|
if (list)
|
|
|
|
string_list_free(list);
|
2019-08-10 02:34:15 +00:00
|
|
|
#endif
|
2016-05-09 16:11:17 +00:00
|
|
|
|
|
|
|
*infos = core_info_list->list;
|
|
|
|
*num_infos = supported;
|
|
|
|
}
|
|
|
|
|
2018-04-10 01:02:10 +00:00
|
|
|
void core_info_get_name(const char *path, char *s, size_t len,
|
2018-04-10 02:31:19 +00:00
|
|
|
const char *path_info, const char *dir_cores,
|
2019-03-07 16:54:46 +00:00
|
|
|
const char *exts, bool dir_show_hidden_files,
|
|
|
|
bool get_display_name)
|
2016-05-09 16:11:17 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
2018-04-10 01:02:10 +00:00
|
|
|
const char *path_basedir = !string_is_empty(path_info) ?
|
|
|
|
path_info : dir_cores;
|
2018-04-10 02:31:19 +00:00
|
|
|
struct string_list *contents = dir_list_new(
|
2019-01-10 21:24:43 +00:00
|
|
|
dir_cores, exts, false, dir_show_hidden_files, false, false);
|
2019-03-06 16:38:55 +00:00
|
|
|
const char *core_path_basename = path_basename(path);
|
|
|
|
|
2016-05-09 16:11:17 +00:00
|
|
|
if (!contents)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < contents->size; i++)
|
|
|
|
{
|
2016-12-14 00:07:48 +00:00
|
|
|
config_file_t *conf = NULL;
|
|
|
|
char *new_core_name = NULL;
|
2018-02-01 10:28:45 +00:00
|
|
|
const char *current_path = contents->elems[i].data;
|
2016-12-13 23:55:05 +00:00
|
|
|
|
2019-03-06 16:38:55 +00:00
|
|
|
if (!string_is_equal(path_basename(current_path), core_path_basename))
|
2016-05-09 16:11:17 +00:00
|
|
|
continue;
|
2018-02-01 10:28:45 +00:00
|
|
|
|
2019-04-28 03:15:21 +00:00
|
|
|
conf = core_info_list_iterate(contents->elems[i].data,
|
|
|
|
path_basedir);
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2016-12-14 11:55:12 +00:00
|
|
|
if (!conf)
|
|
|
|
continue;
|
|
|
|
|
2019-04-27 12:23:07 +00:00
|
|
|
if (config_get_string(conf, get_display_name
|
|
|
|
? "display_name" : "corename",
|
2016-12-14 11:55:12 +00:00
|
|
|
&new_core_name))
|
|
|
|
{
|
|
|
|
strlcpy(s, new_core_name, len);
|
|
|
|
free(new_core_name);
|
|
|
|
}
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2016-12-14 00:07:48 +00:00
|
|
|
config_file_free(conf);
|
|
|
|
break;
|
2016-05-09 16:11:17 +00:00
|
|
|
}
|
|
|
|
|
2019-04-27 12:23:07 +00:00
|
|
|
dir_list_free(contents);
|
2016-05-09 16:11:17 +00:00
|
|
|
contents = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t core_info_list_num_info_files(core_info_list_t *core_info_list)
|
|
|
|
{
|
|
|
|
size_t i, num = 0;
|
|
|
|
|
|
|
|
if (!core_info_list)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (i = 0; i < core_info_list->count; i++)
|
|
|
|
{
|
|
|
|
config_file_t *conf = (config_file_t*)
|
|
|
|
core_info_list->list[i].config_data;
|
|
|
|
num += !!conf;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
2017-11-09 00:59:52 +00:00
|
|
|
bool core_info_database_match_archive_member(const char *database_path)
|
|
|
|
{
|
2020-03-06 17:13:36 +00:00
|
|
|
char *database = NULL;
|
|
|
|
const char *new_path = path_basename(database_path);
|
|
|
|
core_info_state_t *p_coreinfo = coreinfo_get_ptr();
|
2017-11-09 00:59:52 +00:00
|
|
|
|
|
|
|
if (string_is_empty(new_path))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
database = strdup(new_path);
|
|
|
|
|
|
|
|
if (string_is_empty(database))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
path_remove_extension(database);
|
|
|
|
|
2020-03-06 17:13:36 +00:00
|
|
|
if (p_coreinfo->curr_list)
|
2017-11-09 00:59:52 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
2020-03-06 17:13:36 +00:00
|
|
|
for (i = 0; i < p_coreinfo->curr_list->count; i++)
|
2017-11-09 00:59:52 +00:00
|
|
|
{
|
2020-03-06 17:13:36 +00:00
|
|
|
const core_info_t *info = &p_coreinfo->curr_list->list[i];
|
2017-11-09 00:59:52 +00:00
|
|
|
|
|
|
|
if (!info->database_match_archive_member)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!string_list_find_elem(info->databases_list, database))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
free(database);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
error:
|
|
|
|
if (database)
|
|
|
|
free(database);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-08-10 02:34:15 +00:00
|
|
|
bool core_info_database_supports_content_path(
|
|
|
|
const char *database_path, const char *path)
|
2016-10-03 20:08:55 +00:00
|
|
|
{
|
2020-03-06 17:13:36 +00:00
|
|
|
char *database = NULL;
|
|
|
|
const char *new_path = path_basename(database_path);
|
|
|
|
core_info_state_t *p_coreinfo = coreinfo_get_ptr();
|
2016-10-03 20:08:55 +00:00
|
|
|
|
2017-03-05 17:47:02 +00:00
|
|
|
if (string_is_empty(new_path))
|
2016-10-03 20:08:55 +00:00
|
|
|
return false;
|
|
|
|
|
2017-03-05 17:47:02 +00:00
|
|
|
database = strdup(new_path);
|
2017-01-11 06:25:42 +00:00
|
|
|
|
2017-03-05 17:47:02 +00:00
|
|
|
if (string_is_empty(database))
|
2017-09-10 22:12:26 +00:00
|
|
|
goto error;
|
2016-10-03 20:08:55 +00:00
|
|
|
|
2017-03-05 17:47:02 +00:00
|
|
|
path_remove_extension(database);
|
2016-10-03 20:08:55 +00:00
|
|
|
|
2020-03-06 17:13:36 +00:00
|
|
|
if (p_coreinfo->curr_list)
|
2017-03-05 17:47:02 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
2017-02-28 10:16:05 +00:00
|
|
|
|
2020-03-06 17:13:36 +00:00
|
|
|
for (i = 0; i < p_coreinfo->curr_list->count; i++)
|
2016-10-12 20:14:00 +00:00
|
|
|
{
|
2020-03-06 17:13:36 +00:00
|
|
|
const core_info_t *info = &p_coreinfo->curr_list->list[i];
|
2016-10-12 20:14:00 +00:00
|
|
|
|
2017-03-05 17:47:02 +00:00
|
|
|
if (!string_list_find_elem(info->supported_extensions_list,
|
|
|
|
path_get_extension(path)))
|
2016-12-14 00:16:10 +00:00
|
|
|
continue;
|
|
|
|
|
2017-03-05 17:47:02 +00:00
|
|
|
if (!string_list_find_elem(info->databases_list, database))
|
|
|
|
continue;
|
2016-12-14 00:16:10 +00:00
|
|
|
|
2017-03-05 17:47:02 +00:00
|
|
|
free(database);
|
|
|
|
return true;
|
|
|
|
}
|
2016-10-03 20:08:55 +00:00
|
|
|
}
|
|
|
|
|
2017-09-10 22:12:26 +00:00
|
|
|
error:
|
|
|
|
if (database)
|
|
|
|
free(database);
|
2016-10-03 20:08:55 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-09 16:11:17 +00:00
|
|
|
bool core_info_list_get_display_name(core_info_list_t *core_info_list,
|
|
|
|
const char *path, char *s, size_t len)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!core_info_list)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (i = 0; i < core_info_list->count; i++)
|
2016-02-07 01:18:26 +00:00
|
|
|
{
|
2016-05-09 16:11:17 +00:00
|
|
|
const core_info_t *info = &core_info_list->list[i];
|
2016-12-14 00:23:08 +00:00
|
|
|
|
|
|
|
if (!string_is_equal(path_basename(info->path), path_basename(path)))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!info->display_name)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
strlcpy(s, info->display_name, len);
|
|
|
|
return true;
|
2016-02-07 01:18:26 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 16:11:17 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool core_info_get_display_name(const char *path, char *s, size_t len)
|
|
|
|
{
|
2019-07-17 22:43:03 +00:00
|
|
|
char *tmp = NULL;
|
2019-07-18 10:03:50 +00:00
|
|
|
config_file_t *conf = config_file_new_from_path_to_string(path);
|
2016-05-09 16:11:17 +00:00
|
|
|
|
|
|
|
if (!conf)
|
2019-04-27 12:23:07 +00:00
|
|
|
return false;
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2016-12-14 12:15:23 +00:00
|
|
|
if (config_get_string(conf, "display_name", &tmp))
|
|
|
|
{
|
2017-01-25 01:39:52 +00:00
|
|
|
strlcpy(s, tmp, len);
|
2016-12-14 12:15:23 +00:00
|
|
|
free(tmp);
|
|
|
|
}
|
2016-05-09 16:11:17 +00:00
|
|
|
|
2016-05-24 20:12:41 +00:00
|
|
|
config_file_free(conf);
|
2019-04-27 12:23:07 +00:00
|
|
|
return true;
|
2016-02-07 01:18:26 +00:00
|
|
|
}
|
2019-06-26 16:40:00 +00:00
|
|
|
|
|
|
|
static int core_info_qsort_func_path(const core_info_t *a,
|
|
|
|
const core_info_t *b)
|
|
|
|
{
|
|
|
|
if (!a || !b)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (string_is_empty(a->path) || string_is_empty(b->path))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return strcasecmp(a->path, b->path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int core_info_qsort_func_display_name(const core_info_t *a,
|
|
|
|
const core_info_t *b)
|
|
|
|
{
|
|
|
|
if (!a || !b)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (string_is_empty(a->display_name) || string_is_empty(b->display_name))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return strcasecmp(a->display_name, b->display_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int core_info_qsort_func_core_name(const core_info_t *a,
|
|
|
|
const core_info_t *b)
|
|
|
|
{
|
|
|
|
if (!a || !b)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (string_is_empty(a->core_name) || string_is_empty(b->core_name))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return strcasecmp(a->core_name, b->core_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int core_info_qsort_func_system_name(const core_info_t *a,
|
|
|
|
const core_info_t *b)
|
|
|
|
{
|
|
|
|
if (!a || !b)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (string_is_empty(a->systemname) || string_is_empty(b->systemname))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return strcasecmp(a->systemname, b->systemname);
|
|
|
|
}
|
|
|
|
|
2019-08-10 02:34:15 +00:00
|
|
|
void core_info_qsort(core_info_list_t *core_info_list,
|
|
|
|
enum core_info_list_qsort_type qsort_type)
|
2019-06-26 16:40:00 +00:00
|
|
|
{
|
|
|
|
if (!core_info_list)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (core_info_list->count < 2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (qsort_type)
|
|
|
|
{
|
|
|
|
case CORE_INFO_LIST_SORT_PATH:
|
2019-08-10 02:34:15 +00:00
|
|
|
qsort(core_info_list->list,
|
|
|
|
core_info_list->count,
|
|
|
|
sizeof(core_info_t),
|
|
|
|
(int (*)(const void *, const void *))
|
|
|
|
core_info_qsort_func_path);
|
2019-06-26 16:40:00 +00:00
|
|
|
break;
|
|
|
|
case CORE_INFO_LIST_SORT_DISPLAY_NAME:
|
2019-08-10 02:34:15 +00:00
|
|
|
qsort(core_info_list->list,
|
|
|
|
core_info_list->count,
|
|
|
|
sizeof(core_info_t),
|
|
|
|
(int (*)(const void *, const void *))
|
|
|
|
core_info_qsort_func_display_name);
|
2019-06-26 16:40:00 +00:00
|
|
|
break;
|
|
|
|
case CORE_INFO_LIST_SORT_CORE_NAME:
|
2019-08-10 02:34:15 +00:00
|
|
|
qsort(core_info_list->list,
|
|
|
|
core_info_list->count,
|
|
|
|
sizeof(core_info_t),
|
|
|
|
(int (*)(const void *, const void *))
|
|
|
|
core_info_qsort_func_core_name);
|
2019-06-26 16:40:00 +00:00
|
|
|
break;
|
|
|
|
case CORE_INFO_LIST_SORT_SYSTEM_NAME:
|
2019-08-10 02:34:15 +00:00
|
|
|
qsort(core_info_list->list,
|
|
|
|
core_info_list->count,
|
|
|
|
sizeof(core_info_t),
|
|
|
|
(int (*)(const void *, const void *))
|
|
|
|
core_info_qsort_func_system_name);
|
2019-06-26 16:40:00 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-07-24 02:44:45 +00:00
|
|
|
|
|
|
|
static bool core_info_compare_api_version(int sys_major, int sys_minor, int major, int minor, enum compare_op op)
|
|
|
|
{
|
|
|
|
switch (op)
|
|
|
|
{
|
|
|
|
case COMPARE_OP_EQUAL:
|
|
|
|
if (sys_major == major && sys_minor == minor)
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case COMPARE_OP_NOT_EQUAL:
|
|
|
|
if (!(sys_major == major && sys_minor == minor))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case COMPARE_OP_LESS:
|
|
|
|
if (sys_major < major || (sys_major == major && sys_minor < minor))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case COMPARE_OP_LESS_EQUAL:
|
|
|
|
if (sys_major < major || (sys_major == major && sys_minor <= minor))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case COMPARE_OP_GREATER:
|
|
|
|
if (sys_major > major || (sys_major == major && sys_minor > minor))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case COMPARE_OP_GREATER_EQUAL:
|
|
|
|
if (sys_major > major || (sys_major == major && sys_minor >= minor))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool core_info_hw_api_supported(core_info_t *info)
|
|
|
|
{
|
2019-07-29 20:30:53 +00:00
|
|
|
#ifdef RARCH_INTERNAL
|
2019-07-25 03:42:23 +00:00
|
|
|
unsigned i;
|
2019-07-24 02:44:45 +00:00
|
|
|
enum gfx_ctx_api sys_api;
|
2019-07-25 03:42:23 +00:00
|
|
|
gfx_ctx_flags_t sys_flags = {0};
|
2019-07-24 02:44:45 +00:00
|
|
|
const char *sys_api_version_str = video_driver_get_gpu_api_version_string();
|
2019-07-25 03:42:23 +00:00
|
|
|
int sys_api_version_major = 0;
|
|
|
|
int sys_api_version_minor = 0;
|
2019-07-24 02:44:45 +00:00
|
|
|
|
|
|
|
enum api_parse_state
|
|
|
|
{
|
|
|
|
STATE_API_NAME,
|
|
|
|
STATE_API_COMPARE_OP,
|
|
|
|
STATE_API_VERSION
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!info || !info->required_hw_api_list || info->required_hw_api_list->size == 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
sys_api = video_context_driver_get_api();
|
|
|
|
video_context_driver_get_flags(&sys_flags);
|
|
|
|
|
|
|
|
for (i = 0; i < info->required_hw_api_list->size; i++)
|
|
|
|
{
|
2019-07-25 03:42:23 +00:00
|
|
|
char api_str[32] = {0};
|
|
|
|
char version[16] = {0};
|
|
|
|
char major_str[16] = {0};
|
|
|
|
char minor_str[16] = {0};
|
|
|
|
const char *cur_api = info->required_hw_api_list->elems[i].data;
|
|
|
|
int api_pos = 0;
|
|
|
|
int major_str_pos = 0;
|
|
|
|
int minor_str_pos = 0;
|
|
|
|
int cur_api_len = 0;
|
|
|
|
int j = 0;
|
|
|
|
int major = 0;
|
|
|
|
int minor = 0;
|
|
|
|
bool found_major = false;
|
|
|
|
bool found_minor = false;
|
|
|
|
enum compare_op op = COMPARE_OP_GREATER_EQUAL;
|
2019-07-24 02:44:45 +00:00
|
|
|
enum api_parse_state state = STATE_API_NAME;
|
|
|
|
|
|
|
|
if (string_is_empty(cur_api))
|
|
|
|
continue;
|
|
|
|
|
2019-09-14 15:15:30 +00:00
|
|
|
cur_api_len = (int)strlen(cur_api);
|
2019-07-24 02:44:45 +00:00
|
|
|
|
|
|
|
for (j = 0; j < cur_api_len; j++)
|
|
|
|
{
|
|
|
|
if (cur_api[j] == ' ')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case STATE_API_NAME:
|
|
|
|
{
|
|
|
|
if (isupper(cur_api[j]) || islower(cur_api[j]))
|
|
|
|
api_str[api_pos++] = cur_api[j];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
j--;
|
|
|
|
state = STATE_API_COMPARE_OP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case STATE_API_COMPARE_OP:
|
|
|
|
{
|
|
|
|
if (j < cur_api_len - 1 && !(cur_api[j] >= '0' && cur_api[j] <= '9'))
|
|
|
|
{
|
|
|
|
if (cur_api[j] == '=' && cur_api[j + 1] == '=')
|
|
|
|
{
|
|
|
|
op = COMPARE_OP_EQUAL;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
else if (cur_api[j] == '=')
|
|
|
|
op = COMPARE_OP_EQUAL;
|
|
|
|
else if (cur_api[j] == '!' && cur_api[j + 1] == '=')
|
|
|
|
{
|
|
|
|
op = COMPARE_OP_NOT_EQUAL;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
else if (cur_api[j] == '<' && cur_api[j + 1] == '=')
|
|
|
|
{
|
|
|
|
op = COMPARE_OP_LESS_EQUAL;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
else if (cur_api[j] == '>' && cur_api[j + 1] == '=')
|
|
|
|
{
|
|
|
|
op = COMPARE_OP_GREATER_EQUAL;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
else if (cur_api[j] == '<')
|
|
|
|
op = COMPARE_OP_LESS;
|
|
|
|
else if (cur_api[j] == '>')
|
|
|
|
op = COMPARE_OP_GREATER;
|
|
|
|
}
|
|
|
|
|
|
|
|
state = STATE_API_VERSION;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case STATE_API_VERSION:
|
|
|
|
{
|
|
|
|
if (!found_minor && cur_api[j] >= '0' && cur_api[j] <= '9' && cur_api[j] != '.')
|
|
|
|
{
|
|
|
|
found_major = true;
|
|
|
|
|
|
|
|
if (major_str_pos < sizeof(major_str) - 1)
|
|
|
|
major_str[major_str_pos++] = cur_api[j];
|
|
|
|
}
|
|
|
|
else if (found_major && found_minor && cur_api[j] >= '0' && cur_api[j] <= '9')
|
|
|
|
{
|
|
|
|
if (minor_str_pos < sizeof(minor_str) - 1)
|
|
|
|
minor_str[minor_str_pos++] = cur_api[j];
|
|
|
|
}
|
|
|
|
else if (cur_api[j] == '.')
|
|
|
|
found_minor = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sscanf(major_str, "%d", &major);
|
|
|
|
sscanf(minor_str, "%d", &minor);
|
|
|
|
snprintf(version, sizeof(version), "%d.%d", major, minor);
|
|
|
|
#if 0
|
|
|
|
printf("Major: %d\n", major);
|
|
|
|
printf("Minor: %d\n", minor);
|
|
|
|
printf("API: %s\n", api_str);
|
|
|
|
printf("Version: %s\n", version);
|
|
|
|
fflush(stdout);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ((string_is_equal_noncase(api_str, "opengl") && sys_api == GFX_CTX_OPENGL_API) ||
|
|
|
|
(string_is_equal_noncase(api_str, "openglcompat") && sys_api == GFX_CTX_OPENGL_API) ||
|
|
|
|
(string_is_equal_noncase(api_str, "openglcompatibility") && sys_api == GFX_CTX_OPENGL_API))
|
|
|
|
{
|
2019-07-25 03:42:23 +00:00
|
|
|
/* system is running a core context while compat is requested */
|
|
|
|
if (sys_flags.flags & (1 << GFX_CTX_FLAGS_GL_CORE_CONTEXT))
|
2019-07-24 02:44:45 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
sscanf(sys_api_version_str, "%d.%d", &sys_api_version_major, &sys_api_version_minor);
|
|
|
|
|
|
|
|
if (core_info_compare_api_version(sys_api_version_major, sys_api_version_minor, major, minor, op))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (string_is_equal_noncase(api_str, "openglcore") && sys_api == GFX_CTX_OPENGL_API)
|
|
|
|
{
|
|
|
|
sscanf(sys_api_version_str, "%d.%d", &sys_api_version_major, &sys_api_version_minor);
|
|
|
|
|
|
|
|
if (core_info_compare_api_version(sys_api_version_major, sys_api_version_minor, major, minor, op))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (string_is_equal_noncase(api_str, "opengles") && sys_api == GFX_CTX_OPENGL_ES_API)
|
|
|
|
{
|
|
|
|
sscanf(sys_api_version_str, "OpenGL ES %d.%d", &sys_api_version_major, &sys_api_version_minor);
|
|
|
|
|
|
|
|
if (core_info_compare_api_version(sys_api_version_major, sys_api_version_minor, major, minor, op))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (string_is_equal_noncase(api_str, "direct3d8") && sys_api == GFX_CTX_DIRECT3D8_API)
|
|
|
|
{
|
|
|
|
sys_api_version_major = 8;
|
|
|
|
sys_api_version_minor = 0;
|
|
|
|
|
|
|
|
if (core_info_compare_api_version(sys_api_version_major, sys_api_version_minor, major, minor, op))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (string_is_equal_noncase(api_str, "direct3d9") && sys_api == GFX_CTX_DIRECT3D9_API)
|
|
|
|
{
|
|
|
|
sys_api_version_major = 9;
|
|
|
|
sys_api_version_minor = 0;
|
|
|
|
|
|
|
|
if (core_info_compare_api_version(sys_api_version_major, sys_api_version_minor, major, minor, op))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (string_is_equal_noncase(api_str, "direct3d10") && sys_api == GFX_CTX_DIRECT3D10_API)
|
|
|
|
{
|
|
|
|
sys_api_version_major = 10;
|
|
|
|
sys_api_version_minor = 0;
|
|
|
|
|
|
|
|
if (core_info_compare_api_version(sys_api_version_major, sys_api_version_minor, major, minor, op))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (string_is_equal_noncase(api_str, "direct3d11") && sys_api == GFX_CTX_DIRECT3D11_API)
|
|
|
|
{
|
|
|
|
sys_api_version_major = 11;
|
|
|
|
sys_api_version_minor = 0;
|
|
|
|
|
|
|
|
if (core_info_compare_api_version(sys_api_version_major, sys_api_version_minor, major, minor, op))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (string_is_equal_noncase(api_str, "direct3d12") && sys_api == GFX_CTX_DIRECT3D12_API)
|
|
|
|
{
|
|
|
|
sys_api_version_major = 12;
|
|
|
|
sys_api_version_minor = 0;
|
|
|
|
|
|
|
|
if (core_info_compare_api_version(sys_api_version_major, sys_api_version_minor, major, minor, op))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (string_is_equal_noncase(api_str, "vulkan") && sys_api == GFX_CTX_VULKAN_API)
|
|
|
|
{
|
|
|
|
sscanf(sys_api_version_str, "%d.%d", &sys_api_version_major, &sys_api_version_minor);
|
|
|
|
|
|
|
|
if (core_info_compare_api_version(sys_api_version_major, sys_api_version_minor, major, minor, op))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (string_is_equal_noncase(api_str, "metal") && sys_api == GFX_CTX_METAL_API)
|
|
|
|
{
|
|
|
|
sscanf(sys_api_version_str, "%d.%d", &sys_api_version_major, &sys_api_version_minor);
|
|
|
|
|
|
|
|
if (core_info_compare_api_version(sys_api_version_major, sys_api_version_minor, major, minor, op))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2019-07-29 20:30:53 +00:00
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
2019-07-24 02:44:45 +00:00
|
|
|
}
|