Add 'verify' example skeleton
This will become an example program to enroll a fingerprint and then verify a finger against it.
This commit is contained in:
parent
2c06a4ebfa
commit
f81aa47a19
5 changed files with 89 additions and 3 deletions
|
@ -1,2 +1,8 @@
|
|||
SUBDIRS = libfprint
|
||||
EXTRA_DIST = THANKS
|
||||
|
||||
SUBDIRS = libfprint
|
||||
|
||||
if BUILD_EXAMPLES
|
||||
SUBDIRS += examples
|
||||
endif
|
||||
|
||||
|
|
|
@ -4,4 +4,4 @@ aclocal || exit 1
|
|||
autoheader || exit 1
|
||||
autoconf || exit 1
|
||||
automake -a -c || exit 1
|
||||
./configure --enable-maintainer-mode $*
|
||||
./configure --enable-maintainer-mode --enable-examples-build $*
|
||||
|
|
|
@ -24,8 +24,15 @@ PKG_CHECK_MODULES(GLIB, "glib-2.0")
|
|||
AC_SUBST(GLIB_CFLAGS)
|
||||
AC_SUBST(GLIB_LIBS)
|
||||
|
||||
# Examples build
|
||||
AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build],
|
||||
[build example applications (default n)])],
|
||||
[build_examples=$enableval],
|
||||
[build_examples='no'])
|
||||
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
|
||||
|
||||
AC_DEFINE([API_EXPORTED], [__attribute__((visibility("default")))], [Default visibility])
|
||||
|
||||
AC_CONFIG_FILES([Makefile] [libfprint/Makefile])
|
||||
AC_CONFIG_FILES([Makefile] [libfprint/Makefile] [examples/Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
|
|
6
examples/Makefile.am
Normal file
6
examples/Makefile.am
Normal file
|
@ -0,0 +1,6 @@
|
|||
INCLUDES = -I$(top_srcdir)
|
||||
noinst_PROGRAMS = verify
|
||||
|
||||
verify_SOURCES = verify.c
|
||||
verify_LDADD = ../libfprint/libfprint.la -lfprint
|
||||
|
67
examples/verify.c
Normal file
67
examples/verify.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Example fingerprint verification program
|
||||
* Copyright (C) 2007 Daniel Drake <dsd@gentoo.org>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <libfprint/fprint.h>
|
||||
|
||||
struct fp_dscv_dev *discover_device(struct fp_dscv_dev **discovered_devs)
|
||||
{
|
||||
struct fp_dscv_dev *ddev = NULL;
|
||||
struct fp_dscv_dev *tmpdev;
|
||||
int i;
|
||||
|
||||
for (i = 0; tmpdev = discovered_devs[i]; i++) {
|
||||
const struct fp_driver *drv = fp_dscv_dev_get_driver(tmpdev);
|
||||
printf("Found device claimed by %s driver\n",
|
||||
fp_driver_get_full_name(drv));
|
||||
return ddev;
|
||||
}
|
||||
|
||||
return ddev;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
struct fp_dscv_dev *ddev;
|
||||
struct fp_dscv_dev **discovered_devs;
|
||||
|
||||
r = fp_init();
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "Failed to initialize libfprint\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
discovered_devs = fp_discover_devs();
|
||||
if (!discovered_devs) {
|
||||
fprintf(stderr, "Could not discover devices\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ddev = discover_device(discovered_devs);
|
||||
if (!ddev) {
|
||||
fprintf(stderr, "No devices detected.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fp_dscv_devs_free(discovered_devs);
|
||||
}
|
||||
|
Loading…
Reference in a new issue