Create database_info_build_query, move it to database_info.c

This commit is contained in:
twinaphex 2015-05-24 19:36:28 +02:00
parent 3c6dd65208
commit fd8c202edd
6 changed files with 79 additions and 79 deletions

View File

@ -29,6 +29,80 @@
#include "config.h"
#endif
int database_info_build_query(
char *query, size_t len, const char *label, const char *path)
{
bool add_quotes = true;
strlcpy(query, "{'", len);
if (!strcmp(label, "displaylist_parse_database_entry"))
strlcat(query, "name", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_publisher"))
strlcat(query, "publisher", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_developer"))
strlcat(query, "developer", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_origin"))
strlcat(query, "origin", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_franchise"))
strlcat(query, "franchise", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_esrb_rating"))
strlcat(query, "esrb_rating", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_bbfc_rating"))
strlcat(query, "bbfc_rating", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_elspa_rating"))
strlcat(query, "elspa_rating", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_pegi_rating"))
strlcat(query, "pegi_rating", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_enhancement_hw"))
strlcat(query, "enhancement_hw", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_cero_rating"))
strlcat(query, "cero_rating", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_edge_magazine_rating"))
{
strlcat(query, "edge_rating", len);
add_quotes = false;
}
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_edge_magazine_issue"))
{
strlcat(query, "edge_issue", len);
add_quotes = false;
}
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_famitsu_magazine_rating"))
{
strlcat(query, "famitsu_rating", len);
add_quotes = false;
}
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_releasemonth"))
{
strlcat(query, "releasemonth", len);
add_quotes = false;
}
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_releaseyear"))
{
strlcat(query, "releaseyear", len);
add_quotes = false;
}
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_max_users"))
{
strlcat(query, "users", len);
add_quotes = false;
}
strlcat(query, "':", len);
if (add_quotes)
strlcat(query, "\"", len);
strlcat(query, path, len);
if (add_quotes)
strlcat(query, "\"", len);
strlcat(query, "}", len);
#if 0
RARCH_LOG("query: %s\n", query);
#endif
return 0;
}
int database_open_cursor(libretrodb_t *db,
libretrodb_cursor_t *cur, const char *query)
{

View File

@ -99,6 +99,9 @@ database_info_handle_t *database_info_init(const char *dir,
void database_info_free(database_info_handle_t *dbl);
int database_info_build_query(
char *query, size_t len, const char *label, const char *path);
#ifdef __cplusplus
}
#endif

View File

@ -19,80 +19,6 @@
#include "../playlist.h"
#include <string.h>
int menu_database_build_query(
char *query, size_t len, const char *label, const char *path)
{
bool add_quotes = true;
strlcpy(query, "{'", len);
if (!strcmp(label, "displaylist_parse_database_entry"))
strlcat(query, "name", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_publisher"))
strlcat(query, "publisher", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_developer"))
strlcat(query, "developer", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_origin"))
strlcat(query, "origin", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_franchise"))
strlcat(query, "franchise", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_esrb_rating"))
strlcat(query, "esrb_rating", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_bbfc_rating"))
strlcat(query, "bbfc_rating", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_elspa_rating"))
strlcat(query, "elspa_rating", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_pegi_rating"))
strlcat(query, "pegi_rating", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_enhancement_hw"))
strlcat(query, "enhancement_hw", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_cero_rating"))
strlcat(query, "cero_rating", len);
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_edge_magazine_rating"))
{
strlcat(query, "edge_rating", len);
add_quotes = false;
}
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_edge_magazine_issue"))
{
strlcat(query, "edge_issue", len);
add_quotes = false;
}
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_famitsu_magazine_rating"))
{
strlcat(query, "famitsu_rating", len);
add_quotes = false;
}
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_releasemonth"))
{
strlcat(query, "releasemonth", len);
add_quotes = false;
}
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_releaseyear"))
{
strlcat(query, "releaseyear", len);
add_quotes = false;
}
else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_max_users"))
{
strlcat(query, "users", len);
add_quotes = false;
}
strlcat(query, "':", len);
if (add_quotes)
strlcat(query, "\"", len);
strlcat(query, path, len);
if (add_quotes)
strlcat(query, "\"", len);
strlcat(query, "}", len);
#if 0
RARCH_LOG("query: %s\n", query);
#endif
return 0;
}
static void menu_database_playlist_free(menu_handle_t *menu)
{
if (menu->db_playlist)

View File

@ -31,9 +31,6 @@ extern "C" {
/* HACK */
extern unsigned int rdb_entry_start_game_selection_ptr;
int menu_database_build_query(
char *query, size_t len, const char *label, const char *path);
void menu_database_free(void *data);
bool menu_database_realloc(const char *path,

View File

@ -910,7 +910,7 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
if (!menu)
return -1;
menu_database_build_query(query, sizeof(query), "displaylist_parse_database_entry", info->path_b);
database_info_build_query(query, sizeof(query), "displaylist_parse_database_entry", info->path_b);
if (!(db_info = database_info_list_new(info->path, query)))
return -1;

View File

@ -112,7 +112,7 @@ static int deferred_push_cursor_manager_list_deferred_query_subsearch(menu_displ
char query[PATH_MAX_LENGTH];
struct string_list *str_list = string_split(info->path, "|");
menu_database_build_query(query, sizeof(query), info->label, str_list->elems[0].data);
database_info_build_query(query, sizeof(query), info->label, str_list->elems[0].data);
if (query[0] == '\0')
{