From 61483a4c472a27d3c5f8035463166517b6cd2911 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 29 Nov 2018 14:05:25 +0100 Subject: [PATCH] lib: Make the fp_print_data structure private And add a couple of helpers for the upekts driver to use. --- doc/libfprint-sections.txt | 1 - libfprint/drivers/upekts.c | 4 ++-- libfprint/fp_internal.h | 13 +++++++++++++ libfprint/fpi-data.c | 13 +++++++++++++ libfprint/fpi-data.h | 15 +++------------ 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/doc/libfprint-sections.txt b/doc/libfprint-sections.txt index fccea60..715ea5a 100644 --- a/doc/libfprint-sections.txt +++ b/doc/libfprint-sections.txt @@ -281,7 +281,6 @@ fpi_assemble_lines
fpi-data.h fpi-data -fp_print_data_type fp_print_data_item fpi_print_data_new diff --git a/libfprint/drivers/upekts.c b/libfprint/drivers/upekts.c index b930863..476ef34 100644 --- a/libfprint/drivers/upekts.c +++ b/libfprint/drivers/upekts.c @@ -1042,7 +1042,7 @@ static void e_handle_resp02(struct fp_dev *dev, unsigned char *data, item = fpi_print_data_item_new(data_len - sizeof(scan_comp)); memcpy(item->data, data + sizeof(scan_comp), data_len - sizeof(scan_comp)); - fdata->prints = g_slist_prepend(fdata->prints, item); + fpi_print_data_add_item(fdata, item); result = FP_ENROLL_COMPLETE; } @@ -1204,7 +1204,7 @@ static void verify_start_sm_run_state(fpi_ssm *ssm, struct fp_dev *dev, void *us break; case VERIFY_INIT: ; struct fp_print_data *print = fpi_dev_get_verify_data(dev); - struct fp_print_data_item *item = print->prints->data; + struct fp_print_data_item *item = fpi_print_data_get_item(print); size_t data_len = sizeof(verify_hdr) + item->length; unsigned char *data = g_malloc(data_len); struct libusb_transfer *transfer; diff --git a/libfprint/fp_internal.h b/libfprint/fp_internal.h index f3bd9ed..5a69e51 100644 --- a/libfprint/fp_internal.h +++ b/libfprint/fp_internal.h @@ -39,6 +39,19 @@ extern libusb_context *fpi_usb_ctx; extern GSList *opened_devices; +/* fp_print_data structure definition */ +enum fp_print_data_type { + PRINT_DATA_RAW = 0, /* memset-imposed default */ + PRINT_DATA_NBIS_MINUTIAE +}; + +struct fp_print_data { + uint16_t driver_id; + uint32_t devtype; + enum fp_print_data_type type; + GSList *prints; +}; + /* fp_dev structure definition */ enum fp_dev_state { DEV_STATE_INITIAL = 0, diff --git a/libfprint/fpi-data.c b/libfprint/fpi-data.c index 7f5f2d7..0465b72 100644 --- a/libfprint/fpi-data.c +++ b/libfprint/fpi-data.c @@ -149,6 +149,19 @@ struct fp_print_data *fpi_print_data_new(struct fp_dev *dev) fpi_driver_get_data_type(dev->drv)); } +struct fp_print_data_item * +fpi_print_data_get_item(struct fp_print_data *data) +{ + return data->prints->data; +} + +void +fpi_print_data_add_item(struct fp_print_data *data, + struct fp_print_data_item *item) +{ + data->prints = g_slist_prepend(data->prints, item); +} + /** * fp_print_data_get_data: * @data: the stored print diff --git a/libfprint/fpi-data.h b/libfprint/fpi-data.h index 3ea27dd..37a7911 100644 --- a/libfprint/fpi-data.h +++ b/libfprint/fpi-data.h @@ -20,24 +20,15 @@ #ifndef __FPI_DATA_H__ #define __FPI_DATA_H__ -enum fp_print_data_type { - PRINT_DATA_RAW = 0, /* memset-imposed default */ - PRINT_DATA_NBIS_MINUTIAE -}; - +struct fp_print_data; struct fp_print_data_item { size_t length; unsigned char data[0]; }; -struct fp_print_data { - uint16_t driver_id; - uint32_t devtype; - enum fp_print_data_type type; - GSList *prints; -}; - struct fp_print_data *fpi_print_data_new(struct fp_dev *dev); struct fp_print_data_item *fpi_print_data_item_new(size_t length); +struct fp_print_data_item *fpi_print_data_get_item(struct fp_print_data *data); +void fpi_print_data_add_item(struct fp_print_data *data, struct fp_print_data_item *item); #endif