From ca06fae22e71a811a197edc69fab78348a8ff063 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 27 Sep 2018 16:36:09 +0200 Subject: [PATCH] lib: Split off fpi_print_data helpers And rename data.c to fpi-data.c --- libfprint/drivers_api.h | 24 +----------------- libfprint/fp_internal.h | 33 +----------------------- libfprint/{data.c => fpi-data.c} | 13 ++++++++++ libfprint/fpi-data.h | 43 ++++++++++++++++++++++++++++++++ libfprint/meson.build | 3 ++- 5 files changed, 60 insertions(+), 56 deletions(-) rename libfprint/{data.c => fpi-data.c} (98%) create mode 100644 libfprint/fpi-data.h diff --git a/libfprint/drivers_api.h b/libfprint/drivers_api.h index a567c3c..b61aa14 100644 --- a/libfprint/drivers_api.h +++ b/libfprint/drivers_api.h @@ -34,6 +34,7 @@ #include "fpi-poll.h" #include "fpi-dev.h" #include "fpi-usb.h" +#include "fpi-data.h" #include "assembling.h" #include "drivers/driver_ids.h" @@ -124,29 +125,6 @@ struct fp_img_driver { void (*deactivate)(struct fp_img_dev *dev); }; -enum fp_print_data_type { - PRINT_DATA_RAW = 0, /* memset-imposed default */ - PRINT_DATA_NBIS_MINUTIAE, -}; - -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); -gboolean fpi_print_data_compatible(uint16_t driver_id1, uint32_t devtype1, - enum fp_print_data_type type1, uint16_t driver_id2, uint32_t devtype2, - enum fp_print_data_type type2); - struct fp_minutiae; /* bit values for fp_img.flags */ diff --git a/libfprint/fp_internal.h b/libfprint/fp_internal.h index 7044a62..ab24df8 100644 --- a/libfprint/fp_internal.h +++ b/libfprint/fp_internal.h @@ -30,6 +30,7 @@ #include "fprint.h" #include "fpi-log.h" #include "fpi-dev.h" +#include "fpi-data.h" #include "drivers/driver_ids.h" #define container_of(ptr, type, member) ({ \ @@ -237,39 +238,7 @@ struct fp_dscv_print { char *path; }; -enum fp_print_data_type { - PRINT_DATA_RAW = 0, /* memset-imposed default */ - PRINT_DATA_NBIS_MINUTIAE, -}; - -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 fpi_print_data_fp2 { - char prefix[3]; - uint16_t driver_id; - uint32_t devtype; - unsigned char data_type; - unsigned char data[0]; -} __attribute__((__packed__)); - -struct fpi_print_data_item_fp2 { - uint32_t length; - unsigned char data[0]; -} __attribute__((__packed__)); - void fpi_data_exit(void); -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); gboolean fpi_print_data_compatible(uint16_t driver_id1, uint32_t devtype1, enum fp_print_data_type type1, uint16_t driver_id2, uint32_t devtype2, enum fp_print_data_type type2); diff --git a/libfprint/data.c b/libfprint/fpi-data.c similarity index 98% rename from libfprint/data.c rename to libfprint/fpi-data.c index 62a5fea..c2974a1 100644 --- a/libfprint/data.c +++ b/libfprint/fpi-data.c @@ -32,6 +32,19 @@ #define DIR_PERMS 0700 +struct fpi_print_data_fp2 { + char prefix[3]; + uint16_t driver_id; + uint32_t devtype; + unsigned char data_type; + unsigned char data[0]; +} __attribute__((__packed__)); + +struct fpi_print_data_item_fp2 { + uint32_t length; + unsigned char data[0]; +} __attribute__((__packed__)); + /** * SECTION: print_data * @title: Stored prints diff --git a/libfprint/fpi-data.h b/libfprint/fpi-data.h new file mode 100644 index 0000000..3ea27dd --- /dev/null +++ b/libfprint/fpi-data.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2007-2008 Daniel Drake + * Copyright (C) 2018 Bastien Nocera + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#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_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); + +#endif diff --git a/libfprint/meson.build b/libfprint/meson.build index c4c32e0..1d9079e 100644 --- a/libfprint/meson.build +++ b/libfprint/meson.build @@ -3,7 +3,8 @@ libfprint_sources = [ 'drivers_api.h', 'async.c', 'core.c', - 'data.c', + 'fpi-data.c', + 'fpi-data.h', 'fpi-dev.c', 'fpi-dev.h', 'fpi-log.h',