Cleanups - turn some functions into static functions and move

to task_database.c
This commit is contained in:
twinaphex 2016-12-20 21:08:31 +01:00
parent 88f915dadd
commit c8dc0fef0c
3 changed files with 41 additions and 50 deletions

View File

@ -659,31 +659,3 @@ void database_info_list_free(database_info_list_t *database_info_list)
free(database_info_list->list);
}
void database_info_set_type(database_info_handle_t *handle, enum database_type type)
{
if (!handle)
return;
handle->type = type;
}
enum database_type database_info_get_type(database_info_handle_t *handle)
{
if (!handle)
return DATABASE_TYPE_NONE;
return handle->type;
}
const char *database_info_get_current_name(database_state_handle_t *handle)
{
if (!handle || !handle->list)
return NULL;
return handle->list->elems[handle->list_index].data;
}
const char *database_info_get_current_element_name(database_info_handle_t *handle)
{
if (!handle || !handle->list)
return NULL;
return handle->list->elems[handle->list_ptr].data;
}

View File

@ -47,7 +47,6 @@ enum database_type
DATABASE_TYPE_CRC_LOOKUP
};
typedef struct
{
enum database_status status;
@ -98,19 +97,6 @@ typedef struct
size_t count;
} database_info_list_t;
typedef struct database_state_handle
{
database_info_list_t *info;
struct string_list *list;
size_t list_index;
size_t entry_index;
uint32_t crc;
uint32_t archive_crc;
uint8_t *buf;
char archive_name[255];
char serial[4096];
} database_state_handle_t;
database_info_list_t *database_info_list_new(const char *rdb_path,
const char *query);
@ -122,14 +108,6 @@ database_info_handle_t *database_info_dir_init(const char *dir,
database_info_handle_t *database_info_file_init(const char *path,
enum database_type type);
void database_info_set_type(database_info_handle_t *handle, enum database_type type);
const char *database_info_get_current_element_name(database_info_handle_t *handle);
const char *database_info_get_current_name(database_state_handle_t *handle);
enum database_type database_info_get_type(database_info_handle_t *handle);
void database_info_free(database_info_handle_t *handle);
int database_info_build_query(

View File

@ -42,6 +42,19 @@
#define COLLECTION_SIZE 99999
#endif
typedef struct database_state_handle
{
database_info_list_t *info;
struct string_list *list;
size_t list_index;
size_t entry_index;
uint32_t crc;
uint32_t archive_crc;
uint8_t *buf;
char archive_name[255];
char serial[4096];
} database_state_handle_t;
typedef struct db_handle
{
database_state_handle_t state;
@ -50,6 +63,34 @@ typedef struct db_handle
unsigned status;
} db_handle_t;
static void database_info_set_type(database_info_handle_t *handle, enum database_type type)
{
if (!handle)
return;
handle->type = type;
}
static enum database_type database_info_get_type(database_info_handle_t *handle)
{
if (!handle)
return DATABASE_TYPE_NONE;
return handle->type;
}
static const char *database_info_get_current_name(database_state_handle_t *handle)
{
if (!handle || !handle->list)
return NULL;
return handle->list->elems[handle->list_index].data;
}
static const char *database_info_get_current_element_name(database_info_handle_t *handle)
{
if (!handle || !handle->list)
return NULL;
return handle->list->elems[handle->list_ptr].data;
}
static int task_database_iterate_start(database_info_handle_t *db,
const char *name)
{