From c8dc0fef0ccccbc386629ed2de3627defc8ead86 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 20 Dec 2016 21:08:31 +0100 Subject: [PATCH] Cleanups - turn some functions into static functions and move to task_database.c --- database_info.c | 28 ---------------------------- database_info.h | 22 ---------------------- tasks/task_database.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 50 deletions(-) diff --git a/database_info.c b/database_info.c index 7a37531bc2..b2bde55049 100644 --- a/database_info.c +++ b/database_info.c @@ -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; -} diff --git a/database_info.h b/database_info.h index 7ec56de6a1..8f6ca65a85 100644 --- a/database_info.h +++ b/database_info.h @@ -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( diff --git a/tasks/task_database.c b/tasks/task_database.c index 1615f25569..446ebd81a7 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -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) {