1 /* RetroArch - A frontend for libretro. 2 * Copyright (C) 2010-2014 - Hans-Kristian Arntzen 3 * Copyright (C) 2011-2017 - Daniel De Matteis 4 * Copyright (C) 2016-2019 - Brad Parker 5 * 6 * RetroArch is free software: you can redistribute it and/or modify it under the terms 7 * of the GNU General Public License as published by the Free Software Found- 8 * ation, either version 3 of the License, or (at your option) any later version. 9 * 10 * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 * PURPOSE. See the GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License along with RetroArch. 15 * If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef CORE_INFO_H_ 19 #define CORE_INFO_H_ 20 21 #include <stddef.h> 22 23 #include <lists/string_list.h> 24 #include <retro_common_api.h> 25 26 RETRO_BEGIN_DECLS 27 28 enum core_info_list_qsort_type 29 { 30 CORE_INFO_LIST_SORT_PATH = 0, 31 CORE_INFO_LIST_SORT_DISPLAY_NAME, 32 CORE_INFO_LIST_SORT_CORE_NAME, 33 CORE_INFO_LIST_SORT_SYSTEM_NAME 34 }; 35 36 typedef struct 37 { 38 char *path; 39 char *desc; 40 /* Set missing once to avoid opening 41 * the same file several times. */ 42 bool missing; 43 bool optional; 44 } core_info_firmware_t; 45 46 /* Simple container/convenience struct for 47 * holding the 'id' of a core file 48 * > 'str' is the filename without extension or 49 * platform-specific suffix 50 * > 'hash' is a hash key used for efficient core 51 * list searches */ 52 typedef struct 53 { 54 char *str; 55 uint32_t hash; 56 } core_file_id_t; 57 58 typedef struct 59 { 60 char *path; 61 char *display_name; 62 char *display_version; 63 char *core_name; 64 char *system_manufacturer; 65 char *systemname; 66 char *system_id; 67 char *supported_extensions; 68 char *authors; 69 char *permissions; 70 char *licenses; 71 char *categories; 72 char *databases; 73 char *notes; 74 char *required_hw_api; 75 char *description; 76 struct string_list *categories_list; 77 struct string_list *databases_list; 78 struct string_list *note_list; 79 struct string_list *supported_extensions_list; 80 struct string_list *authors_list; 81 struct string_list *permissions_list; 82 struct string_list *licenses_list; 83 struct string_list *required_hw_api_list; 84 core_info_firmware_t *firmware; 85 core_file_id_t core_file_id; /* ptr alignment */ 86 size_t firmware_count; 87 bool has_info; 88 bool supports_no_game; 89 bool database_match_archive_member; 90 bool is_experimental; 91 bool is_locked; 92 bool is_installed; 93 } core_info_t; 94 95 /* A subset of core_info parameters required for 96 * core updater tasks */ 97 typedef struct 98 { 99 char *display_name; 100 char *description; 101 char *licenses; 102 bool is_experimental; 103 } core_updater_info_t; 104 105 typedef struct 106 { 107 core_info_t *list; 108 char *all_ext; 109 size_t count; 110 size_t info_count; 111 } core_info_list_t; 112 113 typedef struct core_info_ctx_firmware 114 { 115 const char *path; 116 struct 117 { 118 const char *system; 119 } directory; 120 } core_info_ctx_firmware_t; 121 122 struct core_info_state 123 { 124 #ifdef HAVE_COMPRESSION 125 const struct string_list *tmp_list; 126 #endif 127 const char *tmp_path; 128 core_info_t *current; 129 core_info_list_t *curr_list; 130 }; 131 132 typedef struct core_info_state core_info_state_t; 133 134 /* Non-reentrant, does not allocate. Returns pointer to internal state. */ 135 void core_info_list_get_supported_cores(core_info_list_t *list, 136 const char *path, const core_info_t **infos, size_t *num_infos); 137 138 bool core_info_list_get_display_name(core_info_list_t *list, 139 const char *core_path, char *s, size_t len); 140 141 /* Returns core_info parameters required for 142 * core updater tasks, read from specified file. 143 * Returned core_updater_info_t object must be 144 * freed using core_info_free_core_updater_info(). 145 * Returns NULL if 'path' is invalid. */ 146 core_updater_info_t *core_info_get_core_updater_info(const char *info_path); 147 void core_info_free_core_updater_info(core_updater_info_t *info); 148 149 core_info_t *core_info_get(core_info_list_t *list, size_t i); 150 151 void core_info_free_current_core(core_info_state_t *p_coreinfo); 152 153 bool core_info_init_current_core(void); 154 155 bool core_info_get_current_core(core_info_t **core); 156 157 void core_info_deinit_list(void); 158 159 bool core_info_init_list(const char *path_info, const char *dir_cores, 160 const char *exts, bool show_hidden_files, 161 bool enable_cache, bool *cache_supported); 162 163 bool core_info_get_list(core_info_list_t **core); 164 165 /* Returns number of installed cores */ 166 size_t core_info_count(void); 167 168 bool core_info_list_update_missing_firmware(core_info_ctx_firmware_t *info, 169 bool *set_missing_bios); 170 171 bool core_info_find(const char *core_path, 172 core_info_t **core_info); 173 174 bool core_info_load(const char *core_path, 175 core_info_state_t *p_coreinfo); 176 177 bool core_info_database_supports_content_path(const char *database_path, const char *path); 178 179 bool core_info_database_match_archive_member(const char *database_path); 180 181 void core_info_qsort(core_info_list_t *core_info_list, enum core_info_list_qsort_type qsort_type); 182 183 bool core_info_list_get_info(core_info_list_t *core_info_list, 184 core_info_t *out_info, const char *core_path); 185 186 bool core_info_hw_api_supported(core_info_t *info); 187 188 /* Sets 'locked' status of specified core 189 * > Returns true if successful 190 * > Like all functions that access the cached 191 * core info list this is *not* thread safe */ 192 bool core_info_set_core_lock(const char *core_path, bool lock); 193 /* Fetches 'locked' status of specified core 194 * > If 'validate_path' is 'true', will search 195 * cached core info list for a corresponding 196 * 'sanitised' core file path. This is *not* 197 * thread safe 198 * > If 'validate_path' is 'false', performs a 199 * direct filesystem check. This *is* thread 200 * safe, but validity of specified core path 201 * must be checked externally */ 202 bool core_info_get_core_lock(const char *core_path, bool validate_path); 203 204 core_info_state_t *coreinfo_get_ptr(void); 205 206 bool core_info_core_file_id_is_equal(const char *core_path_a, const char *core_path_b); 207 208 /* When called, generates a temporary file 209 * that will force an info cache refresh the 210 * next time that core info is initialised with 211 * caching enabled */ 212 bool core_info_cache_force_refresh(const char *path_info); 213 214 RETRO_END_DECLS 215 216 #endif /* CORE_INFO_H_ */ 217