From db8e786f85a821441166a237a76f576f11cf4bd0 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Wed, 28 Dec 2016 20:55:52 +0100 Subject: Lift ostc_get_data_descriptor out from ostctools.c This is for later reuse of that function in other source files. Signed-off-by: Anton Lundin Signed-off-by: Dirk Hohndel --- core/libdivecomputer.c | 29 +++++++++++++++++++++++++++++ core/libdivecomputer.h | 1 + core/ostctools.c | 29 ----------------------------- 3 files changed, 30 insertions(+), 29 deletions(-) (limited to 'core') diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c index 4a50acf90..89d9702ce 100644 --- a/core/libdivecomputer.c +++ b/core/libdivecomputer.c @@ -1135,3 +1135,32 @@ dc_status_t libdc_buffer_parser(struct dive *dive, device_data_t *data, unsigned dc_parser_destroy(parser); return(DC_STATUS_SUCCESS); } + +/* + * Returns a dc_descriptor_t structure based on dc model's number and family. + */ + +dc_descriptor_t *ostc_get_data_descriptor(int data_model, dc_family_t data_fam) +{ + dc_descriptor_t *descriptor = NULL, *current = NULL; + ; + dc_iterator_t *iterator = NULL; + dc_status_t rc; + + rc = dc_descriptor_iterator(&iterator); + if (rc != DC_STATUS_SUCCESS) { + fprintf(stderr, "Error creating the device descriptor iterator.\n"); + return current; + } + while ((dc_iterator_next(iterator, &descriptor)) == DC_STATUS_SUCCESS) { + int desc_model = dc_descriptor_get_model(descriptor); + dc_family_t desc_fam = dc_descriptor_get_type(descriptor); + if (data_model == desc_model && data_fam == desc_fam) { + current = descriptor; + break; + } + dc_descriptor_free(descriptor); + } + dc_iterator_free(iterator); + return current; +} diff --git a/core/libdivecomputer.h b/core/libdivecomputer.h index f2894b0c4..613ab702d 100644 --- a/core/libdivecomputer.h +++ b/core/libdivecomputer.h @@ -52,6 +52,7 @@ const char *do_libdivecomputer_import(device_data_t *data); const char *do_uemis_import(device_data_t *data); dc_status_t libdc_buffer_parser(struct dive *dive, device_data_t *data, unsigned char *buffer, int size); void logfunc(dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsigned int line, const char *function, const char *msg, void *userdata); +dc_descriptor_t *ostc_get_data_descriptor(int data_model, dc_family_t data_fam); extern int import_thread_cancelled; extern const char *progress_bar_text; diff --git a/core/ostctools.c b/core/ostctools.c index 9be591b0e..02e80fc16 100644 --- a/core/ostctools.c +++ b/core/ostctools.c @@ -7,35 +7,6 @@ #include "divelist.h" #include "libdivecomputer.h" -/* - * Returns a dc_descriptor_t structure based on dc model's number and family. - */ - -static dc_descriptor_t *ostc_get_data_descriptor(int data_model, dc_family_t data_fam) -{ - dc_descriptor_t *descriptor = NULL, *current = NULL; - ; - dc_iterator_t *iterator = NULL; - dc_status_t rc; - - rc = dc_descriptor_iterator(&iterator); - if (rc != DC_STATUS_SUCCESS) { - fprintf(stderr, "Error creating the device descriptor iterator.\n"); - return current; - } - while ((dc_iterator_next(iterator, &descriptor)) == DC_STATUS_SUCCESS) { - int desc_model = dc_descriptor_get_model(descriptor); - dc_family_t desc_fam = dc_descriptor_get_type(descriptor); - if (data_model == desc_model && data_fam == desc_fam) { - current = descriptor; - break; - } - dc_descriptor_free(descriptor); - } - dc_iterator_free(iterator); - return current; -} - /* * Fills a device_data_t structure with known dc data and a descriptor. */ -- cgit v1.2.3-70-g09d2