Move database_cursor_iterate to database_info.c

This commit is contained in:
twinaphex 2015-05-24 20:19:34 +02:00
parent 1f4c04de6a
commit 47a2c1f3c3
3 changed files with 31 additions and 31 deletions

View File

@ -103,6 +103,35 @@ int database_info_build_query(
return 0;
}
int database_cursor_iterate(libretrodb_cursor_t *cur, char *s, size_t len)
{
unsigned i;
struct rmsgpack_dom_value item;
if (libretrodb_cursor_read_item(cur, &item) != 0)
return -1;
if (item.type != RDT_MAP)
return 1;
for (i = 0; i < item.map.len; i++)
{
struct rmsgpack_dom_value *key = &item.map.items[i].key;
struct rmsgpack_dom_value *val = &item.map.items[i].value;
if (!key || !val)
continue;
if (!strcmp(key->string.buff, "name"))
{
strlcpy(s, val->string.buff, len);
return 0;
}
}
return 1;
}
int database_open_cursor(libretrodb_t *db,
libretrodb_cursor_t *cur, const char *query)
{

View File

@ -94,6 +94,8 @@ void database_info_list_free(database_info_list_t *list);
int database_open_cursor(libretrodb_t *db,
libretrodb_cursor_t *cur, const char *query);
int database_cursor_iterate(libretrodb_cursor_t *cur, char *s, size_t len);
database_info_handle_t *database_info_init(const char *dir,
enum database_type type);

View File

@ -1145,37 +1145,6 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
return 0;
}
#ifdef HAVE_LIBRETRODB
static int database_cursor_iterate(libretrodb_cursor_t *cur, char *s, size_t len)
{
unsigned i;
struct rmsgpack_dom_value item;
if (libretrodb_cursor_read_item(cur, &item) != 0)
return -1;
if (item.type != RDT_MAP)
return 1;
for (i = 0; i < item.map.len; i++)
{
struct rmsgpack_dom_value *key = &item.map.items[i].key;
struct rmsgpack_dom_value *val = &item.map.items[i].value;
if (!key || !val)
continue;
if (!strcmp(key->string.buff, "name"))
{
strlcpy(s, val->string.buff, len);
return 0;
}
}
return 1;
}
#endif
static int menu_database_parse_query(file_list_t *list, const char *path,
const char *query)
{