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 DATABASE_INFO_H_ 19 #define DATABASE_INFO_H_ 20 21 #include <stdint.h> 22 #include <stddef.h> 23 24 #include <file/archive_file.h> 25 #include <retro_common_api.h> 26 #include <queues/task_queue.h> 27 28 RETRO_BEGIN_DECLS 29 30 enum database_status 31 { 32 DATABASE_STATUS_NONE = 0, 33 DATABASE_STATUS_ITERATE, 34 DATABASE_STATUS_ITERATE_BEGIN, 35 DATABASE_STATUS_ITERATE_START, 36 DATABASE_STATUS_ITERATE_NEXT, 37 DATABASE_STATUS_FREE 38 }; 39 40 enum database_type 41 { 42 DATABASE_TYPE_NONE = 0, 43 DATABASE_TYPE_ITERATE, 44 DATABASE_TYPE_ITERATE_ARCHIVE, 45 DATABASE_TYPE_ITERATE_LUTRO, 46 DATABASE_TYPE_SERIAL_LOOKUP, 47 DATABASE_TYPE_CRC_LOOKUP 48 }; 49 50 enum database_query_type 51 { 52 DATABASE_QUERY_NONE = 0, 53 DATABASE_QUERY_ENTRY, 54 DATABASE_QUERY_ENTRY_PUBLISHER, 55 DATABASE_QUERY_ENTRY_DEVELOPER, 56 DATABASE_QUERY_ENTRY_ORIGIN, 57 DATABASE_QUERY_ENTRY_FRANCHISE, 58 DATABASE_QUERY_ENTRY_RATING, 59 DATABASE_QUERY_ENTRY_BBFC_RATING, 60 DATABASE_QUERY_ENTRY_ELSPA_RATING, 61 DATABASE_QUERY_ENTRY_ESRB_RATING, 62 DATABASE_QUERY_ENTRY_PEGI_RATING, 63 DATABASE_QUERY_ENTRY_CERO_RATING, 64 DATABASE_QUERY_ENTRY_ENHANCEMENT_HW, 65 DATABASE_QUERY_ENTRY_EDGE_MAGAZINE_RATING, 66 DATABASE_QUERY_ENTRY_EDGE_MAGAZINE_ISSUE, 67 DATABASE_QUERY_ENTRY_FAMITSU_MAGAZINE_RATING, 68 DATABASE_QUERY_ENTRY_RELEASEDATE_MONTH, 69 DATABASE_QUERY_ENTRY_RELEASEDATE_YEAR, 70 DATABASE_QUERY_ENTRY_MAX_USERS 71 }; 72 73 typedef struct 74 { 75 struct string_list *list; 76 size_t list_ptr; 77 enum database_status status; 78 enum database_type type; 79 } database_info_handle_t; 80 81 typedef struct 82 { 83 char *name; 84 char *rom_name; 85 char *serial; 86 char *description; 87 char *genre; 88 char *publisher; 89 struct string_list *developer; 90 char *origin; 91 char *franchise; 92 char *edge_magazine_review; 93 char *bbfc_rating; 94 char *elspa_rating; 95 char *esrb_rating; 96 char *pegi_rating; 97 char *cero_rating; 98 char *enhancement_hw; 99 char *sha1; 100 char *md5; 101 void *userdata; 102 int analog_supported; 103 int rumble_supported; 104 int coop_supported; 105 uint32_t crc32; 106 unsigned size; 107 unsigned famitsu_magazine_rating; 108 unsigned edge_magazine_rating; 109 unsigned edge_magazine_issue; 110 unsigned max_users; 111 unsigned releasemonth; 112 unsigned releaseyear; 113 unsigned tgdb_rating; 114 } database_info_t; 115 116 typedef struct 117 { 118 database_info_t *list; 119 size_t count; 120 } database_info_list_t; 121 122 database_info_list_t *database_info_list_new(const char *rdb_path, 123 const char *query); 124 125 void database_info_list_free(database_info_list_t *list); 126 127 database_info_handle_t *database_info_dir_init(const char *dir, 128 enum database_type type, retro_task_t *task, 129 bool show_hidden_files); 130 131 database_info_handle_t *database_info_file_init(const char *path, 132 enum database_type type, retro_task_t *task); 133 134 void database_info_free(database_info_handle_t *handle); 135 136 int database_info_build_query_enum( 137 char *query, size_t len, enum database_query_type type, const char *path); 138 139 /* NOTE: Allocates memory, it is the caller's responsibility to free the 140 * memory after it is no longer required. */ 141 char *bin_to_hex_alloc(const uint8_t *data, size_t len); 142 143 RETRO_END_DECLS 144 145 #endif /* CORE_INFO_H_ */ 146