mirror of
https://github.com/libretro/RetroArch
synced 2025-01-31 15:32:59 +00:00
Revert "(task_database.c) Style nits"
This reverts commit 0f46d42c267cef80c634eef8f66dad68cc19e705.
This commit is contained in:
parent
24adcc8e68
commit
16ba94b531
@ -90,7 +90,7 @@ static int zlib_compare_crc32(const char *name, const char *valid_exts,
|
||||
static int database_info_iterate_start(database_info_handle_t *db,
|
||||
const char *name)
|
||||
{
|
||||
char msg[128];
|
||||
char msg[128] = {0};
|
||||
|
||||
#ifdef _WIN32
|
||||
snprintf(msg, sizeof(msg),
|
||||
@ -125,7 +125,7 @@ static int iso_get_serial(database_state_handle_t *db_state,
|
||||
database_info_handle_t *db, const char *name, char* serial)
|
||||
{
|
||||
int rv;
|
||||
int32_t offset = 0;
|
||||
int32_t offset = 0;
|
||||
const char* system_name = NULL;
|
||||
|
||||
if ((rv = detect_system(name, offset, &system_name)) < 0)
|
||||
@ -152,8 +152,7 @@ static int cue_get_serial(database_state_handle_t *db_state,
|
||||
{
|
||||
char track_path[PATH_MAX_LENGTH];
|
||||
int32_t offset = 0;
|
||||
int rv = find_first_data_track(
|
||||
name, &offset, track_path, PATH_MAX_LENGTH);
|
||||
int rv = find_first_data_track(name, &offset, track_path, PATH_MAX_LENGTH);
|
||||
|
||||
if (rv < 0)
|
||||
{
|
||||
@ -170,8 +169,8 @@ static int database_info_iterate_playlist(
|
||||
database_state_handle_t *db_state,
|
||||
database_info_handle_t *db, const char *name)
|
||||
{
|
||||
char parent_dir[PATH_MAX_LENGTH];
|
||||
uint32_t extension_hash = 0;
|
||||
char parent_dir[PATH_MAX_LENGTH] = {0};
|
||||
|
||||
path_parent_dir(parent_dir);
|
||||
|
||||
@ -202,23 +201,20 @@ static int database_info_iterate_playlist(
|
||||
default:
|
||||
{
|
||||
ssize_t ret;
|
||||
int read_from = retro_read_file(name, (void**)&db_state->buf, &ret);
|
||||
#ifdef HAVE_ZLIB
|
||||
const struct file_archive_file_backend *stream_backend =
|
||||
file_archive_get_default_file_backend();
|
||||
#endif
|
||||
if (
|
||||
retro_read_file(name, (void**)&db_state->buf, &ret) != 1)
|
||||
return 0;
|
||||
|
||||
if (ret <= 0)
|
||||
if (read_from != 1 || ret <= 0)
|
||||
return 0;
|
||||
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
db_state->crc =
|
||||
stream_backend->stream_crc_calculate(0, db_state->buf, ret);
|
||||
db_state->crc = stream_backend->stream_crc_calculate(0, db_state->buf, ret);
|
||||
#endif
|
||||
db->type = DATABASE_TYPE_CRC_LOOKUP;
|
||||
db->type = DATABASE_TYPE_CRC_LOOKUP;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -226,8 +222,7 @@ static int database_info_iterate_playlist(
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int database_info_list_iterate_end_no_match(
|
||||
database_state_handle_t *db_state)
|
||||
static int database_info_list_iterate_end_no_match(database_state_handle_t *db_state)
|
||||
{
|
||||
/* Reached end of database list, CRC match probably didn't succeed. */
|
||||
db_state->list_index = 0;
|
||||
@ -247,8 +242,7 @@ static int database_info_iterate_next(database_info_handle_t *db)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int database_info_list_iterate_new(
|
||||
database_state_handle_t *db_state, const char *query)
|
||||
static int database_info_list_iterate_new(database_state_handle_t *db_state, const char *query)
|
||||
{
|
||||
const char *new_database = db_state->list->elems[db_state->list_index].data;
|
||||
#if 0
|
||||
@ -267,10 +261,10 @@ static int database_info_list_iterate_found_match(
|
||||
const char *zip_name
|
||||
)
|
||||
{
|
||||
char db_crc[PATH_MAX_LENGTH];
|
||||
char db_playlist_path[PATH_MAX_LENGTH];
|
||||
char db_playlist_base_str[PATH_MAX_LENGTH];
|
||||
char entry_path_str[PATH_MAX_LENGTH];
|
||||
char db_crc[PATH_MAX_LENGTH] = {0};
|
||||
char db_playlist_path[PATH_MAX_LENGTH] = {0};
|
||||
char db_playlist_base_str[PATH_MAX_LENGTH] = {0};
|
||||
char entry_path_str[PATH_MAX_LENGTH] = {0};
|
||||
content_playlist_t *playlist = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *db_path = db_state->list->elems[db_state->list_index].data;
|
||||
@ -312,8 +306,7 @@ static int database_info_list_iterate_found_match(
|
||||
if(!content_playlist_entry_exists(playlist, entry_path_str, db_crc))
|
||||
{
|
||||
content_playlist_push(playlist, entry_path_str,
|
||||
db_info_entry->name, "DETECT", "DETECT",
|
||||
db_crc, db_playlist_base_str);
|
||||
db_info_entry->name, "DETECT", "DETECT", db_crc, db_playlist_base_str);
|
||||
}
|
||||
|
||||
content_playlist_write_file(playlist);
|
||||
@ -348,23 +341,20 @@ static int database_info_iterate_crc_lookup(
|
||||
const char *zip_entry)
|
||||
{
|
||||
|
||||
if (!db_state->list ||
|
||||
(unsigned)db_state->list_index == (unsigned)db_state->list->size)
|
||||
if (!db_state->list || (unsigned)db_state->list_index == (unsigned)db_state->list->size)
|
||||
return database_info_list_iterate_end_no_match(db_state);
|
||||
|
||||
if (db_state->entry_index == 0)
|
||||
{
|
||||
char query[50] = {0};
|
||||
snprintf(query, sizeof(query),
|
||||
"{crc: b\"%08X\"}", swap_if_big32(db_state->crc));
|
||||
snprintf(query, sizeof(query), "{crc: b\"%08X\"}", swap_if_big32(db_state->crc));
|
||||
|
||||
database_info_list_iterate_new(db_state, query);
|
||||
}
|
||||
|
||||
if (db_state->info)
|
||||
{
|
||||
database_info_t *db_info_entry =
|
||||
&db_state->info->list[db_state->entry_index];
|
||||
database_info_t *db_info_entry = &db_state->info->list[db_state->entry_index];
|
||||
|
||||
if (db_info_entry && db_info_entry->crc32)
|
||||
{
|
||||
@ -373,8 +363,7 @@ static int database_info_iterate_crc_lookup(
|
||||
db_state->crc, db_info_entry->crc32, db_info_entry->name);
|
||||
#endif
|
||||
if (db_state->crc == db_info_entry->crc32)
|
||||
return database_info_list_iterate_found_match(
|
||||
db_state, db, zip_entry);
|
||||
return database_info_list_iterate_found_match(db_state, db, zip_entry);
|
||||
}
|
||||
}
|
||||
|
||||
@ -402,16 +391,17 @@ static int database_info_iterate_playlist_zip(
|
||||
bool returnerr = true;
|
||||
#ifdef HAVE_ZLIB
|
||||
if (db_state->crc != 0)
|
||||
return database_info_iterate_crc_lookup(
|
||||
db_state, db, db_state->zip_name);
|
||||
return database_info_iterate_crc_lookup(db_state, db, db_state->zip_name);
|
||||
else
|
||||
{
|
||||
if (file_archive_parse_file_iterate(&db->state,
|
||||
&returnerr, name, NULL, zlib_compare_crc32,
|
||||
(void*)db_state) != 0)
|
||||
return 0;
|
||||
|
||||
if (file_archive_parse_file_iterate(&db->state,
|
||||
&returnerr, name, NULL, zlib_compare_crc32,
|
||||
(void*)db_state) != 0)
|
||||
return 0;
|
||||
|
||||
if (db_state->crc)
|
||||
file_archive_parse_file_iterate_stop(&db->state);
|
||||
if (db_state->crc)
|
||||
file_archive_parse_file_iterate_stop(&db->state);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@ -421,15 +411,13 @@ static int database_info_iterate_serial_lookup(
|
||||
database_state_handle_t *db_state,
|
||||
database_info_handle_t *db, const char *name)
|
||||
{
|
||||
if (!db_state->list ||
|
||||
(unsigned)db_state->list_index == (unsigned)db_state->list->size)
|
||||
if (!db_state->list || (unsigned)db_state->list_index == (unsigned)db_state->list->size)
|
||||
return database_info_list_iterate_end_no_match(db_state);
|
||||
|
||||
if (db_state->entry_index == 0)
|
||||
{
|
||||
char query[50];
|
||||
char *serial_buf =
|
||||
bin_to_hex_alloc((uint8_t*)db_state->serial, 10 * sizeof(uint8_t));
|
||||
char *serial_buf = bin_to_hex_alloc((uint8_t*)db_state->serial, 10 * sizeof(uint8_t));
|
||||
|
||||
if (!serial_buf)
|
||||
return 1;
|
||||
@ -442,8 +430,7 @@ static int database_info_iterate_serial_lookup(
|
||||
|
||||
if (db_state->info)
|
||||
{
|
||||
database_info_t *db_info_entry =
|
||||
&db_state->info->list[db_state->entry_index];
|
||||
database_info_t *db_info_entry = &db_state->info->list[db_state->entry_index];
|
||||
|
||||
if (db_info_entry && db_info_entry->serial)
|
||||
{
|
||||
@ -473,13 +460,9 @@ static int database_info_iterate_serial_lookup(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int database_info_iterate(database_state_handle_t *db_state,
|
||||
database_info_handle_t *db)
|
||||
static int database_info_iterate(database_state_handle_t *db_state, database_info_handle_t *db)
|
||||
{
|
||||
const char *name = NULL;
|
||||
|
||||
if (db)
|
||||
db = (database_info_handle_t*)db->list->elems[db->list_ptr].data;
|
||||
const char *name = db ? db->list->elems[db->list_ptr].data : NULL;
|
||||
|
||||
if (!db || !db->list)
|
||||
return -1;
|
||||
@ -489,6 +472,8 @@ static int database_info_iterate(database_state_handle_t *db_state,
|
||||
|
||||
switch (db->type)
|
||||
{
|
||||
case DATABASE_TYPE_NONE:
|
||||
break;
|
||||
case DATABASE_TYPE_ITERATE:
|
||||
return database_info_iterate_playlist(db_state, db, name);
|
||||
case DATABASE_TYPE_ITERATE_ZIP:
|
||||
@ -497,16 +482,11 @@ static int database_info_iterate(database_state_handle_t *db_state,
|
||||
return database_info_iterate_serial_lookup(db_state, db, name);
|
||||
case DATABASE_TYPE_CRC_LOOKUP:
|
||||
return database_info_iterate_crc_lookup(db_state, db, NULL);
|
||||
case DATABASE_TYPE_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rarch_main_data_db_cleanup_state(
|
||||
database_state_handle_t *db_state)
|
||||
static void rarch_main_data_db_cleanup_state(database_state_handle_t *db_state)
|
||||
{
|
||||
if (!db_state)
|
||||
return;
|
||||
@ -518,13 +498,10 @@ static void rarch_main_data_db_cleanup_state(
|
||||
|
||||
static void rarch_dbscan_task_handler(rarch_task_t *task)
|
||||
{
|
||||
db_handle_t *db = (db_handle_t*)task->state;
|
||||
db_handle_t *db = (db_handle_t*)task->state;
|
||||
database_info_handle_t *dbinfo = db->handle;
|
||||
database_state_handle_t *dbstate = &db->state;
|
||||
const char *name = NULL;
|
||||
|
||||
if (dbinfo)
|
||||
name = dbinfo->list->elems[dbinfo->list_ptr].data;
|
||||
const char *name = dbinfo ? dbinfo->list->elems[dbinfo->list_ptr].data : NULL;
|
||||
|
||||
if (!dbinfo || task->cancelled)
|
||||
goto task_finished;
|
||||
@ -533,8 +510,7 @@ static void rarch_dbscan_task_handler(rarch_task_t *task)
|
||||
{
|
||||
case DATABASE_STATUS_ITERATE_BEGIN:
|
||||
if (dbstate && !dbstate->list)
|
||||
dbstate->list = dir_list_new_special(
|
||||
NULL, DIR_LIST_DATABASES, NULL);
|
||||
dbstate->list = dir_list_new_special(NULL, DIR_LIST_DATABASES, NULL);
|
||||
dbinfo->status = DATABASE_STATUS_ITERATE_START;
|
||||
break;
|
||||
case DATABASE_STATUS_ITERATE_START:
|
||||
@ -587,8 +563,7 @@ task_finished:
|
||||
free(db);
|
||||
}
|
||||
|
||||
bool rarch_task_push_dbscan(const char *fullpath,
|
||||
bool directory, rarch_task_callback_t cb)
|
||||
bool rarch_task_push_dbscan(const char *fullpath, bool directory, rarch_task_callback_t cb)
|
||||
{
|
||||
rarch_task_t *t = (rarch_task_t*)calloc(1, sizeof(*t));
|
||||
db_handle_t *db = (db_handle_t*)calloc(1, sizeof(db_handle_t));
|
||||
|
Loading…
x
Reference in New Issue
Block a user