Rename ostc_get_data_descriptor to get_descriptor

This renames and cleans up ostc_get_data_descriptor into get_descriptor,
for more generic use.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Anton Lundin 2016-12-28 20:55:53 +01:00 committed by Dirk Hohndel
parent db8e786f85
commit 00629c861c
3 changed files with 13 additions and 13 deletions

View file

@ -1137,30 +1137,30 @@ dc_status_t libdc_buffer_parser(struct dive *dive, device_data_t *data, unsigned
}
/*
* Returns a dc_descriptor_t structure based on dc model's number and family.
* Returns a dc_descriptor_t structure based on dc model's number and family.
*
* That dc_descriptor_t needs to be freed with dc_descriptor_free by the reciver.
*/
dc_descriptor_t *ostc_get_data_descriptor(int data_model, dc_family_t data_fam)
dc_descriptor_t *get_descriptor(dc_family_t type, unsigned int model)
{
dc_descriptor_t *descriptor = NULL, *current = NULL;
;
dc_descriptor_t *descriptor = NULL, *needle = 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;
return NULL;
}
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;
unsigned int desc_model = dc_descriptor_get_model(descriptor);
dc_family_t desc_type = dc_descriptor_get_type(descriptor);
if (model == desc_model && type == desc_type) {
needle = descriptor;
break;
}
dc_descriptor_free(descriptor);
}
dc_iterator_free(iterator);
return current;
return needle;
}

View file

@ -52,7 +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);
dc_descriptor_t *get_descriptor(dc_family_t type, unsigned int model);
extern int import_thread_cancelled;
extern const char *progress_bar_text;

View file

@ -17,7 +17,7 @@ static int ostc_prepare_data(int data_model, dc_family_t dc_fam, device_data_t *
dev_data->device = NULL;
dev_data->context = NULL;
data_descriptor = ostc_get_data_descriptor(data_model, dc_fam);
data_descriptor = get_descriptor(data_model, dc_fam);
if (data_descriptor) {
dev_data->descriptor = data_descriptor;
dev_data->vendor = copy_string(data_descriptor->vendor);