Commit b69cb4a7 authored by Daniel Drake's avatar Daniel Drake

Initial commit

parents
Makefile.in
Makefile
aclocal.m4
compile
autom4te.cache
configure
depcomp
install-sh
missing
config.log
config.status
.deps
client-bindings.h
server-bindings.h
demo
*.o
fprintd
Daniel Drake <dsd@gentoo.org>
This diff is collapsed.
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
2006, 2007 Free Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
Briefly, the shell commands `./configure; make; make install' should
configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
6. Often, you can also type `make uninstall' to remove the installed
files again.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that the
`configure' script does not know about. Run `./configure --help' for
details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
With a non-GNU `make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out automatically,
but needs to determine by the type of machine the package will run on.
Usually, assuming the package is built to be run on the _same_
architectures, `configure' can figure that out, but if it prints a
message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share, you
can create a site shell script called `config.site' that gives default
values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf bug. Until the bug is fixed you can use this workaround:
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
`configure' recognizes the following options to control how it operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.
AUTOMAKE_OPTIONS = dist-bzip2
SUBDIRS = src examples
EXTRA_DIST = TODO
This file lists notable changes in each release. For the full history of all
changes, see ChangeLog.
fprintd
=======
http://www.reactivated.net/fprint/wiki/Fprintd
Daemon to offer libfprint functionality over D-Bus
Currently in early stages. Might eat your kangaroo.
Written in C. Requires bleeding edge libfprint (libusb-1.0 port).
Licensed under the GPL version 2 (see COPYING).
Enrollment
Identification
Image transfer
Imaging
Automatically ReleaseDevice when application disconnects from bus
Rethink print handling - we discover on ListEnrolled and rediscover on each LoadPrintData
Enforce command sequences:
force VerifyStop after non-retry verify result comes in
only allow GetVerifyResult during a verification
only allow VerifyStop during a verification
etc
dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
dnl
dnl example
dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
AC_DEFUN([AS_AC_EXPAND],
[
EXP_VAR=[$1]
FROM_VAR=[$2]
dnl first expand prefix and exec_prefix if necessary
prefix_save=$prefix
exec_prefix_save=$exec_prefix
dnl if no prefix given, then use /usr/local, the default prefix
if test "x$prefix" = "xNONE"; then
prefix=$ac_default_prefix
fi
dnl if no exec_prefix given, then use prefix
if test "x$exec_prefix" = "xNONE"; then
exec_prefix=$prefix
fi
full_var="$FROM_VAR"
dnl loop until it doesn't change anymore
while true; do
new_full_var="`eval echo $full_var`"
if test "x$new_full_var"="x$full_var"; then break; fi
full_var=$new_full_var
done
dnl clean up
full_var=$new_full_var
AC_SUBST([$1], "$full_var")
dnl restore prefix and exec_prefix
prefix=$prefix_save
exec_prefix=$exec_prefix_save
])
#!/bin/sh
aclocal || exit 1
autoconf || exit 1
automake -a -c || exit 1
./configure --enable-maintainer-mode $*
AC_INIT([fprintd], [0.1])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/main.c])
AC_PREREQ([2.50])
AC_PROG_CC
AM_PROG_CC_C_O
PKG_CHECK_MODULES(FPRINT, "libfprint")
AC_SUBST(FPRINT_LIBS)
AC_SUBST(FPRINT_CFLAGS)
PKG_CHECK_MODULES(GLIB, "glib-2.0")
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
PKG_CHECK_MODULES(DBUS_GLIB, "dbus-glib-1")
AC_SUBST(DBUS_GLIB_LIBS)
AC_SUBST(DBUS_GLIB_CFLAGS)
AS_AC_EXPAND(DATADIR, $datadir)
DBUS_SERVICES_DIR="$DATADIR/dbus-1/services"
AC_SUBST(DBUS_SERVICES_DIR)
AC_DEFINE_UNQUOTED(DBUS_SERVICES_DIR, "$DBUS_SERVICES_DIR", [Where services dir for DBUS is])
# Restore gnu89 inline semantics on gcc 4.3 and newer
saved_cflags="$CFLAGS"
CFLAGS="$CFLAGS -fgnu89-inline"
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), inline_cflags="-fgnu89-inline", inline_cflags="")
CFLAGS="$saved_cflags"
AM_CFLAGS="-std=gnu99 $inline_cflags -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration -Wno-pointer-sign -Wshadow"
AC_SUBST(AM_CFLAGS)
AC_CONFIG_FILES([Makefile] [src/Makefile] [examples/Makefile])
AC_OUTPUT
BUILT_SOURCES = client-bindings.h
noinst_HEADERS = $(BUILT_SOURCES)
CLEANFILES = $(BUILT_SOURCES)
bin_PROGRAMS = demo
demo_SOURCES = demo.c
demo_CFLAGS = $(AM_CFLAGS) $(DBUS_GLIB_CFLAGS)
demo_LDADD = $(DBUS_GLIB_LIBS)
client-bindings.h: ../src/fprintd.xml
dbus-binding-tool --prefix=fprint --mode=glib-client $< --output=$@
/*
* fprintd example to verify a fingerprint
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdlib.h>
#include <dbus/dbus-glib-bindings.h>
#include "client-bindings.h"
static DBusGProxy *proxy = NULL;
static DBusGConnection *connection = NULL;
enum fp_verify_result {
VERIFY_NO_MATCH = 0,
VERIFY_MATCH = 1,
VERIFY_RETRY = 100,
VERIFY_RETRY_TOO_SHORT = 101,
VERIFY_RETRY_CENTER_FINGER = 102,
VERIFY_RETRY_REMOVE_FINGER = 103,
};
static const char *verify_result_str(int result)
{
switch (result) {
case VERIFY_NO_MATCH:
return "No match";
case VERIFY_MATCH:
return "Match!";
case VERIFY_RETRY:
return "Retry scan";
case VERIFY_RETRY_TOO_SHORT:
return "Swipe too short, please retry";
case VERIFY_RETRY_CENTER_FINGER:
return "Finger not centered, please retry";
case VERIFY_RETRY_REMOVE_FINGER:
return "Please remove finger and retry";
default:
return "Unknown";
}
}
enum fp_finger {
LEFT_THUMB = 1, /** thumb (left hand) */
LEFT_INDEX, /** index finger (left hand) */
LEFT_MIDDLE, /** middle finger (left hand) */
LEFT_RING, /** ring finger (left hand) */
LEFT_LITTLE, /** little finger (left hand) */
RIGHT_THUMB, /** thumb (right hand) */
RIGHT_INDEX, /** index finger (right hand) */
RIGHT_MIDDLE, /** middle finger (right hand) */
RIGHT_RING, /** ring finger (right hand) */
RIGHT_LITTLE, /** little finger (right hand) */
};
static const char *fingerstr(guint32 fingernum)
{
switch (fingernum) {
case LEFT_THUMB:
return "Left thumb";
case LEFT_INDEX:
return "Left index finger";
case LEFT_MIDDLE:
return "Left middle finger";
case LEFT_RING:
return "Left ring finger";
case LEFT_LITTLE:
return "Left little finger";
case RIGHT_THUMB:
return "Right thumb";
case RIGHT_INDEX:
return "Right index finger";
case RIGHT_MIDDLE:
return "Right middle finger";
case RIGHT_RING:
return "Right ring finger";
case RIGHT_LITTLE:
return "Right little finger";
default:
return "Unknown finger";
}
}
static void create_proxy(void)
{
GError *error = NULL;
connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
if (connection == NULL)
g_error("Failed to connect to session bus: %s", error->message);
proxy = dbus_g_proxy_new_for_name_owner(connection,
"net.reactivated.Fprint", "/net/reactivated/Fprint",
"net.reactivated.Fprint", &error);
if (proxy == NULL)
g_error("Failed to create proxy: %s", error->message);
}
static guint32 open_device(void)
{
GError *error = NULL;
GArray *device_ids;
char **drvnames;
char **fullnames;
guint i;
guint32 device_id;
if (!net_reactivated_Fprint_list_devices(proxy, &device_ids, &drvnames,
&fullnames, &error))
g_error("list_devices failed: %s", error->message);
if (device_ids->len == 0) {
g_print("No devices found\n");
exit(1);
}
g_print("found %d devices\n", device_ids->len);
for (i = 0; i < device_ids->len; i++) {
g_print("Device #%d: %s (%s)\n", g_array_index(device_ids, guint32, i),
fullnames[i], drvnames[i]);
}
device_id = g_array_index(device_ids, int, 0);
g_strfreev(drvnames);
g_strfreev(fullnames);
g_array_free(device_ids, TRUE);
g_print("using device #%d\n", device_id);
if (!net_reactivated_Fprint_claim_device(proxy, device_id, &error))
g_error("failed to claim device: %s", error->message);
return device_id;
}
static guint32 find_finger(guint32 device_id)
{
GError *error = NULL;
GArray *fingers;
guint i;
int fingernum;
guint32 print_id;
if (!net_reactivated_Fprint_list_enrolled_fingers(proxy, 0, &fingers, &error))
g_error("ListEnrolledFingers failed: %s", error->message);
if (fingers->len == 0) {
g_print("No fingers enrolled for this device.\n");
exit(1);
}
g_print("Listing enrolled fingers:\n");
for (i = 0; i < fingers->len; i++) {
fingernum = g_array_index(fingers, guint32, i);
g_print(" - #%d: %s\n", fingernum, fingerstr(fingernum));
}
fingernum = g_array_index(fingers, guint32, 0);
g_array_free(fingers, TRUE);
g_print("Verifying: %s\n", fingerstr(fingernum));
if (!net_reactivated_Fprint_load_print_data(proxy, device_id, fingernum, &print_id, &error))
g_error("LoadPrintData failed: %s", error->message);
return print_id;
}
static int do_verify(guint32 device_id, guint32 print_id)
{
GError *error;
gboolean more_results;
int result;
if (!net_reactivated_Fprint_verify_start(proxy, device_id, print_id, &error))
g_error("VerifyStart failed: %s", error->message);
do {
if (!net_reactivated_Fprint_get_verify_result(proxy, device_id, &result, &more_results, &error))
g_error("GetVerifyResult failed: %s", error->message);
g_print("Verify result: %s (%d)\n", verify_result_str(result), result);
} while (result != VERIFY_NO_MATCH && result != VERIFY_MATCH);
if (!net_reactivated_Fprint_verify_stop(proxy, device_id, &error))
g_error("VerifyStop failed: %s", error->message);
return result;
}
static void unload_print(guint32 device_id, guint32 print_id)
{
GError *error = NULL;
if (!net_reactivated_Fprint_unload_print_data(proxy, device_id, print_id, &error))
g_error("UnloadPrint failed: %s", error->message);
}
static void release_device(guint32 device_id)
{
GError *error = NULL;
if (!net_reactivated_Fprint_release_device(proxy, device_id, &error))
g_error("ReleaseDevice failed: %s", error->message);
}
int main(int argc, char **argv)
{
GMainLoop *loop;
guint32 device_id;
guint32 print_id;
int verify_result;
g_type_init();
loop = g_main_loop_new(NULL, FALSE);
create_proxy();
device_id = open_device();
print_id = find_finger(device_id);
verify_result = do_verify(device_id, print_id);
unload_print(device_id, print_id);
release_device(device_id);
return 0;
}
BUILT_SOURCES = server-bindings.h
noinst_HEADERS = $(BUILT_SOURCES)
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = fprintd.xml
bin_PROGRAMS = fprintd
fprintd_SOURCES = main.c
fprintd_LDADD = $(GLIB_LIBS) $(DBUS_GLIB_LIBS) $(FPRINT_LIBS)
fprintd_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) $(DBUS_GLIB_CFLAGS) $(FPRINT_CFLAGS)
server-bindings.h: fprintd.xml
dbus-binding-tool --prefix=fprint --mode=glib-server $< --output=$@
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/net/reactivated/Fprint">
<interface name="net.reactivated.Fprint">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="fprint" />
<method name="ListDevices">
<arg type="au" name="device_ids" direction="out" />
<arg type="as" name="drv_names" direction="out" />
<arg type="as" name="drv_full_names" direction="out" />
</method>
<method name="ClaimDevice">
<arg type="u" name="device_id" direction="in" />
</method>
<method name="ReleaseDevice">
<arg type="u" name="device_id" direction="in" />
</method>
<method name="ListEnrolledFingers">
<arg type="u" name="device_id" direction="in" />
<arg type="au" name="enrolled_fingers" direction="out" />
</method>
<method name="LoadPrintData">
<arg type="u" name="device_id" direction="in" />
<arg type="u" name="finger_num" direction="in" />
<arg type="u" name="print_id" direction="out" />
</method>
<method name="UnloadPrintData">
<arg type="u" name="device_id" direction="in" />
<arg type="u" name="print_id" direction="in" />
</method>
<method name="VerifyStart">
<arg type="u" name="device_id" direction="in" />
<arg type="u" name="print_id" direction="in" />
</method>
<method name="GetVerifyResult">
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
<arg type="u" name="device_id" direction="in" />
<arg type="i" name="result" direction="out" />
<arg type="b" name="more_results" direction="out" />
</method>
<method name="VerifyStop">
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
<arg type="u" name="device_id" direction="in" />
</method>
</interface>
</node>
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment